Merge "Handle proxy chains including the system package" into sc-dev

This commit is contained in:
Nate Myren
2021-03-23 15:27:07 +00:00
committed by Android (Google) Code Review

View File

@@ -283,9 +283,7 @@ public class PermissionUsageHelper {
continue; continue;
} }
if (packageName.equals(SYSTEM_PKG) if (!shouldShowPermissionsHub() && !isUserSensitive(packageName, user, op)) {
|| (!shouldShowPermissionsHub()
&& !isUserSensitive(packageName, user, op))) {
continue; continue;
} }
@@ -372,8 +370,10 @@ public class PermissionUsageHelper {
proxyLabels.put(usage, new ArrayList<>()); proxyLabels.put(usage, new ArrayList<>());
proxyUids.add(usage.uid); proxyUids.add(usage.uid);
} }
if (!mostRecentUsages.containsKey(usage.uid) || usage.lastAccessTime // If this usage is not by the system, and is more recent than the next-most recent
> mostRecentUsages.get(usage.uid).lastAccessTime) { // for it's uid, save it.
if (!usage.packageName.equals(SYSTEM_PKG) && (!mostRecentUsages.containsKey(usage.uid)
|| usage.lastAccessTime > mostRecentUsages.get(usage.uid).lastAccessTime)) {
mostRecentUsages.put(usage.uid, usage); mostRecentUsages.put(usage.uid, usage);
} }
} }
@@ -416,20 +416,22 @@ public class PermissionUsageHelper {
} }
proxyUids.add(currentUsage.uid); proxyUids.add(currentUsage.uid);
try { // Don't add an app label for the main app, or the system app
PackageManager userPkgManager = if (!currentUsage.packageName.equals(start.packageName)
getUserContext(currentUsage.getUser()).getPackageManager(); && !currentUsage.packageName.equals(SYSTEM_PKG)) {
ApplicationInfo appInfo = userPkgManager.getApplicationInfo( try {
currentUsage.packageName, 0); PackageManager userPkgManager =
CharSequence appLabel = appInfo.loadLabel(userPkgManager); getUserContext(currentUsage.getUser()).getPackageManager();
// If we don't already have the app label, and it's not the same as the main ApplicationInfo appInfo = userPkgManager.getApplicationInfo(
// app, add it currentUsage.packageName, 0);
if (!proxyLabelList.contains(appLabel) CharSequence appLabel = appInfo.loadLabel(userPkgManager);
&& !currentUsage.packageName.equals(start.packageName)) { // If we don't already have the app label add it
proxyLabelList.add(appLabel); if (!proxyLabelList.contains(appLabel)) {
proxyLabelList.add(appLabel);
}
} catch (PackageManager.NameNotFoundException e) {
// Ignore
} }
} catch (PackageManager.NameNotFoundException e) {
// Ignore
} }
iterNum++; iterNum++;
} }