Java 类com.google.android.gms.wearable.CapabilityInfo 实例源码

项目:Excuser    文件:MainWearActivity.java   
private void checkIfPhoneHasApp() {
    Log.d(TAG, "checkIfPhoneHasApp()");

    PendingResult<CapabilityApi.GetCapabilityResult> pendingResult =
            Wearable.CapabilityApi.getCapability(
                    mGoogleApiClient,
                    CAPABILITY_PHONE_APP,
                    CapabilityApi.FILTER_ALL);

    pendingResult.setResultCallback(new ResultCallback<CapabilityApi.GetCapabilityResult>() {

        @Override
        public void onResult(@NonNull CapabilityApi.GetCapabilityResult getCapabilityResult) {
            Log.d(TAG, "onResult(): " + getCapabilityResult);

            if (getCapabilityResult.getStatus().isSuccess()) {
                CapabilityInfo capabilityInfo = getCapabilityResult.getCapability();
                mAndroidPhoneNodeWithApp = pickBestNodeId(capabilityInfo.getNodes());
                verifyNodeAndUpdateUI();

            } else {
                Log.d(TAG, "Failed CapabilityApi: " + getCapabilityResult.getStatus());
            }
        }
    });
}
项目:adrenaline_watch_face    文件:SonicBoomFace.java   
private void setupF35Wearable() {
    CapabilityApi.GetCapabilityResult result =
            Wearable.CapabilityApi.getCapability(
                    mGoogleApiClient, F35_WEARABLE_CAPABILITY_NAME,
                    CapabilityApi.FILTER_REACHABLE).await();

    updateTranscriptionCapability(result.getCapability());

    //setupComplete(); we can fire messages

    CapabilityApi.CapabilityListener capabilityListener =
            new CapabilityApi.CapabilityListener() {
                @Override
                public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
                    updateTranscriptionCapability(capabilityInfo);
                }
            };

    Wearable.CapabilityApi.addCapabilityListener(
            mGoogleApiClient,
            capabilityListener,
            F35_WEARABLE_CAPABILITY_NAME);
}
项目:xDrip    文件:ListenerService.java   
@Override
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    Node phoneNode = updatePhoneSyncBgsCapability(capabilityInfo);
    Log.d(TAG, "onCapabilityChanged mPhoneNodeID:" + (phoneNode != null ? phoneNode.getId() : ""));//mPhoneNodeId
    //onPeerConnected and onPeerDisconnected deprecated at the same time as BIND_LISTENER

    if (phoneNode != null && phoneNode.getId().length() > 0) {
        if (JoH.ratelimit("on-connected-nodes-sync", 1200)) {
            Log.d(TAG, "onCapabilityChanged event - attempting resync");
            requestData();
        } else {
            Log.d(TAG, "onCapabilityChanged event - ratelimited");
        }
        sendPrefSettings();//from onPeerConnected
    }
}
项目:xDrip-plus    文件:ListenerService.java   
@Override
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    Node phoneNode = updatePhoneSyncBgsCapability(capabilityInfo);
    Log.d(TAG, "onCapabilityChanged mPhoneNodeID:" + (phoneNode != null ? phoneNode.getId() : ""));//mPhoneNodeId
    //onPeerConnected and onPeerDisconnected deprecated at the same time as BIND_LISTENER

    if (phoneNode != null && phoneNode.getId().length() > 0) {
        if (JoH.ratelimit("on-connected-nodes-sync", 1200)) {
            Log.d(TAG, "onCapabilityChanged event - attempting resync");
            requestData();
        } else {
            Log.d(TAG, "onCapabilityChanged event - ratelimited");
        }
        sendPrefSettings();//from onPeerConnected
    }
}
项目:PowerSwitch_Android    文件:MessageApiHandler.java   
private void setupReachableReceiverActionTrigger() {
    CapabilityApi.GetCapabilityResult result = Wearable.CapabilityApi.getCapability(
            googleApiClient, context
                    .getResources()
                    .getString(eu.power_switch.shared.R.string.RECEIVER_ACTION_TRIGGER_CAPABILITY_NAME), CapabilityApi.FILTER_REACHABLE)
            .await();
    updateReceiverActionTriggerCapability(result.getCapability());

    CapabilityApi.CapabilityListener capabilityListener =
            new CapabilityApi.CapabilityListener() {
                @Override
                public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
                    updateReceiverActionTriggerCapability(capabilityInfo);
                }
            };

    Wearable.CapabilityApi.addCapabilityListener(googleApiClient, capabilityListener,
            context.getResources()
                    .getString(eu.power_switch.shared.R.string.RECEIVER_ACTION_TRIGGER_CAPABILITY_NAME));
}
项目:airhero_watch_face    文件:F35Face.java   
private void setupF35Wearable() {
    CapabilityApi.GetCapabilityResult result =
            Wearable.CapabilityApi.getCapability(
                    mGoogleApiClient, F35_WEARABLE_CAPABILITY_NAME,
                    CapabilityApi.FILTER_REACHABLE).await();

    updateTranscriptionCapability(result.getCapability());

    //setupComplete(); we can fire messages

    CapabilityApi.CapabilityListener capabilityListener =
            new CapabilityApi.CapabilityListener() {
                @Override
                public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
                    updateTranscriptionCapability(capabilityInfo);
                }
            };

    Wearable.CapabilityApi.addCapabilityListener(
            mGoogleApiClient,
            capabilityListener,
            F35_WEARABLE_CAPABILITY_NAME);
}
项目:android-DataLayer    文件:MainActivity.java   
/**
 * Find the connected nodes that provide at least one of the given capabilities
 */
