mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Camera: Migrate VTS tests to AIDL
This CL migrates the existing camera VTS tests to AIDL Bug: 210912368 Test: Migrated all HIDL tests to AIDL Change-Id: I4da6d38105d96908684a754da73699486295da8b
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# Bug component: 41727
|
||||
|
||||
# Camera team
|
||||
include platform/frameworks/av:/camera/OWNERS
|
||||
|
||||
|
||||
@@ -65,5 +65,9 @@ cc_test {
|
||||
"libhidlmemory",
|
||||
"libgralloctypes",
|
||||
],
|
||||
test_suites: ["general-tests", "vts"],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
"vts",
|
||||
],
|
||||
|
||||
}
|
||||
|
||||
75
camera/provider/aidl/vts/Android.bp
Normal file
75
camera/provider/aidl/vts/Android.bp
Normal file
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
package {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "hardware_interfaces_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: ["hardware_interfaces_license"],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "VtsAidlHalCameraProvider_TargetTest",
|
||||
defaults: [
|
||||
"VtsHalTargetTestDefaults",
|
||||
"use_libaidlvintf_gtest_helper_static",
|
||||
],
|
||||
srcs: [
|
||||
"camera_aidl_test.cpp",
|
||||
"device_cb.cpp",
|
||||
"empty_device_cb.cpp",
|
||||
"simple_device_cb.cpp",
|
||||
"torch_provider_cb.cpp",
|
||||
"VtsAidlHalCameraProvider_TargetTest.cpp",
|
||||
],
|
||||
|
||||
// TODO(b/64437680): Assume these are always available on the device.
|
||||
shared_libs: [
|
||||
"libbinder_ndk",
|
||||
"libcamera_metadata",
|
||||
"libcutils",
|
||||
"libfmq",
|
||||
"libgui",
|
||||
"libui",
|
||||
"libbase",
|
||||
"android.hardware.common-V2-ndk",
|
||||
"android.hardware.common.fmq-V1-ndk",
|
||||
"android.hardware.graphics.mapper@2.0",
|
||||
"android.hardware.graphics.mapper@3.0",
|
||||
"android.hardware.graphics.mapper@4.0",
|
||||
],
|
||||
|
||||
// Statically link to libs not guaranteed to be present on the device.
|
||||
static_libs: [
|
||||
"android.hardware.camera.common@1.0-helper",
|
||||
"android.hardware.camera.common-V1-ndk",
|
||||
"android.hardware.camera.device-V1-ndk",
|
||||
"android.hardware.camera.metadata-V1-ndk",
|
||||
"android.hardware.camera.provider-V1-ndk",
|
||||
"android.hardware.graphics.common-V3-ndk",
|
||||
"android.hidl.allocator@1.0",
|
||||
"libgrallocusage",
|
||||
"libhidlmemory",
|
||||
"libgralloctypes",
|
||||
"libaidlcommonsupport",
|
||||
],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
"vts",
|
||||
],
|
||||
}
|
||||
33
camera/provider/aidl/vts/AndroidTest.xml
Normal file
33
camera/provider/aidl/vts/AndroidTest.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
<configuration description="Runs VtsAidlHalCameraProvider_TargetTest.">
|
||||
<option name="test-suite-tag" value="apct" />
|
||||
<option name="test-suite-tag" value="apct-native" />
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
|
||||
</target_preparer>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
|
||||
<option name="cleanup" value="true" />
|
||||
<option name="push" value="VtsAidlHalCameraProvider_TargetTest->/data/local/tmp/VtsAidlHalCameraProvider_TargetTest" />
|
||||
</target_preparer>
|
||||
|
||||
<test class="com.android.tradefed.testtype.GTest" >
|
||||
<option name="native-test-device-path" value="/data/local/tmp" />
|
||||
<option name="module-name" value="VtsAidlHalCameraProvider_TargetTest" />
|
||||
<option name="native-test-timeout" value="1800000"/> <!-- 30 min -->
|
||||
</test>
|
||||
</configuration>
|
||||
6
camera/provider/aidl/vts/OWNERS
Normal file
6
camera/provider/aidl/vts/OWNERS
Normal file
@@ -0,0 +1,6 @@
|
||||
# Camera team
|
||||
include platform/frameworks/av:/camera/OWNERS
|
||||
|
||||
# VTS team
|
||||
yim@google.com
|
||||
zhuoyao@google.com
|
||||
3010
camera/provider/aidl/vts/VtsAidlHalCameraProvider_TargetTest.cpp
Normal file
3010
camera/provider/aidl/vts/VtsAidlHalCameraProvider_TargetTest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
2924
camera/provider/aidl/vts/camera_aidl_test.cpp
Normal file
2924
camera/provider/aidl/vts/camera_aidl_test.cpp
Normal file
File diff suppressed because it is too large
Load Diff
528
camera/provider/aidl/vts/camera_aidl_test.h
Normal file
528
camera/provider/aidl/vts/camera_aidl_test.h
Normal file
@@ -0,0 +1,528 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_CAMERA_AIDL_TEST_H_
|
||||
#define HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_CAMERA_AIDL_TEST_H_
|
||||
|
||||
#define LOG_TAG "camera_aidl_hal_test"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <CameraMetadata.h>
|
||||
#include <CameraParameters.h>
|
||||
#include <HandleImporter.h>
|
||||
#include <fmq/AidlMessageQueue.h>
|
||||
|
||||
#include <aidl/android/hardware/graphics/common/Dataspace.h>
|
||||
|
||||
#include <aidl/android/hardware/camera/common/Status.h>
|
||||
#include <aidl/android/hardware/camera/common/TorchModeStatus.h>
|
||||
#include <aidl/android/hardware/common/NativeHandle.h>
|
||||
|
||||
#include <aidl/android/hardware/camera/device/CaptureResult.h>
|
||||
#include <aidl/android/hardware/camera/device/ErrorCode.h>
|
||||
#include <aidl/android/hardware/camera/device/HalStream.h>
|
||||
#include <aidl/android/hardware/camera/device/ICameraDevice.h>
|
||||
#include <aidl/android/hardware/camera/device/NotifyMsg.h>
|
||||
#include <aidl/android/hardware/camera/device/PhysicalCameraMetadata.h>
|
||||
#include <aidl/android/hardware/camera/device/Stream.h>
|
||||
|
||||
#include <aidl/android/hardware/camera/provider/ICameraProvider.h>
|
||||
|
||||
#include <aidl/android/hardware/graphics/common/PixelFormat.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <log/log.h>
|
||||
#include <system/camera_metadata.h>
|
||||
#include <utils/KeyedVector.h>
|
||||
#include <utils/Timers.h>
|
||||
|
||||
using ::aidl::android::hardware::camera::common::Status;
|
||||
using ::aidl::android::hardware::camera::common::TorchModeStatus;
|
||||
using ::aidl::android::hardware::camera::device::BufferRequest;
|
||||
using ::aidl::android::hardware::camera::device::BufferRequestStatus;
|
||||
using ::aidl::android::hardware::camera::device::CameraMetadata;
|
||||
using ::aidl::android::hardware::camera::device::CaptureResult;
|
||||
using ::aidl::android::hardware::camera::device::ErrorCode;
|
||||
using ::aidl::android::hardware::camera::device::HalStream;
|
||||
using ::aidl::android::hardware::camera::device::ICameraDevice;
|
||||
using ::aidl::android::hardware::camera::device::ICameraDeviceSession;
|
||||
using ::aidl::android::hardware::camera::device::ICameraInjectionSession;
|
||||
using ::aidl::android::hardware::camera::device::NotifyMsg;
|
||||
using ::aidl::android::hardware::camera::device::PhysicalCameraMetadata;
|
||||
using ::aidl::android::hardware::camera::device::RequestTemplate;
|
||||
using ::aidl::android::hardware::camera::device::Stream;
|
||||
using ::aidl::android::hardware::camera::device::StreamBuffer;
|
||||
using ::aidl::android::hardware::camera::device::StreamBufferRet;
|
||||
using ::aidl::android::hardware::camera::device::StreamConfiguration;
|
||||
using ::aidl::android::hardware::camera::device::StreamConfigurationMode;
|
||||
using ::aidl::android::hardware::camera::provider::ConcurrentCameraIdCombination;
|
||||
using ::aidl::android::hardware::camera::provider::ICameraProvider;
|
||||
|
||||
using ::aidl::android::hardware::common::NativeHandle;
|
||||
using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
|
||||
|
||||
using ::aidl::android::hardware::graphics::common::Dataspace;
|
||||
using ::aidl::android::hardware::graphics::common::PixelFormat;
|
||||
|
||||
using ::android::hardware::camera::common::V1_0::helper::HandleImporter;
|
||||
using ::android::hardware::camera::common::V1_0::helper::Size;
|
||||
|
||||
using ResultMetadataQueue = android::AidlMessageQueue<int8_t, SynchronizedReadWrite>;
|
||||
|
||||
using ::ndk::ScopedAStatus;
|
||||
|
||||
class DeviceCb; // Forward declare to break circular header dependency
|
||||
|
||||
class CameraAidlTest : public ::testing::TestWithParam<std::string> {
|
||||
public:
|
||||
enum SystemCameraKind {
|
||||
/**
|
||||
* These camera devices are visible to all apps and system components alike
|
||||
*/
|
||||
PUBLIC = 0,
|
||||
|
||||
/**
|
||||
* These camera devices are visible only to processes having the
|
||||
* android.permission.SYSTEM_CAMERA permission. They are not exposed to 3P
|
||||
* apps.
|
||||
*/
|
||||
SYSTEM_ONLY_CAMERA,
|
||||
|
||||
/**
|
||||
* These camera devices are visible only to HAL clients (that try to connect
|
||||
* on a hwbinder thread).
|
||||
*/
|
||||
HIDDEN_SECURE_CAMERA
|
||||
};
|
||||
|
||||
struct AvailableStream {
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
int32_t format;
|
||||
};
|
||||
|
||||
enum ReprocessType {
|
||||
PRIV_REPROCESS,
|
||||
YUV_REPROCESS,
|
||||
};
|
||||
|
||||
struct AvailableZSLInputOutput {
|
||||
int32_t inputFormat;
|
||||
int32_t outputFormat;
|
||||
};
|
||||
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
std::vector<std::string> getCameraDeviceNames(std::shared_ptr<ICameraProvider>& provider,
|
||||
bool addSecureOnly = false);
|
||||
|
||||
static bool isSecureOnly(const std::shared_ptr<ICameraProvider>& provider,
|
||||
const std::string& name);
|
||||
|
||||
std::map<std::string, std::string> getCameraDeviceIdToNameMap(
|
||||
std::shared_ptr<ICameraProvider> provider);
|
||||
|
||||
static std::vector<ConcurrentCameraIdCombination> getConcurrentDeviceCombinations(
|
||||
std::shared_ptr<ICameraProvider>& provider);
|
||||
|
||||
void notifyDeviceState(int64_t state);
|
||||
|
||||
static void allocateGraphicBuffer(uint32_t width, uint32_t height, uint64_t usage,
|
||||
PixelFormat format, buffer_handle_t* buffer_handle /*out*/);
|
||||
|
||||
static void openEmptyDeviceSession(const std::string& name,
|
||||
std::shared_ptr<ICameraProvider> provider,
|
||||
std::shared_ptr<ICameraDeviceSession>* session /*out*/,
|
||||
CameraMetadata* staticMeta /*out*/,
|
||||
std::shared_ptr<ICameraDevice>* device /*out*/);
|
||||
static void openEmptyInjectionSession(const std::string& name,
|
||||
const std::shared_ptr<ICameraProvider>& provider,
|
||||
std::shared_ptr<ICameraInjectionSession>* session /*out*/,
|
||||
CameraMetadata* staticMeta /*out*/,
|
||||
std::shared_ptr<ICameraDevice>* device /*out*/);
|
||||
|
||||
static void createStreamConfiguration(std::vector<Stream>& streams,
|
||||
StreamConfigurationMode configMode,
|
||||
StreamConfiguration* config, int32_t jpegBufferSize = 0);
|
||||
|
||||
void configureOfflineStillStream(
|
||||
const std::string& name, const std::shared_ptr<ICameraProvider>& provider,
|
||||
const AvailableStream* threshold,
|
||||
std::shared_ptr<ICameraDeviceSession>* session /*out*/, Stream* stream /*out*/,
|
||||
std::vector<HalStream>* halStreams, bool* supportsPartialResults /*out*/,
|
||||
int32_t* partialResultCount /*out*/, std::shared_ptr<DeviceCb>* outCb /*out*/,
|
||||
int32_t* jpegBufferSize /*out*/, bool* useHalBufManager /*out*/);
|
||||
|
||||
void configureStreams(
|
||||
const std::string& name, const std::shared_ptr<ICameraProvider>& provider,
|
||||
PixelFormat format, std::shared_ptr<ICameraDeviceSession>* session /*out*/,
|
||||
Stream* previewStream /*out*/, std::vector<HalStream>* halStreams /*out*/,
|
||||
bool* supportsPartialResults /*out*/, int32_t* partialResultCount /*out*/,
|
||||
bool* useHalBufManager /*out*/, std::shared_ptr<DeviceCb>* outCb /*out*/,
|
||||
uint32_t streamConfigCounter, bool maxResolution,
|
||||
aidl::android::hardware::camera::metadata::RequestAvailableDynamicRangeProfilesMap
|
||||
prof = ::aidl::android::hardware::camera::metadata::
|
||||
RequestAvailableDynamicRangeProfilesMap(0));
|
||||
|
||||
void configurePreviewStreams(
|
||||
const std::string& name, const std::shared_ptr<ICameraProvider>& provider,
|
||||
const AvailableStream* previewThreshold,
|
||||
const std::unordered_set<std::string>& physicalIds,
|
||||
std::shared_ptr<ICameraDeviceSession>* session /*out*/, Stream* previewStream /*out*/,
|
||||
std::vector<HalStream>* halStreams /*out*/, bool* supportsPartialResults /*out*/,
|
||||
int32_t* partialResultCount /*out*/, bool* useHalBufManager /*out*/,
|
||||
std::shared_ptr<DeviceCb>* cb /*out*/, int32_t streamConfigCounter = 0);
|
||||
|
||||
void configurePreviewStream(
|
||||
const std::string& name, const std::shared_ptr<ICameraProvider>& provider,
|
||||
const AvailableStream* previewThreshold,
|
||||
std::shared_ptr<ICameraDeviceSession>* session /*out*/, Stream* previewStream /*out*/,
|
||||
std::vector<HalStream>* halStreams /*out*/, bool* supportsPartialResults /*out*/,
|
||||
int32_t* partialResultCount /*out*/, bool* useHalBufManager /*out*/,
|
||||
std::shared_ptr<DeviceCb>* cb /*out*/, uint32_t streamConfigCounter = 0);
|
||||
|
||||
void configureSingleStream(
|
||||
const std::string& name, const std::shared_ptr<ICameraProvider>& provider,
|
||||
const AvailableStream* previewThreshold, uint64_t bufferUsage,
|
||||
RequestTemplate reqTemplate, std::shared_ptr<ICameraDeviceSession>* session /*out*/,
|
||||
Stream* previewStream /*out*/, std::vector<HalStream>* halStreams /*out*/,
|
||||
bool* supportsPartialResults /*out*/, int32_t* partialResultCount /*out*/,
|
||||
bool* useHalBufManager /*out*/, std::shared_ptr<DeviceCb>* cb /*out*/,
|
||||
uint32_t streamConfigCounter = 0);
|
||||
|
||||
void verifyLogicalOrUltraHighResCameraMetadata(const std::string& cameraName,
|
||||
const std::shared_ptr<ICameraDevice>& device,
|
||||
const CameraMetadata& chars,
|
||||
const std::vector<std::string>& deviceNames);
|
||||
|
||||
static void verifyCameraCharacteristics(const CameraMetadata& chars);
|
||||
|
||||
static void verifyExtendedSceneModeCharacteristics(const camera_metadata_t* metadata);
|
||||
|
||||
static void verifyZoomCharacteristics(const camera_metadata_t* metadata);
|
||||
|
||||
static void verifyRecommendedConfigs(const CameraMetadata& chars);
|
||||
|
||||
static void verifyMonochromeCharacteristics(const CameraMetadata& chars);
|
||||
|
||||
static void verifyMonochromeCameraResult(
|
||||
const ::android::hardware::camera::common::V1_0::helper::CameraMetadata& metadata);
|
||||
|
||||
static void verifyStreamUseCaseCharacteristics(const camera_metadata_t* metadata);
|
||||
|
||||
static void verifyStreamCombination(const std::shared_ptr<ICameraDevice>& device,
|
||||
const StreamConfiguration& config, bool expectedStatus,
|
||||
bool expectStreamCombQuery);
|
||||
|
||||
static void verifyLogicalCameraResult(const camera_metadata_t* staticMetadata,
|
||||
const std::vector<uint8_t>& resultMetadata);
|
||||
|
||||
static void verifyBuffersReturned(const std::shared_ptr<ICameraDeviceSession>& session,
|
||||
int32_t streamId, const std::shared_ptr<DeviceCb>& cb,
|
||||
uint32_t streamConfigCounter = 0);
|
||||
|
||||
void verifyBuffersReturned(const std::shared_ptr<ICameraDeviceSession>& session,
|
||||
const std::vector<int32_t>& streamIds, std::shared_ptr<DeviceCb> cb,
|
||||
uint32_t streamConfigCounter = 0);
|
||||
|
||||
static void verifySessionReconfigurationQuery(
|
||||
const std::shared_ptr<ICameraDeviceSession>& session, camera_metadata* oldSessionParams,
|
||||
camera_metadata* newSessionParams);
|
||||
|
||||
static void verifyRequestTemplate(const camera_metadata_t* metadata,
|
||||
RequestTemplate requestTemplate);
|
||||
|
||||
static void overrideRotateAndCrop(CameraMetadata* settings /*in/out*/);
|
||||
|
||||
static bool isDepthOnly(const camera_metadata_t* staticMeta);
|
||||
|
||||
static bool isUltraHighResolution(const camera_metadata_t* staticMeta);
|
||||
|
||||
static Status getAvailableOutputStreams(const camera_metadata_t* staticMeta,
|
||||
std::vector<AvailableStream>& outputStreams,
|
||||
const AvailableStream* threshold = nullptr,
|
||||
bool maxResolution = false);
|
||||
|
||||
static Status getMaxOutputSizeForFormat(const camera_metadata_t* staticMeta, PixelFormat format,
|
||||
Size* size, bool maxResolution = false);
|
||||
|
||||
static Status getMandatoryConcurrentStreams(const camera_metadata_t* staticMeta,
|
||||
std::vector<AvailableStream>* outputStreams);
|
||||
|
||||
static bool supportsPreviewStabilization(const std::string& name,
|
||||
const std::shared_ptr<ICameraProvider>& provider);
|
||||
|
||||
static Status getJpegBufferSize(camera_metadata_t* staticMeta, int32_t* outBufSize);
|
||||
|
||||
static Status isConstrainedModeAvailable(camera_metadata_t* staticMeta);
|
||||
|
||||
static Status isLogicalMultiCamera(const camera_metadata_t* staticMeta);
|
||||
|
||||
static bool isTorchSupported(const camera_metadata_t* staticMeta);
|
||||
|
||||
static bool isTorchStrengthControlSupported(const camera_metadata_t* staticMeta);
|
||||
|
||||
static Status isOfflineSessionSupported(const camera_metadata_t* staticMeta);
|
||||
|
||||
static Status getPhysicalCameraIds(const camera_metadata_t* staticMeta,
|
||||
std::unordered_set<std::string>* physicalIds /*out*/);
|
||||
|
||||
static Status getSupportedKeys(camera_metadata_t* staticMeta, uint32_t tagId,
|
||||
std::unordered_set<int32_t>* requestIDs /*out*/);
|
||||
|
||||
static void fillOutputStreams(camera_metadata_ro_entry_t* entry,
|
||||
std::vector<AvailableStream>& outputStreams,
|
||||
const AvailableStream* threshold = nullptr,
|
||||
const int32_t availableConfigOutputTag = 0u);
|
||||
|
||||
static void constructFilteredSettings(
|
||||
const std::shared_ptr<ICameraDeviceSession>& session,
|
||||
const std::unordered_set<int32_t>& availableKeys, RequestTemplate reqTemplate,
|
||||
android::hardware::camera::common::V1_0::helper::CameraMetadata*
|
||||
defaultSettings /*out*/,
|
||||
android::hardware::camera::common::V1_0::helper::CameraMetadata* filteredSettings
|
||||
/*out*/);
|
||||
|
||||
static Status pickConstrainedModeSize(camera_metadata_t* staticMeta,
|
||||
AvailableStream& hfrStream);
|
||||
|
||||
static Status isZSLModeAvailable(const camera_metadata_t* staticMeta);
|
||||
|
||||
static Status isZSLModeAvailable(const camera_metadata_t* staticMeta, ReprocessType reprocType);
|
||||
|
||||
static Status getZSLInputOutputMap(camera_metadata_t* staticMeta,
|
||||
std::vector<AvailableZSLInputOutput>& inputOutputMap);
|
||||
|
||||
static Status findLargestSize(const std::vector<AvailableStream>& streamSizes, int32_t format,
|
||||
AvailableStream& result);
|
||||
|
||||
static Status isMonochromeCamera(const camera_metadata_t* staticMeta);
|
||||
|
||||
static Status getSystemCameraKind(const camera_metadata_t* staticMeta,
|
||||
SystemCameraKind* systemCameraKind);
|
||||
|
||||
static void getMultiResolutionStreamConfigurations(
|
||||
camera_metadata_ro_entry* multiResStreamConfigs,
|
||||
camera_metadata_ro_entry* streamConfigs,
|
||||
camera_metadata_ro_entry* maxResolutionStreamConfigs,
|
||||
const camera_metadata_t* staticMetadata);
|
||||
|
||||
static void getPrivacyTestPatternModes(
|
||||
const camera_metadata_t* staticMetadata,
|
||||
std::unordered_set<int32_t>* privacyTestPatternModes /*out*/);
|
||||
|
||||
static Dataspace getDataspace(PixelFormat format);
|
||||
|
||||
void processCaptureRequestInternal(uint64_t bufferUsage, RequestTemplate reqTemplate,
|
||||
bool useSecureOnlyCameras);
|
||||
|
||||
void processPreviewStabilizationCaptureRequestInternal(
|
||||
bool previewStabilizationOn,
|
||||
/*inout*/ std::unordered_map<std::string, nsecs_t>& cameraDeviceToTimeLag);
|
||||
|
||||
static bool is10BitDynamicRangeCapable(const camera_metadata_t* staticMeta);
|
||||
|
||||
static void get10BitDynamicRangeProfiles(
|
||||
const camera_metadata_t* staticMeta,
|
||||
std::vector<aidl::android::hardware::camera::metadata::
|
||||
RequestAvailableDynamicRangeProfilesMap>* profiles);
|
||||
|
||||
// Used by switchToOffline where a new result queue is created for offline reqs
|
||||
void updateInflightResultQueue(const std::shared_ptr<ResultMetadataQueue>& resultQueue);
|
||||
|
||||
static Size getMinSize(Size a, Size b);
|
||||
|
||||
protected:
|
||||
// In-flight queue for tracking completion of capture requests.
|
||||
struct InFlightRequest {
|
||||
// Set by notify() SHUTTER call.
|
||||
nsecs_t shutterTimestamp;
|
||||
|
||||
bool shutterReadoutTimestampValid;
|
||||
nsecs_t shutterReadoutTimestamp;
|
||||
|
||||
bool errorCodeValid;
|
||||
ErrorCode errorCode;
|
||||
|
||||
// Is partial result supported
|
||||
bool usePartialResult;
|
||||
|
||||
// Partial result count expected
|
||||
int32_t numPartialResults;
|
||||
|
||||
// Message queue
|
||||
std::shared_ptr<ResultMetadataQueue> resultQueue;
|
||||
|
||||
// Set by process_capture_result call with valid metadata
|
||||
bool haveResultMetadata;
|
||||
|
||||
// Decremented by calls to process_capture_result with valid output
|
||||
// and input buffers
|
||||
ssize_t numBuffersLeft;
|
||||
|
||||
// A 64bit integer to index the frame number associated with this result.
|
||||
int64_t frameNumber;
|
||||
|
||||
// The partial result count (index) for this capture result.
|
||||
int32_t partialResultCount;
|
||||
|
||||
// For buffer drop errors, the stream ID for the stream that lost a buffer.
|
||||
// For physical sub-camera result errors, the Id of the physical stream
|
||||
// for the physical sub-camera.
|
||||
// Otherwise -1.
|
||||
int32_t errorStreamId;
|
||||
|
||||
// If this request has any input buffer
|
||||
bool hasInputBuffer;
|
||||
|
||||
// Result metadata
|
||||
::android::hardware::camera::common::V1_0::helper::CameraMetadata collectedResult;
|
||||
|
||||
// A copy-able StreamBuffer using buffer_handle_t instead of AIDLs NativeHandle
|
||||
struct NativeStreamBuffer {
|
||||
int32_t streamId;
|
||||
int64_t bufferId;
|
||||
buffer_handle_t buffer;
|
||||
aidl::android::hardware::camera::device::BufferStatus status;
|
||||
buffer_handle_t acquireFence;
|
||||
buffer_handle_t releaseFence;
|
||||
};
|
||||
|
||||
// Buffers are added by process_capture_result when output buffers
|
||||
// return from HAL but framework.
|
||||
struct StreamBufferAndTimestamp {
|
||||
NativeStreamBuffer buffer;
|
||||
nsecs_t timeStamp;
|
||||
};
|
||||
std::vector<StreamBufferAndTimestamp> resultOutputBuffers;
|
||||
|
||||
std::unordered_set<std::string> expectedPhysicalResults;
|
||||
|
||||
InFlightRequest()
|
||||
: shutterTimestamp(0),
|
||||
shutterReadoutTimestampValid(false),
|
||||
shutterReadoutTimestamp(0),
|
||||
errorCodeValid(false),
|
||||
errorCode(ErrorCode::ERROR_BUFFER),
|
||||
usePartialResult(false),
|
||||
numPartialResults(0),
|
||||
resultQueue(nullptr),
|
||||
haveResultMetadata(false),
|
||||
numBuffersLeft(0),
|
||||
frameNumber(0),
|
||||
partialResultCount(0),
|
||||
errorStreamId(-1),
|
||||
hasInputBuffer(false),
|
||||
collectedResult(1, 10) {}
|
||||
|
||||
InFlightRequest(ssize_t numBuffers, bool hasInput, bool partialResults,
|
||||
int32_t partialCount, std::shared_ptr<ResultMetadataQueue> queue = nullptr)
|
||||
: shutterTimestamp(0),
|
||||
shutterReadoutTimestampValid(false),
|
||||
shutterReadoutTimestamp(0),
|
||||
errorCodeValid(false),
|
||||
errorCode(ErrorCode::ERROR_BUFFER),
|
||||
usePartialResult(partialResults),
|
||||
numPartialResults(partialCount),
|
||||
resultQueue(queue),
|
||||
haveResultMetadata(false),
|
||||
numBuffersLeft(numBuffers),
|
||||
frameNumber(0),
|
||||
partialResultCount(0),
|
||||
errorStreamId(-1),
|
||||
hasInputBuffer(hasInput),
|
||||
collectedResult(1, 10) {}
|
||||
|
||||
InFlightRequest(ssize_t numBuffers, bool hasInput, bool partialResults,
|
||||
int32_t partialCount,
|
||||
const std::unordered_set<std::string>& extraPhysicalResult,
|
||||
std::shared_ptr<ResultMetadataQueue> queue = nullptr)
|
||||
: shutterTimestamp(0),
|
||||
shutterReadoutTimestampValid(false),
|
||||
shutterReadoutTimestamp(0),
|
||||
errorCodeValid(false),
|
||||
errorCode(ErrorCode::ERROR_BUFFER),
|
||||
usePartialResult(partialResults),
|
||||
numPartialResults(partialCount),
|
||||
resultQueue(queue),
|
||||
haveResultMetadata(false),
|
||||
numBuffersLeft(numBuffers),
|
||||
frameNumber(0),
|
||||
partialResultCount(0),
|
||||
errorStreamId(-1),
|
||||
hasInputBuffer(hasInput),
|
||||
collectedResult(1, 10),
|
||||
expectedPhysicalResults(extraPhysicalResult) {}
|
||||
};
|
||||
|
||||
static bool matchDeviceName(const std::string& deviceName, const std::string& providerType,
|
||||
std::string* deviceVersion, std::string* cameraId);
|
||||
|
||||
static void verify10BitMetadata(
|
||||
HandleImporter& importer, const InFlightRequest& request,
|
||||
aidl::android::hardware::camera::metadata::RequestAvailableDynamicRangeProfilesMap
|
||||
profile);
|
||||
|
||||
// Map from frame number to the in-flight request state
|
||||
typedef std::unordered_map<uint32_t, std::shared_ptr<InFlightRequest>> InFlightMap;
|
||||
|
||||
std::mutex mLock; // Synchronize access to member variables
|
||||
std::condition_variable mResultCondition; // Condition variable for incoming results
|
||||
InFlightMap mInflightMap; // Map of all inflight requests
|
||||
|
||||
std::vector<NotifyMsg> mNotifyMessages; // Current notification message
|
||||
|
||||
std::mutex mTorchLock; // Synchronize access to torch status
|
||||
std::condition_variable mTorchCond; // Condition variable for torch status
|
||||
TorchModeStatus mTorchStatus; // Current torch status
|
||||
|
||||
// Camera provider service
|
||||
std::shared_ptr<ICameraProvider> mProvider;
|
||||
|
||||
// Camera device session used by the tests
|
||||
// Tests should take care of closing this session and setting it back to nullptr in successful
|
||||
// case. Declared as a field to allow TeadDown function to close the session if a test assertion
|
||||
// fails.
|
||||
std::shared_ptr<ICameraDeviceSession> mSession;
|
||||
|
||||
// Camera provider type.
|
||||
std::string mProviderType;
|
||||
|
||||
HandleImporter mHandleImporter;
|
||||
|
||||
friend class DeviceCb;
|
||||
friend class SimpleDeviceCb;
|
||||
friend class TorchProviderCb;
|
||||
};
|
||||
|
||||
namespace {
|
||||
// device@<major>.<minor>/<type>/id
|
||||
const char* kDeviceNameRE = "device@([0-9]+\\.[0-9]+)/\\s+/(.+)";
|
||||
const int32_t kMaxVideoWidth = 4096;
|
||||
const int32_t kMaxVideoHeight = 2160;
|
||||
|
||||
const int64_t kStreamBufferTimeoutSec = 3;
|
||||
const int64_t kTorchTimeoutSec = 1;
|
||||
const char* kDumpOutput = "/dev/null";
|
||||
const uint32_t kMaxPreviewWidth = 1920;
|
||||
const uint32_t kMaxPreviewHeight = 1080;
|
||||
} // namespace
|
||||
#endif // HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_CAMERA_AIDL_TEST_H_
|
||||
544
camera/provider/aidl/vts/device_cb.cpp
Normal file
544
camera/provider/aidl/vts/device_cb.cpp
Normal file
@@ -0,0 +1,544 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "device_cb.h"
|
||||
|
||||
#include <aidl/android/hardware/graphics/common/PixelFormat.h>
|
||||
#include <aidlcommonsupport/NativeHandle.h>
|
||||
#include <grallocusage/GrallocUsageConversion.h>
|
||||
#include <ui/Fence.h>
|
||||
#include <cinttypes>
|
||||
|
||||
using ::aidl::android::hardware::camera::device::BufferStatus;
|
||||
using ::aidl::android::hardware::camera::device::ErrorMsg;
|
||||
using ::aidl::android::hardware::camera::device::StreamBufferRequestError;
|
||||
using ::aidl::android::hardware::camera::device::StreamBuffersVal;
|
||||
using ::aidl::android::hardware::graphics::common::PixelFormat;
|
||||
|
||||
const int64_t kBufferReturnTimeoutSec = 1;
|
||||
|
||||
DeviceCb::DeviceCb(CameraAidlTest* parent, camera_metadata_t* staticMeta) : mParent(parent) {
|
||||
mStaticMetadata = staticMeta;
|
||||
}
|
||||
|
||||
ScopedAStatus DeviceCb::notify(const std::vector<NotifyMsg>& msgs) {
|
||||
std::vector<std::pair<bool, nsecs_t>> readoutTimestamps;
|
||||
|
||||
size_t count = msgs.size();
|
||||
readoutTimestamps.resize(count);
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
const NotifyMsg& msg = msgs[i];
|
||||
switch (msg.getTag()) {
|
||||
case NotifyMsg::Tag::error:
|
||||
readoutTimestamps[i] = {false, 0};
|
||||
break;
|
||||
case NotifyMsg::Tag::shutter:
|
||||
const auto& shutter = msg.get<NotifyMsg::Tag::shutter>();
|
||||
readoutTimestamps[i] = {true, shutter.readoutTimestamp};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return notifyHelper(msgs, readoutTimestamps);
|
||||
}
|
||||
|
||||
ScopedAStatus DeviceCb::processCaptureResult(const std::vector<CaptureResult>& results) {
|
||||
if (nullptr == mParent) {
|
||||
return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
|
||||
}
|
||||
|
||||
bool notify = false;
|
||||
std::unique_lock<std::mutex> l(mParent->mLock);
|
||||
for (const auto& result : results) {
|
||||
notify = processCaptureResultLocked(result, result.physicalCameraMetadata);
|
||||
}
|
||||
|
||||
l.unlock();
|
||||
if (notify) {
|
||||
mParent->mResultCondition.notify_one();
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus DeviceCb::requestStreamBuffers(const std::vector<BufferRequest>& bufReqs,
|
||||
std::vector<StreamBufferRet>* buffers,
|
||||
BufferRequestStatus* _aidl_return) {
|
||||
std::vector<StreamBufferRet>& bufRets = *buffers;
|
||||
std::unique_lock<std::mutex> l(mLock);
|
||||
|
||||
if (!mUseHalBufManager) {
|
||||
ALOGE("%s: Camera does not support HAL buffer management", __FUNCTION__);
|
||||
ADD_FAILURE();
|
||||
*_aidl_return = BufferRequestStatus::FAILED_ILLEGAL_ARGUMENTS;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
if (bufReqs.size() > mStreams.size()) {
|
||||
ALOGE("%s: illegal buffer request: too many requests!", __FUNCTION__);
|
||||
ADD_FAILURE();
|
||||
*_aidl_return = BufferRequestStatus::FAILED_ILLEGAL_ARGUMENTS;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
std::vector<size_t> indexes(bufReqs.size());
|
||||
for (size_t i = 0; i < bufReqs.size(); i++) {
|
||||
bool found = false;
|
||||
for (size_t idx = 0; idx < mStreams.size(); idx++) {
|
||||
if (bufReqs[i].streamId == mStreams[idx].id) {
|
||||
found = true;
|
||||
indexes[i] = idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
ALOGE("%s: illegal buffer request: unknown streamId %d!", __FUNCTION__,
|
||||
bufReqs[i].streamId);
|
||||
ADD_FAILURE();
|
||||
*_aidl_return = BufferRequestStatus::FAILED_ILLEGAL_ARGUMENTS;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
}
|
||||
|
||||
bool allStreamOk = true;
|
||||
bool atLeastOneStreamOk = false;
|
||||
bufRets.resize(bufReqs.size());
|
||||
|
||||
for (size_t i = 0; i < bufReqs.size(); i++) {
|
||||
size_t idx = indexes[i];
|
||||
const auto& stream = mStreams[idx];
|
||||
const auto& halStream = mHalStreams[idx];
|
||||
const BufferRequest& bufReq = bufReqs[i];
|
||||
|
||||
if (mOutstandingBufferIds[idx].size() + bufReq.numBuffersRequested > halStream.maxBuffers) {
|
||||
bufRets[i].streamId = stream.id;
|
||||
bufRets[i].val.set<StreamBuffersVal::Tag::error>(
|
||||
StreamBufferRequestError::MAX_BUFFER_EXCEEDED);
|
||||
allStreamOk = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<StreamBuffer> tmpRetBuffers(bufReq.numBuffersRequested);
|
||||
for (size_t j = 0; j < bufReq.numBuffersRequested; j++) {
|
||||
buffer_handle_t handle;
|
||||
uint32_t w = stream.width;
|
||||
uint32_t h = stream.height;
|
||||
if (stream.format == PixelFormat::BLOB) {
|
||||
w = stream.bufferSize;
|
||||
h = 1;
|
||||
}
|
||||
|
||||
CameraAidlTest::allocateGraphicBuffer(
|
||||
w, h,
|
||||
android_convertGralloc1To0Usage(static_cast<uint64_t>(halStream.producerUsage),
|
||||
static_cast<uint64_t>(halStream.consumerUsage)),
|
||||
halStream.overrideFormat, &handle);
|
||||
|
||||
StreamBuffer streamBuffer = StreamBuffer();
|
||||
StreamBuffer& sb = tmpRetBuffers[j];
|
||||
sb = {
|
||||
stream.id, mNextBufferId, ::android::dupToAidl(handle),
|
||||
BufferStatus::OK, NativeHandle(), NativeHandle(),
|
||||
};
|
||||
|
||||
mOutstandingBufferIds[idx][mNextBufferId++] = ::android::dupToAidl(handle);
|
||||
}
|
||||
atLeastOneStreamOk = true;
|
||||
bufRets[i].streamId = stream.id;
|
||||
bufRets[i].val.set<StreamBuffersVal::Tag::buffers>(std::move(tmpRetBuffers));
|
||||
}
|
||||
|
||||
if (allStreamOk) {
|
||||
*_aidl_return = BufferRequestStatus::OK;
|
||||
} else if (atLeastOneStreamOk) {
|
||||
*_aidl_return = BufferRequestStatus::FAILED_PARTIAL;
|
||||
} else {
|
||||
*_aidl_return = BufferRequestStatus::FAILED_UNKNOWN;
|
||||
}
|
||||
|
||||
if (!hasOutstandingBuffersLocked()) {
|
||||
l.unlock();
|
||||
mFlushedCondition.notify_one();
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus DeviceCb::returnStreamBuffers(const std::vector<StreamBuffer>& buffers) {
|
||||
if (!mUseHalBufManager) {
|
||||
ALOGE("%s: Camera does not support HAL buffer management", __FUNCTION__);
|
||||
ADD_FAILURE();
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> l(mLock);
|
||||
for (const auto& buf : buffers) {
|
||||
if (buf.bufferId == 0) {
|
||||
// Don't return buffers of bufId 0 (empty buffer)
|
||||
continue;
|
||||
}
|
||||
bool found = false;
|
||||
for (size_t idx = 0; idx < mOutstandingBufferIds.size(); idx++) {
|
||||
if (mStreams[idx].id == buf.streamId &&
|
||||
mOutstandingBufferIds[idx].count(buf.bufferId) == 1) {
|
||||
mOutstandingBufferIds[idx].erase(buf.bufferId);
|
||||
// TODO: check do we need to close/delete native handle or assume we have enough
|
||||
// memory to run till the test finish? since we do not capture much requests (and
|
||||
// most of time one buffer is sufficient)
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
continue;
|
||||
}
|
||||
ALOGE("%s: unknown buffer ID %" PRIu64, __FUNCTION__, buf.bufferId);
|
||||
ADD_FAILURE();
|
||||
}
|
||||
if (!hasOutstandingBuffersLocked()) {
|
||||
l.unlock();
|
||||
mFlushedCondition.notify_one();
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
void DeviceCb::setCurrentStreamConfig(const std::vector<Stream>& streams,
|
||||
const std::vector<HalStream>& halStreams) {
|
||||
ASSERT_EQ(streams.size(), halStreams.size());
|
||||
ASSERT_NE(streams.size(), 0);
|
||||
for (size_t i = 0; i < streams.size(); i++) {
|
||||
ASSERT_EQ(streams[i].id, halStreams[i].id);
|
||||
}
|
||||
std::lock_guard<std::mutex> l(mLock);
|
||||
mUseHalBufManager = true;
|
||||
mStreams = streams;
|
||||
mHalStreams = halStreams;
|
||||
mOutstandingBufferIds.clear();
|
||||
for (size_t i = 0; i < streams.size(); i++) {
|
||||
mOutstandingBufferIds.emplace_back();
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceCb::waitForBuffersReturned() {
|
||||
std::unique_lock<std::mutex> lk(mLock);
|
||||
if (hasOutstandingBuffersLocked()) {
|
||||
auto timeout = std::chrono::seconds(kBufferReturnTimeoutSec);
|
||||
auto st = mFlushedCondition.wait_for(lk, timeout);
|
||||
ASSERT_NE(std::cv_status::timeout, st);
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviceCb::processCaptureResultLocked(
|
||||
const CaptureResult& results, std::vector<PhysicalCameraMetadata> physicalCameraMetadata) {
|
||||
bool notify = false;
|
||||
uint32_t frameNumber = results.frameNumber;
|
||||
|
||||
if ((results.result.metadata.empty()) && (results.outputBuffers.empty()) &&
|
||||
(results.inputBuffer.buffer.fds.empty()) && (results.fmqResultSize == 0)) {
|
||||
ALOGE("%s: No result data provided by HAL for frame %d result count: %d", __func__,
|
||||
frameNumber, (int)results.fmqResultSize);
|
||||
ADD_FAILURE();
|
||||
return notify;
|
||||
}
|
||||
|
||||
auto requestEntry = mParent->mInflightMap.find(frameNumber);
|
||||
if (requestEntry == mParent->mInflightMap.end()) {
|
||||
ALOGE("%s: Unexpected frame number! received: %u", __func__, frameNumber);
|
||||
ADD_FAILURE();
|
||||
return notify;
|
||||
}
|
||||
|
||||
bool isPartialResult = false;
|
||||
bool hasInputBufferInRequest = false;
|
||||
auto& request = requestEntry->second;
|
||||
|
||||
CameraMetadata resultMetadata;
|
||||
size_t resultSize = 0;
|
||||
if (results.fmqResultSize > 0) {
|
||||
resultMetadata.metadata.resize(results.fmqResultSize);
|
||||
if (request->resultQueue == nullptr) {
|
||||
ADD_FAILURE();
|
||||
return notify;
|
||||
}
|
||||
|
||||
if (!request->resultQueue->read(reinterpret_cast<int8_t*>(resultMetadata.metadata.data()),
|
||||
results.fmqResultSize)) {
|
||||
ALOGE("%s: Frame %d: Cannot read camera metadata from fmq,"
|
||||
"size = %" PRIu64,
|
||||
__func__, frameNumber, results.fmqResultSize);
|
||||
ADD_FAILURE();
|
||||
return notify;
|
||||
}
|
||||
|
||||
// Physical device results are only expected in the last/final
|
||||
// partial result notification.
|
||||
bool expectPhysicalResults = !(request->usePartialResult &&
|
||||
(results.partialResult < request->numPartialResults));
|
||||
if (expectPhysicalResults &&
|
||||
(physicalCameraMetadata.size() != request->expectedPhysicalResults.size())) {
|
||||
ALOGE("%s: Frame %d: Returned physical metadata count %zu "
|
||||
"must be equal to expected count %zu",
|
||||
__func__, frameNumber, physicalCameraMetadata.size(),
|
||||
request->expectedPhysicalResults.size());
|
||||
ADD_FAILURE();
|
||||
return notify;
|
||||
}
|
||||
std::vector<std::vector<uint8_t>> physResultMetadata;
|
||||
physResultMetadata.resize(physicalCameraMetadata.size());
|
||||
for (size_t i = 0; i < physicalCameraMetadata.size(); i++) {
|
||||
physResultMetadata[i].resize(physicalCameraMetadata[i].fmqMetadataSize);
|
||||
if (!request->resultQueue->read(reinterpret_cast<int8_t*>(physResultMetadata[i].data()),
|
||||
physicalCameraMetadata[i].fmqMetadataSize)) {
|
||||
ALOGE("%s: Frame %d: Cannot read physical camera metadata from fmq,"
|
||||
"size = %" PRIu64,
|
||||
__func__, frameNumber, physicalCameraMetadata[i].fmqMetadataSize);
|
||||
ADD_FAILURE();
|
||||
return notify;
|
||||
}
|
||||
}
|
||||
resultSize = resultMetadata.metadata.size();
|
||||
} else if (!results.result.metadata.empty()) {
|
||||
resultMetadata = results.result;
|
||||
resultSize = resultMetadata.metadata.size();
|
||||
}
|
||||
|
||||
if (!request->usePartialResult && (resultSize > 0) && (results.partialResult != 1)) {
|
||||
ALOGE("%s: Result is malformed for frame %d: partial_result %u "
|
||||
"must be 1 if partial result is not supported",
|
||||
__func__, frameNumber, results.partialResult);
|
||||
ADD_FAILURE();
|
||||
return notify;
|
||||
}
|
||||
|
||||
if (results.partialResult != 0) {
|
||||
request->partialResultCount = results.partialResult;
|
||||
}
|
||||
|
||||
// Check if this result carries only partial metadata
|
||||
if (request->usePartialResult && (resultSize > 0)) {
|
||||
if ((results.partialResult > request->numPartialResults) || (results.partialResult < 1)) {
|
||||
ALOGE("%s: Result is malformed for frame %d: partial_result %u"
|
||||
" must be in the range of [1, %d] when metadata is "
|
||||
"included in the result",
|
||||
__func__, frameNumber, results.partialResult, request->numPartialResults);
|
||||
ADD_FAILURE();
|
||||
return notify;
|
||||
}
|
||||
|
||||
// Verify no duplicate tags between partial results
|
||||
const camera_metadata_t* partialMetadata =
|
||||
reinterpret_cast<const camera_metadata_t*>(resultMetadata.metadata.data());
|
||||
const camera_metadata_t* collectedMetadata = request->collectedResult.getAndLock();
|
||||
camera_metadata_ro_entry_t searchEntry, foundEntry;
|
||||
for (size_t i = 0; i < get_camera_metadata_entry_count(partialMetadata); i++) {
|
||||
if (0 != get_camera_metadata_ro_entry(partialMetadata, i, &searchEntry)) {
|
||||
ADD_FAILURE();
|
||||
request->collectedResult.unlock(collectedMetadata);
|
||||
return notify;
|
||||
}
|
||||
if (-ENOENT !=
|
||||
find_camera_metadata_ro_entry(collectedMetadata, searchEntry.tag, &foundEntry)) {
|
||||
ADD_FAILURE();
|
||||
request->collectedResult.unlock(collectedMetadata);
|
||||
return notify;
|
||||
}
|
||||
}
|
||||
request->collectedResult.unlock(collectedMetadata);
|
||||
request->collectedResult.append(partialMetadata);
|
||||
|
||||
isPartialResult = (results.partialResult < request->numPartialResults);
|
||||
} else if (resultSize > 0) {
|
||||
request->collectedResult.append(
|
||||
reinterpret_cast<const camera_metadata_t*>(resultMetadata.metadata.data()));
|
||||
isPartialResult = false;
|
||||
}
|
||||
|
||||
hasInputBufferInRequest = request->hasInputBuffer;
|
||||
|
||||
// Did we get the (final) result metadata for this capture?
|
||||
if ((resultSize > 0) && !isPartialResult) {
|
||||
if (request->haveResultMetadata) {
|
||||
ALOGE("%s: Called multiple times with metadata for frame %d", __func__, frameNumber);
|
||||
ADD_FAILURE();
|
||||
return notify;
|
||||
}
|
||||
request->haveResultMetadata = true;
|
||||
request->collectedResult.sort();
|
||||
|
||||
// Verify final result metadata
|
||||
auto staticMetadataBuffer = mStaticMetadata;
|
||||
bool isMonochrome = Status::OK == CameraAidlTest::isMonochromeCamera(staticMetadataBuffer);
|
||||
if (isMonochrome) {
|
||||
CameraAidlTest::verifyMonochromeCameraResult(request->collectedResult);
|
||||
}
|
||||
|
||||
// Verify logical camera result metadata
|
||||
bool isLogicalCamera =
|
||||
Status::OK == CameraAidlTest::isLogicalMultiCamera(staticMetadataBuffer);
|
||||
if (isLogicalCamera) {
|
||||
camera_metadata_t* collectedMetadata =
|
||||
const_cast<camera_metadata_t*>(request->collectedResult.getAndLock());
|
||||
uint8_t* rawMetadata = reinterpret_cast<uint8_t*>(collectedMetadata);
|
||||
std::vector metadata = std::vector(
|
||||
rawMetadata, rawMetadata + get_camera_metadata_size(collectedMetadata));
|
||||
CameraAidlTest::verifyLogicalCameraResult(staticMetadataBuffer, metadata);
|
||||
request->collectedResult.unlock(collectedMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t numBuffersReturned = results.outputBuffers.size();
|
||||
auto& inputBuffer = results.inputBuffer.buffer;
|
||||
if (!inputBuffer.fds.empty() && !inputBuffer.ints.empty()) {
|
||||
if (hasInputBufferInRequest) {
|
||||
numBuffersReturned += 1;
|
||||
} else {
|
||||
ALOGW("%s: Input buffer should be NULL if there is no input"
|
||||
" buffer sent in the request",
|
||||
__func__);
|
||||
}
|
||||
}
|
||||
request->numBuffersLeft -= numBuffersReturned;
|
||||
if (request->numBuffersLeft < 0) {
|
||||
ALOGE("%s: Too many buffers returned for frame %d", __func__, frameNumber);
|
||||
ADD_FAILURE();
|
||||
return notify;
|
||||
}
|
||||
|
||||
for (const auto& buffer : results.outputBuffers) {
|
||||
// wait for the fence timestamp and store it along with the buffer
|
||||
// TODO: Check if we really need the dup here
|
||||
android::sp<android::Fence> releaseFence = nullptr;
|
||||
if (buffer.releaseFence.fds.size() == 1 && buffer.releaseFence.fds[0].get() >= 0) {
|
||||
releaseFence = new android::Fence(dup(buffer.releaseFence.fds[0].get()));
|
||||
}
|
||||
|
||||
CameraAidlTest::InFlightRequest::StreamBufferAndTimestamp streamBufferAndTimestamp;
|
||||
streamBufferAndTimestamp.buffer = {buffer.streamId,
|
||||
buffer.bufferId,
|
||||
::android::makeFromAidl(buffer.buffer),
|
||||
buffer.status,
|
||||
::android::makeFromAidl(buffer.acquireFence),
|
||||
::android::makeFromAidl(buffer.releaseFence)};
|
||||
streamBufferAndTimestamp.timeStamp = systemTime();
|
||||
if (releaseFence && releaseFence->isValid()) {
|
||||
releaseFence->wait(/*ms*/ 300);
|
||||
nsecs_t releaseTime = releaseFence->getSignalTime();
|
||||
if (streamBufferAndTimestamp.timeStamp < releaseTime)
|
||||
streamBufferAndTimestamp.timeStamp = releaseTime;
|
||||
}
|
||||
request->resultOutputBuffers.push_back(streamBufferAndTimestamp);
|
||||
}
|
||||
// If shutter event is received notify the pending threads.
|
||||
if (request->shutterTimestamp != 0) {
|
||||
notify = true;
|
||||
}
|
||||
|
||||
if (mUseHalBufManager) {
|
||||
returnStreamBuffers(results.outputBuffers);
|
||||
}
|
||||
return notify;
|
||||
}
|
||||
|
||||
ScopedAStatus DeviceCb::notifyHelper(
|
||||
const std::vector<NotifyMsg>& msgs,
|
||||
const std::vector<std::pair<bool, nsecs_t>>& readoutTimestamps) {
|
||||
std::lock_guard<std::mutex> l(mParent->mLock);
|
||||
|
||||
for (size_t i = 0; i < msgs.size(); i++) {
|
||||
const NotifyMsg& msg = msgs[i];
|
||||
NotifyMsg::Tag msgTag = msgs[i].getTag();
|
||||
switch (msgTag) {
|
||||
case NotifyMsg::Tag::error:
|
||||
if (ErrorCode::ERROR_DEVICE == msg.get<NotifyMsg::Tag::error>().errorCode) {
|
||||
ALOGE("%s: Camera reported serious device error", __func__);
|
||||
ADD_FAILURE();
|
||||
} else {
|
||||
auto itr = mParent->mInflightMap.find(
|
||||
msg.get<NotifyMsg::Tag::error>().frameNumber);
|
||||
if (itr == mParent->mInflightMap.end()) {
|
||||
ALOGE("%s: Unexpected error frame number! received: %u", __func__,
|
||||
msg.get<NotifyMsg::Tag::error>().frameNumber);
|
||||
ADD_FAILURE();
|
||||
break;
|
||||
}
|
||||
|
||||
auto r = itr->second;
|
||||
if (ErrorCode::ERROR_RESULT == msg.get<NotifyMsg::Tag::error>().errorCode &&
|
||||
msg.get<NotifyMsg::Tag::error>().errorStreamId != -1) {
|
||||
if (r->haveResultMetadata) {
|
||||
ALOGE("%s: Camera must report physical camera result error before "
|
||||
"the final capture result!",
|
||||
__func__);
|
||||
ADD_FAILURE();
|
||||
} else {
|
||||
for (auto& mStream : mStreams) {
|
||||
if (mStream.id == msg.get<NotifyMsg::Tag::error>().errorStreamId) {
|
||||
std::string physicalCameraId = mStream.physicalCameraId;
|
||||
bool idExpected =
|
||||
r->expectedPhysicalResults.find(physicalCameraId) !=
|
||||
r->expectedPhysicalResults.end();
|
||||
if (!idExpected) {
|
||||
ALOGE("%s: ERROR_RESULT's error stream's physicalCameraId "
|
||||
"%s must be expected",
|
||||
__func__, physicalCameraId.c_str());
|
||||
ADD_FAILURE();
|
||||
} else {
|
||||
r->expectedPhysicalResults.erase(physicalCameraId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
r->errorCodeValid = true;
|
||||
r->errorCode = msg.get<NotifyMsg::Tag::error>().errorCode;
|
||||
r->errorStreamId = msg.get<NotifyMsg::Tag::error>().errorStreamId;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NotifyMsg::Tag::shutter:
|
||||
auto itr =
|
||||
mParent->mInflightMap.find(msg.get<NotifyMsg::Tag::shutter>().frameNumber);
|
||||
if (itr == mParent->mInflightMap.end()) {
|
||||
ALOGE("%s: Unexpected shutter frame number! received: %u", __func__,
|
||||
msg.get<NotifyMsg::Tag::shutter>().frameNumber);
|
||||
ADD_FAILURE();
|
||||
break;
|
||||
}
|
||||
auto& r = itr->second;
|
||||
r->shutterTimestamp = msg.get<NotifyMsg::Tag::shutter>().timestamp;
|
||||
r->shutterReadoutTimestampValid = readoutTimestamps[i].first;
|
||||
r->shutterReadoutTimestamp = readoutTimestamps[i].second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mParent->mResultCondition.notify_one();
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
bool DeviceCb::hasOutstandingBuffersLocked() {
|
||||
if (!mUseHalBufManager) {
|
||||
return false;
|
||||
}
|
||||
for (const auto& outstandingBuffers : mOutstandingBufferIds) {
|
||||
if (!outstandingBuffers.empty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
82
camera/provider/aidl/vts/device_cb.h
Normal file
82
camera/provider/aidl/vts/device_cb.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_DEVICECB_H_
|
||||
#define HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_DEVICECB_H_
|
||||
|
||||
#include <camera_aidl_test.h>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include <CameraMetadata.h>
|
||||
#include <aidl/android/hardware/camera/device/BnCameraDeviceCallback.h>
|
||||
#include <aidl/android/hardware/camera/device/NotifyMsg.h>
|
||||
|
||||
using ::aidl::android::hardware::camera::device::BnCameraDeviceCallback;
|
||||
using ::aidl::android::hardware::camera::device::BufferRequest;
|
||||
using ::aidl::android::hardware::camera::device::BufferRequestStatus;
|
||||
using ::aidl::android::hardware::camera::device::CaptureResult;
|
||||
using ::aidl::android::hardware::camera::device::HalStream;
|
||||
using ::aidl::android::hardware::camera::device::NotifyMsg;
|
||||
using ::aidl::android::hardware::camera::device::PhysicalCameraMetadata;
|
||||
using ::aidl::android::hardware::camera::device::Stream;
|
||||
using ::aidl::android::hardware::camera::device::StreamBuffer;
|
||||
using ::aidl::android::hardware::camera::device::StreamBufferRet;
|
||||
using ::aidl::android::hardware::common::NativeHandle;
|
||||
|
||||
using ::ndk::ScopedAStatus;
|
||||
|
||||
class CameraAidlTest;
|
||||
|
||||
class DeviceCb : public BnCameraDeviceCallback {
|
||||
public:
|
||||
DeviceCb(CameraAidlTest* parent, camera_metadata_t* staticMeta);
|
||||
ScopedAStatus notify(const std::vector<NotifyMsg>& msgs) override;
|
||||
ScopedAStatus processCaptureResult(const std::vector<CaptureResult>& results) override;
|
||||
ScopedAStatus requestStreamBuffers(const std::vector<BufferRequest>& bufReqs,
|
||||
std::vector<StreamBufferRet>* buffers,
|
||||
BufferRequestStatus* _aidl_return) override;
|
||||
ScopedAStatus returnStreamBuffers(const std::vector<StreamBuffer>& buffers) override;
|
||||
|
||||
void setCurrentStreamConfig(const std::vector<Stream>& streams,
|
||||
const std::vector<HalStream>& halStreams);
|
||||
|
||||
void waitForBuffersReturned();
|
||||
|
||||
private:
|
||||
bool processCaptureResultLocked(const CaptureResult& results,
|
||||
std::vector<PhysicalCameraMetadata> physicalCameraMetadata);
|
||||
ScopedAStatus notifyHelper(const std::vector<NotifyMsg>& msgs,
|
||||
const std::vector<std::pair<bool, nsecs_t>>& readoutTimestamps);
|
||||
|
||||
CameraAidlTest* mParent; // Parent object
|
||||
|
||||
camera_metadata_t* mStaticMetadata;
|
||||
bool hasOutstandingBuffersLocked();
|
||||
|
||||
/* members for requestStreamBuffers() and returnStreamBuffers()*/
|
||||
std::mutex mLock; // protecting members below
|
||||
bool mUseHalBufManager = false;
|
||||
std::vector<Stream> mStreams;
|
||||
std::vector<HalStream> mHalStreams;
|
||||
int64_t mNextBufferId = 1;
|
||||
using OutstandingBuffers = std::unordered_map<uint64_t, NativeHandle>;
|
||||
// size == mStreams.size(). Tracking each streams outstanding buffers
|
||||
std::vector<OutstandingBuffers> mOutstandingBufferIds;
|
||||
std::condition_variable mFlushedCondition;
|
||||
};
|
||||
|
||||
#endif // HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_DEVICECB_H_
|
||||
43
camera/provider/aidl/vts/empty_device_cb.cpp
Normal file
43
camera/provider/aidl/vts/empty_device_cb.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "empty_device_cb.h"
|
||||
#include <log/log.h>
|
||||
|
||||
ScopedAStatus EmptyDeviceCb::notify(const std::vector<NotifyMsg>&) {
|
||||
ALOGI("notify callback");
|
||||
ADD_FAILURE(); // Empty callback should not reach here
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
ScopedAStatus EmptyDeviceCb::processCaptureResult(const std::vector<CaptureResult>&) {
|
||||
ALOGI("processCaptureResult callback");
|
||||
ADD_FAILURE(); // Empty callback should not reach here
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
ScopedAStatus EmptyDeviceCb::requestStreamBuffers(const std::vector<BufferRequest>&,
|
||||
std::vector<StreamBufferRet>*,
|
||||
BufferRequestStatus* _aidl_return) {
|
||||
ALOGI("requestStreamBuffers callback");
|
||||
// HAL might want to request buffer after configureStreams, but tests with EmptyDeviceCb
|
||||
// doesn't actually need to send capture requests, so just return an error.
|
||||
*_aidl_return = BufferRequestStatus::FAILED_UNKNOWN;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
ScopedAStatus EmptyDeviceCb::returnStreamBuffers(const std::vector<StreamBuffer>&) {
|
||||
ALOGI("returnStreamBuffers");
|
||||
ADD_FAILURE(); // Empty callback should not reach here
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
38
camera/provider/aidl/vts/empty_device_cb.h
Normal file
38
camera/provider/aidl/vts/empty_device_cb.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_EMPTY_DEVICE_CB_H_
|
||||
#define HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_EMPTY_DEVICE_CB_H_
|
||||
|
||||
#include <aidl/android/hardware/camera/device/BnCameraDeviceCallback.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using namespace ::aidl::android::hardware::camera::device;
|
||||
|
||||
using ::aidl::android::hardware::camera::device::BnCameraDeviceCallback;
|
||||
using ::ndk::ScopedAStatus;
|
||||
|
||||
class EmptyDeviceCb : public BnCameraDeviceCallback {
|
||||
public:
|
||||
ScopedAStatus notify(const std::vector<NotifyMsg>& msgs) override;
|
||||
ScopedAStatus processCaptureResult(const std::vector<::CaptureResult>& results) override;
|
||||
ScopedAStatus requestStreamBuffers(const std::vector<BufferRequest>& bufReqs,
|
||||
std::vector<StreamBufferRet>* buffers,
|
||||
BufferRequestStatus* _aidl_return) override;
|
||||
ScopedAStatus returnStreamBuffers(const std::vector<StreamBuffer>& buffers) override;
|
||||
};
|
||||
|
||||
#endif // HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_EMPTY_DEVICE_CB_H_
|
||||
36
camera/provider/aidl/vts/simple_device_cb.cpp
Normal file
36
camera/provider/aidl/vts/simple_device_cb.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "simple_device_cb.h"
|
||||
|
||||
ScopedAStatus SimpleDeviceCb::notify(const std::vector<NotifyMsg>& msgs) {
|
||||
std::unique_lock<std::mutex> l(mParent->mLock);
|
||||
mParent->mNotifyMessages = msgs;
|
||||
mParent->mResultCondition.notify_one();
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
ScopedAStatus SimpleDeviceCb::processCaptureResult(const std::vector<CaptureResult>&) {
|
||||
return ndk::ScopedAStatus::fromStatus(STATUS_UNKNOWN_TRANSACTION);
|
||||
}
|
||||
ScopedAStatus SimpleDeviceCb::requestStreamBuffers(const std::vector<BufferRequest>&,
|
||||
std::vector<StreamBufferRet>*,
|
||||
BufferRequestStatus*) {
|
||||
return ndk::ScopedAStatus::fromStatus(STATUS_UNKNOWN_TRANSACTION);
|
||||
}
|
||||
ScopedAStatus SimpleDeviceCb::returnStreamBuffers(const std::vector<StreamBuffer>&) {
|
||||
return ndk::ScopedAStatus::fromStatus(STATUS_UNKNOWN_TRANSACTION);
|
||||
}
|
||||
41
camera/provider/aidl/vts/simple_device_cb.h
Normal file
41
camera/provider/aidl/vts/simple_device_cb.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_SIMPLE_DEVICE_CB_H_
|
||||
#define HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_SIMPLE_DEVICE_CB_H_
|
||||
|
||||
#include "camera_aidl_test.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include <aidl/android/hardware/camera/device/BnCameraDeviceCallback.h>
|
||||
|
||||
using namespace ::aidl::android::hardware::camera::device;
|
||||
|
||||
class SimpleDeviceCb : public BnCameraDeviceCallback {
|
||||
public:
|
||||
ScopedAStatus notify(const std::vector<NotifyMsg>& msgs) override;
|
||||
ScopedAStatus processCaptureResult(const std::vector<CaptureResult>& results) override;
|
||||
ScopedAStatus requestStreamBuffers(const std::vector<BufferRequest>& bufReqs,
|
||||
std::vector<StreamBufferRet>* buffers,
|
||||
BufferRequestStatus* _aidl_return) override;
|
||||
virtual ScopedAStatus returnStreamBuffers(const std::vector<StreamBuffer>& buffers) override;
|
||||
|
||||
private:
|
||||
CameraAidlTest* mParent;
|
||||
};
|
||||
|
||||
#endif // HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_SIMPLE_DEVICE_CB_H_
|
||||
40
camera/provider/aidl/vts/torch_provider_cb.cpp
Normal file
40
camera/provider/aidl/vts/torch_provider_cb.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "torch_provider_cb.h"
|
||||
|
||||
TorchProviderCb::TorchProviderCb(CameraAidlTest* parent) {
|
||||
mParent = parent;
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus TorchProviderCb::torchModeStatusChange(const std::string&,
|
||||
TorchModeStatus newStatus) {
|
||||
std::lock_guard<std::mutex> l(mParent->mTorchLock);
|
||||
mParent->mTorchStatus = newStatus;
|
||||
mParent->mTorchCond.notify_one();
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
ScopedAStatus TorchProviderCb::cameraDeviceStatusChange(
|
||||
const std::string&, ::aidl::android::hardware::camera::common::CameraDeviceStatus) {
|
||||
// Should not be called
|
||||
return ndk::ScopedAStatus::fromStatus(STATUS_UNKNOWN_TRANSACTION);
|
||||
}
|
||||
ScopedAStatus TorchProviderCb::physicalCameraDeviceStatusChange(
|
||||
const std::string&, const std::string&,
|
||||
::aidl::android::hardware::camera::common::CameraDeviceStatus) {
|
||||
// Should not be called
|
||||
return ndk::ScopedAStatus::fromStatus(STATUS_UNKNOWN_TRANSACTION);
|
||||
}
|
||||
44
camera/provider/aidl/vts/torch_provider_cb.h
Normal file
44
camera/provider/aidl/vts/torch_provider_cb.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_TORCH_PROVIDER_CB_H_
|
||||
#define HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_TORCH_PROVIDER_CB_H_
|
||||
|
||||
#import <aidl/android/hardware/camera/provider/BnCameraProviderCallback.h>
|
||||
#import <camera_aidl_test.h>
|
||||
|
||||
using ::aidl::android::hardware::camera::common::TorchModeStatus;
|
||||
using ::aidl::android::hardware::camera::provider::BnCameraProviderCallback;
|
||||
|
||||
class TorchProviderCb : public BnCameraProviderCallback {
|
||||
public:
|
||||
TorchProviderCb(CameraAidlTest* parent);
|
||||
ndk::ScopedAStatus torchModeStatusChange(const std::string& cameraDeviceName,
|
||||
TorchModeStatus newStatus) override;
|
||||
|
||||
ScopedAStatus cameraDeviceStatusChange(
|
||||
const std::string& in_cameraDeviceName,
|
||||
::aidl::android::hardware::camera::common::CameraDeviceStatus in_newStatus) override;
|
||||
|
||||
ScopedAStatus physicalCameraDeviceStatusChange(
|
||||
const std::string& in_cameraDeviceName, const std::string& in_physicalCameraDeviceName,
|
||||
::aidl::android::hardware::camera::common::CameraDeviceStatus in_newStatus) override;
|
||||
|
||||
private:
|
||||
CameraAidlTest* mParent;
|
||||
};
|
||||
|
||||
#endif // HARDWARE_INTERFACES_CAMERA_PROVIDER_AIDL_VTS_TORCH_PROVIDER_CB_H_
|
||||
Reference in New Issue
Block a user