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
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user