private void showNodes(final String... capabilityNames) {

    Task<Map<String, CapabilityInfo>> capabilitiesTask =
            Wearable.getCapabilityClient(this)
                    .getAllCapabilities(CapabilityClient.FILTER_REACHABLE);

    capabilitiesTask.addOnSuccessListener(new OnSuccessListener<Map<String, CapabilityInfo>>() {
        @Override
        public void onSuccess(Map<String, CapabilityInfo> capabilityInfoMap) {
            Set<Node> nodes = new HashSet<>();

            if (capabilityInfoMap.isEmpty()) {
                showDiscoveredNodes(nodes);
                return;
            }
            for (String capabilityName : capabilityNames) {
                CapabilityInfo capabilityInfo = capabilityInfoMap.get(capabilityName);
                if (capabilityInfo != null) {
                    nodes.addAll(capabilityInfo.getNodes());
                }
            }
            showDiscoveredNodes(nodes);
        }
    });
}
项目:wear-dnd-sync    文件:SettingsService.java   
@Override
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    super.onCapabilityChanged(capabilityInfo);
    if (capabilityInfo.getNodes().isEmpty())
        return;

    Log.d(TAG, "Watch connected");
    forceSync();
}
项目:Excuser    文件:MainWearActivity.java   
@Override
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    Log.d(TAG, "onCapabilityChanged(): " + capabilityInfo);

    mAndroidPhoneNodeWithApp = pickBestNodeId(capabilityInfo.getNodes());
    verifyNodeAndUpdateUI();
}
项目:Excuser    文件:DeviceWearConnectionFragment.java   
@SuppressLint("LongLogTag")
@Override
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    Log.d(TAG, "onCapabilityChanged(): " + capabilityInfo);

    mWearNodesWithApp = capabilityInfo.getNodes();

    // Because we have an updated list of devices with/without our app, we need to also update
    // our list of active Wear devices.
    findAllWearDevices();
    verifyNodeAndUpdateUI();
}
项目:Excuser    文件:DeviceWearConnectionFragment.java   
@SuppressLint("LongLogTag")
private void findWearDevicesWithApp() {
    Log.d(TAG, "findWearDevicesWithApp()");

    // You can filter this by FILTER_REACHABLE if you only want to open Nodes (Wear Devices)
    // directly connect to your phone.
    PendingResult<CapabilityApi.GetCapabilityResult> pendingResult =
            Wearable.CapabilityApi.getCapability(
                    mGoogleApiClient,
                    CAPABILITY_WEAR_APP,
                    CapabilityApi.FILTER_ALL);

    pendingResult.setResultCallback(new ResultCallback<CapabilityApi.GetCapabilityResult>() {
        @Override
        public void onResult(@NonNull CapabilityApi.GetCapabilityResult getCapabilityResult) {
            Log.d(TAG, "findWearDevicesWithApp onResult(): " + getCapabilityResult);

            if (getCapabilityResult.getStatus().isSuccess()) {
                CapabilityInfo capabilityInfo = getCapabilityResult.getCapability();
                mWearNodesWithApp = capabilityInfo.getNodes();
                verifyNodeAndUpdateUI();

            } else {
                Log.d(TAG, "Failed CapabilityApi: " + getCapabilityResult.getStatus());
            }
        }
    });
}
项目:locus-addon-wearables    文件:WearCommService.java   
@Override
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    Set<Node> capableNodes = capabilityInfo != null ? capabilityInfo.getNodes() : null;
    mCapableClientDetected = capableNodes != null && capableNodes.size() > 0 ?
            TriStateLogicEnum.TRUE : TriStateLogicEnum.FALSE;

    if (mApp != null) {
        mApp.onCapableClientConnected();
    }
}
项目:GmsWear    文件:GmsWear.java   
/**
 * Clients can register to {@link DataConsumer#onCapabilityChanged(String, Set)}.
 */
