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

Commit 20132348 authored by Sally Qi's avatar Sally Qi
Browse files

Fix ExtendedCameraCharacteristicsTest cts failures.

Relnote: SurfaceUtils#getSurfaceFormat function should return the
the formats of Surface, therefore, no need to convert it to public
format.

Bug: 254349961
Test: android.hardware.camera2.cts.ImageReaderTest,
android.hardware.camera2.cts.ImageWriterTest,
android.hardware.camera2.cts.ExtendedCameraCharacteristicsTest

Change-Id: I58340f684b4fc9cb2578cee03ef1d65171c9eaed
parent 5f359071
Loading
Loading
Loading
Loading
+11 −14
Original line number Diff line number Diff line
@@ -89,42 +89,39 @@ static sp<Surface> getSurface(JNIEnv* env, jobject surface) {

extern "C" {

static jint SurfaceUtils_nativeDetectSurfaceDataspace(JNIEnv* env, jobject thiz, jobject surface) {
    ALOGV("nativeDetectSurfaceDataspace");
static jint SurfaceUtils_nativeDetectSurfaceType(JNIEnv* env, jobject thiz, jobject surface) {
    ALOGV("nativeDetectSurfaceType");
    sp<ANativeWindow> anw;
    if ((anw = getNativeWindow(env, surface)) == NULL) {
        ALOGE("%s: Could not retrieve native window from surface.", __FUNCTION__);
        return BAD_VALUE;
    }
    int32_t fmt = 0;
    status_t err = anw->query(anw.get(), NATIVE_WINDOW_DEFAULT_DATASPACE, &fmt);
    status_t err = anw->query(anw.get(), NATIVE_WINDOW_FORMAT, &fmt);
    if (err != NO_ERROR) {
        ALOGE("%s: Error while querying surface dataspace  %s (%d).", __FUNCTION__, strerror(-err),
              err);
        ALOGE("%s: Error while querying surface pixel format %s (%d).", __FUNCTION__,
              strerror(-err), err);
        OVERRIDE_SURFACE_ERROR(err);
        return err;
    }
    return fmt;
}

static jint SurfaceUtils_nativeDetectSurfaceType(JNIEnv* env, jobject thiz, jobject surface) {
    ALOGV("nativeDetectSurfaceType");
static jint SurfaceUtils_nativeDetectSurfaceDataspace(JNIEnv* env, jobject thiz, jobject surface) {
    ALOGV("nativeDetectSurfaceDataspace");
    sp<ANativeWindow> anw;
    if ((anw = getNativeWindow(env, surface)) == NULL) {
        ALOGE("%s: Could not retrieve native window from surface.", __FUNCTION__);
        return BAD_VALUE;
    }
    int32_t halFmt = 0;
    status_t err = anw->query(anw.get(), NATIVE_WINDOW_FORMAT, &halFmt);
    int32_t fmt = 0;
    status_t err = anw->query(anw.get(), NATIVE_WINDOW_DEFAULT_DATASPACE, &fmt);
    if (err != NO_ERROR) {
        ALOGE("%s: Error while querying surface pixel format %s (%d).", __FUNCTION__,
              strerror(-err), err);
        ALOGE("%s: Error while querying surface dataspace  %s (%d).", __FUNCTION__, strerror(-err),
              err);
        OVERRIDE_SURFACE_ERROR(err);
        return err;
    }
    int32_t dataspace = SurfaceUtils_nativeDetectSurfaceDataspace(env, thiz, surface);
    int32_t fmt = static_cast<int32_t>(
            mapHalFormatDataspaceToPublicFormat(halFmt, static_cast<android_dataspace>(dataspace)));
    return fmt;
}

+3 −4
Original line number Diff line number Diff line
@@ -264,10 +264,9 @@ public class ImageWriter implements AutoCloseable {
        if (useSurfaceImageFormatInfo) {
            // nativeInit internally overrides UNKNOWN format. So does surface format query after
            // nativeInit and before getEstimatedNativeAllocBytes().
            imageFormat = SurfaceUtils.getSurfaceFormat(surface);
            mDataSpace = dataSpace = PublicFormatUtils.getHalDataspace(imageFormat);
            mHardwareBufferFormat =
                hardwareBufferFormat = PublicFormatUtils.getHalFormat(imageFormat);
            mHardwareBufferFormat = hardwareBufferFormat = SurfaceUtils.getSurfaceFormat(surface);
            mDataSpace = dataSpace = SurfaceUtils.getSurfaceDataspace(surface);
            imageFormat = PublicFormatUtils.getPublicFormat(hardwareBufferFormat, dataSpace);
        }

        // Estimate the native buffer allocation size and register it so it gets accounted for