summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSnild Dolkow <snild.dolkow@sonymobile.com>2015-09-03 11:50:05 +0200
committerZoran Jovanovic <zoran.jovanovic@sonymobile.com>2015-10-07 19:58:17 +0200
commit3875bf6c047b5e1e6a0bebe8f630b89fc60fd6f6 (patch)
treeb800530a91d7fcf7a5fa43c31691c583771552ea
parentc9390c8baf0a41633c176d6d9a2d7e5d0c61c387 (diff)
Handle 'root' pseudo-package in the appops command
The AppOpsService handles the 'root' pseudo-package as any other; it gets no automatic allowances. This is reasonable, but it blocked me from accessing the mms-sms provider through the 'content' command, even in a root shell. So I tried to change the rules: $ adb root $ adb shell appops set root WRITE_SMS allow Error: No UID for root in user 0 This error occurs in the appops command because there isn't really a package called root, so the UID lookup via PackageManager fails. But we know that root is UID 0, so we can just skip the lookup. (Also, AppOpsService handles the other way around in getOpsLocked method.) Change-Id: Ie0cad67efa438a74a4d9921d29933610cfb13974
-rw-r--r--cmds/appops/src/com/android/commands/appops/AppOpsCommand.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/cmds/appops/src/com/android/commands/appops/AppOpsCommand.java b/cmds/appops/src/com/android/commands/appops/AppOpsCommand.java
index 3ec63b429a28..98dc7528a74d 100644
--- a/cmds/appops/src/com/android/commands/appops/AppOpsCommand.java
+++ b/cmds/appops/src/com/android/commands/appops/AppOpsCommand.java
@@ -168,7 +168,12 @@ public class AppOpsCommand extends BaseCommand {
final IPackageManager pm = ActivityThread.getPackageManager();
final IAppOpsService appOpsService = IAppOpsService.Stub.asInterface(
ServiceManager.getService(Context.APP_OPS_SERVICE));
- final int uid = pm.getPackageUid(packageName, userId);
+ final int uid;
+ if ("root".equals(packageName)) {
+ uid = 0;
+ } else {
+ uid = pm.getPackageUid(packageName, userId);
+ }
if (uid < 0) {
System.err.println("Error: No UID for " + packageName + " in user " + userId);
return;
@@ -211,7 +216,12 @@ public class AppOpsCommand extends BaseCommand {
final IPackageManager pm = ActivityThread.getPackageManager();
final IAppOpsService appOpsService = IAppOpsService.Stub.asInterface(
ServiceManager.getService(Context.APP_OPS_SERVICE));
- final int uid = pm.getPackageUid(packageName, userId);
+ final int uid;
+ if ("root".equals(packageName)) {
+ uid = 0;
+ } else {
+ uid = pm.getPackageUid(packageName, userId);
+ }
if (uid < 0) {
System.err.println("Error: No UID for " + packageName + " in user " + userId);
return;