summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/Surface.java
diff options
context:
space:
mode:
authorKevin Hester <khester@google.com>2012-03-08 17:06:56 -0800
committerMike Lockwood <lockwood@google.com>2012-03-22 15:09:40 -0700
commitb85c933d850286874005f97a9764c9b22e49a597 (patch)
treec1428f115166d45c996ee2c7c23f331c770dcfd4 /core/java/android/view/Surface.java
parentdab2072365565b4892be7910b0cdb870e83689f6 (diff)
downloadframeworks_base-b85c933d850286874005f97a9764c9b22e49a597.zip
frameworks_base-b85c933d850286874005f97a9764c9b22e49a597.tar.gz
frameworks_base-b85c933d850286874005f97a9764c9b22e49a597.tar.bz2
Do not allow Surface creation on machines without SurfaceFlinger
We will fail later anyways, but this change makes it much easier to track down places where we are inadvertently doing operations that depend on the flinger. Change-Id: If38a1a10061a594dba5c220a86b32eec7b5ec901
Diffstat (limited to 'core/java/android/view/Surface.java')
-rw-r--r--core/java/android/view/Surface.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index edaa262..eb80290d 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -20,6 +20,7 @@ import android.content.res.CompatibilityInfo.Translator;
import android.graphics.*;
import android.os.Parcelable;
import android.os.Parcel;
+import android.os.SystemProperties;
import android.util.Log;
/**
@@ -35,6 +36,15 @@ public class Surface implements Parcelable {
public static final int ROTATION_180 = 2;
public static final int ROTATION_270 = 3;
+ private static final boolean headless = "1".equals(
+ SystemProperties.get("ro.config.headless", "0"));
+
+ private static void checkHeadless() {
+ if(headless) {
+ throw new UnsupportedOperationException("Device is headless");
+ }
+ }
+
/**
* Create Surface from a {@link SurfaceTexture}.
*
@@ -46,6 +56,8 @@ public class Surface implements Parcelable {
* Surface.
*/
public Surface(SurfaceTexture surfaceTexture) {
+ checkHeadless();
+
if (DEBUG_RELEASE) {
mCreationStack = new Exception();
}
@@ -244,6 +256,8 @@ public class Surface implements Parcelable {
public Surface(SurfaceSession s,
int pid, int display, int w, int h, int format, int flags)
throws OutOfResourcesException {
+ checkHeadless();
+
if (DEBUG_RELEASE) {
mCreationStack = new Exception();
}
@@ -255,6 +269,8 @@ public class Surface implements Parcelable {
public Surface(SurfaceSession s,
int pid, String name, int display, int w, int h, int format, int flags)
throws OutOfResourcesException {
+ checkHeadless();
+
if (DEBUG_RELEASE) {
mCreationStack = new Exception();
}
@@ -269,6 +285,8 @@ public class Surface implements Parcelable {
* @hide
*/
public Surface() {
+ checkHeadless();
+
if (DEBUG_RELEASE) {
mCreationStack = new Exception();
}