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

Commit 8958c1ef authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Initial stab at background check."

parents fc1a1bad bef28feb
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -327,12 +327,39 @@ public class ActivityManager {
    /** @hide Process is being cached for later use and is empty. */
    public static final int PROCESS_STATE_CACHED_EMPTY = 16;

    /** @hide Should this process state be considered a background state? */
    public static final boolean isProcStateBackground(int procState) {
        return procState >= PROCESS_STATE_BACKUP;
    }

    /** @hide requestType for assist context: only basic information. */
    public static final int ASSIST_CONTEXT_BASIC = 0;

    /** @hide requestType for assist context: generate full AssistStructure. */
    public static final int ASSIST_CONTEXT_FULL = 1;

    /** @hide Flag for registerUidObserver: report changes in process state. */
    public static final int UID_OBSERVER_PROCSTATE = 1<<0;

    /** @hide Flag for registerUidObserver: report uid gone. */
    public static final int UID_OBSERVER_GONE = 1<<1;

    /** @hide Flag for registerUidObserver: report uid has become idle. */
    public static final int UID_OBSERVER_IDLE = 1<<2;

    /** @hide Flag for registerUidObserver: report uid has become active. */
    public static final int UID_OBSERVER_ACTIVE = 1<<3;

    /** @hide Mode for {@link IActivityManager#getAppStartMode}: normal free-to-run operation. */
    public static final int APP_START_MODE_NORMAL = 0;

    /** @hide Mode for {@link IActivityManager#getAppStartMode}: delay running until later. */
    public static final int APP_START_MODE_DELAYED = 1;

    /** @hide Mode for {@link IActivityManager#getAppStartMode}: disable/cancel pending
     * launches. */
    public static final int APP_START_MODE_DISABLED = 2;

    /**
     * Lock task mode is not active.
     */
+32 −6
Original line number Diff line number Diff line
@@ -756,7 +756,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case MOVE_TOP_ACTIVITY_TO_PINNED_STACK: {
        case MOVE_TOP_ACTIVITY_TO_PINNED_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            final int stackId = data.readInt();
            final Rect r = Rect.CREATOR.createFromParcel(data);
@@ -2029,7 +2029,8 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            data.enforceInterface(IActivityManager.descriptor);
            IUidObserver observer = IUidObserver.Stub.asInterface(
                    data.readStrongBinder());
            registerUidObserver(observer);
            int which = data.readInt();
            registerUidObserver(observer, which);
            return true;
        }

@@ -2698,13 +2699,22 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            reply.writeNoException();
            return true;
        }
        case REMOVE_STACK: {
        case REMOVE_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            final int stackId = data.readInt();
            removeStack(stackId);
            reply.writeNoException();
            return true;
        }
        case GET_APP_START_MODE_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            final int uid = data.readInt();
            final String pkg = data.readString();
            int res = getAppStartMode(uid, pkg);
            reply.writeNoException();
            reply.writeInt(res);
            return true;
        }
        }

        return super.onTransact(code, data, reply, flags);
@@ -3579,7 +3589,7 @@ class ActivityManagerProxy implements IActivityManager
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(stackId);
        r.writeToParcel(data, 0);
        mRemote.transact(MOVE_TOP_ACTIVITY_TO_PINNED_STACK, data, reply, 0);
        mRemote.transact(MOVE_TOP_ACTIVITY_TO_PINNED_STACK_TRANSACTION, data, reply, 0);
        reply.readException();
        final boolean res = reply.readInt() != 0;
        data.recycle();
