Thanks Dianne, Chinmay.
I investigated the proper HAL way, but it turns out that the device
(bma150) is implemented by the linux driver without support for the
input subsystem. E.g. there's no /dev/input/* device for it, just a
raw data device /dev/bma150. This differs from all the implementations
I've seen of the sensors.
I have no clue how the manufacturers implemented this, then. I suppose
they either faked a dummy input device, or just returned a bogus
filedescriptor for the input device requested by the hal interface.
I, instead, decided to adjust the base framework and swap the axes of
the accelerometer there. It seemed that, on the original firmware that
came shipped with the device, the orientation of the accelerometer was
also interpreted differently by multiple applications. E.g. the
launcher and browser behaved differently than some games. Might have
to do with the way they hacked it into android. So, I made it user-
configurable using a system property, and also added a system property
that will make the SensorManager optionally monitor for changes to the
axis swapping vector.
E.g., one can specify this as vector: "-y,x,z" which will swap x and
y, and invert y. And with the monitor property, one could write a
simple app that will allow the user to toggle between multiple setups.
So, in the end, I'm happy with doing this directly in the framework.
Patch that implements this in 2.2 can be found here:
https://github.com/stragulus/Flytouch-2-Frameworks-Base/commit/2d9355dd2de93f25db3977dd2367ab1558a5a765
I was dubbing whether I should spawn a separate thread to monitor the
changes to the swap settings, but chose to add it to the same thread
that broadcasts the sensor events to limit the extra bookkeeping
required for the thread. A drawback to this solution is that it will
call System.nanoTime() quite frequently. Is that bad? At least, this
way, when the sensor thread is cleaned up, this too will go away, not
hogging the system accidentally when the device goes in idle mode.