diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemFramework/Phone/SystemFrameworkT.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemFramework/Phone/SystemFrameworkT.java
index ab0541f57b..8e7601485e 100644
--- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemFramework/Phone/SystemFrameworkT.java
+++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemFramework/Phone/SystemFrameworkT.java
@@ -64,6 +64,7 @@
import com.sevtinge.hyperceiler.module.hook.systemframework.corepatch.BypassSignCheckForT;
import com.sevtinge.hyperceiler.module.hook.systemframework.display.AllDarkMode;
import com.sevtinge.hyperceiler.module.hook.systemframework.display.DisplayCutout;
+import com.sevtinge.hyperceiler.module.hook.systemframework.display.ThemeProvider;
import com.sevtinge.hyperceiler.module.hook.systemframework.display.ToastTime;
import com.sevtinge.hyperceiler.module.hook.systemframework.display.UseAOSPScreenShot;
import com.sevtinge.hyperceiler.module.hook.systemframework.freeform.OpenAppInFreeForm;
@@ -130,6 +131,7 @@ public void handleLoadPackage() {
initHook(UseAOSPScreenShot.INSTANCE, mPrefsMap.getBoolean("system_ui_display_use_aosp_screenshot_enable"));
initHook(new ToastTime(), mPrefsMap.getBoolean("system_ui_display_toast_times_enable"));
initHook(new AllDarkMode(), mPrefsMap.getBoolean("system_framework_allow_all_dark_mode"));
+ initHook(new ThemeProvider(), mPrefsMap.getBoolean("system_framework_allow_third_theme"));
// initHook(new AutoBrightness(), mPrefsMap.getBoolean("system_control_center_auto_brightness"));
// 位置模拟
diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/ThemeManager.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/ThemeManager.java
index 9a5deda381..9ea10bee77 100644
--- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/ThemeManager.java
+++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/ThemeManager.java
@@ -20,6 +20,7 @@
import com.sevtinge.hyperceiler.module.base.BaseModule;
import com.sevtinge.hyperceiler.module.base.HookExpand;
+import com.sevtinge.hyperceiler.module.hook.thememanager.AllowThirdTheme;
import com.sevtinge.hyperceiler.module.hook.thememanager.DisableThemeAdNew;
import com.sevtinge.hyperceiler.module.hook.thememanager.EnableFoldTheme;
import com.sevtinge.hyperceiler.module.hook.thememanager.EnablePadTheme;
@@ -30,7 +31,8 @@ public class ThemeManager extends BaseModule {
@Override
public void handleLoadPackage() {
- initHook(new DisableThemeAdNew(), mPrefsMap.getBoolean("various_theme_diable_ads"));
+ initHook(new AllowThirdTheme(), mPrefsMap.getBoolean("system_framework_allow_third_theme"));
+ initHook(new DisableThemeAdNew(), mPrefsMap.getBoolean("various_theme_disable_ads"));
initHook(new EnablePadTheme(), mPrefsMap.getBoolean("various_theme_enable_pad_theme"));
initHook(new EnableFoldTheme(), mPrefsMap.getBoolean("various_theme_enable_fold_theme"));
diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/base/BaseModule.java b/app/src/main/java/com/sevtinge/hyperceiler/module/base/BaseModule.java
index f635013f10..ed750274d4 100644
--- a/app/src/main/java/com/sevtinge/hyperceiler/module/base/BaseModule.java
+++ b/app/src/main/java/com/sevtinge/hyperceiler/module/base/BaseModule.java
@@ -82,10 +82,14 @@ public void init(LoadPackageParam lpparam) {
public void initZygote() {
}
- public void initHook(BaseHook baseHook) {
+ /*public void initHook(BaseHook baseHook) {
if (baseHook.isLoad()) {
baseHook.onCreate(mLoadPackageParam);
}
+ }*/
+
+ public void initHook(BaseHook baseHook) {
+ initHook(baseHook, true);
}
public void initHook(BaseHook baseHook, boolean isInit) {
diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemframework/display/ThemeProvider.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemframework/display/ThemeProvider.kt
new file mode 100644
index 0000000000..6494036b87
--- /dev/null
+++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemframework/display/ThemeProvider.kt
@@ -0,0 +1,48 @@
+/*
+ * This file is part of HyperCeiler.
+
+ * HyperCeiler is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+
+ * Copyright (C) 2023-2024 HyperCeiler Contributions
+ */
+package com.sevtinge.hyperceiler.module.hook.systemframework.display
+
+import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
+import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks
+import com.github.kyuubiran.ezxhelper.Log
+import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
+import com.sevtinge.hyperceiler.module.base.*
+import de.robv.android.xposed.XC_MethodHook
+import miui.drm.DrmManager
+import miui.drm.ThemeReceiver
+
+class ThemeProvider : BaseHook() {
+ override fun init() {
+ var hook: List? = null
+ try {
+ ThemeReceiver::class.java.methodFinder().filterByName("validateTheme").first().createHook {
+ before {
+ hook = DrmManager::class.java.methodFinder().filterByName("isLegal").toList().createHooks {
+ returnConstant(DrmManager.DrmResult.DRM_SUCCESS)
+ }
+ }
+ after {
+ hook?.forEach { it.unhook() }
+ }
+ }
+ } catch (t: Throwable) {
+ Log.ex(t)
+ }
+ }
+}
diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/thememanager/AllowThirdTheme.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/thememanager/AllowThirdTheme.java
new file mode 100644
index 0000000000..c9e740f51e
--- /dev/null
+++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/thememanager/AllowThirdTheme.java
@@ -0,0 +1,49 @@
+/*
+ * This file is part of HyperCeiler.
+
+ * HyperCeiler is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+
+ * Copyright (C) 2023-2024 HyperCeiler Contributions
+ */
+package com.sevtinge.hyperceiler.module.hook.thememanager;
+
+import com.sevtinge.hyperceiler.module.base.BaseHook;
+import com.sevtinge.hyperceiler.module.base.dexkit.DexKit;
+
+import org.luckypray.dexkit.query.FindMethod;
+import org.luckypray.dexkit.query.matchers.MethodMatcher;
+import org.luckypray.dexkit.result.MethodData;
+
+import java.lang.reflect.Method;
+
+import miui.drm.DrmManager;
+
+public class AllowThirdTheme extends BaseHook {
+ @Override
+ public void init() throws NoSuchMethodException {
+ MethodData methodData = DexKit.getDexKitBridge().findMethod(FindMethod.create()
+ .matcher(MethodMatcher.create()
+ .usingStrings("theme", "ThemeManagerTag", "/system", "check rights isLegal: ")
+ )
+ ).singleOrThrow(() -> new IllegalStateException("AllowThirdTheme: Cannot found MethodData"));
+ Method method = methodData.getMethodInstance(lpparam.classLoader);
+ logD(TAG, lpparam.packageName, "isLegal() method is " + method);
+ hookMethod(method, new MethodHook() {
+ @Override
+ protected void before(MethodHookParam param) throws Throwable {
+ param.setResult(DrmManager.DrmResult.DRM_SUCCESS);
+ }
+ });
+ }
+}
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 2421774826..9dbe66397c 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -439,6 +439,7 @@
秒截图
禁用截图延迟
隐藏正在使用流量加速 Toast
+ 允许使用第三方主题
包管理服务
允许降级安装应用
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7d988a6aac..d07983d9cf 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -434,6 +434,7 @@
Quick screenshot
Disable screenshot delay
Hide LinkTurbo Toast
+ Allows to use third-party themes
Package Manager Service
Allow downgrade
diff --git a/app/src/main/res/xml/framework_display.xml b/app/src/main/res/xml/framework_display.xml
index 8eec46b40e..fd4251995e 100644
--- a/app/src/main/res/xml/framework_display.xml
+++ b/app/src/main/res/xml/framework_display.xml
@@ -19,6 +19,11 @@
android:title="@string/system_framework_allow_all_dark_mode"
android:key="prefs_key_system_framework_allow_all_dark_mode" />
+
+