Java Code Examples for android.os.Parcel#readParcelableArray()

The following examples show how to use android.os.Parcel#readParcelableArray() .
Example 1
Project: Upchain-wallet   File: Transaction.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
protected Transaction(Parcel in) {
    hash = in.readString();
    error = in.readString();
    blockNumber = in.readString();
    timeStamp = in.readLong();
    nonce = in.readInt();
    from = in.readString();
    to = in.readString();
    value = in.readString();
    gas = in.readString();
    gasPrice = in.readString();
    input = in.readString();
    gasUsed = in.readString();
    Parcelable[] parcelableArray = in.readParcelableArray(TransactionOperation.class.getClassLoader());
    TransactionOperation[] operations = null;
    if (parcelableArray != null) {
        operations = Arrays.copyOf(parcelableArray, parcelableArray.length, TransactionOperation[].class);
    }
    this.operations = operations;
    this.contract = in.readString();
}
 
Example 2
Project: android_9.0.0_r45   File: RestrictionEntry.java    License: Apache License 2.0 6 votes vote down vote up
public RestrictionEntry(Parcel in) {
    mType = in.readInt();
    mKey = in.readString();
    mTitle = in.readString();
    mDescription = in.readString();
    mChoiceEntries = in.readStringArray();
    mChoiceValues = in.readStringArray();
    mCurrentValue = in.readString();
    mCurrentValues = in.readStringArray();
    Parcelable[] parcelables = in.readParcelableArray(null);
    if (parcelables != null) {
        mRestrictions = new RestrictionEntry[parcelables.length];
        for (int i = 0; i < parcelables.length; i++) {
            mRestrictions[i] = (RestrictionEntry) parcelables[i];
        }
    }
}
 
Example 3
Project: alpha-wallet-android   File: Transaction.java    License: MIT License 6 votes vote down vote up
protected Transaction(Parcel in)
{
	hash = in.readString();
	error = in.readString();
	blockNumber = in.readString();
	timeStamp = in.readLong();
	nonce = in.readInt();
	from = in.readString();
	to = in.readString();
	value = in.readString();
	gas = in.readString();
	gasPrice = in.readString();
	input = in.readString();
	gasUsed = in.readString();
	chainId = in.readInt();
	Parcelable[] parcelableArray = in.readParcelableArray(TransactionOperation.class.getClassLoader());
	TransactionOperation[] operations = null;
	if (parcelableArray != null)
	{
		operations = Arrays.copyOf(parcelableArray, parcelableArray.length, TransactionOperation[].class);
	}
	this.operations = operations;
}
 
Example 4
Project: android_9.0.0_r45   File: CharSequenceTransformation.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public CharSequenceTransformation createFromParcel(Parcel parcel) {
    final AutofillId[] ids = parcel.readParcelableArray(null, AutofillId.class);
    final Pattern[] regexs = (Pattern[]) parcel.readSerializable();
    final String[] substs = parcel.createStringArray();

    // Always go through the builder to ensure the data ingested by
    // the system obeys the contract of the builder to avoid attacks
    // using specially crafted parcels.
    final CharSequenceTransformation.Builder builder =
            new CharSequenceTransformation.Builder(ids[0], regexs[0], substs[0]);

    final int size = ids.length;
    for (int i = 1; i < size; i++) {
        builder.addField(ids[i], regexs[i], substs[i]);
    }
    return builder.build();
}
 
Example 5
Project: android_9.0.0_r45   File: BatchUpdates.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public BatchUpdates createFromParcel(Parcel parcel) {
    // Always go through the builder to ensure the data ingested by
    // the system obeys the contract of the builder to avoid attacks
    // using specially crafted parcels.
    final Builder builder = new Builder();
    final int[] ids = parcel.createIntArray();
    if (ids != null) {
        final InternalTransformation[] values =
            parcel.readParcelableArray(null, InternalTransformation.class);
        final int size = ids.length;
        for (int i = 0; i < size; i++) {
            builder.transformChild(ids[i], values[i]);
        }
    }
    final RemoteViews updates = parcel.readParcelable(null);
    if (updates != null) {
        builder.updateTemplate(updates);
    }
    return builder.build();
}
 
