diff options
| author | Dianne Hackborn <hackbod@google.com> | 2018-03-07 12:42:47 -0800 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2018-03-13 14:51:30 -0700 |
| commit | bf1b57d856685243f677e1f1bd29866e637a16fb (patch) | |
| tree | c5d22f1d9a7c2eaf7d6622f734d237673527549f /core/java/android/app/AppOpsManager.java | |
| parent | 4983ebd9e29c8bfd4eb353147e3a3805f74e9edd (diff) | |
Fix issue #62342672: API Review: OPSTR_ACTIVATE_VPN SystemApi
Add a new platform-only permission for being able to change
app ops mode, so nothing outside of the platform can do this.
Bug: 62342672
Test: Booted, ran, settings works, shell works, apps install
Change-Id: I372e649c019a8f9b95919ff0da6f56612d7061c2
Diffstat (limited to 'core/java/android/app/AppOpsManager.java')
| -rw-r--r-- | core/java/android/app/AppOpsManager.java | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 05a9861f5a20..14edd31a48cf 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -1609,6 +1609,7 @@ public class AppOpsManager { * @param mode The app op mode to set. * @hide */ + @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) public void setUidMode(int code, int uid, int mode) { try { mService.setUidMode(code, uid, mode); @@ -1628,7 +1629,7 @@ public class AppOpsManager { * @hide */ @SystemApi - @RequiresPermission(android.Manifest.permission.UPDATE_APP_OPS_STATS) + @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) public void setUidMode(String appOp, int uid, int mode) { try { mService.setUidMode(AppOpsManager.strOpToOp(appOp), uid, mode); @@ -1660,6 +1661,7 @@ public class AppOpsManager { /** @hide */ @TestApi + @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) public void setMode(int code, int uid, String packageName, int mode) { try { mService.setMode(code, uid, packageName, mode); @@ -1669,6 +1671,27 @@ public class AppOpsManager { } /** + * Change the operating mode for the given op in the given app package. You must pass + * in both the uid and name of the application whose mode is being modified; if these + * do not match, the modification will not be applied. + * + * @param op The operation to modify. One of the OPSTR_* constants. + * @param uid The user id of the application whose mode will be changed. + * @param packageName The name of the application package name whose mode will + * be changed. + * @hide + */ + @SystemApi + @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) + public void setMode(String op, int uid, String packageName, int mode) { + try { + mService.setMode(strOpToOp(op), uid, packageName, mode); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * Set a non-persisted restriction on an audio operation at a stream-level. * Restrictions are temporary additional constraints imposed on top of the persisted rules * defined by {@link #setMode}. @@ -1679,6 +1702,7 @@ public class AppOpsManager { * @param exceptionPackages Optional list of packages to exclude from the restriction. * @hide */ + @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) public void setRestriction(int code, @AttributeUsage int usage, int mode, String[] exceptionPackages) { try { @@ -1690,6 +1714,7 @@ public class AppOpsManager { } /** @hide */ + @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) public void resetAllModes() { try { mService.resetAllModes(mContext.getUserId(), null); |
