From d744bd18b936c10d72e3362ef61de7d2dc8fe8f4 Mon Sep 17 00:00:00 2001 From: Sandro Meier Date: Mon, 13 Mar 2023 10:18:35 +0000 Subject: [PATCH] Inline getVirtualDisplayName into deprecated API The getVirtualDisplayName is only used in the deprecated virtual display creation API. The new API uses VirtualDisplayConfig where the client can set the name. To make it clear the name as generated is only used in the deprecated API this commit removes the private method and inlines it in the deprecated constructor. Bug: 270334704 Test: VDM Test app, created Virtual display with old and new API Change-Id: I73726b73aef94276d44a830f83ad74fc764bc1fb --- .../virtual/VirtualDeviceManager.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/core/java/android/companion/virtual/VirtualDeviceManager.java b/core/java/android/companion/virtual/VirtualDeviceManager.java index 90681cba7d832..a6ac151630538 100644 --- a/core/java/android/companion/virtual/VirtualDeviceManager.java +++ b/core/java/android/companion/virtual/VirtualDeviceManager.java @@ -545,8 +545,13 @@ public final class VirtualDeviceManager { @VirtualDisplayFlag int flags, @Nullable @CallbackExecutor Executor executor, @Nullable VirtualDisplay.Callback callback) { + // Currently this just use the device ID, which means all of the virtual displays + // created using the same virtual device will have the same name if they use this + // deprecated API. The name should only be used for informational purposes, and not for + // identifying the display in code. + String virtualDisplayName = "VirtualDevice_" + getDeviceId(); VirtualDisplayConfig.Builder builder = new VirtualDisplayConfig.Builder( - getVirtualDisplayName(), width, height, densityDpi) + virtualDisplayName, width, height, densityDpi) .setFlags(flags); if (surface != null) { builder.setSurface(surface); @@ -858,18 +863,6 @@ public final class VirtualDeviceManager { } } - private String getVirtualDisplayName() { - try { - // Currently this just use the device ID, which means all of the virtual displays - // created using the same virtual device will have the same name. The name should - // only be used for informational purposes, and not for identifying the display in - // code. - return "VirtualDevice_" + mVirtualDevice.getDeviceId(); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } - /** * Adds an activity listener to listen for events such as top activity change or virtual * display task stack became empty.