From 99e69716215cd0665379bc90d708f2ea8689831d Mon Sep 17 00:00:00 2001 From: Ruben Brunk Date: Tue, 26 May 2015 17:25:07 -0700 Subject: Track camera and flashlight usage in battery stats. Bug: 15986092 Change-Id: I9dc6828332e4091fd93bf2d82839e8e3862a2fc2 --- services/camera/libcameraservice/CameraService.h | 26 ++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'services/camera/libcameraservice/CameraService.h') diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index 9b7163a..2e4743f 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -46,6 +46,7 @@ #include #include #include +#include namespace android { @@ -327,6 +328,20 @@ public: }; // class Client + /** + * A listener class that implements the LISTENER interface for use with a ClientManager, and + * implements the following methods: + * void onClientRemoved(const ClientDescriptor& descriptor); + * void onClientAdded(const ClientDescriptor& descriptor); + */ + class ClientEventListener { + public: + void onClientAdded(const resource_policy::ClientDescriptor>& descriptor); + void onClientRemoved(const resource_policy::ClientDescriptor>& descriptor); + }; // class ClientEventListener + typedef std::shared_ptr>> DescriptorPtr; @@ -338,9 +353,10 @@ public: * This class manages the eviction behavior for the camera clients. See the parent class * implementation in utils/ClientManager for the specifics of this behavior. */ - class CameraClientManager : - public resource_policy::ClientManager> { + class CameraClientManager : public resource_policy::ClientManager, ClientEventListener> { public: + CameraClientManager(); virtual ~CameraClientManager(); /** @@ -624,13 +640,15 @@ private: sp mFlashlight; // guard mTorchStatusMap Mutex mTorchStatusMutex; - // guard mTorchClientMap + // guard mTorchClientMap, mTorchUidMap Mutex mTorchClientMapMutex; // camera id -> torch status KeyedVector mTorchStatusMap; // camera id -> torch client binder // only store the last client that turns on each camera's torch mode - KeyedVector > mTorchClientMap; + KeyedVector> mTorchClientMap; + // camera id -> [incoming uid, current uid] pair + std::map> mTorchUidMap; // check and handle if torch client's process has died void handleTorchClientBinderDied(const wp &who); -- cgit v1.1