summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2013-02-25 15:56:31 -0800
committerMathias Agopian <mathias@google.com>2013-02-25 16:49:57 -0800
commitffddc9b8045235a493ec506965ae4892601eb23d (patch)
treebdff21b92c01acf683b2103d9eed0c2fde95bdc1
parent88a1cf841ef8b5792fad8f3af4b4831101497c6c (diff)
downloadframeworks_base-ffddc9b8045235a493ec506965ae4892601eb23d.zip
frameworks_base-ffddc9b8045235a493ec506965ae4892601eb23d.tar.gz
frameworks_base-ffddc9b8045235a493ec506965ae4892601eb23d.tar.bz2
Fix SurfaceControl.setDisplaySurface() such that it accepts a null Surface
also fix a typo that made us call the wrong Surface ctor Bug: 8225509 Change-Id: I23f92179b6003d4c3e0febb35166c1caeafa27f5
-rw-r--r--core/java/android/view/SurfaceControl.java9
-rw-r--r--core/jni/android_view_Surface.cpp2
-rw-r--r--core/jni/android_view_SurfaceControl.cpp5
3 files changed, 7 insertions, 9 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index 7ef7e2b..ded2f47 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -509,13 +509,8 @@ public class SurfaceControl {
if (displayToken == null) {
throw new IllegalArgumentException("displayToken must not be null");
}
- if (surface == null) {
- throw new IllegalArgumentException("surface must not be null");
- }
- if (surface.mNativeObject == 0)
- throw new NullPointerException("Surface native object is null. Are you using a released surface?");
-
- nativeSetDisplaySurface(displayToken, surface.mNativeObject);
+ int nativeSurface = surface != null ? surface.mNativeObject : 0;
+ nativeSetDisplaySurface(displayToken, nativeSurface);
}
public static IBinder createDisplay(String name, boolean secure) {
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index b4a19f1..02e76e5 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -388,7 +388,7 @@ int register_android_view_Surface(JNIEnv* env)
env->GetFieldID(gSurfaceClassInfo.clazz, "mGenerationId", "I");
gSurfaceClassInfo.mCanvas =
env->GetFieldID(gSurfaceClassInfo.clazz, "mCanvas", "Landroid/graphics/Canvas;");
- gSurfaceClassInfo.ctor = env->GetMethodID(gSurfaceClassInfo.clazz, "<init>", "()V");
+ gSurfaceClassInfo.ctor = env->GetMethodID(gSurfaceClassInfo.clazz, "<init>", "(I)V");
clazz = env->FindClass("android/graphics/Canvas");
gCanvasClassInfo.mFinalizer = env->GetFieldID(clazz, "mFinalizer", "Landroid/graphics/Canvas$CanvasFinalizer;");
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index a218488..5da5b4f 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -320,8 +320,11 @@ static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz,
jobject tokenObj, jint nativeSurfaceObject) {
sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
if (token == NULL) return;
+ sp<IGraphicBufferProducer> bufferProducer;
sp<Surface> sur(reinterpret_cast<Surface *>(nativeSurfaceObject));
- sp<IGraphicBufferProducer> bufferProducer(sur->getIGraphicBufferProducer());
+ if (sur != NULL) {
+ bufferProducer = sur->getIGraphicBufferProducer();
+ }
SurfaceComposerClient::setDisplaySurface(token, bufferProducer);
}