<commit_before>/*
 KadecotDeviceService.java
Copyright (c) 2015 Sony Computer Science Labs, Inc.
Released under the MIT license
http://opensource.org/licenses/mit-license.php

 */
package com.sonycsl.Kadecot.plugin.gotapi;

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

import com.sonycsl.Kadecot.plugin.gotapi.profile.DummyLightProfile;
import com.sonycsl.Kadecot.plugin.gotapi.profile.KadecotProfile;
import com.sonycsl.Kadecot.plugin.gotapi.profile.KadecotServiceDiscoveryProfile;
import com.sonycsl.Kadecot.plugin.gotapi.profile.KadecotServiceInformationProfile;
import com.sonycsl.Kadecot.plugin.gotapi.profile.KadecotSystemProfile;

import org.deviceconnect.android.event.EventManager;
import org.deviceconnect.android.event.cache.db.DBCacheController;
import org.deviceconnect.android.localoauth.LocalOAuth2Main;
import org.deviceconnect.android.message.DConnectMessageService;
import org.deviceconnect.android.profile.ServiceDiscoveryProfile;
import org.deviceconnect.android.profile.ServiceInformationProfile;
import org.deviceconnect.android.profile.SystemProfile;

import java.util.Iterator;
import java.util.logging.Logger;


public class KadecotDeviceService extends DConnectMessageService {

    /** ロガー. */
    private Logger mLogger = Logger.getLogger("dconnect.dplugin.kadecot");

    @Override
    public void onCreate() {
        super.onCreate();
        EventManager.INSTANCE.setController(new DBCacheController(this));
        LocalOAuth2Main.initialize(getApplicationContext());
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());
        addProfile(new KadecotProfile());
        addProfile(new DummyLightProfile());
    }

    @Override
    public int onStartCommand(final Intent intent, final int flags, final int startId) {
        mLogger.info("onStartCommand: intent:\n" + intent);
        if (intent != null) {
            mLogger.info("onStartCommand: extras=" + toString(intent.getExtras()));
        }

        return super.onStartCommand(intent, flags, startId);
    }

    /*
     * JSON文字列に変換する.
     * @param bundle Bundle
     * @return JSON String
     */
    private String toString(final Bundle bundle) {
        StringBuilder sb = new StringBuilder();
        sb.append("{");<commit_msg>perform network operation outside of main thread<commit_after>/*
 KadecotDeviceService.java
Copyright (c) 2015 Sony Computer Science Labs, Inc.
Released under the MIT license
http://opensource.org/licenses/mit-license.php

 */
package com.sonycsl.Kadecot.plugin.gotapi;

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

import com.sonycsl.Kadecot.plugin.gotapi.profile.DummyLightProfile;
import com.sonycsl.Kadecot.plugin.gotapi.profile.KadecotProfile;
import com.sonycsl.Kadecot.plugin.gotapi.profile.KadecotServiceDiscoveryProfile;
import com.sonycsl.Kadecot.plugin.gotapi.profile.KadecotServiceInformationProfile;
import com.sonycsl.Kadecot.plugin.gotapi.profile.KadecotSystemProfile;

import org.deviceconnect.android.event.EventManager;
import org.deviceconnect.android.event.cache.db.DBCacheController;
import org.deviceconnect.android.localoauth.LocalOAuth2Main;
import org.deviceconnect.android.message.DConnectMessageService;
import org.deviceconnect.android.profile.ServiceDiscoveryProfile;
import org.deviceconnect.android.profile.ServiceInformationProfile;
import org.deviceconnect.android.profile.SystemProfile;

import java.util.Iterator;
import java.util.logging.Logger;


public class KadecotDeviceService extends DConnectMessageService {

    /** ロガー. */
    private Logger mLogger = Logger.getLogger("dconnect.dplugin.kadecot");

    @Override
    public void onCreate() {
        super.onCreate();
        EventManager.INSTANCE.setController(new DBCacheController(this));
        LocalOAuth2Main.initialize(getApplicationContext());
        //StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());
        addProfile(new KadecotProfile());
        addProfile(new DummyLightProfile());
    }

    @Override
    public int onStartCommand(final Intent intent, final int flags, final int startId) {
        mLogger.info("onStartCommand: intent:\n" + intent);
        if (intent != null) {
            mLogger.info("onStartCommand: extras=" + toString(intent.getExtras()));
        }
        new Thread(new Runnable() {
            @Override
            public void run() {
                KadecotDeviceService.super.onStartCommand(intent, flags, startId);
            }
        }).start();

        return START_STICKY;
    }

    /*
     * JSON文字列に変換する.
     * @param bundle Bundle
     * @return JSON String
     */
    private String toString(final Bundle bundle) {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
{'fraction_non_alphanumeric': 0.10395010395010396, 'fraction_numerical': 0.002494802494802495, 'mean_word_length': 4.0802534318901795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '536184', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1376, 'n_words': 248}