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

Commit a40dd998 authored by Tiger Huang's avatar Tiger Huang Committed by Android (Google) Code Review
Browse files

Merge "Refine updateSystemUiVisibilityLw for performance" into sc-v2-dev

parents a4bd8de9 f6205bfa
Loading
Loading
Loading
Loading
+2 −13
Original line number Diff line number Diff line
@@ -134,7 +134,6 @@ import static com.android.server.wm.WindowManagerService.H.REPORT_HARD_KEYBOARD_
import static com.android.server.wm.WindowManagerService.H.WINDOW_HIDE_TIMEOUT;
import static com.android.server.wm.WindowManagerService.LAYOUT_REPEAT_THRESHOLD;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_PLACING_SURFACES;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_REMOVING_FOCUS;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_ASSIGN_LAYERS;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES;
import static com.android.server.wm.WindowManagerService.WINDOWS_FREEZING_SCREENS_TIMEOUT;
@@ -450,6 +449,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    // Accessed directly by all users.
    private boolean mLayoutNeeded;
    int pendingLayoutChanges;
    boolean mLayoutAndAssignWindowLayersScheduled;

    /**
     * Used to gate application window layout until we have sent the complete configuration.
@@ -3470,13 +3470,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            }
        }

        int focusChanged = getDisplayPolicy().focusChangedLw(oldFocus, newFocus);
        getDisplayPolicy().focusChangedLw(oldFocus, newFocus);

        if (imWindowChanged && oldFocus != mInputMethodWindow) {
            // Focus of the input method window changed. Perform layout if needed.
            if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
                performLayout(true /*initial*/,  updateInputWindows);
                focusChanged &= ~FINISH_LAYOUT_REDO_LAYOUT;
            } else if (mode == UPDATE_FOCUS_WILL_PLACE_SURFACES) {
                // Client will do the layout, but we need to assign layers
                // for handleNewWindowLocked() below.
@@ -3484,16 +3483,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            }
        }

        if ((focusChanged & FINISH_LAYOUT_REDO_LAYOUT) != 0) {
            // The change in focus caused us to need to do a layout.  Okay.
            setLayoutNeeded();
            if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
                performLayout(true /*initial*/, updateInputWindows);
            } else if (mode == UPDATE_FOCUS_REMOVING_FOCUS) {
                mWmService.mRoot.performSurfacePlacement();
            }
        }

        if (mode != UPDATE_FOCUS_WILL_ASSIGN_LAYERS) {
            // If we defer assigning layers, then the caller is responsible for doing this part.
            getInputMonitor().setInputFocusLw(newFocus, updateInputWindows);
+10 −23
Original line number Diff line number Diff line
@@ -1984,11 +1984,7 @@ public class DisplayPolicy {
            mTopIsFullscreen = topIsFullscreen;
        }

        if (updateSystemUiVisibilityLw()) {
            // If the navigation bar has been hidden or shown, we need to do another
            // layout pass to update that window.
            changes |= FINISH_LAYOUT_REDO_LAYOUT;
        }
        updateSystemBarAttributes();

        if (mShowingDream != mLastShowingDream) {
            mLastShowingDream = mShowingDream;
@@ -2524,18 +2520,13 @@ public class DisplayPolicy {
    /**
     * A new window has been focused.
     */
    public int focusChangedLw(WindowState lastFocus, WindowState newFocus) {
    public void focusChangedLw(WindowState lastFocus, WindowState newFocus) {
        mFocusedWindow = newFocus;
        mLastFocusedWindow = lastFocus;
        if (mDisplayContent.isDefaultDisplay) {
            mService.mPolicy.onDefaultDisplayFocusChangedLw(newFocus);
        }
        if (updateSystemUiVisibilityLw()) {
            // If the navigation bar has been hidden or shown, we need to do another
            // layout pass to update that window.
            return FINISH_LAYOUT_REDO_LAYOUT;
        }
        return 0;
        updateSystemBarAttributes();
    }

    private void requestTransientBars(WindowState swipeTarget) {
@@ -2611,21 +2602,18 @@ public class DisplayPolicy {
        return mDisplayContent.getInsetsPolicy();
    }

    void resetSystemUiVisibilityLw() {
    void resetSystemBarAttributes() {
        mLastDisableFlags = 0;
        updateSystemUiVisibilityLw();
        updateSystemBarAttributes();
    }

    /**
     * @return {@code true} if the update may affect the layout.
     */
    boolean updateSystemUiVisibilityLw() {
    void updateSystemBarAttributes() {
        // If there is no window focused, there will be nobody to handle the events
        // anyway, so just hang on in whatever state we're in until things settle down.
        WindowState winCandidate = mFocusedWindow != null ? mFocusedWindow
                : mTopFullscreenOpaqueWindowState;
        if (winCandidate == null) {
            return false;
            return;
        }

        // The immersive mode confirmation should never affect the system bar visibility, otherwise
@@ -2641,7 +2629,7 @@ public class DisplayPolicy {
                    : lastFocusCanReceiveKeys ? mLastFocusedWindow
                            : mTopFullscreenOpaqueWindowState;
            if (winCandidate == null) {
                return false;
                return;
            }
        }
        final WindowState win = winCandidate;
@@ -2680,7 +2668,7 @@ public class DisplayPolicy {
                && Objects.equals(mFocusedApp, focusedApp)
                && mLastFocusIsFullscreen == isFullscreen
                && Arrays.equals(mLastStatusBarAppearanceRegions, appearanceRegions)) {
            return false;
            return;
        }
        if (mDisplayContent.isDefaultDisplay && mLastFocusIsFullscreen != isFullscreen
                && ((mLastAppearance ^ appearance) & APPEARANCE_LOW_PROFILE_BARS) != 0) {
@@ -2698,7 +2686,6 @@ public class DisplayPolicy {
        callStatusBarSafely(statusBar -> statusBar.onSystemBarAttributesChanged(displayId,
                appearance, appearanceRegions, isNavbarColorManagedByIme, behavior,
                requestedVisibilities, focusedApp));
        return true;
    }

    private int getStatusBarAppearance(WindowState opaque, WindowState opaqueOrDimming) {
@@ -2970,7 +2957,7 @@ public class DisplayPolicy {
                    return;
                }
                mPendingPanicGestureUptime = SystemClock.uptimeMillis();
                updateSystemUiVisibilityLw();
                updateSystemBarAttributes();
            }
        }
    };
+5 −2
Original line number Diff line number Diff line
@@ -376,8 +376,11 @@ class InsetsSourceProvider {
            return;
        }
        mClientVisible = clientVisible;
        if (!mDisplayContent.mLayoutAndAssignWindowLayersScheduled) {
            mDisplayContent.mLayoutAndAssignWindowLayersScheduled = true;
            mDisplayContent.mWmService.mH.obtainMessage(
                    LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED, mDisplayContent).sendToTarget();
        }
        updateVisibility();
    }

+1 −1
Original line number Diff line number Diff line
@@ -385,7 +385,7 @@ class InsetsStateController {
        if (changed) {
            notifyInsetsChanged();
            mDisplayContent.updateSystemGestureExclusion();
            mDisplayContent.getDisplayPolicy().updateSystemUiVisibilityLw();
            mDisplayContent.getDisplayPolicy().updateSystemBarAttributes();
        }
    }

+2 −1
Original line number Diff line number Diff line
@@ -3050,7 +3050,7 @@ public class WindowManagerService extends IWindowManager.Stub
        mSettingsObserver.updateSystemUiSettings(true /* handleChange */);
        synchronized (mGlobalLock) {
            // force a re-application of focused window sysui visibility on each display.
            mRoot.forAllDisplayPolicies(DisplayPolicy::resetSystemUiVisibilityLw);
            mRoot.forAllDisplayPolicies(DisplayPolicy::resetSystemBarAttributes);
        }
    }

@@ -5292,6 +5292,7 @@ public class WindowManagerService extends IWindowManager.Stub
                case LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED: {
                    synchronized (mGlobalLock) {
                        final DisplayContent displayContent = (DisplayContent) msg.obj;
                        displayContent.mLayoutAndAssignWindowLayersScheduled = false;
                        displayContent.layoutAndAssignWindowLayersIfNeeded();
                    }
                    break;
Loading