File tree Expand file tree Collapse file tree
play-services-wearable/core/src/main/java/org/microg/gms/wearable Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -729,27 +729,36 @@ public void run() {
729729 // Start message processing thread
730730 new Thread (connection ).start ();
731731
732- // Send our identity to the watch
733- String localId = getLocalNodeId ();
734- connection .writeMessage (
735- new RootMessage .Builder ()
736- .connect (new Connect .Builder ()
737- .id (localId )
738- .name ("Phone" )
739- .build ())
740- .build ()
741- );
732+ try {
733+ // Send our identity to the watch
734+ String localId = getLocalNodeId ();
735+ connection .writeMessage (
736+ new RootMessage .Builder ()
737+ .connect (new Connect .Builder ()
738+ .id (localId )
739+ .name ("Phone" )
740+ .networkId (localId )
741+ .peerAndroidId (localId )
742+ .peerVersion (2 )
743+ .build ())
744+ .build ()
745+ );
746+ } catch (IOException e ) {
747+ Log .w (TAG , "Handshake failed, closing connection" , e );
748+ connection .close ();
749+ }
742750 }
743751 } catch (IOException e ) {
744752 Log .d (TAG , "BT connection failed: " + e .getMessage ());
745- if (socket != null ) {
753+ if (socket != null && ! socket . isConnected () ) {
746754 try {
747755 socket .close ();
748756 } catch (IOException closeErr ) {
749757 // Ignore
750758 }
751759 }
752760 }
761+
753762 }
754763 }
755764 } catch (Exception e ) {
You can’t perform that action at this time.
0 commit comments