diff --git a/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/entry/ApplicationLike.java b/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/entry/ApplicationLike.java index 72e83651c..972cb98cc 100644 --- a/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/entry/ApplicationLike.java +++ b/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/entry/ApplicationLike.java @@ -22,6 +22,8 @@ import android.content.res.AssetManager; import android.content.res.Configuration; import android.content.res.Resources; +import android.content.res.Resources.Theme; + import com.tencent.tinker.anno.Keep; /** @@ -126,6 +128,9 @@ public Context getBaseContext(Context base) { return base; } + @Keep + public Theme getTheme(Theme theme) { return theme; } + @Keep public int mzNightModeUseOf() { // Return 1 for default according to MeiZu's announcement. diff --git a/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/entry/TinkerApplicationInlineFence.java b/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/entry/TinkerApplicationInlineFence.java index 833e31d9c..3491b6d2a 100644 --- a/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/entry/TinkerApplicationInlineFence.java +++ b/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/entry/TinkerApplicationInlineFence.java @@ -20,6 +20,7 @@ import android.content.res.AssetManager; import android.content.res.Configuration; import android.content.res.Resources; +import android.content.res.Resources.Theme; import android.os.Handler; import android.os.Message; import com.tencent.tinker.anno.Keep; @@ -29,6 +30,7 @@ import static com.tencent.tinker.loader.app.TinkerInlineFenceAction.ACTION_GET_CLASSLOADER; import static com.tencent.tinker.loader.app.TinkerInlineFenceAction.ACTION_GET_RESOURCES; import static com.tencent.tinker.loader.app.TinkerInlineFenceAction.ACTION_GET_SYSTEM_SERVICE; +import static com.tencent.tinker.loader.app.TinkerInlineFenceAction.ACTION_GET_THEME; import static com.tencent.tinker.loader.app.TinkerInlineFenceAction.ACTION_MZ_NIGHTMODE_USE_OF; import static com.tencent.tinker.loader.app.TinkerInlineFenceAction.ACTION_ON_BASE_CONTEXT_ATTACHED; import static com.tencent.tinker.loader.app.TinkerInlineFenceAction.ACTION_ON_CONFIGURATION_CHANGED; @@ -104,15 +106,19 @@ private void handleMessageImpl(Message msg) { msg.obj = mAppLike.getAssets((AssetManager) msg.obj); break; } - case ACTION_GET_RESOURCES : { + case ACTION_GET_RESOURCES: { msg.obj = mAppLike.getResources((Resources) msg.obj); break; } - case ACTION_GET_SYSTEM_SERVICE : { + case ACTION_GET_SYSTEM_SERVICE: { final Object[] params = (Object[]) msg.obj; msg.obj = mAppLike.getSystemService((String) params[0], params[1]); break; } + case ACTION_GET_THEME: { + msg.obj = mAppLike.getTheme((Theme) msg.obj); + break; + } case ACTION_MZ_NIGHTMODE_USE_OF: { msg.obj = mAppLike.mzNightModeUseOf(); break; diff --git a/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/entry/ApplicationLike.java b/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/entry/ApplicationLike.java index a41ddf0fe..972cb98cc 100644 --- a/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/entry/ApplicationLike.java +++ b/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/entry/ApplicationLike.java @@ -22,6 +22,7 @@ import android.content.res.AssetManager; import android.content.res.Configuration; import android.content.res.Resources; +import android.content.res.Resources.Theme; import com.tencent.tinker.anno.Keep; @@ -127,6 +128,9 @@ public Context getBaseContext(Context base) { return base; } + @Keep + public Theme getTheme(Theme theme) { return theme; } + @Keep public int mzNightModeUseOf() { // Return 1 for default according to MeiZu's announcement. diff --git a/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java b/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java index e22f00aeb..100db671f 100644 --- a/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java +++ b/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java @@ -23,6 +23,7 @@ import android.content.res.AssetManager; import android.content.res.Configuration; import android.content.res.Resources; +import android.content.res.Resources.Theme; import android.os.SystemClock; import com.tencent.tinker.anno.Keep; @@ -217,6 +218,15 @@ public Context getBaseContext() { } } + @Override + public Theme getTheme() { + final Theme theme = super.getTheme(); + if (mAppLike != null) { + return mAppLike.getTheme(theme); + } + return theme; + } + @Keep public int mzNightModeUseOf() { if (mAppLike != null) { diff --git a/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java b/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java index 3d223a044..a2312e9b0 100644 --- a/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java +++ b/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/app/TinkerApplication.java @@ -23,6 +23,7 @@ import android.content.res.AssetManager; import android.content.res.Configuration; import android.content.res.Resources; +import android.content.res.Resources.Theme; import android.os.Handler; import android.os.SystemClock; @@ -277,6 +278,15 @@ public Context getBaseContext() { return TinkerInlineFenceAction.callGetBaseContext(mInlineFence, base); } + @Override + public Theme getTheme() { + final Theme theme = super.getTheme(); + if (mInlineFence == null) { + return theme; + } + return TinkerInlineFenceAction.callGetTheme(mInlineFence, theme); + } + @Keep public int mzNightModeUseOf() { if (mInlineFence == null) { diff --git a/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/app/TinkerInlineFenceAction.java b/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/app/TinkerInlineFenceAction.java index d5f4af333..c96bc8c62 100644 --- a/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/app/TinkerInlineFenceAction.java +++ b/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/app/TinkerInlineFenceAction.java @@ -20,6 +20,7 @@ import android.content.res.AssetManager; import android.content.res.Configuration; import android.content.res.Resources; +import android.content.res.Resources.Theme; import android.os.Handler; import android.os.Message; @@ -39,6 +40,7 @@ public final class TinkerInlineFenceAction { public static final int ACTION_GET_RESOURCES = 10; public static final int ACTION_GET_SYSTEM_SERVICE = 11; public static final int ACTION_MZ_NIGHTMODE_USE_OF = 12; + public static final int ACTION_GET_THEME = 13; static void callOnBaseContextAttached(Handler inlineFence, Context context) { Message msg = null; @@ -155,6 +157,17 @@ static Object callGetSystemService(Handler inlineFence, String name, Object serv } } + static Theme callGetTheme(Handler inlineFence, Theme theme) { + Message msg = null; + try { + msg = Message.obtain(inlineFence, ACTION_GET_THEME, theme); + inlineFence.handleMessage(msg); + return (Theme) msg.obj; + } finally { + msg.recycle(); + } + } + static int callMZNightModeUseOf(Handler inlineFence) { Message msg = null; try {