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

Commit 24f42455 authored by Evan Chen's avatar Evan Chen
Browse files

Catch the IllegalArgumentException if try to disassociate

a non existent associationId.

This also fix a potential race condition when call disassociate API

Test: CtsCompanionDeviceManagerCoreTestCases
Fix: 430453028
Flag: EXEMPT bugfix
Change-Id: I8b9aac7ba8b60bc760eb6438f5dc757037180854
parent a1f819a3
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -113,7 +113,17 @@ public class DisassociationProcessor {
    public void disassociate(int id, String reason) {
        Slog.i(TAG, "Disassociating id=[" + id + "]...");

        final AssociationInfo association = mAssociationStore.getAssociationWithCallerChecks(id);
        final AssociationInfo association;
        try {
            // Attempt to get the association.
            association = mAssociationStore.getAssociationWithCallerChecks(id);
        } catch (IllegalArgumentException e) {
            // The association does not exist. This is NOT an error for disassociation.
            // It means our job is already done. Log it and return successfully.
            Slog.w(TAG, "Association id=" + id + " is already disassociated.");
            return;
        }

        final int userId = association.getUserId();
        final String packageName = association.getPackageName();
        final String deviceProfile = association.getDeviceProfile();