If you haven’t heard about Android Wear now will be a good time to head over this website to learn more about it, and if you have heard about it than hopefully you will learn something useful as what I’ve learned. What I’ve done is download and diassembled the Android_Wear_Beta.apk that is available from Google Play to studied how it works internally and also look at studying the logcat from the emulator. You will be surprised at how much information you can gather from logcat
Android Wear is a way for an external wearable device to get notifications from your mobile devices. There are 2 major components in the whole picture – the wearable and the mobile device, which translates to 2 different software – the wearable software and the mobile software (I’m going to call the wear application that runs on the emulator is called Wear). The Wear emulator software stack runs the full Android stack which means that the wearable device will be running the same Android stack that your mobile is running (no idea if Google will change this in the future as this is something that they could change down the track, but I’m speculating they won’t). Put it simply the architecture is like a peer-to-peer architecture, the application that runs on the wearable will accept incoming data either through TCP socket or Bluetooth to display notifications and at the same time it will send command back to the mobile device when a certain activities are performed by the user – reply/open/speech gesture.
Following are the packages that can be found inside the .apk:
The code that does communication between the mobile device and wear is inside the com.google.android.clockwork.node package – socket and bluetooth management and listeners are all inside here.
Inside Wear there is a concept called ‘Asset’ object where this object travels between devices. This ‘Asset’ is what being displayed on the Wear device, the data class that encapsulate this ‘Asset’ is inside com.google.android.clockwork.data
One funny and memorable thing I found when cleaning the asset classes was when the asset failed to be delivered to Wear emulator the app shows up the data as follows
Communication Data Structure
This is the biggest chunk of the code inside Wear. Defining what information can be send back and forth between Wear peer is crucial and proper definition need to be done properly. Wear uses it’s own communication protocol by utilising extensively a project called micro-protobuf that resides inside the package com.google.protobuf.micro and project that are found inside Android source code called nano-protobuf. Looking at the transport mechanism that Wear will be using (Bluetooth) these 2 projects is the right candidate due to the bandwidth constraint. Was able to confirm that this is the right project by just replacing the disassembled code using this project and the app works just fine.
Looking into the Java classs structure for data that are relayed back to the Wear device it can be seen there are varieties of information that can be passed – route, image, flight, finance, currency, url, video, time, calculator and many more. There are few class that I find are related to advertisement that seems to piggyback inside the data structure that are being communicate to Wear device – namely YouTube information and vendor information (url, pricing information) that will be used to display onto the Wear device.
The other thing that I found inside the data structure is the possibility of passing information as part of an agenda things like car rental, flight information,
Voice & Speech
Speech by default is disabled in the Wear emulator image as there is a code that checked whether the app is running in an emulator. Speech is another big part inside Wear as it is understandable that this will be the main communication between Wear and the user. Haven’t got my head around how the speech will work, but one thing for sure it it using the OMX.google.aac.encoder codec to decode the inputstream
The other interesting package name that I saw com.x.google.common which I thought initially is a project from Google X, but after searching around found out that the same package is also used internally inside Google Glass
Few services are listed inside AndroidManifest.xml that handles bug report, submit feedback and phone handling. The phone handling service is interesting as it will notify the Wear that there is an incoming call and action will be performed based on user’s feedback from Wear.
On another side of the fence is the emulator that runs the Wear application. Extracting the emulator image the content is the same as normal emulator the difference that I can see is the application that is being hosted as can be seen below (ignore the -decode and _FILES prefix directories).
There are 3 main .apk that can be found inside the priv-app/ directory – ClockworkSettings.apk, ClockworkSetup.apk, PrebuiltClockworkHome.apk. On dissecting these 3 apps one of the .apk (PrebuiltClockworkHome.apk) represent resemblance to the application that inside Android_Wear_Beta.apk. The other interesting finding is inside the assets/ folder of the same apk we can see a binary file that resembles a file containing words that are recognised by the speech app in Wear
and sure enough there is a code inside PrebuiltClockworkHome app that read the file and interestingly the class is call HotwordRecognizerRunner. This confirms that future wear devices will have speech recognition capability.