<commit_before>/*
 LinkingServiceDiscoveryProfile.java
 Copyright (c) 2016 NTT DOCOMO,INC.
 Released under the MIT license
 http://opensource.org/licenses/mit-license.php
 */
package org.deviceconnect.android.deviceplugin.linking.profile;

import android.content.Intent;
import android.os.Bundle;

import org.deviceconnect.android.deviceplugin.linking.linking.LinkingDevice;
import org.deviceconnect.android.deviceplugin.linking.linking.LinkingManagerFactory;
import org.deviceconnect.android.deviceplugin.linking.linking.LinkingUtil;
import org.deviceconnect.android.profile.DConnectProfile;
import org.deviceconnect.android.profile.DConnectProfileProvider;
import org.deviceconnect.android.profile.ServiceDiscoveryProfile;
import org.deviceconnect.message.DConnectMessage;
import org.deviceconnect.profile.DeviceOrientationProfileConstants;
import org.deviceconnect.profile.LightProfileConstants;
import org.deviceconnect.profile.VibrationProfileConstants;

import java.util.ArrayList;
import java.util.List;

/**
 * Discovery Profile.
 *
 * @author NTT DOCOMO, INC.
 */
public class LinkingServiceDiscoveryProfile extends ServiceDiscoveryProfile {

    public LinkingServiceDiscoveryProfile(final DConnectProfileProvider provider) {
        super(provider);
    }

    @Override
    protected boolean onGetServices(final Intent request, final Intent response) {
        List<LinkingDevice> list = LinkingManagerFactory.createManager(getContext().getApplicationContext()).getDevices();
        if (list.size() == 0) {
            setResult(response, DConnectMessage.RESULT_OK);
            return true;
        }
        Bundle[] services = new Bundle[list.size()];
        int index = 0;
        for (LinkingDevice device : list) {
            Bundle service = new Bundle();
            ServiceDiscoveryProfile.setId(service, device.getBdAddress());
            ServiceDiscoveryProfile.setName(service, device.getDisplayName());
            ServiceDiscoveryProfile.setType(service, NetworkType.BLE);
            ServiceDiscoveryProfile.setOnline(service, device.isConnected());
            DConnectProfileProvider provider = getProfileProvider();
            List<String> scopes = new ArrayList<>();
            for (DConnectProfile profile : provider.getProfileList()) {
                scopes.add(profile.getProfileName());
            }
            if (!LinkingUtil.hasLED(device)) {
                scopes.remove(LightProfileConstants.PROFILE_NAME);
            }
            if (!LinkingUtil.hasVibration(device)) {
                scopes.remove(VibrationProfileConstants.PROFILE_NAME);
            }
            if (!LinkingUtil.hasSensor(device)) {
                scopes.remove(DeviceOrientationProfileConstants.PROFILE_NAME);
            }
            String[] array = new String[scopes.size()];
            array = scopes.toArray(array);
            service.putStringArray(PARAM_SCOPES, array);
            services[index] = service;
            index++;
        }
        setServices(response, services);
        setResult(response, DConnectMessage.RESULT_OK);
        return true;
    }

}
<commit_msg>Added a log.<commit_after>/*
 LinkingServiceDiscoveryProfile.java
 Copyright (c) 2016 NTT DOCOMO,INC.
 Released under the MIT license
 http://opensource.org/licenses/mit-license.php
 */
package org.deviceconnect.android.deviceplugin.linking.profile;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import org.deviceconnect.android.deviceplugin.linking.BuildConfig;
import org.deviceconnect.android.deviceplugin.linking.linking.LinkingDevice;
import org.deviceconnect.android.deviceplugin.linking.linking.LinkingManagerFactory;
import org.deviceconnect.android.deviceplugin.linking.linking.LinkingUtil;
import org.deviceconnect.android.profile.DConnectProfile;
import org.deviceconnect.android.profile.DConnectProfileProvider;
import org.deviceconnect.android.profile.ServiceDiscoveryProfile;
import org.deviceconnect.message.DConnectMessage;
import org.deviceconnect.profile.DeviceOrientationProfileConstants;
import org.deviceconnect.profile.LightProfileConstants;
import org.deviceconnect.profile.VibrationProfileConstants;

import java.util.ArrayList;
import java.util.List;

/**
 * Discovery Profile.
 *
 * @author NTT DOCOMO, INC.
 */
public class LinkingServiceDiscoveryProfile extends ServiceDiscoveryProfile {

    public LinkingServiceDiscoveryProfile(final DConnectProfileProvider provider) {
        super(provider);
    }

    @Override
    protected boolean onGetServices(final Intent request, final Intent response) {
        if (BuildConfig.DEBUG) {
            Log.i("LinkingPlugIn", "ServiceDiscovery:onGetServices");
        }
        List<LinkingDevice> list = LinkingManagerFactory.createManager(getContext().getApplicationContext()).getDevices();
        if (list.size() == 0) {
            setResult(response, DConnectMessage.RESULT_OK);
            return true;
        }
        Bundle[] services = new Bundle[list.size()];
        int index = 0;
        for (LinkingDevice device : list) {
            if (BuildConfig.DEBUG) {
                Log.i("LinkingPlugIn", "name:" + device.getDisplayName() + " feature:" + device.getFeature());
            }
            Bundle service = new Bundle();
            ServiceDiscoveryProfile.setId(service, device.getBdAddress());
            ServiceDiscoveryProfile.setName(service, device.getDisplayName());
            ServiceDiscoveryProfile.setType(service, NetworkType.BLE);
            ServiceDiscoveryProfile.setOnline(service, device.isConnected());
            DConnectProfileProvider provider = getProfileProvider();
            List<String> scopes = new ArrayList<>();
            for (DConnectProfile profile : provider.getProfileList()) {
                scopes.add(profile.getProfileName());
            }
            if (!LinkingUtil.hasLED(device)) {
                scopes.remove(LightProfileConstants.PROFILE_NAME);
            }
            if (!LinkingUtil.hasVibration(device)) {
                scopes.remove(VibrationProfileConstants.PROFILE_NAME);
            }
            if (!LinkingUtil.hasSensor(device)) {
                scopes.remove(DeviceOrientationProfileConstants.PROFILE_NAME);
            }
            String[] array = new String[scopes.size()];
            array = scopes.toArray(array);
            service.putStringArray(PARAM_SCOPES, array);
            services[index] = service;
            index++;
        }
        setServices(response, services);
        setResult(response, DConnectMessage.RESULT_OK);
        return true;
    }

}

{'fraction_non_alphanumeric': 0.09848484848484848, 'fraction_numerical': 0.0018181818181818182, 'mean_word_length': 3.225992317541613, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2776718', 'n_tokens_mistral': 1739, 'n_tokens_neox': 1678, 'n_words': 295}