Example usage for android.os Parcel unmarshall

List of usage examples for android.os Parcel unmarshall

Introduction

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

Prototype

public final void unmarshall(byte[] data, int offset, int length) 

Source Link

Document

Set the bytes in data to be the raw bytes of this Parcel.

Usage

From source file:com.google.android.gms.internal.fv.java

public static fv m1980e(byte[] bArr) {
    Parcel obtain = Parcel.obtain();
    obtain.unmarshall(bArr, 0, bArr.length);
    obtain.setDataPosition(0);//from w w  w. j av a  2s .  co  m
    fv D = CREATOR.m622D(obtain);
    obtain.recycle();
    return D;
}

From source file:org.droid2droid.internal.AbstractRemoteAndroidImpl.java

protected final void updateData(Parcel data) // TODO: a placer plutot cot serveur
{
    if (UPDATE_PARCEL) {
        int v = VERSION.SDK_INT;
        data.setDataPosition(0);/*from  w ww  .ja  v a2  s.  c  o  m*/
        if (v >= 10) // Gingerbread_MR1+
        {
            data.readInt();
        }
        String enforceInterfaceName = data.readString(); // Read the interface name (see Parcel.cpp)
        assert (enforceInterfaceName != null);
        byte[] bufDatas = data.marshall(); // Return all the buffer (with the specific enforceInterface
        int startDatas = data.dataPosition(); // Position after the first string

        // Create a new one with interface name + buffers
        Parcel p = Parcel.obtain();
        p.setDataPosition(0);
        p.writeString(enforceInterfaceName);
        int sizeInterface = p.dataPosition();
        byte[] bufInterface = p.marshall(); // Part of buffer only for the string
        p.recycle();

        // Extract the rest of the buffer
        byte[] result = new byte[sizeInterface + bufDatas.length - startDatas];
        System.arraycopy(bufInterface, 0, result, 0, sizeInterface);
        System.arraycopy(bufDatas, startDatas, result, sizeInterface, bufDatas.length - startDatas);
        data.unmarshall(result, 0, result.length);
    }
}