Loading services/companion/java/com/android/server/companion/virtual/VirtualDeviceManagerService.java +7 −2 Original line number Diff line number Diff line Loading @@ -460,11 +460,11 @@ public class VirtualDeviceManagerService extends SystemService { synchronized (mVirtualDeviceManagerLock) { if (!Flags.persistentDeviceIdApi() && mVirtualDevices.size() == 0) { final long callindId = Binder.clearCallingIdentity(); final long callingId = Binder.clearCallingIdentity(); try { registerCdmAssociationListener(); } finally { Binder.restoreCallingIdentity(callindId); Binder.restoreCallingIdentity(callingId); } } mVirtualDevices.put(deviceId, virtualDevice); Loading Loading @@ -850,6 +850,11 @@ public class VirtualDeviceManagerService extends SystemService { .collect(Collectors.toCollection(ArraySet::new)); } @Override public int getDeviceIdForDisplayId(int displayId) { return mImpl.getDeviceIdForDisplayId(displayId); } @Override public @Nullable String getPersistentIdForDevice(int deviceId) { if (deviceId == Context.DEVICE_ID_DEFAULT) { Loading services/core/java/com/android/server/companion/virtual/VirtualDeviceManagerInternal.java +8 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,14 @@ public abstract class VirtualDeviceManagerInternal { */ public abstract @NonNull ArraySet<Integer> getDisplayIdsForDevice(int deviceId); /** * Returns the ID of the device which owns the display with the given ID. * * <p>In case the virtual display ID is invalid or doesn't belong to a virtual device, then * {@link android.content.Context#DEVICE_ID_DEFAULT} is returned.</p> */ public abstract int getDeviceIdForDisplayId(int displayId); /** * Gets the persistent ID for the VirtualDevice with the given device ID. * Loading services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -413,18 +413,24 @@ public class VirtualDeviceManagerServiceTest { public void getDeviceIdForDisplayId_invalidDisplayId_returnsDefault() { assertThat(mVdm.getDeviceIdForDisplayId(Display.INVALID_DISPLAY)) .isEqualTo(DEVICE_ID_DEFAULT); assertThat(mLocalService.getDeviceIdForDisplayId(Display.INVALID_DISPLAY)) .isEqualTo(DEVICE_ID_DEFAULT); } @Test public void getDeviceIdForDisplayId_defaultDisplayId_returnsDefault() { assertThat(mVdm.getDeviceIdForDisplayId(Display.DEFAULT_DISPLAY)) .isEqualTo(DEVICE_ID_DEFAULT); assertThat(mLocalService.getDeviceIdForDisplayId(Display.DEFAULT_DISPLAY)) .isEqualTo(DEVICE_ID_DEFAULT); } @Test public void getDeviceIdForDisplayId_nonExistentDisplayId_returnsDefault() { assertThat(mVdm.getDeviceIdForDisplayId(NON_EXISTENT_DISPLAY_ID)) .isEqualTo(DEVICE_ID_DEFAULT); assertThat(mLocalService.getDeviceIdForDisplayId(NON_EXISTENT_DISPLAY_ID)) .isEqualTo(DEVICE_ID_DEFAULT); } @Test Loading @@ -433,6 +439,8 @@ public class VirtualDeviceManagerServiceTest { assertThat(mVdm.getDeviceIdForDisplayId(DISPLAY_ID_1)) .isEqualTo(mDeviceImpl.getDeviceId()); assertThat(mLocalService.getDeviceIdForDisplayId(DISPLAY_ID_1)) .isEqualTo(mDeviceImpl.getDeviceId()); } @Test Loading Loading
services/companion/java/com/android/server/companion/virtual/VirtualDeviceManagerService.java +7 −2 Original line number Diff line number Diff line Loading @@ -460,11 +460,11 @@ public class VirtualDeviceManagerService extends SystemService { synchronized (mVirtualDeviceManagerLock) { if (!Flags.persistentDeviceIdApi() && mVirtualDevices.size() == 0) { final long callindId = Binder.clearCallingIdentity(); final long callingId = Binder.clearCallingIdentity(); try { registerCdmAssociationListener(); } finally { Binder.restoreCallingIdentity(callindId); Binder.restoreCallingIdentity(callingId); } } mVirtualDevices.put(deviceId, virtualDevice); Loading Loading @@ -850,6 +850,11 @@ public class VirtualDeviceManagerService extends SystemService { .collect(Collectors.toCollection(ArraySet::new)); } @Override public int getDeviceIdForDisplayId(int displayId) { return mImpl.getDeviceIdForDisplayId(displayId); } @Override public @Nullable String getPersistentIdForDevice(int deviceId) { if (deviceId == Context.DEVICE_ID_DEFAULT) { Loading
services/core/java/com/android/server/companion/virtual/VirtualDeviceManagerInternal.java +8 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,14 @@ public abstract class VirtualDeviceManagerInternal { */ public abstract @NonNull ArraySet<Integer> getDisplayIdsForDevice(int deviceId); /** * Returns the ID of the device which owns the display with the given ID. * * <p>In case the virtual display ID is invalid or doesn't belong to a virtual device, then * {@link android.content.Context#DEVICE_ID_DEFAULT} is returned.</p> */ public abstract int getDeviceIdForDisplayId(int displayId); /** * Gets the persistent ID for the VirtualDevice with the given device ID. * Loading
services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -413,18 +413,24 @@ public class VirtualDeviceManagerServiceTest { public void getDeviceIdForDisplayId_invalidDisplayId_returnsDefault() { assertThat(mVdm.getDeviceIdForDisplayId(Display.INVALID_DISPLAY)) .isEqualTo(DEVICE_ID_DEFAULT); assertThat(mLocalService.getDeviceIdForDisplayId(Display.INVALID_DISPLAY)) .isEqualTo(DEVICE_ID_DEFAULT); } @Test public void getDeviceIdForDisplayId_defaultDisplayId_returnsDefault() { assertThat(mVdm.getDeviceIdForDisplayId(Display.DEFAULT_DISPLAY)) .isEqualTo(DEVICE_ID_DEFAULT); assertThat(mLocalService.getDeviceIdForDisplayId(Display.DEFAULT_DISPLAY)) .isEqualTo(DEVICE_ID_DEFAULT); } @Test public void getDeviceIdForDisplayId_nonExistentDisplayId_returnsDefault() { assertThat(mVdm.getDeviceIdForDisplayId(NON_EXISTENT_DISPLAY_ID)) .isEqualTo(DEVICE_ID_DEFAULT); assertThat(mLocalService.getDeviceIdForDisplayId(NON_EXISTENT_DISPLAY_ID)) .isEqualTo(DEVICE_ID_DEFAULT); } @Test Loading @@ -433,6 +439,8 @@ public class VirtualDeviceManagerServiceTest { assertThat(mVdm.getDeviceIdForDisplayId(DISPLAY_ID_1)) .isEqualTo(mDeviceImpl.getDeviceId()); assertThat(mLocalService.getDeviceIdForDisplayId(DISPLAY_ID_1)) .isEqualTo(mDeviceImpl.getDeviceId()); } @Test Loading