Skip to content

Commit

Permalink
[AppInfo] Fix displaying past data usage of an updated app
Browse files Browse the repository at this point in the history
If an updated app used the Internet in the past, but the Internet permission was
removed through an update, the past data usage were not reported.

Signed-off-by: Muntashir Al-Islam <[email protected]>
  • Loading branch information
MuntashirAkon committed Aug 12, 2024
1 parent 0b3eaf4 commit 874df1a
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,13 @@ private void loadAppInfoInternal(@NonNull PackageInfo packageInfo, boolean isExt
boolean hasUsageAccess = FeatureController.isUsageAccessEnabled() && SelfPermissions.checkUsageStatsPermission();
if (hasUsageAccess) {
// Net statistics
if (ArrayUtils.contains(packageInfo.requestedPermissions, Manifest.permission.INTERNET)) {
appInfo.dataUsage = AppUsageStatsManager.getDataUsageForPackage(getApplication(),
applicationInfo.uid, UsageUtils.USAGE_LAST_BOOT);
} else appInfo.dataUsage = null;
AppUsageStatsManager.DataUsage dataUsage;
dataUsage = AppUsageStatsManager.getDataUsageForPackage(getApplication(),
applicationInfo.uid, UsageUtils.USAGE_LAST_BOOT);
if (dataUsage.getTotal() == 0 && !ArrayUtils.contains(
packageInfo.requestedPermissions, Manifest.permission.INTERNET)) {
appInfo.dataUsage = null;
} else appInfo.dataUsage = dataUsage;
// Set sizes
appInfo.sizeInfo = PackageUtils.getPackageSizeInfo(getApplication(), packageName, userId,
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? applicationInfo.storageUuid : null);
Expand Down

0 comments on commit 874df1a

Please sign in to comment.