void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    String capability = capabilityInfo.getName();
    Set<Node> nodes = capabilityInfo.getNodes();
    mCapabilityToNodesMapping.put(capability, nodes);
    for (DataConsumer consumer : mDataConsumers) {
        consumer.onCapabilityChanged(capability, nodes);
    }
}
项目:PainlessMusicPlayer    文件:RemoteControl.java   
private void updateRemoteControlCapability(@Nullable final CapabilityInfo capabilityInfo) {
    if (capabilityInfo != null) {
        final String playbackNodeId = pickBestNodeId(capabilityInfo.getNodes());
        mPlaybackNodeListener.onNodeConnectionStateChanged(playbackNodeId != null);
        synchronized (mCapabilityLock) {
            mPlaybackControlNodeId = playbackNodeId;
        }
    }
}
项目:WearSocket    文件:WearSocket.java   
private void findCapableNode(final String capability) {
    Log.d(TAG,"Start looking for a capable node");
    new Thread(new Runnable() {
        @Override
        public void run() {
            CapabilityApi.GetCapabilityResult result =
                    Wearable.CapabilityApi.getCapability(googleApiClient,capability,CapabilityApi.FILTER_REACHABLE).await();
            CapabilityInfo capabilityInfo = result.getCapability();
            Set<Node> nodes = capabilityInfo.getNodes();
            String nodeID = findBestNodeId(nodes);
            Log.d(TAG,"Node found: "+nodeID);
            if (nodeID==null) {
                //This might be caused by there not being a watch paired to the device
                //Run it on the UI thread
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        errorListener.onError(new Throwable("Error, cannot find a connected device"));
                    }
                });

                return;
            }
            WearSocket.this.nodeID = nodeID;
            nodeFound.release();
        }
    }).start();
}
项目:cordova-androidwear    文件:WearProviderService.java   
private void loadNodes() {
    Task<CapabilityInfo> capabilityTask = Wearable.getCapabilityClient(this)
            .getCapability(CORDOVA_CAPABILITY, CapabilityClient.FILTER_REACHABLE);
    capabilityTask.addOnSuccessListener(new OnSuccessListener<CapabilityInfo>() {
        @Override
        public void onSuccess(CapabilityInfo capabilityInfo) {
            WearProviderService.this.onCapabilityChanged(capabilityInfo);
        }
    });
}
项目:JudoNetworking    文件:MessageUtils.java   
public <T> T sendMessageAndReceive(Object msg, int operationTimeout, Class<T> clazz) throws IOException {
    makeSureIsConnected();
    CapabilityInfo capabilityInfo = Wearable.CapabilityApi.getCapability(
            googleClient, context.getString(R.string.jj_request_proxy),
            CapabilityApi.FILTER_REACHABLE).await().getCapability();
    if (capabilityInfo == null) {
        throw new ConnectionException("CapabilityApi unavailable");
    }
    Set<Node> nodes = capabilityInfo.getNodes();
    String id = generateUniqId();
    Object waitObject = new Object();
    waitObjects.put(id, waitObject);
    sendMessage(id, pickBestNodeId(nodes), msg);
    try {
        synchronized (waitObject) {
            waitObject.wait(readTimeout + operationTimeout);
        }
    } catch (InterruptedException e) {
        throw new ConnectionException("GoogleApiClient timeout");
    } finally {
        waitObjects.remove(id);
    }
    byte[] message = resultObjects.remove(id);
    if (message != null) {
        return readObject(message, clazz);
    } else {
        throw new ConnectionException("GoogleApiClient timeout");
    }
}
项目:SunshineWithWear    文件:MyDigitalWatchFace.java   
private void updateTranscriptionCapability(CapabilityInfo capabilityInfo) {
    Set<Node> connectedNodes = capabilityInfo.getNodes();

    transcriptionNodeId = pickBestNodeId(connectedNodes);
}
项目:adrenaline_watch_face    文件:SonicBoomFace.java   
private void updateTranscriptionCapability(CapabilityInfo capabilityInfo) {
    Set<Node> connectedNodes = capabilityInfo.getNodes();
    phoneNodeId = pickBestNodeId(connectedNodes);
}
项目:xDrip    文件:ListenerService.java   
private Node updatePhoneSyncBgsCapability(CapabilityInfo capabilityInfo) {
    Set<Node> connectedNodes = capabilityInfo.getNodes();
    return pickBestNode(connectedNodes);
    //mPhoneNodeId = pickBestNodeId(connectedNodes);
}
项目:xDrip    文件:WatchUpdaterService.java   
private void updateWearSyncBgsCapability(CapabilityInfo capabilityInfo) {
    Set<Node> connectedNodes = capabilityInfo.getNodes();
    mWearNodeId = pickBestNodeId(connectedNodes);
}
项目:xDrip    文件:WatchUpdaterService.java   
@Override
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    updateWearSyncBgsCapability(capabilityInfo);
    Log.d(TAG, "onConnected onCapabilityChanged mWearNodeID:" + mWearNodeId);
    new CheckWearableConnected().execute();
}
项目:xDrip    文件:WatchUpdaterService.java   
@Override
protected Void doInBackground(Void... voids) {
    if (googleApiClient.isConnected()) {
        if (System.currentTimeMillis() - lastRequest > 20 * 1000) { // enforce 20-second debounce period
            lastRequest = System.currentTimeMillis();
            //NodeApi.GetConnectedNodesResult nodes =
            //        Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
            if (localnode == null || (localnode != null && localnode.isEmpty())) setLocalNodeName();
            CapabilityApi.GetCapabilityResult capabilityResult =
                    Wearable.CapabilityApi.getCapability(
                            googleApiClient, CAPABILITY_WEAR_APP,
                            CapabilityApi.FILTER_REACHABLE).await(GET_CAPABILITIES_TIMEOUT_MS, TimeUnit.MILLISECONDS);
            CapabilityInfo nodes;
            if (!capabilityResult.getStatus().isSuccess()) {
                Log.e(TAG, "doInBackground Failed to get capabilities, status: " + capabilityResult.getStatus().getStatusMessage());
                nodes = null;
            }
            else {
                nodes = capabilityResult.getCapability();
            }
            SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
            SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit();
            boolean enable_wearG5 = sharedPrefs.getBoolean("enable_wearG5", false);
            boolean force_wearG5 = sharedPrefs.getBoolean("force_wearG5", false);
            String node_wearG5 = mPrefs.getString("node_wearG5", "");

            if (nodes != null && nodes.getNodes().size() > 0) {
                updateWearSyncBgsCapability(nodes);
                int count = nodes.getNodes().size();
                Log.d(TAG, "doInBackground connected.  CapabilityApi.GetCapabilityResult mWearNodeID=" + (mWearNodeId != null ? mWearNodeId : "") + " count=" + count);//KS
                boolean isConnectedToWearable = false;
                for (Node peer : nodes.getNodes()) {

                    //onPeerConnected
                    String wearNode = peer.getDisplayName() + "|" + peer.getId();
                    Log.d(TAG, "CheckWearableConnected onPeerConnected peer name & ID: " + wearNode);
                    if (wearNode.equals(node_wearG5)) {
                        isConnectedToWearable = true;
                        sendPrefSettings();
                        break;
                    }
                    else if (node_wearG5.equals("")) {
                        isConnectedToWearable = true;
                        prefs.putString("node_wearG5", wearNode);
                        prefs.commit();
                        break;
                    }

                }
                sendPrefSettings();
                initWearData();
                if (enable_wearG5) {
                    //Only stop service if Phone will rely on Wear Collection Service
                    if (force_wearG5 && isConnectedToWearable) {
                        Log.d(TAG, "CheckWearableConnected onPeerConnected force_wearG5=true Phone stopBtService and continue to use Wear BT Collector");
                        stopBtService();
                    } else {
                        Log.d(TAG, "CheckWearableConnected onPeerConnected force_wearG5=false Phone startBtService");
                        startBtService();
                    }
                }
            }
            else {
                //onPeerDisconnected
                Log.d(TAG, "CheckWearableConnected onPeerDisconnected");
                if (sharedPrefs.getBoolean("wear_sync", false)) {
                    Log.d(TAG, "CheckWearableConnected onPeerDisconnected wear_sync=true Phone startBtService");
                    startBtService();
                }
            }
        } else {
            Log.d(TAG, "Debounce limit hit - not sending");
        }
    } else {
        Log.d(TAG, "Not connected for sending");
        googleApiClient.connect();
    }
    return null;
}
项目:xDrip-plus    文件:ListenerService.java   
private Node updatePhoneSyncBgsCapability(CapabilityInfo capabilityInfo) {
    Set<Node> connectedNodes = capabilityInfo.getNodes();
    return pickBestNode(connectedNodes);
    //mPhoneNodeId = pickBestNodeId(connectedNodes);
}
项目:xDrip-plus    文件:WatchUpdaterService.java   
private void updateWearSyncBgsCapability(CapabilityInfo capabilityInfo) {
    Set<Node> connectedNodes = capabilityInfo.getNodes();
    mWearNodeId = pickBestNodeId(connectedNodes);
}
项目:xDrip-plus    文件:WatchUpdaterService.java   
@Override
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    updateWearSyncBgsCapability(capabilityInfo);
    Log.d(TAG, "onConnected onCapabilityChanged mWearNodeID:" + mWearNodeId);
    new CheckWearableConnected().execute();
}
项目:xDrip-plus    文件:WatchUpdaterService.java   
@Override
protected Void doInBackground(Void... voids) {
    if (googleApiClient.isConnected()) {
        if (System.currentTimeMillis() - lastRequest > 20 * 1000) { // enforce 20-second debounce period
            lastRequest = System.currentTimeMillis();
            //NodeApi.GetConnectedNodesResult nodes =
            //        Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
            if (localnode == null || (localnode != null && localnode.isEmpty())) setLocalNodeName();
            CapabilityApi.GetCapabilityResult capabilityResult =
                    Wearable.CapabilityApi.getCapability(
                            googleApiClient, CAPABILITY_WEAR_APP,
                            CapabilityApi.FILTER_REACHABLE).await(GET_CAPABILITIES_TIMEOUT_MS, TimeUnit.MILLISECONDS);
            CapabilityInfo nodes;
            if (!capabilityResult.getStatus().isSuccess()) {
                Log.e(TAG, "doInBackground Failed to get capabilities, status: " + capabilityResult.getStatus().getStatusMessage());
                nodes = null;
            }
            else {
                nodes = capabilityResult.getCapability();
            }
            SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
            SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit();
            boolean enable_wearG5 = sharedPrefs.getBoolean("enable_wearG5", false);
            boolean force_wearG5 = sharedPrefs.getBoolean("force_wearG5", false);
            String node_wearG5 = mPrefs.getString("node_wearG5", "");

            if (nodes != null && nodes.getNodes().size() > 0) {
                updateWearSyncBgsCapability(nodes);
                int count = nodes.getNodes().size();
                Log.d(TAG, "doInBackground connected.  CapabilityApi.GetCapabilityResult mWearNodeID=" + (mWearNodeId != null ? mWearNodeId : "") + " count=" + count);//KS
                boolean isConnectedToWearable = false;
                for (Node peer : nodes.getNodes()) {

                    //onPeerConnected
                    String wearNode = peer.getDisplayName() + "|" + peer.getId();
                    Log.d(TAG, "CheckWearableConnected onPeerConnected peer name & ID: " + wearNode);
                    if (wearNode.equals(node_wearG5)) {
                        isConnectedToWearable = true;
                        sendPrefSettings();
                        break;
                    }
                    else if (node_wearG5.equals("")) {
                        isConnectedToWearable = true;
                        prefs.putString("node_wearG5", wearNode);
                        prefs.commit();
                        break;
                    }

                }
                sendPrefSettings();
                initWearData();
                if (enable_wearG5) {
                    //Only stop service if Phone will rely on Wear Collection Service
                    if (force_wearG5 && isConnectedToWearable) {
                        Log.d(TAG, "CheckWearableConnected onPeerConnected force_wearG5=true Phone stopBtService and continue to use Wear BT Collector");
                        stopBtService();
                    } else {
                        Log.d(TAG, "CheckWearableConnected onPeerConnected force_wearG5=false Phone startBtService");
                        startBtService();
                    }
                }
            }
            else {
                //onPeerDisconnected
                Log.d(TAG, "CheckWearableConnected onPeerDisconnected");
                if (sharedPrefs.getBoolean("wear_sync", false)) {
                    Log.d(TAG, "CheckWearableConnected onPeerDisconnected wear_sync=true Phone startBtService");
                    startBtService();
                }
            }
        } else {
            Log.d(TAG, "Debounce limit hit - not sending");
        }
    } else {
        Log.d(TAG, "Not connected for sending");
        googleApiClient.connect();
    }
    return null;
}
项目:stayawhile-android    文件:MainActivity.java   
private void updateTranscriptionCapability(CapabilityInfo capabilityInfo) {
    Set<Node> connectedNodes = capabilityInfo.getNodes();

    hostNodeId = pickBestNodeId(connectedNodes);
}
项目:GmsWear    文件:GmsWear.java   
/**
 * Clients can register to {@link DataConsumer#onGmsApiConnected()}.
 */
