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

Commit 0de6a7f5 authored by Chad Brubaker's avatar Chad Brubaker
Browse files

Fall back to checking packages if one is not provided

Test: atest GsmCdmaPhoneTest.java
Change-Id: I81df49fd2f751ce28d834fc5d9cd254623930770
Fixes: 75450505
parent 6317df6e
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -20721,7 +20721,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    // BROADCASTS
    // =========================================================
    private boolean isInstantApp(ProcessRecord record, String callerPackage, int uid) {
    private boolean isInstantApp(ProcessRecord record, @Nullable String callerPackage, int uid) {
        if (UserHandle.getAppId(uid) < FIRST_APPLICATION_UID) {
            return false;
        }
@@ -20730,13 +20730,17 @@ public class ActivityManagerService extends IActivityManager.Stub
            return record.info.isInstantApp();
        }
        // Otherwise check with PackageManager.
        IPackageManager pm = AppGlobals.getPackageManager();
        try {
            if (callerPackage == null) {
            Slog.e(TAG, "isInstantApp with an application's uid, no record, and no package name");
            throw new IllegalArgumentException("Calling application did not provide package name");
                final String[] packageNames = pm.getPackagesForUid(uid);
                if (packageNames == null || packageNames.length == 0) {
                    throw new IllegalArgumentException("Unable to determine caller package name");
                }
                // Instant Apps can't use shared uids, so its safe to only check the first package.
                callerPackage = packageNames[0];
            }
            mAppOpsService.checkPackage(uid, callerPackage);
        try {
            IPackageManager pm = AppGlobals.getPackageManager();
            return pm.isInstantApp(callerPackage, UserHandle.getUserId(uid));
        } catch (RemoteException e) {
            Slog.e(TAG, "Error looking up if " + callerPackage + " is an instant app.", e);