如何检查是否有任何应用程序使用可访问性权限(BIND_ACCESSIBILITY_SERVICE),或者请求相同的应用程序名称以及是否授予它们?
要检测以下应用程序正在使用辅助功能权限:
- https://play.google.com/store/apps/details?id=you.in.spark.access.dots&hl=en_IN&gl=US
- https://play.google.com/store/apps/details?id=com.oddlyspaced.burnermedia.burnerguard&hl=en_IN&gl=US
- https://play.google.com/store/apps/details?id=com.lastpass.lpandroid&hl=en_IN&gl=US
已经尝试过以下代码,该代码不适用于上述应用程序,不显示 Access Dot 应用程序和 BurnerGuard 应用程序的任何条目,同时显示 Last pass 的条目但不影响权限更改:
List<PackageInfo> allpackages = getPackageManager().getInstalledPackages(PackageManager.GET_PERMISSIONS);
for(int i =0;i<allpackages.size();i++){
PackageInfo pi = allpackages.get(i);
if (pi.requestedPermissions == null) {
// No permissions are requested in the AndroidManifest
continue;
}
String[] requestedPermissions = pi.requestedPermissions;
int[] requestPermissionFlags;
for(int j=0;j<requestedPermissions.length;j++){
String reqParm = requestedPermissions[j];
int status = pi.requestedPermissionsFlags[j] & PackageInfo.REQUESTED_PERMISSION_GRANTED;
try {
PermissionInfo permissionInfo = getPackageManager().getPermissionInfo(reqParm,0);
if(permissionInfo.name.equals("android.permission.BIND_ACCESSIBILITY_SERVICE")) {
if(status!=0) {
Log.i("accessibility", "Package Name :: " + pi.packageName + " permission name :: " + permissionInfo.name + " Permission Granted " );
} else {
Log.i("accessibility", "Package Name :: " + pi.packageName + " permission name :: " + permissionInfo.name + " Permission Requested " );
}
}
} catch (PackageManager.NameNotFoundException e) {
//Log.e("accessibility", "Unknown permission: ");
continue;
}
}
谢谢