private void onConnected(Bundle bundle) {
    WearUtil.logD(TAG, "Google Api Connected");
    for (DataConsumer consumer : mDataConsumers) {
        consumer.onGmsApiConnected();
    }
    addCapabilities(mCapabilitiesToBeAdded);
    Wearable.CapabilityApi.getAllCapabilities(mGoogleApiClient,
            CapabilityApi.FILTER_REACHABLE).setResultCallback(

            new ResultCallback<CapabilityApi.GetAllCapabilitiesResult>() {
                @Override
                public void onResult(
                        CapabilityApi.GetAllCapabilitiesResult getAllCapabilitiesResult) {
                    if (getAllCapabilitiesResult.getStatus().isSuccess()) {
                        Map<String, CapabilityInfo> capabilities = getAllCapabilitiesResult
                                .getAllCapabilities();
                        if (capabilities != null) {
                            for (String capability : capabilities.keySet()) {
                                CapabilityInfo info = capabilities.get(capability);
                                mCapabilityToNodesMapping.put(capability, info.getNodes());
                            }
                        }
                        onConnectedInitialCapabilitiesReceived();
                    } else {
                        Log.e(TAG, "getAllCapabilities(): Failed to get all the capabilities");
                    }
                }
            });
    Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).setResultCallback(
            new ResultCallback<NodeApi.GetConnectedNodesResult>() {
                @Override
                public void onResult(NodeApi.GetConnectedNodesResult getConnectedNodesResult) {
                    if (getConnectedNodesResult.getStatus().isSuccess()) {
                        mConnectedNodes.clear();
                        mConnectedNodes.addAll(getConnectedNodesResult.getNodes());
                        onConnectedInitialNodesReceived();
                    }
                }
            });
}
项目:GmsWear    文件:GmsWearService.java   
@Override
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    super.onCapabilityChanged(capabilityInfo);
    mGmsWear.onCapabilityChanged(capabilityInfo);
}
项目:PainlessMusicPlayer    文件:WearableSearchProviderService.java   
private void onActionSearch(@NonNull final Intent intent) {
    final String query = intent.getStringExtra(EXTRA_QUERY);
    if (query == null) {
        throw new IllegalArgumentException("EXTRA_QUERY is null");
    }

    final WearSearchData.Results results = new WearSearchData.Results();
    results.albums = queryAlbums(query);
    results.artists = queryArtists(query);
    results.tracks = queryTracks(query);

    final GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API).build();
    final ConnectionResult connectionResult = googleApiClient.blockingConnect();
    if (!connectionResult.isSuccess()) {
        Log.w(TAG, "GoogleApiClient not connected: " + GoogleApiAvailability.getInstance()
                .getErrorString(connectionResult.getErrorCode()));
        return;
    }

    try {
        final String capability = getString(R.string.wear_capability_search_receiver);
        final CapabilityApi.GetCapabilityResult capabilityResult = Wearable.CapabilityApi
                .getCapability(googleApiClient, capability, CapabilityApi.FILTER_REACHABLE)
                .await();
        final CapabilityInfo capabilityInfo = capabilityResult.getCapability();
        if (capabilityInfo == null) {
            Log.w(TAG, "No search receiver devices connected");
            return;
        }

        final String searchReceiverNodeId = pickBestNodeId(capabilityInfo.getNodes());
        if (TextUtils.isEmpty(searchReceiverNodeId)) {
            Log.w(TAG, "No search receiver nodes found");
            return;
        }

        final byte[] resultsArray;
        try {
            resultsArray = ProtoUtils.toByteArray(results);
        } catch (IOException e) {
            Log.w(TAG, e);
            return;
        }

        Wearable.MessageApi.sendMessage(googleApiClient, searchReceiverNodeId,
                DataPaths.Messages.SEARCH_RESULT, resultsArray).await();
    } finally {
        googleApiClient.disconnect();
    }

}
项目:wearbooksource    文件:MyWearableListenerService.java   
@Override
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    super.onCapabilityChanged(capabilityInfo);
    Log.d(TAG, "onCapabilityChanged() ...") ;
}
项目:PowerSwitch_Android    文件:MessageApiHandler.java   
private void updateReceiverActionTriggerCapability(CapabilityInfo capabilityInfo) {
    connectedNodes = capabilityInfo.getNodes();
}
项目:mage-chronostouch-android    文件:DataListenerService.java   
@Override
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    DataManager.getInstance(this).updateCapability(capabilityInfo);
}
项目:mage-chronostouch-android    文件:DataManager.java   
public void updateCapability(CapabilityInfo capabilityInfo) {
    // TODO: Do something with this capabilityinfo.
}
项目:airhero_watch_face    文件:F35Face.java   
private void updateTranscriptionCapability(CapabilityInfo capabilityInfo) {
    Set<Node> connectedNodes = capabilityInfo.getNodes();
    phoneNodeId = pickBestNodeId(connectedNodes);
}
项目:cordova-androidwear    文件:WearProviderService.java   
@Override
public void onCapabilityChanged(@NonNull CapabilityInfo capabilityInfo) {
    LOGD(TAG, "onCapabilityChanged: " + capabilityInfo);

    syncNodes(capabilityInfo.getNodes());
}
项目:android-DataLayer    文件:MainActivity.java   
@Override
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
    LOGD(TAG, "onCapabilityChanged: " + capabilityInfo);
    mDataFragment.appendItem("onCapabilityChanged", capabilityInfo.toString());
}
项目:android-DataLayer    文件:MainActivity.java   
@Override
public void onCapabilityChanged(final CapabilityInfo capabilityInfo) {
    LOGD(TAG, "onCapabilityChanged: " + capabilityInfo);

    mDataItemListAdapter.add(new Event("onCapabilityChanged", capabilityInfo.toString()));
}
项目:CrossBow    文件:CrossbowListenerService.java   
@Override
@CallSuper
public void onCapabilityChanged(CapabilityInfo capabilityInfo) {
}