Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 22260862 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Consolidate the update of display orientation and configuration"

parents e914f1e4 4e61177c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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
+33 −12
Original line number Diff line number Diff line
@@ -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();
                }
            }

+1 −4
Original line number Diff line number Diff line
@@ -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;
+26 −62
Original line number Diff line number Diff line
@@ -1448,7 +1448,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;
            }
        }
@@ -2060,7 +2060,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) {
@@ -2351,6 +2351,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) {
@@ -2358,7 +2367,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) {
@@ -2393,43 +2403,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()")) {
@@ -3676,8 +3649,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        layoutNeeded = true;
                    }
                    if (rotationChanged || alwaysSendConfiguration) {
                        mH.obtainMessage(H.SEND_NEW_CONFIGURATION, displayContent.getDisplayId())
                                .sendToTarget();
                        displayContent.sendNewConfiguration();
                    }
                }

@@ -4572,15 +4544,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;
@@ -4904,7 +4878,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);
@@ -4923,7 +4896,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) {
                }
@@ -4934,7 +4906,6 @@ public class WindowManagerService extends IWindowManager.Stub
        final int density = getForcedDisplayDensityForUserLocked(mCurrentUserId);
        if (density != 0) {
            displayContent.mBaseDisplayDensity = density;
            changed = true;
        }

        // Display scaling mode.
@@ -4943,11 +4914,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);
        }
    }

@@ -5074,8 +5040,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);
@@ -5085,7 +5050,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();
@@ -5389,7 +5354,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)) {
@@ -5419,7 +5383,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
@@ -5437,7 +5401,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }

        if (configChanged) {
            mH.obtainMessage(H.SEND_NEW_CONFIGURATION, displayId).sendToTarget();
            displayContent.sendNewConfiguration();
        }
        mLatencyTracker.onActionEnd(ACTION_ROTATE_SCREEN);
    }
+5 −3
Original line number Diff line number Diff line
@@ -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