Chapter 17. Accelerometer
17.1. Introduction: Sensors
Accelerometers are one of the more interesting bits of hardware in smartphones. Earlier devices such as the OpenMoko “Neo” smartphone and the Apple iPhone included them. Before Android was released I was advocating for OpenMoko at open source conferences. One of my favorite imaginary applications was private key generation. Adhering to the theory that “When privacy is outlawed, only outlaws will have privacy,” several people were talking about this as early as 2008 (when I presented the idea, to great applause, at the Ontario Linux Fest). The idea is: if you can’t or don’t want to exchange private keys over a public channel, you meet on a street corner and shake hands—with each hand having a cell phone concealed in the palm. The devices are touching each other, thus their sensors should record exactly the same somewhat random motions. With a bit of mathematics to filter out the leading and trailing motion of the hands moving together, both devices should have quite a few bits’ worth of identical, random data that nobody else has—just what you need for crypto key exchange. I’ve yet to see anybody implement this, and I must admit I still hope somebody will come through.
Meanwhile, we have many other recipes on accelerometers and other sensors in this chapter...
17.2. Checking for the Presence or Absence of a Sensor
You want to use a given sensor. Before using an Android device for a sensor-based ...