获取开启的辅助服务列表

来源:互联网 发布:韩语翻译软件 编辑:程序博客网 时间:2024/04/29 20:28
static final char ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR = ':';
// Auxiliary members.
final static SimpleStringSplitter sStringColonSplitter =
new SimpleStringSplitter(ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR);


static Set<ComponentName> getEnabledServicesFromSettings(Context context) {
final String enabledServicesSetting = Settings.Secure.getString(
context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
if (enabledServicesSetting == null) {
return Collections.emptySet();
}


final Set<ComponentName> enabledServices = new HashSet<ComponentName>();
final SimpleStringSplitter colonSplitter = sStringColonSplitter;
colonSplitter.setString(enabledServicesSetting);


while (colonSplitter.hasNext()) {
final String componentNameString = colonSplitter.next();
final ComponentName enabledService = ComponentName.unflattenFromString(
componentNameString);
if (enabledService != null) {
enabledServices.add(enabledService);
}
}


return enabledServices;
}
0 0
原创粉丝点击