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

Commit ffd57465 authored by Shivam Agrawal's avatar Shivam Agrawal Committed by Android (Google) Code Review
Browse files

Merge "Remove Handler for Syncing Config Changes"

parents 38dd28ca 6472e0ed
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
        mDisplayId = display.getDisplayId();
        mDisplay = display;
        mDisplayContent = createDisplayContent();
        mDisplayContent.reconfigureDisplayLocked();
        updateBounds();
    }

+42 −25
Original line number Diff line number Diff line
@@ -122,7 +122,6 @@ import static com.android.server.wm.WindowManagerService.CUSTOM_SCREEN_ROTATION;
import static com.android.server.wm.WindowManagerService.H.REPORT_FOCUS_CHANGE;
import static com.android.server.wm.WindowManagerService.H.REPORT_HARD_KEYBOARD_STATUS_CHANGE;
import static com.android.server.wm.WindowManagerService.H.REPORT_LOSING_FOCUS;
import static com.android.server.wm.WindowManagerService.H.SEND_NEW_CONFIGURATION;
import static com.android.server.wm.WindowManagerService.H.UPDATE_DOCKED_STACK_DIVIDER;
import static com.android.server.wm.WindowManagerService.H.WINDOW_HIDE_TIMEOUT;
import static com.android.server.wm.WindowManagerService.LAYOUT_REPEAT_THRESHOLD;
@@ -1212,20 +1211,40 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        }
    }

    /** Notify the configuration change of this display. */
    void postNewConfigurationToHandler() {
        mWmService.mH.obtainMessage(SEND_NEW_CONFIGURATION, this).sendToTarget();
    void reconfigureDisplayLocked() {
        if (!isReady()) {
            return;
        }
        configureDisplayPolicy();
        setLayoutNeeded();

        boolean configChanged = updateOrientationFromAppTokens();
        final Configuration currentDisplayConfig = getConfiguration();
        mTmpConfiguration.setTo(currentDisplayConfig);
        computeScreenConfiguration(mTmpConfiguration);
        configChanged |= currentDisplayConfig.diff(mTmpConfiguration) != 0;

        if (configChanged) {
            mWaitingForConfig = true;
            mWmService.startFreezingDisplayLocked(0 /* exitAnim */, 0 /* enterAnim */, this);
            sendNewConfiguration();
        }

        mWmService.mWindowPlacerLocked.performSurfacePlacement();
    }

    void sendNewConfiguration() {
        synchronized (mWmService.mGlobalLock) {
            final boolean configUpdated = mAcitvityDisplay
                    .updateDisplayOverrideConfigurationLocked();
            if (!configUpdated) {
        if (!isReady() || mAcitvityDisplay == null) {
            return;
        }
        final boolean configUpdated = mAcitvityDisplay.updateDisplayOverrideConfigurationLocked();
        if (configUpdated) {
            return;
        }
        // Something changed (E.g. device rotation), but no configuration update is needed.
                // E.g. changing device rotation by 180 degrees. Go ahead and perform surface
                // placement to unfreeze the display since we froze it when the rotation was updated
                // in DisplayContent#updateRotationUnchecked.
        // E.g. changing device rotation by 180 degrees. Go ahead and perform surface placement to
        // unfreeze the display since we froze it when the rotation was updated in
        // DisplayContent#updateRotationUnchecked.
        if (mWaitingForConfig) {
            mWaitingForConfig = false;
            mWmService.mLastFinishedFreezeSource = "config-unchanged";
@@ -1233,8 +1252,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            mWmService.mWindowPlacerLocked.performSurfacePlacement();
        }
    }
        }
    }

    @Override
    boolean onDescendantOrientationChanged(IBinder freezeDisplayToken,
@@ -1351,7 +1368,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    boolean updateRotationAndSendNewConfigIfNeeded() {
        final boolean changed = updateRotationUnchecked(false /* forceUpdate */);
        if (changed) {
            postNewConfigurationToHandler();
            sendNewConfiguration();
        }
        return changed;
    }
@@ -2292,7 +2309,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            mInitialDisplayHeight = newHeight;
            mInitialDisplayDensity = newDensity;
            mInitialDisplayCutout = newCutout;
            mWmService.reconfigureDisplayLocked(this);
            reconfigureDisplayLocked();
        }
    }

@@ -2345,7 +2362,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        final boolean updateCurrent = userId == UserHandle.USER_CURRENT;
        if (mWmService.mCurrentUserId == userId || updateCurrent) {
            mBaseDisplayDensity = density;
            mWmService.reconfigureDisplayLocked(this);
            reconfigureDisplayLocked();
        }
        if (updateCurrent) {
            // We are applying existing settings so no need to save it again.
@@ -2366,7 +2383,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

        mDisplayScalingDisabled = (mode != FORCE_SCALING_MODE_AUTO);
        Slog.i(TAG_WM, "Using display scaling mode: " + (mDisplayScalingDisabled ? "off" : "auto"));
        mWmService.reconfigureDisplayLocked(this);
        reconfigureDisplayLocked();

        mWmService.mDisplayWindowSettings.setForcedScalingMode(this, mode);
    }
@@ -2385,7 +2402,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

        Slog.i(TAG_WM, "Using new display size: " + width + "x" + height);
        updateBaseDisplayMetrics(width, height, mBaseDisplayDensity);
        mWmService.reconfigureDisplayLocked(this);
        reconfigureDisplayLocked();

        if (clear) {
            width = height = 0;
@@ -3730,7 +3747,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout");
                if (updateOrientationFromAppTokens()) {
                    setLayoutNeeded();
                    postNewConfigurationToHandler();
                    sendNewConfiguration();
                }
            }

+4 −1
Original line number Diff line number Diff line
@@ -133,7 +133,10 @@ final class InputManagerCallback implements InputManagerService.WindowManagerCal
    @Override
    public void notifyConfigurationChanged() {
        // TODO(multi-display): Notify proper displays that are associated with this input device.
        mService.mRoot.getDisplayContent(DEFAULT_DISPLAY).sendNewConfiguration();

        synchronized (mService.mGlobalLock) {
            mService.getDefaultDisplayContentLocked().sendNewConfiguration();
        }

        synchronized (mInputDevicesReadyMonitor) {
            if (!mInputDevicesReady) {
+1 −3
Original line number Diff line number Diff line
@@ -248,8 +248,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            dc.configureDisplayPolicy();
        }

        mWmService.reconfigureDisplayLocked(dc);

        return dc;
    }

@@ -267,7 +265,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            }

            displayContent.initializeDisplayOverrideConfiguration();
            mWmService.reconfigureDisplayLocked(displayContent);
            displayContent.reconfigureDisplayLocked();

            // We need to update global configuration as well if config of default display has
            // changed. Do it inline because ATMS#retrieveSettings() will soon update the
+10 −52
Original line number Diff line number Diff line
@@ -79,7 +79,6 @@ import static com.android.server.wm.ActivityStackSupervisor.PRESERVE_WINDOWS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG;
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_CONFIGURATION;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DISPLAY;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT;
@@ -1651,6 +1650,7 @@ public class WindowManagerService extends IWindowManager.Stub

            if (display != null) {
                displayContent = mRoot.createDisplayContent(display, null /* activityDisplay */);
                displayContent.reconfigureDisplayLocked();
            }
        }

@@ -3751,7 +3751,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        layoutNeeded = true;
                    }
                    if (rotationChanged || alwaysSendConfiguration) {
                        displayContent.postNewConfigurationToHandler();
                        displayContent.sendNewConfiguration();
                    }
                }

@@ -4421,7 +4421,7 @@ public class WindowManagerService extends IWindowManager.Stub
            mDisplayReady = true;
            // Reconfigure all displays to make sure that forced properties and
            // DisplayWindowSettings are applied.
            mRoot.forAllDisplays(this::reconfigureDisplayLocked);
            mRoot.forAllDisplays(DisplayContent::reconfigureDisplayLocked);
            mIsTouchDevice = mContext.getPackageManager().hasSystemFeature(
                    PackageManager.FEATURE_TOUCHSCREEN);
        }
@@ -4500,7 +4500,6 @@ public class WindowManagerService extends IWindowManager.Stub
        public static final int FORCE_GC = 15;
        public static final int ENABLE_SCREEN = 16;
        public static final int APP_FREEZE_TIMEOUT = 17;
        public static final int SEND_NEW_CONFIGURATION = 18;
        public static final int REPORT_WINDOWS_CHANGE = 19;

        public static final int REPORT_HARD_KEYBOARD_STATUS_CHANGE = 22;
