Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
weixiansen574 opened this issue Oct 18, 2024 · 0 comments
Open

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

weixiansen574 opened this issue Oct 18, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@weixiansen574
Copy link

需求内容

优化无障碍授权直达,用户可添加一个白名单列表,在名单内的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;
}
@weixiansen574 weixiansen574 added the enhancement New feature or request label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant