diff options
| author | 2013-02-26 00:52:55 +0000 | |
|---|---|---|
| committer | 2013-02-26 00:55:25 +0000 | |
| commit | 19a38f6f408d8672ca8d253fb7a6039a7f25c96f (patch) | |
| tree | 3b0fa8f88b4dbb9c0a3eae3bd63731dbdb16a3c9 | |
| parent | 89ceb6e2d9d954c4802b4cf434e1aac4c4a622ef (diff) | |
| parent | ffddc9b8045235a493ec506965ae4892601eb23d (diff) | |
Merge "Fix SurfaceControl.setDisplaySurface() such that it accepts a null Surface" into jb-mr2-dev
| -rw-r--r-- | core/java/android/view/SurfaceControl.java | 9 | ||||
| -rw-r--r-- | core/jni/android_view_Surface.cpp | 2 | ||||
| -rw-r--r-- | core/jni/android_view_SurfaceControl.cpp | 5 |
3 files changed, 7 insertions, 9 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index 7ef7e2bf6f11..ded2f470ac7b 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 b4a19f103eb6..02e76e5ad3a2 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 a2184883b498..5da5b4ffec20 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); } |