@@ -4712,23 +4711,6 @@ public class WindowManagerService extends IWindowManager.Stub
                    break;
                }

                case SEND_NEW_CONFIGURATION: {
                    final DisplayContent displayContent = (DisplayContent) msg.obj;
                    removeMessages(SEND_NEW_CONFIGURATION, displayContent);
                    if (displayContent.isReady()) {
                        displayContent.sendNewConfiguration();
                    } else {
                        // Message could come after display has already been removed.
                        if (DEBUG_CONFIGURATION) {
                            final String reason = displayContent.getParent() == null
                                    ? "detached" : "unready";
                            Slog.w(TAG, "Trying to send configuration to " + reason + " display="
                                    + displayContent);
                        }
                    }
                    break;
                }

                case REPORT_WINDOWS_CHANGE: {
                    if (mWindowsChanged) {
                        synchronized (mGlobalLock) {
@@ -5183,29 +5165,6 @@ public class WindowManagerService extends IWindowManager.Stub
        return 0;
    }

    void reconfigureDisplayLocked(@NonNull DisplayContent displayContent) {
        if (!displayContent.isReady()) {
            return;
        }
        displayContent.configureDisplayPolicy();
        displayContent.setLayoutNeeded();

        boolean configChanged = displayContent.updateOrientationFromAppTokens();
        final Configuration currentDisplayConfig = displayContent.getConfiguration();
        mTempConfiguration.setTo(currentDisplayConfig);
        displayContent.computeScreenConfiguration(mTempConfiguration);
        configChanged |= currentDisplayConfig.diff(mTempConfiguration) != 0;

        if (configChanged) {
            displayContent.mWaitingForConfig = true;
            startFreezingDisplayLocked(0 /* exitAnim */,
                    0 /* enterAnim */, displayContent);
            displayContent.postNewConfigurationToHandler();
        }

        mWindowPlacerLocked.performSurfacePlacement();
    }

    @Override
    public void setOverscan(int displayId, int left, int top, int right, int bottom) {
        if (mContext.checkCallingOrSelfPermission(WRITE_SECURE_SETTINGS)
@@ -5235,7 +5194,7 @@ public class WindowManagerService extends IWindowManager.Stub

        mDisplayWindowSettings.setOverscanLocked(displayInfo, left, top, right, bottom);

        reconfigureDisplayLocked(displayContent);
        displayContent.reconfigureDisplayLocked();
    }

    @Override
@@ -5547,7 +5506,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }

        if (configChanged) {
            displayContent.postNewConfigurationToHandler();
            displayContent.sendNewConfiguration();
        }
        mLatencyTracker.onActionEnd(ACTION_ROTATE_SCREEN);
    }
@@ -6863,12 +6822,11 @@ public class WindowManagerService extends IWindowManager.Stub
            int lastWindowingMode = displayContent.getWindowingMode();
            mDisplayWindowSettings.setWindowingModeLocked(displayContent, mode);

            reconfigureDisplayLocked(displayContent);
            displayContent.reconfigureDisplayLocked();

            if (lastWindowingMode != displayContent.getWindowingMode()) {
                // reconfigure won't detect this change in isolation because the windowing mode is
                // already set on the display, so fire off a new config now.
                mH.removeMessages(H.SEND_NEW_CONFIGURATION);

                final long origId = Binder.clearCallingIdentity();
                try {
@@ -6916,7 +6874,7 @@ public class WindowManagerService extends IWindowManager.Stub

            mDisplayWindowSettings.setRemoveContentModeLocked(displayContent, mode);

            reconfigureDisplayLocked(displayContent);
            displayContent.reconfigureDisplayLocked();
        }
    }

@@ -6955,7 +6913,7 @@ public class WindowManagerService extends IWindowManager.Stub
            mDisplayWindowSettings.setShouldShowWithInsecureKeyguardLocked(displayContent,
                    shouldShow);

            reconfigureDisplayLocked(displayContent);
            displayContent.reconfigureDisplayLocked();
        }
    }

@@ -6999,7 +6957,7 @@ public class WindowManagerService extends IWindowManager.Stub

            mDisplayWindowSettings.setShouldShowSystemDecorsLocked(displayContent, shouldShow);

            reconfigureDisplayLocked(displayContent);
            displayContent.reconfigureDisplayLocked();
        }
    }

@@ -7044,7 +7002,7 @@ public class WindowManagerService extends IWindowManager.Stub

            mDisplayWindowSettings.setShouldShowImeLocked(displayContent, shouldShow);

            reconfigureDisplayLocked(displayContent);
            displayContent.reconfigureDisplayLocked();
        }
    }

Loading