Coding Glassware

.Google Glass Logo

Google Glass Logo, Public Domain via Wikimedia Commons

Do you want to code Glassware (software for Google Glass)? Developers who are part of Google's Glass Explorer program have been given access to the Google Mirror API for creating Glassware. An Explorer developer can build a starter project in several languages (Java, .NET, PHP, Python). The Glass Developer Guide describes a user interface consisting of a "timeline" containing "cards" to push data to Glass. Images and video streams can be attached to a timeline card. Several cards can be combined into a bundle that is expandable and collapsible. Software navigation is accomplished through a combination of voice commands and swiping gestures on the Glass touch pad.

Wide 400

Google Glass Hello World Program CC3.0

Google's current mirror API only allows developers to push HTML data, photos, videos, and text. However on May 16, 2013 during the Google I/O developers conference in San Francisco, Google announced they are working on a Software Development Kit (SDK) for Glass. The SDK will allow programmers to access more Glass capabilities than are currently accessible with the Mirror API. The SDK will use Android development technology, with an additional code library for Glass.

Voiding Your Warranty: Hacking Glass

As a prelude to the Glass SDK, Google presented a conference session called Voiding Your Warranty: Hacking Glass which showed how to root Glass. After gaining root access, they installed existing Android applications on Glass and connected a keyboard for navigation (via Bluetooth). They discussed aspects of converting the existing Android applications to run on Glass. The next demonstration was how to get Ubuntu to run on top of Glass. At the end of the session was a question and answer segment during which the presenters indicated there would be a way to restore Glass back to the factory state. They also indicated Google was discussing the creation of an emulator which would allow development of Glassware without having the Glass device. As a side note, developer Gerwin Sturm has already released an "unofficial Google Glass emulator" available on GitHub. Gerwin named the emulator application "Mirror Api Emulator (MAE)" and posted MAE documentation. The entire Google conference session was recorded on the following YouTube video:



Topics Covered

  1. Recap of previous Glass for Developer sessions.
  2. Experiment with Android Applications.
  3. First Demonstration: How to modify your existing Android applications to run on Glass.
  4. High Fidelity Inc Avatar Video
  5. Things you can not do by just Enabling ADB
  6. Commands to root the Glass device.
  7. Second Demonstration - Running Ubuntu on top of Glass Device
  8. Q/A Session

Recap of previous Glass for Developer sessions

  • The name of Glass's main interface is called a timeline.
  • A timeline is a strip of cards laid out horizontally. When Glass is woken up, the first screen you see is the clock screen. To the right are past event timeline cards that were generated when you took a photo, video, or receive email. To the left are future event cards.
  • Third party services can insert cards into the timeline interface using the Mirror API. The Mirror API was designed to be simple and to avoid having the developer be concerned with system resources. For those tasks Google is currently building a Glass SDK.

Experiment with Android Applications (Before you void your warranty)

  • Enable Android Debug Bridge (ADB).
  • On laptop, download the latest Android SDK.
  • Can communicate with Glass device through USB connection.
  • Glass is currently built on Android ICS MR1 (4.0.4), API level 15 (however at time of consumer launch, this may not be the API level used).
  • Most of the hardware is available through standard Android APIs. But what is different is the touch handling. Instead of having a touch screen, Glass has a touch pad on the side. If the Android application's input handling depends on any touch screen coordinates, it will not work. You will need to change it to be something that will be more like D-pad operations.
  • Instead of an LCD display, Glass has a transparent background which requires the best contrast possible. To accomplish this set the background to black and have white (or very light colored) text.

First Demonstration: How to modify your existing Android applications to run on Glass

  • Presenter used an application called Screen Cast which allowed him to share with the audience what was displaying on his Glass device.
  • Enable ADB - When you wake the device up and you land on the Clock card, all you have to do is swipe all the way back until you reach the settings card. Once in the settings bundle, look for the device info card, then options, then the ADB toggle (Turn on debug).
  • Install Applications - Now that ADB is enabled, install applications that were already downloaded from the Android Open Source Project (AOSP). Pretty much just compile those into regular .apk files. Run the commands to install on the device (adb install -r Settings.apk).
  • With apps installed, for purpose of this demo, will just the Android launcher.
  • Glass is able to get around in the Android application because of some modifications made to Android OS. Glass forward and backward swipes are converted into focus events. Taps are used to select. Swipe downs have the back action. This will you allow you to navigate around your Android application and reach a lot of its features.
  • However if your app has designed for a touch screen, this navigation will not be enough. So use the bluetooth to connect to a keyboard. Now have the D-pad and mouse actions.
  • Have the keyboard connection is very important if you plan to port an existing application to Glass.
  • At this point you can navigate around the existing app and make the changes required to support the Glass navigations.

High Fidelity Inc Avatar Video

Next the presenters showed a video created by High Fidelity Inc who used Glass's motion sensors and microphone to move an avatar's head.



Things you can NOT do by just Enabling ADB

  • Can not access user data
  • Can not delete Stock Glass system applications
  • Can not replace the operating system

Commands to root the Glass device.

  • $ adb reboot bootloader
  • $ fastboot oem unlock ( a byproduct of this command is to erase all the user data and cache, basically puts into factory reset state)
  • $ fastboot flash boot boot.img (overwrite boot partition with new image. boot.img available at developers.google.com/glass/downloads)
  • $ fastboot reboot
  • $ adb root (now have access to data partition)

Second Demonstration - Running Ubuntu on top of Glass Device

  • Downloaded and Installed a couple of apps from Play Store
  • Ran terminal emulator
  • Login as root

Q/A Session

  • Question: Will Google release a factory image so Glass can be flashed back to factory state. Answer: Yes.
  • Question: Does Google have plans to have extra security features on Glass, e.g. to prevent from putting in ADB mode? Answer: They are working on adding more security features.
  • Question: Will more developers be able to obtain the Glass device? Answer: Glass Explorer program is currently closed. Google is working hard to have commercial release of Glass by the end of the year.
  • Question: How will Glassware be delivered, will there be a Play store for Glassware? Answer: They have nothing to announce today, but rest assured there will be a good delivery mechanism in place.
  • Question: Once rooted will you have access to the Camera. Answer: You don't need root to get access to camera stream. You can do that with standard API.
  • Question: Will Google release an emulator so you can develop without a Glass device. Answer: That is something Google is working on, but they really believe you should have access to at least one Glass device to truly see how the application will behave.


Glass Coding Guidelines

Google has banned coding the following on Glass: advertisements, facial recognition, and pornography. Google posted Glass User Interface Guidelines, which starts with the advice:

Glass provides a new kind of interface. As with anything new it provides both new opportunities and poses new design challenges. During our time using and developing for Glass, we've learned a few things that we would like to share with you. Please follow these guidelines as you build out your service.

Google also created a short video with guidelines for coding with the Mirror API.<.p>


Glassware Blog

Additional information about coding Glassware can be found at the Glassware Blog. On the blog site you can: