summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/display/DisplayManagerService.java
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2013-08-02 19:03:49 -0700
committerJeff Brown <jeffbrown@google.com>2013-08-02 21:11:07 -0700
commit7d00affce6e25b22fd8fc135933b3bf6b547a0dc (patch)
tree6ceb674184170a62dd93d7b3508f11ed1830349e /services/java/com/android/server/display/DisplayManagerService.java
parent040f44d0ebdd3a50c59ba0cbc0b023fd2d71039d (diff)
Support public virtual displays.
Refactor the new private virtual display API to also support creating public virtual displays with various characteristics. This feature requires special permissions and is only intended for use by the system. Change-Id: I44dd19f37cf76ea6d6e313afe42f4a412bd96663
Diffstat (limited to 'services/java/com/android/server/display/DisplayManagerService.java')
-rw-r--r--services/java/com/android/server/display/DisplayManagerService.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/services/java/com/android/server/display/DisplayManagerService.java b/services/java/com/android/server/display/DisplayManagerService.java
index c339c26e51e5..19a11c0f4071 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);