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

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbManager;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;

import com.hoho.android.usbserial.driver.UsbSerialDriver;
import com.hoho.android.usbserial.driver.UsbSerialPort;
import com.hoho.android.usbserial.driver.UsbSerialProber;
import com.hoho.android.usbserial.util.SerialInputOutputManager;

import org.deviceconnect.android.deviceplugin.smartmeter.device.BP35C2;
import org.deviceconnect.android.deviceplugin.smartmeter.device.UsbSerialDevice;
import org.deviceconnect.android.deviceplugin.smartmeter.param.DongleConst;
import org.deviceconnect.android.deviceplugin.smartmeter.param.WiSunDevice;
import org.deviceconnect.android.deviceplugin.smartmeter.profiles.SmartMeterDeviceProfile;
import org.deviceconnect.android.deviceplugin.smartmeter.profiles.SmartMeterPowerMeterProfile;
import org.deviceconnect.android.deviceplugin.smartmeter.profiles.SmartMeterSystemProfile;
import org.deviceconnect.android.deviceplugin.smartmeter.util.ENLUtil;
import org.deviceconnect.android.deviceplugin.smartmeter.util.PrefUtil;
import org.deviceconnect.android.deviceplugin.smartmeter.util.TestUtil;
import org.deviceconnect.android.message.DConnectMessageService;
import org.deviceconnect.android.message.MessageUtils;
import org.deviceconnect.android.profile.SystemProfile;
import org.deviceconnect.android.service.DConnectService;
import org.deviceconnect.message.DConnectMessage;
import org.deviceconnect.profile.ServiceDiscoveryProfileConstants;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static org.deviceconnect.android.profile.DConnectProfile.setResult;

/**
 * 本デバイスプラグインのプロファイルをDeviceConnectに登録するサービス.
 *
 * @author NTT DOCOMO, INC.
 */
public class SmartMeterMessageService extends DConnectMessageService {
    /** Tag. */
    private final static String TAG = "SMARTMETER_PLUGIN";
    /** デバッグフラグ. */
    private static final boolean DEBUG = BuildConfig.DEBUG;
    /** Dongleとの接続が完了した時にActivityを終了するフラグを格納するキー. */
    public static final String EXTRA_FINISH_FLAG = "flag";
    /** USBシリアルデバイス管理DBHelper. */
    private SmartMeterDBHelper mSmartMeterDBHelper;
    /** USB Port. */
    private static UsbSerialPort mSerialPort = null;
    /** USBのSerial IO Manager. */
    private static SerialInputOutputManager mSerialIoManager;
    /** Executor. */
    private final ExecutorService mExecutor = Executors.newSingleThreadExecutor();
    /** Status. */
    private static int mStatus;
    /** PrefUtil Instance. */
    private PrefUtil mPrefUtil;
    /** Wi-SUN Config. */
    WiSunDevice mWiSunDevice = new WiSunDevice();
    /** ECHONET Lite Utility Class. */
    ENLUtil mENLUtil = new ENLUtil();
    /** USBシリアルデバイスリスト. */
    ArrayList<UsbSerialDevice> mUsbSerialDevices = new ArrayList<>();
    /** ペアリング応答返信先Intent. */
    private Intent mPairingResponse;
    /** ペアリング先ServiceId. */
    private String mPairngServiceId;

