Merge "CameraService: hold onto SensorPrivacyManager"

gugelfrei
Steven Moreland 4 years ago committed by Gerrit Code Review
commit 733c728752

@ -56,7 +56,6 @@
#include <media/IMediaHTTPService.h> #include <media/IMediaHTTPService.h>
#include <media/mediaplayer.h> #include <media/mediaplayer.h>
#include <mediautils/BatteryNotifier.h> #include <mediautils/BatteryNotifier.h>
#include <sensorprivacy/SensorPrivacyManager.h>
#include <utils/Errors.h> #include <utils/Errors.h>
#include <utils/Log.h> #include <utils/Log.h>
#include <utils/String16.h> #include <utils/String16.h>
@ -2853,10 +2852,9 @@ void CameraService::SensorPrivacyPolicy::registerSelf() {
if (mRegistered) { if (mRegistered) {
return; return;
} }
SensorPrivacyManager spm; mSpm.addSensorPrivacyListener(this);
spm.addSensorPrivacyListener(this); mSensorPrivacyEnabled = mSpm.isSensorPrivacyEnabled();
mSensorPrivacyEnabled = spm.isSensorPrivacyEnabled(); status_t res = mSpm.linkToDeath(this);
status_t res = spm.linkToDeath(this);
if (res == OK) { if (res == OK) {
mRegistered = true; mRegistered = true;
ALOGV("SensorPrivacyPolicy: Registered with SensorPrivacyManager"); ALOGV("SensorPrivacyPolicy: Registered with SensorPrivacyManager");
@ -2865,9 +2863,8 @@ void CameraService::SensorPrivacyPolicy::registerSelf() {
void CameraService::SensorPrivacyPolicy::unregisterSelf() { void CameraService::SensorPrivacyPolicy::unregisterSelf() {
Mutex::Autolock _l(mSensorPrivacyLock); Mutex::Autolock _l(mSensorPrivacyLock);
SensorPrivacyManager spm; mSpm.removeSensorPrivacyListener(this);
spm.removeSensorPrivacyListener(this); mSpm.unlinkToDeath(this);
spm.unlinkToDeath(this);
mRegistered = false; mRegistered = false;
ALOGV("SensorPrivacyPolicy: Unregistered with SensorPrivacyManager"); ALOGV("SensorPrivacyPolicy: Unregistered with SensorPrivacyManager");
} }

@ -31,6 +31,7 @@
#include <binder/IAppOpsCallback.h> #include <binder/IAppOpsCallback.h>
#include <binder/IUidObserver.h> #include <binder/IUidObserver.h>
#include <hardware/camera.h> #include <hardware/camera.h>
#include <sensorprivacy/SensorPrivacyManager.h>
#include <android/hardware/camera/common/1.0/types.h> #include <android/hardware/camera/common/1.0/types.h>
@ -599,6 +600,7 @@ private:
virtual void binderDied(const wp<IBinder> &who); virtual void binderDied(const wp<IBinder> &who);
private: private:
SensorPrivacyManager mSpm;
wp<CameraService> mService; wp<CameraService> mService;
Mutex mSensorPrivacyLock; Mutex mSensorPrivacyLock;
bool mSensorPrivacyEnabled; bool mSensorPrivacyEnabled;

Loading…
Cancel
Save