Merge "Fix parsing code parcelling errors" into rvc-dev am: 2b220b4ef7
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15583462 Change-Id: Ifba815fef90ebfbac8b871b337baf8f87d1a2d27
This commit is contained in:
@@ -1007,7 +1007,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
sForInternedStringList.parcel(this.requestedPermissions, dest, flags);
|
||||
sForInternedStringList.parcel(this.implicitPermissions, dest, flags);
|
||||
sForStringSet.parcel(this.upgradeKeySets, dest, flags);
|
||||
dest.writeMap(this.keySetMapping);
|
||||
ParsingPackageUtils.writeKeySetMapping(dest, this.keySetMapping);
|
||||
sForInternedStringList.parcel(this.protectedBroadcasts, dest, flags);
|
||||
dest.writeTypedList(this.activities);
|
||||
dest.writeTypedList(this.receivers);
|
||||
@@ -1026,7 +1026,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
dest.writeBoolean(this.use32BitAbi);
|
||||
dest.writeBoolean(this.visibleToInstantApps);
|
||||
dest.writeBoolean(this.forceQueryable);
|
||||
dest.writeParcelableList(this.queriesIntents, flags);
|
||||
dest.writeTypedList(this.queriesIntents, flags);
|
||||
sForInternedStringList.parcel(this.queriesPackages, dest, flags);
|
||||
sForInternedStringSet.parcel(this.queriesProviders, dest, flags);
|
||||
dest.writeString(this.appComponentFactory);
|
||||
@@ -1169,7 +1169,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
this.requestedPermissions = sForInternedStringList.unparcel(in);
|
||||
this.implicitPermissions = sForInternedStringList.unparcel(in);
|
||||
this.upgradeKeySets = sForStringSet.unparcel(in);
|
||||
this.keySetMapping = in.readHashMap(boot);
|
||||
this.keySetMapping = ParsingPackageUtils.readKeySetMapping(in);
|
||||
this.protectedBroadcasts = sForInternedStringList.unparcel(in);
|
||||
|
||||
this.activities = in.createTypedArrayList(ParsedActivity.CREATOR);
|
||||
|
||||
@@ -84,6 +84,7 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.FileUtils;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
import android.os.Trace;
|
||||
import android.os.ext.SdkExtensions;
|
||||
@@ -2834,6 +2835,68 @@ public class ParsingPackageUtils {
|
||||
return sa.getNonResourceString(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the keyset mapping to the provided package. {@code null} mappings are permitted.
|
||||
*/
|
||||
public static void writeKeySetMapping(@NonNull Parcel dest,
|
||||
@NonNull Map<String, ArraySet<PublicKey>> keySetMapping) {
|
||||
if (keySetMapping == null) {
|
||||
dest.writeInt(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
final int N = keySetMapping.size();
|
||||
dest.writeInt(N);
|
||||
|
||||
for (String key : keySetMapping.keySet()) {
|
||||
dest.writeString(key);
|
||||
ArraySet<PublicKey> keys = keySetMapping.get(key);
|
||||
if (keys == null) {
|
||||
dest.writeInt(-1);
|
||||
continue;
|
||||
}
|
||||
|
||||
final int M = keys.size();
|
||||
dest.writeInt(M);
|
||||
for (int j = 0; j < M; j++) {
|
||||
dest.writeSerializable(keys.valueAt(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a keyset mapping from the given parcel at the given data position. May return
|
||||
* {@code null} if the serialized mapping was {@code null}.
|
||||
*/
|
||||
@NonNull
|
||||
public static ArrayMap<String, ArraySet<PublicKey>> readKeySetMapping(@NonNull Parcel in) {
|
||||
final int N = in.readInt();
|
||||
if (N == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayMap<String, ArraySet<PublicKey>> keySetMapping = new ArrayMap<>();
|
||||
for (int i = 0; i < N; ++i) {
|
||||
String key = in.readString();
|
||||
final int M = in.readInt();
|
||||
if (M == -1) {
|
||||
keySetMapping.put(key, null);
|
||||
continue;
|
||||
}
|
||||
|
||||
ArraySet<PublicKey> keys = new ArraySet<>(M);
|
||||
for (int j = 0; j < M; ++j) {
|
||||
PublicKey pk = (PublicKey) in.readSerializable();
|
||||
keys.add(pk);
|
||||
}
|
||||
|
||||
keySetMapping.put(key, keys);
|
||||
}
|
||||
|
||||
return keySetMapping;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback interface for retrieving information that may be needed while parsing
|
||||
* a package.
|
||||
|
||||
Reference in New Issue
Block a user