So I found the Gravity Sensor code here https://cs.android.com/android/platform/superproject/+/master:frameworks/native/services/sensorservice/GravitySensor.cpp
This is the Gravity Sensor as implemented by Android. But this is clearly not the sensor that I'm getting. When using the Sensor Kinetics app I can see that the Gravity Sensor on the phone is coming from Samsung Elektronics. So it looks like that manufacturers also bundle a implementation for the Gravity Sensor.
This explains why I'm seeing different results for gravity sensor values on different devices while gyro + accelerometer values are very similar (since gyro accel are similar I expect great similarity in gravity values as well, since gravity is derived from accel + gyro).
So is there a way to register an event listener specific for the Android implementation? Or even better is there a Java sensor (gyro and accelero) fusion library available that is able to filter out gravity. That would be the best since I wouldn't be dependent of Android versions and/or manufacturer implementations.
The way I'm currently registering:
sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY), SensorManager.SENSOR_DELAY_FASTEST);
Thanks.
UPDATE: My assumption seems to be correct. On this page they are talking about a way to select the secondary Gravity sensor if the manufacturer comes with one, but it's not described how. If I use SensorManager.getSensors() and list them, unfortunately the Google secondary sensors are not listed. See https://developer.android.com/guide/topics/sensors/sensors_motion#android-open-source-project-sensors
The Gravity sensor on Galaxy A40 (version 1).
Gravity sensor on Galaxy S9, coming from samsung, version 3 - different algoritm.