Example 6
Project: android_9.0.0_r45   File: RadioManager.java    License: Apache License 2.0 6 votes vote down vote up
private ModuleProperties(Parcel in) {
    mId = in.readInt();
    String serviceName = in.readString();
    mServiceName = TextUtils.isEmpty(serviceName) ? "default" : serviceName;
    mClassId = in.readInt();
    mImplementor = in.readString();
    mProduct = in.readString();
    mVersion = in.readString();
    mSerial = in.readString();
    mNumTuners = in.readInt();
    mNumAudioSources = in.readInt();
    mIsInitializationRequired = in.readInt() == 1;
    mIsCaptureSupported = in.readInt() == 1;
    Parcelable[] tmp = in.readParcelableArray(BandDescriptor.class.getClassLoader());
    mBands = new BandDescriptor[tmp.length];
    for (int i = 0; i < tmp.length; i++) {
        mBands[i] = (BandDescriptor) tmp[i];
    }
    mIsBgScanSupported = in.readInt() == 1;
    mSupportedProgramTypes = arrayToSet(in.createIntArray());
    mSupportedIdentifierTypes = arrayToSet(in.createIntArray());
    mDabFrequencyTable = Utils.readStringIntMap(in);
    mVendorInfo = Utils.readStringMap(in);
}
 
Example 7
Project: android_9.0.0_r45   File: UsbDevice.java    License: Apache License 2.0 6 votes vote down vote up
public UsbDevice createFromParcel(Parcel in) {
    String name = in.readString();
    int vendorId = in.readInt();
    int productId = in.readInt();
    int clasz = in.readInt();
    int subClass = in.readInt();
    int protocol = in.readInt();
    String manufacturerName = in.readString();
    String productName = in.readString();
    String version = in.readString();
    String serialNumber = in.readString();
    Parcelable[] configurations = in.readParcelableArray(UsbInterface.class.getClassLoader());
    UsbDevice device = new UsbDevice(name, vendorId, productId, clasz, subClass, protocol,
                         manufacturerName, productName, version, serialNumber);
    device.setConfigurations(configurations);
    return device;
}
 
Example 8
Project: ETHWallet   File: Transaction.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected Transaction(Parcel in) {
    hash = in.readString();
    error = in.readString();
    blockNumber = in.readString();
    timeStamp = in.readLong();
    nonce = in.readInt();
    from = in.readString();
    to = in.readString();
    value = in.readString();
    gas = in.readString();
    gasPrice = in.readString();
    input = in.readString();
    gasUsed = in.readString();
    Parcelable[] parcelableArray = in.readParcelableArray(TransactionOperation.class.getClassLoader());
    TransactionOperation[] operations = null;
    if (parcelableArray != null) {
        operations = Arrays.copyOf(parcelableArray, parcelableArray.length, TransactionOperation[].class);
    }
    this.operations = operations;
}
 
Example 9
Project: epoxy   File: ViewHolderState.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ViewState createFromParcel(Parcel source, ClassLoader loader) {
  int size = source.readInt();
  int[] keys = new int[size];
  source.readIntArray(keys);
  Parcelable[] values = source.readParcelableArray(loader);
  return new ViewState(size, keys, values);
}
 
Example 10
Project: Firefly   File: ParcelableTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSupportParcelArray() throws Exception {
    Parcel parcel = Parcel.obtain();
    TestStruct struct = new TestStruct();
    struct.a = 321;
    struct.e = TestEnum.A;
    struct.bin = new byte[]{123};
    parcel.writeParcelableArray(new TestStruct[]{new TestStruct(), struct}, 0);
    parcel.setDataPosition(0);
    TestStruct readStruct = (TestStruct) parcel.readParcelableArray(getClass().getClassLoader())[1];
    Assert.assertEquals(struct.a, readStruct.a);
    Assert.assertEquals(struct.e, readStruct.e);
    Assert.assertArrayEquals(struct.bin, readStruct.bin);
}
 
