From 8aedcc8b970f9da7c89ebaf6db23366d354aabe8 Mon Sep 17 00:00:00 2001 From: Benjamin Franz Date: Fri, 2 Feb 2018 08:49:27 +0000 Subject: [PATCH] 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 --- .../server/am/ActivityManagerShellCommand.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java index f0c90e0f1fab1..24a77c7693d05 100644 --- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java +++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java @@ -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) { - options = ActivityOptions.makeBasic(); + 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,