Remove dependency on libandroid
The main purpose of this change is to avoid having to pull in libandroid
for the sake of using the sensor manager from the audioserver process
(native). The way this is achieved is by using lower-level APIs, namely
those offered by libsensor.
As a result, we were able to use sensor handles in SensorPoseProvider,
rather than ASensor* objects, which is simpler and removes the need to
enumerate all the sensor for the sake of finding the one with the
correct handle.
Test: Manually enable head tracking and observe the logs to verify that
the expected pose updates are received.
Bug: 198795859
Change-Id: Ic69c322d6ea9297309a4856b3047c841831e04d7
diff --git a/services/audiopolicy/service/Spatializer.h b/services/audiopolicy/service/Spatializer.h
index 136a467..4d77b78 100644
--- a/services/audiopolicy/service/Spatializer.h
+++ b/services/audiopolicy/service/Spatializer.h
@@ -22,7 +22,6 @@
#include <android/media/SpatializationLevel.h>
#include <android/media/SpatializationMode.h>
#include <android/media/SpatializerHeadTrackingMode.h>
-#include <android/sensor.h>
#include <media/audiohal/EffectHalInterface.h>
#include <media/stagefright/foundation/ALooper.h>
#include <media/AudioEffect.h>
@@ -162,9 +161,6 @@
void onHeadToStagePoseMsg(const std::vector<float>& headToStage);
void onActualModeChangeMsg(media::HeadTrackingMode mode);
-
- static ConversionResult<ASensorRef> getSensorFromHandle(int handle);
-
static constexpr int kMaxEffectParamValues = 10;
/**
* Get a parameter from spatializer engine by calling the effect HAL command method directly.
@@ -312,10 +308,10 @@
= media::SpatializerHeadTrackingMode::DISABLED;
/** Selected Head pose sensor */
- ASensorRef mHeadSensor GUARDED_BY(mLock) = nullptr;
+ int32_t mHeadSensor GUARDED_BY(mLock) = SpatializerPoseController::INVALID_SENSOR;
/** Selected Screen pose sensor */
- ASensorRef mScreenSensor GUARDED_BY(mLock) = nullptr;
+ int32_t mScreenSensor GUARDED_BY(mLock) = SpatializerPoseController::INVALID_SENSOR;
/** Last display orientation received */
static constexpr float kDisplayOrientationInvalid = 1000;