Merge changes from topic 'device_version_cleanup' into oc-dev

am: 3176e6ebb9

Change-Id: I02d4b35bd0e74c5569de7425ea1baaab0cde45f9
This commit is contained in:
Emilian Peev 2017-04-27 23:59:53 +00:00 committed by android-build-merger
commit 5649a3df94
2 changed files with 49 additions and 0 deletions

View file

@ -207,6 +207,20 @@ bool CameraProvider::initialize() {
mNumberOfLegacyCameras = mModule->getNumberOfCameras();
for (int i = 0; i < mNumberOfLegacyCameras; i++) {
struct camera_info info;
auto rc = mModule->getCameraInfo(i, &info);
if (rc != NO_ERROR) {
ALOGE("%s: Camera info query failed!", __func__);
mModule.clear();
return true;
}
if (checkCameraVersion(i, info) != OK) {
ALOGE("%s: Camera version check failed!", __func__);
mModule.clear();
return true;
}
char cameraId[kMaxCameraIdLen];
snprintf(cameraId, sizeof(cameraId), "%d", i);
std::string cameraIdStr(cameraId);
@ -242,6 +256,40 @@ bool CameraProvider::initialize() {
return false; // mInitFailed
}
/**
* Check that the device HAL version is still in supported.
*/
int CameraProvider::checkCameraVersion(int id, camera_info info) {
if (mModule == nullptr) {
return NO_INIT;
}
// device_version undefined in CAMERA_MODULE_API_VERSION_1_0,
// All CAMERA_MODULE_API_VERSION_1_0 devices are backward-compatible
if (mModule->getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_0) {
// Verify the device version is in the supported range
switch (info.device_version) {
case CAMERA_DEVICE_API_VERSION_1_0:
case CAMERA_DEVICE_API_VERSION_3_2:
case CAMERA_DEVICE_API_VERSION_3_3:
case CAMERA_DEVICE_API_VERSION_3_4:
// in support
break;
case CAMERA_DEVICE_API_VERSION_2_0:
case CAMERA_DEVICE_API_VERSION_2_1:
case CAMERA_DEVICE_API_VERSION_3_0:
case CAMERA_DEVICE_API_VERSION_3_1:
// no longer supported
default:
ALOGE("%s: Device %d has HAL version %x, which is not supported",
__FUNCTION__, id, info.device_version);
return NO_INIT;
}
}
return OK;
}
bool CameraProvider::setUpVendorTags() {
ATRACE_CALL();
vendor_tag_ops_t vOps = vendor_tag_ops_t();

View file

@ -89,6 +89,7 @@ private:
hidl_vec<VendorTagSection> mVendorTagSections;
bool setUpVendorTags();
int checkCameraVersion(int id, camera_info info);
// extract legacy camera ID/device version from a HIDL device name
static std::string getLegacyCameraId(const hidl_string& deviceName);