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

Commit 36884c17 authored by John Reck's avatar John Reck
Browse files

Adjust how force-dark is enabled

Move it off of a pure targetSdkVersion check and instead
to an opt-in based off of theme.

Bug: 128683634
Test: force dark tests
Change-Id: I95095a246f3482110b71cd63742db8b955516e50
parent 59a599c1
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -1213,15 +1213,12 @@ public final class ViewRootImpl implements ViewParent,

        boolean useAutoDark = getNightMode() == Configuration.UI_MODE_NIGHT_YES;

        // Allow debug.hwui.force_dark to override the target SDK check
        if (useAutoDark && !SystemProperties.getBoolean("debug.hwui.force_dark", false)) {
            useAutoDark = mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q;
        }

        if (useAutoDark) {
            boolean forceDarkAllowedDefault =
                    SystemProperties.getBoolean("debug.hwui.force_dark", false);
            TypedArray a = mContext.obtainStyledAttributes(R.styleable.Theme);
            useAutoDark = a.getBoolean(R.styleable.Theme_isLightTheme, true)
                    && a.getBoolean(R.styleable.Theme_forceDarkAllowed, true);
                    && a.getBoolean(R.styleable.Theme_forceDarkAllowed, forceDarkAllowedDefault);
            a.recycle();
        }