Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19e99b43 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by android-build-merger
Browse files

Merge "Further flesh out app ops foreground state." into pi-dev am: 7105e2ca

am: 74dc4572

Change-Id: I54ec9070d60b234f22c6940f78ab001ffdd15b28
parents cd280b73 74dc4572
Loading
Loading
Loading
Loading
+56 −2
Original line number Diff line number Diff line
@@ -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
@@ -1900,6 +1907,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.
     *
@@ -1913,6 +1935,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) {
@@ -1929,7 +1969,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();
            }
@@ -2082,6 +2122,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
@@ -2220,7 +2273,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();
        }
+19 −0
Original line number Diff line number Diff line
@@ -10429,6 +10429,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:
+2 −0
Original line number Diff line number Diff line
@@ -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);
}
+1 −0
Original line number Diff line number Diff line
@@ -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,
+342 −53

File changed.

Preview size limit exceeded, changes collapsed.