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

Commit 8639043e authored by Phill Hayers's avatar Phill Hayers
Browse files

Rename device ID constants.

Updates DEFAULT_DEVICE_ID to DEVICE_ID_DEFAULT and INVALID_DEVICE_ID to
DEVICE_ID_INVALID.

Based on API feedback in b/261607264.

Test: atest
(VirtualDeviceTest|ContextTest|VirtualDeviceManagerServiceTest)
Bug: 261607264

Change-Id: I94c1360b88f252f4bce38f130ad05c17ddc33a15
parent 354c1da5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -9177,8 +9177,8 @@ package android.companion.virtual {
  public final class VirtualDeviceManager {
    method @NonNull public java.util.List<android.companion.virtual.VirtualDevice> getVirtualDevices();
    field public static final int DEFAULT_DEVICE_ID = 0; // 0x0
    field public static final int INVALID_DEVICE_ID = -1; // 0xffffffff
    field public static final int DEVICE_ID_DEFAULT = 0; // 0x0
    field public static final int DEVICE_ID_INVALID = -1; // 0xffffffff
  }
}
+3 −3
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@ class ContextImpl extends Context {
    @UnsupportedAppUsage
    private @NonNull Resources mResources;
    private @Nullable Display mDisplay; // may be null if invalid display or not initialized yet.
    private int mDeviceId = VirtualDeviceManager.DEFAULT_DEVICE_ID;
    private int mDeviceId = VirtualDeviceManager.DEVICE_ID_DEFAULT;

    /**
     * If set to {@code true} the resources for this context will be configured for mDisplay which
@@ -2699,8 +2699,8 @@ class ContextImpl extends Context {

    @Override
    public @NonNull Context createDeviceContext(int deviceId) {
        boolean validDeviceId = deviceId == VirtualDeviceManager.DEFAULT_DEVICE_ID;
        if (deviceId > VirtualDeviceManager.DEFAULT_DEVICE_ID) {
        boolean validDeviceId = deviceId == VirtualDeviceManager.DEVICE_ID_DEFAULT;
        if (deviceId > VirtualDeviceManager.DEVICE_ID_DEFAULT) {
            VirtualDeviceManager vdm = getSystemService(VirtualDeviceManager.class);
            if (vdm != null) {
                List<VirtualDevice> virtualDevices = vdm.getVirtualDevices();
+2 −2
Original line number Diff line number Diff line
@@ -38,9 +38,9 @@ public final class VirtualDevice implements Parcelable {
     * @hide
     */
    public VirtualDevice(int id, @Nullable String name) {
        if (id <= VirtualDeviceManager.DEFAULT_DEVICE_ID) {
        if (id <= VirtualDeviceManager.DEVICE_ID_DEFAULT) {
            throw new IllegalArgumentException("VirtualDevice ID mist be greater than "
                    + VirtualDeviceManager.DEFAULT_DEVICE_ID);
                    + VirtualDeviceManager.DEVICE_ID_DEFAULT);
        }
        mId = id;
        mName = name;
+3 −3
Original line number Diff line number Diff line
@@ -88,12 +88,12 @@ public final class VirtualDeviceManager {
    /**
     * The default device ID, which is the ID of the primary (non-virtual) device.
     */
    public static final int DEFAULT_DEVICE_ID = 0;
    public static final int DEVICE_ID_DEFAULT = 0;

    /**
     * Invalid device ID.
     */
    public static final int INVALID_DEVICE_ID = -1;
    public static final int DEVICE_ID_INVALID = -1;

    /**
     * Broadcast Action: A Virtual Device was removed.
@@ -238,7 +238,7 @@ public final class VirtualDeviceManager {
    public int getDeviceIdForDisplayId(int displayId) {
        if (mService == null) {
            Log.w(TAG, "Failed to retrieve virtual devices; no virtual device manager service.");
            return DEFAULT_DEVICE_ID;
            return DEVICE_ID_DEFAULT;
        }
        try {
            return mService.getDeviceIdForDisplayId(displayId);
+2 −2
Original line number Diff line number Diff line
@@ -6903,7 +6903,7 @@ public abstract class Context {
     * <p>
     * Applications that run on virtual devices may use this method to access the default device
     * capabilities and functionality (by passing
     * {@link android.companion.virtual.VirtualDeviceManager#DEFAULT_DEVICE_ID}. Similarly,
     * {@link android.companion.virtual.VirtualDeviceManager#DEVICE_ID_DEFAULT}. Similarly,
     * applications running on the default device may access the functionality of virtual devices.
     * </p>
     * @param deviceId The ID of the device to associate with this context.
@@ -7245,7 +7245,7 @@ public abstract class Context {
     * determine whether they are running on a virtual device and identify that device.
     *
     * The device ID of the host device is
     * {@link android.companion.virtual.VirtualDeviceManager#DEFAULT_DEVICE_ID}
     * {@link android.companion.virtual.VirtualDeviceManager#DEVICE_ID_DEFAULT}
     *
     * @return the ID of the device this context is associated with.
     * @see #createDeviceContext(int)
Loading