Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69a3f399 authored by Nikita Ioffe's avatar Nikita Ioffe
Browse files

Teach PackageManager.getApplicationInfo about MATCH_APEX

Test: atest android.content.pm.cts.PackageManagerTest#testGetApplicationInfo_ApexSupported_MatchesApex
Bug: 155092136
Change-Id: I489e186242d4db4de4753a11e90ce23e35f2aa80
parent 0f309dc0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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 {}
+15 −0
Original line number Diff line number Diff line
@@ -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;
            }