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

Commit 77a4f7e9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use single source of truth for CDM associations" into main

parents 71a769dc cd0d36e2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -529,6 +529,7 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub implements IBinder.Dea
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        Slog.d(TAG, "Creating virtual device with deviceId: " + deviceId);
        mVirtualDeviceLog.logCreated(deviceId, mOwnerUid);

        mPublicVirtualDeviceObject = new VirtualDevice(
@@ -849,6 +850,7 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub implements IBinder.Dea
            return;
        }

        Slog.d(TAG, "Closing virtual device with deviceId: " + mDeviceId);
        mVirtualDeviceLog.logClosed(mDeviceId, mOwnerUid);

        final long ident = Binder.clearCallingIdentity();
@@ -902,6 +904,7 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub implements IBinder.Dea

    @Override
    public void binderDied() {
        Slog.d(TAG, "Binder died, closing virtual device with deviceId: " + mDeviceId);
        close();
    }

+6 −1
Original line number Diff line number Diff line
@@ -238,8 +238,11 @@ public class VirtualDeviceManagerService extends SystemService {
        CompanionDeviceManager cdm = getContext().getSystemService(CompanionDeviceManager.class);
        if (cdm != null) {
            onCdmAssociationsChanged(cdm.getAllAssociations(UserHandle.USER_ALL));
            // The associations received in the callback can provide a stale state so always get
            // the accurate list of associations from the single source of truth
            cdm.addOnAssociationsChangedListener(getContext().getMainExecutor(),
                    this::onCdmAssociationsChanged, UserHandle.USER_ALL);
                    associations -> onCdmAssociationsChanged(
                            cdm.getAllAssociations(UserHandle.USER_ALL)), UserHandle.USER_ALL);
        } else {
            Slog.e(TAG, "Failed to find CompanionDeviceManager. No CDM association info "
                    + " will be available.");
@@ -393,6 +396,8 @@ public class VirtualDeviceManagerService extends SystemService {
        }

        for (VirtualDeviceImpl virtualDevice : virtualDevicesToRemove) {
            Slog.d(TAG, "onCdmAssociationsChanged, removing virtual device with deviceId: "
                    + virtualDevice.getDeviceId());
            virtualDevice.close();
        }