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

Commit 0545420a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera2: CaptureRequest: Use common code for Surface unparcel" into nyc-mr1-dev

parents 21b83d1c 48932bbf
Loading
Loading
Loading
Loading
+18 −25
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ status_t CaptureRequest::readFromParcel(const Parcel* parcel) {
    mMetadata.clear();
    mSurfaceList.clear();

    status_t err;
    status_t err = OK;

    if ((err = mMetadata.readFromParcel(parcel)) != OK) {
        ALOGE("%s: Failed to read metadata from parcel", __FUNCTION__);
@@ -65,20 +65,16 @@ status_t CaptureRequest::readFromParcel(const Parcel* parcel) {
        }

        // Surface.writeToParcel
        const char16_t* name = parcel->readString16Inplace(&len);
        ALOGV("%s: Read surface name = %s", __FUNCTION__,
            name != NULL ? String8(name).string() : "<null>");
        parcel->readInt32();
        sp<IBinder> binder(parcel->readStrongBinder());
        ALOGV("%s: Read surface binder = %p",
              __FUNCTION__, binder.get());
        view::Surface surfaceShim;
        if ((err = surfaceShim.readFromParcel(parcel)) != OK) {
            ALOGE("%s: Failed to read output target Surface %d from parcel: %s (%d)",
                    __FUNCTION__, i, strerror(-err), err);
            return err;
        }

        sp<Surface> surface;

        if (binder != NULL) {
            sp<IGraphicBufferProducer> gbp =
                    interface_cast<IGraphicBufferProducer>(binder);
            surface = new Surface(gbp);
        if (surfaceShim.graphicBufferProducer != NULL) {
            surface = new Surface(surfaceShim.graphicBufferProducer);
        }

        mSurfaceList.push_back(surface);
@@ -100,7 +96,7 @@ status_t CaptureRequest::writeToParcel(Parcel* parcel) const {
        return BAD_VALUE;
    }

    status_t err;
    status_t err = OK;

    if ((err = mMetadata.writeToParcel(parcel)) != OK) {
        return err;
@@ -112,21 +108,18 @@ status_t CaptureRequest::writeToParcel(Parcel* parcel) const {
    parcel->writeInt32(size);

    for (int32_t i = 0; i < size; ++i) {
        sp<Surface> surface = mSurfaceList[i];

        sp<IBinder> binder;
        if (surface != 0) {
            binder = IInterface::asBinder(surface->getIGraphicBufferProducer());
        }

        // not sure if readParcelableArray does this, hard to tell from source
        parcel->writeString16(String16("android.view.Surface"));

        // Surface.writeToParcel
        parcel->writeString16(String16("unknown_name"));
        parcel->writeInt32(0);
        // Surface.nativeWriteToParcel
        parcel->writeStrongBinder(binder);
        view::Surface surfaceShim;
        surfaceShim.name = String16("unknown_name");
        surfaceShim.graphicBufferProducer = mSurfaceList[i]->getIGraphicBufferProducer();
        if ((err = surfaceShim.writeToParcel(parcel)) != OK) {
            ALOGE("%s: Failed to write output target Surface %d to parcel: %s (%d)",
                    __FUNCTION__, i, strerror(-err), err);
            return err;
        }
    }

    parcel->writeInt32(mIsReprocess ? 1 : 0);