summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chung <winsonc@google.com> 2017-01-30 12:01:45 -0800
committer Winson Chung <winsonc@google.com> 2017-02-01 11:12:06 -0800
commitbb348802d3aa3880bf6ad119dfd980cd93b05a38 (patch)
treeb95051a14ec229154c49c532c94fdc5c776eca29
parent4dabf2396f4fe18b2f83641fe2ac52a913763bad (diff)
Disallow entering PiP when activity is locked.
- Also ensuring that when we request for a task to be locked via the shell, we directly set the locked state instead of relying on the SystemUI to show a prompt to lock (necessary for the CTS test to run). Test: android.server.cts.ActivityManagerPinnedStackTests Test: #testDisallowEnterPipActivityLocked Change-Id: Ice608e6d8e7f018dbd5e20ae457343bfdd0a8630
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerShellCommand.java2
-rw-r--r--services/core/java/com/android/server/am/ActivityRecord.java20
2 files changed, 14 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
index 8c3477671730..a06fa1b8dcfe 100644
--- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
+++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
@@ -2043,7 +2043,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
mInterface.stopLockTaskMode();
} else {
int taskId = Integer.parseInt(taskIdStr);
- mInterface.startLockTaskModeById(taskId);
+ mInterface.startSystemLockTaskMode(taskId);
}
pw.println("Activity manager is " + (mInterface.isInLockTaskMode() ? "" : "not ") +
"in lockTaskMode");
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index cd28da7f938d..7fea843b5ff2 100644
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -17,6 +17,7 @@
package com.android.server.am;
import static android.app.ActivityManager.ENABLE_TASK_SNAPSHOTS;
+import static android.app.ActivityManager.LOCK_TASK_MODE_NONE;
import static android.app.ActivityManager.StackId;
import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
@@ -947,25 +948,30 @@ final class ActivityRecord implements AppWindowContainerListener {
* the activity is not currently visible and {@param noThrow} is not set.
*/
boolean checkEnterPictureInPictureState(String caller, boolean noThrow) {
+ boolean isCurrentAppLocked = mStackSupervisor.getLockTaskModeState() != LOCK_TASK_MODE_NONE;
boolean isKeyguardLocked = service.isKeyguardLocked();
boolean hasPinnedStack = mStackSupervisor.getStack(PINNED_STACK_ID) != null;
+ // Don't return early if !isNotLocked, since we want to throw an exception if the activity
+ // is in an incorrect state
+ boolean isNotLocked = !isKeyguardLocked && !isCurrentAppLocked;
switch (state) {
case RESUMED:
- // When visible, allow entering PiP if not on the lockscreen. If there is another
- // PiP activity, the logic to handle that comes later in enterPictureInPictureMode()
- return !isKeyguardLocked;
+ // When visible, allow entering PiP if not on the lockscreen and if the task is not
+ // locked
+ return isNotLocked;
case PAUSING:
case PAUSED:
- // When pausing, only allow enter PiP if not on the lockscreen and there is not
- // already an existing PiP activity
- return !isKeyguardLocked && !hasPinnedStack && supportsPictureInPictureWhilePausing
+ // When pausing, then only allow enter PiP as in the resume state, and in addition,
+ // require that there is not an existing PiP activity and that the current system
+ // state supports entering PiP
+ return isNotLocked && !hasPinnedStack && supportsPictureInPictureWhilePausing
&& checkEnterPictureInPictureOnHideAppOpsState();
case STOPPING:
// When stopping in a valid state, then only allow enter PiP as in the pause state.
// Otherwise, fall through to throw an exception if the caller is trying to enter
// PiP in an invalid stopping state.
if (supportsPictureInPictureWhilePausing) {
- return !isKeyguardLocked && !hasPinnedStack
+ return isNotLocked && !hasPinnedStack
&& checkEnterPictureInPictureOnHideAppOpsState();
}
default: