Camera: Add ICameraProviderCallback version 2.6

The new version adds callback for physical sub-camera status callback.

Test: VtsHalCameraProviderV2_4TargetTest --hal_service_instance=android.hardware.camera.provider@2.6::ICameraProvider/internal/1
Bug: 119325027
Change-Id: I8148f6c55f80d7f4092d2fe5ccf92509bb8c069d
This commit is contained in:
Shuzhen Wang
2020-01-10 12:43:08 -08:00
parent 151e81a191
commit 05066109ff
9 changed files with 173 additions and 13 deletions

View File

@@ -115,7 +115,7 @@ interface ICameraProvider {
* INTERNAL_ERROR:
* A camera ID list cannot be created. This may be due to
* a failure to initialize the camera subsystem, for example.
* @return cameraDeviceServiceNames The vector of internal camera device
* @return cameraDeviceNames The vector of internal camera device
* names known to this provider.
*/
getCameraIdList()

View File

@@ -39,7 +39,7 @@ interface ICameraProviderCallback {
* are already present, as soon as the callbacks are available through
* setCallback.
*
* @param cameraDeviceServiceName The name of the camera device that has a
* @param cameraDeviceName The name of the camera device that has a
* new status.
* @param newStatus The new status that device is in.
*
@@ -57,7 +57,7 @@ interface ICameraProviderCallback {
* android.flash.info.available is reported as true via the
* ICameraDevice::getCameraCharacteristics call.
*
* @param cameraDeviceServiceName The name of the camera device that has a
* @param cameraDeviceName The name of the camera device that has a
* new status.
* @param newStatus The new status that device is in.
*

View File

@@ -41,6 +41,7 @@ cc_test {
"android.hardware.camera.metadata@3.4",
"android.hardware.camera.provider@2.4",
"android.hardware.camera.provider@2.5",
"android.hardware.camera.provider@2.6",
"android.hardware.graphics.common@1.0",
"android.hidl.allocator@1.0",
"libgrallocusage",

View File

@@ -40,15 +40,17 @@
#include <android/hardware/camera/metadata/3.4/types.h>
#include <android/hardware/camera/provider/2.4/ICameraProvider.h>
#include <android/hardware/camera/provider/2.5/ICameraProvider.h>
#include <android/hardware/camera/provider/2.6/ICameraProvider.h>
#include <android/hardware/camera/provider/2.6/ICameraProviderCallback.h>
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <binder/MemoryHeapBase.h>
#include <cutils/properties.h>
#include <fmq/MessageQueue.h>
#include <grallocusage/GrallocUsageConversion.h>
#include <gtest/gtest.h>
#include <gui/BufferItemConsumer.h>
#include <gui/BufferQueue.h>
#include <gui/Surface.h>
#include <gtest/gtest.h>
#include <hardware/gralloc.h>
#include <hardware/gralloc1.h>
#include <hidl/GtestPrinter.h>
@@ -537,7 +539,7 @@ public:
uint32_t id;
ASSERT_TRUE(parseProviderName(service_name, &mProviderType, &id));
castProvider(mProvider, &mProvider2_5);
castProvider(mProvider, &mProvider2_5, &mProvider2_6);
notifyDeviceState(provider::V2_5::DeviceState::NORMAL);
}
virtual void TearDown() override {}
@@ -709,8 +711,9 @@ public:
sp<ICameraDeviceSession> *session /*out*/,
camera_metadata_t **staticMeta /*out*/,
::android::sp<ICameraDevice> *device = nullptr/*out*/);
void castProvider(const sp<provider::V2_4::ICameraProvider> &provider,
sp<provider::V2_5::ICameraProvider> *provider2_5 /*out*/);
void castProvider(const sp<provider::V2_4::ICameraProvider>& provider,
sp<provider::V2_5::ICameraProvider>* provider2_5 /*out*/,
sp<provider::V2_6::ICameraProvider>* provider2_6 /*out*/);
void castSession(const sp<ICameraDeviceSession> &session, int32_t deviceVersion,
sp<device::V3_3::ICameraDeviceSession> *session3_3 /*out*/,
sp<device::V3_4::ICameraDeviceSession> *session3_4 /*out*/,
@@ -937,6 +940,7 @@ protected:
// Camera provider service
sp<ICameraProvider> mProvider;
sp<::android::hardware::camera::provider::V2_5::ICameraProvider> mProvider2_5;
sp<::android::hardware::camera::provider::V2_6::ICameraProvider> mProvider2_6;
// Camera provider type.
std::string mProviderType;
@@ -1649,6 +1653,33 @@ TEST_P(CameraHidlTest, setCallback) {
return Void();
}
};
struct ProviderCb2_6
: public ::android::hardware::camera::provider::V2_6::ICameraProviderCallback {
virtual Return<void> cameraDeviceStatusChange(const hidl_string& cameraDeviceName,
CameraDeviceStatus newStatus) override {
ALOGI("camera device status callback name %s, status %d", cameraDeviceName.c_str(),
(int)newStatus);
return Void();
}
virtual Return<void> torchModeStatusChange(const hidl_string& cameraDeviceName,
TorchModeStatus newStatus) override {
ALOGI("Torch mode status callback name %s, status %d", cameraDeviceName.c_str(),
(int)newStatus);
return Void();
}
virtual Return<void> physicalCameraDeviceStatusChange(
const hidl_string& cameraDeviceName, const hidl_string& physicalCameraDeviceName,
CameraDeviceStatus newStatus) override {
ALOGI("physical camera device status callback name %s, physical camera name %s,"
" status %d",
cameraDeviceName.c_str(), physicalCameraDeviceName.c_str(), (int)newStatus);
return Void();
}
};
sp<ProviderCb> cb = new ProviderCb;
auto status = mProvider->setCallback(cb);
ASSERT_TRUE(status.isOk());
@@ -1656,6 +1687,16 @@ TEST_P(CameraHidlTest, setCallback) {
status = mProvider->setCallback(nullptr);
ASSERT_TRUE(status.isOk());
ASSERT_EQ(Status::OK, status);
if (mProvider2_6.get() != nullptr) {
sp<ProviderCb2_6> cb = new ProviderCb2_6;
auto status = mProvider2_6->setCallback(cb);
ASSERT_TRUE(status.isOk());
ASSERT_EQ(Status::OK, status);
status = mProvider2_6->setCallback(nullptr);
ASSERT_TRUE(status.isOk());
ASSERT_EQ(Status::OK, status);
}
}
// Test if ICameraProvider::getCameraDeviceInterface returns Status::OK and non-null device
@@ -5596,12 +5637,19 @@ void CameraHidlTest::castDevice(const sp<device::V3_2::ICameraDevice> &device,
}
//Cast camera provider to corresponding version if available
void CameraHidlTest::castProvider(const sp<ICameraProvider> &provider,
sp<provider::V2_5::ICameraProvider> *provider2_5 /*out*/) {
void CameraHidlTest::castProvider(const sp<ICameraProvider>& provider,
sp<provider::V2_5::ICameraProvider>* provider2_5 /*out*/,
sp<provider::V2_6::ICameraProvider>* provider2_6 /*out*/) {
ASSERT_NE(nullptr, provider2_5);
auto castResult = provider::V2_5::ICameraProvider::castFrom(provider);
if (castResult.isOk()) {
*provider2_5 = castResult;
auto castResult2_5 = provider::V2_5::ICameraProvider::castFrom(provider);
if (castResult2_5.isOk()) {
*provider2_5 = castResult2_5;
}
ASSERT_NE(nullptr, provider2_6);
auto castResult2_6 = provider::V2_6::ICameraProvider::castFrom(provider);
if (castResult2_6.isOk()) {
*provider2_6 = castResult2_6;
}
}

View File

@@ -0,0 +1,25 @@
// This file is autogenerated by hidl-gen -Landroidbp.
hidl_interface {
name: "android.hardware.camera.provider@2.6",
root: "android.hardware",
vndk: {
enabled: true,
},
srcs: [
"ICameraProvider.hal",
"ICameraProviderCallback.hal",
],
interfaces: [
"android.hardware.camera.common@1.0",
"android.hardware.camera.device@1.0",
"android.hardware.camera.device@3.2",
"android.hardware.camera.device@3.3",
"android.hardware.camera.device@3.4",
"android.hardware.camera.provider@2.4",
"android.hardware.camera.provider@2.5",
"android.hardware.graphics.common@1.0",
"android.hidl.base@1.0",
],
gen_java: false,
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright (C) 2020 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 android.hardware.camera.provider@2.6;
import @2.5::ICameraProvider;
/**
* Camera provider HAL
*/
interface ICameraProvider extends @2.5::ICameraProvider {
/**
* @2.4::ICameraProvider::setCallback can be passed a
* @2.6::ICameraProviderCallback to receive physical camera availability
* callbacks for logical multi-cameras.
*/
};

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2020 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 android.hardware.camera.provider@2.6;
import android.hardware.camera.common@1.0::types;
import android.hardware.camera.provider@2.4::ICameraProviderCallback;
/**
* Callback functions for a camera provider HAL to use to inform the camera
* service of changes to the camera subsystem.
*
* Version 2.6 adds support for physical camera device status callback for
* multi-camera.
*/
interface ICameraProviderCallback extends @2.4::ICameraProviderCallback {
/**
* cameraPhysicalDeviceStatusChange:
*
* Callback to the camera service to indicate that the state of a physical
* camera device of a logical multi-camera has changed.
*
* On camera service startup, when ICameraProvider::setCallback is invoked,
* the camera service must assume that all physical devices backing internal
* multi-camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state.
*
* The provider must call this method to inform the camera service of any
* initially NOT_PRESENT physical devices, as soon as the callbacks are available
* through setCallback.
*
* @param cameraDeviceName The name of the logical multi-camera whose
* physical camera has a new status.
* @param physicalCameraDeviceName The name of the physical camera device
* that has a new status.
* @param newStatus The new status that device is in.
*
*/
physicalCameraDeviceStatusChange(string cameraDeviceName,
string physicalCameraDeviceName, CameraDeviceStatus newStatus);
};

View File

@@ -122,7 +122,7 @@
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.camera.provider</name>
<version>2.4-5</version>
<version>2.4-6</version>
<interface>
<name>ICameraProvider</name>
<regex-instance>[^/]+/[0-9]+</regex-instance>

View File

@@ -588,6 +588,8 @@ d3a344b7bd4c0d2658ae7209f55a979b8f53f361fd00f4fca29d5baa56d11fd2 android.hardwar
cd06a7911b9acd4a653bbf7133888878fbcb3f84be177c7a3f1becaae3d8618f android.hardware.camera.metadata@3.2::types
a05277065c28ebecd58118bd240fb8c55757361e8648c01f7c4dacdb7f2a95dc android.hardware.camera.metadata@3.3::types
9cb3df2bde2c6cd5fd96b7c41555420cacd7e276a556c684af91b7461c86460f android.hardware.gnss@1.0::IGnssCallback
bceee81ec1b59324abd05932b5620fda5a6589597c9cb3953ba7f3ea02cccd3e android.hardware.camera.provider@2.4::ICameraProvider
2ce820dc4f3c6d85721b65150ed2157c6e2e2055f866fb6c6ba4790f14408d66 android.hardware.camera.provider@2.4::ICameraProviderCallback
b69a7615c508acf5c5201efd1bfa3262167874fc3594e2db5a3ff93addd8ac75 android.hardware.keymaster@4.0::IKeymasterDevice
eb2fa0c883c2185d514be0b84c179b283753ef0c1b77b45b4f359bd23bba8b75 android.hardware.neuralnetworks@1.0::IPreparedModel
8eac60e1f724d141c71c69f06d4544acb720a55dfbbcd97fa01bb3d25ee4e2f5 android.hardware.neuralnetworks@1.0::types