Camera: fix new device register logic
Test: smoking test GCA, CTS
Bug: 38452093
Change-Id: I984cfbb61a7c4983e27f250f9825f9418cf940e9
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 415fdf5..c2b71a2 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -250,9 +250,13 @@
conflicting.emplace(String8(cost.conflictingDevices[i].c_str()));
}
- Mutex::Autolock lock(mCameraStatesLock);
- mCameraStates.emplace(id8,
- std::make_shared<CameraState>(id8, cost.resourceCost, conflicting));
+ {
+ Mutex::Autolock lock(mCameraStatesLock);
+ mCameraStates.emplace(id8,
+ std::make_shared<CameraState>(id8, cost.resourceCost, conflicting));
+ }
+
+ onDeviceStatusChanged(id8, CameraDeviceStatus::PRESENT);
if (mFlashlight->hasFlashUnit(id8)) {
mTorchStatusMap.add(id8, TorchModeStatus::AVAILABLE_OFF);
@@ -301,7 +305,12 @@
std::shared_ptr<CameraState> state = getCameraState(id);
if (state == nullptr) {
- ALOGE("%s: Bad camera ID %s", __FUNCTION__, id.string());
+ if (newStatus == StatusInternal::PRESENT) {
+ ALOGW("%s: Unknown camera ID %s, probably newly registered?",
+ __FUNCTION__, id.string());
+ } else {
+ ALOGE("%s: Bad camera ID %s", __FUNCTION__, id.string());
+ }
return;
}