Commit 4921986d authored by Fyodor Kupolov's avatar Fyodor Kupolov

Use concrete CREATOR instance for parceling lists

Replaced readTypedArrayList/writeTypedArrayList with
writeTypedList/createTypedArrayList(CREATOR)

Bug: 71508348
Test: CtsAutoFillServiceTestCases pass
Merged-In: I2a8321023b40cc74b7026eb0fb32a9cc5f5543a9
Change-Id: Id17d02e40a4ae567bf2d74d2ea8ba4d8a943bdb7
parent 38860f2c
......@@ -1279,6 +1279,13 @@ public final class Parcel {
* @see Parcelable
*/
public final <T extends Parcelable> void writeTypedList(List<T> val) {
writeTypedList(val, 0);
}
/**
* @hide
*/
public <T extends Parcelable> void writeTypedList(List<T> val, int parcelableFlags) {
if (val == null) {
writeInt(-1);
return;
......@@ -1287,13 +1294,7 @@ public final class Parcel {
int i=0;
writeInt(N);
while (i < N) {
T item = val.get(i);
if (item != null) {
writeInt(1);
item.writeToParcel(this, 0);
} else {
writeInt(0);
}
writeTypedObject(val.get(i), parcelableFlags);
i++;
}
}
......
......@@ -315,8 +315,8 @@ public final class Dataset implements Parcelable {
@Override
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeParcelable(mPresentation, flags);
parcel.writeTypedArrayList(mFieldIds, flags);
parcel.writeTypedArrayList(mFieldValues, flags);
parcel.writeTypedList(mFieldIds, flags);
parcel.writeTypedList(mFieldValues, flags);
parcel.writeParcelableList(mFieldPresentations, flags);
parcel.writeParcelable(mAuthentication, flags);
parcel.writeString(mId);
......@@ -332,8 +332,9 @@ public final class Dataset implements Parcelable {
final Builder builder = (presentation == null)
? new Builder()
: new Builder(presentation);
final ArrayList<AutofillId> ids = parcel.readTypedArrayList(null);
final ArrayList<AutofillValue> values = parcel.readTypedArrayList(null);
final ArrayList<AutofillId> ids = parcel.createTypedArrayList(AutofillId.CREATOR);
final ArrayList<AutofillValue> values =
parcel.createTypedArrayList(AutofillValue.CREATOR);
final ArrayList<RemoteViews> presentations = new ArrayList<>();
parcel.readParcelableList(presentations, null);
final int idCount = (ids != null) ? ids.size() : 0;
......
......@@ -19,9 +19,9 @@ package android.service.autofill;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Parcel;
import android.os.Parcelable;
import com.android.internal.util.Preconditions;
import java.util.ArrayList;
......@@ -45,7 +45,7 @@ public final class SaveRequest implements Parcelable {
}
private SaveRequest(@NonNull Parcel parcel) {
this(parcel.readTypedArrayList(null), parcel.readBundle());
this(parcel.createTypedArrayList(FillContext.CREATOR), parcel.readBundle());
}
/**
......@@ -57,7 +57,7 @@ public final class SaveRequest implements Parcelable {
/**
* Gets the extra client state returned from the last {@link
* AutofillService#onFillRequest(FillRequest, CancellationSignal, FillCallback)}
* AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback)}
* fill request}.
*
* @return The client state.
......@@ -73,7 +73,7 @@ public final class SaveRequest implements Parcelable {
@Override
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeTypedArrayList(mFillContexts, flags);
parcel.writeTypedList(mFillContexts, flags);
parcel.writeBundle(mClientState);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment