CameraService: hold onto SensorPrivacyManager
unlinkToDeath is no longer required, (this change in behavior is to
avoid leaks) so holding onto the service here (still calling
unlinkToDeath to avoid a log, but may for instance remove all
unlinkToDeath calls in the future).
Bug: 145692765
Test: boot, see linkToDeath maintained
Change-Id: Ib74ab470580643ff61fc684fdd4e16d5e38389af
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 850b275..6e5c979 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -56,7 +56,6 @@
#include <media/IMediaHTTPService.h>
#include <media/mediaplayer.h>
#include <mediautils/BatteryNotifier.h>
-#include <sensorprivacy/SensorPrivacyManager.h>
#include <utils/Errors.h>
#include <utils/Log.h>
#include <utils/String16.h>
@@ -2853,10 +2852,9 @@
if (mRegistered) {
return;
}
- SensorPrivacyManager spm;
- spm.addSensorPrivacyListener(this);
- mSensorPrivacyEnabled = spm.isSensorPrivacyEnabled();
- status_t res = spm.linkToDeath(this);
+ mSpm.addSensorPrivacyListener(this);
+ mSensorPrivacyEnabled = mSpm.isSensorPrivacyEnabled();
+ status_t res = mSpm.linkToDeath(this);
if (res == OK) {
mRegistered = true;
ALOGV("SensorPrivacyPolicy: Registered with SensorPrivacyManager");
@@ -2865,9 +2863,8 @@
void CameraService::SensorPrivacyPolicy::unregisterSelf() {
Mutex::Autolock _l(mSensorPrivacyLock);
- SensorPrivacyManager spm;
- spm.removeSensorPrivacyListener(this);
- spm.unlinkToDeath(this);
+ mSpm.removeSensorPrivacyListener(this);
+ mSpm.unlinkToDeath(this);
mRegistered = false;
ALOGV("SensorPrivacyPolicy: Unregistered with SensorPrivacyManager");
}