    @Override
    public void onCreate() {
        super.onCreate();
        if (DEBUG) {
            android.os.Debug.waitForDebugger();
        }

        mPrefUtil = new PrefUtil(this);
        mSmartMeterDBHelper = new SmartMeterDBHelper(getApplicationContext());

        // USBのEvent用のBroadcast Receiverを設定.
        IntentFilter mIntentFilter = new IntentFilter();
        mIntentFilter.addAction(DongleConst.DEVICE_TO_DONGLE_OPEN_USB);
        mIntentFilter.addAction(DongleConst.DEVICE_TO_DONGLE_CHECK_USB);
        mIntentFilter.addAction(DongleConst.DEVICE_TO_DONGLE_CLOSE_USB);
        mIntentFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
        registerReceiver(mUSBEvent, mIntentFilter);
        /* DB保存USBシリアルデバイスリスト展開. */
        loadUSBSerialDeviceList();
        /* USBシリアルデバイス検索スレッド起動. */
        startSearchUSBSerialDeviceThread();
    }<commit_msg>ダミーデータ使用評価版起動対応。<commit_after>/*
 SmartMeterMessageService.java
 Copyright (c) 2017 NTT DOCOMO,INC.
 Released under the MIT license
 http://opensource.org/licenses/mit-license.php
 */
package org.deviceconnect.android.deviceplugin.smartmeter;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbManager;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;

import com.hoho.android.usbserial.driver.UsbSerialDriver;
import com.hoho.android.usbserial.driver.UsbSerialPort;
import com.hoho.android.usbserial.driver.UsbSerialProber;
import com.hoho.android.usbserial.util.SerialInputOutputManager;

import org.deviceconnect.android.deviceplugin.smartmeter.device.BP35C2;
import org.deviceconnect.android.deviceplugin.smartmeter.device.UsbSerialDevice;
import org.deviceconnect.android.deviceplugin.smartmeter.param.DongleConst;
import org.deviceconnect.android.deviceplugin.smartmeter.param.WiSunDevice;
import org.deviceconnect.android.deviceplugin.smartmeter.profiles.SmartMeterDeviceProfile;
import org.deviceconnect.android.deviceplugin.smartmeter.profiles.SmartMeterPowerMeterProfile;
import org.deviceconnect.android.deviceplugin.smartmeter.profiles.SmartMeterSystemProfile;
import org.deviceconnect.android.deviceplugin.smartmeter.util.ENLUtil;
import org.deviceconnect.android.deviceplugin.smartmeter.util.PrefUtil;
import org.deviceconnect.android.deviceplugin.smartmeter.util.TestUtil;
import org.deviceconnect.android.message.DConnectMessageService;
import org.deviceconnect.android.message.MessageUtils;
import org.deviceconnect.android.profile.SystemProfile;
import org.deviceconnect.android.service.DConnectService;
import org.deviceconnect.message.DConnectMessage;
import org.deviceconnect.profile.ServiceDiscoveryProfileConstants;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static org.deviceconnect.android.profile.DConnectProfile.setResult;

/**
 * 本デバイスプラグインのプロファイルをDeviceConnectに登録するサービス.
 *
 * @author <NAME>, INC.
 */
public class SmartMeterMessageService extends DConnectMessageService {
    /** Tag. */
    private final static String TAG = "SMARTMETER_PLUGIN";
    /** デバッグフラグ. */
    private static final boolean DEBUG = BuildConfig.DEBUG;
    /** Dongleとの接続が完了した時にActivityを終了するフラグを格納するキー. */
    public static final String EXTRA_FINISH_FLAG = "flag";
    /** USBシリアルデバイス管理DBHelper. */
    private SmartMeterDBHelper mSmartMeterDBHelper;
    /** USB Port. */
    private static UsbSerialPort mSerialPort = null;
    /** USBのSerial IO Manager. */
    private static SerialInputOutputManager mSerialIoManager;
    /** Executor. */
    private final ExecutorService mExecutor = Executors.newSingleThreadExecutor();
    /** Status. */
    private static int mStatus;
    /** PrefUtil Instance. */
    private PrefUtil mPrefUtil;
    /** Wi-SUN Config. */
    WiSunDevice mWiSunDevice = new WiSunDevice();
    /** ECHONET Lite Utility Class. */
    ENLUtil mENLUtil = new ENLUtil();
    /** USBシリアルデバイスリスト. */
    ArrayList<UsbSerialDevice> mUsbSerialDevices = new ArrayList<>();
    /** ペアリング応答返信先Intent. */
    private Intent mPairingResponse;
    /** ペアリング先ServiceId. */
    private String mPairngServiceId;

    @Override
    public void onCreate() {
        super.onCreate();
//        if (DEBUG) {
//            android.os.Debug.waitForDebugger();
//        }

        mPrefUtil = new PrefUtil(this);
        mSmartMeterDBHelper = new SmartMeterDBHelper(getApplicationContext());

        // USBのEvent用のBroadcast Receiverを設定.
        IntentFilter mIntentFilter = new IntentFilter();
        mIntentFilter.addAction(DongleConst.DEVICE_TO_DONGLE_OPEN_USB);
        mIntentFilter.addAction(DongleConst.DEVICE_TO_DONGLE_CHECK_USB);
        mIntentFilter.addAction(DongleConst.DEVICE_TO_DONGLE_CLOSE_USB);
        mIntentFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
        registerReceiver(mUSBEvent, mIntentFilter);
        /* DB保存USBシリアルデバイスリスト展開. */
        loadUSBSerialDeviceList();
        /* USBシリアルデバイス検索スレッド起動. */
        startSearchUSBSerialDeviceThread();
    }
{'fraction_non_alphanumeric': 0.09662108712848909, 'fraction_numerical': 0.0015820996722793535, 'mean_word_length': 4.644132653061225, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '7666792', 'n_tokens_mistral': 2818, 'n_tokens_neox': 2776, 'n_words': 427}