From 412fe56cd7cf7d73bc5d2bcc3f635bc650d18de9 Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Thu, 20 Aug 2015 17:08:32 -0700 Subject: CameraService: Notify camera service proxy of device status Send the camera proxy service in system server updates to camera device state: opened/closed/active/idle. Bug: 23393557 Change-Id: Id7c70f134821efa34af8f6e7b4caa4c2ab128ebc --- services/camera/libcameraservice/CameraService.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'services/camera/libcameraservice/CameraService.h') diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index 7f4d43f..894767a 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -164,6 +165,14 @@ public: void playSound(sound_kind kind); void releaseSound(); + /** + * Update the state of a given camera device (open/close/active/idle) with + * the camera proxy service in the system service + */ + static void updateProxyDeviceState( + ICameraServiceProxy::CameraState newState, + const String8& cameraId); + ///////////////////////////////////////////////////////////////////// // CameraDeviceFactory functionality int getDeviceVersion(int cameraId, int* facing = NULL); @@ -728,6 +737,7 @@ private: static String8 toString(std::set intSet); + static sp getCameraServiceProxy(); static void pingCameraServiceProxy(); }; -- cgit v1.1 From fe751bea0d3eedd6e817aebf4e457425b82e7117 Mon Sep 17 00:00:00 2001 From: Chien-Yu Chen Date: Tue, 1 Sep 2015 14:16:44 -0700 Subject: Camera: Fix flashlight deadlock Use a dedicated mutex for torch UID map so it won't cause a deadlock after flashlight app gets killed while the torch is on. Bug: 23722318 Change-Id: I228377aa0412052d56b6b948361d9abaecbbc686 --- services/camera/libcameraservice/CameraService.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'services/camera/libcameraservice/CameraService.h') diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index 7f4d43f..b56c161 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -648,8 +648,10 @@ private: sp mFlashlight; // guard mTorchStatusMap Mutex mTorchStatusMutex; - // guard mTorchClientMap, mTorchUidMap + // guard mTorchClientMap Mutex mTorchClientMapMutex; + // guard mTorchUidMap + Mutex mTorchUidMapMutex; // camera id -> torch status KeyedVector mTorchStatusMap; // camera id -> torch client binder -- cgit v1.1 From 52aad85627f5216e7a3d9db425d2cc409f998a01 Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Thu, 3 Sep 2015 12:24:24 -0700 Subject: CameraService: Treat TOP_SLEEPING same as TOP for priority. When arbitrating between camera clients, treat processes in the TOP_SLEEPING state with the same high priority as processes in the TOP state. This resolves race conditions during lock screen handoffs between clients such as face unlock (a bound foreground process) and a secure camera app (the topmost activity, but transitioning from TOP_SLEEPING to TOP asynchronously from the activity lifecycle callbacks). Bug: 23731720 Change-Id: I92c3f8f561c7725627826c0ba3dc926e99af746c --- services/camera/libcameraservice/CameraService.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'services/camera/libcameraservice/CameraService.h') diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index a8c6b6c..330a19d 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -75,6 +75,8 @@ public: // Process state (mirrors frameworks/base/core/java/android/app/ActivityManager.java) static const int PROCESS_STATE_NONEXISTENT = -1; + static const int PROCESS_STATE_TOP = 2; + static const int PROCESS_STATE_TOP_SLEEPING = 5; // 3 second busy timeout when other clients are connecting static const nsecs_t DEFAULT_CONNECT_TIMEOUT_NS = 3000000000; -- cgit v1.1 From 24901c86e10a0923fe10f5e9bce5e6dba061a289 Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Fri, 4 Sep 2015 14:15:58 -0700 Subject: CameraService: Link to client binder death at end of connect If, within a binder Looper thread, a Binder object death notifier is registered, and then a nested Binder transaction is begun, that transaction may process a death notification callback for the just-registered object, if it was dead at the time of registration. This can lead to an unexpected nested call into the service, and cause deadlock. To avoid this, move the death notifier registration to the end of handling the connect transaction. Also remove one extra bit of disconnect logging. Bug: 23525545 Change-Id: If01cbaf42704f55134118afefc9a8f7bdb014e09 --- services/camera/libcameraservice/CameraService.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'services/camera/libcameraservice/CameraService.h') diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index 330a19d..cd97b08 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -873,11 +873,6 @@ status_t CameraService::connectHelper(const sp& cameraCb, const String return ret; } - sp remoteCallback = client->getRemote(); - if (remoteCallback != nullptr) { - remoteCallback->linkToDeath(this); - } - // Update shim paremeters for legacy clients if (effectiveApiLevel == API_1) { // Assume we have always received a Client subclass for API1 -- cgit v1.1