Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -773,6 +773,7 @@ package android { field public static final int isFeatureSplit = 16844123; // 0x101055b field public static final int isGame = 16843764; // 0x10103f4 field public static final int isIndicator = 16843079; // 0x1010147 field public static final int isLightTheme = 16844175; // 0x101058f field public static final int isModifier = 16843334; // 0x1010246 field public static final int isRepeatable = 16843336; // 0x1010248 field public static final int isScrollContainer = 16843342; // 0x101024e core/java/android/view/ThreadedRenderer.java +20 −0 Original line number Diff line number Diff line Loading @@ -974,6 +974,25 @@ public final class ThreadedRenderer { } } /** The root of everything */ public @NonNull RenderNode getRootNode() { return mRootNode; } private boolean mForceDark = false; /** * Whether or not the force-dark feature should be used for this renderer. */ public boolean setForceDark(boolean enable) { if (mForceDark != enable) { mForceDark = enable; nSetForceDark(mNativeProxy, enable); return true; } return false; } /** * Basic synchronous renderer. Currently only used to render the Magnifier, so use with care. * TODO: deduplicate against ThreadedRenderer. Loading Loading @@ -1253,4 +1272,5 @@ public final class ThreadedRenderer { private static native void nSetIsolatedProcess(boolean enabled); private static native void nSetContextPriority(int priority); private static native void nAllocateBuffers(long nativeProxy, Surface window); private static native void nSetForceDark(long nativeProxy, boolean enabled); } core/java/android/view/View.java +4 −0 Original line number Diff line number Diff line Loading @@ -15255,6 +15255,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * a value of 'true' will not override any 'false' value in its parent chain nor will * it prevent any 'false' in any of its children. * * The default behavior of force dark is also influenced by the Theme's * {@link android.R.styleable#Theme_isLightTheme isLightTheme} attribute. * If a theme is isLightTheme="false", then force dark is globally disabled for that theme. * * @param allow Whether or not to allow force dark. * * @hide core/java/android/view/ViewRootImpl.java +25 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.content.pm.PackageManager; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; Loading Loading @@ -1077,6 +1078,7 @@ public final class ViewRootImpl implements ViewParent, mAttachInfo.mThreadedRenderer = ThreadedRenderer.create(mContext, translucent, attrs.getTitle().toString()); mAttachInfo.mThreadedRenderer.setWideGamut(wideGamut); updateForceDarkMode(); if (mAttachInfo.mThreadedRenderer != null) { mAttachInfo.mHardwareAccelerated = mAttachInfo.mHardwareAccelerationRequested = true; Loading @@ -1085,6 +1087,27 @@ public final class ViewRootImpl implements ViewParent, } } private int getNightMode() { return mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; } private void updateForceDarkMode() { if (mAttachInfo.mThreadedRenderer == null) return; boolean nightMode = getNightMode() == Configuration.UI_MODE_NIGHT_YES; TypedArray a = mContext.obtainStyledAttributes(R.styleable.Theme); boolean isLightTheme = a.getBoolean(R.styleable.Theme_isLightTheme, false); a.recycle(); boolean changed = mAttachInfo.mThreadedRenderer.setForceDark(nightMode); changed |= mAttachInfo.mThreadedRenderer.getRootNode().setAllowForceDark(isLightTheme); if (changed) { // TODO: Don't require regenerating all display lists to apply this setting invalidateWorld(mView); } } @UnsupportedAppUsage public View getView() { return mView; Loading Loading @@ -4077,6 +4100,8 @@ public final class ViewRootImpl implements ViewParent, mForceNextWindowRelayout = true; requestLayout(); } updateForceDarkMode(); } /** Loading core/jni/android_view_ThreadedRenderer.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -1064,6 +1064,12 @@ static void android_view_ThreadedRenderer_allocateBuffers(JNIEnv* env, jobject c proxy->allocateBuffers(surface); } static void android_view_ThreadedRenderer_setForceDark(JNIEnv* env, jobject clazz, jlong proxyPtr, jboolean enable) { RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); proxy->setForceDark(enable); } // ---------------------------------------------------------------------------- // FrameMetricsObserver // ---------------------------------------------------------------------------- Loading Loading @@ -1177,6 +1183,7 @@ static const JNINativeMethod gMethods[] = { { "nSetIsolatedProcess", "(Z)V", (void*)android_view_ThreadedRenderer_setIsolatedProcess }, { "nSetContextPriority", "(I)V", (void*)android_view_ThreadedRenderer_setContextPriority }, { "nAllocateBuffers", "(JLandroid/view/Surface;)V", (void*)android_view_ThreadedRenderer_allocateBuffers }, { "nSetForceDark", "(JZ)V", (void*)android_view_ThreadedRenderer_setForceDark }, }; static JavaVM* mJvm = nullptr; Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -773,6 +773,7 @@ package android { field public static final int isFeatureSplit = 16844123; // 0x101055b field public static final int isGame = 16843764; // 0x10103f4 field public static final int isIndicator = 16843079; // 0x1010147 field public static final int isLightTheme = 16844175; // 0x101058f field public static final int isModifier = 16843334; // 0x1010246 field public static final int isRepeatable = 16843336; // 0x1010248 field public static final int isScrollContainer = 16843342; // 0x101024e
core/java/android/view/ThreadedRenderer.java +20 −0 Original line number Diff line number Diff line Loading @@ -974,6 +974,25 @@ public final class ThreadedRenderer { } } /** The root of everything */ public @NonNull RenderNode getRootNode() { return mRootNode; } private boolean mForceDark = false; /** * Whether or not the force-dark feature should be used for this renderer. */ public boolean setForceDark(boolean enable) { if (mForceDark != enable) { mForceDark = enable; nSetForceDark(mNativeProxy, enable); return true; } return false; } /** * Basic synchronous renderer. Currently only used to render the Magnifier, so use with care. * TODO: deduplicate against ThreadedRenderer. Loading Loading @@ -1253,4 +1272,5 @@ public final class ThreadedRenderer { private static native void nSetIsolatedProcess(boolean enabled); private static native void nSetContextPriority(int priority); private static native void nAllocateBuffers(long nativeProxy, Surface window); private static native void nSetForceDark(long nativeProxy, boolean enabled); }
core/java/android/view/View.java +4 −0 Original line number Diff line number Diff line Loading @@ -15255,6 +15255,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * a value of 'true' will not override any 'false' value in its parent chain nor will * it prevent any 'false' in any of its children. * * The default behavior of force dark is also influenced by the Theme's * {@link android.R.styleable#Theme_isLightTheme isLightTheme} attribute. * If a theme is isLightTheme="false", then force dark is globally disabled for that theme. * * @param allow Whether or not to allow force dark. * * @hide
core/java/android/view/ViewRootImpl.java +25 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.content.pm.PackageManager; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; Loading Loading @@ -1077,6 +1078,7 @@ public final class ViewRootImpl implements ViewParent, mAttachInfo.mThreadedRenderer = ThreadedRenderer.create(mContext, translucent, attrs.getTitle().toString()); mAttachInfo.mThreadedRenderer.setWideGamut(wideGamut); updateForceDarkMode(); if (mAttachInfo.mThreadedRenderer != null) { mAttachInfo.mHardwareAccelerated = mAttachInfo.mHardwareAccelerationRequested = true; Loading @@ -1085,6 +1087,27 @@ public final class ViewRootImpl implements ViewParent, } } private int getNightMode() { return mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; } private void updateForceDarkMode() { if (mAttachInfo.mThreadedRenderer == null) return; boolean nightMode = getNightMode() == Configuration.UI_MODE_NIGHT_YES; TypedArray a = mContext.obtainStyledAttributes(R.styleable.Theme); boolean isLightTheme = a.getBoolean(R.styleable.Theme_isLightTheme, false); a.recycle(); boolean changed = mAttachInfo.mThreadedRenderer.setForceDark(nightMode); changed |= mAttachInfo.mThreadedRenderer.getRootNode().setAllowForceDark(isLightTheme); if (changed) { // TODO: Don't require regenerating all display lists to apply this setting invalidateWorld(mView); } } @UnsupportedAppUsage public View getView() { return mView; Loading Loading @@ -4077,6 +4100,8 @@ public final class ViewRootImpl implements ViewParent, mForceNextWindowRelayout = true; requestLayout(); } updateForceDarkMode(); } /** Loading
core/jni/android_view_ThreadedRenderer.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -1064,6 +1064,12 @@ static void android_view_ThreadedRenderer_allocateBuffers(JNIEnv* env, jobject c proxy->allocateBuffers(surface); } static void android_view_ThreadedRenderer_setForceDark(JNIEnv* env, jobject clazz, jlong proxyPtr, jboolean enable) { RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); proxy->setForceDark(enable); } // ---------------------------------------------------------------------------- // FrameMetricsObserver // ---------------------------------------------------------------------------- Loading Loading @@ -1177,6 +1183,7 @@ static const JNINativeMethod gMethods[] = { { "nSetIsolatedProcess", "(Z)V", (void*)android_view_ThreadedRenderer_setIsolatedProcess }, { "nSetContextPriority", "(I)V", (void*)android_view_ThreadedRenderer_setContextPriority }, { "nAllocateBuffers", "(JLandroid/view/Surface;)V", (void*)android_view_ThreadedRenderer_allocateBuffers }, { "nSetForceDark", "(JZ)V", (void*)android_view_ThreadedRenderer_setForceDark }, }; static JavaVM* mJvm = nullptr; Loading