Do not include hidden secure cameras in camera1: getNumberOfCameras

Apps cannot connect to hidden secure cameras. Do not include them in the
number of cameras reported by camera1 api.

Bug: 141247926

Test: Without CL -> mark all cameras as hidden secure cameras;
      atest FastBasicsTest.java#testCamera1 fails
      With CL -> mark all cameras as hidden secure cameras;
      atest FastBasicsTest.java#testCamera1 passes

Test: camera CTS

Merged-In: I9d1721fd5e94fa7f692c3da52aa667ae9247d368
Change-Id: I229a336bed6b2695e16c1457cb8f74c26b07f7e8
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
(cherry picked from commit cf93540965)
gugelfrei
Jayant Chowdhary 5 years ago
parent 9ee56ec1a7
commit 56c3307952

@ -97,7 +97,13 @@ int CameraProviderManager::getCameraCount() const {
std::lock_guard<std::mutex> lock(mInterfaceMutex);
int count = 0;
for (auto& provider : mProviders) {
count += provider->mUniqueCameraIds.size();
for (auto& id : provider->mUniqueCameraIds) {
// Hidden secure camera ids are not to be exposed to camera1 api.
if (isPublicallyHiddenSecureCameraLocked(id)) {
continue;
}
count++;
}
}
return count;
}
@ -123,7 +129,11 @@ std::vector<std::string> CameraProviderManager::getAPI1CompatibleCameraDeviceIds
// for each camera facing, only take the first id advertised by HAL in
// all [logical, physical1, physical2, ...] id combos, and filter out the rest.
filterLogicalCameraIdsLocked(providerDeviceIds);
// Hidden secure camera ids are not to be exposed to camera1 api.
providerDeviceIds.erase(std::remove_if(providerDeviceIds.begin(), providerDeviceIds.end(),
[this](const std::string& s) {
return this->isPublicallyHiddenSecureCameraLocked(s);}),
providerDeviceIds.end());
deviceIds.insert(deviceIds.end(), providerDeviceIds.begin(), providerDeviceIds.end());
}
@ -1035,9 +1045,12 @@ bool CameraProviderManager::isLogicalCamera(const std::string& id,
return deviceInfo->mIsLogicalCamera;
}
bool CameraProviderManager::isPublicallyHiddenSecureCamera(const std::string& id) {
bool CameraProviderManager::isPublicallyHiddenSecureCamera(const std::string& id) const {
std::lock_guard<std::mutex> lock(mInterfaceMutex);
return isPublicallyHiddenSecureCameraLocked(id);
}
bool CameraProviderManager::isPublicallyHiddenSecureCameraLocked(const std::string& id) const {
auto deviceInfo = findDeviceInfoLocked(id);
if (deviceInfo == nullptr) {
return false;

@ -269,7 +269,7 @@ public:
*/
bool isLogicalCamera(const std::string& id, std::vector<std::string>* physicalCameraIds);
bool isPublicallyHiddenSecureCamera(const std::string& id);
bool isPublicallyHiddenSecureCamera(const std::string& id) const;
bool isHiddenPhysicalCamera(const std::string& cameraId);
static const float kDepthARTolerance;
@ -591,6 +591,9 @@ private:
status_t getCameraCharacteristicsLocked(const std::string &id,
CameraMetadata* characteristics) const;
bool isPublicallyHiddenSecureCameraLocked(const std::string& id) const;
void filterLogicalCameraIdsLocked(std::vector<std::string>& deviceIds) const;
};

Loading…
Cancel
Save