0

I have an Android "companion" app which runs on the phone to which Glass is tethered, and talks to a GDK app running on Glass. What I'm looking for is a way to determine (programmatically, from the phone side) if a given Bluetooth pairing is to Glass or not.

The only thing I've come up with is to check if the device name includes the word "Glass" - since, AFAIK, the default device name that Glass assigns itself always does, and there's no UI that I know of to change it. But that's pretty hokey. Any better ideas?

Sterling
  • 6,365
  • 2
  • 32
  • 40

1 Answers1

0

I think you can iterate over the list of service uuids from BluetoothAdapter.getDefaultAdapter().getBondedDevices() and then check for the Glass uuid.

Set<BluetoothDevice> devices = BluetoothAdapter.getDefaultAdapter().getBondedDevices();
BluetoothDevice glass = null;
for (BluetoothDevice d : devices {
    ParcelUuid[] uuids = d.getUuids();
        for (ParcelUuid p : uuids) {
           System.out.println(p.getUuid().toString());
           if (p.getUuid().toString().equals("fafbdd20-83f0-4389-addf-917ac9dae5b1")) {
                  //found in the GlassHome.apk for XE16.  
                 glass = d;
                 break;
           }
          //NOTE: you may need to adjust this UIUD.
        }
     if (glass != null) { break; }
}
if (glass != null) {
   if (glass.getBondState().equals(BOND_BONDED) {
      //This last check makes sure you are through the pairing process.

   }
}
John Fontaine
  • 1,019
  • 9
  • 14
  • I didn't get a chance to test this on XE16 before my device updated to 16.1, but it's not working there. My Glass has 5 UIUDs, none of which is the one checked for here. – Sterling Apr 23 '14 at 02:44