Finally Tinkering With The Nexus Q

I was fortunate enough to attend Google I/O 2012 back in June of 2012. One of the perks beyond the great sessions was receiving the Nexus Q, a device who’s actual release has been cancelled. It was, at the time, kind of neat, though spartan in terms of features: Android users can play music and YouTube videos to it over WiFi. That’s it. Under the hood, however, the device is running a full install of Android 4.0.

My first point of entry was enabling development mode. This is done from within the Nexus Q companion app, and was as simple as navigating to the advanced settings and flipping a switch. From the debug info screen, I could see what IP address the Nexus Q had on my network. From there, it was a simple remote ADB:

adb connect <IP Address>:4321

From that point, all standard ADB commands will be sent over the network—no cables needed! At that point, I opened the Settings app and tried connecting a Bluetooth mouse. How? You can always fire intents from an ADB shell; opening the Settings app goes like this:

am start -a android.settings.SETTINGS

From here, however, it’s a little tricky: there are no buttons to interact with what’s on screen, except mute and volume controls. It’s possible to send input codes as if they were typed on hardware buttons from ADB, though. This list of key codes really helped out. Entering a key code from an ADB shell:

input keyevent <Key Code Number>

Fairly simple stuff. But not all apps (such as Netflix) respond well to caret-style app navigation, so you can’t move from button to button with d-pad keys. For that, we can use MonkeyRunner. This was originally designed for controlling applications programmatically for testing, as part of your testing routine. To get this working from your terminal, run monkeyrunner (.bat, if you’re in Windows) from your Android SDK tools directory, and run each of these lines from the strange Java-meets-Python console:

from import MonkeyRunner, MonkeyDevice
device = MonkeyRunner.waitForConnection()

From here, the sky’s the limit. Have a look at the full MonkeyDevice API, notably the touch() and type() methods. It’s certainly more painful that using an attached mouse, but it works. It’s worth noting here that none of these instructions are specific to the Nexus Q: you could do any of this with any development-enabled Android device.

My next step is writing a companion Android app operating as a hybrid remote launcher, keyboard and mouse. One helpful thing might be installing a launcher, I suggest Cyanogenmod’s Trebuchet (grab it out of a Galaxy Nexus CM9 build). In fact, many applications designed for a Galaxy Nexus ought to work here, as they share a lot of the same hardware. Just side-load the same way you would any APK—it even works via remote ADB like the above commands.

© 2011–2022 Carson Brown