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

Commit 858aef29 authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Add lock-to-app mode"

parents a8ac5fb6 62515bee
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.internal.policy.PolicyManager;

import android.annotation.IntDef;
import android.annotation.Nullable;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentCallbacks2;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -5935,14 +5936,21 @@ public class Activity extends ContextThemeWrapper
    }

    /**
     * Put this Activity in a mode where the user is locked to the
     * Request to put this Activity in a mode where the user is locked to the
     * current task.
     *
     * This will prevent the user from launching other apps, going to settings,
     * or reaching the home screen.
     *
     * Lock task mode will only start if the activity has been whitelisted by the
     * Device Owner through DevicePolicyManager#setLockTaskComponents.
     * If {@link DevicePolicyManager#isLockTaskPermitted(String)} returns true
     * for this component then the app will go directly into Lock Task mode.  The user
     * will not be able to exit this mode until {@link Activity#stopLockTask()} is called.
     *
     * If {@link DevicePolicyManager#isLockTaskPermitted(String)} returns false
     * then the system will prompt the user with a dialog requesting permission to enter
     * this mode.  When entered through this method the user can exit at any time by
     * swiping down twice from the top of the screen.  Calling stopLockTask will also
     * exit the mode.
     */
    public void startLockTask() {
        try {
+36 −0
Original line number Diff line number Diff line
@@ -2145,6 +2145,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case START_LOCK_TASK_BY_CURRENT: {
            data.enforceInterface(IActivityManager.descriptor);
            startLockTaskModeOnCurrent();
            reply.writeNoException();
            return true;
        }

        case STOP_LOCK_TASK_MODE_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            stopLockTaskMode();
@@ -2152,6 +2159,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case STOP_LOCK_TASK_BY_CURRENT: {
            data.enforceInterface(IActivityManager.descriptor);
            stopLockTaskModeOnCurrent();
            reply.writeNoException();
            return true;
        }

        case IS_IN_LOCK_TASK_MODE_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            final boolean isInLockTaskMode = isInLockTaskMode();
@@ -4946,6 +4960,17 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    @Override
    public void startLockTaskModeOnCurrent() throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        mRemote.transact(START_LOCK_TASK_BY_CURRENT, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    @Override
    public void stopLockTaskMode() throws RemoteException {
        Parcel data = Parcel.obtain();
@@ -4957,6 +4982,17 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    @Override
    public void stopLockTaskModeOnCurrent() throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        mRemote.transact(STOP_LOCK_TASK_BY_CURRENT, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    @Override
    public boolean isInLockTaskMode() throws RemoteException {
        Parcel data = Parcel.obtain();
+8 −0
Original line number Diff line number Diff line
@@ -428,6 +428,9 @@ public interface IActivityManager extends IInterface {

    public IBinder getHomeActivityToken() throws RemoteException;

    /** @hide */
    public void startLockTaskModeOnCurrent() throws RemoteException;

    /** @hide */
    public void startLockTaskMode(int taskId) throws RemoteException;

@@ -437,6 +440,9 @@ public interface IActivityManager extends IInterface {
    /** @hide */
    public void stopLockTaskMode() throws RemoteException;

    /** @hide */
    public void stopLockTaskModeOnCurrent() throws RemoteException;

    /** @hide */
    public boolean isInLockTaskMode() throws RemoteException;

@@ -744,4 +750,6 @@ public interface IActivityManager extends IInterface {
    int START_VOICE_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+218;
    int GET_ACTIVITY_OPTIONS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+219;
    int GET_APP_TASKS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+220;
    int START_LOCK_TASK_BY_CURRENT = IBinder.FIRST_CALL_TRANSACTION+221;
    int STOP_LOCK_TASK_BY_CURRENT = IBinder.FIRST_CALL_TRANSACTION+222;
}
+12 −0
Original line number Diff line number Diff line
@@ -2459,6 +2459,18 @@ public final class Settings {
         */
        public static final String POINTER_SPEED = "pointer_speed";

        /**
         * Whether lock-to-app will be triggered by long-press on recents.
         * @hide
         */
        public static final String LOCK_TO_APP_ENABLED = "lock_to_app_enabled";

        /**
         * Whether lock-to-app will lock the keyguard when exiting.
         * @hide
         */
        public static final String LOCK_TO_APP_EXIT_LOCKED = "lock_to_app_exit_locked";

        /**
         * I am the lolrus.
         * <p>
+390 B
Loading image diff...
Loading