summaryrefslogtreecommitdiffstats
path: root/services/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com')
-rw-r--r--services/java/com/android/server/display/DisplayDeviceInfo.java8
-rw-r--r--services/java/com/android/server/display/DisplayManagerService.java30
-rw-r--r--services/java/com/android/server/display/LocalDisplayAdapter.java1
-rw-r--r--services/java/com/android/server/display/LogicalDisplay.java3
-rw-r--r--services/java/com/android/server/display/OverlayDisplayAdapter.java2
-rw-r--r--services/java/com/android/server/display/VirtualDisplayAdapter.java26
-rw-r--r--services/java/com/android/server/display/WifiDisplayAdapter.java2
7 files changed, 59 insertions, 13 deletions
diff --git a/services/java/com/android/server/display/DisplayDeviceInfo.java b/services/java/com/android/server/display/DisplayDeviceInfo.java
index 11f8d6a..11c5d87 100644
--- a/services/java/com/android/server/display/DisplayDeviceInfo.java
+++ b/services/java/com/android/server/display/DisplayDeviceInfo.java
@@ -73,6 +73,11 @@ final class DisplayDeviceInfo {
public static final int FLAG_NEVER_BLANK = 1 << 5;
/**
+ * Flag: Indicates that the display is suitable for presentations.
+ */
+ public static final int FLAG_PRESENTATION = 1 << 6;
+
+ /**
* Touch attachment: Display does not receive touch.
*/
public static final int TOUCH_NONE = 0;
@@ -289,6 +294,9 @@ final class DisplayDeviceInfo {
if ((flags & FLAG_NEVER_BLANK) != 0) {
msg.append(", FLAG_NEVER_BLANK");
}
+ if ((flags & FLAG_PRESENTATION) != 0) {
+ msg.append(", FLAG_PRESENTATION");
+ }
return msg.toString();
}
}
diff --git a/services/java/com/android/server/display/DisplayManagerService.java b/services/java/com/android/server/display/DisplayManagerService.java
index c339c26..19a11c0 100644
--- a/services/java/com/android/server/display/DisplayManagerService.java
+++ b/services/java/com/android/server/display/DisplayManagerService.java
@@ -21,6 +21,7 @@ import com.android.internal.util.IndentingPrintWriter;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManagerGlobal;
import android.hardware.display.IDisplayManager;
import android.hardware.display.IDisplayManagerCallback;
@@ -589,8 +590,8 @@ public final class DisplayManagerService extends IDisplayManager.Stub {
}
@Override // Binder call
- public int createPrivateVirtualDisplay(IBinder appToken, String packageName,
- String name, int width, int height, int densityDpi, Surface surface) {
+ public int createVirtualDisplay(IBinder appToken, String packageName,
+ String name, int width, int height, int densityDpi, Surface surface, int flags) {
final int callingUid = Binder.getCallingUid();
if (!validatePackageName(callingUid, packageName)) {
throw new SecurityException("packageName must match the calling uid");
@@ -608,6 +609,25 @@ public final class DisplayManagerService extends IDisplayManager.Stub {
if (surface == null) {
throw new IllegalArgumentException("surface must not be null");
}
+ if ((flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC) != 0) {
+ if (mContext.checkCallingPermission(android.Manifest.permission.CAPTURE_VIDEO_OUTPUT)
+ != PackageManager.PERMISSION_GRANTED
+ && mContext.checkCallingPermission(
+ android.Manifest.permission.CAPTURE_SECURE_VIDEO_OUTPUT)
+ != PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Requires CAPTURE_VIDEO_OUTPUT or "
+ + "CAPTURE_SECURE_VIDEO_OUTPUT permission to create a "
+ + "public virtual display.");
+ }
+ }
+ if ((flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE) != 0) {
+ if (mContext.checkCallingPermission(
+ android.Manifest.permission.CAPTURE_SECURE_VIDEO_OUTPUT)
+ != PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Requires CAPTURE_SECURE_VIDEO_OUTPUT "
+ + "to create a secure virtual display.");
+ }
+ }
final long token = Binder.clearCallingIdentity();
try {
@@ -618,9 +638,9 @@ public final class DisplayManagerService extends IDisplayManager.Stub {
return -1;
}
- DisplayDevice device = mVirtualDisplayAdapter.createPrivateVirtualDisplayLocked(
+ DisplayDevice device = mVirtualDisplayAdapter.createVirtualDisplayLocked(
appToken, callingUid, packageName, name, width, height, densityDpi,
- surface);
+ surface, flags);
if (device == null) {
return -1;
}
@@ -632,7 +652,7 @@ public final class DisplayManagerService extends IDisplayManager.Stub {
}
// Something weird happened and the logical display was not created.
- Slog.w(TAG, "Rejecting request to create private virtual display "
+ Slog.w(TAG, "Rejecting request to create virtual display "
+ "because the logical display was not created.");
mVirtualDisplayAdapter.releaseVirtualDisplayLocked(appToken);
handleDisplayDeviceRemovedLocked(device);
diff --git a/services/java/com/android/server/display/LocalDisplayAdapter.java b/services/java/com/android/server/display/LocalDisplayAdapter.java
index 475f27b..cb8f3e2 100644
--- a/services/java/com/android/server/display/LocalDisplayAdapter.java
+++ b/services/java/com/android/server/display/LocalDisplayAdapter.java
@@ -155,6 +155,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
mInfo.touch = DisplayDeviceInfo.TOUCH_INTERNAL;
} else {
mInfo.type = Display.TYPE_HDMI;
+ mInfo.flags |= DisplayDeviceInfo.FLAG_PRESENTATION;
mInfo.name = getContext().getResources().getString(
com.android.internal.R.string.display_manager_hdmi_display_name);
mInfo.touch = DisplayDeviceInfo.TOUCH_EXTERNAL;
diff --git a/services/java/com/android/server/display/LogicalDisplay.java b/services/java/com/android/server/display/LogicalDisplay.java
index 775ebb2..b9839c2 100644
--- a/services/java/com/android/server/display/LogicalDisplay.java
+++ b/services/java/com/android/server/display/LogicalDisplay.java
@@ -205,6 +205,9 @@ final class LogicalDisplay {
if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_PRIVATE) != 0) {
mBaseDisplayInfo.flags |= Display.FLAG_PRIVATE;
}
+ if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_PRESENTATION) != 0) {
+ mBaseDisplayInfo.flags |= Display.FLAG_PRESENTATION;
+ }
mBaseDisplayInfo.type = deviceInfo.type;
mBaseDisplayInfo.address = deviceInfo.address;
mBaseDisplayInfo.name = deviceInfo.name;
diff --git a/services/java/com/android/server/display/OverlayDisplayAdapter.java b/services/java/com/android/server/display/OverlayDisplayAdapter.java
index 3152897..ce402a5 100644
--- a/services/java/com/android/server/display/OverlayDisplayAdapter.java
+++ b/services/java/com/android/server/display/OverlayDisplayAdapter.java
@@ -245,7 +245,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
mInfo.densityDpi = mDensityDpi;
mInfo.xDpi = mDensityDpi;
mInfo.yDpi = mDensityDpi;
- mInfo.flags = 0;
+ mInfo.flags = DisplayDeviceInfo.FLAG_PRESENTATION;
if (mSecure) {
mInfo.flags |= DisplayDeviceInfo.FLAG_SECURE;
}
diff --git a/services/java/com/android/server/display/VirtualDisplayAdapter.java b/services/java/com/android/server/display/VirtualDisplayAdapter.java
index 634fba7..3a71361 100644
--- a/services/java/com/android/server/display/VirtualDisplayAdapter.java
+++ b/services/java/com/android/server/display/VirtualDisplayAdapter.java
@@ -17,6 +17,7 @@
package com.android.server.display;
import android.content.Context;
+import android.hardware.display.DisplayManager;
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder.DeathRecipient;
@@ -46,12 +47,13 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
super(syncRoot, context, handler, listener, TAG);
}
- public DisplayDevice createPrivateVirtualDisplayLocked(IBinder appToken,
+ public DisplayDevice createVirtualDisplayLocked(IBinder appToken,
int ownerUid, String ownerPackageName,
- String name, int width, int height, int densityDpi, Surface surface) {
- IBinder displayToken = SurfaceControl.createDisplay(name, false /*secure*/);
+ String name, int width, int height, int densityDpi, Surface surface, int flags) {
+ boolean secure = (flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE) != 0;
+ IBinder displayToken = SurfaceControl.createDisplay(name, secure);
VirtualDisplayDevice device = new VirtualDisplayDevice(displayToken, appToken,
- ownerUid, ownerPackageName, name, width, height, densityDpi, surface);
+ ownerUid, ownerPackageName, name, width, height, densityDpi, surface, flags);
try {
appToken.linkToDeath(device, 0);
@@ -96,6 +98,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
private final int mWidth;
private final int mHeight;
private final int mDensityDpi;
+ private final int mFlags;
private boolean mReleased;
private Surface mSurface;
@@ -103,7 +106,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
public VirtualDisplayDevice(IBinder displayToken,
IBinder appToken, int ownerUid, String ownerPackageName,
- String name, int width, int height, int densityDpi, Surface surface) {
+ String name, int width, int height, int densityDpi, Surface surface, int flags) {
super(VirtualDisplayAdapter.this, displayToken);
mAppToken = appToken;
mOwnerUid = ownerUid;
@@ -113,6 +116,7 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
mHeight = height;
mDensityDpi = densityDpi;
mSurface = surface;
+ mFlags = flags;
}
@Override
@@ -149,7 +153,17 @@ final class VirtualDisplayAdapter extends DisplayAdapter {
mInfo.densityDpi = mDensityDpi;
mInfo.xDpi = mDensityDpi;
mInfo.yDpi = mDensityDpi;
- mInfo.flags = DisplayDeviceInfo.FLAG_PRIVATE | DisplayDeviceInfo.FLAG_NEVER_BLANK;
+ mInfo.flags = 0;
+ if ((mFlags & DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC) == 0) {
+ mInfo.flags |= DisplayDeviceInfo.FLAG_PRIVATE |
+ DisplayDeviceInfo.FLAG_NEVER_BLANK;
+ }
+ if ((mFlags & DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE) != 0) {
+ mInfo.flags |= DisplayDeviceInfo.FLAG_SECURE;
+ }
+ if ((mFlags & DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION) != 0) {
+ mInfo.flags |= DisplayDeviceInfo.FLAG_PRESENTATION;
+ }
mInfo.type = Display.TYPE_VIRTUAL;
mInfo.touch = DisplayDeviceInfo.TOUCH_NONE;
mInfo.ownerUid = mOwnerUid;
diff --git a/services/java/com/android/server/display/WifiDisplayAdapter.java b/services/java/com/android/server/display/WifiDisplayAdapter.java
index 4c80cf5..11d3819 100644
--- a/services/java/com/android/server/display/WifiDisplayAdapter.java
+++ b/services/java/com/android/server/display/WifiDisplayAdapter.java
@@ -352,7 +352,7 @@ final class WifiDisplayAdapter extends DisplayAdapter {
}
boolean secure = (flags & RemoteDisplay.DISPLAY_FLAG_SECURE) != 0;
- int deviceFlags = 0;
+ int deviceFlags = DisplayDeviceInfo.FLAG_PRESENTATION;
if (secure) {
deviceFlags |= DisplayDeviceInfo.FLAG_SECURE;
if (mSupportsProtectedBuffers) {