Loading core/java/android/app/AppOpsManager.java +56 −2 Original line number Diff line number Diff line Loading @@ -118,6 +118,13 @@ public class AppOpsManager { */ public static final int MODE_FOREGROUND = 4; /** * Flag for {@link #startWatchingMode(String, String, int, OnOpChangedListener)}: * Also get reports if the foreground state of an op's uid changes. This only works * when watching a particular op, not when watching a package. * @hide */ public static final int WATCH_FOREGROUND_CHANGES = 1 << 0; /** * @hide Loading Loading @@ -1898,6 +1905,21 @@ public class AppOpsManager { startWatchingMode(strOpToOp(op), packageName, callback); } /** * Monitor for changes to the operating mode for the given op in the given app package. * You can watch op changes only for your UID. * * @param op The operation to monitor, one of OPSTR_*. * @param packageName The name of the application to monitor. * @param flags Option flags: any combination of {@link #WATCH_FOREGROUND_CHANGES} or 0. * @param callback Where to report changes. * @hide */ public void startWatchingMode(String op, String packageName, int flags, final OnOpChangedListener callback) { startWatchingMode(strOpToOp(op), packageName, flags, callback); } /** * Monitor for changes to the operating mode for the given op in the given app package. * Loading @@ -1911,6 +1933,24 @@ public class AppOpsManager { */ @RequiresPermission(value=android.Manifest.permission.WATCH_APPOPS, conditional=true) public void startWatchingMode(int op, String packageName, final OnOpChangedListener callback) { startWatchingMode(op, packageName, 0, callback); } /** * Monitor for changes to the operating mode for the given op in the given app package. * * <p> If you don't hold the {@link android.Manifest.permission#WATCH_APPOPS} permission * you can watch changes only for your UID. * * @param op The operation to monitor, one of OP_*. * @param packageName The name of the application to monitor. * @param flags Option flags: any combination of {@link #WATCH_FOREGROUND_CHANGES} or 0. * @param callback Where to report changes. * @hide */ @RequiresPermission(value=android.Manifest.permission.WATCH_APPOPS, conditional=true) public void startWatchingMode(int op, String packageName, int flags, final OnOpChangedListener callback) { synchronized (mModeWatchers) { IAppOpsCallback cb = mModeWatchers.get(callback); if (cb == null) { Loading @@ -1927,7 +1967,7 @@ public class AppOpsManager { mModeWatchers.put(callback, cb); } try { mService.startWatchingMode(op, packageName, cb); mService.startWatchingModeWithFlags(op, packageName, flags, cb); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -2079,6 +2119,19 @@ public class AppOpsManager { return checkOpNoThrow(strOpToOp(op), uid, packageName); } /** * Like {@link #checkOp} but returns the <em>raw</em> mode associated with the op. * Does not throw a security exception, does not translate {@link #MODE_FOREGROUND}. * @hide */ public int unsafeCheckOpRaw(String op, int uid, String packageName) { try { return mService.checkOperation(strOpToOp(op), uid, packageName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Make note of an application performing an operation. Note that you must pass * in both the uid and name of the application to be checked; this function will verify Loading Loading @@ -2217,7 +2270,8 @@ public class AppOpsManager { */ public int checkOpNoThrow(int op, int uid, String packageName) { try { return mService.checkOperation(op, uid, packageName); int mode = mService.checkOperation(op, uid, packageName); return mode == AppOpsManager.MODE_FOREGROUND ? AppOpsManager.MODE_ALLOWED : mode; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading core/java/android/provider/Settings.java +19 −0 Original line number Diff line number Diff line Loading @@ -10424,6 +10424,25 @@ public final class Settings { */ public static final String ACTIVITY_MANAGER_CONSTANTS = "activity_manager_constants"; /** * App ops specific settings. * This is encoded as a key=value list, separated by commas. Ex: * * "state_settle_time=10000" * * The following keys are supported: * * <pre> * state_settle_time (long) * </pre> * * <p> * Type: string * @hide * @see com.android.server.AppOpsService.Constants */ public static final String APP_OPS_CONSTANTS = "app_ops_constants"; /** * Device Idle (Doze) specific settings. * This is encoded as a key=value list, separated by commas. Ex: Loading core/java/com/android/internal/app/IAppOpsService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -54,4 +54,6 @@ interface IAppOpsService { void startWatchingActive(in int[] ops, IAppOpsActiveCallback callback); void stopWatchingActive(IAppOpsActiveCallback callback); boolean isOperationActive(int code, int uid, String packageName); void startWatchingModeWithFlags(int op, String packageName, int flags, IAppOpsCallback callback); } core/tests/coretests/src/android/provider/SettingsBackupTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,7 @@ public class SettingsBackupTest { Settings.Global.APN_DB_UPDATE_CONTENT_URL, Settings.Global.APN_DB_UPDATE_METADATA_URL, Settings.Global.APP_IDLE_CONSTANTS, Settings.Global.APP_OPS_CONSTANTS, Settings.Global.APP_STANDBY_ENABLED, Settings.Global.ASSISTED_GPS_ENABLED, Settings.Global.AUDIO_SAFE_VOLUME_STATE, Loading services/core/java/com/android/server/AppOpsService.java +342 −53 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
core/java/android/app/AppOpsManager.java +56 −2 Original line number Diff line number Diff line Loading @@ -118,6 +118,13 @@ public class AppOpsManager { */ public static final int MODE_FOREGROUND = 4; /** * Flag for {@link #startWatchingMode(String, String, int, OnOpChangedListener)}: * Also get reports if the foreground state of an op's uid changes. This only works * when watching a particular op, not when watching a package. * @hide */ public static final int WATCH_FOREGROUND_CHANGES = 1 << 0; /** * @hide Loading Loading @@ -1898,6 +1905,21 @@ public class AppOpsManager { startWatchingMode(strOpToOp(op), packageName, callback); } /** * Monitor for changes to the operating mode for the given op in the given app package. * You can watch op changes only for your UID. * * @param op The operation to monitor, one of OPSTR_*. * @param packageName The name of the application to monitor. * @param flags Option flags: any combination of {@link #WATCH_FOREGROUND_CHANGES} or 0. * @param callback Where to report changes. * @hide */ public void startWatchingMode(String op, String packageName, int flags, final OnOpChangedListener callback) { startWatchingMode(strOpToOp(op), packageName, flags, callback); } /** * Monitor for changes to the operating mode for the given op in the given app package. * Loading @@ -1911,6 +1933,24 @@ public class AppOpsManager { */ @RequiresPermission(value=android.Manifest.permission.WATCH_APPOPS, conditional=true) public void startWatchingMode(int op, String packageName, final OnOpChangedListener callback) { startWatchingMode(op, packageName, 0, callback); } /** * Monitor for changes to the operating mode for the given op in the given app package. * * <p> If you don't hold the {@link android.Manifest.permission#WATCH_APPOPS} permission * you can watch changes only for your UID. * * @param op The operation to monitor, one of OP_*. * @param packageName The name of the application to monitor. * @param flags Option flags: any combination of {@link #WATCH_FOREGROUND_CHANGES} or 0. * @param callback Where to report changes. * @hide */ @RequiresPermission(value=android.Manifest.permission.WATCH_APPOPS, conditional=true) public void startWatchingMode(int op, String packageName, int flags, final OnOpChangedListener callback) { synchronized (mModeWatchers) { IAppOpsCallback cb = mModeWatchers.get(callback); if (cb == null) { Loading @@ -1927,7 +1967,7 @@ public class AppOpsManager { mModeWatchers.put(callback, cb); } try { mService.startWatchingMode(op, packageName, cb); mService.startWatchingModeWithFlags(op, packageName, flags, cb); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -2079,6 +2119,19 @@ public class AppOpsManager { return checkOpNoThrow(strOpToOp(op), uid, packageName); } /** * Like {@link #checkOp} but returns the <em>raw</em> mode associated with the op. * Does not throw a security exception, does not translate {@link #MODE_FOREGROUND}. * @hide */ public int unsafeCheckOpRaw(String op, int uid, String packageName) { try { return mService.checkOperation(strOpToOp(op), uid, packageName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Make note of an application performing an operation. Note that you must pass * in both the uid and name of the application to be checked; this function will verify Loading Loading @@ -2217,7 +2270,8 @@ public class AppOpsManager { */ public int checkOpNoThrow(int op, int uid, String packageName) { try { return mService.checkOperation(op, uid, packageName); int mode = mService.checkOperation(op, uid, packageName); return mode == AppOpsManager.MODE_FOREGROUND ? AppOpsManager.MODE_ALLOWED : mode; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
core/java/android/provider/Settings.java +19 −0 Original line number Diff line number Diff line Loading @@ -10424,6 +10424,25 @@ public final class Settings { */ public static final String ACTIVITY_MANAGER_CONSTANTS = "activity_manager_constants"; /** * App ops specific settings. * This is encoded as a key=value list, separated by commas. Ex: * * "state_settle_time=10000" * * The following keys are supported: * * <pre> * state_settle_time (long) * </pre> * * <p> * Type: string * @hide * @see com.android.server.AppOpsService.Constants */ public static final String APP_OPS_CONSTANTS = "app_ops_constants"; /** * Device Idle (Doze) specific settings. * This is encoded as a key=value list, separated by commas. Ex: Loading
core/java/com/android/internal/app/IAppOpsService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -54,4 +54,6 @@ interface IAppOpsService { void startWatchingActive(in int[] ops, IAppOpsActiveCallback callback); void stopWatchingActive(IAppOpsActiveCallback callback); boolean isOperationActive(int code, int uid, String packageName); void startWatchingModeWithFlags(int op, String packageName, int flags, IAppOpsCallback callback); }
core/tests/coretests/src/android/provider/SettingsBackupTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,7 @@ public class SettingsBackupTest { Settings.Global.APN_DB_UPDATE_CONTENT_URL, Settings.Global.APN_DB_UPDATE_METADATA_URL, Settings.Global.APP_IDLE_CONSTANTS, Settings.Global.APP_OPS_CONSTANTS, Settings.Global.APP_STANDBY_ENABLED, Settings.Global.ASSISTED_GPS_ENABLED, Settings.Global.AUDIO_SAFE_VOLUME_STATE, Loading
services/core/java/com/android/server/AppOpsService.java +342 −53 File changed.Preview size limit exceeded, changes collapsed. Show changes