|
1 | 1 | package org.matrix.vector.core |
2 | 2 |
|
3 | | -import android.content.pm.ApplicationInfo |
4 | | -import android.ext.settings.app.AswRestrictMemoryDynCodeLoading |
5 | 3 | import android.os.IBinder |
6 | 4 | import android.os.Process |
7 | | -import de.robv.android.xposed.XC_MethodReplacement |
8 | | -import de.robv.android.xposed.XposedBridge |
9 | | -import de.robv.android.xposed.XposedHelpers |
10 | 5 | import org.lsposed.lspd.service.ILSPApplicationService |
11 | 6 | import org.lsposed.lspd.util.Utils |
12 | 7 | import org.matrix.vector.BuildConfig |
@@ -40,43 +35,8 @@ object Main { |
40 | 35 | ParasiticManagerSystemHooker.start() |
41 | 36 | } |
42 | 37 |
|
43 | | - if (niceName == "system" || niceName == "com.android.settings") { |
44 | | - try { |
45 | | - // Force GrapheneOS to allow changing the restriction on Dynamic Code Loading, and |
46 | | - // force-disable it for the settings app and the shell |
47 | | - XposedBridge.hookAllMethods( |
48 | | - AswRestrictMemoryDynCodeLoading::class.java, |
49 | | - "getImmutableValue", |
50 | | - object : XC_MethodReplacement() { |
51 | | - override fun replaceHookedMethod(param: MethodHookParam<*>?): Any? { |
52 | | - val appInfo = param?.args[2] as? ApplicationInfo? |
53 | | - |
54 | | - // Settings has to always be allowed so that it can be patched as well. |
55 | | - if (appInfo != null && listOf( |
56 | | - "com.android.settings", |
57 | | - "com.android.shell" |
58 | | - ).contains(appInfo.packageName) |
59 | | - ) { |
60 | | - return false |
61 | | - } |
62 | | - |
63 | | - // All system apps are configurable (null) |
64 | | - if (appInfo != null && (appInfo.flags and ApplicationInfo.FLAG_SYSTEM) != 0) { |
65 | | - return null |
66 | | - } |
67 | | - |
68 | | - // Defer to original implementation for other apps |
69 | | - return XposedBridge.invokeOriginalMethod( |
70 | | - param?.method, param?.thisObject, param?.args |
71 | | - ) |
72 | | - } |
73 | | - } |
74 | | - ) |
75 | | - } catch (e: XposedHelpers.ClassNotFoundError) { |
76 | | - // Ignore, assuming we are not on GrapheneOS |
77 | | - } catch (e: Exception) { |
78 | | - Utils.logE("Unknown error patching Graphene", e) |
79 | | - } |
| 38 | + if (isSystem || niceName == BuildConfig.GrapheneSettingsPackageName) { |
| 39 | + ParasiticManagerHooker.patchGrapheneDCLRestriction() |
80 | 40 | } |
81 | 41 |
|
82 | 42 | // Initialize Xposed bridge components |
|
0 commit comments