-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: system framework - display - Allows to use third-party themes
- Loading branch information
Showing
9 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...c/main/java/com/sevtinge/hyperceiler/module/hook/systemframework/display/ThemeProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
* 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<XC_MethodHook.Unhook>? = 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) | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
app/src/main/java/com/sevtinge/hyperceiler/module/hook/thememanager/AllowThirdTheme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
* 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); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters