Is it possible to simulate accelerometer motion on

2020-02-15 07:19发布

问题:

Is it possible to transmit fake values to the accelerometer sensor like it is possible with GPS coordinates?

回答1:

If you mean the GPS location, then yes, you can fake that (look at the very bottom of the page): Android DDMS

Using the DDMS, you can simply tell your device its current GPS coordinates.

EDIT: I guess, this post answers your question Stackoverflow. It points out that SensorSimulator is capable of doing that. If you scroll down a little bit on the page, it explains you how to connect the tool with a real device. I myself have never used it, so just try it :)

Hope it helps!



回答2:

You can do that if you find the input event file, and write the values directly to the file. ls -l /dev/input/ and you will see the list of the events you may access. Not sure if you need to be root for that (which can be the case).



回答3:

I tried to follow the logic and reached this area of the code: https://github.com/mozilla-b2g/android-device-crespo/tree/master/libsensors which refers to gyros and whatnot in the various device builds

The code actually makes reference to chip-specific /dev files and paths like /sys/devices/platform/soc-audio.0/sound/card0/pcmC0D9p/dev which I could probably work out how to interpret, but fear I've already squandered too much time on.

It looks like if you're going to try this, you'd need to pretend to be a variety of accelerometer chips, but I suspect squirting data into them is unlikely to work the same way it does with the easier devices.