Example 11
Project: android_9.0.0_r45   File: UsbInterface.java    License: Apache License 2.0 5 votes vote down vote up
public UsbInterface createFromParcel(Parcel in) {
    int id = in.readInt();
    int alternateSetting = in.readInt();
    String name = in.readString();
    int Class = in.readInt();
    int subClass = in.readInt();
    int protocol = in.readInt();
    Parcelable[] endpoints = in.readParcelableArray(UsbEndpoint.class.getClassLoader());
    UsbInterface intf = new UsbInterface(id, alternateSetting, name, Class, subClass, protocol);
    intf.setEndpoints(endpoints);
    return intf;
}
 
Example 12
Project: android_9.0.0_r45   File: UsbConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
public UsbConfiguration createFromParcel(Parcel in) {
    int id = in.readInt();
    String name = in.readString();
    int attributes = in.readInt();
    int maxPower = in.readInt();
    Parcelable[] interfaces = in.readParcelableArray(UsbInterface.class.getClassLoader());
    UsbConfiguration configuration = new UsbConfiguration(id, name, attributes, maxPower);
    configuration.setInterfaces(interfaces);
    return configuration;
}
 
Example 13
Project: android_9.0.0_r45   File: GestureDescription.java    License: Apache License 2.0 5 votes vote down vote up
public GestureStep(Parcel parcel) {
    timeSinceGestureStart = parcel.readLong();
    Parcelable[] parcelables =
            parcel.readParcelableArray(TouchPoint.class.getClassLoader());
    numTouchPoints = (parcelables == null) ? 0 : parcelables.length;
    touchPoints = new TouchPoint[numTouchPoints];
    for (int i = 0; i < numTouchPoints; i++) {
        touchPoints[i] = (TouchPoint) parcelables[i];
    }
}
 
Example 14
Project: android_9.0.0_r45   File: ShortcutInfo.java    License: Apache License 2.0 4 votes vote down vote up
private ShortcutInfo(Parcel source) {
    final ClassLoader cl = getClass().getClassLoader();

    mUserId = source.readInt();
    mId = source.readString();
    mPackageName = source.readString();
    mActivity = source.readParcelable(cl);
    mFlags = source.readInt();
    mIconResId = source.readInt();
    mLastChangedTimestamp = source.readLong();
    mDisabledReason = source.readInt();

    if (source.readInt() == 0) {
        return; // key information only.
    }

    mIcon = source.readParcelable(cl);
    mTitle = source.readCharSequence();
    mTitleResId = source.readInt();
    mText = source.readCharSequence();
    mTextResId = source.readInt();
    mDisabledMessage = source.readCharSequence();
    mDisabledMessageResId = source.readInt();
    mIntents = source.readParcelableArray(cl, Intent.class);
    mIntentPersistableExtrases = source.readParcelableArray(cl, PersistableBundle.class);
    mRank = source.readInt();
    mExtras = source.readParcelable(cl);
    mBitmapPath = source.readString();

    mIconResName = source.readString();
    mTitleResName = source.readString();
    mTextResName = source.readString();
    mDisabledMessageResName = source.readString();

    int N = source.readInt();
    if (N == 0) {
        mCategories = null;
    } else {
        mCategories = new ArraySet<>(N);
        for (int i = 0; i < N; i++) {
            mCategories.add(source.readString().intern());
        }
    }
}
 
