Example usage for android.os Parcel writeStrongBinder

List of usage examples for android.os Parcel writeStrongBinder

Introduction

In this page you can find the example usage for android.os Parcel writeStrongBinder.

Prototype

public final void writeStrongBinder(IBinder val) 

Source Link

Document

Write an object into the parcel at the current dataPosition(), growing dataCapacity() if needed.

Usage

From source file:edu.umich.flowfence.common.CallParam.java

@Override
public void writeToParcel(Parcel dest, int flags) {
    int startPos = dest.dataPosition();
    if (payload == null) {
        setType(TYPE_NULL);//  www. ja  va 2s .  c om
    }

    dest.writeInt(header);
    switch (getType()) {
    case TYPE_NULL:
        // NULL: no need to write any data
        break;
    case TYPE_DATA:
        // DATA: write parceled data as byte[], so it can be skipped
        // without running untrusted code
        ParceledPayload parceled = (payload instanceof ParceledPayload) ? (ParceledPayload) payload
                : ParceledPayload.create(payload);
        parceled.writeToParcel(dest, flags);
        break;
    case TYPE_HANDLE:
        dest.writeStrongBinder((IBinder) payload);
        break;
    default:
        throw new IllegalArgumentException(String.format("Unknown CallParam type 0x%02x", header & MASK_TYPE));
    }
    //Log.d(TAG, String.format("Wrote (%d bytes @0x%x) %s", dest.dataPosition() - startPos, startPos, this));
}