/**
* Check if any package in the list is installed
* @param packages - list of packages to search for
* @return true if any of the packages are installed
*/
private boolean isAnyPackageFromListInstalled(List<String> packages){
boolean result = false;
PackageManager pm = mContext.getPackageManager();
for (String packageName : packages) {
try {
// Root app detected
pm.getPackageInfo(packageName, 0);
QLog.e(packageName + " ROOT management app detected!");
result = true;
} catch (PackageManager.NameNotFoundException e) {
// Exception thrown, package is not installed into the system
}
}
return result;
}
pm.getPackageInfo(packageName, 0); this method may be not allowed to be called frequently to some other policies (because it's in a for loop).
Myabe cache an installed app list in RootBeer class, and do some local List operations to check if any package is installed, this would be better?
In every detect method will finally call
pm.getPackageInfo(packageName, 0);
this method may be not allowed to be called frequently to some other policies (because it's in a for loop).Myabe cache an installed app list in RootBeer class, and do some local List operations to check if any package is installed, this would be better?
Thanks!