[Settings] Passing correct user id to getAppOpPermissionPackages
A new user id parameter is added to the IPackageManager#getAppOpPermissionPackages API. Update the new api usage to the Settings application. Bug: 229684723 Test: atest SettingsUnitTests Test: m -j RunSettingsRoboTests \ ROBOTEST_FILTER="AlarmsAndRemindersDetailsTest| AlarmsAndRemindersDetailPreferenceControllerTest" Change-Id: I8c90f0a57426c669478367004571cca5dfb05cb6
This commit is contained in:
@@ -172,25 +172,25 @@ public abstract class AppStateAppOpsBridge extends AppStateBaseBridge {
|
||||
*/
|
||||
private SparseArray<ArrayMap<String, PermissionState>> getEntries() {
|
||||
try {
|
||||
Set<String> packagesSet = new HashSet<>();
|
||||
for (String permission : mPermissions) {
|
||||
String[] pkgs = mIPackageManager.getAppOpPermissionPackages(permission);
|
||||
if (pkgs != null) {
|
||||
packagesSet.addAll(Arrays.asList(pkgs));
|
||||
}
|
||||
}
|
||||
|
||||
if (packagesSet.isEmpty()) {
|
||||
// No packages are requesting permission as specified by mPermissions.
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create a sparse array that maps profileIds to an ArrayMap that maps package names to
|
||||
// an associated PermissionState object
|
||||
SparseArray<ArrayMap<String, PermissionState>> entries = new SparseArray<>();
|
||||
for (final UserHandle profile : mProfiles) {
|
||||
final ArrayMap<String, PermissionState> entriesForProfile = new ArrayMap<>();
|
||||
final int profileId = profile.getIdentifier();
|
||||
final Set<String> packagesSet = new HashSet<>();
|
||||
for (String permission : mPermissions) {
|
||||
final String[] pkgs = mIPackageManager.getAppOpPermissionPackages(
|
||||
permission, profileId);
|
||||
if (pkgs != null) {
|
||||
packagesSet.addAll(Arrays.asList(pkgs));
|
||||
}
|
||||
}
|
||||
if (packagesSet.isEmpty()) {
|
||||
// No packages are requesting permission as specified by mPermissions.
|
||||
continue;
|
||||
}
|
||||
|
||||
final ArrayMap<String, PermissionState> entriesForProfile = new ArrayMap<>();
|
||||
entries.put(profileId, entriesForProfile);
|
||||
for (final String packageName : packagesSet) {
|
||||
final boolean isAvailable = mIPackageManager.isPackageAvailable(packageName,
|
||||
@@ -201,6 +201,9 @@ public abstract class AppStateAppOpsBridge extends AppStateBaseBridge {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entries.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return entries;
|
||||
} catch (RemoteException e) {
|
||||
|
Reference in New Issue
Block a user