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

Commit 235d9053 authored by Fan Wu's avatar Fan Wu Committed by Nolen Johnson
Browse files

Check the permission of the callingUid instead of the calling package

Bug: 372671447
Test: atest
Flag: EXEMPT bug fix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e719575e92c1e6bd0b9088663e6c909bccf2b007)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:062c56f835bec484f97476f42bacd75058c9fb4a)
Merged-In: Ib36c0a3ba482bcddd53c2c09409ea818e6f43cad
Change-Id: Ib36c0a3ba482bcddd53c2c09409ea818e6f43cad
parent 6fcc2743
Loading
Loading
Loading
Loading
+9 −13
Original line number Diff line number Diff line
@@ -174,22 +174,18 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
        }
        String callingPackageName = null;
        try {
            callingPackageName = ActivityManager.getService()
                .getLaunchedFromPackage(activity.getActivityToken());
        } catch (Exception e) {
            return false;
        }
        if (TextUtils.isEmpty(callingPackageName)) {
            Log.w(TAG, "Not able to get calling package name for permission check");
            return false;
        }
        if (mPm.checkPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL, callingPackageName)
                != PackageManager.PERMISSION_GRANTED) {
            Log.w(TAG, "Package " + callingPackageName + " does not have required permission "
            int callerUid = ActivityManager.getService().getLaunchedFromUid(
                    activity.getActivityToken());
            if (ActivityManager.checkUidPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL,
                    callerUid) != PackageManager.PERMISSION_GRANTED) {
                Log.w(TAG, "Uid " + callerUid + " does not have required permission "
                        + Manifest.permission.INTERACT_ACROSS_USERS_FULL);
                return false;
            }
            return true;
        } catch (Exception e) {
            return false;
        }
    }

    protected void setIntentAndFinish(boolean finish, boolean appChanged) {