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

Commit 846e9cfd authored by Marco Loaiza's avatar Marco Loaiza Committed by Automerger Merge Worker
Browse files

Merge "Revert^2 "Move DEVICE_ID_DEFAULT from VDM to Context"" into udc-dev am: f0629193

parents 9cc771fd f0629193
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -9574,8 +9574,6 @@ package android.companion.virtual {
  public final class VirtualDeviceManager {
    method @NonNull public java.util.List<android.companion.virtual.VirtualDevice> getVirtualDevices();
    field public static final int DEVICE_ID_DEFAULT = 0; // 0x0
    field public static final int DEVICE_ID_INVALID = -1; // 0xffffffff
  }
}
@@ -10352,6 +10350,8 @@ package android.content {
    field public static final int CONTEXT_RESTRICTED = 4; // 0x4
    field public static final String CREDENTIAL_SERVICE = "credential";
    field public static final String CROSS_PROFILE_APPS_SERVICE = "crossprofileapps";
    field public static final int DEVICE_ID_DEFAULT = 0; // 0x0
    field public static final int DEVICE_ID_INVALID = -1; // 0xffffffff
    field public static final String DEVICE_LOCK_SERVICE = "device_lock";
    field public static final String DEVICE_POLICY_SERVICE = "device_policy";
    field public static final String DISPLAY_HASH_SERVICE = "display_hash";
+2 −2
Original line number Diff line number Diff line
@@ -4621,7 +4621,7 @@ public final class ActivityThread extends ClientTransactionHandler
                    ActivityManager.getService());
            if (!service.isUiContext()) { // WindowProviderService is a UI Context.
                VirtualDeviceManager vdm = context.getSystemService(VirtualDeviceManager.class);
                if (mLastReportedDeviceId == VirtualDeviceManager.DEVICE_ID_DEFAULT
                if (mLastReportedDeviceId == Context.DEVICE_ID_DEFAULT
                        || vdm.isValidVirtualDeviceId(mLastReportedDeviceId)) {
                    service.updateDeviceId(mLastReportedDeviceId);
                }
@@ -6149,7 +6149,7 @@ public final class ActivityThread extends ClientTransactionHandler

    private void updateDeviceIdForNonUIContexts(int deviceId) {
        // Invalid device id is treated as a no-op.
        if (deviceId == VirtualDeviceManager.DEVICE_ID_INVALID) {
        if (deviceId == Context.DEVICE_ID_INVALID) {
            return;
        }
        if (deviceId == mLastReportedDeviceId) {
+3 −3
Original line number Diff line number Diff line
@@ -245,7 +245,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.DEVICE_ID_DEFAULT;
    private int mDeviceId = Context.DEVICE_ID_DEFAULT;

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

    @Override
    public @NonNull Context createDeviceContext(int deviceId) {
        if (deviceId != VirtualDeviceManager.DEVICE_ID_DEFAULT) {
        if (deviceId != Context.DEVICE_ID_DEFAULT) {
            VirtualDeviceManager vdm = getSystemService(VirtualDeviceManager.class);
            if (!vdm.isValidVirtualDeviceId(deviceId)) {
                throw new IllegalArgumentException(
@@ -3092,7 +3092,7 @@ class ContextImpl extends Context {

    @Override
    public void updateDeviceId(int updatedDeviceId) {
        if (updatedDeviceId != VirtualDeviceManager.DEVICE_ID_DEFAULT) {
        if (updatedDeviceId != Context.DEVICE_ID_DEFAULT) {
            VirtualDeviceManager vdm = getSystemService(VirtualDeviceManager.class);
            if (!vdm.isValidVirtualDeviceId(updatedDeviceId)) {
                throw new IllegalArgumentException(
+3 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.companion.virtual;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;

@@ -38,9 +39,9 @@ public final class VirtualDevice implements Parcelable {
     * @hide
     */
    public VirtualDevice(int id, @Nullable String name) {
        if (id <= VirtualDeviceManager.DEVICE_ID_DEFAULT) {
        if (id <= Context.DEVICE_ID_DEFAULT) {
            throw new IllegalArgumentException("VirtualDevice ID mist be greater than "
                    + VirtualDeviceManager.DEVICE_ID_DEFAULT);
                    + Context.DEVICE_ID_DEFAULT);
        }
        mId = id;
        mName = name;
+2 −12
Original line number Diff line number Diff line
@@ -97,16 +97,6 @@ public final class VirtualDeviceManager {
                    | DisplayManager.VIRTUAL_DISPLAY_FLAG_SUPPORTS_TOUCH
                    | DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_FOCUS;

    /**
     * The default device ID, which is the ID of the primary (non-virtual) device.
     */
    public static final int DEVICE_ID_DEFAULT = 0;

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

    /**
     * Broadcast Action: A Virtual Device was removed.
     *
@@ -250,7 +240,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 DEVICE_ID_DEFAULT;
            return Context.DEVICE_ID_DEFAULT;
        }
        try {
            return mService.getDeviceIdForDisplayId(displayId);
@@ -261,7 +251,7 @@ public final class VirtualDeviceManager {

    /**
     * Checks whether the passed {@code deviceId} is a valid virtual device ID or not.
     * {@link VirtualDeviceManager#DEVICE_ID_DEFAULT} is not valid as it is the ID of the default
     * {@link Context#DEVICE_ID_DEFAULT} is not valid as it is the ID of the default
     * device which is not a virtual device. {@code deviceId} must correspond to a virtual device
     * created by {@link VirtualDeviceManager#createVirtualDevice(int, VirtualDeviceParams)}.
     *
Loading