Fix multi-user handling in PermissionPolicyService.
PackageListObserver is actually only called once with an app ID, instead of for each user with a UID. This is a modified version of pa/2393586, with fixes for package change and removal callbacks as well. Bug: 221911904 Test: presubmit Change-Id: I390e1493193651689c5fa37e2b2ebe9d7aabaf80
This commit is contained in:
@@ -194,27 +194,38 @@ public final class PermissionPolicyService extends SystemService {
|
||||
|
||||
mPackageManagerInternal.getPackageList(new PackageListObserver() {
|
||||
@Override
|
||||
public void onPackageAdded(String packageName, int uid) {
|
||||
final int userId = UserHandle.getUserId(uid);
|
||||
if (isStarted(userId)) {
|
||||
synchronizePackagePermissionsAndAppOpsForUser(packageName, userId);
|
||||
public void onPackageAdded(String packageName, int appId) {
|
||||
final int[] userIds = LocalServices.getService(UserManagerInternal.class)
|
||||
.getUserIds();
|
||||
for (final int userId : userIds) {
|
||||
if (isStarted(userId)) {
|
||||
synchronizePackagePermissionsAndAppOpsForUser(packageName, userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageChanged(String packageName, int uid) {
|
||||
final int userId = UserHandle.getUserId(uid);
|
||||
if (isStarted(userId)) {
|
||||
synchronizePackagePermissionsAndAppOpsForUser(packageName, userId);
|
||||
resetAppOpPermissionsIfNotRequestedForUid(uid);
|
||||
public void onPackageChanged(String packageName, int appId) {
|
||||
final int[] userIds = LocalServices.getService(UserManagerInternal.class)
|
||||
.getUserIds();
|
||||
for (final int userId : userIds) {
|
||||
if (isStarted(userId)) {
|
||||
synchronizePackagePermissionsAndAppOpsForUser(packageName, userId);
|
||||
final int uid = UserHandle.getUid(userId, appId);
|
||||
resetAppOpPermissionsIfNotRequestedForUid(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageRemoved(String packageName, int uid) {
|
||||
final int userId = UserHandle.getUserId(uid);
|
||||
if (isStarted(userId)) {
|
||||
resetAppOpPermissionsIfNotRequestedForUid(uid);
|
||||
public void onPackageRemoved(String packageName, int appId) {
|
||||
final int[] userIds = LocalServices.getService(UserManagerInternal.class)
|
||||
.getUserIds();
|
||||
for (final int userId : userIds) {
|
||||
if (isStarted(userId)) {
|
||||
final int uid = UserHandle.getUid(userId, appId);
|
||||
resetAppOpPermissionsIfNotRequestedForUid(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user