[automerger] RESTRICT AUTOMERGE: Backporting of b/77821568 am: 4bc1c2445c am: b9c3b099e4 am: 24d402096e

Change-Id: Ia7340c71283b7f88378e34584b373cce180262ec
This commit is contained in:
Android Build Merger (Role)
2018-06-13 18:09:32 +00:00

View File

@@ -3823,13 +3823,25 @@ public class PackageManagerService extends IPackageManager.Stub {
*/ */
void enforceCrossUserPermission(int callingUid, int userId, boolean requireFullPermission, void enforceCrossUserPermission(int callingUid, int userId, boolean requireFullPermission,
boolean checkShell, String message) { 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) { if (userId < 0) {
throw new IllegalArgumentException("Invalid userId " + userId); throw new IllegalArgumentException("Invalid userId " + userId);
} }
if (checkShell) { if (checkShell) {
enforceShellRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES, callingUid, userId); 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 (callingUid != Process.SYSTEM_UID && callingUid != 0) {
if (requireFullPermission) { if (requireFullPermission) {
mContext.enforceCallingOrSelfPermission( mContext.enforceCallingOrSelfPermission(
@@ -6272,7 +6284,7 @@ public class PackageManagerService extends IPackageManager.Stub {
flags = updateFlagsForPackage(flags, userId, null); flags = updateFlagsForPackage(flags, userId, null);
final boolean listUninstalled = (flags & MATCH_UNINSTALLED_PACKAGES) != 0; final boolean listUninstalled = (flags & MATCH_UNINSTALLED_PACKAGES) != 0;
enforceCrossUserPermission(Binder.getCallingUid(), userId, enforceCrossUserPermission(Binder.getCallingUid(), userId,
true /* requireFullPermission */, false /* checkShell */, false /* requireFullPermission */, false /* checkShell */,
"get installed packages"); "get installed packages");
// writer // writer
@@ -6380,10 +6392,18 @@ public class PackageManagerService extends IPackageManager.Stub {
@Override @Override
public ParceledListSlice<ApplicationInfo> getInstalledApplications(int flags, int userId) { public ParceledListSlice<ApplicationInfo> getInstalledApplications(int flags, int userId) {
final int callingUid = Binder.getCallingUid();
if (!sUserManager.exists(userId)) return ParceledListSlice.emptyList(); if (!sUserManager.exists(userId)) return ParceledListSlice.emptyList();
flags = updateFlagsForApplication(flags, userId, null); flags = updateFlagsForApplication(flags, userId, null);
final boolean listUninstalled = (flags & MATCH_UNINSTALLED_PACKAGES) != 0; final boolean listUninstalled = (flags & MATCH_UNINSTALLED_PACKAGES) != 0;
enforceCrossUserPermission(
callingUid,
userId,
false /* requireFullPermission */,
false /* checkShell */,
"get installed application info");
// writer // writer
synchronized (mPackages) { synchronized (mPackages) {
ArrayList<ApplicationInfo> list; ArrayList<ApplicationInfo> list;