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

Commit 41014801 authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "Introduce android:lockTaskMode"

parents dc3e29c3 15df08ab
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -815,6 +815,7 @@ package android {
    field public static final int listSeparatorTextViewStyle = 16843272; // 0x1010208
    field public static final int listViewStyle = 16842868; // 0x1010074
    field public static final int listViewWhiteStyle = 16842869; // 0x1010075
    field public static final int lockTaskMode = 16844013; // 0x10104ed
    field public static final int logo = 16843454; // 0x10102be
    field public static final int longClickable = 16842982; // 0x10100e6
    field public static final int loopViews = 16843527; // 0x1010307
+1 −0
Original line number Diff line number Diff line
@@ -888,6 +888,7 @@ package android {
    field public static final int listSeparatorTextViewStyle = 16843272; // 0x1010208
    field public static final int listViewStyle = 16842868; // 0x1010074
    field public static final int listViewWhiteStyle = 16842869; // 0x1010075
    field public static final int lockTaskMode = 16844013; // 0x10104ed
    field public static final int logo = 16843454; // 0x10102be
    field public static final int longClickable = 16842982; // 0x10100e6
    field public static final int loopViews = 16843527; // 0x1010307
+17 −5
Original line number Diff line number Diff line
@@ -6434,18 +6434,22 @@ public class Activity extends ContextThemeWrapper
     * 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.
     * This will prevent the user from launching other apps, going to settings, or reaching the
     * home screen. This does not include those apps whose {@link android.R.attr#lockTaskMode}
     * values permit launching while locked.
     *
     * 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 true or
     * lockTaskMode=lockTaskModeAlways 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 through
     * an action described by the request dialog.  Calling stopLockTask will also exit the
     * mode.
     *
     * @see android.R.attr#lockTaskMode
     */
    public void startLockTask() {
        try {
@@ -6462,6 +6466,14 @@ public class Activity extends ContextThemeWrapper
     * startLockTask previously.
     *
     * This will allow the user to exit this app and move onto other activities.
     * <p>Note: This method should only be called when the activity is user-facing. That is,
     * between onResume() and onPause().
     * <p>Note: If there are other tasks below this one that are also locked then calling this
     * method will immediately finish this task and resume the previous locked one, remaining in
     * lockTask mode.
     *
     * @see android.R.attr#lockTaskMode
     * @see ActivityManager#getLockTaskModeState()
     */
    public void stopLockTask() {
        try {
+40 −4
Original line number Diff line number Diff line
@@ -648,6 +648,37 @@ public class ActivityInfo extends ComponentInfo
     */
    public boolean resizeable;

    /** @hide */
    public static final int LOCK_TASK_LAUNCH_MODE_DEFAULT = 0;
    /** @hide */
    public static final int LOCK_TASK_LAUNCH_MODE_NEVER = 1;
    /** @hide */
    public static final int LOCK_TASK_LAUNCH_MODE_ALWAYS = 2;
    /** @hide */
    public static final int LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED = 3;

    /** @hide */
    public static final String lockTaskLaunchModeToString(int lockTaskLaunchMode) {
        switch (lockTaskLaunchMode) {
            case LOCK_TASK_LAUNCH_MODE_DEFAULT:
                return "LOCK_TASK_LAUNCH_MODE_DEFAULT";
            case LOCK_TASK_LAUNCH_MODE_NEVER:
                return "LOCK_TASK_LAUNCH_MODE_NEVER";
            case LOCK_TASK_LAUNCH_MODE_ALWAYS:
                return "LOCK_TASK_LAUNCH_MODE_ALWAYS";
            case LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED:
                return "LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED";
            default:
                return "unknown=" + lockTaskLaunchMode;
        }
    }
    /**
     * Value indicating if the activity is to be locked at startup. Takes on the values from
     * {@link android.R.attr#lockTaskMode}.
     * @hide
     */
    public int lockTaskLaunchMode;

    public ActivityInfo() {
    }

@@ -665,6 +696,8 @@ public class ActivityInfo extends ComponentInfo
        uiOptions = orig.uiOptions;
        parentActivityName = orig.parentActivityName;
        maxRecents = orig.maxRecents;
        resizeable = orig.resizeable;
        lockTaskLaunchMode = orig.lockTaskLaunchMode;
    }

    /**
@@ -709,7 +742,8 @@ public class ActivityInfo extends ComponentInfo
        if (uiOptions != 0) {
            pw.println(prefix + " uiOptions=0x" + Integer.toHexString(uiOptions));
        }
        pw.println(prefix + "resizeable=" + resizeable);
        pw.println(prefix + "resizeable=" + resizeable + " lockTaskLaunchMode="
                + lockTaskLaunchModeToString(lockTaskLaunchMode));
        super.dumpBack(pw, prefix);
    }
    
@@ -739,6 +773,7 @@ public class ActivityInfo extends ComponentInfo
        dest.writeInt(persistableMode);
        dest.writeInt(maxRecents);
        dest.writeInt(resizeable ? 1 : 0);
        dest.writeInt(lockTaskLaunchMode);
    }

    public static final Parcelable.Creator<ActivityInfo> CREATOR
@@ -767,5 +802,6 @@ public class ActivityInfo extends ComponentInfo
        persistableMode = source.readInt();
        maxRecents = source.readInt();
        resizeable = (source.readInt() == 1);
        lockTaskLaunchMode = source.readInt();
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -3159,6 +3159,9 @@ public class PackageParser {
                        R.styleable.AndroidManifestActivity_screenOrientation,
                        ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
            }

            a.info.lockTaskLaunchMode =
                    sa.getInt(R.styleable.AndroidManifestActivity_lockTaskMode, 0);
        } else {
            a.info.launchMode = ActivityInfo.LAUNCH_MULTIPLE;
            a.info.configChanges = 0;
Loading