Merge "Unhide VDM APIs"
This commit is contained in:
@@ -2604,10 +2604,32 @@ package android.companion {
|
||||
package android.companion.virtual {
|
||||
|
||||
public final class VirtualDeviceManager {
|
||||
method @Nullable @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.companion.virtual.VirtualDeviceManager.VirtualDevice createVirtualDevice(int, @NonNull android.companion.virtual.VirtualDeviceParams);
|
||||
}
|
||||
|
||||
public static class VirtualDeviceManager.VirtualDevice implements java.lang.AutoCloseable {
|
||||
method public void close();
|
||||
method @Nullable public android.hardware.display.VirtualDisplay createVirtualDisplay(int, int, int, @Nullable android.view.Surface, int, @Nullable android.os.Handler, @Nullable android.hardware.display.VirtualDisplay.Callback);
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualKeyboard createVirtualKeyboard(@NonNull android.hardware.display.VirtualDisplay, @NonNull String, int, int);
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualMouse createVirtualMouse(@NonNull android.hardware.display.VirtualDisplay, @NonNull String, int, int);
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE) public android.hardware.input.VirtualTouchscreen createVirtualTouchscreen(@NonNull android.hardware.display.VirtualDisplay, @NonNull String, int, int);
|
||||
}
|
||||
|
||||
public final class VirtualDeviceParams implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public int getLockState();
|
||||
method @NonNull public java.util.Set<android.os.UserHandle> getUsersWithMatchingAccounts();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.companion.virtual.VirtualDeviceParams> CREATOR;
|
||||
field public static final int LOCK_STATE_ALWAYS_LOCKED = 0; // 0x0
|
||||
field public static final int LOCK_STATE_ALWAYS_UNLOCKED = 1; // 0x1
|
||||
}
|
||||
|
||||
public static final class VirtualDeviceParams.Builder {
|
||||
ctor public VirtualDeviceParams.Builder();
|
||||
method @NonNull public android.companion.virtual.VirtualDeviceParams build();
|
||||
method @NonNull @RequiresPermission(value="android.permission.ADD_ALWAYS_UNLOCKED_DISPLAY", conditional=true) public android.companion.virtual.VirtualDeviceParams.Builder setLockState(int);
|
||||
method @NonNull public android.companion.virtual.VirtualDeviceParams.Builder setUsersWithMatchingAccounts(@NonNull java.util.Set<android.os.UserHandle>);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3661,6 +3683,7 @@ package android.hardware.display {
|
||||
method @RequiresPermission(android.Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS) public void setBrightnessConfiguration(android.hardware.display.BrightnessConfiguration);
|
||||
method @RequiresPermission(android.Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS) public void setBrightnessConfigurationForDisplay(@NonNull android.hardware.display.BrightnessConfiguration, @NonNull String);
|
||||
method @Deprecated @RequiresPermission(android.Manifest.permission.CONTROL_DISPLAY_SATURATION) public void setSaturationLevel(float);
|
||||
field public static final int VIRTUAL_DISPLAY_FLAG_TRUSTED = 1024; // 0x400
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package android.companion.virtual;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.RequiresPermission;
|
||||
@@ -43,10 +42,6 @@ import android.os.RemoteException;
|
||||
import android.os.ResultReceiver;
|
||||
import android.view.Surface;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
@@ -61,23 +56,6 @@ public final class VirtualDeviceManager {
|
||||
private static final boolean DEBUG = false;
|
||||
private static final String LOG_TAG = "VirtualDeviceManager";
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = "DISPLAY_FLAG_",
|
||||
flag = true,
|
||||
value = {DISPLAY_FLAG_TRUSTED})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
|
||||
public @interface DisplayFlags {}
|
||||
|
||||
/**
|
||||
* Indicates that the display is trusted to show system decorations and receive inputs without
|
||||
* users' touch.
|
||||
*
|
||||
* @see DisplayManager#VIRTUAL_DISPLAY_FLAG_TRUSTED
|
||||
* @hide // TODO(b/194949534): Unhide this API
|
||||
*/
|
||||
public static final int DISPLAY_FLAG_TRUSTED = 1;
|
||||
|
||||
private static final int DEFAULT_VIRTUAL_DISPLAY_FLAGS =
|
||||
DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC
|
||||
| DisplayManager.VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT
|
||||
@@ -102,12 +80,12 @@ public final class VirtualDeviceManager {
|
||||
* @param associationId The association ID as returned by {@link AssociationInfo#getId()} from
|
||||
* Companion Device Manager. Virtual devices must have a corresponding association with CDM in
|
||||
* order to be created.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
|
||||
@Nullable
|
||||
public VirtualDevice createVirtualDevice(int associationId, VirtualDeviceParams params) {
|
||||
// TODO(b/194949534): Unhide this API
|
||||
public VirtualDevice createVirtualDevice(
|
||||
int associationId,
|
||||
@NonNull VirtualDeviceParams params) {
|
||||
try {
|
||||
IVirtualDevice virtualDevice = mService.createVirtualDevice(
|
||||
new Binder(), mContext.getPackageName(), associationId, params);
|
||||
@@ -187,7 +165,12 @@ public final class VirtualDeviceManager {
|
||||
* @param surface The surface to which the content of the virtual display should
|
||||
* be rendered, or null if there is none initially. The surface can also be set later using
|
||||
* {@link VirtualDisplay#setSurface(Surface)}.
|
||||
* @param flags Either 0, or {@link #DISPLAY_FLAG_TRUSTED}.
|
||||
* @param flags A combination of virtual display flags accepted by
|
||||
* {@link DisplayManager#createVirtualDisplay}. In addition, the following flags are
|
||||
* automatically set for all virtual devices:
|
||||
* {@link DisplayManager#VIRTUAL_DISPLAY_FLAG_PUBLIC VIRTUAL_DISPLAY_FLAG_PUBLIC} and
|
||||
* {@link DisplayManager#VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY
|
||||
* VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY}.
|
||||
* @param callback Callback to call when the state of the {@link VirtualDisplay} changes
|
||||
* @param handler The handler on which the listener should be invoked, or null
|
||||
* if the listener should be invoked on the calling thread's looper.
|
||||
@@ -195,9 +178,7 @@ public final class VirtualDeviceManager {
|
||||
* not create the virtual display.
|
||||
*
|
||||
* @see DisplayManager#createVirtualDisplay
|
||||
* @hide
|
||||
*/
|
||||
// TODO(b/194949534): Unhide this API
|
||||
// Suppress "ExecutorRegistration" because DisplayManager.createVirtualDisplay takes a
|
||||
// handler
|
||||
@SuppressLint("ExecutorRegistration")
|
||||
@@ -207,7 +188,7 @@ public final class VirtualDeviceManager {
|
||||
int height,
|
||||
int densityDpi,
|
||||
@Nullable Surface surface,
|
||||
@DisplayFlags int flags,
|
||||
int flags,
|
||||
@Nullable Handler handler,
|
||||
@Nullable VirtualDisplay.Callback callback) {
|
||||
// TODO(b/205343547): Handle display groups properly instead of creating a new display
|
||||
@@ -246,7 +227,6 @@ public final class VirtualDeviceManager {
|
||||
* @param inputDeviceName the name to call this input device
|
||||
* @param vendorId the vendor id
|
||||
* @param productId the product id
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
|
||||
@NonNull
|
||||
@@ -273,7 +253,6 @@ public final class VirtualDeviceManager {
|
||||
* @param inputDeviceName the name to call this input device
|
||||
* @param vendorId the vendor id
|
||||
* @param productId the product id
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
|
||||
@NonNull
|
||||
@@ -300,7 +279,6 @@ public final class VirtualDeviceManager {
|
||||
* @param inputDeviceName the name to call this input device
|
||||
* @param vendorId the vendor id
|
||||
* @param productId the product id
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.CREATE_VIRTUAL_DEVICE)
|
||||
@NonNull
|
||||
@@ -328,12 +306,8 @@ public final class VirtualDeviceManager {
|
||||
* com.android.server.companion.virtual.VirtualDeviceImpl#getBaseVirtualDisplayFlags()} will
|
||||
* be added by DisplayManagerService.
|
||||
*/
|
||||
private int getVirtualDisplayFlags(@DisplayFlags int flags) {
|
||||
int virtualDisplayFlags = DEFAULT_VIRTUAL_DISPLAY_FLAGS;
|
||||
if ((flags & DISPLAY_FLAG_TRUSTED) != 0) {
|
||||
virtualDisplayFlags |= DisplayManager.VIRTUAL_DISPLAY_FLAG_TRUSTED;
|
||||
}
|
||||
return virtualDisplayFlags;
|
||||
private int getVirtualDisplayFlags(int flags) {
|
||||
return DEFAULT_VIRTUAL_DISPLAY_FLAGS | flags;
|
||||
}
|
||||
|
||||
private String getVirtualDisplayName() {
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SystemApi;
|
||||
import android.content.ComponentName;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -41,7 +42,7 @@ import java.util.Set;
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
// TODO(b/194949534): Unhide this API
|
||||
@SystemApi
|
||||
public final class VirtualDeviceParams implements Parcelable {
|
||||
|
||||
/** @hide */
|
||||
@@ -53,15 +54,11 @@ public final class VirtualDeviceParams implements Parcelable {
|
||||
|
||||
/**
|
||||
* Indicates that the lock state of the virtual device should be always locked.
|
||||
*
|
||||
* @hide // TODO(b/194949534): Unhide this API
|
||||
*/
|
||||
public static final int LOCK_STATE_ALWAYS_LOCKED = 0;
|
||||
|
||||
/**
|
||||
* Indicates that the lock state of the virtual device should be always unlocked.
|
||||
*
|
||||
* @hide // TODO(b/194949534): Unhide this API
|
||||
*/
|
||||
public static final int LOCK_STATE_ALWAYS_UNLOCKED = 1;
|
||||
|
||||
@@ -112,6 +109,7 @@ public final class VirtualDeviceParams implements Parcelable {
|
||||
* Returns the set of activities allowed to be streamed, or {@code null} if this is not set.
|
||||
*
|
||||
* @see Builder#setAllowedActivities(Set)
|
||||
* @hide // TODO(b/194949534): Unhide this API
|
||||
*/
|
||||
@Nullable
|
||||
public Set<ComponentName> getAllowedActivities() {
|
||||
@@ -126,6 +124,7 @@ public final class VirtualDeviceParams implements Parcelable {
|
||||
* set.
|
||||
*
|
||||
* @see Builder#setBlockedActivities(Set)
|
||||
* @hide // TODO(b/194949534): Unhide this API
|
||||
*/
|
||||
@Nullable
|
||||
public Set<ComponentName> getBlockedActivities() {
|
||||
@@ -169,6 +168,7 @@ public final class VirtualDeviceParams implements Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public String toString() {
|
||||
return "VirtualDeviceParams("
|
||||
+ " mLockState=" + mLockState
|
||||
@@ -178,6 +178,7 @@ public final class VirtualDeviceParams implements Parcelable {
|
||||
+ ")";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static final Parcelable.Creator<VirtualDeviceParams> CREATOR =
|
||||
new Parcelable.Creator<VirtualDeviceParams>() {
|
||||
public VirtualDeviceParams createFromParcel(Parcel in) {
|
||||
@@ -216,13 +217,25 @@ public final class VirtualDeviceParams implements Parcelable {
|
||||
|
||||
/**
|
||||
* Sets the user handles with matching managed accounts on the remote device to which
|
||||
* this virtual device is streaming.
|
||||
* this virtual device is streaming. The caller is responsible for verifying the presence
|
||||
* and legitimacy of a matching managed account on the remote device.
|
||||
*
|
||||
* <p>If the app streaming policy is
|
||||
* {@link android.app.admin.DevicePolicyManager#NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY
|
||||
* NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY}, activities not in
|
||||
* {@code usersWithMatchingAccounts} will be blocked from starting.
|
||||
*
|
||||
* <p> If {@code usersWithMatchingAccounts} is empty (the default), streaming is allowed
|
||||
* only if there is no device policy, or if the nearby streaming policy is
|
||||
* {@link android.app.admin.DevicePolicyManager#NEARBY_STREAMING_ENABLED
|
||||
* NEARBY_STREAMING_ENABLED}.
|
||||
*
|
||||
* @param usersWithMatchingAccounts A set of user handles with matching managed
|
||||
* accounts on the remote device this is streaming to.
|
||||
*
|
||||
* @see android.app.admin.DevicePolicyManager#NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setUsersWithMatchingAccounts(
|
||||
@NonNull Set<UserHandle> usersWithMatchingAccounts) {
|
||||
mUsersWithMatchingAccounts = usersWithMatchingAccounts;
|
||||
@@ -242,6 +255,7 @@ public final class VirtualDeviceParams implements Parcelable {
|
||||
*
|
||||
* @param allowedActivities A set of activity {@link ComponentName} allowed to be launched
|
||||
* in the virtual device.
|
||||
* @hide // TODO(b/194949534): Unhide this API
|
||||
*/
|
||||
public Builder setAllowedActivities(@Nullable Set<ComponentName> allowedActivities) {
|
||||
if (mBlockedActivities != null && allowedActivities != null) {
|
||||
@@ -265,6 +279,7 @@ public final class VirtualDeviceParams implements Parcelable {
|
||||
*
|
||||
* @param blockedActivities A set of {@link ComponentName} to be blocked launching from
|
||||
* virtual device.
|
||||
* @hide // TODO(b/194949534): Unhide this API
|
||||
*/
|
||||
public Builder setBlockedActivities(@Nullable Set<ComponentName> blockedActivities) {
|
||||
if (mAllowedActivities != null && blockedActivities != null) {
|
||||
|
||||
@@ -334,6 +334,7 @@ public final class DisplayManager {
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@SystemApi
|
||||
public static final int VIRTUAL_DISPLAY_FLAG_TRUSTED = 1 << 10;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user