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

Commit 7e0a903a authored by Biswarup Pal's avatar Biswarup Pal
Browse files

Show status bar icon during VDM screen mirroring

This change also triggers connected display animation
every time a virtual device owned mirror display is added.

Flag: ACONFIG android.companion.virtual.flags.interactive_screen_mirror DEVELOPMENT
Test: atest SystemUITests
Bug: 292212199
Change-Id: I9bfd7f5e2923f18b963d0e71ed5ad03c687f0d42
parent be39353a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -866,6 +866,14 @@ package android.companion {

}

package android.companion.virtual {

  public final class VirtualDeviceManager {
    method @FlaggedApi("android.companion.virtual.flags.interactive_screen_mirror") public boolean isVirtualDeviceOwnedMirrorDisplay(int);
  }

}

package android.content {

  public final class AttributionSource implements android.os.Parcelable {
+6 −0
Original line number Diff line number Diff line
@@ -122,4 +122,10 @@ interface IVirtualDeviceManager {
     *   {@code android.media.AudioManager.SystemSoundEffect}
     */
    void playSoundEffect(int deviceId, int effectType);

    /**
     * Returns whether the given display is an auto-mirror display owned by a virtual
     * device.
     */
    boolean isVirtualDeviceOwnedMirrorDisplay(int displayId);
}
+20 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UserIdInt;
import android.app.PendingIntent;
import android.companion.AssociationInfo;
@@ -435,6 +436,25 @@ public final class VirtualDeviceManager {
        }
    }

    /**
     * Returns whether the given display is an auto-mirror display owned by a virtual device.
     *
     * @hide
     */
    @FlaggedApi(Flags.FLAG_INTERACTIVE_SCREEN_MIRROR)
    @TestApi
    public boolean isVirtualDeviceOwnedMirrorDisplay(int displayId) {
        if (mService == null) {
            Log.w(TAG, "Failed to retrieve virtual devices; no virtual device manager service.");
            return false;
        }
        try {
            return mService.isVirtualDeviceOwnedMirrorDisplay(displayId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * A representation of a virtual device.
     *
+7 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.app.smartspace.SmartspaceManager;
import android.app.trust.TrustManager;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.companion.virtual.VirtualDeviceManager;
import android.content.ClipboardManager;
import android.content.ContentResolver;
import android.content.Context;
@@ -234,6 +235,12 @@ public class FrameworkServicesModule {
        return context.getSystemService(DisplayManager.class);
    }

    @Provides
    @Singleton
    static VirtualDeviceManager provideVirtualDeviceManager(Context context) {
        return context.getSystemService(VirtualDeviceManager.class);
    }

    @Provides
    @Singleton
    static DeviceStateManager provideDeviceStateManager(Context context) {
+8 −0
Original line number Diff line number Diff line
@@ -56,6 +56,9 @@ interface DisplayRepository {
    /** Display change event indicating a change to the given displayId has occurred. */
    val displayChangeEvent: Flow<Int>

    /** Display addition event indicating a new display has been added. */
    val displayAdditionEvent: Flow<Display?>

    /** Provides the current set of displays. */
    val displays: Flow<Set<Display>>

@@ -126,6 +129,11 @@ constructor(
    override val displayChangeEvent: Flow<Int> =
        allDisplayEvents.filter { it is DisplayEvent.Changed }.map { it.displayId }

    override val displayAdditionEvent: Flow<Display?> =
        allDisplayEvents
            .filter { it is DisplayEvent.Added }
            .map { displayManager.getDisplay(it.displayId) }

    private val enabledDisplays =
        allDisplayEvents
            .map { getDisplays() }
Loading