Loading services/core/java/com/android/server/wm/DisplayContent.java +45 −58 Original line number Diff line number Diff line Loading @@ -400,14 +400,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo /** @see #getCurrentOverrideConfigurationChanges */ private int mCurrentOverrideConfigurationChanges; /** * Orientation forced by some window. If there is no visible window that specifies orientation * it is set to {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}. * * @see NonAppWindowContainers#getOrientation() */ private int mLastWindowForcedOrientation = SCREEN_ORIENTATION_UNSPECIFIED; /** * Last orientation forced by the keyguard. It is applied when keyguard is shown and is not * occluded. Loading Loading @@ -1283,11 +1275,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return mDisplayRotation.getLastOrientation(); } @ScreenOrientation int getLastWindowForcedOrientation() { return mLastWindowForcedOrientation; } void registerRemoteAnimations(RemoteAnimationDefinition definition) { mAppTransitionController.registerRemoteAnimations(definition); } Loading Loading @@ -2134,16 +2121,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } if (mWmService.mDisplayFrozen) { if (mLastWindowForcedOrientation != SCREEN_ORIENTATION_UNSPECIFIED) { ProtoLog.v(WM_DEBUG_ORIENTATION, "Display id=%d is frozen, return %d", mDisplayId, mLastWindowForcedOrientation); // If the display is frozen, some activities may be in the middle of restarting, and // thus have removed their old window. If the window has the flag to hide the lock // screen, then the lock screen can re-appear and inflict its own orientation on us. // Keep the orientation stable until this all settles down. return mLastWindowForcedOrientation; } else if (policy.isKeyguardLocked()) { if (policy.isKeyguardLocked()) { // Use the last orientation the while the display is frozen with the keyguard // locked. This could be the keyguard forced orientation or from a SHOW_WHEN_LOCKED // window. We don't want to check the show when locked window directly though as Loading @@ -2154,12 +2132,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo mDisplayId, getLastOrientation()); return getLastOrientation(); } } else { } final int orientation = mAboveAppWindowsContainers.getOrientation(); if (orientation != SCREEN_ORIENTATION_UNSET) { return orientation; } } // Top system windows are not requesting an orientation. Start searching from apps. return mTaskStackContainers.getOrientation(); Loading Loading @@ -4141,6 +4118,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo DisplayChildWindowContainer(WindowManagerService service) { super(service); // TODO(display-area): move to ConfigurationContainer? mOrientation = SCREEN_ORIENTATION_UNSET; } @Override Loading Loading @@ -4547,7 +4526,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } @Override int getOrientation() { int getOrientation(int candidate) { if (isStackVisible(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY)) { // Apps and their containers are not allowed to specify an orientation while the // docked stack is visible...except for the home stack if the docked stack is Loading @@ -4565,7 +4544,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return SCREEN_ORIENTATION_UNSPECIFIED; } final int orientation = super.getOrientation(); final int orientation = super.getOrientation(candidate); if (orientation != SCREEN_ORIENTATION_UNSET && orientation != SCREEN_ORIENTATION_BEHIND) { ProtoLog.v(WM_DEBUG_ORIENTATION, Loading Loading @@ -4820,9 +4799,23 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo token2.mOwnerCanManageAppTokens) ? -1 : 1; private final Predicate<WindowState> mGetOrientingWindow = w -> { if (!w.isVisibleLw() || !w.mLegacyPolicyVisibilityAfterAnim) { final WindowManagerPolicy policy = mWmService.mPolicy; if (policy.isKeyguardHostWindow(w.mAttrs)) { if (mWmService.mKeyguardGoingAway) { return false; } // Consider unoccluding only when all unknown visibilities have been // resolved, as otherwise we just may be starting another occluding activity. final boolean isUnoccluding = mDisplayContent.mAppTransition.getAppTransition() == TRANSIT_KEYGUARD_UNOCCLUDE && mDisplayContent.mUnknownAppVisibilityController.allResolved(); // If keyguard is showing, or we're unoccluding, force the keyguard's orientation, // even if SystemUI hasn't updated the attrs yet. if (policy.isKeyguardShowingAndNotOccluded() || isUnoccluding) { return true; } } final int req = w.mAttrs.screenOrientation; if (req == SCREEN_ORIENTATION_UNSPECIFIED || req == SCREEN_ORIENTATION_BEHIND || req == SCREEN_ORIENTATION_UNSET) { Loading Loading @@ -4851,39 +4844,27 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } @Override int getOrientation() { final WindowManagerPolicy policy = mWmService.mPolicy; int getOrientation(int candidate) { // Find a window requesting orientation. final WindowState win = getWindow(mGetOrientingWindow); if (win != null) { final int req = win.mAttrs.screenOrientation; if (policy.isKeyguardHostWindow(win.mAttrs)) { mLastKeyguardForcedOrientation = req; if (mWmService.mKeyguardGoingAway) { // Keyguard can't affect the orientation if it is going away... mLastWindowForcedOrientation = SCREEN_ORIENTATION_UNSPECIFIED; return SCREEN_ORIENTATION_UNSET; } } int req = win.mAttrs.screenOrientation; ProtoLog.v(WM_DEBUG_ORIENTATION, "%s forcing orientation to %d for display id=%d", win, req, mDisplayId); return (mLastWindowForcedOrientation = req); if (mWmService.mPolicy.isKeyguardHostWindow(win.mAttrs)) { // SystemUI controls the Keyguard orientation asynchronously, and mAttrs may be // stale. We record / use the last known override. if (req != SCREEN_ORIENTATION_UNSET && req != SCREEN_ORIENTATION_UNSPECIFIED) { mDisplayContent.mLastKeyguardForcedOrientation = req; } else { req = mDisplayContent.mLastKeyguardForcedOrientation; } mLastWindowForcedOrientation = SCREEN_ORIENTATION_UNSPECIFIED; // Only allow force setting the orientation when all unknown visibilities have been // resolved, as otherwise we just may be starting another occluding activity. final boolean isUnoccluding = mAppTransition.getAppTransition() == TRANSIT_KEYGUARD_UNOCCLUDE && mUnknownAppVisibilityController.allResolved(); if (policy.isKeyguardShowingAndNotOccluded() || isUnoccluding) { return mLastKeyguardForcedOrientation; } return SCREEN_ORIENTATION_UNSET; return req; } return candidate; } @Override Loading Loading @@ -4929,6 +4910,12 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo mNeedsLayer = true; } @Override int getOrientation(int candidate) { // IME does not participate in orientation. return candidate; } @Override boolean forAllWindows(ToBooleanFunction<WindowState> callback, boolean traverseTopToBottom) { Loading services/core/java/com/android/server/wm/WindowManagerService.java +4 −6 Original line number Diff line number Diff line Loading @@ -5998,8 +5998,6 @@ public class WindowManagerService extends IWindowManager.Stub pw.print(" apps="); pw.print(mAppsFreezingScreen); final DisplayContent defaultDisplayContent = getDefaultDisplayContentLocked(); pw.print(" mRotation="); pw.print(defaultDisplayContent.getRotation()); pw.print(" mLastWindowForcedOrientation="); pw.print(defaultDisplayContent.getLastWindowForcedOrientation()); pw.print(" mLastOrientation="); pw.println(defaultDisplayContent.getLastOrientation()); pw.print(" waitingForConfig="); Loading Loading
services/core/java/com/android/server/wm/DisplayContent.java +45 −58 Original line number Diff line number Diff line Loading @@ -400,14 +400,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo /** @see #getCurrentOverrideConfigurationChanges */ private int mCurrentOverrideConfigurationChanges; /** * Orientation forced by some window. If there is no visible window that specifies orientation * it is set to {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}. * * @see NonAppWindowContainers#getOrientation() */ private int mLastWindowForcedOrientation = SCREEN_ORIENTATION_UNSPECIFIED; /** * Last orientation forced by the keyguard. It is applied when keyguard is shown and is not * occluded. Loading Loading @@ -1283,11 +1275,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return mDisplayRotation.getLastOrientation(); } @ScreenOrientation int getLastWindowForcedOrientation() { return mLastWindowForcedOrientation; } void registerRemoteAnimations(RemoteAnimationDefinition definition) { mAppTransitionController.registerRemoteAnimations(definition); } Loading Loading @@ -2134,16 +2121,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } if (mWmService.mDisplayFrozen) { if (mLastWindowForcedOrientation != SCREEN_ORIENTATION_UNSPECIFIED) { ProtoLog.v(WM_DEBUG_ORIENTATION, "Display id=%d is frozen, return %d", mDisplayId, mLastWindowForcedOrientation); // If the display is frozen, some activities may be in the middle of restarting, and // thus have removed their old window. If the window has the flag to hide the lock // screen, then the lock screen can re-appear and inflict its own orientation on us. // Keep the orientation stable until this all settles down. return mLastWindowForcedOrientation; } else if (policy.isKeyguardLocked()) { if (policy.isKeyguardLocked()) { // Use the last orientation the while the display is frozen with the keyguard // locked. This could be the keyguard forced orientation or from a SHOW_WHEN_LOCKED // window. We don't want to check the show when locked window directly though as Loading @@ -2154,12 +2132,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo mDisplayId, getLastOrientation()); return getLastOrientation(); } } else { } final int orientation = mAboveAppWindowsContainers.getOrientation(); if (orientation != SCREEN_ORIENTATION_UNSET) { return orientation; } } // Top system windows are not requesting an orientation. Start searching from apps. return mTaskStackContainers.getOrientation(); Loading Loading @@ -4141,6 +4118,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo DisplayChildWindowContainer(WindowManagerService service) { super(service); // TODO(display-area): move to ConfigurationContainer? mOrientation = SCREEN_ORIENTATION_UNSET; } @Override Loading Loading @@ -4547,7 +4526,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } @Override int getOrientation() { int getOrientation(int candidate) { if (isStackVisible(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY)) { // Apps and their containers are not allowed to specify an orientation while the // docked stack is visible...except for the home stack if the docked stack is Loading @@ -4565,7 +4544,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return SCREEN_ORIENTATION_UNSPECIFIED; } final int orientation = super.getOrientation(); final int orientation = super.getOrientation(candidate); if (orientation != SCREEN_ORIENTATION_UNSET && orientation != SCREEN_ORIENTATION_BEHIND) { ProtoLog.v(WM_DEBUG_ORIENTATION, Loading Loading @@ -4820,9 +4799,23 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo token2.mOwnerCanManageAppTokens) ? -1 : 1; private final Predicate<WindowState> mGetOrientingWindow = w -> { if (!w.isVisibleLw() || !w.mLegacyPolicyVisibilityAfterAnim) { final WindowManagerPolicy policy = mWmService.mPolicy; if (policy.isKeyguardHostWindow(w.mAttrs)) { if (mWmService.mKeyguardGoingAway) { return false; } // Consider unoccluding only when all unknown visibilities have been // resolved, as otherwise we just may be starting another occluding activity. final boolean isUnoccluding = mDisplayContent.mAppTransition.getAppTransition() == TRANSIT_KEYGUARD_UNOCCLUDE && mDisplayContent.mUnknownAppVisibilityController.allResolved(); // If keyguard is showing, or we're unoccluding, force the keyguard's orientation, // even if SystemUI hasn't updated the attrs yet. if (policy.isKeyguardShowingAndNotOccluded() || isUnoccluding) { return true; } } final int req = w.mAttrs.screenOrientation; if (req == SCREEN_ORIENTATION_UNSPECIFIED || req == SCREEN_ORIENTATION_BEHIND || req == SCREEN_ORIENTATION_UNSET) { Loading Loading @@ -4851,39 +4844,27 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } @Override int getOrientation() { final WindowManagerPolicy policy = mWmService.mPolicy; int getOrientation(int candidate) { // Find a window requesting orientation. final WindowState win = getWindow(mGetOrientingWindow); if (win != null) { final int req = win.mAttrs.screenOrientation; if (policy.isKeyguardHostWindow(win.mAttrs)) { mLastKeyguardForcedOrientation = req; if (mWmService.mKeyguardGoingAway) { // Keyguard can't affect the orientation if it is going away... mLastWindowForcedOrientation = SCREEN_ORIENTATION_UNSPECIFIED; return SCREEN_ORIENTATION_UNSET; } } int req = win.mAttrs.screenOrientation; ProtoLog.v(WM_DEBUG_ORIENTATION, "%s forcing orientation to %d for display id=%d", win, req, mDisplayId); return (mLastWindowForcedOrientation = req); if (mWmService.mPolicy.isKeyguardHostWindow(win.mAttrs)) { // SystemUI controls the Keyguard orientation asynchronously, and mAttrs may be // stale. We record / use the last known override. if (req != SCREEN_ORIENTATION_UNSET && req != SCREEN_ORIENTATION_UNSPECIFIED) { mDisplayContent.mLastKeyguardForcedOrientation = req; } else { req = mDisplayContent.mLastKeyguardForcedOrientation; } mLastWindowForcedOrientation = SCREEN_ORIENTATION_UNSPECIFIED; // Only allow force setting the orientation when all unknown visibilities have been // resolved, as otherwise we just may be starting another occluding activity. final boolean isUnoccluding = mAppTransition.getAppTransition() == TRANSIT_KEYGUARD_UNOCCLUDE && mUnknownAppVisibilityController.allResolved(); if (policy.isKeyguardShowingAndNotOccluded() || isUnoccluding) { return mLastKeyguardForcedOrientation; } return SCREEN_ORIENTATION_UNSET; return req; } return candidate; } @Override Loading Loading @@ -4929,6 +4910,12 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo mNeedsLayer = true; } @Override int getOrientation(int candidate) { // IME does not participate in orientation. return candidate; } @Override boolean forAllWindows(ToBooleanFunction<WindowState> callback, boolean traverseTopToBottom) { Loading
services/core/java/com/android/server/wm/WindowManagerService.java +4 −6 Original line number Diff line number Diff line Loading @@ -5998,8 +5998,6 @@ public class WindowManagerService extends IWindowManager.Stub pw.print(" apps="); pw.print(mAppsFreezingScreen); final DisplayContent defaultDisplayContent = getDefaultDisplayContentLocked(); pw.print(" mRotation="); pw.print(defaultDisplayContent.getRotation()); pw.print(" mLastWindowForcedOrientation="); pw.print(defaultDisplayContent.getLastWindowForcedOrientation()); pw.print(" mLastOrientation="); pw.println(defaultDisplayContent.getLastOrientation()); pw.print(" waitingForConfig="); Loading