Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 667c3bc4 authored by Evan Chen's avatar Evan Chen Committed by Android (Google) Code Review
Browse files

Merge "Make sure to disassociate all the packages with shared UID" into udc-qpr-dev

parents 44e94c11 371a65e5
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@ public class CompanionDeviceManagerService extends SystemService {
    private final IAppOpsService mAppOpsManager;
    private final PowerWhitelistManager mPowerWhitelistManager;
    private final UserManager mUserManager;
    private final PackageManager mPackageManager;
    final PackageManagerInternal mPackageManagerInternal;

    /**
@@ -221,6 +222,7 @@ public class CompanionDeviceManagerService extends SystemService {
        mAtmInternal = LocalServices.getService(ActivityTaskManagerInternal.class);
        mAmInternal = LocalServices.getService(ActivityManagerInternal.class);
        mPackageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
        mPackageManager = context.getPackageManager();
        mUserManager = context.getSystemService(UserManager.class);

        mUserPersistenceHandler = new PersistUserStateHandler();
@@ -1589,8 +1591,10 @@ public class CompanionDeviceManagerService extends SystemService {
                return;
            }

            final String packageName = getPackageNameByUid(uid);
            if (packageName == null) {
            // A UID can be shared by multiple packages if android:sharedUserId is used.
            // We must get all packages for the UID to ensure we find the correct one.
            final String[] packageNames = mPackageManager.getPackagesForUid(uid);
            if (packageNames == null || packageNames.length == 0) {
                // Not interested in this uid.
                return;
            }
@@ -1599,6 +1603,7 @@ public class CompanionDeviceManagerService extends SystemService {

            boolean needToPersistStateForUser = false;

            for (String packageName : packageNames) {
                for (AssociationInfo association :
                        getPendingRoleHolderRemovalAssociationsForUser(userId)) {
                    if (!packageName.equals(association.getPackageName())) continue;
@@ -1611,6 +1616,7 @@ public class CompanionDeviceManagerService extends SystemService {
                    removeFromPendingRoleHolderRemoval(association);
                    needToPersistStateForUser = true;
                }
            }

            if (needToPersistStateForUser) {
                mUserPersistenceHandler.postPersistUserState(userId);