Merge "Fix --user parameter when setting app op for shell with shell command." into sc-dev am: 58f468f186

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15150888

Change-Id: Iec8b20214bc6e7b5c7ab1e81d6a61dd56255cd62
This commit is contained in:
TreeHugger Robot
2021-06-30 06:27:50 +00:00
committed by Automerger Merge Worker

View File

@@ -4523,10 +4523,15 @@ public class AppOpsService extends IAppOpsService.Stub {
int callingUid = Binder.getCallingUid(); int callingUid = Binder.getCallingUid();
// Allow any attribution tag for resolvable uids // Allow any attribution tag for resolvable uids
int pkgUid = resolveUid(packageName); int pkgUid;
if (pkgUid != Process.INVALID_UID) { if (Objects.equals(packageName, "com.android.shell")) {
// Special case for the shell which is a package but should be able // Special case for the shell which is a package but should be able
// to bypass app attribution tag restrictions. // to bypass app attribution tag restrictions.
pkgUid = Process.SHELL_UID;
} else {
pkgUid = resolveUid(packageName);
}
if (pkgUid != Process.INVALID_UID) {
if (pkgUid != UserHandle.getAppId(uid)) { if (pkgUid != UserHandle.getAppId(uid)) {
String otherUidMessage = DEBUG ? " but it is really " + pkgUid : " but it is not"; String otherUidMessage = DEBUG ? " but it is really " + pkgUid : " but it is not";
throw new SecurityException("Specified package " + packageName + " under uid " throw new SecurityException("Specified package " + packageName + " under uid "
@@ -6993,7 +6998,6 @@ public class AppOpsService extends IAppOpsService.Stub {
return Process.ROOT_UID; return Process.ROOT_UID;
case "shell": case "shell":
case "dumpstate": case "dumpstate":
case "com.android.shell":
return Process.SHELL_UID; return Process.SHELL_UID;
case "media": case "media":
return Process.MEDIA_UID; return Process.MEDIA_UID;