@@ -5326,11 +5336,12 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    public void registerUidObserver(IUidObserver observer) throws RemoteException {
    public void registerUidObserver(IUidObserver observer, int which) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(observer != null ? observer.asBinder() : null);
        data.writeInt(which);
        mRemote.transact(REGISTER_UID_OBSERVER_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
@@ -6292,11 +6303,26 @@ class ActivityManagerProxy implements IActivityManager
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(stackId);
        mRemote.transact(REMOVE_STACK, data, reply, 0);
        mRemote.transact(REMOVE_STACK_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    @Override
    public int getAppStartMode(int uid, String packageName) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(uid);
        data.writeString(packageName);
        mRemote.transact(GET_APP_START_MODE_TRANSACTION, data, reply, 0);
        reply.readException();
        int res = reply.readInt();
        data.recycle();
        reply.recycle();
        return res;
    }

    private IBinder mRemote;
}
+15 −5
Original line number Diff line number Diff line
@@ -237,8 +237,10 @@ public class AppOpsManager {
    public static final int OP_TURN_SCREEN_ON = 61;
    /** @hide Get device accounts. */
    public static final int OP_GET_ACCOUNTS = 62;
    /** @hide Control whether an application is allowed to run in the background. */
    public static final int OP_RUN_IN_BACKGROUND = 63;
    /** @hide */
    public static final int _NUM_OP = 63;
    public static final int _NUM_OP = 64;

    /** Access to coarse location information. */
    public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -409,6 +411,7 @@ public class AppOpsManager {
            OP_WRITE_EXTERNAL_STORAGE,
            OP_TURN_SCREEN_ON,
            OP_GET_ACCOUNTS,
            OP_RUN_IN_BACKGROUND,
    };

    /**
@@ -478,7 +481,8 @@ public class AppOpsManager {
            OPSTR_READ_EXTERNAL_STORAGE,
            OPSTR_WRITE_EXTERNAL_STORAGE,
            null,
            OPSTR_GET_ACCOUNTS
            OPSTR_GET_ACCOUNTS,
            null,
    };

    /**
@@ -549,6 +553,7 @@ public class AppOpsManager {
            "WRITE_EXTERNAL_STORAGE",
            "TURN_ON_SCREEN",
            "GET_ACCOUNTS",
            "RUN_IN_BACKGROUND",
    };

    /**
@@ -618,7 +623,8 @@ public class AppOpsManager {
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE,
            null, // no permission for turning the screen on
            Manifest.permission.GET_ACCOUNTS
            Manifest.permission.GET_ACCOUNTS,
            null, // no permission for running in background
    };

    /**
@@ -690,6 +696,7 @@ public class AppOpsManager {
            null, // WRITE_EXTERNAL_STORAGE
            null, // TURN_ON_SCREEN
            null, // GET_ACCOUNTS
            null, // RUN_IN_BACKGROUND
    };

    /**
@@ -760,6 +767,7 @@ public class AppOpsManager {
            false, // WRITE_EXTERNAL_STORAGE
            false, // TURN_ON_SCREEN
            false, // GET_ACCOUNTS
            false, // RUN_IN_BACKGROUND
    };

    /**
@@ -829,6 +837,7 @@ public class AppOpsManager {
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_ALLOWED,  // OP_TURN_ON_SCREEN
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_ALLOWED,  // OP_RUN_IN_BACKGROUND
    };

    /**
@@ -901,7 +910,8 @@ public class AppOpsManager {
            false,
            false,
            false,
            false
            false,
            false,
    };

    /**
@@ -1329,7 +1339,7 @@ public class AppOpsManager {
            IAppOpsCallback cb = mModeWatchers.get(callback);
            if (cb == null) {
                cb = new IAppOpsCallback.Stub() {
                    public void opChanged(int op, String packageName) {
                    public void opChanged(int op, int uid, String packageName) {
                        if (callback instanceof OnOpChangedInternalListener) {
                            ((OnOpChangedInternalListener)callback).onOpChanged(op, packageName);
                        }
+6 −3
Original line number Diff line number Diff line
@@ -400,7 +400,7 @@ public interface IActivityManager extends IInterface {
    public void registerProcessObserver(IProcessObserver observer) throws RemoteException;
    public void unregisterProcessObserver(IProcessObserver observer) throws RemoteException;

    public void registerUidObserver(IUidObserver observer) throws RemoteException;
    public void registerUidObserver(IUidObserver observer, int which) throws RemoteException;
    public void unregisterUidObserver(IUidObserver observer) throws RemoteException;

    public boolean isIntentSenderTargetedToPackage(IIntentSender sender) throws RemoteException;
@@ -542,6 +542,8 @@ public interface IActivityManager extends IInterface {

    public void removeStack(int stackId) throws RemoteException;

    public int getAppStartMode(int uid, String packageName) throws RemoteException;

    /*
     * Private non-Binder interfaces
     */
@@ -899,6 +901,7 @@ public interface IActivityManager extends IInterface {
    int REPORT_SIZE_CONFIGURATIONS = IBinder.FIRST_CALL_TRANSACTION + 345;
    int MOVE_TASK_TO_DOCKED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 346;
    int SUPPRESS_RESIZE_CONFIG_CHANGES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 347;
    int REMOVE_STACK = IBinder.FIRST_CALL_TRANSACTION + 348;
    int MOVE_TOP_ACTIVITY_TO_PINNED_STACK = IBinder.FIRST_CALL_TRANSACTION + 349;
    int REMOVE_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 348;
    int MOVE_TOP_ACTIVITY_TO_PINNED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 349;
    int GET_APP_START_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 350;
}
+18 −0
Original line number Diff line number Diff line
@@ -18,6 +18,24 @@ package android.app;

/** {@hide} */
oneway interface IUidObserver {
    /**
     * General report of a state change of an uid.
     */
    void onUidStateChanged(int uid, int procState);

    /**
     * Report that there are no longer any processes running for a uid.
     */
    void onUidGone(int uid);

    /**
     * Report that a uid is now active (no longer idle).
     */
    void onUidActive(int uid);

    /**
     * Report that a uid is idle -- it has either been running in the background for
     * a sufficient period of time, or all of its processes have gone away.
     */
    void onUidIdle(int uid);
}
Loading