Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19a38f6f authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge "Fix SurfaceControl.setDisplaySurface() such that it accepts a null Surface" into jb-mr2-dev

parents 89ceb6e2 ffddc9b8
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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;");
+4 −1
Original line number Diff line number Diff line
@@ -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);
}