Teach PackageManager.getApplicationInfo about MATCH_APEX
Test: atest android.content.pm.cts.PackageManagerTest#testGetApplicationInfo_ApexSupported_MatchesApex Bug: 155092136 Change-Id: I489e186242d4db4de4753a11e90ce23e35f2aa80
This commit is contained in:
@@ -180,6 +180,7 @@ public abstract class PackageManager {
|
||||
GET_DISABLED_UNTIL_USED_COMPONENTS,
|
||||
GET_UNINSTALLED_PACKAGES,
|
||||
MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS,
|
||||
MATCH_APEX,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ApplicationInfoFlags {}
|
||||
|
||||
@@ -4944,6 +4944,21 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
}
|
||||
return ai;
|
||||
}
|
||||
if ((flags & PackageManager.MATCH_APEX) != 0) {
|
||||
// For APKs, PackageInfo.applicationInfo is not exactly the same as ApplicationInfo
|
||||
// returned from getApplicationInfo, but for APEX packages difference shouldn't be
|
||||
// very big.
|
||||
// TODO(b/155328545): generate proper application info for APEXes as well.
|
||||
int apexFlags = ApexManager.MATCH_ACTIVE_PACKAGE;
|
||||
if ((flags & PackageManager.MATCH_SYSTEM_ONLY) != 0) {
|
||||
apexFlags = ApexManager.MATCH_FACTORY_PACKAGE;
|
||||
}
|
||||
final PackageInfo pi = mApexManager.getPackageInfo(packageName, apexFlags);
|
||||
if (pi == null) {
|
||||
return null;
|
||||
}
|
||||
return pi.applicationInfo;
|
||||
}
|
||||
if ("android".equals(packageName)||"system".equals(packageName)) {
|
||||
return mAndroidApplication;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user