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

Commit 82ec66f8 authored by [D's avatar [D[1;5D
Browse files

VDM API for per-display UI Mode

Bug: 434903682
Test: CTS
Flag: android.companion.virtualdevice.flags.device_aware_ui_mode

Change-Id: I0ffd7aa4d1114ee1be9959214b9023531aff2508
parent 40ae3f5a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3638,6 +3638,7 @@ package android.companion.virtual {
    method public void setDevicePolicy(int, int);
    method @FlaggedApi("android.companion.virtualdevice.flags.activity_control_api") public void setDevicePolicy(int, int, int);
    method public void setDisplayImePolicy(int, int);
    method @FlaggedApi("android.companion.virtualdevice.flags.device_aware_ui_mode") public void setDisplayUiMode(int, int);
    method public void setShowPointerIcon(boolean);
    method public void unregisterIntentInterceptor(@NonNull android.companion.virtual.VirtualDeviceManager.IntentInterceptorCallback);
    method @FlaggedApi("android.companion.virtualdevice.flags.device_aware_display_power") public void wakeUp();
+3 −0
Original line number Diff line number Diff line
@@ -206,6 +206,9 @@ interface IVirtualDevice {
    /** Sets an IME policy for the given display. */
    void setDisplayImePolicy(int displayId, int policy);

    /** Sets the UI mode for the given display. */
    void setDisplayUiMode(int displayId, int uiMode);

    /**
     * Registers an intent interceptor that will intercept an intent attempting to launch
     * when matching the provided IntentFilter and calls the callback with the intercepted
+7 −0
Original line number Diff line number Diff line
@@ -519,6 +519,13 @@ public class VirtualDeviceInternal {
        }
    }

    void setDisplayUiMode(int displayId, int uiMode) {
        try {
            mVirtualDevice.setDisplayUiMode(displayId, uiMode);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    void addActivityListener(
            @CallbackExecutor @NonNull Executor executor,
            @NonNull VirtualDeviceManager.ActivityListener listener) {
+28 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.res.Configuration;
import android.graphics.Point;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
@@ -1135,6 +1136,33 @@ public final class VirtualDeviceManager {
            mVirtualDeviceInternal.setDisplayImePolicy(displayId, policy);
        }

        /**
         * Specifies the UI mode on the given display.
         *
         * <p>By default, all displays created by virtual devices have
         * {@link Configuration#UI_MODE_TYPE_UNDEFINED} and
         * {@link Configuration#UI_MODE_NIGHT_UNDEFINED}, meaning that they follow the global UI
         * mode type and night mode. These constants can also be used to unset a previously set
         * UI mode.</p>
         *
         * @param displayId the ID of the display to change the UI mode for. It must be a trusted
         *   non-mirror display, owned by this virtual device.
         * @param uiMode the UI mode to use on that display, a combination of the UI mode type
         *   given by the {@link Configuration#UI_MODE_TYPE_MASK} bits, and the night mode given by
         *   the {@link Configuration#UI_MODE_NIGHT_MASK} bits.
         * @throws SecurityException if the display is not owned by this device, is not
         *   {@link DisplayManager#VIRTUAL_DISPLAY_FLAG_TRUSTED trusted}, or is a
         *   {@link DisplayManager#VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR mirror} display.
         * @see Configuration#uiMode
         */
        @FlaggedApi(Flags.FLAG_DEVICE_AWARE_UI_MODE)
        public void setDisplayUiMode(int displayId, int uiMode) {
            if (!Flags.deviceAwareUiMode()) {
                throw new UnsupportedOperationException("Required flag is not enabled");
            }
            mVirtualDeviceInternal.setDisplayUiMode(displayId, uiMode);
        }

        /**
         * Adds an activity listener to listen for events such as top activity change or virtual
         * display task stack became empty.
+7 −0
Original line number Diff line number Diff line
@@ -212,6 +212,13 @@ flag {
    }
}

flag {
    name: "device_aware_ui_mode"
    namespace: "virtual_devices"
    description: "Device and display awareness for UiModeManager"
    bug: "340667076"
}

flag {
    name: "fix_vdm_opt_out_on_mirror_displays"
    namespace: "virtual_devices"
Loading