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

Commit 3d38ba1f authored by Atanas Kirilov's avatar Atanas Kirilov Committed by Android (Google) Code Review
Browse files

Merge changes from topic "am-8acf63d1-cfe0-4950-98c3-1d2367987749" into cw-f-dev

* changes:
  [automerger] RESTRICT AUTOMERGE: Backporting of b/77821568 am: 4bc1c244 am: b9c3b099 am: 24d40209
  [automerger] RESTRICT AUTOMERGE: Backporting of b/77821568 am: 4bc1c244 am: b9c3b099
  [automerger] RESTRICT AUTOMERGE: Backporting of b/77821568 am: 4bc1c244
  RESTRICT AUTOMERGE: Backporting of b/77821568
parents 0c8cc417 0eda2602
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -3823,13 +3823,25 @@ public class PackageManagerService extends IPackageManager.Stub {
     */
    void enforceCrossUserPermission(int callingUid, int userId, boolean requireFullPermission,
            boolean checkShell, String message) {
        enforceCrossUserPermission(
              callingUid,
              userId,
              requireFullPermission,
              checkShell,
              false,
              message);
    }
    private void enforceCrossUserPermission(int callingUid, int userId,
            boolean requireFullPermission, boolean checkShell,
            boolean requirePermissionWhenSameUser, String message) {
        if (userId < 0) {
            throw new IllegalArgumentException("Invalid userId " + userId);
        }
        if (checkShell) {
            enforceShellRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES, callingUid, userId);
        }
        if (userId == UserHandle.getUserId(callingUid)) return;
        if (!requirePermissionWhenSameUser && userId == UserHandle.getUserId(callingUid)) return;
        if (callingUid != Process.SYSTEM_UID && callingUid != 0) {
            if (requireFullPermission) {
                mContext.enforceCallingOrSelfPermission(
@@ -6272,7 +6284,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        flags = updateFlagsForPackage(flags, userId, null);
        final boolean listUninstalled = (flags & MATCH_UNINSTALLED_PACKAGES) != 0;
        enforceCrossUserPermission(Binder.getCallingUid(), userId,
                true /* requireFullPermission */, false /* checkShell */,
                false /* requireFullPermission */, false /* checkShell */,
                "get installed packages");
        // writer
@@ -6380,10 +6392,18 @@ public class PackageManagerService extends IPackageManager.Stub {
    @Override
    public ParceledListSlice<ApplicationInfo> getInstalledApplications(int flags, int userId) {
        final int callingUid = Binder.getCallingUid();
        if (!sUserManager.exists(userId)) return ParceledListSlice.emptyList();
        flags = updateFlagsForApplication(flags, userId, null);
        final boolean listUninstalled = (flags & MATCH_UNINSTALLED_PACKAGES) != 0;
        enforceCrossUserPermission(
            callingUid,
            userId,
            false /* requireFullPermission */,
            false /* checkShell */,
            "get installed application info");
        // writer
        synchronized (mPackages) {
            ArrayList<ApplicationInfo> list;