Example 15
Project: android_9.0.0_r45   File: FillResponse.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public FillResponse createFromParcel(Parcel parcel) {
    // Always go through the builder to ensure the data ingested by
    // the system obeys the contract of the builder to avoid attacks
    // using specially crafted parcels.
    final Builder builder = new Builder();
    final ParceledListSlice<Dataset> datasetSlice = parcel.readParcelable(null);
    final List<Dataset> datasets = (datasetSlice != null) ? datasetSlice.getList() : null;
    final int datasetCount = (datasets != null) ? datasets.size() : 0;
    for (int i = 0; i < datasetCount; i++) {
        builder.addDataset(datasets.get(i));
    }
    builder.setSaveInfo(parcel.readParcelable(null));
    builder.setClientState(parcel.readParcelable(null));

    // Sets authentication state.
    final AutofillId[] authenticationIds = parcel.readParcelableArray(null,
            AutofillId.class);
    final IntentSender authentication = parcel.readParcelable(null);
    final RemoteViews presentation = parcel.readParcelable(null);
    if (authenticationIds != null) {
        builder.setAuthentication(authenticationIds, authentication, presentation);
    }
    final RemoteViews header = parcel.readParcelable(null);
    if (header != null) {
        builder.setHeader(header);
    }
    final RemoteViews footer = parcel.readParcelable(null);
    if (footer != null) {
        builder.setFooter(footer);
    }

    builder.setIgnoredIds(parcel.readParcelableArray(null, AutofillId.class));
    final long disableDuration = parcel.readLong();
    if (disableDuration > 0) {
        builder.disableAutofill(disableDuration);
    }
    final AutofillId[] fieldClassifactionIds =
            parcel.readParcelableArray(null, AutofillId.class);
    if (fieldClassifactionIds != null) {
        builder.setFieldClassificationIds(fieldClassifactionIds);
    }
    builder.setFlags(parcel.readInt());

    final FillResponse response = builder.build();
    response.setRequestId(parcel.readInt());

    return response;
}
 
Example 16
Project: android_9.0.0_r45   File: OptionalValidators.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public OptionalValidators createFromParcel(Parcel parcel) {
    return new OptionalValidators(parcel
        .readParcelableArray(null, InternalValidator.class));
}
 
Example 17
Project: android_9.0.0_r45   File: LuhnChecksumValidator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public LuhnChecksumValidator createFromParcel(Parcel parcel) {
    return new LuhnChecksumValidator(parcel.readParcelableArray(null, AutofillId.class));
}
 
Example 18
Project: android_9.0.0_r45   File: SaveInfo.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public SaveInfo createFromParcel(Parcel parcel) {

    // Always go through the builder to ensure the data ingested by
    // the system obeys the contract of the builder to avoid attacks
    // using specially crafted parcels.
    final int type = parcel.readInt();
    final AutofillId[] requiredIds = parcel.readParcelableArray(null, AutofillId.class);
    final Builder builder = requiredIds != null
            ? new Builder(type, requiredIds)
            : new Builder(type);
    final AutofillId[] optionalIds = parcel.readParcelableArray(null, AutofillId.class);
    if (optionalIds != null) {
        builder.setOptionalIds(optionalIds);
    }

    builder.setNegativeAction(parcel.readInt(), parcel.readParcelable(null));
    builder.setDescription(parcel.readCharSequence());
    final CustomDescription customDescripton = parcel.readParcelable(null);
    if (customDescripton != null) {
        builder.setCustomDescription(customDescripton);
    }
    final InternalValidator validator = parcel.readParcelable(null);
    if (validator != null) {
        builder.setValidator(validator);
    }
    final InternalSanitizer[] sanitizers =
            parcel.readParcelableArray(null, InternalSanitizer.class);
    if (sanitizers != null) {
        final int size = sanitizers.length;
        for (int i = 0; i < size; i++) {
            final AutofillId[] autofillIds =
                    parcel.readParcelableArray(null, AutofillId.class);
            builder.addSanitizer(sanitizers[i], autofillIds);
        }
    }
    final AutofillId triggerId = parcel.readParcelable(null);
    if (triggerId != null) {
        builder.setTriggerId(triggerId);
    }
    builder.setFlags(parcel.readInt());
    return builder.build();
}
 
Example 19
Project: android_9.0.0_r45   File: CaptureRequest.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Expand this object from a Parcel.
 * Hidden since this breaks the immutability of CaptureRequest, but is
 * needed to receive CaptureRequests with aidl.
 *
 * @param in The parcel from which the object should be read
 * @hide
 */
