cameraserver: system camera rules should be checked before making onPhysicalCameraStatusChanged callbacks.
Bug: 152089822
Test: GCA (sanity)
Test: Camera CTS
Change-Id: I1cdca010819550f9743f8a6d1c209b123cb16ba4
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 9af1c36..2f11dc2 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -467,10 +467,21 @@
logDeviceRemoved(idCombo,
String8::format("Device status changed to %d", newStatus));
}
-
+ // Avoid calling getSystemCameraKind() with mStatusListenerLock held (b/141756275)
+ SystemCameraKind deviceKind = SystemCameraKind::PUBLIC;
+ if (getSystemCameraKind(id, &deviceKind) != OK) {
+ ALOGE("%s: Invalid camera id %s, skipping", __FUNCTION__, id.string());
+ return;
+ }
String16 id16(id), physicalId16(physicalId);
Mutex::Autolock lock(mStatusListenerLock);
for (auto& listener : mListenerList) {
+ if (shouldSkipStatusUpdates(deviceKind, listener->isVendorListener(),
+ listener->getListenerPid(), listener->getListenerUid())) {
+ ALOGV("Skipping discovery callback for system-only camera device %s",
+ id.c_str());
+ continue;
+ }
listener->getListener()->onPhysicalCameraStatusChanged(mapToInterface(newStatus),
id16, physicalId16);
}
@@ -3755,13 +3766,13 @@
Mutex::Autolock lock(mStatusListenerLock);
- notifyPhysicalCameraStatusLocked(mapToInterface(status), cameraId);
+ notifyPhysicalCameraStatusLocked(mapToInterface(status), cameraId, deviceKind);
for (auto& listener : mListenerList) {
bool isVendorListener = listener->isVendorListener();
if (shouldSkipStatusUpdates(deviceKind, isVendorListener,
listener->getListenerPid(), listener->getListenerUid()) ||
- (isVendorListener && !supportsHAL3)) {
+ (isVendorListener && !supportsHAL3)) {
ALOGV("Skipping discovery callback for system-only camera/HAL1 device %s",
cameraId.c_str());
continue;
@@ -3873,7 +3884,8 @@
return OK;
}
-void CameraService::notifyPhysicalCameraStatusLocked(int32_t status, const String8& cameraId) {
+void CameraService::notifyPhysicalCameraStatusLocked(int32_t status, const String8& cameraId,
+ SystemCameraKind deviceKind) {
Mutex::Autolock lock(mCameraStatesLock);
for (const auto& state : mCameraStates) {
std::vector<std::string> physicalCameraIds;
@@ -3889,6 +3901,12 @@
String16 id16(state.first), physicalId16(cameraId);
for (auto& listener : mListenerList) {
+ if (shouldSkipStatusUpdates(deviceKind, listener->isVendorListener(),
+ listener->getListenerPid(), listener->getListenerUid())) {
+ ALOGV("Skipping discovery callback for system-only camera device %s",
+ cameraId.c_str());
+ continue;
+ }
listener->getListener()->onPhysicalCameraStatusChanged(status,
id16, physicalId16);
}