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

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

Merge "Fix ExtendedCameraCharacteristicsTest cts failures."

parents b9cb204e 20132348
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