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

Commit 8aedcc8b authored by Benjamin Franz's avatar Benjamin Franz
Browse files

Add shell command to populate lock task option

Add a shell flag to indicate that you want the given intent to be
launched with the lock task option active.

Bug: 72806000
Test: adb shell am start --lock-task ...
Change-Id: I84ea86e30f40c0751bdd79c09f414dbbc8c3110d
parent 9d3986bd
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
    private int mActivityType;
    private int mTaskId;
    private boolean mIsTaskOverlay;
    private boolean mIsLockTask;

    final boolean mDumping;

@@ -278,6 +279,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
        mActivityType = ACTIVITY_TYPE_UNDEFINED;
        mTaskId = INVALID_TASK_ID;
        mIsTaskOverlay = false;
        mIsLockTask = false;

        return Intent.parseCommandArgs(this, new Intent.CommandOptionHandler() {
            @Override
@@ -334,6 +336,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
                    mTaskId = Integer.parseInt(getNextArgRequired());
                } else if (opt.equals("--task-overlay")) {
                    mIsTaskOverlay = true;
                } else if (opt.equals("--lock-task")) {
                    mIsLockTask = true;
                } else {
                    return false;
                }
@@ -429,13 +433,22 @@ final class ActivityManagerShellCommand extends ShellCommand {
                options.setLaunchActivityType(mActivityType);
            }
            if (mTaskId != INVALID_TASK_ID) {
                if (options == null) {
                    options = ActivityOptions.makeBasic();
                }
                options.setLaunchTaskId(mTaskId);

                if (mIsTaskOverlay) {
                    options.setTaskOverlay(true, true /* canResume */);
                }
            }
            android.util.Log.d("bfranz", "I was here: " + mIsLockTask);
            if (mIsLockTask) {
                if (options == null) {
                    options = ActivityOptions.makeBasic();
                }
                options.setLockTaskMode(true);
            }
            if (mWaitOption) {
                result = mInterface.startActivityAndWait(null, null, intent, mimeType,
                        null, null, 0, mStartFlags, profilerInfo,