private void readFromParcel(Parcel in) {
    int physicalCameraCount = in.readInt();
    if (physicalCameraCount <= 0) {
        throw new RuntimeException("Physical camera count" + physicalCameraCount +
                " should always be positive");
    }

    //Always start with the logical camera id
    mLogicalCameraId = in.readString();
    mLogicalCameraSettings = new CameraMetadataNative();
    mLogicalCameraSettings.readFromParcel(in);
    setNativeInstance(mLogicalCameraSettings);
    mPhysicalCameraSettings.put(mLogicalCameraId, mLogicalCameraSettings);
    for (int i = 1; i < physicalCameraCount; i++) {
        String physicalId = in.readString();
        CameraMetadataNative physicalCameraSettings = new CameraMetadataNative();
        physicalCameraSettings.readFromParcel(in);
        mPhysicalCameraSettings.put(physicalId, physicalCameraSettings);
    }

    mIsReprocess = (in.readInt() == 0) ? false : true;
    mReprocessableSessionId = CameraCaptureSession.SESSION_ID_NONE;

    synchronized (mSurfacesLock) {
        mSurfaceSet.clear();
        Parcelable[] parcelableArray = in.readParcelableArray(Surface.class.getClassLoader());
        if (parcelableArray != null) {
            for (Parcelable p : parcelableArray) {
                Surface s = (Surface) p;
                mSurfaceSet.add(s);
            }
        }
        // Intentionally disallow java side readFromParcel to receive streamIdx/surfaceIdx
        // Since there is no good way to convert indexes back to Surface
        int streamSurfaceSize = in.readInt();
        if (streamSurfaceSize != 0) {
            throw new RuntimeException("Reading cached CaptureRequest is not supported");
        }
    }
}
 
Example 20
Project: kernel_adiutor   File: Tab.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Tab createFromParcel(Parcel parcel) {
    Tab tab = new Tab(null);
    tab.setTitle(parcel.readString());

    List<Simple> simples = new ArrayList<>();
    List<Divider> dividers = new ArrayList<>();
    List<EditText> editTexts = new ArrayList<>();
    List<Information> informations = new ArrayList<>();
    List<Popup> popups = new ArrayList<>();
    List<SeekBar> seekBars = new ArrayList<>();
    List<Switcher> switchers = new ArrayList<>();
    List<Progress> progresses = new ArrayList<>();

    for (Parcelable simple : parcel.readParcelableArray(Simple.class.getClassLoader()))
        simples.add((Simple) simple);
    for (Parcelable divider : parcel.readParcelableArray(Divider.class.getClassLoader()))
        dividers.add((Divider) divider);
    for (Parcelable edittext : parcel.readParcelableArray(EditText.class.getClassLoader()))
        editTexts.add((EditText) edittext);
    for (Parcelable information : parcel.readParcelableArray(Information.class.getClassLoader()))
        informations.add((Information) information);
    for (Parcelable popup : parcel.readParcelableArray(Popup.class.getClassLoader()))
        popups.add((Popup) popup);
    for (Parcelable seekbar : parcel.readParcelableArray(SeekBar.class.getClassLoader()))
        seekBars.add((SeekBar) seekbar);
    for (Parcelable switcher : parcel.readParcelableArray(Switcher.class.getClassLoader()))
        switchers.add((Switcher) switcher);
    for (Parcelable progress : parcel.readParcelableArray(Progress.class.getClassLoader()))
        progresses.add((Progress) progress);

    List<Item> items = new ArrayList<>();
    items.addAll(simples);
    items.addAll(dividers);
    items.addAll(editTexts);
    items.addAll(informations);
    items.addAll(popups);
    items.addAll(seekBars);
    items.addAll(switchers);
    items.addAll(progresses);
    for (int i = 0; i < items.size(); i++)
        for (Item item : items) if (item.getId() == i) tab.addItem(item);

    tab.setPackageName(parcel.readString());
    tab.setOnRefreshPendingListener((PendingIntent) parcel.readParcelable(PendingIntent.class.getClassLoader()),
            parcel.readInt());

    return tab;
}