I finally managed to solve it! So to get acceleration vector in Earth’s coordinate system you need to:
- get rotation matrix (
floatso it could be used later by
SENSOR.TYPE_MAGNETIC_FIELDsensors values as parameters),
android.opengl.Matrix.invertM()on the rotation matrix to invert it (not transpose!),
Sensor.TYPE_LINEAR_ACCELERATIONsensor to get linear acceleration vector (in device’s coord. sys.),
android.opengl.Matrix.multiplyMV()to multiply the rotation matrix by linear acceleration vector.
And there you have it! I hope I will save some precious time for others.
Thanks for Edward Falk and Ali for hints!!