From e581ebfb7d8915af7724f841860d5b2eb7b8d045 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 21 Feb 2017 08:25:03 -0800 Subject: [PATCH] Fixing regression in entering PiP over keyguard. - The call to check the current system state before entering PiP should not check the keyguard visibility state when the activity is resumed. The caller (enterPictureInPictureMode()) will make that check itself and defer until entering PiP until the keyguard is gone. Bug: 33645392 Test: android.server.cts.KeyguardLockedTests Test: android.server.cts.ActivityManagerPinnedStackTests Change-Id: Ib9a5d0f51400b8dd9146e3445c2415e2a458e690 --- .../core/java/com/android/server/am/ActivityRecord.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java index 082b6b50fd49..0d73f3b24a1e 100644 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -977,25 +977,26 @@ final class ActivityRecord implements AppWindowContainerListener { 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; + boolean isNotLockedOrOnKeyguard = !isKeyguardLocked && !isCurrentAppLocked; switch (state) { case RESUMED: - // When visible, allow entering PiP if not on the lockscreen and if the task is not - // locked - return isNotLocked; + // When visible, allow entering PiP if the app is not locked. If it is over the + // keyguard, then we will prompt to unlock in the caller before entering PiP. + return !isCurrentAppLocked; case PAUSING: case PAUSED: // 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 + return isNotLockedOrOnKeyguard && !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 isNotLocked && !hasPinnedStack + return isNotLockedOrOnKeyguard && !hasPinnedStack && checkEnterPictureInPictureOnHideAppOpsState(); } default: -- 2.11.0