Remove disabled app from the displayed list.

This commit is contained in:
Schoumi 2018-08-31 18:36:01 +02:00
parent 0af388ca72
commit ba6cd8c9a3
1 changed files with 11 additions and 0 deletions

View File

@ -19,6 +19,7 @@
package org.eu.exodus_privacy.exodusprivacy.adapters;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.databinding.DataBindingUtil;
@ -79,12 +80,22 @@ public class ApplicationListAdapter extends RecyclerView.Adapter {
List<PackageInfo> toRemove = new ArrayList<>();
for (PackageInfo pkg : packages) {
if (!gStore.equals(packageManager.getInstallerPackageName(pkg.packageName))) {
String auid = Utils.getCertificateSHA1Fingerprint(packageManager,pkg.packageName);
String appuid = DatabaseManager.getInstance(context).getAUID(pkg.packageName);
if(!auid.equalsIgnoreCase(appuid)) {
toRemove.add(pkg);
}
}
try {
ApplicationInfo info = packageManager.getApplicationInfo(pkg.packageName,0);
if(!info.enabled) {
toRemove.add(pkg);
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
packages.removeAll(toRemove);
}