Merge "cameraserver: filter out non-HAL3 devices from HIDL addListener."

am: 58205951c3

Change-Id: I0c55193a877c65312d05f0564fd838505aed84b9
gugelfrei
Jayant Chowdhary 5 years ago committed by android-build-merger
commit 6ffc16c353

@ -3274,9 +3274,21 @@ void CameraService::updateStatus(StatusInternal status, const String8& cameraId,
return; return;
} }
bool isHidden = isPublicallyHiddenSecureCamera(cameraId); bool isHidden = isPublicallyHiddenSecureCamera(cameraId);
bool supportsHAL3 = false;
// supportsCameraApi also holds mInterfaceMutex, we can't call it in the
// HIDL onStatusChanged wrapper call (we'll hold mStatusListenerLock and
// mInterfaceMutex together, which can lead to deadlocks)
binder::Status sRet =
supportsCameraApi(String16(cameraId), hardware::ICameraService::API_VERSION_2,
&supportsHAL3);
if (!sRet.isOk()) {
ALOGW("%s: Failed to determine if device supports HAL3 %s, supportsCameraApi call failed",
__FUNCTION__, cameraId.string());
return;
}
// Update the status for this camera state, then send the onStatusChangedCallbacks to each // Update the status for this camera state, then send the onStatusChangedCallbacks to each
// of the listeners with both the mStatusStatus and mStatusListenerLock held // of the listeners with both the mStatusStatus and mStatusListenerLock held
state->updateStatus(status, cameraId, rejectSourceStates, [this,&isHidden] state->updateStatus(status, cameraId, rejectSourceStates, [this, &isHidden, &supportsHAL3]
(const String8& cameraId, StatusInternal status) { (const String8& cameraId, StatusInternal status) {
if (status != StatusInternal::ENUMERATING) { if (status != StatusInternal::ENUMERATING) {
@ -3298,8 +3310,8 @@ void CameraService::updateStatus(StatusInternal status, const String8& cameraId,
Mutex::Autolock lock(mStatusListenerLock); Mutex::Autolock lock(mStatusListenerLock);
for (auto& listener : mListenerList) { for (auto& listener : mListenerList) {
if (!listener.first && isHidden) { if (!listener.first && (isHidden || !supportsHAL3)) {
ALOGV("Skipping camera discovery callback for system-only camera %s", ALOGV("Skipping camera discovery callback for system-only / HAL1 camera %s",
cameraId.c_str()); cameraId.c_str());
continue; continue;
} }

@ -191,6 +191,14 @@ Return<void> HidlCameraService::addListener(const sp<HCameraServiceListener>& hC
_hidl_cb(status, {}); _hidl_cb(status, {});
return Void(); return Void();
} }
cameraStatusAndIds.erase(std::remove_if(cameraStatusAndIds.begin(), cameraStatusAndIds.end(),
[this](const hardware::CameraStatus& s) {
bool supportsHAL3 = false;
binder::Status sRet =
mAidlICameraService->supportsCameraApi(String16(s.cameraId),
hardware::ICameraService::API_VERSION_2, &supportsHAL3);
return !sRet.isOk() || !supportsHAL3;
}), cameraStatusAndIds.end());
hidl_vec<HCameraStatusAndId> hCameraStatusAndIds; hidl_vec<HCameraStatusAndId> hCameraStatusAndIds;
//Convert cameraStatusAndIds to HIDL and call callback //Convert cameraStatusAndIds to HIDL and call callback
convertToHidl(cameraStatusAndIds, &hCameraStatusAndIds); convertToHidl(cameraStatusAndIds, &hCameraStatusAndIds);

Loading…
Cancel
Save