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

Commit c9eb89a9 authored by Anton Ivanov's avatar Anton Ivanov Committed by Android (Google) Code Review
Browse files

Merge "Harden construction sites of android::Surface." into main

parents d86e4698 a4c448d5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ BootAnimation::BootAnimation(sp<Callbacks> callbacks)
        : Thread(false), mLooper(new Looper(false)), mClockEnabled(true), mTimeIsAccurate(false),
        mTimeFormat12Hour(false), mTimeCheckThread(nullptr), mCallbacks(callbacks) {
    ATRACE_CALL();
    mSession = new SurfaceComposerClient();
    mSession = sp<SurfaceComposerClient>::make();

    std::string powerCtl = android::base::GetProperty("sys.powerctl", "");
    if (powerCtl.empty()) {
+1 −1
Original line number Diff line number Diff line
@@ -399,7 +399,7 @@ static jlong ImageWriter_init(JNIEnv* env, jobject thiz, jobject weakThiz, jobje
    }
    sp<JNIImageWriterContext> ctx(new JNIImageWriterContext(env, weakThiz, clazz));

    sp<Surface> producer = new Surface(bufferProducer, /*controlledByApp*/false);
    sp<Surface> producer = sp<Surface>::make(bufferProducer, /*controlledByApp*/ false);
    ctx->setProducer(producer);
    /**
     * NATIVE_WINDOW_API_CPU isn't a good choice here, as it makes the bufferQueue not connectable
+4 −4
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env,
        return NULL;
    }

    sp<Surface> surface(new Surface(bufferProducer, true));
    sp<Surface> surface = sp<Surface>::make(bufferProducer, true);
    return android_view_Surface_createFromSurface(env, surface);
}

@@ -161,7 +161,7 @@ static jlong nativeCreateFromSurfaceTexture(JNIEnv* env, jclass clazz,
        return 0;
    }

    sp<Surface> surface(new Surface(producer, true));
    sp<Surface> surface = sp<Surface>::make(producer, true);
    if (surface == NULL) {
        jniThrowException(env, OutOfResourcesException, NULL);
        return 0;
@@ -358,7 +358,7 @@ static jlong nativeReadFromParcel(JNIEnv* env, jclass clazz,
    sp<Surface> sur;
    if (surfaceShim.graphicBufferProducer != nullptr) {
        // we have a new IGraphicBufferProducer, create a new Surface for it
        sur = new Surface(surfaceShim.graphicBufferProducer, true,
        sur = sp<Surface>::make(surfaceShim.graphicBufferProducer, true,
                                surfaceShim.surfaceControlHandle);
        // and keep a reference before passing to java
        sur->incStrong(&sRefBaseOwner);
+4 −4
Original line number Diff line number Diff line
@@ -42,14 +42,14 @@ sp<SurfaceComposerClient> android_view_SurfaceSession_getClient(


static jlong nativeCreate(JNIEnv* env, jclass clazz) {
    SurfaceComposerClient* client = new SurfaceComposerClient();
    client->incStrong((void*)nativeCreate);
    return reinterpret_cast<jlong>(client);
    // Will be deleted via decStrong() in nativeDestroy.
    auto client = sp<SurfaceComposerClient>::make();
    return reinterpret_cast<jlong>(client.release());
}

static void nativeDestroy(JNIEnv* env, jclass clazz, jlong ptr) {
    SurfaceComposerClient* client = reinterpret_cast<SurfaceComposerClient*>(ptr);
    client->decStrong((void*)nativeCreate);
    client->decStrong((void*)client);
}

static const JNINativeMethod gMethods[] = {
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ static void android_view_TextureView_createNativeWindow(JNIEnv* env, jobject tex
        jobject surface) {

    sp<IGraphicBufferProducer> producer(SurfaceTexture_getProducer(env, surface));
    sp<ANativeWindow> window = new Surface(producer, true);
    sp<ANativeWindow> window = sp<Surface>::make(producer, true);

    window->incStrong((void*)android_view_TextureView_createNativeWindow);
    SET_LONG(textureView, gTextureViewClassInfo.nativeWindow, jlong(window.get()));
Loading