Continue populating legacy data structures.
Previous work implemented getRequestedPermissions() by dynamically
constructing the legacy list of requested permissions, along with a
deprecation message to migrate to ParsedUsesPermission, but there
are too many callers to migrate at this stage of the release.
For now, to mitigate performance issues that arose, this change
builds a parallel list of requested permissions to avoid the
overhead of dynamically building the legacy list.
Bug: 183223056
Test: atest FrameworksServicesTests:PackageParserTest
Test: atest com.android.server.pm.parsing
Test: atest -p core/java/android/content/pm \
core/java/com/android/internal/content \
services/core/java/com/android/server/pm \
services/tests/servicestests/src/com/android/server/pm
Change-Id: I538fbc12a9fd34f5ad5d63177ac5a2cb9a1ff3ce
This commit is contained in:
committed by
Jeff Sharkey
parent
456fb2e78b
commit
2d9355bc44
@@ -227,6 +227,14 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
@NonNull
|
||||
@DataClass.ParcelWith(ForInternedStringList.class)
|
||||
protected List<String> adoptPermissions = emptyList();
|
||||
/**
|
||||
* @deprecated consider migrating to {@link #getUsesPermissions} which has
|
||||
* more parsed details, such as flags
|
||||
*/
|
||||
@NonNull
|
||||
@Deprecated
|
||||
@DataClass.ParcelWith(ForInternedStringList.class)
|
||||
protected List<String> requestedPermissions = emptyList();
|
||||
|
||||
@NonNull
|
||||
private List<ParsedUsesPermission> usesPermissions = emptyList();
|
||||
@@ -701,6 +709,11 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
@Override
|
||||
public ParsingPackageImpl addUsesPermission(ParsedUsesPermission permission) {
|
||||
this.usesPermissions = CollectionUtils.add(this.usesPermissions, permission);
|
||||
|
||||
// Continue populating legacy data structures to avoid performance
|
||||
// issues until all that code can be migrated
|
||||
this.requestedPermissions = CollectionUtils.add(this.requestedPermissions, permission.name);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1142,6 +1155,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
dest.writeByteArray(this.restrictUpdateHash);
|
||||
dest.writeStringList(this.originalPackages);
|
||||
sForInternedStringList.parcel(this.adoptPermissions, dest, flags);
|
||||
sForInternedStringList.parcel(this.requestedPermissions, dest, flags);
|
||||
dest.writeTypedList(this.usesPermissions);
|
||||
sForInternedStringList.parcel(this.implicitPermissions, dest, flags);
|
||||
sForStringSet.parcel(this.upgradeKeySets, dest, flags);
|
||||
@@ -1264,6 +1278,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
this.restrictUpdateHash = in.createByteArray();
|
||||
this.originalPackages = in.createStringArrayList();
|
||||
this.adoptPermissions = sForInternedStringList.unparcel(in);
|
||||
this.requestedPermissions = sForInternedStringList.unparcel(in);
|
||||
this.usesPermissions = in.createTypedArrayList(ParsedUsesPermission.CREATOR);
|
||||
this.implicitPermissions = sForInternedStringList.unparcel(in);
|
||||
this.upgradeKeySets = sForStringSet.unparcel(in);
|
||||
@@ -1558,15 +1573,14 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
|
||||
return adoptPermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated consider migrating to {@link #getUsesPermissions} which has
|
||||
* more parsed details, such as flags
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<String> getRequestedPermissions() {
|
||||
final List<ParsedUsesPermission> usesPermissions = getUsesPermissions();
|
||||
final int size = usesPermissions.size();
|
||||
final List<String> requestedPermissions = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
requestedPermissions.add(usesPermissions.get(i).name);
|
||||
}
|
||||
return requestedPermissions;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user