diff --git a/app/src/main/kotlin/star/sky/voyager/activity/pages/sub/ControlCenterPage.kt b/app/src/main/kotlin/star/sky/voyager/activity/pages/sub/ControlCenterPage.kt index 9ed5591..b8c77c4 100644 --- a/app/src/main/kotlin/star/sky/voyager/activity/pages/sub/ControlCenterPage.kt +++ b/app/src/main/kotlin/star/sky/voyager/activity/pages/sub/ControlCenterPage.kt @@ -76,6 +76,13 @@ class ControlCenterPage : BasePage() { ), SwitchV("super_volume"), ) + TextSummaryWithSwitch( + TextSummaryV( + textId = R.string.hyperos_miui, + tipsId = R.string.hyperos_miui_summary, + ), + SwitchV("hyperos_miui"), + ) Line() val ccBinding = GetDataBinding({ safeSP.getBoolean( diff --git a/app/src/main/kotlin/star/sky/voyager/hook/apps/SystemUI.kt b/app/src/main/kotlin/star/sky/voyager/hook/apps/SystemUI.kt index 960aefb..c2c7b01 100644 --- a/app/src/main/kotlin/star/sky/voyager/hook/apps/SystemUI.kt +++ b/app/src/main/kotlin/star/sky/voyager/hook/apps/SystemUI.kt @@ -20,6 +20,7 @@ import star.sky.voyager.hook.hooks.systemui.HideStatusBarIcon import star.sky.voyager.hook.hooks.systemui.HideStatusBarNetworkSpeedSecond import star.sky.voyager.hook.hooks.systemui.HideStatusBarWhenScreenShot import star.sky.voyager.hook.hooks.systemui.HideWifiActivityIcon +import star.sky.voyager.hook.hooks.systemui.HyperOSMIUI import star.sky.voyager.hook.hooks.systemui.IconPosition import star.sky.voyager.hook.hooks.systemui.LockScreenBlurButton import star.sky.voyager.hook.hooks.systemui.LockScreenClockDisplaySeconds @@ -118,6 +119,7 @@ object SystemUI : AppRegister() { NoPasswordHook, // 开机免输密码 OldQSCustom, // 自定义行列数 SuperVolume, + HyperOSMIUI, // 状态栏网络速度 Start StatusBarNetworkSpeedRefreshSpeed, HideStatusBarNetworkSpeedSecond, diff --git a/app/src/main/kotlin/star/sky/voyager/hook/hooks/multipackage/DC.kt b/app/src/main/kotlin/star/sky/voyager/hook/hooks/multipackage/DC.kt index ba3796e..769458f 100644 --- a/app/src/main/kotlin/star/sky/voyager/hook/hooks/multipackage/DC.kt +++ b/app/src/main/kotlin/star/sky/voyager/hook/hooks/multipackage/DC.kt @@ -20,6 +20,9 @@ object DC : HookRegister() { if (it.args[0] == "support_dc_backlight") { it.result = true } + if (it.args[0] == "support_dc_backlight_sec") { + it.result = true + } } } } diff --git a/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/HyperOSMIUI.kt b/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/HyperOSMIUI.kt new file mode 100644 index 0000000..8426fb1 --- /dev/null +++ b/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/HyperOSMIUI.kt @@ -0,0 +1,19 @@ +package star.sky.voyager.hook.hooks.systemui + +import star.sky.voyager.utils.api.findClass +import star.sky.voyager.utils.init.HookRegister +import star.sky.voyager.utils.key.hasEnable +import star.sky.voyager.utils.voyager.PluginClassLoader + +object HyperOSMIUI : HookRegister() { + override fun init() = hasEnable("hyperos_miui") { + PluginClassLoader.hookPluginClassLoader { _, classLoader -> + "miui.systemui.util.CommonUtils".findClass(classLoader) + .getDeclaredField("IS_BELOW_MIUI_15") + .apply { + isAccessible = true + setBoolean(null, false) + } + } + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/RestoreNearbyTile.kt b/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/RestoreNearbyTile.kt index 0c46d83..ca04ef3 100644 --- a/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/RestoreNearbyTile.kt +++ b/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/RestoreNearbyTile.kt @@ -1,15 +1,19 @@ package star.sky.voyager.hook.hooks.systemui +import android.os.Build import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass import com.github.kyuubiran.ezxhelper.ClassUtils.setStaticObject +import com.github.kyuubiran.ezxhelper.EzXHelper import com.github.kyuubiran.ezxhelper.HookFactory import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook +import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks import com.github.kyuubiran.ezxhelper.LogExtensions.logexIfThrow import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder import star.sky.voyager.utils.init.HookRegister import star.sky.voyager.utils.key.hasEnable import star.sky.voyager.utils.voyager.PluginClassLoader.hookPluginClassLoader import star.sky.voyager.utils.yife.Build.IS_INTERNATIONAL_BUILD +import star.sky.voyager.utils.yife.DexKit object RestoreNearbyTile : HookRegister() { private var isTrulyInit: Boolean = false @@ -37,6 +41,7 @@ object RestoreNearbyTile : HookRegister() { // } // } hookPluginClassLoader { _, classLoader -> +// Log.i("set classLoader: $classLoader") if (!isTrulyInit) kotlin.runCatching { loadClass( "miui.systemui.controlcenter.qs.customize.TileQueryHelper\$Companion", @@ -48,26 +53,51 @@ object RestoreNearbyTile : HookRegister() { }.logexIfThrow("Failed truly init hook: ${this@RestoreNearbyTile.javaClass.simpleName}") } - if (!IS_INTERNATIONAL_BUILD) { - if (IS_INTERNATIONAL_BUILD) return@hasEnable - val isInternationalHook: HookFactory.() -> Unit = { - val constantsClazz = loadClass("com.android.systemui.controlcenter.utils.Constants") - before { - setStaticObject(constantsClazz, "IS_INTERNATIONAL", true) - } - after { - setStaticObject(constantsClazz, "IS_INTERNATIONAL", false) + when (Build.VERSION.SDK_INT) { + Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> { + DexKit.dexKitBridge.findMethod { + matcher { + usingStrings = + listOf("com.google.android.gms/.nearby.sharing.SharingTileService") + } + }.map { it.getMethodInstance(EzXHelper.safeClassLoader) }.createHooks { + val miuiConfigsCls = + loadClass("com.miui.utils.configs.MiuiConfigs") + before { + setStaticObject(miuiConfigsCls, "IS_INTERNATIONAL_BUILD", true) + } + + after { + setStaticObject(miuiConfigsCls, "IS_INTERNATIONAL_BUILD", false) + } } } - loadClass("com.android.systemui.qs.MiuiQSTileHostInjector").methodFinder().first { - name == "createMiuiTile" - }.createHook(isInternationalHook) + Build.VERSION_CODES.TIRAMISU -> { + if (!IS_INTERNATIONAL_BUILD) { + if (IS_INTERNATIONAL_BUILD) return@hasEnable + val isInternationalHook: HookFactory.() -> Unit = { + val constantsClazz = + loadClass("com.android.systemui.controlcenter.utils.Constants") + before { + setStaticObject(constantsClazz, "IS_INTERNATIONAL", true) + } + after { + setStaticObject(constantsClazz, "IS_INTERNATIONAL", false) + } + } + + loadClass("com.android.systemui.qs.MiuiQSTileHostInjector").methodFinder() + .first { + name == "createMiuiTile" + }.createHook(isInternationalHook) - loadClass("com.android.systemui.controlcenter.utils.ControlCenterUtils").methodFinder() - .first { - name == "filterCustomTile" - }.createHook(isInternationalHook) + loadClass("com.android.systemui.controlcenter.utils.ControlCenterUtils").methodFinder() + .first { + name == "filterCustomTile" + }.createHook(isInternationalHook) + } + } } } } \ No newline at end of file diff --git a/app/src/main/kotlin/star/sky/voyager/utils/voyager/PluginClassLoader.kt b/app/src/main/kotlin/star/sky/voyager/utils/voyager/PluginClassLoader.kt index bb794ba..614794e 100644 --- a/app/src/main/kotlin/star/sky/voyager/utils/voyager/PluginClassLoader.kt +++ b/app/src/main/kotlin/star/sky/voyager/utils/voyager/PluginClassLoader.kt @@ -1,8 +1,10 @@ package star.sky.voyager.utils.voyager import android.content.pm.ApplicationInfo +import android.os.Build import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook +import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder import de.robv.android.xposed.XC_MethodHook @@ -21,23 +23,59 @@ object PluginClassLoader { * @return appInfo & classLoaderP */ var hook: XC_MethodHook.Unhook? = null + private var pluginAppInfo: ApplicationInfo? = null + private var pluginClsLoader: ClassLoader? = null fun hookPluginClassLoader(onGetClassLoader: (appInfo: ApplicationInfo, classLoader: ClassLoader) -> Unit) { - val classLoaderClass = - loadClass("com.android.systemui.shared.plugins.PluginInstance\$Factory") - hook = classLoaderClass.methodFinder().first { - name == "getClassLoader" - && parameterCount == 2 - && parameterTypes[0] == ApplicationInfo::class.java - && parameterTypes[1] == ClassLoader::class.java - }.createHook { - after { getClassLoader -> - val appInfo = getClassLoader.args[0] as ApplicationInfo - val classLoaderP = getClassLoader.result as ClassLoader + when (Build.VERSION.SDK_INT) { + Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> { + loadClass("com.android.systemui.shared.plugins.PluginInstance\$Factory") + .methodFinder().filterByName("create").toList().createHooks { + before { + pluginAppInfo = it.args[1] as ApplicationInfo + } + } + hook = + loadClass("com.android.systemui.shared.plugins.PluginInstance\$Factory\$\$ExternalSyntheticLambda0") + .methodFinder().filterByName("get").first().createHook { + var isHooked = false + after { + val patchClassLoader = + it.result + if (pluginAppInfo != null) { + if (pluginAppInfo?.packageName.equals("miui.systemui.plugin") && !isHooked) { + isHooked = true + if (pluginClsLoader == null) { + pluginClsLoader = + patchClassLoader as ClassLoader +// Log.i("get classLoader: $pluginAppInfo $pluginClsLoader") + onGetClassLoader(pluginAppInfo!!, pluginClsLoader!!) + } + } + } + hook?.unhook() + } + } + } + + Build.VERSION_CODES.TIRAMISU -> { + val classLoaderClass = + loadClass("com.android.systemui.shared.plugins.PluginInstance\$Factory") + hook = classLoaderClass.methodFinder().first { + name == "getClassLoader" + && parameterCount == 2 + && parameterTypes[0] == ApplicationInfo::class.java + && parameterTypes[1] == ClassLoader::class.java + }.createHook { + after { getClassLoader -> + val appInfo = getClassLoader.args[0] as ApplicationInfo + val classLoaderP = getClassLoader.result as ClassLoader // Log.i("get classLoader: $appInfo $classLoaderP") - if (appInfo.packageName == "miui.systemui.plugin") { - onGetClassLoader(appInfo, classLoaderP) + if (appInfo.packageName == "miui.systemui.plugin") { + onGetClassLoader(appInfo, classLoaderP) + } + hook?.unhook() + } } - hook?.unhook() } } } diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 824eda5..4d2267a 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -169,6 +169,8 @@ 最近の画面 Xiaomi の 方法 これはゲーム中のみ動作する特別な機能です。\nこの機能について詳しく知りたい場合は、有効にした後に Xiaomi の公式説明をご確認いただけます。 + MIUI -> HyperOS + このスコープであなたのシステムを HyperOS として認識させる\nこれは MIUI に一部の HyperOS の機能を使うことができます。 自動スクリーンオフ時間 非アクティブ状態後の自動ロックスクリーンをカスタマイズ diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 04d1804..5196e1e 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -169,6 +169,8 @@ 最近任务 使用小米的方案 这是一个只在游戏中生效的特殊功能,如果你想具体了解这个功能可以在开启后去看小米的官方描述 + MIUI -> HyperOS + 让该作用域识别你的系统为 HyperOS\n这可以让 MIUI 用上一部分 HyperOS 的功能 自动锁屏时间 自定义在无操作多久后自动锁屏 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 047ba55..f2288fb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -170,6 +170,8 @@ Recent Xiaomi\'s Approach This is a special feature that only works during games.\nIf you\'d like to learn more about this feature, you can check Xiaomi\'s official description after enabling it. + MIUI -> HyperOS + Let this scope identify your system as HyperOS\nallows MIUI to use some of the functions of HyperOS. Screen Off Timeout Customize Auto Lock Screen After Inactivity diff --git a/gradle/sweet-dependency/sweet-dependency-config.yaml b/gradle/sweet-dependency/sweet-dependency-config.yaml index 0d3231f..a5b0b58 100644 --- a/gradle/sweet-dependency/sweet-dependency-config.yaml +++ b/gradle/sweet-dependency/sweet-dependency-config.yaml @@ -13,7 +13,7 @@ repositories: plugins: com.android.application: alias: android-application - version: 8.1.2 + version: 8.1.4 auto-update: true org.jetbrains.kotlin.android: alias: kotlin-android diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5710c1d..815271d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Oct 07 05:51:12 CST 2023 +#Sat Nov 18 07:12:40 CST 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-rc-3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index 0639aee..b6c790f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,7 +8,7 @@ pluginManagement { } } plugins { - id("com.highcapable.sweetdependency") version "1.0.2" + id("com.highcapable.sweetdependency") version "1.0.4" } rootProject.name = "StarSkyVoyager"