Skip to content

Commit

Permalink
utils优化
Browse files Browse the repository at this point in the history
  • Loading branch information
hosizoraru committed Aug 15, 2023
1 parent 7446b62 commit 1cf9a16
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ class MiAiPage : BasePage() {
textId = R.string.meeting_mode,
), SwitchV("meeting_mode")
)
TextSummaryWithSwitch(
TextSummaryV(
textId = R.string.aiasst_vision_new_voip,
), SwitchV("aiasst_vision_new_voip")
)
TextSummaryWithSwitch(
TextSummaryV(
textId = R.string.desktop_mode_screen_translate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package star.sky.voyager.hook.apps
import de.robv.android.xposed.callbacks.XC_LoadPackage
import star.sky.voyager.hook.hooks.aiasstvision.DesktopModeScreenTranslate
import star.sky.voyager.hook.hooks.aiasstvision.MeetingMode
import star.sky.voyager.hook.hooks.aiasstvision.NewVoip
import star.sky.voyager.hook.hooks.aiasstvision.SplitScreenTranslate
import star.sky.voyager.utils.init.AppRegister

Expand All @@ -14,7 +13,6 @@ object AiasstVision : AppRegister() {
autoInitHooks(
lpparam,
MeetingMode, // 解锁会议模式
NewVoip, //
DesktopModeScreenTranslate, // 允许在工作台模式下使用屏幕翻译
SplitScreenTranslate, // 解锁分屏翻译
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package star.sky.voyager.hook.hooks.aiasstvision

import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks
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.LazyClass.AiasstVisionSystemUtilsCls

object MeetingMode : HookRegister() {
override fun init() = hasEnable("meeting_mode") {
val systemUtilsCls =
loadClass("com.xiaomi.aiasst.vision.utils.SystemUtils")

systemUtilsCls.methodFinder().filter {
AiasstVisionSystemUtilsCls.methodFinder().filter {
name in setOf(
"isSupportNewVoip",
"isM81",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.github.kyuubiran.ezxhelper.ObjectUtils.invokeMethodBestMatch
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.LazyClass.MiuiBuildCls
import star.sky.voyager.utils.yife.Build.IS_INTERNATIONAL_BUILD

object DarkModeForAllApps : HookRegister() {
Expand All @@ -18,11 +19,11 @@ object DarkModeForAllApps : HookRegister() {
clazzForceDarkAppListManager.methodFinder().filterByName("getDarkModeAppList").toList()
.createHooks {
before {
setStaticObject(loadClass("miui.os.Build"), "IS_INTERNATIONAL_BUILD", true)
setStaticObject(MiuiBuildCls, "IS_INTERNATIONAL_BUILD", true)
}
after {
setStaticObject(
loadClass("miui.os.Build"),
MiuiBuildCls,
"IS_INTERNATIONAL_BUILD",
IS_INTERNATIONAL_BUILD
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import star.sky.voyager.utils.yife.XSharedPreferences.getBoolean

object SelectName : HookRegister() {
override fun init() {
val selectable by lazy {
getBoolean("file_explorer_can_selectable", false)
}
val singleLine by lazy {
getBoolean("file_explorer_is_single_line", false)
}
if (selectable && !singleLine) return
hasEnable("file_explorer_can_selectable") {
hasEnable("file_explorer_is_single_line") {
loadClass("com.android.fileexplorer.view.FileListItem").methodFinder()
Expand All @@ -22,10 +29,7 @@ object SelectName : HookRegister() {
"mFileNameTextView"
))?.apply {
setTextIsSelectable(
getBoolean(
"file_explorer_can_selectable",
false
)
selectable
)
isSingleLine = getBoolean("file_explorer_is_single_line", false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import com.github.kyuubiran.ezxhelper.ObjectUtils.invokeMethodBestMatch
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.LazyClass.MiuiBuildCls

object RestoreSwitchMinusScreen : HookRegister() {
override fun init() = hasEnable("restore_switch_minus_screen") {
val clazzUtilities = loadClass("com.miui.home.launcher.common.Utilities")
val clazzMiuiBuild = loadClass("miui.os.Build")
val clazzLauncher = loadClass("com.miui.home.launcher.Launcher")
val clazzMiuiHomeSettings = loadClass("com.miui.home.settings.MiuiHomeSettings")
loadClass("com.miui.home.launcher.DeviceConfig").methodFinder()
Expand All @@ -39,21 +39,21 @@ object RestoreSwitchMinusScreen : HookRegister() {
clazzUtilities, "getCurrentPersonalAssistant"
)!! as String) == "personal_assistant_google"
setStaticObject(
clazzMiuiBuild,
MiuiBuildCls,
"IS_INTERNATIONAL_BUILD",
isPersonalAssistantGoogle
)
}
after {
setStaticObject(clazzMiuiBuild, "IS_INTERNATIONAL_BUILD", false)
setStaticObject(MiuiBuildCls, "IS_INTERNATIONAL_BUILD", false)
}
}
clazzLauncher.declaredConstructors.createHooks {
before {
setStaticObject(clazzMiuiBuild, "IS_INTERNATIONAL_BUILD", true)
setStaticObject(MiuiBuildCls, "IS_INTERNATIONAL_BUILD", true)
}
after {
setStaticObject(clazzMiuiBuild, "IS_INTERNATIONAL_BUILD", false)
setStaticObject(MiuiBuildCls, "IS_INTERNATIONAL_BUILD", false)
}
}
clazzMiuiHomeSettings.methodFinder().filterByName("onCreatePreferences")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package star.sky.voyager.hook.hooks.mediaeditor

import android.os.Build
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
import com.github.kyuubiran.ezxhelper.ClassUtils.setStaticObject
import com.github.kyuubiran.ezxhelper.EzXHelper.safeClassLoader
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
import com.github.kyuubiran.ezxhelper.finders.MethodFinder
import io.luckypray.dexkit.enums.MatchType
import star.sky.voyager.utils.init.HookRegister
import star.sky.voyager.utils.key.hasEnable
import star.sky.voyager.utils.voyager.LazyClass.AndroidBuildCls
import star.sky.voyager.utils.yife.DexKit.safeDexKitBridge

object FilterManager : HookRegister() {
Expand All @@ -24,10 +24,10 @@ object FilterManager : HookRegister() {
if (!this@FilterManager::device.isInitialized) {
device = Build.DEVICE
}
setStaticObject(loadClass("android.os.Build"), "DEVICE", "wayne")
setStaticObject(AndroidBuildCls, "DEVICE", "wayne")
}
after {
setStaticObject(loadClass("android.os.Build"), "DEVICE", device)
setStaticObject(AndroidBuildCls, "DEVICE", device)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
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.LazyClass.MiuiBuildCls
import star.sky.voyager.utils.voyager.LazyClass.SettingsFeaturesCls
import star.sky.voyager.utils.yife.Build.IS_TABLET

Expand All @@ -31,7 +32,7 @@ object TaplusUnlock : HookRegister() {
.filterByName("getFragment")
.first().createHook {
setStaticObject(
loadClass("miui.os.Build"),
MiuiBuildCls,
"IS_TABLET",
false
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinde
import star.sky.voyager.utils.init.HookRegister
import star.sky.voyager.utils.key.XSPUtils.getString
import star.sky.voyager.utils.key.hasEnable
import star.sky.voyager.utils.voyager.LazyClass.AndroidBuildCls

object DeviceShell : HookRegister() {
private lateinit var device: String
Expand All @@ -23,11 +24,11 @@ object DeviceShell : HookRegister() {
if (!this@DeviceShell::device.isInitialized) {
device = Build.DEVICE
}
setStaticObject(loadClass("android.os.Build"), "DEVICE", deviceS)
setStaticObject(AndroidBuildCls, "DEVICE", deviceS)
}

after {
setStaticObject(loadClass("android.os.Build"), "DEVICE", device)
setStaticObject(AndroidBuildCls, "DEVICE", device)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ object LazyClass {
loadClass("android.os.SystemProperties")
}

val AndroidBuildCls by lazy {
loadClass("android.os.Build")
}

val MiuiBuildCls by lazy {
loadClass("miui.os.Build")
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ja-rJP/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@
<string name="device_modify_summary">あなたのデバイス型番を Xiaomi 13 Pro に偽装し、制限を回避します</string>

<string name="meeting_mode">ミーティングモードのロックを解除する</string>
<string name="aiasst_vision_new_voip">Unlock New Voip</string>
<string name="desktop_mode_screen_translate">ワークベンチモードで画面翻訳を許可する</string>
<string name="split_screen_translate">分割画面翻訳のロックを解除する</string>
<string name="split_screen_translate_summary">画面を分割するときに、単一のアプリケーションの翻訳を許可する</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@
<string name="device_modify_summary">对小爱建议伪装你的机型为小米13 Pro,以移除它对机型和账号的限制</string>

<string name="meeting_mode">解锁会议模式</string>
<string name="aiasst_vision_new_voip">解锁网络通话翻译</string>
<string name="desktop_mode_screen_translate">允许在工作台模式下使用屏幕翻译</string>
<string name="split_screen_translate">解锁分屏翻译</string>
<string name="split_screen_translate_summary">允许在分屏时单独对单个应用使用翻译</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@
<string name="device_modify_summary">For Aireco, it is recommended to disguise your model as Xiaomi 13 Pro to remove its restrictions on the model and account.</string>

<string name="meeting_mode">Unlock Meeting Mode</string>
<string name="aiasst_vision_new_voip">Unlock New Voip</string>
<string name="desktop_mode_screen_translate">Allow screen translation in workbench mode</string>
<string name="split_screen_translate">Unlock split-screen translation</string>
<string name="split_screen_translate_summary">Allow translation for a single application when splitting the screen</string>
Expand Down

0 comments on commit 1cf9a16

Please sign in to comment.