OSDN Git Service

Fixing regression in entering PiP over keyguard.
authorWinson Chung <winsonc@google.com>
Tue, 21 Feb 2017 16:25:03 +0000 (08:25 -0800)
committerWinson Chung <winsonc@google.com>
Tue, 21 Feb 2017 16:43:56 +0000 (08:43 -0800)
- 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

services/core/java/com/android/server/am/ActivityRecord.java

index 082b6b5..0d73f3b 100644 (file)
@@ -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: