diff --git a/app/src/main/java/io/github/muntashirakon/AppManager/details/AppDetailsViewModel.java b/app/src/main/java/io/github/muntashirakon/AppManager/details/AppDetailsViewModel.java index 06b286e7cb6..a164253d8b4 100644 --- a/app/src/main/java/io/github/muntashirakon/AppManager/details/AppDetailsViewModel.java +++ b/app/src/main/java/io/github/muntashirakon/AppManager/details/AppDetailsViewModel.java @@ -146,14 +146,9 @@ public class AppDetailsViewModel extends AndroidViewModel { public AppDetailsViewModel(@NonNull Application application) { super(application); - try { - mPackageManager = application.getPackageManager(); - mReceiver = new PackageIntentReceiver(this); - mWaitForBlocker = true; - } catch (Throwable th) { - Log.e(TAG, th); - throw new RuntimeException("Could not instantiate AppDetailsViewModel", th); - } + mPackageManager = application.getPackageManager(); + mReceiver = new PackageIntentReceiver(this); + mWaitForBlocker = true; } @GuardedBy("blockerLocker") @@ -1170,7 +1165,6 @@ private void loadActivities() { SelfPermissions.checkSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS); for (ActivityInfo activityInfo : packageInfo.activities) { AppDetailsActivityItem componentItem = new AppDetailsActivityItem(activityInfo); - componentItem.name = activityInfo.name; componentItem.label = getComponentLabel(activityInfo, appLabel); synchronized (mBlockerLocker) { if (!mExternalApk) { @@ -1214,7 +1208,6 @@ private void loadServices() { CharSequence appLabel = packageInfo.applicationInfo.loadLabel(mPackageManager); for (ServiceInfo serviceInfo : packageInfo.services) { AppDetailsServiceItem serviceItem = new AppDetailsServiceItem(serviceInfo); - serviceItem.name = serviceInfo.name; serviceItem.label = getComponentLabel(serviceInfo, appLabel); synchronized (mBlockerLocker) { if (!mExternalApk) { @@ -1259,7 +1252,6 @@ private void loadReceivers() { CharSequence appLabel = packageInfo.applicationInfo.loadLabel(mPackageManager); for (ActivityInfo activityInfo : packageInfo.receivers) { AppDetailsComponentItem componentItem = new AppDetailsComponentItem(activityInfo); - componentItem.name = activityInfo.name; componentItem.label = getComponentLabel(activityInfo, appLabel); synchronized (mBlockerLocker) { if (!mExternalApk) { @@ -1293,7 +1285,6 @@ private void loadProviders() { CharSequence appLabel = packageInfo.applicationInfo.loadLabel(mPackageManager); for (ProviderInfo providerInfo : packageInfo.providers) { AppDetailsComponentItem componentItem = new AppDetailsComponentItem(providerInfo); - componentItem.name = providerInfo.name; componentItem.label = getComponentLabel(providerInfo, appLabel); synchronized (mBlockerLocker) { if (!mExternalApk) { @@ -1458,7 +1449,6 @@ private void loadAppOps() { } else { appDetailsItem = new AppDetailsAppOpItem(entry); } - appDetailsItem.name = entry.getName(); mAppOpItems.add(appDetailsItem); } // Add other ops @@ -1481,7 +1471,6 @@ private void loadAppOps() { } else { appDetailsItem = new AppDetailsAppOpItem(op); } - appDetailsItem.name = AppOpsManagerCompat.opToName(op); mAppOpItems.add(appDetailsItem); } } catch (Throwable e) { @@ -1610,7 +1599,6 @@ private void loadPermissions() { if (packageInfo.permissions != null) { for (PermissionInfo permissionInfo : packageInfo.permissions) { AppDetailsDefinedPermissionItem appDetailsItem = new AppDetailsDefinedPermissionItem(permissionInfo, false); - appDetailsItem.name = permissionInfo.name; mPermissionItems.add(appDetailsItem); visitedPerms.add(permissionInfo.name); } @@ -1627,7 +1615,6 @@ private void loadPermissions() { permissionInfo.name = activityInfo.permission; } AppDetailsDefinedPermissionItem appDetailsItem = new AppDetailsDefinedPermissionItem(permissionInfo, true); - appDetailsItem.name = permissionInfo.name; mPermissionItems.add(appDetailsItem); visitedPerms.add(permissionInfo.name); } catch (RemoteException e) { @@ -1648,7 +1635,6 @@ private void loadPermissions() { permissionInfo.name = serviceInfo.permission; } AppDetailsDefinedPermissionItem appDetailsItem = new AppDetailsDefinedPermissionItem(permissionInfo, true); - appDetailsItem.name = permissionInfo.name; mPermissionItems.add(appDetailsItem); visitedPerms.add(permissionInfo.name); } catch (RemoteException e) { @@ -1669,7 +1655,6 @@ private void loadPermissions() { permissionInfo.name = providerInfo.readPermission; } AppDetailsDefinedPermissionItem appDetailsItem = new AppDetailsDefinedPermissionItem(permissionInfo, true); - appDetailsItem.name = permissionInfo.name; mPermissionItems.add(appDetailsItem); visitedPerms.add(permissionInfo.name); } catch (RemoteException e) { @@ -1686,7 +1671,6 @@ private void loadPermissions() { permissionInfo.name = providerInfo.writePermission; } AppDetailsDefinedPermissionItem appDetailsItem = new AppDetailsDefinedPermissionItem(permissionInfo, true); - appDetailsItem.name = permissionInfo.name; mPermissionItems.add(appDetailsItem); visitedPerms.add(permissionInfo.name); } catch (RemoteException e) { @@ -1707,7 +1691,6 @@ private void loadPermissions() { permissionInfo.name = activityInfo.permission; } AppDetailsDefinedPermissionItem appDetailsItem = new AppDetailsDefinedPermissionItem(permissionInfo, true); - appDetailsItem.name = permissionInfo.name; mPermissionItems.add(appDetailsItem); visitedPerms.add(permissionInfo.name); } catch (RemoteException e) { diff --git a/app/src/main/java/io/github/muntashirakon/AppManager/details/struct/AppDetailsAppOpItem.java b/app/src/main/java/io/github/muntashirakon/AppManager/details/struct/AppDetailsAppOpItem.java index 671b03ff482..d7182578801 100644 --- a/app/src/main/java/io/github/muntashirakon/AppManager/details/struct/AppDetailsAppOpItem.java +++ b/app/src/main/java/io/github/muntashirakon/AppManager/details/struct/AppDetailsAppOpItem.java @@ -14,6 +14,7 @@ import androidx.core.content.pm.PermissionInfoCompat; import java.util.List; +import java.util.Objects; import io.github.muntashirakon.AppManager.compat.AppOpsManagerCompat; import io.github.muntashirakon.AppManager.compat.ManifestCompat; @@ -41,11 +42,13 @@ public class AppDetailsAppOpItem extends AppDetailsItem { public AppDetailsAppOpItem(@NonNull AppOpsManagerCompat.OpEntry opEntry) { this(opEntry.getOp()); + name = opEntry.getName(); mOpEntry = opEntry; } public AppDetailsAppOpItem(int op) { super(op); + name = AppOpsManagerCompat.opToName(op); mOpEntry = null; permissionInfo = null; permission = null; @@ -57,6 +60,7 @@ public AppDetailsAppOpItem(int op) { public AppDetailsAppOpItem(@NonNull AppOpsManagerCompat.OpEntry opEntry, @NonNull PermissionInfo permissionInfo, boolean isGranted, int permissionFlags, boolean appContainsPermission) { super(opEntry.getOp()); + name = opEntry.getName(); mOpEntry = opEntry; this.permissionInfo = permissionInfo; this.appContainsPermission = appContainsPermission; @@ -75,6 +79,7 @@ public AppDetailsAppOpItem(@NonNull AppOpsManagerCompat.OpEntry opEntry, @NonNul public AppDetailsAppOpItem(int op, @NonNull PermissionInfo permissionInfo, boolean isGranted, int permissionFlags, boolean appContainsPermission) { super(op); + name = AppOpsManagerCompat.opToName(op); mOpEntry = null; this.permissionInfo = permissionInfo; this.appContainsPermission = appContainsPermission; @@ -220,4 +225,18 @@ public void invalidate(@NonNull AppOpsManagerCompat appOpsManager, @NonNull Pack throw new PermissionException(e); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof AppDetailsAppOpItem)) return false; + if (!super.equals(o)) return false; + AppDetailsAppOpItem that = (AppDetailsAppOpItem) o; + return Objects.equals(mainItem, that.mainItem); + } + + @Override + public int hashCode() { + return Objects.hash(mainItem); + } } diff --git a/app/src/main/java/io/github/muntashirakon/AppManager/details/struct/AppDetailsComponentItem.java b/app/src/main/java/io/github/muntashirakon/AppManager/details/struct/AppDetailsComponentItem.java index 53705f1f8f1..8aa868b9321 100644 --- a/app/src/main/java/io/github/muntashirakon/AppManager/details/struct/AppDetailsComponentItem.java +++ b/app/src/main/java/io/github/muntashirakon/AppManager/details/struct/AppDetailsComponentItem.java @@ -23,6 +23,7 @@ public class AppDetailsComponentItem extends AppDetailsItem { public AppDetailsComponentItem(@NonNull ComponentInfo componentInfo) { super(componentInfo); + name = componentInfo.name; mIsDisabled = !componentInfo.isEnabled(); } diff --git a/app/src/main/java/io/github/muntashirakon/AppManager/details/struct/AppDetailsDefinedPermissionItem.java b/app/src/main/java/io/github/muntashirakon/AppManager/details/struct/AppDetailsDefinedPermissionItem.java index 4f27d41b1eb..64bf1a2e11d 100644 --- a/app/src/main/java/io/github/muntashirakon/AppManager/details/struct/AppDetailsDefinedPermissionItem.java +++ b/app/src/main/java/io/github/muntashirakon/AppManager/details/struct/AppDetailsDefinedPermissionItem.java @@ -11,6 +11,7 @@ public class AppDetailsDefinedPermissionItem extends AppDetailsItem