Example usage for android.os Parcel readByteArray

List of usage examples for android.os Parcel readByteArray

Introduction

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

Prototype

public final void readByteArray(byte[] val) 

Source Link

Document

Read a byte[] object from the parcel and copy it into the given byte array.

Usage

From source file:com.v2soft.dnremote.dao.Server.java

private static byte[] readIPAddr(Parcel in) {
    int count = in.readInt();
    byte[] res = new byte[count];
    in.readByteArray(res);
    return res;/*from w  ww .j a  va 2  s. co  m*/
}

From source file:Main.java

/**
 * Repairs the broken tag on HTC devices running Android 5.x
 * <p/>//from ww w .  ja  v a  2s.c  o  m
 * "It seems, the reason of this bug in TechExtras of NfcA is null. However, TechList contains MifareClassic." -bildin
 * For more information please refer to https://github.com/ikarus23/MifareClassicTool/issues/52#issuecomment-103797115
 * <p/>
 * Code source: https://github.com/ikarus23/MifareClassicTool/issues/52#issuecomment-104277445
 *
 * @param oTag The broken tag
 * @return The fixed tag
 */
public static Tag repairTag(Tag oTag) {
    if (oTag == null)
        return null;

    String[] sTechList = oTag.getTechList();

    Parcel oParcel, nParcel;

    oParcel = Parcel.obtain();
    oTag.writeToParcel(oParcel, 0);
    oParcel.setDataPosition(0);

    int len = oParcel.readInt();
    byte[] id = null;
    if (len >= 0) {
        id = new byte[len];
        oParcel.readByteArray(id);
    }
    int[] oTechList = new int[oParcel.readInt()];
    oParcel.readIntArray(oTechList);
    Bundle[] oTechExtras = oParcel.createTypedArray(Bundle.CREATOR);
    int serviceHandle = oParcel.readInt();
    int isMock = oParcel.readInt();
    IBinder tagService;
    if (isMock == 0) {
        tagService = oParcel.readStrongBinder();
    } else {
        tagService = null;
    }
    oParcel.recycle();

    int nfca_idx = -1;
    int mc_idx = -1;

    for (int idx = 0; idx < sTechList.length; idx++) {
        if (sTechList[idx].equals(NfcA.class.getName())) {
            nfca_idx = idx;
        } else if (sTechList[idx].equals(MifareClassic.class.getName())) {
            mc_idx = idx;
        }
    }

    if (nfca_idx >= 0 && mc_idx >= 0 && oTechExtras[mc_idx] == null) {
        oTechExtras[mc_idx] = oTechExtras[nfca_idx];
    } else {
        return oTag;
    }

    nParcel = Parcel.obtain();
    nParcel.writeInt(id.length);
    nParcel.writeByteArray(id);
    nParcel.writeInt(oTechList.length);
    nParcel.writeIntArray(oTechList);
    nParcel.writeTypedArray(oTechExtras, 0);
    nParcel.writeInt(serviceHandle);
    nParcel.writeInt(isMock);
    if (isMock == 0) {
        nParcel.writeStrongBinder(tagService);
    }
    nParcel.setDataPosition(0);

    Tag nTag = Tag.CREATOR.createFromParcel(nParcel);

    nParcel.recycle();

    return nTag;
}

From source file:com.jungle.base.utils.MiscUtils.java

public static byte[] readBytesFromParcel(Parcel source) {
    int len = source.readInt();
    if (len > 0) {
        byte[] buff = new byte[len];
        source.readByteArray(buff);
        return buff;
    }/*w  w w .  ja  v a  2 s  .  c o m*/

    return null;
}

From source file:com.google.sample.beaconservice.Beacon.java

private Beacon(Parcel source) {
    type = source.readString();/*from ww  w .j  a va  2s.  c om*/
    int len = source.readInt();
    id = new byte[len];
    source.readByteArray(id);
    status = source.readString();
    if (source.readInt() == 1) {
        placeId = source.readString();
    }
    if (source.readInt() == 1) {
        latitude = source.readDouble();
    }
    if (source.readInt() == 1) {
        longitude = source.readDouble();
    }
    if (source.readInt() == 1) {
        expectedStability = source.readString();
    }
    if (source.readInt() == 1) {
        description = source.readString();
    }
}

From source file:de.schildbach.wallet.data.PaymentIntent.java

private PaymentIntent(final Parcel in) {
    standard = (Standard) in.readSerializable();

    payeeName = in.readString();/*from   w w  w.  j av  a 2s .  c  om*/
    payeeVerifiedBy = in.readString();

    final int outputsLength = in.readInt();
    if (outputsLength > 0) {
        outputs = new Output[outputsLength];
        in.readTypedArray(outputs, Output.CREATOR);
    } else {
        outputs = null;
    }

    memo = in.readString();

    paymentUrl = in.readString();

    final int payeeDataLength = in.readInt();
    if (payeeDataLength > 0) {
        payeeData = new byte[payeeDataLength];
        in.readByteArray(payeeData);
    } else {
        payeeData = null;
    }

    paymentRequestUrl = in.readString();

    final int paymentRequestHashLength = in.readInt();
    if (paymentRequestHashLength > 0) {
        paymentRequestHash = new byte[paymentRequestHashLength];
        in.readByteArray(paymentRequestHash);
    } else {
        paymentRequestHash = null;
    }
}