Last week Pebble Locker added first class support for Android Wear allowing users to add their Android Wear devices as a trusted device and automatically lock and unlock their phones and tablets.
Pebble Locker uses the WearableListenerService to learn when Android Wears are connected and disconnected. The source code is available on GitHub