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

Commit 0d04cf33 authored by Menghan Li's avatar Menghan Li Committed by Android (Google) Code Review
Browse files

Merge "fix(EDT): Avoid memory leak with cached UIMondeManager" into main

parents 75c4c6e6 dbd7ad55
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -555,8 +555,6 @@ public final class ViewRootImpl implements ViewParent,
    @UiContext
    public final Context mContext;
    private UiModeManager mUiModeManager;
    @UnsupportedAppUsage
    final IWindowSession mWindowSession;
    @NonNull Display mDisplay;
@@ -2079,8 +2077,7 @@ public final class ViewRootImpl implements ViewParent,
                // We also ignore dark theme, since the app developer can override the user's
                // preference for dark mode in configuration.uiMode. Instead, we assume that both
                // force invert and the system's dark theme are enabled.
                if (getUiModeManager().getForceInvertState() ==
                        UiModeManager.FORCE_INVERT_TYPE_DARK) {
                if (shouldApplyForceInvertDark()) {
                    final boolean isLightTheme =
                        a.getBoolean(R.styleable.Theme_isLightTheme, false);
                    // TODO: b/372558459 - Also check the background ColorDrawable color lightness
@@ -2108,6 +2105,14 @@ public final class ViewRootImpl implements ViewParent,
        }
    }
    private boolean shouldApplyForceInvertDark() {
        final UiModeManager uiModeManager = mContext.getSystemService(UiModeManager.class);
        if (uiModeManager == null) {
            return false;
        }
        return uiModeManager.getForceInvertState() == UiModeManager.FORCE_INVERT_TYPE_DARK;
    }
    private void updateForceDarkMode() {
        if (mAttachInfo.mThreadedRenderer == null) return;
        if (mAttachInfo.mThreadedRenderer.setForceDark(determineForceDarkType())) {
@@ -9413,13 +9418,6 @@ public final class ViewRootImpl implements ViewParent,
        return mAudioManager;
    }
    private UiModeManager getUiModeManager() {
        if (mUiModeManager == null) {
            mUiModeManager = mContext.getSystemService(UiModeManager.class);
        }
        return mUiModeManager;
    }
    private Vibrator getSystemVibrator() {
        if (mVibrator == null) {
            mVibrator = mContext.getSystemService(Vibrator.class);