ReChronoRain / HyperCeiler

MIUI & HyperOS enhancement module - Make MIUI & HyperOS Great Again!
https://hyperceiler.sevtinge.cc
GNU Affero General Public License v3.0
2.73k stars 154 forks source link

💡 [需求] <更快速的无障碍授权> #909

Open weixiansen574 opened 1 month ago

weixiansen574 commented 1 month ago

需求内容

优化无障碍授权直达,用户可添加一个白名单列表,在名单内的APP直接开启无障碍并退出设置Activity,最快化授权。未在白名单里的,与原来一致,直达设置界面。

实现思路&截图

No response

简单例子

修改这个代码:https://github.com/ReChronoRain/HyperCeiler/blob/main/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemsettings/QuickManagerAccessibilityPermission.java 然后添加并修改以下代码

String serviceName = packageName + "/" + accessibilityService;
String eas = Settings.Secure.getString(activity.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
if (packageName.equals("白名单里的应用包名") && (eas == null || !eas.contains(serviceName))){
    if (eas == null || eas.equals("")){
        Settings.Secure.putString(activity.getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,serviceName);
    } else {
        String[] split = eas.split(":");
        StringBuilder stringBuilder = new StringBuilder();
        for (String s : split) {
            stringBuilder.append(s).append(":");
        }
        stringBuilder.append(serviceName);
        Settings.Secure.putString(activity.getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,stringBuilder.toString());
    }
    Toast.makeText(activity, "已直接授权:"+serviceName, Toast.LENGTH_SHORT).show();
    activity.finish();
    return;
}