Camera: Add onCameraOpened/onCameraClosed callbacks
The onCameraOpened/onCameraClosed callbacks are used to notify camera
service client with CAMERA_OPEN_CLOSE_LISTENER permission that a certain
camera device has been opened/closed.
Test: Manually check callbacks are received in SystemUI app
Bug: 150540299
Change-Id: If6f3624c43927c30afef7df0a780eafe3ae4c527
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 265a572..f12b4cc 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -912,9 +912,10 @@
class ServiceListener : public virtual IBinder::DeathRecipient {
public:
ServiceListener(sp<CameraService> parent, sp<hardware::ICameraServiceListener> listener,
- int uid, int pid, bool isVendorClient)
+ int uid, int pid, bool isVendorClient, bool openCloseCallbackAllowed)
: mParent(parent), mListener(listener), mListenerUid(uid), mListenerPid(pid),
- mIsVendorListener(isVendorClient) { }
+ mIsVendorListener(isVendorClient),
+ mOpenCloseCallbackAllowed(openCloseCallbackAllowed) { }
status_t initialize() {
return IInterface::asBinder(mListener)->linkToDeath(this);
@@ -931,6 +932,7 @@
int getListenerPid() { return mListenerPid; }
sp<hardware::ICameraServiceListener> getListener() { return mListener; }
bool isVendorListener() { return mIsVendorListener; }
+ bool isOpenCloseCallbackAllowed() { return mOpenCloseCallbackAllowed; }
private:
wp<CameraService> mParent;
@@ -938,6 +940,7 @@
int mListenerUid = -1;
int mListenerPid = -1;
bool mIsVendorListener = false;
+ bool mOpenCloseCallbackAllowed = false;
};
// Guarded by mStatusListenerMutex
@@ -960,6 +963,13 @@
void updateStatus(StatusInternal status,
const String8& cameraId);
+ /**
+ * Update the opened/closed status of the given camera id.
+ *
+ * This method acqiures mStatusListenerLock.
+ */
+ void updateOpenCloseStatus(const String8& cameraId, bool open, const String16& packageName);
+
// flashlight control
sp<CameraFlashlight> mFlashlight;
// guard mTorchStatusMap