From 75520d5cadf59e7abcb4df0a61b8d5cbddc4819a Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Thu, 24 Aug 2017 17:23:19 +0200 Subject: [PATCH 1/2] Use Keyguard orientation when unoccluding If we are about to unocclude Keyguard, we already use its orientation spec such that if both Keyguard and the activity going aways share the same orientation spec, there is no unnecessary orientation change. Test: Launch SHOW_WHEN_LOCKED portrait activity, hold device in landscape, toggle power button twice, press home, make sure no orientation change when animating to Keyguard. Test: go/wm-smoke Change-Id: Ic5f110747de5f5f7d73adf83f5f53c7fd56d860c Fixes: 38146081 --- .../core/java/com/android/server/am/ActivityStack.java | 10 ++++++++++ .../java/com/android/server/wm/DisplayContent.java | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index eb3177a6e1c9e..c67b0d88147da 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -2580,6 +2580,16 @@ class ActivityStack extends ConfigurationContai // the screen based on the new activity order. boolean notUpdated = true; if (mStackSupervisor.isFocusedStack(this)) { + + // We have special rotation behavior when Keyguard is locked. Make sure all activity + // visibilities are set correctly as well as the transition is updated if needed to + // get the correct rotation behavior. + // TODO: Remove this once visibilities are set correctly immediately when starting + // an activity. + if (mStackSupervisor.mKeyguardController.isKeyguardLocked()) { + mStackSupervisor.ensureActivitiesVisibleLocked(null /* starting */, + 0 /* configChanges */, false /* preserveWindows */); + } final Configuration config = mWindowManager.updateOrientationFromAppTokens( mStackSupervisor.getDisplayOverrideConfiguration(mDisplayId), next.mayFreezeScreenLocked(next.app) ? next.appToken : null, mDisplayId); diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index f0a375bf29f4a..266ebf3df8512 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -57,6 +57,7 @@ import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM; import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG; import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT; import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; +import static com.android.server.wm.AppTransition.TRANSIT_KEYGUARD_UNOCCLUDE; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_BOOT; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DISPLAY; @@ -3554,7 +3555,8 @@ class DisplayContent extends WindowContainer Date: Mon, 28 Aug 2017 15:44:43 +0200 Subject: [PATCH 2/2] Fix transition between two occluding activities This fixes an issue when starting an activity that occldues Keyguard with the window flag from an activity that is already occluding Keyguard. Normally we wait until the transition starts until the next activity had a chance to set its layout flag (FLAG_SHOW_WHEN_LOCKED) with the UnknownVisibilityController. Now, since setAppVisibility(false) was called after immediately starting the activity, we removed the activity immediately from the UnknownVisibilityController waiting list and then unoccluded Keyguard. We fix this by only removing the activity from the waiting list if the app is actually hidden and not just because it's hidden by Keyguard. This regressed from I745e985766a1af97203e1d22b6443dabdd0c0363 because calling setVisible(true) was setting the token's visible to true. Then, setVisible(false) was NOT ignored anymore. Previously it was just ignored because the app wasn't made visible yet from WM perspective. Test: go/wm-smoke Test: android.server.cts.KeyguardTransitionTests#testNewActivityDuringOccluded Test: Launch camera from Keyguard with animation transition scale set to 0. (regression test) Change-Id: I36ec1bf335c48baf298e78620381bdd0be34aa1d Fixes: 65061212 Bug: 37677242 --- .../core/java/com/android/server/am/ActivityRecord.java | 3 ++- .../com/android/server/am/ActivityStackSupervisor.java | 7 ++++--- .../android/server/wm/AppWindowContainerController.java | 8 ++++++-- 3 files changed, 12 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 874bd1e7625bf..c49ea81f63db2 100644 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -1572,7 +1572,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo } void setVisibility(boolean visible) { - mWindowContainerController.setVisibility(visible, mDeferHidingClient); + mWindowContainerController.setVisibility(visible, visibleIgnoringKeyguard, + mDeferHidingClient); mStackSupervisor.mActivityMetricsLogger.notifyVisibilityChanged(this, visible); } diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 68a4ad964ab81..4cc2892c12fd5 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -1336,6 +1336,10 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D r.app = app; + if (mKeyguardController.isKeyguardLocked()) { + r.notifyUnknownVisibilityLaunched(); + } + // Have the window manager re-evaluate the orientation of the screen based on the new // activity order. Note that as a result of this, it can call back into the activity // manager with a new orientation. We don't care about that, because the activity is @@ -1362,9 +1366,6 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D r.setVisibility(true); } - if (mKeyguardController.isKeyguardLocked()) { - r.notifyUnknownVisibilityLaunched(); - } final int applicationInfoUid = (r.info.applicationInfo != null) ? r.info.applicationInfo.uid : -1; if ((r.userId != app.userId) || (r.appInfo.uid != applicationInfoUid)) { diff --git a/services/core/java/com/android/server/wm/AppWindowContainerController.java b/services/core/java/com/android/server/wm/AppWindowContainerController.java index f142ff619884b..ebd82e3d77043 100644 --- a/services/core/java/com/android/server/wm/AppWindowContainerController.java +++ b/services/core/java/com/android/server/wm/AppWindowContainerController.java @@ -321,7 +321,8 @@ public class AppWindowContainerController } } - public void setVisibility(boolean visible, boolean deferHidingClient) { + public void setVisibility(boolean visible, boolean visibleIgnoringKeyguard, + boolean deferHidingClient) { synchronized(mWindowMap) { if (mContainer == null) { Slog.w(TAG_WM, "Attempted to set visibility of non-existing app token: " @@ -360,13 +361,16 @@ public class AppWindowContainerController wtoken.hiddenRequested = !visible; wtoken.mDeferHidingClient = deferHidingClient; + if (!visibleIgnoringKeyguard) { + mService.mUnknownAppVisibilityController.appRemovedOrHidden(wtoken); + } + if (!visible) { // If the app is dead while it was visible, we kept its dead window on screen. // Now that the app is going invisible, we can remove it. It will be restarted // if made visible again. wtoken.removeDeadWindows(); wtoken.setVisibleBeforeClientHidden(); - mService.mUnknownAppVisibilityController.appRemovedOrHidden(wtoken); } else { if (!mService.mAppTransition.isTransitionSet() && mService.mAppTransition.isReady()) {