private void closeConnection(String nodeId) { WearableConnection connection = activeConnections.get(nodeId); try { connection.close(); } catch (IOException e1) { Log.w(TAG, e1); } if (connection == sct.getWearableConnection()) { sct.close(); sct = null; } activeConnections.remove(nodeId); for (ConnectionConfiguration config : getConfigurations()) { if (config.nodeId.equals(nodeId) || config.peerNodeId.equals(nodeId)) { config.connected = false; } } onPeerDisconnected(new NodeParcelable(nodeId, "Wear device")); Log.d(TAG, "Closed connection to " + nodeId + " on error"); }
public final void onConnectedNodes(final List<NodeParcelable> paramList) { zzb(new Runnable() { public final void run() {} }, "onConnectedNodes", paramList); }
public final void zza(final NodeParcelable paramNodeParcelable) { zzb(new Runnable() { public final void run() {} }, "onPeerConnected", paramNodeParcelable); }
public final void zzb(final NodeParcelable paramNodeParcelable) { zzb(new Runnable() { public final void run() {} }, "onPeerDisconnected", paramNodeParcelable); }
@Override public void onPeerConnected(final NodeParcelable node) throws RemoteException { post(new Runnable() { @Override public void run() { WearableListenerService.this.onPeerConnected(node); } }); }
@Override public void onPeerDisconnected(final NodeParcelable node) throws RemoteException { post(new Runnable() { @Override public void run() { WearableListenerService.this.onPeerDisconnected(node); } }); }
@Override public void onConnectedNodes(final List<NodeParcelable> nodes) throws RemoteException { post(new Runnable() { @Override public void run() { WearableListenerService.this.onConnectedNodes(new ArrayList<Node>(nodes)); } }); }
public void onConnectReceived(WearableConnection connection, String nodeId, Connect connect) { for (ConnectionConfiguration config : getConfigurations()) { if (config.nodeId.equals(nodeId)) { if (config.nodeId != nodeId) { config.nodeId = connect.id; configDatabase.putConfiguration(config, nodeId); } config.peerNodeId = connect.id; config.connected = true; } } Log.d(TAG, "Adding connection to list of open connections: " + connection + " with connect " + connect); activeConnections.put(connect.id, connection); onPeerConnected(new NodeParcelable(connect.id, connect.name)); // Fetch missing assets Cursor cursor = nodeDatabase.listMissingAssets(); if (cursor != null) { while (cursor.moveToNext()) { try { Log.d(TAG, "Fetch for " + cursor.getString(12)); connection.writeMessage(new RootMessage.Builder() .fetchAsset(new FetchAsset.Builder() .assetName(cursor.getString(12)) .packageName(cursor.getString(1)) .signatureDigest(cursor.getString(2)) .permission(false) .build()).build()); } catch (IOException e) { Log.w(TAG, e); closeConnection(connect.id); } } cursor.close(); } }
public void onDisconnectReceived(WearableConnection connection, Connect connect) { for (ConnectionConfiguration config : getConfigurations()) { if (config.nodeId.equals(connect.id)) { config.connected = false; } } Log.d(TAG, "Removing connection from list of open connections: " + connection); activeConnections.remove(connect.id); onPeerDisconnected(new NodeParcelable(connect.id, connect.name)); }
public List<NodeParcelable> getConnectedNodesParcelableList() { List<NodeParcelable> nodes = new ArrayList<NodeParcelable>(); for (Node connectedNode : connectedNodes) { nodes.add(new NodeParcelable(connectedNode)); } return nodes; }
public void onPeerConnected(NodeParcelable node) { Log.d(TAG, "onPeerConnected: " + node); try { getAllListeners().onPeerConnected(node); } catch (RemoteException e) { Log.w(TAG, e); } addConnectedNode(node); }
public void onPeerDisconnected(NodeParcelable node) { Log.d(TAG, "onPeerDisconnected: " + node); try { getAllListeners().onPeerDisconnected(node); } catch (RemoteException e) { Log.w(TAG, e); } removeConnectedNode(node.getId()); }
public void onConnectedNodes(List<NodeParcelable> nodes) { Log.d(TAG, "onConnectedNodes: " + nodes); try { getAllListeners().onConnectedNodes(nodes); } catch (RemoteException e) { Log.w(TAG, e); } }