James Thomson
James Thomson

Reputation: 51

How to record all touch and acclerometer on an Android device in ALL apps

I am currently working on a research project which involves people playing games on an Android device. I am hoping to be able to write an android app that records the accelerometer and touch events. I would like my users to be able to play games such as angry birds, whilst I record their touching data.

I understand that this type of data collection is possible from inside the app, but is it possible from outside the app? (perhaps via an app running in the background?)

If this is not possible, are there alternatives? (I believe I could theoretically go into the android OS source code and make this happen?)

Upvotes: 5

Views: 1436

Answers (2)

Chris Stratton
Chris Stratton

Reputation: 40397

Apps are not allowed to do this on a secured device (ie, consumer phone/tablet that has not been 'rooted').

However, depending on your needs it may be possible with the development tools connected to a computer. If you can do some moderately annoying setup before each controlled-circumstances trial, I believe you can do it on some stock devices by using the USB cable to switch ADB into wifi mode, then monitoring input events over a wireless ADB session. See

http://source.android.com/tech/input/getevent.html

That document seems to imply that 'su' is needed (which is odd as the official 'su' isn't usable by non-root users), however it works without on many stock devices.

You'd probably also want to be running logcat to figure out what application is in the foreground.

Upvotes: 2

CommonsWare
CommonsWare

Reputation: 1007286

I understand that this type of data collection is possible from inside the app, but is it possible from outside the app? (perhaps via an app running in the background?)

For touch events, no, for obvious privacy and security reasons. It used to be possible (research the term "tapjacking"), but current versions of Android finally blocked this behavior.

For accelerometer events, you can record those, because they are the same for all apps simultaneously. Bear in mind that your sampling rate may not exactly match that of the app being used.

I believe I could theoretically go into the android OS source code and make this happen?

Yes, though you would then need to turn that modified Android into a ROM mod and install it on devices.

Upvotes: 4

Related Questions