├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── xposed_init
│ ├── java
│ └── five
│ │ └── ec1cff
│ │ └── mysysteminjector
│ │ └── xposed
│ │ ├── Helper.java
│ │ └── HookEntry.java
│ └── res
│ └── values
│ ├── array.xml
│ └── strings.xml
├── build.gradle.kts
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle.kts
└── stub
├── .gitignore
├── build.gradle.kts
├── consumer-rules.pro
├── proguard-rules.pro
└── src
└── main
├── AndroidManifest.xml
└── java
├── com
└── android
│ └── internal
│ └── app
│ ├── ResolverActivityStub.java
│ ├── ResolverActivityStubImpl.java
│ └── chooser
│ └── DisplayResolveInfo.java
└── sun
└── misc
└── Unsafe.java
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | .cxx
10 | local.properties
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 自用 MIUI 系统 hook
2 |
3 | 支持版本: ~~12.5.7~~ -> 13.0.3
4 |
5 | 作用域:system (系统服务)、android(系统)
6 |
7 | ## 使用方法
8 |
9 | ```sh
10 | mkdir -p /data/system/fuckmiui
11 | touch /data/system/fuckmiui/${feature}
12 | ```
13 |
14 | feature 为你想要开启的功能(详见下方标题)
15 |
16 | 如果创建了名为 `disable` 的文件,则会关闭所有功能,便于系统无法启动的时候排查问题。
17 |
18 | ## 功能
19 |
20 | 画删除线的是停止维护的功能,不保证可用
21 |
22 | ### nowakepath
23 |
24 | 禁用应用间启动 activity 的警告
25 |
26 | ### ~~installer~~
27 |
28 | 防止 google installer 被自动卸载
29 |
30 | 如果你想换用 google installer ,需要开启该功能同时卸载 miui installer ,因为系统不允许同时存在两个 installer (会崩)。
31 |
32 | ### nomiuiintent
33 |
34 | 防止 MIUI 锁定 intent (例如调用应用安装器)
35 |
36 | ### ~~protect_mc~~
37 |
38 | 防止杀进程(不知道什么情况下会触发的自动清理)
39 |
40 | 启用后还需要需要添加文件 `protect_mc_${packageName}` 指定你想要阻止被杀进程的包名。例如 `protect_mc_com.tencent.mobileqq` 。
41 |
42 | 这个功能的历史:作者曾经有一段时间被 MIUI 自动杀 QQ 困扰。按理来说 QQ 应该在各大国产系统的白名单中,也许是云控系统抽风了。
43 |
44 | 由于 QQ 冷启动实在太慢,因此写了这个功能保活。~~没想到用户也有主动帮 QQ 保活的一天。~~
45 |
46 | ### fonts
47 |
48 | 强制启用 FontManagerService 的更新功能,并禁用基于 fs-verity 的验证。
49 |
50 | 启用后可通过以下命令升级字体:
51 |
52 | ```sh
53 | # /path/to/dummy 是空文件
54 | # 所有路径需要系统服务有读权限,例如 /data/local/tmp
55 | cmd font update /path/to/font.ttf /path/to/dummy
56 | ```
57 |
58 | 这个功能和 MIUI 无关,理论上适用于任何 Android 12 系统。
59 |
60 | ### xspace
61 |
62 | 1. 在系统服务:允许 shell 指定用户直接启动 activity 而无需弹出选择双开的提示( `am start --user` )
63 | 2. 在系统:ResolverActivity 直接显示双开 app 的打开方式,无需二次点击。
64 | 3. 修复该版本中点击 xmsf 推送的通知会显示选择双开的 bug 。
65 | 4. 禁止 ResolverActivity 添加 `SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS` flags ,允许悬浮窗在其上显示。
66 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.application")
3 | }
4 |
5 | android {
6 | compileSdk = 35
7 |
8 | defaultConfig {
9 | applicationId = "five.ec1cff.mysysteminjector"
10 | minSdk = 30
11 | targetSdk = 35
12 | versionCode = 1
13 | versionName = "1.0"
14 | }
15 |
16 | buildTypes {
17 | release {
18 | isMinifyEnabled = false
19 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
20 | }
21 | }
22 | compileOptions {
23 | sourceCompatibility = JavaVersion.VERSION_17
24 | targetCompatibility = JavaVersion.VERSION_17
25 | }
26 | namespace = "five.ec1cff.mysysteminjector"
27 | }
28 |
29 | dependencies {
30 | implementation("androidx.annotation:annotation:1.9.1")
31 | compileOnly("de.robv.android.xposed:api:82")
32 | compileOnly(project(":stub"))
33 | }
34 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/assets/xposed_init:
--------------------------------------------------------------------------------
1 | five.ec1cff.mysysteminjector.xposed.HookEntry
--------------------------------------------------------------------------------
/app/src/main/java/five/ec1cff/mysysteminjector/xposed/Helper.java:
--------------------------------------------------------------------------------
1 | package five.ec1cff.mysysteminjector.xposed;
2 |
3 | import android.annotation.SuppressLint;
4 |
5 | import androidx.annotation.Nullable;
6 |
7 | import java.lang.invoke.MethodHandle;
8 | import java.lang.invoke.MethodHandleInfo;
9 | import java.lang.invoke.MethodHandles;
10 | import java.lang.reflect.Constructor;
11 | import java.lang.reflect.Executable;
12 | import java.lang.reflect.InvocationTargetException;
13 | import java.lang.reflect.Member;
14 | import java.lang.reflect.Method;
15 | import java.lang.reflect.Modifier;
16 |
17 | import de.robv.android.xposed.XposedBridge;
18 | import sun.misc.Unsafe;
19 |
20 | // https://github.com/LSPosed/AndroidHiddenApiBypass/blob/2e46e453c83035d201a90cc05cfd2a7aa0922fa7/library/src/main/java/org/lsposed/hiddenapibypass/HiddenApiBypass.java#L206
21 | @SuppressLint({"SoonBlockedPrivateApi", "DiscouragedPrivateApi"})
22 | public class Helper {
23 | private final static Method deoptimizeMethod;
24 |
25 | static {
26 | Method m = null;
27 | try {
28 | m = XposedBridge.class.getDeclaredMethod("deoptimizeMethod", Member.class);
29 | } catch (Throwable t) {
30 | XposedBridge.log("cannot get deoptimizeMethod");
31 | }
32 | deoptimizeMethod = m;
33 | }
34 |
35 | static void deoptimizeMethod(Class> c, String n) throws InvocationTargetException, IllegalAccessException {
36 | for (Method m : c.getDeclaredMethods()) {
37 | if (deoptimizeMethod != null && m.getName().equals(n)) {
38 | deoptimizeMethod.invoke(null, m);
39 | }
40 | }
41 | }
42 |
43 | private static final Unsafe unsafe;
44 | private static final long methodsOffset;
45 | private static final long artMethodSize;
46 | private static final long artMethodBias;
47 | private static final long artOffset;
48 | private static final long infoOffset;
49 | private static final long memberOffset;
50 |
51 | private static class NeverCall {
52 | private static void a() {
53 | }
54 |
55 | private static void b() {
56 | }
57 | }
58 |
59 | static {
60 | try {
61 | unsafe = (Unsafe) Unsafe.class.getDeclaredMethod("getUnsafe").invoke(null);
62 | assert unsafe != null;
63 | artOffset = unsafe.objectFieldOffset(MethodHandle.class.getDeclaredField("artFieldOrMethod"));
64 | infoOffset = unsafe.objectFieldOffset(Class.forName("java.lang.invoke.MethodHandleImpl").getDeclaredField("info"));
65 | methodsOffset = unsafe.objectFieldOffset(Class.class.getDeclaredField("methods"));
66 | memberOffset = unsafe.objectFieldOffset(Class.forName("java.lang.invoke.MethodHandleImpl$HandleInfo").getDeclaredField("member"));
67 | Method mA = Helper.NeverCall.class.getDeclaredMethod("a");
68 | Method mB = Helper.NeverCall.class.getDeclaredMethod("b");
69 | mA.setAccessible(true);
70 | mB.setAccessible(true);
71 | MethodHandle mhA = MethodHandles.lookup().unreflect(mA);
72 | MethodHandle mhB = MethodHandles.lookup().unreflect(mB);
73 | long aAddr = unsafe.getLong(mhA, artOffset);
74 | long bAddr = unsafe.getLong(mhB, artOffset);
75 | long aMethods = unsafe.getLong(Helper.NeverCall.class, methodsOffset);
76 | artMethodSize = bAddr - aAddr;
77 | artMethodBias = aAddr - aMethods - artMethodSize;
78 | } catch (Throwable t) {
79 | XposedBridge.log("failed to initialize helper");
80 | throw new ExceptionInInitializerError(t);
81 | }
82 | }
83 |
84 | @Nullable
85 | public static Constructor> getClInit(Class> clazz) {
86 | if (clazz.isPrimitive() || clazz.isArray()) return null;
87 | MethodHandle mh;
88 | try {
89 | Method mA = Helper.NeverCall.class.getDeclaredMethod("a");
90 | mA.setAccessible(true);
91 | mh = MethodHandles.lookup().unreflect(mA);
92 | } catch (NoSuchMethodException | IllegalAccessException e) {
93 | return null;
94 | }
95 | long methods = unsafe.getLong(clazz, methodsOffset);
96 | if (methods == 0) return null;
97 | int numMethods = unsafe.getInt(methods);
98 | for (int i = 0; i < numMethods; i++) {
99 | long method = methods + i * artMethodSize + artMethodBias;
100 | unsafe.putLong(mh, artOffset, method);
101 | unsafe.putObject(mh, infoOffset, null);
102 | try {
103 | MethodHandles.lookup().revealDirect(mh);
104 | } catch (Throwable ignored) {
105 | }
106 | MethodHandleInfo info = (MethodHandleInfo) unsafe.getObject(mh, infoOffset);
107 | Executable member = (Executable) unsafe.getObject(info, memberOffset);
108 | if (member instanceof Constructor && (member.getModifiers() & Modifier.STATIC) != 0) return (Constructor>) member;
109 | }
110 | return null;
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/app/src/main/java/five/ec1cff/mysysteminjector/xposed/HookEntry.java:
--------------------------------------------------------------------------------
1 | package five.ec1cff.mysysteminjector.xposed;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.pm.ApplicationInfo;
7 | import android.content.pm.ResolveInfo;
8 | import android.graphics.drawable.Drawable;
9 | import android.os.UserHandle;
10 | import android.view.View;
11 | import android.view.Window;
12 |
13 | import java.io.File;
14 | import java.util.List;
15 | import java.util.Objects;
16 |
17 | import de.robv.android.xposed.IXposedHookLoadPackage;
18 | import de.robv.android.xposed.XC_MethodHook;
19 | import de.robv.android.xposed.XC_MethodReplacement;
20 | import de.robv.android.xposed.XposedBridge;
21 | import de.robv.android.xposed.XposedHelpers;
22 | import de.robv.android.xposed.callbacks.XC_LoadPackage;
23 |
24 | @SuppressWarnings("unchecked")
25 | public class HookEntry implements IXposedHookLoadPackage {
26 | private static final String TAG = "MySystemInjector";
27 | private static final String WORKDIR = "/data/system/fuckmiui";
28 | boolean loaded = false;
29 | public static boolean isFeatureEnabled(String featureName) {
30 | return new File(new File(WORKDIR), featureName).exists();
31 | }
32 |
33 | public static void log(String msg) {
34 | XposedBridge.log("[" + TAG + "] " + msg);
35 | }
36 |
37 | public static void log(String msg, Throwable t) {
38 | XposedBridge.log("[" + TAG + "] " + msg);
39 | XposedBridge.log(t);
40 | }
41 |
42 | @Override
43 | public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
44 | boolean inSystemServer = lpparam.packageName.equals("android") && lpparam.processName.equals("android");
45 | boolean inSystem = lpparam.packageName.equals("system");
46 | XposedBridge.log("handleLoadPackage inSystem=" + inSystem + " package=" + lpparam.packageName + " process=" + lpparam.processName);
47 | if (isFeatureEnabled("share") && !inSystem) {
48 | hookShareInUI(lpparam);
49 | }
50 | if (!inSystemServer && !inSystem) {
51 | return;
52 | }
53 | if (loaded) return;
54 | loaded = true;
55 |
56 | if (isFeatureEnabled("disable")) {
57 | log("disabled, exit");
58 | return;
59 | }
60 |
61 | if (inSystem) {
62 | if (isFeatureEnabled("xspace")) {
63 | hookXSpaceInUI(lpparam);
64 | }
65 | }
66 |
67 | if (!inSystemServer) return;
68 |
69 | try {
70 | if (isFeatureEnabled("nowakepath")) {
71 | log("hook for nowakepath");
72 | XposedBridge.hookAllMethods(
73 | XposedHelpers.findClass("miui.app.ActivitySecurityHelper", lpparam.classLoader),
74 | "getCheckStartActivityIntent",
75 | XC_MethodReplacement.DO_NOTHING
76 | );
77 | // miui-framework.jar
78 | XposedBridge.hookAllMethods(
79 | XposedHelpers.findClass("miui.security.SecurityManager", lpparam.classLoader),
80 | "getCheckStartActivityIntent",
81 | XC_MethodReplacement.DO_NOTHING
82 | );
83 | log("hook done");
84 | }
85 | } catch (Throwable t) {
86 | XposedBridge.log(t);
87 | }
88 |
89 | try {
90 | if (isFeatureEnabled("installer")) {
91 | log("hook for installer");
92 | XposedBridge.hookAllMethods(
93 | XposedHelpers.findClass("com.android.server.pm.PackageManagerServiceInjector", lpparam.classLoader),
94 | "checkPackageInstallerStatus",
95 | new XC_MethodHook() {
96 | @Override
97 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
98 | XposedBridge.log(TAG + "tried to protect installer");
99 | Object curPkgSettings = param.args[1];
100 | Object mPackages = XposedHelpers.getObjectField(curPkgSettings, "mPackages");
101 | Object googleInstaller = XposedHelpers.callMethod(mPackages, "get", "com.google.android.packageinstaller");
102 | Object miuiInstaller = XposedHelpers.callMethod(mPackages, "get", "com.miui.packageinstaller");
103 | if (googleInstaller == null || miuiInstaller == null) {
104 | log("failed to find PackageSetting, cancel");
105 | return;
106 | }
107 | log("google=" + googleInstaller);
108 | log("miui=" + miuiInstaller);
109 | XposedHelpers.callMethod(googleInstaller, "setInstalled", true, 0);
110 | XposedHelpers.callMethod(miuiInstaller, "setInstalled", false, 0);
111 | try {
112 | Object installer = XposedHelpers.callMethod(param.args[0], "getRequiredInstallerLPr");
113 | log("replace installer:" + installer);
114 | } catch (RuntimeException e) {
115 | // ?
116 | log("failed to replace installer, call original method fallback...", e);
117 | return;
118 | } catch (Throwable t) {
119 | log("something wrong", t);
120 | }
121 | param.setResult(null);
122 | }
123 | }
124 | );
125 | log("hook done");
126 | }
127 | } catch (Throwable t) {
128 | log("hook installer", t);
129 | }
130 |
131 | try {
132 | if (isFeatureEnabled("nomiuiintent")) {
133 | log("hook for nomiuiintent");
134 | // for hyperos 1.0.2.0
135 |
136 | XposedHelpers.findAndHookMethod("com.android.server.pm.PackageManagerServiceImpl", lpparam.classLoader,
137 | "hookChooseBestActivity",
138 | Intent.class, String.class, long.class, List.class, int.class, ResolveInfo.class, new XC_MethodHook() {
139 | @Override
140 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
141 | param.setResult(param.args[5]); // defaultValue
142 | }
143 | }
144 | );
145 | /*
146 | // for 13.0.3
147 | // miui-services.jar
148 | XposedHelpers.findAndHookMethod("com.android.server.pm.PackageManagerServiceImpl", lpparam.classLoader,
149 | "hookChooseBestActivity",
150 | Intent.class, String.class, int.class, List.class, int.class, ResolveInfo.class, new XC_MethodHook() {
151 | @Override
152 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
153 | param.setResult(param.args[5]); // defaultValue
154 | }
155 | }
156 | );*/
157 | // for 12.5.7
158 | // services.jar
159 | /*
160 | XposedBridge.hookAllMethods(
161 | XposedHelpers.findClass("com.android.server.pm.PackageManagerServiceInjector", lpparam.classLoader),
162 | "checkMiuiIntent",
163 | new XC_MethodHook() {
164 | @Override
165 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
166 | param.setResult(
167 | XposedHelpers.getObjectField(param.args[0], "mResolveInfo")
168 | );
169 | }
170 | }
171 | );*/
172 | log("nomiuiintent hook done");
173 | }
174 | } catch (Throwable t) {
175 | log("nomiuiintent error", t);
176 | }
177 |
178 | try {
179 | if (isFeatureEnabled("protect_mc")) {
180 | log("hook for ProcessMemoryCleaner");
181 | XposedHelpers.findAndHookMethod(
182 | XposedHelpers.findClass("com.android.server.am.ProcessMemoryCleaner", lpparam.classLoader),
183 | "checkBackgroundApp",
184 | String.class, int.class,
185 | new XC_MethodHook() {
186 | @Override
187 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
188 | var packageName = (String) param.args[0];
189 | if (isFeatureEnabled("protect_mc_" + packageName)) {
190 | // XposedBridge.log("protect " + packageName + " from PMC");
191 | param.setResult(null);
192 | }
193 | }
194 | }
195 | );
196 | }
197 | } catch (Throwable t) {
198 | log("protect_mc error", t);
199 | }
200 |
201 | try {
202 | if (isFeatureEnabled("fonts")) {
203 | log("hook for fonts");
204 | ThreadLocal isCreating = new ThreadLocal<>();
205 | Class> FMS = XposedHelpers.findClass("com.android.server.graphics.fonts.FontManagerService", lpparam.classLoader);
206 | Class> FUI = XposedHelpers.findClass("com.android.server.graphics.fonts.FontManagerService$FsverityUtilImpl", lpparam.classLoader);
207 | XposedBridge.hookAllConstructors(
208 | FMS,
209 | new XC_MethodHook() {
210 | @Override
211 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
212 | isCreating.set(true);
213 | }
214 |
215 | @Override
216 | protected void afterHookedMethod(MethodHookParam param) throws Throwable {
217 | isCreating.set(false);
218 | }
219 | }
220 | );
221 | XposedBridge.hookAllMethods(
222 | XposedHelpers.findClass("com.android.internal.security.VerityUtils", lpparam.classLoader),
223 | "isFsVeritySupported",
224 | new XC_MethodHook() {
225 | @Override
226 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
227 | if (isCreating.get()) {
228 | param.setResult(true);
229 | isCreating.set(false);
230 | }
231 | }
232 | }
233 | );
234 | XposedBridge.hookAllMethods(
235 | FUI,
236 | "hasFsverity",
237 | new XC_MethodHook() {
238 | @Override
239 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
240 | param.setResult(true);
241 | }
242 | }
243 | );
244 | XposedBridge.hookAllMethods(
245 | FUI,
246 | "setUpFsverity",
247 | new XC_MethodReplacement() {
248 | @Override
249 | protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
250 | return null;
251 | }
252 | }
253 | );
254 | }
255 | } catch (Throwable t) {
256 | XposedBridge.log(t);
257 | }
258 |
259 | try {
260 | if (isFeatureEnabled("clipboard")) {
261 | XposedBridge.hookAllMethods(
262 | XposedHelpers.findClass("com.android.server.clipboard.ClipboardService", lpparam.classLoader),
263 | "clipboardAccessAllowed",
264 | new XC_MethodHook() {
265 | @Override
266 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
267 | var pkg = (String) param.args[1];
268 | if (pkg == null) return;
269 | if ("com.fooview.android.fooview".equals(pkg) || "com.termux".equals(pkg) || "com.termux.api".equals(pkg))
270 | param.setResult(true);
271 | }
272 | }
273 | );
274 | }
275 | } catch (Throwable t) {
276 | XposedBridge.log(t);
277 | }
278 |
279 | try {
280 | if (isFeatureEnabled("fixsync")) {
281 | // https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/services/core/java/com/android/server/wm/WindowState.java;l=5756;drc=4eb30271c338af7ee6abcbd2b7a9a0721db0595b
282 | // some goned accessibility windows does not get synced
283 | XposedBridge.hookAllMethods(
284 | XposedHelpers.findClass("com.android.server.wm.WindowState", lpparam.classLoader),
285 | "isSyncFinished",
286 | new XC_MethodHook() {
287 | @Override
288 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
289 | if ((int) XposedHelpers.getObjectField(param.thisObject, "mViewVisibility") != View.VISIBLE
290 | && XposedHelpers.getObjectField(param.thisObject, "mActivityRecord") == null) {
291 | // XposedBridge.log("no wait on " + param.thisObject);
292 | param.setResult(true);
293 | }
294 | }
295 | }
296 | );
297 | }
298 | } catch (Throwable t) {
299 | XposedBridge.log("fixsync");
300 | XposedBridge.log(t);
301 | }
302 |
303 | hookXSpace(lpparam);
304 | }
305 |
306 | private void hookShareInUI(XC_LoadPackage.LoadPackageParam lpparam) {
307 | try {
308 | /*
309 | var impl = new ResolverActivityStubImpl() {
310 | @Override
311 | public boolean useAospShareSheet() {
312 | XposedBridge.log("useAospShareSheet");
313 | return true;
314 | }
315 | };
316 | XposedHelpers.callStaticMethod(
317 | XposedHelpers.findClass("com.miui.base.MiuiStubRegistry", lpparam.classLoader),
318 | "registerSingleton", impl
319 | );
320 | XposedHelpers.setStaticObjectField(ResolverActivityStub.class, "sInstance", impl);
321 | */
322 | XposedBridge.hookAllMethods(
323 | XposedHelpers.findClass("com.android.internal.app.ResolverActivityStubImpl", lpparam.classLoader),
324 | "useAospShareSheet",
325 | new XC_MethodHook() {
326 | @Override
327 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
328 | XposedBridge.log("useAospShareSheet");
329 | param.setResult(true);
330 | }
331 | }
332 | );
333 | XposedBridge.log("hook installed");
334 | } catch (Throwable t) {
335 | XposedBridge.log(t);
336 | }
337 | }
338 |
339 | @SuppressWarnings("unchecked")
340 | private void hookXSpace(XC_LoadPackage.LoadPackageParam lpparam) {
341 | if (!isFeatureEnabled("xspace")) return;
342 | log("[MySystemInjector] hook for xspace");
343 | try {
344 | Class> classXSpaceManager = XposedHelpers.findClass("com.miui.server.xspace.XSpaceManagerServiceImpl", lpparam.classLoader);
345 | List list = (List) XposedHelpers.getStaticObjectField(classXSpaceManager, "sCrossUserCallingPackagesWhiteList");
346 | if (list != null) {
347 | list.add("com.android.shell");
348 | list.add("com.xiaomi.xmsf");
349 | log("add required packages to whitelist at init");
350 | } else {
351 | log("whitelist is null");
352 | }
353 | List publicActions = (List) XposedHelpers.getStaticObjectField(classXSpaceManager, "sPublicActionList");
354 | if (publicActions != null) {
355 | publicActions.clear();
356 | log("clear publicActionList");
357 | } else {
358 | log("publicActionList is null");
359 | }
360 | } catch (Throwable t) {
361 | log("hook xspace shell failed", t);
362 | }
363 | }
364 |
365 | private void hookXSpaceInUI(XC_LoadPackage.LoadPackageParam lpparam) {
366 | log("hookForXspace in system");
367 | XposedBridge.hookAllMethods(
368 | XposedHelpers.findClass("com.android.internal.app.ResolverListController", lpparam.classLoader),
369 | "getResolversForIntent",
370 | new XC_MethodHook() {
371 | @Override
372 | protected void afterHookedMethod(MethodHookParam param) throws Throwable {
373 | List