Fix parsing code parcelling errors
Address problems reading/writing: - ParsedComponent mProperties - ParsingPackageImpl mKeySetMapping - ParsingPackageImpl mQueriesIntent Bug: 187043377 Test: atest com.android.server.pm.test.parsing.parcelling Change-Id: I5b33315f8248d5fcbdef2cc04ecf77cc18dbd7b6
This commit is contained in:
@@ -1164,7 +1164,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
|||||||
dest.writeTypedList(this.usesPermissions);
|
dest.writeTypedList(this.usesPermissions);
|
||||||
sForInternedStringList.parcel(this.implicitPermissions, dest, flags);
|
sForInternedStringList.parcel(this.implicitPermissions, dest, flags);
|
||||||
sForStringSet.parcel(this.upgradeKeySets, dest, flags);
|
sForStringSet.parcel(this.upgradeKeySets, dest, flags);
|
||||||
dest.writeMap(this.keySetMapping);
|
ParsingPackageUtils.writeKeySetMapping(dest, this.keySetMapping);
|
||||||
sForInternedStringList.parcel(this.protectedBroadcasts, dest, flags);
|
sForInternedStringList.parcel(this.protectedBroadcasts, dest, flags);
|
||||||
dest.writeTypedList(this.activities);
|
dest.writeTypedList(this.activities);
|
||||||
dest.writeTypedList(this.receivers);
|
dest.writeTypedList(this.receivers);
|
||||||
@@ -1180,7 +1180,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
|||||||
sForInternedString.parcel(this.volumeUuid, dest, flags);
|
sForInternedString.parcel(this.volumeUuid, dest, flags);
|
||||||
dest.writeParcelable(this.signingDetails, flags);
|
dest.writeParcelable(this.signingDetails, flags);
|
||||||
dest.writeString(this.mPath);
|
dest.writeString(this.mPath);
|
||||||
dest.writeParcelableList(this.queriesIntents, flags);
|
dest.writeTypedList(this.queriesIntents, flags);
|
||||||
sForInternedStringList.parcel(this.queriesPackages, dest, flags);
|
sForInternedStringList.parcel(this.queriesPackages, dest, flags);
|
||||||
sForInternedStringSet.parcel(this.queriesProviders, dest, flags);
|
sForInternedStringSet.parcel(this.queriesProviders, dest, flags);
|
||||||
dest.writeString(this.appComponentFactory);
|
dest.writeString(this.appComponentFactory);
|
||||||
@@ -1287,7 +1287,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
|||||||
this.usesPermissions = in.createTypedArrayList(ParsedUsesPermission.CREATOR);
|
this.usesPermissions = in.createTypedArrayList(ParsedUsesPermission.CREATOR);
|
||||||
this.implicitPermissions = sForInternedStringList.unparcel(in);
|
this.implicitPermissions = sForInternedStringList.unparcel(in);
|
||||||
this.upgradeKeySets = sForStringSet.unparcel(in);
|
this.upgradeKeySets = sForStringSet.unparcel(in);
|
||||||
this.keySetMapping = in.readHashMap(boot);
|
this.keySetMapping = ParsingPackageUtils.readKeySetMapping(in);
|
||||||
this.protectedBroadcasts = sForInternedStringList.unparcel(in);
|
this.protectedBroadcasts = sForInternedStringList.unparcel(in);
|
||||||
|
|
||||||
this.activities = in.createTypedArrayList(ParsedActivity.CREATOR);
|
this.activities = in.createTypedArrayList(ParsedActivity.CREATOR);
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ import android.net.Uri;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.FileUtils;
|
import android.os.FileUtils;
|
||||||
|
import android.os.Parcel;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
@@ -3159,6 +3160,68 @@ public class ParsingPackageUtils {
|
|||||||
return sa.getNonResourceString(index);
|
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
|
* Callback interface for retrieving information that may be needed while parsing
|
||||||
* a package.
|
* a package.
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ public abstract class ParsedComponent implements Parcelable {
|
|||||||
this.packageName = sForInternedString.unparcel(in);
|
this.packageName = sForInternedString.unparcel(in);
|
||||||
this.intents = sForIntentInfos.unparcel(in);
|
this.intents = sForIntentInfos.unparcel(in);
|
||||||
this.metaData = in.readBundle(boot);
|
this.metaData = in.readBundle(boot);
|
||||||
this.mProperties = in.createTypedArrayMap(Property.CREATOR);
|
this.mProperties = in.readHashMap(boot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|||||||
Reference in New Issue
Block a user