Skip to content

Commit

Permalink
添加针对几个isEnabled的处理
Browse files Browse the repository at this point in the history
  • Loading branch information
AoEiuV020 committed Jan 10, 2022
1 parent bc9a7b4 commit e6a3e9e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
16 changes: 14 additions & 2 deletions app/src/main/java/cc/aoeiuv020/iamnotdisabled/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,33 @@ class MainActivity : AppCompatActivity() {
val serviceList: List<AccessibilityServiceInfo> =
accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK)
?: emptyList()
return serviceList.map {
val nameList = serviceList.map {
packageManager.getApplicationLabel(it.resolveInfo.serviceInfo.applicationInfo)
.toString()
}.toMutableList()
if (accessibilityManager.isEnabled) {
nameList.add("AccessibilityManager.isEnabled")
}
if (accessibilityManager.isTouchExplorationEnabled) {
nameList.add("AccessibilityManager.isTouchExplorationEnabled")
}
return nameList
}

private fun getFromSettingsSecure(): List<String> {
val settingValue = Settings.Secure.getString(
contentResolver,
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES
)
return if (settingValue.isEmpty()) {
val nameList = if (settingValue.isEmpty()) {
emptyList()
} else {
settingValue.split(':')
}.toMutableList()
val enabled = Settings.Secure.getInt(contentResolver, Settings.Secure.ACCESSIBILITY_ENABLED)
if (enabled != 0) {
nameList.add("ACCESSIBILITY_ENABLED == $enabled")
}
return nameList
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.aoeiuv020.iamnotdisabled.hook;

import android.content.ContentResolver;
import android.provider.Settings;

import java.util.Collections;

Expand All @@ -19,13 +20,21 @@
public class MainHook implements IXposedHookLoadPackage, IXposedHookZygoteInit {
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
XposedBridge.log("handleLoadPackage: " + lpparam.processName);
XposedHelpers.findAndHookMethod("android.provider.Settings$Secure", lpparam.classLoader, "getString", ContentResolver.class, String.class, new XC_MethodHook() {
protected void beforeHookedMethod(MethodHookParam methodHookParam2) throws Throwable {
if ("enabled_accessibility_services".equals((String) methodHookParam2.args[1])) {
if (Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES.equals((String) methodHookParam2.args[1])) {
methodHookParam2.setResult("");
}
}
});
XposedHelpers.findAndHookMethod("android.provider.Settings$Secure", lpparam.classLoader, "getInt", ContentResolver.class, String.class, new XC_MethodHook() {
protected void beforeHookedMethod(MethodHookParam methodHookParam2) throws Throwable {
if (Settings.Secure.ACCESSIBILITY_ENABLED.equals((String) methodHookParam2.args[1])) {
methodHookParam2.setResult(0);
}
}
});
}

@Override
Expand All @@ -38,5 +47,17 @@ public void initZygote(StartupParam startupParam) throws Throwable {
int.class,
XC_MethodReplacement.returnConstant(Collections.emptyList())
);
XposedHelpers.findAndHookMethod(
"android.view.accessibility.AccessibilityManager",
null,
"isEnabled",
XC_MethodReplacement.returnConstant(false)
);
XposedHelpers.findAndHookMethod(
"android.view.accessibility.AccessibilityManager",
null,
"isTouchExplorationEnabled",
XC_MethodReplacement.returnConstant(false)
);
}
}

0 comments on commit e6a3e9e

Please # to comment.