Merge changes from topic "vts-secure-only-camera" into rvc-dev am: ec37ce4947
am: 1487a9ebb3
am: acc8d9c7ce
Original change: undetermined Change-Id: Ie8ac640400e1de5c129cadff1b3e87936e582002
This commit is contained in:
commit
2d71ac4ea6
1 changed files with 107 additions and 24 deletions
|
@ -575,7 +575,10 @@ public:
|
|||
}
|
||||
virtual void TearDown() override {}
|
||||
|
||||
hidl_vec<hidl_string> getCameraDeviceNames(sp<ICameraProvider> provider);
|
||||
hidl_vec<hidl_string> getCameraDeviceNames(sp<ICameraProvider> provider,
|
||||
bool addSecureOnly = false);
|
||||
|
||||
bool isSecureOnly(sp<ICameraProvider> provider, const hidl_string& name);
|
||||
|
||||
std::map<hidl_string, hidl_string> getCameraDeviceIdToNameMap(sp<ICameraProvider> provider);
|
||||
|
||||
|
@ -799,6 +802,16 @@ public:
|
|||
bool *useHalBufManager /*out*/,
|
||||
sp<DeviceCb> *cb /*out*/,
|
||||
uint32_t streamConfigCounter = 0);
|
||||
void configureSingleStream(const std::string& name, int32_t deviceVersion,
|
||||
sp<ICameraProvider> provider,
|
||||
const AvailableStream* previewThreshold, uint64_t bufferUsage,
|
||||
RequestTemplate reqTemplate,
|
||||
sp<ICameraDeviceSession>* session /*out*/,
|
||||
V3_2::Stream* previewStream /*out*/,
|
||||
HalStreamConfiguration* halStreamConfig /*out*/,
|
||||
bool* supportsPartialResults /*out*/,
|
||||
uint32_t* partialResultCount /*out*/, bool* useHalBufManager /*out*/,
|
||||
sp<DeviceCb>* cb /*out*/, uint32_t streamConfigCounter = 0);
|
||||
|
||||
void verifyLogicalCameraMetadata(const std::string& cameraName,
|
||||
const ::android::sp<::android::hardware::camera::device::V3_2::ICameraDevice>& device,
|
||||
|
@ -875,6 +888,9 @@ public:
|
|||
static Status getSystemCameraKind(const camera_metadata_t* staticMeta,
|
||||
SystemCameraKind* systemCameraKind);
|
||||
|
||||
void processCaptureRequestInternal(uint64_t bufferusage, RequestTemplate reqTemplate,
|
||||
bool useSecureOnlyCameras);
|
||||
|
||||
// Used by switchToOffline where a new result queue is created for offline reqs
|
||||
void updateInflightResultQueue(std::shared_ptr<ResultMetadataQueue> resultQueue);
|
||||
|
||||
|
@ -1585,7 +1601,8 @@ std::map<hidl_string, hidl_string> CameraHidlTest::getCameraDeviceIdToNameMap(
|
|||
return idToNameMap;
|
||||
}
|
||||
|
||||
hidl_vec<hidl_string> CameraHidlTest::getCameraDeviceNames(sp<ICameraProvider> provider) {
|
||||
hidl_vec<hidl_string> CameraHidlTest::getCameraDeviceNames(sp<ICameraProvider> provider,
|
||||
bool addSecureOnly) {
|
||||
std::vector<std::string> cameraDeviceNames;
|
||||
Return<void> ret;
|
||||
ret = provider->getCameraIdList(
|
||||
|
@ -1634,11 +1651,51 @@ hidl_vec<hidl_string> CameraHidlTest::getCameraDeviceNames(sp<ICameraProvider> p
|
|||
}
|
||||
}
|
||||
|
||||
hidl_vec<hidl_string> retList(cameraDeviceNames.size());
|
||||
std::vector<hidl_string> retList;
|
||||
for (size_t i = 0; i < cameraDeviceNames.size(); i++) {
|
||||
retList[i] = cameraDeviceNames[i];
|
||||
bool isSecureOnlyCamera = isSecureOnly(mProvider, cameraDeviceNames[i]);
|
||||
if (addSecureOnly) {
|
||||
if (isSecureOnlyCamera) {
|
||||
retList.emplace_back(cameraDeviceNames[i]);
|
||||
}
|
||||
} else if (!isSecureOnlyCamera) {
|
||||
retList.emplace_back(cameraDeviceNames[i]);
|
||||
}
|
||||
}
|
||||
return retList;
|
||||
hidl_vec<hidl_string> finalRetList = std::move(retList);
|
||||
return finalRetList;
|
||||
}
|
||||
|
||||
bool CameraHidlTest::isSecureOnly(sp<ICameraProvider> provider, const hidl_string& name) {
|
||||
Return<void> ret;
|
||||
::android::sp<ICameraDevice> device3_x;
|
||||
bool retVal = false;
|
||||
if (getCameraDeviceVersion(mProviderType, name) == CAMERA_DEVICE_API_VERSION_1_0) {
|
||||
return false;
|
||||
}
|
||||
ret = provider->getCameraDeviceInterface_V3_x(name, [&](auto status, const auto& device) {
|
||||
ALOGI("getCameraDeviceInterface_V3_x returns status:%d", (int)status);
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
ASSERT_NE(device, nullptr);
|
||||
device3_x = device;
|
||||
});
|
||||
if (!ret.isOk()) {
|
||||
ADD_FAILURE() << "Failed to get camera device interface for " << name;
|
||||
}
|
||||
ret = device3_x->getCameraCharacteristics([&](Status s, CameraMetadata metadata) {
|
||||
ASSERT_EQ(Status::OK, s);
|
||||
camera_metadata_t* chars = (camera_metadata_t*)metadata.data();
|
||||
SystemCameraKind systemCameraKind = SystemCameraKind::PUBLIC;
|
||||
Status status = getSystemCameraKind(chars, &systemCameraKind);
|
||||
ASSERT_EQ(status, Status::OK);
|
||||
if (systemCameraKind == SystemCameraKind::HIDDEN_SECURE_CAMERA) {
|
||||
retVal = true;
|
||||
}
|
||||
});
|
||||
if (!ret.isOk()) {
|
||||
ADD_FAILURE() << "Failed to get camera characteristics for device " << name;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
hidl_vec<hidl_vec<hidl_string>> CameraHidlTest::getConcurrentDeviceCombinations(
|
||||
|
@ -4316,8 +4373,21 @@ TEST_P(CameraHidlTest, configureStreamsVideoStillOutputs) {
|
|||
|
||||
// Generate and verify a camera capture request
|
||||
TEST_P(CameraHidlTest, processCaptureRequestPreview) {
|
||||
hidl_vec<hidl_string> cameraDeviceNames = getCameraDeviceNames(mProvider);
|
||||
AvailableStream previewThreshold = {kMaxPreviewWidth, kMaxPreviewHeight,
|
||||
processCaptureRequestInternal(GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, RequestTemplate::PREVIEW,
|
||||
false /*secureOnlyCameras*/);
|
||||
}
|
||||
|
||||
// Generate and verify a secure camera capture request
|
||||
TEST_P(CameraHidlTest, processSecureCaptureRequest) {
|
||||
processCaptureRequestInternal(GRALLOC1_PRODUCER_USAGE_PROTECTED, RequestTemplate::STILL_CAPTURE,
|
||||
true /*secureOnlyCameras*/);
|
||||
}
|
||||
|
||||
void CameraHidlTest::processCaptureRequestInternal(uint64_t bufferUsage,
|
||||
RequestTemplate reqTemplate,
|
||||
bool useSecureOnlyCameras) {
|
||||
hidl_vec<hidl_string> cameraDeviceNames = getCameraDeviceNames(mProvider, useSecureOnlyCameras);
|
||||
AvailableStream streamThreshold = {kMaxPreviewWidth, kMaxPreviewHeight,
|
||||
static_cast<int32_t>(PixelFormat::IMPLEMENTATION_DEFINED)};
|
||||
uint64_t bufferId = 1;
|
||||
uint32_t frameNumber = 1;
|
||||
|
@ -4333,17 +4403,17 @@ TEST_P(CameraHidlTest, processCaptureRequestPreview) {
|
|||
return;
|
||||
}
|
||||
|
||||
V3_2::Stream previewStream;
|
||||
V3_2::Stream testStream;
|
||||
HalStreamConfiguration halStreamConfig;
|
||||
sp<ICameraDeviceSession> session;
|
||||
sp<DeviceCb> cb;
|
||||
bool supportsPartialResults = false;
|
||||
bool useHalBufManager = false;
|
||||
uint32_t partialResultCount = 0;
|
||||
configurePreviewStream(name, deviceVersion, mProvider, &previewThreshold, &session /*out*/,
|
||||
&previewStream /*out*/, &halStreamConfig /*out*/,
|
||||
&supportsPartialResults /*out*/,
|
||||
&partialResultCount /*out*/, &useHalBufManager /*out*/, &cb /*out*/);
|
||||
configureSingleStream(name, deviceVersion, mProvider, &streamThreshold, bufferUsage,
|
||||
reqTemplate, &session /*out*/, &testStream /*out*/,
|
||||
&halStreamConfig /*out*/, &supportsPartialResults /*out*/,
|
||||
&partialResultCount /*out*/, &useHalBufManager /*out*/, &cb /*out*/);
|
||||
|
||||
std::shared_ptr<ResultMetadataQueue> resultQueue;
|
||||
auto resultQueueRet =
|
||||
|
@ -4364,7 +4434,6 @@ TEST_P(CameraHidlTest, processCaptureRequestPreview) {
|
|||
InFlightRequest inflightReq = {1, false, supportsPartialResults,
|
||||
partialResultCount, resultQueue};
|
||||
|
||||
RequestTemplate reqTemplate = RequestTemplate::PREVIEW;
|
||||
Return<void> ret;
|
||||
ret = session->constructDefaultRequestSettings(reqTemplate,
|
||||
[&](auto status, const auto& req) {
|
||||
|
@ -4383,7 +4452,7 @@ TEST_P(CameraHidlTest, processCaptureRequestPreview) {
|
|||
nullptr,
|
||||
nullptr};
|
||||
} else {
|
||||
allocateGraphicBuffer(previewStream.width, previewStream.height,
|
||||
allocateGraphicBuffer(testStream.width, testStream.height,
|
||||
android_convertGralloc1To0Usage(halStreamConfig.streams[0].producerUsage,
|
||||
halStreamConfig.streams[0].consumerUsage),
|
||||
halStreamConfig.streams[0].overrideFormat, &buffer_handle);
|
||||
|
@ -4432,7 +4501,7 @@ TEST_P(CameraHidlTest, processCaptureRequestPreview) {
|
|||
|
||||
ASSERT_FALSE(inflightReq.errorCodeValid);
|
||||
ASSERT_NE(inflightReq.resultOutputBuffers.size(), 0u);
|
||||
ASSERT_EQ(previewStream.id, inflightReq.resultOutputBuffers[0].streamId);
|
||||
ASSERT_EQ(testStream.id, inflightReq.resultOutputBuffers[0].streamId);
|
||||
|
||||
request.frameNumber++;
|
||||
// Empty settings should be supported after the first call
|
||||
|
@ -4470,11 +4539,11 @@ TEST_P(CameraHidlTest, processCaptureRequestPreview) {
|
|||
|
||||
ASSERT_FALSE(inflightReq.errorCodeValid);
|
||||
ASSERT_NE(inflightReq.resultOutputBuffers.size(), 0u);
|
||||
ASSERT_EQ(previewStream.id, inflightReq.resultOutputBuffers[0].streamId);
|
||||
ASSERT_EQ(testStream.id, inflightReq.resultOutputBuffers[0].streamId);
|
||||
}
|
||||
|
||||
if (useHalBufManager) {
|
||||
verifyBuffersReturned(session, deviceVersion, previewStream.id, cb);
|
||||
verifyBuffersReturned(session, deviceVersion, testStream.id, cb);
|
||||
}
|
||||
|
||||
ret = session->close();
|
||||
|
@ -6278,6 +6347,19 @@ void CameraHidlTest::configurePreviewStream(const std::string &name, int32_t dev
|
|||
bool *useHalBufManager /*out*/,
|
||||
sp<DeviceCb> *outCb /*out*/,
|
||||
uint32_t streamConfigCounter) {
|
||||
configureSingleStream(name, deviceVersion, provider, previewThreshold,
|
||||
GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, RequestTemplate::PREVIEW, session,
|
||||
previewStream, halStreamConfig, supportsPartialResults,
|
||||
partialResultCount, useHalBufManager, outCb, streamConfigCounter);
|
||||
}
|
||||
// Open a device session and configure a preview stream.
|
||||
void CameraHidlTest::configureSingleStream(
|
||||
const std::string& name, int32_t deviceVersion, sp<ICameraProvider> provider,
|
||||
const AvailableStream* previewThreshold, uint64_t bufferUsage, RequestTemplate reqTemplate,
|
||||
sp<ICameraDeviceSession>* session /*out*/, V3_2::Stream* previewStream /*out*/,
|
||||
HalStreamConfiguration* halStreamConfig /*out*/, bool* supportsPartialResults /*out*/,
|
||||
uint32_t* partialResultCount /*out*/, bool* useHalBufManager /*out*/,
|
||||
sp<DeviceCb>* outCb /*out*/, uint32_t streamConfigCounter) {
|
||||
ASSERT_NE(nullptr, session);
|
||||
ASSERT_NE(nullptr, previewStream);
|
||||
ASSERT_NE(nullptr, halStreamConfig);
|
||||
|
@ -6366,11 +6448,14 @@ void CameraHidlTest::configurePreviewStream(const std::string &name, int32_t dev
|
|||
dataspaceFlag = static_cast<V3_2::DataspaceFlags>(Dataspace::UNKNOWN);
|
||||
}
|
||||
|
||||
V3_2::Stream stream3_2 = {0, StreamType::OUTPUT,
|
||||
static_cast<uint32_t> (outputPreviewStreams[0].width),
|
||||
static_cast<uint32_t> (outputPreviewStreams[0].height),
|
||||
static_cast<PixelFormat> (outputPreviewStreams[0].format),
|
||||
GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, dataspaceFlag, StreamRotation::ROTATION_0};
|
||||
V3_2::Stream stream3_2 = {0,
|
||||
StreamType::OUTPUT,
|
||||
static_cast<uint32_t>(outputPreviewStreams[0].width),
|
||||
static_cast<uint32_t>(outputPreviewStreams[0].height),
|
||||
static_cast<PixelFormat>(outputPreviewStreams[0].format),
|
||||
bufferUsage,
|
||||
dataspaceFlag,
|
||||
StreamRotation::ROTATION_0};
|
||||
::android::hardware::hidl_vec<V3_2::Stream> streams3_2 = {stream3_2};
|
||||
::android::hardware::camera::device::V3_2::StreamConfiguration config3_2;
|
||||
::android::hardware::camera::device::V3_4::StreamConfiguration config3_4;
|
||||
|
@ -6378,7 +6463,6 @@ void CameraHidlTest::configurePreviewStream(const std::string &name, int32_t dev
|
|||
createStreamConfiguration(streams3_2, StreamConfigurationMode::NORMAL_MODE,
|
||||
&config3_2, &config3_4, &config3_5, jpegBufferSize);
|
||||
if (session3_5 != nullptr) {
|
||||
RequestTemplate reqTemplate = RequestTemplate::PREVIEW;
|
||||
ret = session3_5->constructDefaultRequestSettings(reqTemplate,
|
||||
[&config3_5](auto status, const auto& req) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
|
@ -6401,7 +6485,6 @@ void CameraHidlTest::configurePreviewStream(const std::string &name, int32_t dev
|
|||
}
|
||||
});
|
||||
} else if (session3_4 != nullptr) {
|
||||
RequestTemplate reqTemplate = RequestTemplate::PREVIEW;
|
||||
ret = session3_4->constructDefaultRequestSettings(reqTemplate,
|
||||
[&config3_4](auto status, const auto& req) {
|
||||
ASSERT_EQ(Status::OK, status);
|
||||
|
|
Loading…
Reference in a new issue