Use ERROR_CAMERA_DISCONNECTED on id remap
- There are many more advantages to using
ERROR_DISCONNECTED instead of ERROR_DEVICE.
- It won't impact app analytics and flag
unnecessary errors to the app.
- It's a much more common scenario to get
disconnected than receing a device error,
so apps are more likely to handle it -
disconnect happens when another higher
priority app wants to use the same camera,
which can be common among multi-window
scenarios.
- Previously, we were using ERROR_CAMERA_DEVICE.
However, if an app tries to immediately reconnect
on receiving that error, they are often able to
connect before we have even finished disconnecting.
This is because we need to release the mServiceLock
before disconnecting.
- Whereas, the next time an app can call connect() after
being disconnected() is likely onAvailable(), which is
only triggered after we have fully disconnected().
Bug: 286287541
Test: Tested locally.
Change-Id: Ia32babe51a31ef6dc2b9ae4570813396a75b76dc
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 6a005c3..e56ca64 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -905,10 +905,8 @@
}
for (auto& clientSp : clientsToDisconnect) {
- // We send up ERROR_CAMERA_DEVICE so that the app attempts to reconnect
- // automatically. Note that this itself can cause clientSp->disconnect() based on the
- // app's response.
- clientSp->notifyError(hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_DEVICE,
+ // Notify the clients about the disconnection.
+ clientSp->notifyError(hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_DISCONNECTED,
CaptureResultExtras{});
}