diff options
5 files changed, 67 insertions, 83 deletions
diff --git a/services/art-profile b/services/art-profile index 742ca1c94a77..bdd49de3ef02 100644 --- a/services/art-profile +++ b/services/art-profile @@ -2271,6 +2271,7 @@ HPLcom/android/server/wm/DisplayContent;->lambda$new$8(Lcom/android/server/wm/Di HPLcom/android/server/wm/DisplayContent;->prepareSurfaces()V HPLcom/android/server/wm/DisplayContent;->resetAnimationBackgroundAnimator()V HPLcom/android/server/wm/DisplayContent;->skipTraverseChild(Lcom/android/server/wm/WindowContainer;)Z +HPLcom/android/server/wm/DisplayContent;->updateOrientationFromAppTokens(Z)Z HPLcom/android/server/wm/DisplayContent;->updateTouchExcludeRegion()V HPLcom/android/server/wm/DockedStackDividerController;->isResizing()Z HPLcom/android/server/wm/DragDropController;->dragDropActiveLocked()Z @@ -2451,7 +2452,6 @@ HPLcom/android/server/wm/WindowManagerService;->relayoutWindow(Lcom/android/serv HPLcom/android/server/wm/WindowManagerService;->resetPriorityAfterLockedSection()V HPLcom/android/server/wm/WindowManagerService;->scheduleAnimationLocked()V HPLcom/android/server/wm/WindowManagerService;->traceStateLocked(Ljava/lang/String;)V -HPLcom/android/server/wm/WindowManagerService;->updateOrientationFromAppTokensLocked(IZ)Z HPLcom/android/server/wm/WindowManagerService;->windowForClientLocked(Lcom/android/server/wm/Session;Landroid/os/IBinder;Z)Lcom/android/server/wm/WindowState; HPLcom/android/server/wm/WindowManagerThreadPriorityBooster;->boost()V HPLcom/android/server/wm/WindowManagerThreadPriorityBooster;->reset()V @@ -18137,6 +18137,7 @@ PLcom/android/server/wm/DisplayContent;->updateBaseDisplayMetricsIfNeeded()V PLcom/android/server/wm/DisplayContent;->updateBounds()V PLcom/android/server/wm/DisplayContent;->updateDisplayAndOrientation(I)Landroid/view/DisplayInfo; PLcom/android/server/wm/DisplayContent;->updateDisplayInfo()V +PLcom/android/server/wm/DisplayContent;->updateOrientationFromAppTokens()Z PLcom/android/server/wm/DisplayContent;->updateRotationUnchecked()Z PLcom/android/server/wm/DisplayContent;->updateRotationUnchecked(Z)Z PLcom/android/server/wm/DisplayContent;->updateStackBoundsAfterConfigChange(Ljava/util/List;)V @@ -18906,7 +18907,6 @@ PLcom/android/server/wm/WindowManagerService;->updateFocusedWindowLocked(IZ)Z PLcom/android/server/wm/WindowManagerService;->updateNonSystemOverlayWindowsVisibilityIfNeeded(Lcom/android/server/wm/WindowState;Z)V PLcom/android/server/wm/WindowManagerService;->updateOrientationFromAppTokens(Landroid/content/res/Configuration;Landroid/os/IBinder;I)Landroid/content/res/Configuration; PLcom/android/server/wm/WindowManagerService;->updateOrientationFromAppTokens(Landroid/content/res/Configuration;Landroid/os/IBinder;IZ)Landroid/content/res/Configuration; -PLcom/android/server/wm/WindowManagerService;->updateOrientationFromAppTokensLocked(I)Z PLcom/android/server/wm/WindowManagerService;->updateOrientationFromAppTokensLocked(Landroid/content/res/Configuration;Landroid/os/IBinder;IZ)Landroid/content/res/Configuration; PLcom/android/server/wm/WindowManagerService;->updatePointerIcon(Landroid/view/IWindow;)V PLcom/android/server/wm/WindowManagerService;->updateRotation(ZZ)V diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index ba030340ef36..348b2afe5bd5 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -314,7 +314,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo * Last applied orientation of the display. * Constants as per {@link android.content.pm.ActivityInfo.ScreenOrientation}. * - * @see WindowManagerService#updateOrientationFromAppTokensLocked(boolean, int) + * @see #updateOrientationFromAppTokens() */ private int mLastOrientation = SCREEN_ORIENTATION_UNSPECIFIED; @@ -1045,18 +1045,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return mLastOrientation; } - void setLastOrientation(int orientation) { - mLastOrientation = orientation; - } - boolean getAltOrientation() { return mAltOrientation; } - void setAltOrientation(boolean altOrientation) { - mAltOrientation = altOrientation; - } - int getLastWindowForcedOrientation() { return mLastWindowForcedOrientation; } @@ -1109,6 +1101,34 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return true; } + /** Notify the configuration change of this display. */ + void sendNewConfiguration() { + mService.mH.obtainMessage(SEND_NEW_CONFIGURATION, this).sendToTarget(); + } + + /** + * Determine the new desired orientation of this display. + * + * The orientation is computed from non-application windows first. If none of the + * non-application windows specify orientation, the orientation is computed from application + * tokens. + * + * @return {@code true} if the orientation is changed. + */ + boolean updateOrientationFromAppTokens() { + return updateOrientationFromAppTokens(false /* forceUpdate */); + } + + boolean updateOrientationFromAppTokens(boolean forceUpdate) { + final int req = getOrientation(); + if (req != mLastOrientation || forceUpdate) { + mLastOrientation = req; + mDisplayRotation.setCurrentOrientation(req); + return updateRotationUnchecked(forceUpdate); + } + return false; + } + /** * Update rotation of the display and send configuration if the rotation is changed. * @@ -1117,7 +1137,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo boolean updateRotationAndSendNewConfigIfNeeded() { final boolean changed = updateRotationUnchecked(false /* forceUpdate */); if (changed) { - mService.mH.obtainMessage(SEND_NEW_CONFIGURATION, mDisplayId).sendToTarget(); + sendNewConfiguration(); } return changed; } @@ -2343,6 +2363,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo mWindowingLayer.release(); mOverlayLayer.release(); } finally { + mDisplayReady = false; mRemovingDisplay = false; } @@ -3348,9 +3369,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo if ((pendingLayoutChanges & FINISH_LAYOUT_REDO_CONFIG) != 0) { if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout"); - if (mService.updateOrientationFromAppTokensLocked(mDisplayId)) { + if (updateOrientationFromAppTokens()) { setLayoutNeeded(); - mService.mH.obtainMessage(SEND_NEW_CONFIGURATION, mDisplayId).sendToTarget(); + sendNewConfiguration(); } } diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index 62078f722434..67fe5c409b69 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -42,7 +42,6 @@ import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS; import static com.android.server.wm.WindowManagerDebugConfig.TAG_KEEP_SCREEN_ON; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; -import static com.android.server.wm.WindowManagerService.H.SEND_NEW_CONFIGURATION; import static com.android.server.wm.WindowManagerService.H.WINDOW_FREEZE_TIMEOUT; import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL; import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_PLACING_SURFACES; @@ -911,10 +910,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> { boolean changed = false; for (int i = mChildren.size() - 1; i >= 0; i--) { final DisplayContent displayContent = mChildren.get(i); - if (displayContent.updateRotationUnchecked()) { + if (displayContent.updateRotationAndSendNewConfigIfNeeded()) { changed = true; - mService.mH.obtainMessage(SEND_NEW_CONFIGURATION, displayContent.getDisplayId()) - .sendToTarget(); } } return changed; diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 96fc2e241a48..c0e8c322602b 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -1455,7 +1455,7 @@ public class WindowManagerService extends IWindowManager.Stub if (localLOGV || DEBUG_ADD_REMOVE) Slog.v(TAG_WM, "addWindow: New client " + client.asBinder() + ": window=" + win + " Callers=" + Debug.getCallers(5)); - if (win.isVisibleOrAdding() && updateOrientationFromAppTokensLocked(displayId)) { + if (win.isVisibleOrAdding() && displayContent.updateOrientationFromAppTokens()) { reportNewConfig = true; } } @@ -2067,7 +2067,7 @@ public class WindowManagerService extends IWindowManager.Stub Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "relayoutWindow: updateOrientationFromAppTokens"); - configChanged = updateOrientationFromAppTokensLocked(displayId); + configChanged = dc.updateOrientationFromAppTokens(); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); if (toBeDisplayed && win.mIsWallpaper) { @@ -2358,6 +2358,15 @@ public class WindowManagerService extends IWindowManager.Stub return config; } + /** + * Update orientation of the target display, returning a non-null new Configuration if it has + * changed from the current orientation. If a non-null configuration is returned, someone must + * call {@link #setNewDisplayOverrideConfiguration(Configuration, int)} to tell the window + * manager it can unfreeze the screen. This will typically be done by calling + * {@link #sendNewConfiguration(int)}. + * + * @see android.view.IWindowManager#updateOrientationFromAppTokens(Configuration, IBinder, int) + */ private Configuration updateOrientationFromAppTokensLocked(Configuration currentConfig, IBinder freezeThisOneIfNeeded, int displayId, boolean forceUpdate) { if (!mDisplayReady) { @@ -2365,7 +2374,8 @@ public class WindowManagerService extends IWindowManager.Stub } Configuration config = null; - if (updateOrientationFromAppTokensLocked(displayId, forceUpdate)) { + final DisplayContent dc = mRoot.getDisplayContent(displayId); + if (dc != null && dc.updateOrientationFromAppTokens(forceUpdate)) { // If we changed the orientation but mOrientationChangeComplete is already true, // we used seamless rotation, and we don't need to freeze the screen. if (freezeThisOneIfNeeded != null && !mRoot.mOrientationChangeComplete) { @@ -2400,43 +2410,6 @@ public class WindowManagerService extends IWindowManager.Stub return config; } - /** - * Determine the new desired orientation of the display, returning a non-null new Configuration - * if it has changed from the current orientation. IF TRUE IS RETURNED SOMEONE MUST CALL - * {@link #setNewDisplayOverrideConfiguration(Configuration, int)} TO TELL THE WINDOW MANAGER IT - * CAN UNFREEZE THE SCREEN. This will typically be done for you if you call - * {@link #sendNewConfiguration(int)}. - * - * The orientation is computed from non-application windows first. If none of the - * non-application windows specify orientation, the orientation is computed from application - * tokens. - * @see android.view.IWindowManager#updateOrientationFromAppTokens(Configuration, IBinder, int) - */ - boolean updateOrientationFromAppTokensLocked(int displayId) { - return updateOrientationFromAppTokensLocked(displayId, false /* forceUpdate */); - } - - boolean updateOrientationFromAppTokensLocked(int displayId, boolean forceUpdate) { - long ident = Binder.clearCallingIdentity(); - try { - final DisplayContent dc = mRoot.getDisplayContent(displayId); - if (dc == null) { - return false; - } - final int req = dc.getOrientation(); - if (req != dc.getLastOrientation() || forceUpdate) { - dc.setLastOrientation(req); - //send a message to Policy indicating orientation change to take - //action like disabling/enabling sensors etc., - dc.getDisplayRotation().setCurrentOrientation(req); - return dc.updateRotationUnchecked(forceUpdate); - } - return false; - } finally { - Binder.restoreCallingIdentity(ident); - } - } - @Override public int[] setNewDisplayOverrideConfiguration(Configuration overrideConfig, int displayId) { if (!checkCallingPermission(MANAGE_APP_TOKENS, "setNewDisplayOverrideConfiguration()")) { @@ -3683,8 +3656,7 @@ public class WindowManagerService extends IWindowManager.Stub layoutNeeded = true; } if (rotationChanged || alwaysSendConfiguration) { - mH.obtainMessage(H.SEND_NEW_CONFIGURATION, displayContent.getDisplayId()) - .sendToTarget(); + displayContent.sendNewConfiguration(); } } @@ -4579,15 +4551,17 @@ public class WindowManagerService extends IWindowManager.Stub } case SEND_NEW_CONFIGURATION: { - removeMessages(SEND_NEW_CONFIGURATION, msg.obj); - final int displayId = (Integer) msg.obj; - if (mRoot.getDisplayContent(displayId) != null) { - sendNewConfiguration(displayId); + final DisplayContent displayContent = (DisplayContent) msg.obj; + removeMessages(SEND_NEW_CONFIGURATION, displayContent); + if (displayContent.isReady()) { + sendNewConfiguration(displayContent.getDisplayId()); } else { // Message could come after display has already been removed. if (DEBUG_CONFIGURATION) { - Slog.w(TAG, "Trying to send configuration to non-existing displayId=" - + displayId); + final String reason = displayContent.getParent() == null + ? "detached" : "unready"; + Slog.w(TAG, "Trying to send configuration to " + reason + " display=" + + displayContent); } } break; @@ -4911,7 +4885,6 @@ public class WindowManagerService extends IWindowManager.Stub /** The global settings only apply to default display. */ private void applyForcedPropertiesForDefaultDisplay() { final DisplayContent displayContent = getDefaultDisplayContentLocked(); - boolean changed = false; // Display size. String sizeStr = Settings.Global.getString(mContext.getContentResolver(), Settings.Global.DISPLAY_SIZE_FORCED); @@ -4930,7 +4903,6 @@ public class WindowManagerService extends IWindowManager.Stub Slog.i(TAG_WM, "FORCED DISPLAY SIZE: " + width + "x" + height); displayContent.updateBaseDisplayMetrics(width, height, displayContent.mBaseDisplayDensity); - changed = true; } } catch (NumberFormatException ex) { } @@ -4941,7 +4913,6 @@ public class WindowManagerService extends IWindowManager.Stub final int density = getForcedDisplayDensityForUserLocked(mCurrentUserId); if (density != 0) { displayContent.mBaseDisplayDensity = density; - changed = true; } // Display scaling mode. @@ -4950,11 +4921,6 @@ public class WindowManagerService extends IWindowManager.Stub if (mode != 0) { Slog.i(TAG_WM, "FORCED DISPLAY SCALING DISABLED"); displayContent.mDisplayScalingDisabled = true; - changed = true; - } - - if (changed) { - reconfigureDisplayLocked(displayContent); } } @@ -5081,8 +5047,7 @@ public class WindowManagerService extends IWindowManager.Stub displayContent.configureDisplayPolicy(); displayContent.setLayoutNeeded(); - final int displayId = displayContent.getDisplayId(); - boolean configChanged = updateOrientationFromAppTokensLocked(displayId); + boolean configChanged = displayContent.updateOrientationFromAppTokens(); final Configuration currentDisplayConfig = displayContent.getConfiguration(); mTempConfiguration.setTo(currentDisplayConfig); displayContent.computeScreenConfiguration(mTempConfiguration); @@ -5092,7 +5057,7 @@ public class WindowManagerService extends IWindowManager.Stub mWaitingForConfig = true; startFreezingDisplayLocked(0 /* exitAnim */, 0 /* enterAnim */, displayContent); - mH.obtainMessage(H.SEND_NEW_CONFIGURATION, displayId).sendToTarget(); + displayContent.sendNewConfiguration(); } mWindowPlacerLocked.performSurfacePlacement(); @@ -5396,7 +5361,6 @@ public class WindowManagerService extends IWindowManager.Stub if (CUSTOM_SCREEN_ROTATION && screenRotationAnimation != null && screenRotationAnimation.hasScreenshot()) { if (DEBUG_ORIENTATION) Slog.i(TAG_WM, "**** Dismissing screen rotation animation"); - // TODO(multidisplay): rotation on main screen only. DisplayInfo displayInfo = displayContent.getDisplayInfo(); // Get rotation animation again, with new top window if (!mPolicy.validateRotationAnimationLw(mExitAnimId, mEnterAnimId, false)) { @@ -5426,7 +5390,7 @@ public class WindowManagerService extends IWindowManager.Stub // to avoid inconsistent states. However, something interesting // could have actually changed during that time so re-evaluate it // now to catch that. - configChanged = updateOrientationFromAppTokensLocked(displayId); + configChanged = displayContent != null && displayContent.updateOrientationFromAppTokens(); // A little kludge: a lot could have happened while the // display was frozen, so now that we are coming back we @@ -5444,7 +5408,7 @@ public class WindowManagerService extends IWindowManager.Stub } if (configChanged) { - mH.obtainMessage(H.SEND_NEW_CONFIGURATION, displayId).sendToTarget(); + displayContent.sendNewConfiguration(); } mLatencyTracker.onActionEnd(ACTION_ROTATE_SCREEN); } diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 9dc77219e8db..febb9ba8a4ee 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -103,7 +103,6 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER_LIGHT; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; -import static com.android.server.wm.WindowManagerService.H.SEND_NEW_CONFIGURATION; import static com.android.server.wm.WindowManagerService.MAX_ANIMATION_DURATION; import static com.android.server.wm.WindowManagerService.TYPE_LAYER_MULTIPLIER; import static com.android.server.wm.WindowManagerService.TYPE_LAYER_OFFSET; @@ -1942,8 +1941,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP removeImmediately(); // Removing a visible window will effect the computed orientation // So just update orientation if needed. - if (wasVisible && mService.updateOrientationFromAppTokensLocked(displayId)) { - mService.mH.obtainMessage(SEND_NEW_CONFIGURATION, displayId).sendToTarget(); + if (wasVisible) { + final DisplayContent displayContent = getDisplayContent(); + if (displayContent.updateOrientationFromAppTokens()) { + displayContent.sendNewConfiguration(); + } } mService.updateFocusedWindowLocked(isFocused() ? UPDATE_FOCUS_REMOVING_FOCUS |