From a150263fb5b686fd6d519cb0b0860f23cb4746ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=93=83=E6=9F=92=E6=9F=92?= Date: Sat, 21 Dec 2024 16:08:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=8F=E7=B1=B3=E4=BA=92=E4=BC=A0=20?= =?UTF-8?q?-=20=E7=A6=81=E7=94=A8=E5=88=86=E4=BA=AB=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=97=B6=E8=87=AA=E5=8A=A8=E5=BC=80=E5=90=AF=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hyperceiler/module/app/MiShare.java | 4 ++- .../hook/mishare/NoAutoTurnOnLocation.kt | 27 +++++++++++++++++++ .../hook/systemframework/FlagSecure.java | 17 +++--------- app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/mishare.xml | 21 +++++++++------ 6 files changed, 49 insertions(+), 22 deletions(-) create mode 100644 app/src/main/java/com/sevtinge/hyperceiler/module/hook/mishare/NoAutoTurnOnLocation.kt diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/MiShare.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/MiShare.java index 669ddada9f..4a8f9ea2a6 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/MiShare.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/MiShare.java @@ -21,14 +21,16 @@ import com.hchen.database.HookBase; import com.sevtinge.hyperceiler.module.base.BaseModule; import com.sevtinge.hyperceiler.module.hook.mishare.NoAutoTurnOff; +import com.sevtinge.hyperceiler.module.hook.mishare.NoAutoTurnOnLocation; import com.sevtinge.hyperceiler.module.hook.mishare.UnlockTurboMode; -@HookBase(targetPackage = "com.miui.mishare.connectivity", isPad = false) +@HookBase(targetPackage = "com.miui.mishare.connectivity") public class MiShare extends BaseModule { @Override public void handleLoadPackage() { initHook(NoAutoTurnOff.INSTANCE, mPrefsMap.getBoolean("disable_mishare_auto_off")); // 禁用 10 分钟自动关闭 + initHook(NoAutoTurnOnLocation.INSTANCE, mPrefsMap.getBoolean("disable_mishare_auto_on_location")); // 禁用分享时自动开启位置信息 initHook(UnlockTurboMode.INSTANCE, mPrefsMap.getBoolean("unlock_turbo_mode")); // 解锁极速传输模式 } } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mishare/NoAutoTurnOnLocation.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mishare/NoAutoTurnOnLocation.kt new file mode 100644 index 0000000000..5ff48664a2 --- /dev/null +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mishare/NoAutoTurnOnLocation.kt @@ -0,0 +1,27 @@ +package com.sevtinge.hyperceiler.module.hook.mishare + +import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook +import com.sevtinge.hyperceiler.module.base.* +import com.sevtinge.hyperceiler.module.base.dexkit.* +import java.lang.reflect.* + +object NoAutoTurnOnLocation : BaseHook() { + override fun init() { + val location by lazy { + DexKit.findMember("location") { + it.findMethod { + searchPackages("com.miui.mishare.connectivity") + matcher { + usingEqStrings("setLocationEnabledForUser") + modifiers = Modifier.STATIC + returnType = "boolean" + } + }.single() + } + } + + location.createHook { + returnConstant(true) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemframework/FlagSecure.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemframework/FlagSecure.java index f5004d5c33..230e735618 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemframework/FlagSecure.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemframework/FlagSecure.java @@ -67,19 +67,10 @@ public void init() { try { Class windowsState = XposedHelpers.findClass("com.android.server.wm.WindowState", lpparam.classLoader); Class windowsManagerServiceImpl = XposedHelpers.findClassIfExists("com.android.server.wm.WindowManagerServiceImpl", lpparam.classLoader); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - XposedHelpers.findAndHookMethod( - windowsState, - "isSecureLocked", - XC_MethodReplacement.returnConstant(false)); - } else { - XposedHelpers.findAndHookMethod( - "com.android.server.wm.WindowManagerService", - lpparam.classLoader, - "isSecureLocked", - windowsState, - XC_MethodReplacement.returnConstant(false)); - } + XposedHelpers.findAndHookMethod( + windowsState, + "isSecureLocked", + XC_MethodReplacement.returnConstant(false)); hookAllMethods(windowsManagerServiceImpl, "notAllowCaptureDisplay", new MethodHook() { @Override protected void before(MethodHookParam param) throws Throwable { diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 8ef8e6134a..69af9837c6 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -1549,6 +1549,7 @@ 小米互传 禁用自动关闭小米互传 + 禁用分享文件时自动开启定位服务 解锁极速传输模式 所有人 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4c3f0e2956..01f1d74163 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1508,6 +1508,7 @@ Xiaomi Share Disable automatic closing of Xiaomi Share + Automatically enable location services when sharing files is disabled Unlock Turbo transfer Everyone diff --git a/app/src/main/res/xml/mishare.xml b/app/src/main/res/xml/mishare.xml index eee1f61f2e..fb4f559aff 100644 --- a/app/src/main/res/xml/mishare.xml +++ b/app/src/main/res/xml/mishare.xml @@ -21,15 +21,20 @@ app:myLocation="@string/mishare" app:quick_restart="com.miui.mishare.connectivity"> - + - + + +