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
This commit is contained in:
Sally Qi
2022-10-19 21:45:57 -07:00
parent 5f35907147
commit 201323481b
2 changed files with 21 additions and 25 deletions

View File

@@ -89,6 +89,24 @@ static sp<Surface> getSurface(JNIEnv* env, jobject surface) {
extern "C" {
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_FORMAT, &fmt);
if (err != NO_ERROR) {
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_nativeDetectSurfaceDataspace(JNIEnv* env, jobject thiz, jobject surface) {
ALOGV("nativeDetectSurfaceDataspace");
sp<ANativeWindow> anw;
@@ -107,27 +125,6 @@ static jint SurfaceUtils_nativeDetectSurfaceDataspace(JNIEnv* env, jobject thiz,
return fmt;
}
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 halFmt = 0;
status_t err = anw->query(anw.get(), NATIVE_WINDOW_FORMAT, &halFmt);
if (err != NO_ERROR) {
ALOGE("%s: Error while querying surface pixel format %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;
}
static jint SurfaceUtils_nativeDetectSurfaceDimens(JNIEnv* env, jobject thiz, jobject surface,
jintArray dimens) {
ALOGV("nativeGetSurfaceDimens");

View File

@@ -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