Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
feat: 小米互传 - 禁用分享文件时自动开启定位服务
Browse files Browse the repository at this point in the history
  • Loading branch information
lingqiqi5211 committed Dec 21, 2024
1 parent d711659 commit a150263
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")); // 解锁极速传输模式
}
}
Original file line number Diff line number Diff line change
@@ -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<Method>("location") {
it.findMethod {
searchPackages("com.miui.mishare.connectivity")
matcher {
usingEqStrings("setLocationEnabledForUser")
modifiers = Modifier.STATIC
returnType = "boolean"
}
}.single()
}
}

location.createHook {
returnConstant(true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,7 @@
<!--小米互传-->
<string name="mishare">小米互传</string>
<string name="mishare_disable_mishare_auto_off">禁用自动关闭小米互传</string>
<string name="mishare_disable_auto_on_location">禁用分享文件时自动开启定位服务</string>
<string name="mishare_unlock_turbo_mode">解锁极速传输模式</string>
<string name="mishare_hook_switch_mode_all">所有人</string>
<!--壁纸-->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,7 @@
<!--Mi Share-->
<string name="mishare">Xiaomi Share</string>
<string name="mishare_disable_mishare_auto_off">Disable automatic closing of Xiaomi Share</string>
<string name="mishare_disable_auto_on_location">Automatically enable location services when sharing files is disabled</string>
<string name="mishare_unlock_turbo_mode">Unlock Turbo transfer</string>
<string name="mishare_hook_switch_mode_all">Everyone</string>
<!--Wallpaper-->
Expand Down
21 changes: 13 additions & 8 deletions app/src/main/res/xml/mishare.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,20 @@
app:myLocation="@string/mishare"
app:quick_restart="com.miui.mishare.connectivity">
<PreferenceCategory>
<SwitchPreference
android:title="@string/mishare_disable_mishare_auto_off"
android:key="prefs_key_disable_mishare_auto_off"
android:defaultValue="false" />
<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_disable_mishare_auto_off"
android:title="@string/mishare_disable_mishare_auto_off" />

<SwitchPreference
android:title="@string/mishare_unlock_turbo_mode"
android:key="prefs_key_unlock_turbo_mode"
android:defaultValue="false" />
<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_disable_mishare_auto_on_location"
android:title="@string/mishare_disable_auto_on_location" />

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_unlock_turbo_mode"
android:title="@string/mishare_unlock_turbo_mode" />

</PreferenceCategory>

Expand Down

0 comments on commit a150263

Please sign in to comment.