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

Commit 33776132 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 main

parents ccd028ea 69baf67a
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.companion.AssociationInfo;
import android.companion.Flags;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.ResolveInfo;
import android.os.Binder;
@@ -75,6 +76,8 @@ public class DisassociationProcessor {
    @NonNull
    private final PackageManagerInternal mPackageManagerInternal;
    @NonNull
    private final PackageManager mPackageManager;
    @NonNull
    private final DevicePresenceProcessor mDevicePresenceMonitor;
    @NonNull
    private final SystemDataTransferRequestStore mSystemDataTransferRequestStore;
@@ -106,6 +109,7 @@ public class DisassociationProcessor {
        mSystemDataTransferRequestStore = systemDataTransferRequestStore;
        mTransportManager = companionTransportManager;
        mNotificationManager = notificationManager;
        mPackageManager = context.getPackageManager();
    }

    /**
@@ -301,17 +305,21 @@ public class DisassociationProcessor {
                return;
            }

            final String packageName = mPackageManagerInternal.getNameForUid(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;
            }

            int userId = UserHandle.getUserId(uid);
            for (String packageName : packageNames) {
                for (AssociationInfo association : mAssociationStore.getRevokedAssociations(userId,
                        packageName)) {
                    disassociate(association.getId(), REASON_REVOKED);
                }
            }

            if (mAssociationStore.getRevokedAssociations().isEmpty()) {
                stopListening();