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

Commit 4c2932e8 authored by Shuzhen Wang's avatar Shuzhen Wang Committed by Android (Google) Code Review
Browse files

Merge "Camera: Add settings override API"

parents 20cce2ac ab80f9f5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -92,6 +92,8 @@ enum CameraMetadataTag {
  ANDROID_CONTROL_ZOOM_RATIO_RANGE = 65582,
  ANDROID_CONTROL_ZOOM_RATIO = 65583,
  ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS_MAXIMUM_RESOLUTION = 65584,
  ANDROID_CONTROL_SETTINGS_OVERRIDE = 65588,
  ANDROID_CONTROL_AVAILABLE_SETTINGS_OVERRIDES = 65589,
  ANDROID_DEMOSAIC_MODE = 131072,
  ANDROID_EDGE_MODE = 196608,
  ANDROID_EDGE_STRENGTH = 196609,
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *//*
 * Autogenerated from camera metadata definitions in
 * /system/media/camera/docs/metadata_definitions.xml
 * *** DO NOT EDIT BY HAND ***
 */
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
///////////////////////////////////////////////////////////////////////////////

// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
//     the interface (from the latest frozen version), the build system will
//     prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.

package android.hardware.camera.metadata;
@Backing(type="int") @VintfStability
enum ControlSettingsOverride {
  ANDROID_CONTROL_SETTINGS_OVERRIDE_OFF = 0,
  ANDROID_CONTROL_SETTINGS_OVERRIDE_ZOOM = 1,
  ANDROID_CONTROL_SETTINGS_OVERRIDE_VENDOR_START = 16384,
}
+14 −0
Original line number Diff line number Diff line
@@ -449,6 +449,20 @@ enum CameraMetadataTag {
     * @see ANDROID_SENSOR_PIXEL_MODE
     */
    ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS_MAXIMUM_RESOLUTION,
    /**
     * android.control.settingsOverride [dynamic, enum, public]
     *
     * <p>The desired CaptureRequest settings override with which certain keys are
     * applied earlier so that they can take effect sooner.</p>
     */
    ANDROID_CONTROL_SETTINGS_OVERRIDE = 65588,
    /**
     * android.control.availableSettingsOverrides [static, int32[], public]
     *
     * <p>List of available settings overrides supported by the camera device that can
     * be used to speed up certain controls.</p>
     */
    ANDROID_CONTROL_AVAILABLE_SETTINGS_OVERRIDES,
    /**
     * android.demosaic.mode [controls, enum, system]
     *
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Autogenerated from camera metadata definitions in
 * /system/media/camera/docs/metadata_definitions.xml
 * *** DO NOT EDIT BY HAND ***
 */

package android.hardware.camera.metadata;

/**
 * android.control.settingsOverride enumeration values
 * @see ANDROID_CONTROL_SETTINGS_OVERRIDE
 */
@VintfStability
@Backing(type="int")
enum ControlSettingsOverride {
    ANDROID_CONTROL_SETTINGS_OVERRIDE_OFF,
    ANDROID_CONTROL_SETTINGS_OVERRIDE_ZOOM,
    ANDROID_CONTROL_SETTINGS_OVERRIDE_VENDOR_START = 0x4000,
}
+68 −1
Original line number Diff line number Diff line
@@ -331,6 +331,63 @@ void CameraAidlTest::verifyStreamUseCaseCharacteristics(const camera_metadata_t*
    ASSERT_EQ(hasStreamUseCaseCap, supportMandatoryUseCases);
}

void CameraAidlTest::verifySettingsOverrideCharacteristics(const camera_metadata_t* metadata) {
    camera_metadata_ro_entry entry;
    int retcode = find_camera_metadata_ro_entry(metadata,
            ANDROID_CONTROL_AVAILABLE_SETTINGS_OVERRIDES, &entry);
    bool supportSettingsOverride = false;
    if ((0 == retcode) && (entry.count > 0)) {
        supportSettingsOverride = true;
        bool hasOff = false;
        for (size_t i = 0; i < entry.count; i++) {
            if (entry.data.u8[i] == ANDROID_CONTROL_SETTINGS_OVERRIDE_OFF) {
                hasOff = true;
            }
        }
        ASSERT_TRUE(hasOff);
    }

    // Check availableRequestKeys
    retcode = find_camera_metadata_ro_entry(metadata,
            ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, &entry);
    bool hasSettingsOverrideRequestKey = false;
    if ((0 == retcode) && (entry.count > 0)) {
        hasSettingsOverrideRequestKey =
                std::find(entry.data.i32, entry.data.i32 + entry.count,
                        ANDROID_CONTROL_SETTINGS_OVERRIDE) != entry.data.i32 + entry.count;
    } else {
        ADD_FAILURE() << "Get camera availableRequestKeys failed!";
    }

    // Check availableResultKeys
    retcode = find_camera_metadata_ro_entry(metadata,
            ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, &entry);
    bool hasSettingsOverrideResultKey = false;
    if ((0 == retcode) && (entry.count > 0)) {
        hasSettingsOverrideResultKey =
                std::find(entry.data.i32, entry.data.i32 + entry.count,
                        ANDROID_CONTROL_SETTINGS_OVERRIDE) != entry.data.i32 + entry.count;
    } else {
        ADD_FAILURE() << "Get camera availableResultKeys failed!";
    }

    // Check availableCharacteristicKeys
    retcode = find_camera_metadata_ro_entry(metadata,
            ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, &entry);
    bool hasSettingsOverrideCharacteristicsKey= false;
    if ((0 == retcode) && (entry.count > 0)) {
        hasSettingsOverrideCharacteristicsKey = std::find(entry.data.i32,
                entry.data.i32 + entry.count, ANDROID_CONTROL_AVAILABLE_SETTINGS_OVERRIDES)
                        != entry.data.i32 + entry.count;
    } else {
        ADD_FAILURE() << "Get camera availableCharacteristicsKeys failed!";
    }

    ASSERT_EQ(supportSettingsOverride, hasSettingsOverrideRequestKey);
    ASSERT_EQ(supportSettingsOverride, hasSettingsOverrideResultKey);
    ASSERT_EQ(supportSettingsOverride, hasSettingsOverrideCharacteristicsKey);
}

Status CameraAidlTest::isMonochromeCamera(const camera_metadata_t* staticMeta) {
    Status ret = Status::OPERATION_NOT_SUPPORTED;
    if (nullptr == staticMeta) {
@@ -606,6 +663,7 @@ void CameraAidlTest::verifyCameraCharacteristics(const CameraMetadata& chars) {
    verifyExtendedSceneModeCharacteristics(metadata);
    verifyZoomCharacteristics(metadata);
    verifyStreamUseCaseCharacteristics(metadata);
    verifySettingsOverrideCharacteristics(metadata);
}

void CameraAidlTest::verifyExtendedSceneModeCharacteristics(const camera_metadata_t* metadata) {
@@ -1517,6 +1575,15 @@ void CameraAidlTest::verifyRequestTemplate(const camera_metadata_t* metadata,
        ASSERT_EQ(zoomRatioEntry.count, 1);
        ASSERT_EQ(zoomRatioEntry.data.f[0], 1.0f);
    }

    // Check settings override
    camera_metadata_ro_entry settingsOverrideEntry;
    int foundSettingsOverride = find_camera_metadata_ro_entry(metadata,
           ANDROID_CONTROL_SETTINGS_OVERRIDE,&settingsOverrideEntry);
    if (foundSettingsOverride == 0) {
        ASSERT_EQ(settingsOverrideEntry.count, 1);
        ASSERT_EQ(settingsOverrideEntry.data.u8[0], ANDROID_CONTROL_SETTINGS_OVERRIDE_OFF);
    }
}

void CameraAidlTest::openEmptyDeviceSession(const std::string& name,
Loading