diff --git a/README.md b/README.md
index ed4f3550ce..008188bce5 100755
--- a/README.md
+++ b/README.md
@@ -150,17 +150,8 @@ curl -X GET \
## デバイスプラグイン
| プロジェクト名|内容 |
|:-----------|:---------|
-|[dConnectDeviceAndroidWear](dConnectDevicePlugin/dConnectDeviceAndroidWear)|AndroidWearのデバイスプラグイン。|
-|[dConnectDeviceChromeCast](dConnectDevicePlugin/dConnectDeviceChromeCast)|Chromecastのデバイスプラグイン。 |
-|[dConnectDeviceFaBo](dConnectDevicePlugin/dConnectDeviceFaBo)|FaBoのデバイスプラグイン。|
-|[dConnectDeviceHeartRate](dConnectDevicePlugin/dConnectDeviceHeartRate)|Mio AlphaなどのHeartRateのデバイスプラグイン。|
-|[dConnectDeviceHOGP](dConnectDevicePlugin/dConnectDeviceHOGP)|HOGPのデバイスプラグイン。|
|[dConnectDeviceHost](dConnectDevicePlugin/dConnectDeviceHost)|Androidのデバイスプラグイン。|
-|[dConnectDeviceHue](dConnectDevicePlugin/dConnectDeviceHue)|Hueのデバイスプラグイン。|
-|[dConnectDeviceIRKit](dConnectDevicePlugin/dConnectDeviceIRKit)|IRKitのデバイスプラグイン。|
|[dConnectDeviceLinking](dConnectDevicePlugin/dConnectDeviceLinking)|Linkingのデバイスプラグイン。|
-|[dConnectDeviceSwitchBot](dConnectDevicePlugin/dConnectDeviceSwitchBot)|SwitchBotのデバイスプラグイン。|
-|[dConnectDeviceTheta](dConnectDevicePlugin/dConnectDeviceTheta)|THETAのデバイスプラグイン。|
|[dConnectDeviceUVC](dConnectDevicePlugin/dConnectDeviceUVC)|UVCカメラのデバイスプラグイン。|
|[dConnectDeviceTest](dConnectDevicePlugin/dConnectDeviceTest)|DeviceConnectのテスト用のデバイスプラグイン。|
|[dConnectDevicePluginSDK](dConnectDevicePlugin/dConnectDevicePluginSDK)|DevicePluginを作成するためのSDK。 dConnectSDKForAndroidが必要。|
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/LICENSE.TXT b/dConnectDevicePlugin/dConnectDeviceAndroidWear/LICENSE.TXT
deleted file mode 100755
index 9f0bfd2fe5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/LICENSE.TXT
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2014 NTT DOCOMO, INC.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/README.md b/dConnectDevicePlugin/dConnectDeviceAndroidWear/README.md
deleted file mode 100644
index 7f45ea3dd9..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# Android Wear プラグイン
-
-このAndroid Wearプラグインでは、Android Wearに対応したスマートウォッチを操作する機能を提供します。
-
-## 開発環境
-Android Studio 2.2.1以上
-
-## ビルドマニュアル
-- [Android Wearビルドマニュアル](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/AndroidWear-Build)
-
-## サポートするプロファイル
-
-* canvas
-* deviceOrientation
-* keyEvent
-* notification
-* touch
-* vibration
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/build.gradle b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/build.gradle
deleted file mode 100644
index ac59734fd9..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/build.gradle
+++ /dev/null
@@ -1,89 +0,0 @@
-apply plugin: 'com.android.application'
-// Create github.properties in root project folder file with
-// gpr.usr=GITHUB_USER_ID
-// gpr.key=PERSONAL_ACCESS_TOKEN
-def githubPropertiesFile = rootProject.file("github.properties")
-def githubProperties = new Properties()
-if (githubPropertiesFile.exists()) {
- githubProperties.load(new FileInputStream(githubPropertiesFile))
-}
-
-dependencies {
- implementation fileTree(include: '*.jar', dir: 'libs')
- implementation 'org.deviceconnect:dconnect-device-plugin-sdk:2.8.4'
- implementation 'androidx.multidex:multidex:2.0.1'
- implementation 'com.google.android.gms:play-services-wearable:17.0.0'
-
- wearApp project(':wear-app')
-}
-
-android {
-
- compileSdkVersion 29
-
- def getVersionName = { ->
- def version
- if (System.getProperty('os.name').toLowerCase().contains('windows')) {
- version = ["cmd", "/c", "git describe --tags --long"].execute().in.text.trim()
- } else {
- version = ["sh", "-c", "git describe --tags --long"].execute().in.text.trim()
- }
- version = version.empty ? "2.1.0" : version
- return "${version}"
- }
-
- defaultConfig {
- applicationId "org.deviceconnect.android.deviceplugin.wear"
- minSdkVersion 23
- targetSdkVersion 29
- versionCode 1
- versionName getVersionName()
- multiDexEnabled true
- }
-
- signingConfigs {
- releaseConfig {
- storeFile=file(project.properties.storeFile)
- storePassword=project.properties.storePassword
- keyAlias=project.properties.keyAlias
- keyPassword=project.properties.keyPassword
- }
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
- signingConfig signingConfigs.releaseConfig
- }
- }
-
- packagingOptions {
- exclude 'LICENSE.txt'
- exclude 'META-INF/DEPENDENCIES'
- exclude 'META-INF/LICENSE'
- exclude 'META-INF/NOTICE'
- }
- tasks.withType(JavaCompile) {
- options.encoding = 'UTF-8'
- }
- lintOptions {
- checkReleaseBuilds false
- abortOnError false
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- repositories {
- maven {
- name = "DeviceConnect-Android"
- url = uri("https://maven.pkg.github.com/DeviceConnect/DeviceConnect-Android")
-
- credentials {
- username = System.getenv("GPR_USER") ?: githubProperties['gpr.usr']
- password = System.getenv("GPR_API_KEY") ?: githubProperties['gpr.key']
- }
- }
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/AndroidManifest.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/AndroidManifest.xml
deleted file mode 100755
index 76ac0caac4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearDeviceProvider.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearDeviceProvider.java
deleted file mode 100755
index 3071fef382..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearDeviceProvider.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- WearServiceProvider.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear;
-
-import android.app.Service;
-
-import org.deviceconnect.android.message.DConnectMessageServiceProvider;
-
-/**
- * Provider.
- *
- * @param Service class.
- * @author NTT DOCOMO, INC.
- */
-public class WearDeviceProvider extends DConnectMessageServiceProvider {
- @SuppressWarnings("unchecked")
- @Override
- protected Class getServiceClass() {
- Class extends Service> clazz = WearDeviceService.class;
- return (Class) clazz;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearDeviceService.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearDeviceService.java
deleted file mode 100755
index 921390b189..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearDeviceService.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- WearDeviceService.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear;
-
-import android.content.Intent;
-
-import com.google.android.gms.wearable.Node;
-
-import org.deviceconnect.android.deviceplugin.wear.profile.WearConst;
-import org.deviceconnect.android.deviceplugin.wear.profile.WearNotificationProfile;
-import org.deviceconnect.android.deviceplugin.wear.profile.WearServiceDiscoveryProfile;
-import org.deviceconnect.android.deviceplugin.wear.profile.WearSystemProfile;
-import org.deviceconnect.android.deviceplugin.wear.profile.WearUtils;
-import org.deviceconnect.android.deviceplugin.wear.service.WearService;
-import org.deviceconnect.android.event.Event;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.DConnectMessageService;
-import org.deviceconnect.android.profile.SystemProfile;
-import org.deviceconnect.android.service.DConnectService;
-
-import java.util.List;
-
-/**
- * WearService.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearDeviceService extends DConnectMessageService implements WearManager.NodeEventListener {
-
- /**
- * Android Wearとの通信を管理するクラス.
- */
- private WearManager mWearManager;
-
- @Override
- public void onCreate() {
- super.onCreate();
- mWearManager = new WearManager(this);
- mWearManager.addNodeListener(this);
- mWearManager.init();
-
- addProfile(new WearServiceDiscoveryProfile(mWearManager, getServiceProvider()));
- }
-
- @Override
- public int onStartCommand(final Intent intent, final int flags, final int startId) {
- if (intent != null) {
- String action = intent.getAction();
- if (WearConst.DEVICE_TO_WEAR_NOTIFICATION_OPEN.equals(action)) {
- String serviceId = intent.getStringExtra(WearConst.PARAM_DEVICEID);
- int notificationId = intent.getIntExtra(WearConst.PARAM_NOTIFICATIONID, -1);
- List events = EventManager.INSTANCE.getEventList(serviceId,
- WearNotificationProfile.PROFILE_NAME, null, WearNotificationProfile.ATTRIBUTE_ON_CLICK);
- synchronized (events) {
- for (Event event : events) {
- Intent msg = EventManager.createEventMessage(event);
- msg.putExtra(WearNotificationProfile.PARAM_NOTIFICATION_ID, notificationId);
- sendEvent(msg, event.getAccessToken());
- }
- }
- } else if (WearConst.DEVICE_TO_WEAR_NOTIFICATION_CLOSED.equals(action)) {
- String serviceId = intent.getStringExtra(WearConst.PARAM_DEVICEID);
- int notificationId = intent.getIntExtra(WearConst.PARAM_NOTIFICATIONID, -1);
- List events = EventManager.INSTANCE.getEventList(serviceId,
- WearNotificationProfile.PROFILE_NAME, null, WearNotificationProfile.ATTRIBUTE_ON_CLOSE);
- synchronized (events) {
- for (Event event : events) {
- Intent msg = EventManager.createEventMessage(event);
- msg.putExtra(WearNotificationProfile.PARAM_NOTIFICATION_ID, notificationId);
- sendEvent(msg, event.getAccessToken());
- }
- }
- }
- }
- return super.onStartCommand(intent, flags, startId);
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- if (mWearManager != null) {
- mWearManager.destroy();
- mWearManager = null;
- }
- }
-
- @Override
- protected SystemProfile getSystemProfile() {
- return new WearSystemProfile();
- }
-
- @Override
- public void onNodeConnected(final Node node) {
- DConnectService service = WearService.getInstance(node, mWearManager);
- service.setOnline(node.isNearby());
- getServiceProvider().addService(service);
- getManager().sendWearData();
- }
-
- @Override
- public void onNodeDisconnected(final Node node) {
- String serviceId = WearUtils.createServiceId(node.getId());
- DConnectService service = getServiceProvider().getService(serviceId);
- if (service != null) {
- service.setOnline(false);
- } else {
- DConnectService addService = WearService.getInstance(node, mWearManager);
- addService.setOnline(node.isNearby());
- getServiceProvider().addService(addService);
- }
- }
-
- /**
- * Android Wear管理クラスを取得する.
- * @return WearManagerのインスタンス
- */
- public WearManager getManager() {
- return mWearManager;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearManager.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearManager.java
deleted file mode 100644
index 379b492ecc..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearManager.java
+++ /dev/null
@@ -1,449 +0,0 @@
-package org.deviceconnect.android.deviceplugin.wear;
-
-import android.content.Context;
-import android.net.Uri;
-import androidx.annotation.NonNull;
-
-import com.google.android.gms.tasks.OnFailureListener;
-import com.google.android.gms.tasks.OnSuccessListener;
-import com.google.android.gms.tasks.Task;
-import com.google.android.gms.tasks.Tasks;
-import com.google.android.gms.wearable.Asset;
-import com.google.android.gms.wearable.CapabilityClient;
-import com.google.android.gms.wearable.CapabilityInfo;
-import com.google.android.gms.wearable.DataItem;
-import com.google.android.gms.wearable.MessageClient;
-import com.google.android.gms.wearable.MessageEvent;
-import com.google.android.gms.wearable.Node;
-import com.google.android.gms.wearable.PutDataMapRequest;
-import com.google.android.gms.wearable.PutDataRequest;
-import com.google.android.gms.wearable.Wearable;
-
-import org.deviceconnect.android.deviceplugin.wear.profile.WearConst;
-
-import org.deviceconnect.android.logger.AndroidHandler;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.logging.SimpleFormatter;
-
-/**
- * Android Wearを管理するクラス.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearManager {
-
- private final Logger mLogger = Logger.getLogger("dconnect.wear");
-
-
- /**
- * コンテキスト.
- */
- private final Context mContext;
-
- /**
- * スレッド管理用クラス.
- */
- private final ExecutorService mExecutorService = Executors.newSingleThreadExecutor();
-
- /**
- * メッセージイベントリスナー一覧.
- */
- private final Map mOnMessageEventListeners
- = new HashMap<>();
-
- /**
- * ノード検知リスナー一覧.
- */
- private final List mNodeEventListeners = new ArrayList<>();
-
- /**
- * ノード情報のキャッシュ.
- */
- private final Map mNodeCache = new HashMap();
-
- /**
- * コンストラクタ.
- *
- * @param context このクラスが属するコンテキスト
- */
- public WearManager(final Context context) {
- mContext = context;
- if (BuildConfig.DEBUG) {
- AndroidHandler handler = new AndroidHandler(mLogger.getName());
- handler.setFormatter(new SimpleFormatter());
- handler.setLevel(Level.ALL);
- mLogger.addHandler(handler);
- mLogger.setLevel(Level.ALL);
- } else {
- mLogger.setLevel(Level.OFF);
- }
- }
-
-
- /**
- * このクラスを初期化する.
- */
- public void init() {
- setCapabilityListener();
- setMessageListener();
- getNodes((results) -> {
- if (results == null) {
- return;
- }
- synchronized (mNodeCache) {
- for (Node node : results) {
- if (!mNodeCache.containsKey(node.getId())) {
- mNodeCache.put(node.getId(), node);
- mLogger.info("getNodes: name = " + node.getDisplayName()
- + ", id = " + node.getId());
- notifyOnNodeConnected(node);
- }
- }
- }
- });
- }
-
- /**
- * 接続しているAndroidWearにIDを送る.
- */
- public void sendWearData() {
- new Thread(() -> {
- getNodes((results) -> {
- if (results == null) {
- return;
- }
- synchronized (mNodeCache) {
- for (Node node : results) {
- if (!mNodeCache.containsKey(node.getId())) {
- mNodeCache.put(node.getId(), node);
- mLogger.info("getNode: name = " + node.getDisplayName()
- + ", id = " + node.getId());
- notifyOnNodeConnected(node);
-
- }
- }
- }
- });
- for (String key : mNodeCache.keySet()) {
- Node node = mNodeCache.get(key);
- sendMessageToWear(node.getId(), WearConst.DEVICE_TO_WEAR_SET_ID, node.getId(), null);
- mLogger.info("sendMessage: name = " + node.getDisplayName()
- + ", id = " + node.getId());
- }
- }).start();
- }
- /**
- * 後始末処理を行う.
- */
- public void destroy() {
- mExecutorService.shutdown();
- mNodeEventListeners.clear();
- mOnMessageEventListeners.clear();
- mNodeCache.clear();
- }
-
- /**
- * メッセージイベントリスナーを追加する.
- *
- * @param path パス
- * @param listener リスナー
- */
- public void addMessageEventListener(final String path, final OnMessageEventListener listener) {
- mOnMessageEventListeners.put(path, listener);
- }
-
- /**
- * ノード検知リスナーを追加する.
- */
- public void addNodeListener(final NodeEventListener listener) {
- synchronized (mNodeEventListeners) {
- mNodeEventListeners.add(listener);
- }
- }
-
- /**
- * Wearとの接続状況を検知するリスナー.
- */
- private void setCapabilityListener() {
- Wearable.getCapabilityClient(mContext).addListener((capabilityInfo) -> {
- for (Node node : capabilityInfo.getNodes()) {
- if (node.isNearby()) {
- mLogger.info("isNearby=true: name = " + node.getDisplayName()
- + ", id = " + node.getId());
- mNodeCache.put(node.getId(), node);
- notifyOnNodeConnected(node);
- } else {
- mLogger.info("onPeerDisconnected: name = " + node.getDisplayName()
- + ", id = " + node.getId());
- mNodeCache.remove(node.getId());
- notifyOnNodeDisconnected(node);
- }
- }
- }, Uri.parse("wear://"), CapabilityClient.FILTER_REACHABLE);
- }
-
- private void notifyOnNodeConnected(final Node node) {
- synchronized (mNodeEventListeners) {
- for (NodeEventListener listener : mNodeEventListeners) {
- listener.onNodeConnected(node);
- }
- }
- }
-
- private void notifyOnNodeDisconnected(final Node node) {
- synchronized (mNodeEventListeners) {
- for (NodeEventListener listener : mNodeEventListeners) {
- listener.onNodeDisconnected(node);
- }
- }
- }
-
- /**
- * Android Wearのリスナーを設定する.
- */
- private void setMessageListener() {
- Wearable.getMessageClient(mContext).addListener((messageEvent) -> {
- final String data = new String(messageEvent.getData());
- final String path = messageEvent.getPath();
- final String nodeId = messageEvent.getSourceNodeId();
- OnMessageEventListener listener = mOnMessageEventListeners.get(path);
- if (listener != null) {
- listener.onEvent(nodeId, data);
- }
- });
- }
-
- /**
- * Wear nodeを取得.
- *
- * @param listener Wear node取得を通知するリスナー
- */
- public void getNodes(final OnNodeResultListener listener) {
- sendMessageToWear(() -> {
- Task> nodeListTask = Wearable.getNodeClient(mContext).getConnectedNodes();
- List nodes = null;
- try {
- nodes = Tasks.await(nodeListTask);
- } catch (ExecutionException exception) {
- mLogger.warning("Task failed: " + exception);
- } catch (InterruptedException exception) {
- mLogger.warning("Interrupt occurred: " + exception);
- }
- if (listener != null) {
- listener.onResult(nodes);
- }
- });
- }
-
- /**
- * メッセージをWearに送信する.
- *
- * @param dest 送信先のWearのnodeId
- * @param action メッセージのアクション
- * @param message メッセージ
- * @param listener メッセージを送信した結果を通知するリスナー
- */
- public void sendMessageToWear(final String dest, final String action, final String message,
- final OnMessageResultListener listener) {
- getNodes((results) -> {
- for (Node node : results) {
- if (node.getId().contains(dest)) {
- Task sendMessageTask =
- Wearable.getMessageClient(mContext).sendMessage(node.getId(), action, message.getBytes());
- sendMessageTask.addOnSuccessListener((integer) -> {
- if (listener != null) {
- listener.onResult();
- }
- });
-
- sendMessageTask.addOnFailureListener((e) -> {
- if (listener != null) {
- listener.onError();
- }
- });
- }
- }
- });
- }
-
- /**
- * PutDataRequestを作成する.
- *
- * @param nodeId ノードID
- * @param requestId リクエストID
- * @param data requestに格納する画像
- * @param x x座標
- * @param y y座標
- * @param mode 描画モード
- * @return PutDataRequestのインスタンス
- */
- private PutDataRequest createPutDataRequest(final String nodeId, final String requestId, final byte[] data,
- final int x, final int y, final int mode) {
- Asset asset = Asset.createFromBytes(data);
- PutDataMapRequest dataMap = PutDataMapRequest.create(WearConst.PATH_CANVAS + "/" + nodeId + "/" + requestId);
- dataMap.getDataMap().putAsset(WearConst.PARAM_BITMAP, asset);
- dataMap.getDataMap().putInt(WearConst.PARAM_X, x);
- dataMap.getDataMap().putInt(WearConst.PARAM_Y, y);
- dataMap.getDataMap().putInt(WearConst.PARAM_MODE, mode);
- dataMap.getDataMap().putLong(WearConst.TIMESTAMP,
- System.currentTimeMillis());
- return dataMap.asPutDataRequest();
- }
-
- /**
- * 画像データを送信する.
- *
- * @param nodeId ノードID
- * @param requestId リクエストID
- * @param data 画像データ
- * @param x x座標
- * @param y y座標
- * @param mode 描画モード
- * @param listener 送信結果を通知するリスナー
- */
- public void sendImageData(final String nodeId, final String requestId,
- final byte[] data, final int x, final int y,
- final int mode, final OnDataItemResultListener listener) {
- // リクエストIDとともに画像送信
- sendMessageToWear(() -> {
- final PutDataRequest request = createPutDataRequest(nodeId, requestId, data, x, y, mode);
- if (request == null) {
- if (listener != null) {
- listener.onError();
- }
- } else {
- request.setUrgent();
- Task dataItemTask = Wearable.getDataClient(mContext).putDataItem(request);
- dataItemTask.addOnSuccessListener((dataItem) -> {
- if (listener != null) {
- listener.onResult(dataItem);
- }
- });
- dataItemTask.addOnFailureListener((e) -> {
- if (listener != null) {
- listener.onError();
- }
- });
- }
- });
- }
-
- /**
- * Wearにメッセージを送ります.
- *
- * @param run 送るメッセージを実行するrunnable
- */
- private void sendMessageToWear(final Runnable run) {
- mExecutorService.execute(run);
- }
-
- public void getLocalNodeId(final String serviceId, final OnLocalNodeListener listener) {
- getNodes((results) -> {
- for (Node node : results) {
- if (node.getId().equals(serviceId)) {
- if (listener != null) {
- listener.onResult(node);
- }
- return;
- }
- }
- if (listener != null) {
- listener.onError();
- }
- });
- }
-
- /**
- * ノード検知イベントリスナー.
- */
- public interface NodeEventListener {
-
- /**
- * ノードとの接続イベント.
- * @param node ノード
- */
- void onNodeConnected(Node node);
-
- /**
- * ノードとの接続の切断イベント.
- * @param node ノード
- */
- void onNodeDisconnected(Node node);
-
- }
-
- /**
- * Nodeの検索結果を通知するリスナー.
- */
- public interface OnNodeResultListener {
- /**
- * 結果を通知する.
- *
- * @param results 検索結果
- */
- void onResult(List results);
-
- }
-
- public interface OnLocalNodeListener {
-
- void onResult(Node localNode);
-
- void onError();
- }
-
- /**
- * メッセージ送信の結果を通知するリスナー.
- */
- public interface OnMessageResultListener {
- /**
- * メッセージ送信結果を通知する.
- *
- */
- void onResult();
-
- /**
- * エラーが発生したことを通知する.
- */
- void onError();
- }
-
- /**
- * データ送信の結果を通知するリスナー.
- */
- public interface OnDataItemResultListener {
- /**
- * データ送信の結果を通知する.
- *
- * @param result 結果
- */
- void onResult(DataItem result);
-
- /**
- * エラーが発生したことを通知する.
- */
- void onError();
- }
-
- /**
- * イベント受信を通知するリスナー.
- */
- public interface OnMessageEventListener {
- /**
- * 受信したイベントを通知する.
- *
- * @param nodeId ノートID
- * @param message イベントメッセージ
- */
- void onEvent(String nodeId, String message);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/package-info.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/package-info.java
deleted file mode 100644
index f3cf053010..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/package-info.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- org.deviceconnect.android.deviceplugin.wear
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-
-/**
- * Android wear device plugin package.
- */
-package org.deviceconnect.android.deviceplugin.wear;
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearCanvasProfile.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearCanvasProfile.java
deleted file mode 100644
index ce5246f34c..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearCanvasProfile.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
-WearCanvasProfile.java
-Copyright (c) 2015 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.profile;
-
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-
-import com.google.android.gms.wearable.DataItem;
-import com.google.android.gms.wearable.Node;
-
-import org.deviceconnect.android.deviceplugin.wear.WearDeviceService;
-import org.deviceconnect.android.deviceplugin.wear.WearManager;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.CanvasProfile;
-import org.deviceconnect.android.profile.api.DConnectApi;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.io.ByteArrayOutputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.logging.Logger;
-
-/**
- * Android Wear用のCanvasプロファイル.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearCanvasProfile extends CanvasProfile {
-
- /**
- * Android wearは1MB以上の画像は送信できない.
- */
- private static final int LIMIT_DATA_SIZE = 1024 * 1024;
-
- private final Logger mLogger = Logger.getLogger("dconnect.wear");
-
- private ExecutorService mImageService = Executors.newSingleThreadExecutor();
-
- private static final Map mRequestMap = new HashMap<>();
-
- private final WearManager mWearManager;
-
- public WearCanvasProfile(final WearManager mgr) {
- mWearManager = mgr;
- mgr.addMessageEventListener(WearConst.WEAR_TO_DEVICE_CANVAS_RESULT,
- this::onCanvasResponse);
- addApi(mPostDrawImage);
- addApi(mDeleteDrawImage);
- }
-
- private DConnectApi mPostDrawImage = new PostApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_DRAW_IMAGE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String nodeId = WearUtils.getNodeId(getServiceID(request));
- final byte[] data = getData(request);
- final double x = getX(request);
- final double y = getY(request);
- final String mode = getMode(request);
- String mimeType = getMIMEType(request);
- if (mimeType != null && !mimeType.contains("image")) {
- MessageUtils.setInvalidRequestParameterError(response,
- "Unsupported mimeType: " + mimeType);
- return true;
- }
-
- if (data == null) {
- mImageService.execute(() -> {
- String uri = getURI(request);
- byte[] result = getData(uri);
- if (result == null) {
- MessageUtils.setInvalidRequestParameterError(response, "could not get image from uri.");
- sendResponse(response);
- return;
- }
- drawImage(response, nodeId, result, x, y, mode);
- });
- return false;
- } else {
- drawImage(response, nodeId, data, x, y, mode);
- return false;
- }
- }
- };
-
- private void drawImage(final Intent response, final String nodeId,
- final byte[] data, final double x, final double y, final String mode) {
- mWearManager.getLocalNodeId(nodeId, new WearManager.OnLocalNodeListener() {
-
- @Override
- public void onResult(final Node localNode) {
- final String localNodeId = localNode.getId();
- if (data.length > LIMIT_DATA_SIZE) {
- MessageUtils.setInvalidRequestParameterError(response, "data size more than 1MB");
- sendResponse(response);
- return;
- }
- Mode m = Mode.getInstance(mode);
- if ((mode != null && mode.length() > 0) && m == null) {
- MessageUtils.setInvalidRequestParameterError(response, "mode is invalid");
- sendResponse(response);
- return;
- }
-
- //for check binary
- Bitmap bitmap;
- try {
- bitmap = getBitmap(data);
- } catch (OutOfMemoryError e) {
- MessageUtils.setInvalidRequestParameterError(response, "Too large bitmap for host device.");
- sendResponse(response);
- return;
- }
- if (bitmap == null) {
- MessageUtils.setInvalidRequestParameterError(response, "format invalid");
- sendResponse(response);
- return;
- }
- int mm = WearUtils.convertMode(m);
-
- //Adjust image format and compress
- ByteArrayOutputStream o = new ByteArrayOutputStream();
- bitmap.compress(Bitmap.CompressFormat.PNG, 50, o);
- final byte[] bitmapData = o.toByteArray();
-
- final String requestId = UUID.randomUUID().toString();
- final DrawImageRequest wearRequest = createCanvasRequest(localNodeId, requestId);
- getManager().sendImageData(localNodeId, requestId, bitmapData, (int) x, (int) y, mm, new WearManager.OnDataItemResultListener() {
- @Override
- public void onResult(final DataItem result) {
- new Thread(() -> {
- if (result != null) {
- try {
- DrawImageResponse wearResponse = wearRequest.await();
- if (wearResponse.isSuccess()) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- int errorCode = wearResponse.getErrorCode();
- String errorMessage = wearResponse.getErrorMessage();
- MessageUtils.setError(response, errorCode, errorMessage);
- }
- } catch (Exception e) {
- MessageUtils.setUnknownError(response, e.getLocalizedMessage());
- }
- } else {
- MessageUtils.setIllegalDeviceStateError(response);
- }
- sendResponse(response);
- }).start();
- }
-
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- }
-
- @Override
- public void onError() {
- MessageUtils.setUnknownError(response, "Failed to get Local Node ID.");
- }
- });
- }
-
- private final DConnectApi mDeleteDrawImage = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_DRAW_IMAGE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId, WearConst.DEVICE_TO_WEAR_CANCAS_DELETE_IMAGE,
- "", new WearManager.OnMessageResultListener() {
- @Override
- public void onResult() {
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
-
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
- /**
- * データを画像に変換します.
- *
- * @param data 画像データ
- * @return Bitmap
- */
- private Bitmap getBitmap(final byte[] data) {
- return BitmapFactory.decodeByteArray(data, 0, data.length);
- }
-
- /**
- * Android Wear管理クラスを取得する.
- *
- * @return WearManager管理クラス
- */
- private WearManager getManager() {
- return ((WearDeviceService) getContext()).getManager();
- }
-
- private DrawImageRequest createCanvasRequest(final String nodeId, final String requestId) {
- DrawImageRequest request = new DrawImageRequest(nodeId);
- mRequestMap.put(requestId, request);
- return request;
- }
-
- private void onCanvasResponse(final String nodeId, final String message) {
- String[] items = message.split(",");
- String requestId = items[0];
- String result = items[1];
- DrawImageRequest request = mRequestMap.get(requestId);
- if (request == null) {
- mLogger.warning("onCanvasImageResponse: request is not found: nodeId = " + nodeId);
- return;
- }
- if (!request.getNodeId().equals(nodeId)) {
- mLogger.warning("onCanvasImageResponse: nodeId are not matched for request: requestId = " + requestId);
- return;
- }
- request.receive(result);
- mRequestMap.remove(requestId);
- }
-
- private static class DrawImageRequest {
-
- private CountDownLatch mLock = new CountDownLatch(1);
-
- private DrawImageResponse mResponse;
-
- private final String mNodeId;
-
- public DrawImageRequest(final String nodeId) {
- mNodeId = nodeId;
- }
-
- public DrawImageResponse await() throws InterruptedException, ResponseTimeoutException {
- mLock.await(30, TimeUnit.SECONDS);
- if (!hasResponse()) {
- throw new ResponseTimeoutException();
- }
- return mResponse;
- }
-
- public void receive(final String message) {
- mResponse = new DrawImageResponse(message);
- mLock.countDown();
- }
-
- public boolean hasResponse() {
- return mResponse != null;
- }
-
- public String getNodeId() {
- return mNodeId;
- }
- }
-
- private static class DrawImageResponse {
-
- private final String mResult;
- private final int mErrorCode;
- private final String mErrorMessage;
-
- public DrawImageResponse(final String message) {
- mResult = message;
- if (WearConst.RESULT_ERROR_TOO_LARGE_BITMAP.equals(message)) {
- mErrorCode = DConnectMessage.ErrorCode.INVALID_REQUEST_PARAMETER.getCode();
- mErrorMessage = "Too large bitmap for watch.";
- } else if (WearConst.RESULT_ERROR_CONNECTION_FAILURE.equals(message)) {
- mErrorCode = DConnectMessage.ErrorCode.ILLEGAL_DEVICE_STATE.getCode();
- mErrorMessage = "Connection failure.";
- } else if (WearConst.RESULT_ERROR_NOT_SUPPORTED_FORMAT.equals(message)) {
- mErrorCode = DConnectMessage.ErrorCode.INVALID_REQUEST_PARAMETER.getCode();
- mErrorMessage = "Not supported format.";
- } else {
- mErrorCode = 0;
- mErrorMessage = "";
- }
- }
-
- public boolean isSuccess() {
- return WearConst.RESULT_SUCCESS.equals(mResult);
- }
-
- public int getErrorCode() {
- return mErrorCode;
- }
-
- public String getErrorMessage() {
- return mErrorMessage;
- }
- }
-
- private static class ResponseTimeoutException extends TimeoutException {
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearConst.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearConst.java
deleted file mode 100755
index 502ec70057..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearConst.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
-WearConst.java
-Copyright (c) 2014 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.profile;
-
-/**
- * Wear Const.
- *
- * @author NTT DOCOMO, INC.
- */
-public final class WearConst {
-
- /** Vibration start. */
- public static final String DEVICE_TO_WEAR_VIBRATION_RUN
- = "org.deviceconnect.wear.vibration.run";
-
- /** Vibration stop. */
- public static final String DEVICE_TO_WEAR_VIBRATION_DEL
- = "org.deviceconnect.wear.vibration.del";
-
- /** When Action is opened. */
- public static final String DEVICE_TO_WEAR_NOTIFICATION_OPEN
- = "org.deviceconnect.wear.notification.open";
-
- /** When Action is closed. */
- public static final String DEVICE_TO_WEAR_NOTIFICATION_CLOSED
- = "org.deviceconnect.wear.notification.closed";
-
- /** When DeviceOrientation register is opened. */
- public static final String DEVICE_TO_WEAR_DEIVCEORIENTATION_REGISTER
- = "org.deviceconnect.wear.deivceorienatation.regist";
-
- /** When DeviceOrientation unregister is opened. */
- public static final String DEVICE_TO_WEAR_DEIVCEORIENTATION_UNREGISTER
- = "org.deviceconnect.wear.deivceorienatation.unregist";
-
- /** When Canvas deleted. */
- public static final String DEVICE_TO_WEAR_CANCAS_DELETE_IMAGE
- = "org.deviceconnect.wear.canvas.delete";
-
- /** Wear to Android. */
- public static final String WEAR_TO_DEVICE_DEIVCEORIENTATION_DATA
- = "org.deviceconnect.wear.deivceorienatation.data";
-
- /** Register Key Event (ondown). */
- public static final String DEVICE_TO_WEAR_KEYEVENT_ONDOWN_REGISTER
- = "org.deviceconnect.wear.keyevent.ondown.regist";
-
- /** Register Key Event (onup). */
- public static final String DEVICE_TO_WEAR_KEYEVENT_ONUP_REGISTER = "org.deviceconnect.wear.keyevent.onup.regist";
- /** Register Key Event (onkeychange). */
- public static final String DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_REGISTER
- = "org.deviceconnect.wear.keyevent.onkeychange.regist";
-
- /** Remove Key Event (ondown). */
- public static final String DEVICE_TO_WEAR_KEYEVENT_ONDOWN_UNREGISTER
- = "org.deviceconnect.wear.keyevent.ondown.unregist";
-
- /** Remove Key Event (onup). */
- public static final String DEVICE_TO_WEAR_KEYEVENT_ONUP_UNREGISTER
- = "org.deviceconnect.wear.keyevent.onup.unregist";
- /** Remove Key Event (onkeychange). */
- public static final String DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_UNREGISTER
- = "org.deviceconnect.wear.keyevent.onkeychange.unregist";
- /** Wear to Android. */
- public static final String WEAR_TO_DEVICE_KEYEVENT_DATA = "org.deviceconnect.wear.keyevent.data";
-
- /** Key Event (down). */
- public static final String PARAM_KEYEVENT_DOWN = "down";
-
- /** Key Event (up). */
- public static final String PARAM_KEYEVENT_UP = "up";
-
- /** ServiceId. */
- public static final String PARAM_DEVICEID = "serviceId";
-
- /** NotificationId. */
- public static final String PARAM_NOTIFICATIONID = "notificationId";
-
- /**
- * サービスID.
- */
- public static final String SERVICE_ID = "Wear";
-
- /**
- * デバイス名: {@value}.
- */
- public static final String DEVICE_NAME = "Android Wear";
-
- /**
- * bitmapを受け渡しするためのキー.
- */
- public static final String PARAM_BITMAP = "bitmap";
-
- /**
- * x座標を受け渡しするためのキー.
- */
- public static final String PARAM_X = "x";
-
- /**
- * y座標を受け渡しするためのキー.
- */
- public static final String PARAM_Y = "y";
-
- /**
- * 描画モードを受け渡しするためのキー.
- */
- public static final String PARAM_MODE = "mode";
-
- /**
- * Timestamp.
- */
- public static final String TIMESTAMP = "timestamp";
- /**
- * 画像を送信するためのパスを定義する.
- */
- public static final String PATH_CANVAS = "/canvas/profile";
-
- /**
- * 通常の描画モード.
- */
- public static final int MODE_NORMAL = 0;
-
- /**
- * 拡大の描画モード.
- */
- public static final int MODE_SCALES = 1;
-
- /**
- * リピート描画モード.
- */
- public static final int MODE_FILLS = 2;
-
- /** Wear to Android. */
- public static final String WEAR_TO_DEVICE_CANVAS_RESULT = "org.deviceconnect.wear.canvas.result";
-
- /** リクエストID. */
- public static final String PARAM_REQUEST_ID = "requestId";
-
- /** データ変更イベントの送信元(Android端末)を特定するためのID. */
- public static final String PARAM_SOURCE_ID = "sourceId";
-
- /** メッセージの送信先(Android端末)を特定するためのID. */
- public static final String PARAM_DESTINATION_ID = "destinationId";
-
- /** 成功. */
- public static final String RESULT_SUCCESS = "success";
-
- /** エラー: ビットマップサイズが大きすぎる. */
- public static final String RESULT_ERROR_TOO_LARGE_BITMAP = "errorTooLargeBitmap";
-
- /** エラー: Android端末との接続に失敗. */
- public static final String RESULT_ERROR_CONNECTION_FAILURE = "errorConnectionFailure";
-
- /** エラー: サポートしていない画像形式. */
- public static final String RESULT_ERROR_NOT_SUPPORTED_FORMAT = "errorNotSupportedFormat";
-
- /** Register Touch (ontouch). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCH_REGISTER
- = "org.deviceconnect.wear.touch.ontouch.regist";
-
- /** Register Touch (ontouchstart). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_REGISTER
- = "org.deviceconnect.wear.touch.ontouchstart.regist";
-
- /** Register Touch (ontouchend). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_REGISTER
- = "org.deviceconnect.wear.touch.ontouchend.regist";
-
- /** Register Touch (ondoubletap). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_REGISTER
- = "org.deviceconnect.wear.touch.ondoubletap.regist";
-
- /** Register Touch (ontouchmove). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_REGISTER
- = "org.deviceconnect.wear.touch.ontouchmove.regist";
-
- /** Register Touch (ontouchcancel). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_REGISTER
- = "org.deviceconnect.wear.touch.ontouchcancel.regist";
- /** Register Touch (ontouchchange). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_REGISTER
- = "org.deviceconnect.wear.touch.ontouchchange.regist";
-
- /** Remove Touch (ontouch). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCH_UNREGISTER
- = "org.deviceconnect.wear.touch.ontouch.unregist";
-
- /** Remove Touch (ontouchstart). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_UNREGISTER
- = "org.deviceconnect.wear.touch.ontouchstart.unregist";
-
- /** Remove Touch (ontouchend). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_UNREGISTER
- = "org.deviceconnect.wear.touch.ontouchend.unregist";
-
- /** Remove Touch (ondoubletap). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_UNREGISTER
- = "org.deviceconnect.wear.touch.ondoubletap.unregist";
-
- /** Remove Touch (ontouchmove). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_UNREGISTER
- = "org.deviceconnect.wear.touch.ontouchmove.unregist";
-
- /** Remove Touch (ontouchcancel). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_UNREGISTER
- = "org.deviceconnect.wear.touch.ontouchcancel.unregist";
- /** Remove Touch (ontouchchange). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_UNREGISTER
- = "org.deviceconnect.wear.touch.ontouchchange.unregist";
- /** Wear to Android. */
- public static final String WEAR_TO_DEVICE_TOUCH_DATA = "org.deviceconnect.wear.touch.data";
- /** Set wear id.. */
- public static final String DEVICE_TO_WEAR_SET_ID
- = "org.deviceconnect.wear.id.set";
-
- /** Touch (touch). */
- public static final String PARAM_TOUCH_TOUCH = "touch";
-
- /** Touch (touchstart). */
- public static final String PARAM_TOUCH_TOUCHSTART = "touchstart";
-
- /** Touch (touchend). */
- public static final String PARAM_TOUCH_TOUCHEND = "touchend";
-
- /** Touch (doubletap). */
- public static final String PARAM_TOUCH_DOUBLETAP = "doubletap";
-
- /** Touch (touchmove). */
- public static final String PARAM_TOUCH_TOUCHMOVE = "touchmove";
-
- /** Touch (touchcancel). */
- public static final String PARAM_TOUCH_TOUCHCANCEL = "touchcancel";
- /**
- * Attribute: {@value} .
- */
- public static final String ATTRIBUTE_ON_TOUCH_CHANGE = "onTouchChange";
- /** Touch State start. */
- public static final String STATE_START = "start";
- /** Touch State end. */
- public static final String STATE_END = "end";
- /** Touch State double tap. */
- public static final String STATE_DOUBLE_TAP = "doubletap";
- /** Touch State move. */
- public static final String STATE_MOVE = "move";
- /** Touch State cancel. */
- public static final String STATE_CANCEL = "cancel";
- /** KeyEvent State move. */
- public static final String STATE_UP = "up";
- /** KeyEvent State cancel. */
- public static final String STATE_DOWN = "down";
- /**
- * Constructor.
- */
- private WearConst() {
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearDeviceOrientationProfile.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearDeviceOrientationProfile.java
deleted file mode 100755
index 83c1b08504..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearDeviceOrientationProfile.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- WearDeviceOrientationProfile.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.profile;
-
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.wear.WearDeviceService;
-import org.deviceconnect.android.deviceplugin.wear.WearManager;
-import org.deviceconnect.android.deviceplugin.wear.WearManager.OnMessageEventListener;
-import org.deviceconnect.android.deviceplugin.wear.WearManager.OnMessageResultListener;
-import org.deviceconnect.android.event.Event;
-import org.deviceconnect.android.event.EventError;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.DeviceOrientationProfile;
-import org.deviceconnect.android.profile.api.DConnectApi;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * DeviceOrientation Profile.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearDeviceOrientationProfile extends DeviceOrientationProfile {
-
- /**
- * 通知先のリスナーを保持するリスト.
- */
- private final List mListeners =
- Collections.synchronizedList(new ArrayList());
-
- /**
- * Android Wearからのイベントを受け取るリスナー.
- */
- private OnMessageEventListener mListener = new OnMessageEventListener() {
- @Override
- public void onEvent(final String nodeId, final String message) {
- synchronized (mListeners) {
- for (OnMessageEventListener l : mListeners) {
- l.onEvent(WearUtils.createServiceId(nodeId), message);
- }
- }
- }
- };
-
- /**
- * コンストラクタ.
- * @param mgr Android Wear管理クラス
- */
- public WearDeviceOrientationProfile(final WearManager mgr) {
- mgr.addMessageEventListener(WearConst.WEAR_TO_DEVICE_DEIVCEORIENTATION_DATA, mListener);
- mListeners.add(new OnMessageEventListener() {
- @Override
- public void onEvent(final String nodeId, final String message) {
- sendMessageToEvent(nodeId, message);
- }
- });
- addApi(mGetOnDeviceOrientation);
- addApi(mPutOnDeviceOrientation);
- addApi(mDeleteOnDeviceOrientation);
- }
-
- private final DConnectApi mGetOnDeviceOrientation = new GetApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_DEVICE_ORIENTATION;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final WearDeviceService service = (WearDeviceService) getContext();
- final String serviceId = WearUtils.getNodeId(getServiceID(request));
- final OnMessageEventListener l = new OnMessageEventListener() {
- @Override
- public void onEvent(final String nodeId, final String message) {
- Bundle orientation = createOrientation(message);
- setResult(response, DConnectMessage.RESULT_OK);
- setOrientation(response, orientation);
- service.sendResponse(response);
- removeListener(this);
- if (isEmptyEvent(serviceId)) {
- stopSensor(serviceId);
- }
- }
- };
- addListener(l);
-
- getManager().sendMessageToWear(serviceId,
- WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_REGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- }
- @Override
- public void onError() {
- removeListener(l);
- MessageUtils.setIllegalDeviceStateError(response);
- service.sendResponse(response);
- }
- });
- return false;
- }
- };
-
- private final DConnectApi mPutOnDeviceOrientation = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_DEVICE_ORIENTATION;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_REGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- sendResponse(response);
- }
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
- private final DConnectApi mDeleteOnDeviceOrientation = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_DEVICE_ORIENTATION;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- stopSensor(nodeId);
-
- // Event release.
- EventError error = EventManager.INSTANCE.removeEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- return true;
- }
- };
-
- /**
- * イベントの配送先の空状態を取得する.
- * @param nodeId wearのID
- * @return 空の場合はtrue、それ以外はfalse
- */
- private boolean isEmptyEvent(final String nodeId) {
- List events = EventManager.INSTANCE.getEventList(
- nodeId, PROFILE_NAME, null, ATTRIBUTE_ON_DEVICE_ORIENTATION);
- return events == null || events.size() == 0;
- }
-
- /**
- * 指定されたWearのセンサーを停止する.
- * @param nodeId wearのID
- */
- private void stopSensor(final String nodeId) {
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_UNREGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- }
- @Override
- public void onError() {
- }
- });
- }
-
- /**
- * リスナーを追加する.
- * @param l 追加するリスナー
- */
- private void addListener(final OnMessageEventListener l) {
- if (!mListeners.contains(l)) {
- mListeners.add(l);
- }
- }
-
- /**
- * リスナーを削除する.
- * @param l 削除するリスナー
- */
- private void removeListener(final OnMessageEventListener l) {
- mListeners.remove(l);
- }
-
- /**
- * Send a message to the registration event.
- *
- * @param nodeId node id
- * @param data Received Strings.
- */
- private void sendMessageToEvent(final String nodeId, final String data) {
- Bundle orientation = createOrientation(data);
-
- List events = EventManager.INSTANCE.getEventList(
- nodeId, PROFILE_NAME, null, ATTRIBUTE_ON_DEVICE_ORIENTATION);
- synchronized (events) {
- for (Event event : events) {
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra(DeviceOrientationProfile.PARAM_ORIENTATION, orientation);
- ((WearDeviceService) getContext()).sendEvent(intent, event.getAccessToken());
- }
- }
- }
-
- /**
- * 受信したデータからOrientationのデータを作成する.
- * @param data 受信したデータ
- * @return Orientationのデータ
- */
- private Bundle createOrientation(final String data) {
- String[] mDataArray = data.split(",", 0);
-
- Bundle orientation = new Bundle();
- Bundle a1 = new Bundle();
- a1.putDouble(DeviceOrientationProfile.PARAM_X, 0.0);
- a1.putDouble(DeviceOrientationProfile.PARAM_Y, 0.0);
- a1.putDouble(DeviceOrientationProfile.PARAM_Z, 0.0);
-
- Bundle a2 = new Bundle();
- a2.putDouble(DeviceOrientationProfile.PARAM_X, Double.parseDouble(mDataArray[0]));
- a2.putDouble(DeviceOrientationProfile.PARAM_Y, Double.parseDouble(mDataArray[1]));
- a2.putDouble(DeviceOrientationProfile.PARAM_Z, Double.parseDouble(mDataArray[2]));
-
- // Conversion the unit of angular speed from rad/s to degree/s.
- double alpha = Math.toDegrees(Double.parseDouble(mDataArray[3]));
- double beta = Math.toDegrees(Double.parseDouble(mDataArray[4]));
- double gamma = Math.toDegrees(Double.parseDouble(mDataArray[5]));
- Bundle r = new Bundle();
- r.putDouble(DeviceOrientationProfile.PARAM_ALPHA, alpha);
- r.putDouble(DeviceOrientationProfile.PARAM_BETA, beta);
- r.putDouble(DeviceOrientationProfile.PARAM_GAMMA, gamma);
- orientation.putBundle(DeviceOrientationProfile.PARAM_ACCELERATION, a1);
- orientation.putBundle(DeviceOrientationProfile.PARAM_ACCELERATION_INCLUDING_GRAVITY, a2);
- orientation.putBundle(DeviceOrientationProfile.PARAM_ROTATION_RATE, r);
- orientation.putLong(DeviceOrientationProfile.PARAM_INTERVAL, 0);
- setInterval(orientation, Integer.parseInt(mDataArray[6]));
- return orientation;
- }
-
- /**
- * Android Wear管理クラスを取得する.
- * @return WearManager管理クラス
- */
- private WearManager getManager() {
- return ((WearDeviceService) getContext()).getManager();
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearKeyEventProfile.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearKeyEventProfile.java
deleted file mode 100644
index 8c2ccf7ff2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearKeyEventProfile.java
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
- WearKeyEventProfile.java
- Copyright (c) 2015 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.profile;
-
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.wear.BuildConfig;
-import org.deviceconnect.android.deviceplugin.wear.WearDeviceService;
-import org.deviceconnect.android.deviceplugin.wear.WearManager;
-import org.deviceconnect.android.deviceplugin.wear.WearManager.OnMessageEventListener;
-import org.deviceconnect.android.deviceplugin.wear.WearManager.OnMessageResultListener;
-import org.deviceconnect.android.event.Event;
-import org.deviceconnect.android.event.EventError;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.KeyEventProfile;
-import org.deviceconnect.android.profile.api.DConnectApi;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.List;
-
-import static org.deviceconnect.android.deviceplugin.wear.profile.WearConst.STATE_DOWN;
-import static org.deviceconnect.android.deviceplugin.wear.profile.WearConst.STATE_UP;
-
-/**
- * Key Event Profile.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearKeyEventProfile extends KeyEventProfile {
-
- /** Tag. */
- private static final String TAG = "WEAR";
-
- /** KeyEvent profile onDown cache. */
- Bundle mOnDownCache = null;
-
- /** KeyEvent profile onDown cache time. */
- long mOnDownCacheTime = 0;
-
- /** KeyEvent profile onDown cache. */
- Bundle mOnUpCache = null;
-
- /** KeyEvent profile onUp cache time. */
- long mOnUpCacheTime = 0;
- /** KeyEvent profile onKeyChange cache. */
- Bundle mOnKeyChangeCache = null;
- /** KeyEvent profile onKeyChange cache time. */
- long mOnKeyChangeCacheTime = 0;
- /** KeyEvent profile cache retention time (mSec). */
- static final long CACHE_RETENTION_TIME = 10000;
- /**
- * Attribute: {@value} .
- */
- public static final String ATTRIBUTE_ON_KEY_CHANGE = "onKeyChange";
- /**
- * Get KeyEvent cache data.
- *
- * @param attr Attribute.
- * @return KeyEvent cache data.
- */
- public Bundle getKeyEventCache(final String attr) {
- long lCurrentTime = System.currentTimeMillis();
- if (attr.equalsIgnoreCase(KeyEventProfile.ATTRIBUTE_ON_DOWN)) {
- if (lCurrentTime - mOnDownCacheTime <= CACHE_RETENTION_TIME) {
- return mOnDownCache;
- } else {
- return null;
- }
- } else if (attr.equalsIgnoreCase(KeyEventProfile.ATTRIBUTE_ON_UP)) {
- if (lCurrentTime - mOnUpCacheTime <= CACHE_RETENTION_TIME) {
- return mOnUpCache;
- } else {
- return null;
- }
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_KEY_CHANGE)) {
- if (lCurrentTime - mOnKeyChangeCacheTime <= CACHE_RETENTION_TIME) {
- return mOnKeyChangeCache;
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- /**
- * Set KeyEvent data to cache.
- *
- * @param attr Attribute.
- * @param keyeventData Touch data.
- */
- public void setKeyEventCache(final String attr, final Bundle keyeventData) {
- long lCurrentTime = System.currentTimeMillis();
- if (attr.equalsIgnoreCase(KeyEventProfile.ATTRIBUTE_ON_DOWN)) {
- mOnDownCache = keyeventData;
- mOnDownCacheTime = lCurrentTime;
- } else if (attr.equalsIgnoreCase(KeyEventProfile.ATTRIBUTE_ON_UP)) {
- mOnUpCache = keyeventData;
- mOnUpCacheTime = lCurrentTime;
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_KEY_CHANGE)) {
- mOnKeyChangeCache = keyeventData;
- mOnKeyChangeCacheTime = lCurrentTime;
- }
- }
-
- /**
- * Receive event listener for Android Wear.
- */
- private OnMessageEventListener mListener = new OnMessageEventListener() {
- @Override
- public void onEvent(final String nodeId, final String message) {
- sendMessageToEvent(WearUtils.createServiceId(nodeId), message);
- }
- };
-
- /**
- * Constructor.
- *
- * @param mgr Android Wear management class.
- */
- public WearKeyEventProfile(final WearManager mgr) {
- mgr.addMessageEventListener(WearConst.WEAR_TO_DEVICE_KEYEVENT_DATA, mListener);
- addApi(mGetOnKeyChange);
- addApi(mGetOnDown);
- addApi(mGetOnUp);
- addApi(mPutOnKeyChange);
- addApi(mPutOnDown);
- addApi(mPutOnUp);
- addApi(mDeleteOnKeyChange);
- addApi(mDeleteOnDown);
- addApi(mDeleteOnUp);
- }
-
- private final DConnectApi mGetOnDown = new GetApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_DOWN;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Bundle keyevent = getKeyEventCache(KeyEventProfile.ATTRIBUTE_ON_DOWN);
- if (keyevent == null) {
- response.putExtra(KeyEventProfile.PARAM_KEYEVENT, "");
- } else {
- response.putExtra(KeyEventProfile.PARAM_KEYEVENT, keyevent);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- return true;
- }
- };
-
- private final DConnectApi mGetOnUp = new GetApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_UP;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Bundle keyEvent = getKeyEventCache(KeyEventProfile.ATTRIBUTE_ON_UP);
- if (keyEvent == null) {
- response.putExtra(KeyEventProfile.PARAM_KEYEVENT, "");
- } else {
- response.putExtra(KeyEventProfile.PARAM_KEYEVENT, keyEvent);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- return true;
- }
- };
- private final DConnectApi mGetOnKeyChange = new GetApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_KEY_CHANGE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Bundle keyevent = getKeyEventCache(ATTRIBUTE_ON_KEY_CHANGE);
- if (keyevent == null) {
- response.putExtra(KeyEventProfile.PARAM_KEYEVENT, "");
- } else {
- response.putExtra(KeyEventProfile.PARAM_KEYEVENT, keyevent);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- return true;
- }
- };
- private final DConnectApi mPutOnDown = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_DOWN;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId, WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_REGISTER, "",
- new OnMessageResultListener() {
- @Override
- public void onResult() {
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- sendResponse(response);
- }
-
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
- private final DConnectApi mPutOnUp = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_UP;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId, WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_REGISTER, "",
- new OnMessageResultListener() {
- @Override
- public void onResult() {
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- sendResponse(response);
- }
-
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
- private final DConnectApi mPutOnKeyChange = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_KEY_CHANGE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId, WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_REGISTER, "",
- new OnMessageResultListener() {
- @Override
- public void onResult() {
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- sendResponse(response);
- }
-
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
- private final DConnectApi mDeleteOnDown = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_DOWN;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId, WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_UNREGISTER, "",
- new OnMessageResultListener() {
- @Override
- public void onResult() {
- }
-
- @Override
- public void onError() {
- }
- });
-
- // Event release.
- EventError error = EventManager.INSTANCE.removeEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- return true;
- }
- };
-
- private final DConnectApi mDeleteOnUp = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_UP;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId, WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_UNREGISTER, "",
- new OnMessageResultListener() {
- @Override
- public void onResult() {
- }
-
- @Override
- public void onError() {
- }
- });
-
- // Event release.
- EventError error = EventManager.INSTANCE.removeEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- return true;
- }
- };
- private final DConnectApi mDeleteOnKeyChange = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_KEY_CHANGE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId, WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_UNREGISTER, "",
- new OnMessageResultListener() {
- @Override
- public void onResult() {
- }
-
- @Override
- public void onError() {
- }
- });
-
- // Event release.
- EventError error = EventManager.INSTANCE.removeEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- return true;
- }
- };
- /**
- * Send a message to the registration event.
- *
- * @param nodeId node id
- * @param data Received Strings.
- */
- private void sendMessageToEvent(final String nodeId, final String data) {
- String[] mDataArray = data.split(",", 0);
- String attr = null;
- String state = null;
- if (mDataArray[0].equals(WearConst.PARAM_KEYEVENT_DOWN)) {
- attr = ATTRIBUTE_ON_DOWN;
- state = STATE_DOWN;
- } else if (mDataArray[0].equals(WearConst.PARAM_KEYEVENT_UP)) {
- attr = ATTRIBUTE_ON_UP;
- state = STATE_UP;
- } else {
- return;
- }
-
- List events = EventManager.INSTANCE.getEventList(nodeId, PROFILE_NAME, null, attr);
- List keyEvents = EventManager.INSTANCE.getEventList(nodeId, PROFILE_NAME, null, ATTRIBUTE_ON_KEY_CHANGE);
-
- Bundle keyevent = new Bundle();
-
- keyevent.putInt(KeyEventProfile.PARAM_ID, Integer.parseInt(mDataArray[1]));
- keyevent.putString(KeyEventProfile.PARAM_CONFIG, mDataArray[2]);
-
- synchronized (events) {
- for (Event event : events) {
-
- String eventAttr = event.getAttribute();
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra(KeyEventProfile.PARAM_KEYEVENT, keyevent);
- ((WearDeviceService) getContext()).sendEvent(intent, event.getAccessToken());
- setKeyEventCache(eventAttr, keyevent);
- }
- }
- synchronized (keyEvents) {
- for (Event event : keyEvents) {
- String eventAttr = event.getAttribute();
- keyevent.putString("state", state);
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra(KeyEventProfile.PARAM_KEYEVENT, keyevent);
- ((WearDeviceService) getContext()).sendEvent(intent, event.getAccessToken());
- setKeyEventCache(eventAttr, keyevent);
- }
- }
-
- }
-
- /**
- * Get Android Wear management class.
- *
- * @return WearManager management class.
- */
- private WearManager getManager() {
- return ((WearDeviceService) getContext()).getManager();
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearNotificationProfile.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearNotificationProfile.java
deleted file mode 100755
index 71de41ed66..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearNotificationProfile.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- WearNotificationProfile.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.profile;
-
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.drawable.Icon;
-import android.os.Build;
-import androidx.core.app.NotificationCompat;
-
-import org.deviceconnect.android.deviceplugin.wear.R;
-import org.deviceconnect.android.event.Event;
-import org.deviceconnect.android.event.EventError;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.DConnectMessageService;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.NotificationProfile;
-import org.deviceconnect.android.profile.api.DConnectApi;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-import org.deviceconnect.message.intent.message.IntentDConnectMessage;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.List;
-import java.util.Random;
-
-/**
- * Notification Profile.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearNotificationProfile extends NotificationProfile {
-
- /**
- * ランダムを生成するクラス.
- */
- private final Random mRandom = new Random(System.currentTimeMillis());
-
- public WearNotificationProfile() {
- addApi(mPostNotify);
- addApi(mDeleteNotify);
- addApi(mDeleteOnClick);
- addApi(mPutOnClick);
- addApi(mDeleteOnClose);
- addApi(mPutOnClose);
- addApi(mDeleteOnShow);
- addApi(mPutOnShow);
- }
-
- private final DConnectApi mPostNotify = new PostApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_NOTIFY;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- final NotificationType type = getType(request);
- final String body = getBody(request);
-
- int myNotificationId = mRandom.nextInt(Integer.MAX_VALUE);
-
- Intent clickIntent = new Intent(getContext(),
- org.deviceconnect.android.deviceplugin.wear.WearDeviceService.class);
- clickIntent.setAction(WearConst.DEVICE_TO_WEAR_NOTIFICATION_OPEN);
- clickIntent.putExtra(WearConst.PARAM_DEVICEID, serviceId);
- clickIntent.putExtra(WearConst.PARAM_NOTIFICATIONID, myNotificationId);
- PendingIntent clickPendingIntent = PendingIntent.getService(getContext(), 0, clickIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
-
- Intent deleteIntent = new Intent(getContext(),
- org.deviceconnect.android.deviceplugin.wear.WearDeviceService.class);
- deleteIntent.setAction(WearConst.DEVICE_TO_WEAR_NOTIFICATION_CLOSED);
- deleteIntent.putExtra(WearConst.PARAM_DEVICEID, serviceId);
- deleteIntent.putExtra(WearConst.PARAM_NOTIFICATIONID, myNotificationId);
- PendingIntent deletePendingIntent = PendingIntent.getService(getContext(), 0, deleteIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
-
- int iconType = 0;
- String title = "";
- if (type == NotificationType.PHONE) {
- iconType = R.drawable.notification_00_post_lollipop;
- title = "PHONE";
- } else if (type == NotificationType.MAIL) {
- iconType = R.drawable.notification_01_post_lollipop;
- title = "MAIL";
- } else if (type == NotificationType.SMS) {
- iconType = R.drawable.notification_02_post_lollipop;
- title = "SMS";
- } else if (type == NotificationType.EVENT) {
- iconType = R.drawable.notification_03_post_lollipop;
- title = "EVENT";
- } else {
- MessageUtils.setInvalidRequestParameterError(response,
- "type is invalid.");
- return true;
- }
-
- String encodeBody = "";
- try {
- if (body != null) {
- encodeBody = URLDecoder.decode(body, "UTF-8");
- }
- } catch (UnsupportedEncodingException e) {
- MessageUtils.setInvalidRequestParameterError(response,
- "body is invalid.");
- return true;
- }
-
-
- Notification notification;
- // Get an instance of the NotificationManager service
- NotificationManager mNotification = (NotificationManager) getContext()
- .getSystemService(Context.NOTIFICATION_SERVICE);
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
- NotificationCompat.Builder notificationBuilder =
- new NotificationCompat.Builder(getContext())
- .setSmallIcon(iconType)
- .setContentTitle("" + title)
- .setContentText(encodeBody)
- .setContentIntent(clickPendingIntent)
- .setVibrate(new long[]{500})
- .setDeleteIntent(deletePendingIntent)
- .extend(new NotificationCompat.WearableExtender());
- notification = notificationBuilder.build();
- } else {
- Notification.Builder notificationBuilder =
- new Notification.Builder(getContext())
- .setSmallIcon(Icon.createWithResource(getContext(), iconType))
- .setContentTitle("" + title)
- .setContentText(encodeBody)
- .setContentIntent(clickPendingIntent)
- .setVibrate(new long[]{500})
- .setDeleteIntent(deletePendingIntent)
- .extend(new Notification.WearableExtender());
- ;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- String channelId = getContext().getResources().getString(R.string.android_wear_notification_channel_id);
- NotificationChannel channel = new NotificationChannel(
- channelId,
- getContext().getResources().getString(R.string.android_wear_notification_channel_title),
- NotificationManager.IMPORTANCE_DEFAULT);
- channel.setDescription(getContext().getResources().getString(R.string.android_wear_notification_channel_desc));
- mNotification.createNotificationChannel(channel);
- notificationBuilder.setChannelId(channelId);
- }
- notification = notificationBuilder.build();
- }
- // Build the notification and issues it with notification
- // manager.
- mNotification.notify(myNotificationId, notification);
-
- response.putExtra(NotificationProfile.PARAM_NOTIFICATION_ID, myNotificationId);
- setResult(response, IntentDConnectMessage.RESULT_OK);
-
- List events = EventManager.INSTANCE.getEventList(serviceId, WearNotificationProfile.PROFILE_NAME,
- null, WearNotificationProfile.ATTRIBUTE_ON_SHOW);
- synchronized (events) {
- for (Event event : events) {
- Intent msg = EventManager.createEventMessage(event);
- msg.putExtra(WearNotificationProfile.PARAM_NOTIFICATION_ID, myNotificationId);
- ((DConnectMessageService) getContext()).sendEvent(msg, event.getAccessToken());
- }
- }
- return true;
- }
- };
-
- private final DConnectApi mDeleteNotify = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_NOTIFY;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- NotificationManager manager = (NotificationManager) getContext()
- .getSystemService(Context.NOTIFICATION_SERVICE);
- try {
- manager.cancel(Integer.parseInt(getNotificationId(request)));
- setResult(response, DConnectMessage.RESULT_OK);
- } catch (NumberFormatException e) {
- MessageUtils.setInvalidRequestParameterError(response,
- "notificationId is invalid.");
- }
- return true;
- }
- };
-
- private final DConnectApi mDeleteOnClick = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_CLICK;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- return unregisterEvent(request, response, getServiceID(request), getSessionKey(request));
- }
- };
-
- private final DConnectApi mPutOnClick = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_CLICK;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- return registerEvent(request, response, getServiceID(request), getSessionKey(request));
- }
- };
-
- private final DConnectApi mDeleteOnClose = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_CLOSE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- return unregisterEvent(request, response, getServiceID(request), getSessionKey(request));
- }
- };
-
- private final DConnectApi mPutOnClose = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_CLOSE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- return registerEvent(request, response, getServiceID(request), getSessionKey(request));
- }
- };
-
- private final DConnectApi mDeleteOnShow = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_SHOW;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- return unregisterEvent(request, response, getServiceID(request), getSessionKey(request));
- }
- };
-
- private final DConnectApi mPutOnShow = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_SHOW;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- return registerEvent(request, response, getServiceID(request), getSessionKey(request));
- }
- };
-
- /**
- * イベントを登録します.
- * @param request リクエスト
- * @param response レスポンス
- * @param serviceId サービスID
- * @param sessionKey セッションキー
- * @return 同期なのでtrueを返却
- */
- private boolean registerEvent(final Intent request, final Intent response, final String serviceId, final String sessionKey) {
- if (serviceId == null) {
- MessageUtils.setEmptyServiceIdError(response);
- } else if (!WearUtils.checkServiceId(serviceId)) {
- MessageUtils.setNotFoundServiceError(response);
- } else {
- // Event registration.
- EventError error = EventManager.INSTANCE.addEvent(request);
- switch (error) {
- case NONE:
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- case FAILED:
- MessageUtils.setUnknownError(response, "Do not register event.");
- break;
- case INVALID_PARAMETER:
- MessageUtils.setInvalidRequestParameterError(response);
- break;
- case NOT_FOUND:
- MessageUtils.setUnknownError(response, "Event not found.");
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- }
- return true;
- }
-
- /**
- * イベントを解除します.
- * @param request リクエスト
- * @param response レスポンス
- * @param serviceId サービスID
- * @param sessionKey セッションキー
- * @return 同期なのでtrueを返却
- */
- private boolean unregisterEvent(final Intent request, final Intent response, final String serviceId, final String sessionKey) {
- if (serviceId == null) {
- MessageUtils.setEmptyServiceIdError(response);
- } else if (!WearUtils.checkServiceId(serviceId)) {
- MessageUtils.setNotFoundServiceError(response);
- } else {
- // Event release.
- EventError error = EventManager.INSTANCE.removeEvent(request);
- switch (error) {
- case NONE:
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- case FAILED:
- MessageUtils.setUnknownError(response, "Do not unregister event.");
- break;
- case INVALID_PARAMETER:
- MessageUtils.setInvalidRequestParameterError(response);
- break;
- case NOT_FOUND:
- MessageUtils.setUnknownError(response, "Event not found.");
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- }
- return true;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearServiceDiscoveryProfile.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearServiceDiscoveryProfile.java
deleted file mode 100644
index 7839a8c599..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearServiceDiscoveryProfile.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- HeartRateServiceDiscoveryProfile
- Copyright (c) 2015 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.wear.WearManager;
-import org.deviceconnect.android.profile.ServiceDiscoveryProfile;
-import org.deviceconnect.android.profile.api.DConnectApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.service.DConnectServiceProvider;
-
-/**
- * Implement ServiceDiscoveryProfile.
- * @author NTT DOCOMO, INC.
- */
-public class WearServiceDiscoveryProfile extends ServiceDiscoveryProfile {
-
-
- private final DConnectApi mServiceDiscoveryApi = new GetApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- mWearManager.sendWearData();
- appendServiceList(response);
- return true;
- }
- };
- private WearManager mWearManager;
- /**
- * コンストラクタ.
- * @param provider プロファイルプロバイダ
- */
- public WearServiceDiscoveryProfile(final WearManager manager, final DConnectServiceProvider provider) {
- super(provider);
- mWearManager = manager;
- addApi(mServiceDiscoveryApi);
- }
-
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearSystemProfile.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearSystemProfile.java
deleted file mode 100755
index c4f4a5d12a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearSystemProfile.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- WearSystemProfile.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.profile;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.wear.setting.WearServiceListActivity;
-import org.deviceconnect.android.profile.SystemProfile;
-
-/**
- * System Profile.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearSystemProfile extends SystemProfile {
-
- @Override
- protected Class extends Activity> getSettingPageActivity(final Intent request, final Bundle param) {
- return WearServiceListActivity.class;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearTouchProfile.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearTouchProfile.java
deleted file mode 100644
index 8ca2e3082f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearTouchProfile.java
+++ /dev/null
@@ -1,897 +0,0 @@
-/*
- WearTouchProfile.java
- Copyright (c) 2015 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.profile;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-
-
-import org.deviceconnect.android.deviceplugin.wear.BuildConfig;
-import org.deviceconnect.android.deviceplugin.wear.WearDeviceService;
-import org.deviceconnect.android.deviceplugin.wear.WearManager;
-import org.deviceconnect.android.deviceplugin.wear.WearManager.OnMessageEventListener;
-import org.deviceconnect.android.deviceplugin.wear.WearManager.OnMessageResultListener;
-import org.deviceconnect.android.event.Event;
-import org.deviceconnect.android.event.EventError;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.TouchProfile;
-import org.deviceconnect.android.profile.api.DConnectApi;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-import org.deviceconnect.message.intent.message.IntentDConnectMessage;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.deviceconnect.android.deviceplugin.wear.profile.WearConst.ATTRIBUTE_ON_TOUCH_CHANGE;
-import static org.deviceconnect.android.deviceplugin.wear.profile.WearConst.STATE_CANCEL;
-import static org.deviceconnect.android.deviceplugin.wear.profile.WearConst.STATE_DOUBLE_TAP;
-import static org.deviceconnect.android.deviceplugin.wear.profile.WearConst.STATE_END;
-import static org.deviceconnect.android.deviceplugin.wear.profile.WearConst.STATE_MOVE;
-import static org.deviceconnect.android.deviceplugin.wear.profile.WearConst.STATE_START;
-
-/**
- * Touch Profile.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearTouchProfile extends TouchProfile {
-
- /** Tag. */
- private static final String TAG = "WEAR";
-
- /** Touch profile onTouch cache. */
- Bundle mOnTouchCache = null;
-
- /** Touch profile onTouch cache time. */
- long mOnTouchCacheTime = 0;
-
- /** Touch profile onTouchStart cache. */
- Bundle mOnTouchStartCache = null;
-
- /** Touch profile onTouchStart cache time. */
- long mOnTouchStartCacheTime = 0;
-
- /** Touch profile onTouchEnd cache. */
- Bundle mOnTouchEndCache = null;
-
- /** Touch profile onTouchEnd cache time. */
- long mOnTouchEndCacheTime = 0;
-
- /** Touch profile onDoubleTap cache. */
- Bundle mOnDoubleTapCache = null;
-
- /** Touch profile onDoubleTap cache time. */
- long mOnDoubleTapCacheTime = 0;
-
- /** Touch profile onTouchMove cache. */
- Bundle mOnTouchMoveCache = null;
-
- /** Touch profile onTouchMove cache time. */
- long mOnTouchMoveCacheTime = 0;
-
- /** Touch profile onTouchCancel cache. */
- Bundle mOnTouchCancelCache = null;
-
- /** Touch profile onTouchCancel cache time. */
- long mOnTouchCancelCacheTime = 0;
- /** Touch profile onTouchChange cache. */
- Bundle mOnTouchChangeCache = null;
-
- /** Touch profile onTouchChange cache time. */
- long mOnTouchChangeCacheTime = 0;
- /** Touch profile cache retention time (mSec). */
- static final long CACHE_RETENTION_TIME = 10000;
-
- /**
- * Get Touch cache data.
- *
- * @param attr Attribute.
- * @return Touch cache data.
- */
- public Bundle getTouchCache(final String attr) {
- long lCurrentTime = System.currentTimeMillis();
- if (attr.equalsIgnoreCase(ATTRIBUTE_ON_TOUCH)) {
- if (lCurrentTime - mOnTouchCacheTime <= CACHE_RETENTION_TIME) {
- return mOnTouchCache;
- } else {
- return null;
- }
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_TOUCH_START)) {
- if (lCurrentTime - mOnTouchStartCacheTime <= CACHE_RETENTION_TIME) {
- return mOnTouchStartCache;
- } else {
- return null;
- }
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_TOUCH_END)) {
- if (lCurrentTime - mOnTouchEndCacheTime <= CACHE_RETENTION_TIME) {
- return mOnTouchEndCache;
- } else {
- return null;
- }
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_DOUBLE_TAP)) {
- if (lCurrentTime - mOnDoubleTapCacheTime <= CACHE_RETENTION_TIME) {
- return mOnDoubleTapCache;
- } else {
- return null;
- }
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_TOUCH_MOVE)) {
- if (lCurrentTime - mOnTouchMoveCacheTime <= CACHE_RETENTION_TIME) {
- return mOnTouchMoveCache;
- } else {
- return null;
- }
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_TOUCH_CANCEL)) {
- if (lCurrentTime - mOnTouchCancelCacheTime <= CACHE_RETENTION_TIME) {
- return mOnTouchCancelCache;
- } else {
- return null;
- }
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_TOUCH_CHANGE)) {
- if (lCurrentTime - mOnTouchChangeCacheTime <= CACHE_RETENTION_TIME) {
- return mOnTouchChangeCache;
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- /**
- * Set Touch data to cache.
- *
- * @param attr Attribute.
- * @param touchData Touch data.
- */
- public void setTouchCache(final String attr, final Bundle touchData) {
- long lCurrentTime = System.currentTimeMillis();
- if (attr.equalsIgnoreCase(ATTRIBUTE_ON_TOUCH)) {
- mOnTouchCache = touchData;
- mOnTouchCacheTime = lCurrentTime;
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_TOUCH_START)) {
- mOnTouchStartCache = touchData;
- mOnTouchStartCacheTime = lCurrentTime;
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_TOUCH_END)) {
- mOnTouchEndCache = touchData;
- mOnTouchEndCacheTime = lCurrentTime;
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_DOUBLE_TAP)) {
- mOnDoubleTapCache = touchData;
- mOnDoubleTapCacheTime = lCurrentTime;
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_TOUCH_MOVE)) {
- mOnTouchMoveCache = touchData;
- mOnTouchMoveCacheTime = lCurrentTime;
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_TOUCH_CANCEL)) {
- mOnTouchCancelCache = touchData;
- mOnTouchCancelCacheTime = lCurrentTime;
- } else if (attr.equalsIgnoreCase(ATTRIBUTE_ON_TOUCH_CHANGE)) {
- mOnTouchChangeCache = touchData;
- mOnTouchChangeCacheTime = lCurrentTime;
- }
- }
-
- /**
- * Event receive listener from Android Wear.
- */
- private OnMessageEventListener mListener = new OnMessageEventListener() {
- @Override
- public void onEvent(final String nodeId, final String message) {
- sendMessageToEvent(WearUtils.createServiceId(nodeId), message);
- }
- };
-
- /**
- * Constructor.
- * @param mgr Android Wear管理クラス
- */
- public WearTouchProfile(final WearManager mgr) {
- mgr.addMessageEventListener(WearConst.WEAR_TO_DEVICE_TOUCH_DATA, mListener);
- addApi(mGetOnTouch);
- addApi(mGetOnTouchStart);
- addApi(mGetOnTouchEnd);
- addApi(mGetOnDoubleTap);
- addApi(mGetOnTouchMove);
- addApi(mGetOnTouchCancel);
- addApi(mGetOnTouchChange);
- addApi(mPutOnTouch);
- addApi(mPutOnTouchStart);
- addApi(mPutOnTouchEnd);
- addApi(mPutOnDoubleTap);
- addApi(mPutOnTouchMove);
- addApi(mPutOnTouchCancel);
- addApi(mPutOnTouchChange);
- addApi(mDeleteOnTouch);
- addApi(mDeleteOnTouchStart);
- addApi(mDeleteOnTouchEnd);
- addApi(mDeleteOnDoubleTap);
- addApi(mDeleteOnTouchMove);
- addApi(mDeleteOnTouchCancel);
- addApi(mDeleteOnTouchChange);
- }
- private final DConnectApi mGetOnTouchChange = new GetApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_CHANGE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Bundle touches = getTouchCache(ATTRIBUTE_ON_TOUCH_CHANGE);
- if (touches == null) {
- response.putExtra(TouchProfile.PARAM_TOUCH, "");
- } else {
- response.putExtra(TouchProfile.PARAM_TOUCH, touches);
- }
- setResult(response, IntentDConnectMessage.RESULT_OK);
- return true;
- }
- };
- private final DConnectApi mGetOnTouch = new GetApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Bundle touches = getTouchCache(TouchProfile.ATTRIBUTE_ON_TOUCH);
- if (touches == null) {
- response.putExtra(TouchProfile.PARAM_TOUCH, "");
- } else {
- response.putExtra(TouchProfile.PARAM_TOUCH, touches);
- }
- setResult(response, IntentDConnectMessage.RESULT_OK);
- return true;
- }
- };
-
- private final DConnectApi mGetOnTouchStart = new GetApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_START;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Bundle touches = getTouchCache(TouchProfile.ATTRIBUTE_ON_TOUCH_START);
- if (touches == null) {
- response.putExtra(TouchProfile.PARAM_TOUCH, "");
- } else {
- response.putExtra(TouchProfile.PARAM_TOUCH, touches);
- }
- setResult(response, IntentDConnectMessage.RESULT_OK);
- return true;
- }
- };
-
- private final DConnectApi mGetOnTouchEnd = new GetApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_END;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Bundle touches = getTouchCache(TouchProfile.ATTRIBUTE_ON_TOUCH_END);
- if (touches == null) {
- response.putExtra(TouchProfile.PARAM_TOUCH, "");
- } else {
- response.putExtra(TouchProfile.PARAM_TOUCH, touches);
- }
- setResult(response, IntentDConnectMessage.RESULT_OK);
- return true;
- }
- };
-
- private final DConnectApi mGetOnDoubleTap = new GetApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_DOUBLE_TAP;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Bundle touches = getTouchCache(TouchProfile.ATTRIBUTE_ON_DOUBLE_TAP);
- if (touches == null) {
- response.putExtra(TouchProfile.PARAM_TOUCH, "");
- } else {
- response.putExtra(TouchProfile.PARAM_TOUCH, touches);
- }
- setResult(response, IntentDConnectMessage.RESULT_OK);
- return true;
- }
- };
-
- private final DConnectApi mGetOnTouchMove = new GetApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_MOVE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Bundle touches = getTouchCache(TouchProfile.ATTRIBUTE_ON_TOUCH_MOVE);
- if (touches == null) {
- response.putExtra(TouchProfile.PARAM_TOUCH, "");
- } else {
- response.putExtra(TouchProfile.PARAM_TOUCH, touches);
- }
- setResult(response, IntentDConnectMessage.RESULT_OK);
- return true;
- }
- };
-
- private final DConnectApi mGetOnTouchCancel = new GetApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_CANCEL;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Bundle touches = getTouchCache(TouchProfile.ATTRIBUTE_ON_TOUCH_CANCEL);
- if (touches == null) {
- response.putExtra(TouchProfile.PARAM_TOUCH, "");
- } else {
- response.putExtra(TouchProfile.PARAM_TOUCH, touches);
- }
- setResult(response, IntentDConnectMessage.RESULT_OK);
- return true;
- }
- };
- private final DConnectApi mPutOnTouchChange = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_CHANGE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
-
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_REGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- // Event registration.
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- sendResponse(response);
- }
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
- private final DConnectApi mPutOnTouch = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
-
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_REGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- // Event registration.
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- sendResponse(response);
- }
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
- private final DConnectApi mPutOnTouchStart = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_START;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_REGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- // Event registration.
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- sendResponse(response);
- }
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
- private final DConnectApi mPutOnTouchEnd = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_END;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_REGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- // Event registration.
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- sendResponse(response);
- }
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
- private final DConnectApi mPutOnDoubleTap = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_DOUBLE_TAP;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_REGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- // Event registration.
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- sendResponse(response);
- }
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
- private final DConnectApi mPutOnTouchMove = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_MOVE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_REGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- // Event registration.
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- sendResponse(response);
- }
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
- private final DConnectApi mPutOnTouchCancel = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_CANCEL;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_REGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- // Event registration.
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- sendResponse(response);
- }
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
- private final DConnectApi mDeleteOnTouchChange = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_CHANGE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_UNREGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- }
- @Override
- public void onError() {
- }
- });
-
- // Event release.
- EventError error = EventManager.INSTANCE.removeEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- return true;
- }
- };
- private final DConnectApi mDeleteOnTouch = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_UNREGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- }
- @Override
- public void onError() {
- }
- });
-
- // Event release.
- EventError error = EventManager.INSTANCE.removeEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- return true;
- }
- };
-
- private final DConnectApi mDeleteOnTouchStart = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_START;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_UNREGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- }
- @Override
- public void onError() {
- }
- });
-
- // Event release.
- EventError error = EventManager.INSTANCE.removeEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- return true;
- }
- };
-
- private final DConnectApi mDeleteOnTouchEnd = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_END;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_UNREGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- }
- @Override
- public void onError() {
- }
- });
-
- // Event release.
- EventError error = EventManager.INSTANCE.removeEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- return true;
- }
- };
-
- private final DConnectApi mDeleteOnDoubleTap = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_DOUBLE_TAP;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_UNREGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- }
- @Override
- public void onError() {
- }
- });
-
- // Event release.
- EventError error = EventManager.INSTANCE.removeEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- return true;
- }
- };
-
- private final DConnectApi mDeleteOnTouchMove = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_MOVE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_UNREGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- }
- @Override
- public void onError() {
- }
- });
-
- // Event release.
- EventError error = EventManager.INSTANCE.removeEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- return true;
- }
- };
-
- private final DConnectApi mDeleteOnTouchCancel = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_TOUCH_CANCEL;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId,
- WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_UNREGISTER,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- }
- @Override
- public void onError() {
- }
- });
-
- // Event release.
- EventError error = EventManager.INSTANCE.removeEvent(request);
- if (error == EventError.NONE) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- setResult(response, DConnectMessage.RESULT_ERROR);
- }
- return true;
- }
- };
-
- /**
- * Send a message to the registration event.
- *
- * @param nodeId node id
- * @param data Received Strings.
- */
- private void sendMessageToEvent(final String nodeId, final String data) {
- if (BuildConfig.DEBUG) {
- Log.i(TAG, "@@@@@@SUCCESS");
- }
-
- String[] mDataArray = data.split(",", 0);
- String attr;
- String action = mDataArray[1];
- String state = null;
- if (action.equals(WearConst.PARAM_TOUCH_TOUCH)) {
- attr = ATTRIBUTE_ON_TOUCH;
- } else if (action.equals(WearConst.PARAM_TOUCH_TOUCHSTART)) {
- attr = ATTRIBUTE_ON_TOUCH_START;
- state = STATE_START;
- } else if (action.equals(WearConst.PARAM_TOUCH_TOUCHEND)) {
- attr = ATTRIBUTE_ON_TOUCH_END;
- state = STATE_END;
- } else if (action.equals(WearConst.PARAM_TOUCH_TOUCHMOVE)) {
- attr = ATTRIBUTE_ON_TOUCH_MOVE;
- state = STATE_MOVE;
- } else if (action.equals(WearConst.PARAM_TOUCH_TOUCHCANCEL)) {
- attr = ATTRIBUTE_ON_TOUCH_CANCEL;
- state = STATE_CANCEL;
- } else if (action.equals(WearConst.PARAM_TOUCH_DOUBLETAP)) {
- attr = ATTRIBUTE_ON_DOUBLE_TAP;
- state = STATE_DOUBLE_TAP;
- } else {
- attr = null;
- state = null;
- }
-
- if (BuildConfig.DEBUG) {
- Log.i(TAG, "action: " + action + " attr: " + attr);
- }
-
- if (attr != null) {
- List events = EventManager.INSTANCE.getEventList(
- nodeId, PROFILE_NAME, null, attr);
- List commonEvents = EventManager.INSTANCE.getEventList(
- nodeId, PROFILE_NAME, null, ATTRIBUTE_ON_TOUCH_CHANGE);
- Bundle touchdata = new Bundle();
- List touchlist = new ArrayList();
- Bundle touches = new Bundle();
- int count = Integer.parseInt(mDataArray[0]);
- int index = 2;
- for (int n = 0; n < count; n++) {
- touchdata.putInt(TouchProfile.PARAM_ID, Integer.parseInt(mDataArray[index++]));
- touchdata.putFloat(TouchProfile.PARAM_X, Float.parseFloat(mDataArray[index++]));
- touchdata.putFloat(TouchProfile.PARAM_Y, Float.parseFloat(mDataArray[index++]));
- touchlist.add((Bundle) touchdata.clone());
- }
- touches.putParcelableArray(TouchProfile.PARAM_TOUCHES,
- touchlist.toArray(new Bundle[touchlist.size()]));
- synchronized (events) {
- for (Event event : events) {
- String eventAttr = event.getAttribute();
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra(TouchProfile.PARAM_TOUCH, touches);
- ((WearDeviceService) getContext()).sendEvent(intent, event.getAccessToken());
- setTouchCache(eventAttr, touches);
- if (BuildConfig.DEBUG) {
- Log.i(TAG, "event: " + event);
- Log.i(TAG, "touches: " + touches);
- Log.i(TAG, "intent: " + intent);
- }
- }
- }
- synchronized (commonEvents) {
- for (Event event : commonEvents) {
- String eventAttr = event.getAttribute();
- Intent intent = EventManager.createEventMessage(event);
- if (state != null) {
- touches.putString("state", state);
- }
- intent.putExtra(TouchProfile.PARAM_TOUCH, touches);
- ((WearDeviceService) getContext()).sendEvent(intent, event.getAccessToken());
- setTouchCache(eventAttr, touches);
- if (BuildConfig.DEBUG) {
- Log.i(TAG, "event: " + event);
- Log.i(TAG, "touches: " + touches);
- Log.i(TAG, "intent: " + intent);
- }
- }
- }
- }
- }
-
- /**
- * Get Android Wear management class.
- * @return WearManager management class.
- */
- private WearManager getManager() {
- return ((WearDeviceService) getContext()).getManager();
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearUtils.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearUtils.java
deleted file mode 100755
index 3489716539..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearUtils.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-WearUtil.java
-Copyright (c) 2014 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.profile;
-
-import org.deviceconnect.profile.CanvasProfileConstants.Mode;
-
-
-/**
- * Wear Utils.
- *
- * @author NTT DOCOMO, INC.
- */
-public final class WearUtils {
-
- /**
- * Constructor.
- */
- private WearUtils() {
- }
-
- /**
- * Android Wearに渡す描画モードに変換する.
- * @param mode モード
- * @return 変換後のモード
- */
- public static int convertMode(final Mode mode) {
- int mm = WearConst.MODE_NORMAL;
- if (Mode.SCALES.equals(mode)) {
- mm = WearConst.MODE_SCALES;
- } else if (Mode.FILLS.equals(mode)) {
- mm = WearConst.MODE_FILLS;
- } else {
- mm = WearConst.MODE_NORMAL;
- }
- return mm;
- }
-
- /**
- * サービスIDを確認する.
- * @param serviceId サービスID
- * @return 問題ない場合にはtrue、それ以外はfalse
- */
- public static boolean checkServiceId(final String serviceId) {
- if (serviceId == null) {
- return false;
- }
- return serviceId.startsWith(WearConst.SERVICE_ID);
- }
-
- /**
- * nodeIdからサービスIDを作成する.
- * @param nodeId ノードID
- * @return サービスID
- */
- public static String createServiceId(final String nodeId) {
- String[] id = nodeId.split("-");
- return WearConst.SERVICE_ID + "-" + id[0];
- }
-
- /**
- * Get node form Service ID.
- *
- * @param serviceId Service ID.
- * @return nodeId Internal management Node ID.
- */
- public static String getNodeId(final String serviceId) {
- String[] mServiceIdArray = serviceId.split("-");
- return mServiceIdArray[1];
- }
-
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearVibrationProfile.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearVibrationProfile.java
deleted file mode 100755
index 09d0494d6d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/WearVibrationProfile.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- WearVibrationProfile.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.profile;
-
-import android.content.Intent;
-
-
-import org.deviceconnect.android.deviceplugin.wear.WearDeviceService;
-import org.deviceconnect.android.deviceplugin.wear.WearManager;
-import org.deviceconnect.android.deviceplugin.wear.WearManager.OnMessageResultListener;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.VibrationProfile;
-import org.deviceconnect.android.profile.api.DConnectApi;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-/**
- * Vibration Profile.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearVibrationProfile extends VibrationProfile {
-
- public WearVibrationProfile() {
- addApi(mPutVibrate);
- addApi(mDeleteVibrate);
- }
-
- private final DConnectApi mPutVibrate = new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_VIBRATE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String pattern = getPattern(request);
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId, WearConst.DEVICE_TO_WEAR_VIBRATION_RUN,
- convertPatternToString(parsePattern(pattern)), new OnMessageResultListener() {
- @Override
- public void onResult() {
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
- private final DConnectApi mDeleteVibrate = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_VIBRATE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String nodeId = WearUtils.getNodeId(getServiceID(request));
- getManager().sendMessageToWear(nodeId, WearConst.DEVICE_TO_WEAR_VIBRATION_DEL,
- "", new OnMessageResultListener() {
- @Override
- public void onResult() {
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
- @Override
- public void onError() {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
- /**
- * バイブレーションのパターンを文字列に変換する.
- * @param pattern パターン
- * @return 文字列に変換されたパターン
- */
- private String convertPatternToString(final long[] pattern) {
- // Convert pattern in string.
- String patternStr = "";
- for (int i = 0; i < pattern.length; i++) {
- if (i == 0) {
- patternStr += pattern[i];
- } else {
- patternStr += "," + pattern[i];
- }
- }
- return patternStr;
- }
-
- /**
- * Android Wear管理クラスを取得する.
- * @return WearManager管理クラス
- */
- private WearManager getManager() {
- return ((WearDeviceService) getContext()).getManager();
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/package-info.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/package-info.java
deleted file mode 100755
index ddd2193b6e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/profile/package-info.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- org.deviceconnect.android.deviceplugin.wear.profile
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-
-/**
- * Profile of wear.
- */
-package org.deviceconnect.android.deviceplugin.wear.profile;
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/service/WearService.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/service/WearService.java
deleted file mode 100644
index 5b69fd7b4d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/service/WearService.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.deviceconnect.android.deviceplugin.wear.service;
-
-
-import com.google.android.gms.wearable.Node;
-
-import org.deviceconnect.android.deviceplugin.wear.WearManager;
-import org.deviceconnect.android.deviceplugin.wear.profile.WearCanvasProfile;
-import org.deviceconnect.android.deviceplugin.wear.profile.WearConst;
-import org.deviceconnect.android.deviceplugin.wear.profile.WearDeviceOrientationProfile;
-import org.deviceconnect.android.deviceplugin.wear.profile.WearKeyEventProfile;
-import org.deviceconnect.android.deviceplugin.wear.profile.WearNotificationProfile;
-import org.deviceconnect.android.deviceplugin.wear.profile.WearTouchProfile;
-import org.deviceconnect.android.deviceplugin.wear.profile.WearUtils;
-import org.deviceconnect.android.deviceplugin.wear.profile.WearVibrationProfile;
-import org.deviceconnect.android.service.DConnectService;
-
-public class WearService extends DConnectService {
-
- private WearService(final String id) {
- super(id);
- }
-
- public static WearService getInstance(final Node node, final WearManager mgr) {
- String nodeId = node.getId();
- String[] serviceId = nodeId.split("-");
-
- WearService service = new WearService(WearUtils.createServiceId(nodeId));
- service.setName(WearConst.DEVICE_NAME + "(" + serviceId[0] + ")");
- service.setNetworkType(NetworkType.BLE);
- service.addProfile(new WearCanvasProfile(mgr));
- service.addProfile(new WearDeviceOrientationProfile(mgr));
- service.addProfile(new WearKeyEventProfile(mgr));
- service.addProfile(new WearNotificationProfile());
- service.addProfile(new WearTouchProfile(mgr));
- service.addProfile(new WearVibrationProfile());
- return service;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/setting/WearServiceListActivity.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/setting/WearServiceListActivity.java
deleted file mode 100644
index d483c53f17..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/setting/WearServiceListActivity.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.deviceconnect.android.deviceplugin.wear.setting;
-
-
-import android.app.Activity;
-
-import org.deviceconnect.android.deviceplugin.wear.WearDeviceService;
-import org.deviceconnect.android.message.DConnectMessageService;
-import org.deviceconnect.android.ui.activity.DConnectServiceListActivity;
-
-public class WearServiceListActivity extends DConnectServiceListActivity {
-
- @Override
- protected Class extends DConnectMessageService> getMessageServiceClass() {
- return WearDeviceService.class;
- }
-
- @Override
- protected Class extends Activity> getSettingManualActivityClass() {
- return WearSettingActivity.class;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/setting/WearSettingActivity.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/setting/WearSettingActivity.java
deleted file mode 100755
index b80d12cf4d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/setting/WearSettingActivity.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- WearSettingActivity.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.setting;
-
-import org.deviceconnect.android.ui.activity.DConnectSettingPageFragmentActivity;
-
-import android.os.Bundle;
-import androidx.fragment.app.Fragment;
-
-/**
- * Setting Activity.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearSettingActivity extends DConnectSettingPageFragmentActivity {
-
- /** Service ID. */
- private String mServiceId;
-
- /** Page count. */
- private static final int PAGE_COUNT = 1;
-
- @Override
- public Fragment createPage(final int position) {
- Bundle mBundle = new Bundle();
- mBundle.putInt("position", position);
- WearSettingFragment mFragment = new WearSettingFragment();
- mFragment.setArguments(mBundle);
- return mFragment;
- }
-
- /**
- * Get Service ID.
- *
- * @return Service ID.
- */
- public String getServiceId() {
- return mServiceId;
- }
-
- /**
- * Set Service ID.
- *
- * @param serviceId Service ID.
- */
- public void setServiceId(final String serviceId) {
- mServiceId = serviceId;
- }
-
- @Override
- public int getPageCount() {
- return PAGE_COUNT;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/setting/WearSettingFragment.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/setting/WearSettingFragment.java
deleted file mode 100755
index 83020ba21e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/setting/WearSettingFragment.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- WearSettingFragment.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.setting;
-
-import org.deviceconnect.android.deviceplugin.wear.R;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import androidx.fragment.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-/**
- * Setting screen Fragment.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearSettingFragment extends Fragment implements OnClickListener {
-
- /** ImageView. */
- private ImageView mImageView;
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
- final Bundle savedInstanceState) {
- // Get position.
- Bundle mBundle = getArguments();
- int mPagePosition = mBundle.getInt("position", 0);
-
- int mPageLayoutId = this.getResources().getIdentifier("wear_setting_" + mPagePosition, "layout",
- getActivity().getPackageName());
-
- View mView = inflater.inflate(mPageLayoutId, container, false);
-
- if (mPagePosition == 0) {
- mImageView = (ImageView) mView.findViewById(R.id.dconnect_settings_googleplay);
- mImageView.setOnClickListener(this);
- }
-
- return mView;
- }
-
- @Override
- public void onClick(final View v) {
- if (v.equals(mImageView)) {
- Uri uri = Uri.parse("market://details?id=com.google.android.wearable.app");
- Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- startActivity(intent);
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/setting/package-info.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/setting/package-info.java
deleted file mode 100755
index 82bc8407a1..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/java/org/deviceconnect/android/deviceplugin/wear/setting/package-info.java
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- org.deviceconnect.android.deviceplugin.wear.setting
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-
-/**
- * Setting activity of wear.
- */
-package org.deviceconnect.android.deviceplugin.wear.setting;
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-hdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-hdpi/ic_launcher.png
deleted file mode 100755
index bff79fd34e..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/ic_launcher.png
deleted file mode 100755
index 6c47374bb1..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_00_post_lollipop.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_00_post_lollipop.png
deleted file mode 100755
index c1d9e6f6b2..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_00_post_lollipop.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_01_post_lollipop.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_01_post_lollipop.png
deleted file mode 100755
index bb0d1a28b0..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_01_post_lollipop.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_02_post_lollipop.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_02_post_lollipop.png
deleted file mode 100755
index 450adce54d..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_02_post_lollipop.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_03_post_lollipop.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_03_post_lollipop.png
deleted file mode 100755
index 502584f909..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_03_post_lollipop.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_04_post_lollipop.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_04_post_lollipop.png
deleted file mode 100755
index ffd8c43d12..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-mdpi/notification_04_post_lollipop.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/dconnect_icon.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/dconnect_icon.png
deleted file mode 100755
index a3a7f4794e..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/dconnect_icon.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/g_play_img.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/g_play_img.png
deleted file mode 100755
index 9a50affda3..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/g_play_img.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100755
index d6e3e95912..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_00.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_00.png
deleted file mode 100755
index dd070b70ac..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_00.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_01.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_01.png
deleted file mode 100755
index cc47b8c960..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_01.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_02.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_02.png
deleted file mode 100755
index 99ed78f4ee..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_02.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_03.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_03.png
deleted file mode 100755
index 5f06303212..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_03.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_04.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_04.png
deleted file mode 100755
index cca2e553fd..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xhdpi/notification_04.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xxhdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100755
index dec0b850ae..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/layout/wear_setting_0.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/layout/wear_setting_0.xml
deleted file mode 100755
index b7491b59eb..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/layout/wear_setting_0.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/values-v11/styles.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/values-v11/styles.xml
deleted file mode 100755
index cc7b3128b5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/values-v11/styles.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/values-v14/styles.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/values-v14/styles.xml
deleted file mode 100755
index d581045ffc..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/values-v14/styles.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/values/strings.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/values/strings.xml
deleted file mode 100755
index 20d28b27f4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
- Android Wear (Device Connect Device Plug-in)
- org.deviceconnect.android.intent.action.notifiy.androidwear
- Device Connect AndroidWear Notification
- DeviceConnectのAndroidWearプラグインの通知
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/values/styles.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/values/styles.xml
deleted file mode 100755
index c1d5d9d7ef..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/xml/network_security_config.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/xml/network_security_config.xml
deleted file mode 100644
index dca93c079e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/xml/network_security_config.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/xml/org_deviceconnect_android_deviceplugin_wear.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/xml/org_deviceconnect_android_deviceplugin_wear.xml
deleted file mode 100755
index 0a48048e41..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/xml/org_deviceconnect_android_deviceplugin_wear.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-
-
-
- デバイス検索
- 周辺のデバイスを検索する
- Network Service Discovery
- Searches near devices.
-
-
- デバイス情報
- デバイス情報を取得する
- Service Information
- Gets service information.
-
-
- システム
- システム情報を取得する
- System
- Obtains system information.
-
-
- 通知
- 通知管理機能にアクセスする
- Notification
- Accesses notification feature.
-
-
- キャンバス
- キャンバスにアクセスする
- Canvas
- Accesses canvas feature.
-
-
-
- バイブレーション
- バイブレーション機能にアクセスする
- Vibrarion
- Accesses vibrarion feature.
-
-
-
- 加速度
- 加速度機能にアクセスする
- Device Orientation
- Accesses device orientation.
-
-
-
- 通知
- 通知管理機能にアクセスする
- Notification
- Accesses notification feature.
-
-
-
- タッチ
- タッチ状態を取得する
- Touch
- Touch event.
-
-
-
- キーイベント
- キーイベント状態を取得する
- KeyEvent
- Key Event.
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/xml/wear.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/xml/wear.xml
deleted file mode 100644
index cde84b0e58..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/xml/wear.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
- - wear_deviceconnect
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/xml/wearable_app_desc.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/xml/wearable_app_desc.xml
deleted file mode 100755
index 3291cf8994..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/app/src/main/res/xml/wearable_app_desc.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
- 1
- 2.0.0
- wearable_app
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/build.gradle b/dConnectDevicePlugin/dConnectDeviceAndroidWear/build.gradle
deleted file mode 100644
index 087ed2dd61..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/build.gradle
+++ /dev/null
@@ -1,18 +0,0 @@
-
-buildscript {
- repositories {
- google()
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:3.6.2'
- }
-}
-
-allprojects {
- repositories {
- jcenter()
- google()
- }
-}
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradle.properties b/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradle.properties
deleted file mode 100644
index 0d089abc76..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradle.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-storeFile=キーストアのファイル名
-storePassword=キーストアのパスワード
-keyAlias=エイリアス名
-keyPassword=エイリアスのパスワード
-android.useAndroidX=true
-android.enableJetifier=true
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradle/wrapper/gradle-wrapper.jar b/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 13372aef5e..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradle/wrapper/gradle-wrapper.properties b/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index ee31d1c5a8..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Tue Apr 14 15:43:39 JST 2020
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradlew b/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradlew
deleted file mode 100755
index 9d82f78915..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradlew
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradlew.bat b/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradlew.bat
deleted file mode 100644
index aec99730b4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/gradlew.bat
+++ /dev/null
@@ -1,90 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/lint.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/lint.xml
deleted file mode 100644
index 715caf3d22..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/lint.xml
+++ /dev/null
@@ -1,190 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/proguard-project.txt b/dConnectDevicePlugin/dConnectDeviceAndroidWear/proguard-project.txt
deleted file mode 100755
index f2fe1559a2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/settings.gradle b/dConnectDevicePlugin/dConnectDeviceAndroidWear/settings.gradle
deleted file mode 100644
index 078b083939..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':app', ':wear-app'
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/build.gradle b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/build.gradle
deleted file mode 100755
index 22c0a2ebc4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/build.gradle
+++ /dev/null
@@ -1,50 +0,0 @@
-apply plugin: 'com.android.application'
-
-
-android {
- compileSdkVersion 29
- defaultConfig {
- applicationId "org.deviceconnect.android.deviceplugin.wear"
- minSdkVersion 23
- targetSdkVersion 29
- versionCode 1
- versionName '2.0.0'
- }
- signingConfigs {
- releaseConfig {
- storeFile=file(project.properties.storeFile)
- storePassword=project.properties.storePassword
- keyAlias=project.properties.keyAlias
- keyPassword=project.properties.keyPassword
- }
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- signingConfig signingConfigs.releaseConfig
- }
- }
- productFlavors {
- }
- tasks.withType(JavaCompile) {
- options.encoding = 'UTF-8'
- }
- lintOptions {
- checkReleaseBuilds false
- abortOnError false
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'androidx.wear:wear:1.0.0'
- implementation 'com.google.android.support:wearable:2.5.0'
- compileOnly 'com.google.android.wearable:wearable:2.5.0'
-
- implementation 'com.google.android.gms:play-services-wearable:17.0.0'
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/proguard-rules.pro b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/proguard-rules.pro
deleted file mode 100755
index 1c560ab8e2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Applications/android-sdk/android-sdk-macosx/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/AndroidManifest.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/AndroidManifest.xml
deleted file mode 100755
index 22de2d9b83..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/DataLayerListenerService.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/DataLayerListenerService.java
deleted file mode 100755
index 4fb882c213..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/DataLayerListenerService.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
-DataLayerListenerService.java
-Copyright (c) 2014 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Vibrator;
-import android.util.Log;
-
-import com.google.android.gms.wearable.Asset;
-import com.google.android.gms.wearable.DataEvent;
-import com.google.android.gms.wearable.DataEventBuffer;
-import com.google.android.gms.wearable.DataMap;
-import com.google.android.gms.wearable.DataMapItem;
-import com.google.android.gms.wearable.MessageEvent;
-import com.google.android.gms.wearable.Node;
-import com.google.android.gms.wearable.WearableListenerService;
-
-import org.deviceconnect.android.deviceplugin.wear.activity.CanvasActivity;
-import org.deviceconnect.android.deviceplugin.wear.activity.WearKeyEventProfileActivity;
-import org.deviceconnect.android.deviceplugin.wear.activity.WearTouchProfileActivity;
-
-import java.util.List;
-
-/**
- * DataLayerListenerService.
- *
- * @author NTT DOCOMO, INC.
- */
-public class DataLayerListenerService extends WearableListenerService {
-
- @Override
- public void onCreate() {
- super.onCreate();
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- }
-
- @Override
- public void onDataChanged(final DataEventBuffer dataEvents) {
- super.onDataChanged(dataEvents);
- for (DataEvent event : dataEvents) {
- Uri uri = event.getDataItem().getUri();
- if (event.getType() == DataEvent.TYPE_CHANGED
- && uri.getPath().startsWith(WearConst.PATH_CANVAS)) {
-
- DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
- DataMap map = dataMapItem.getDataMap();
- List segments = uri.getPathSegments();
-
- String selfId = ((WearApplication) getApplication()).getSelfId();
- String wearId = segments.get(2);
- if (selfId == null || !selfId.equals(wearId)) {
- //WearのIDが違っていれば無視
- return;
- }
- String nodeId = uri.getHost();
- String requestId = segments.get(3);
- Asset profileAsset = map.getAsset(WearConst.PARAM_BITMAP);
- int x = map.getInt(WearConst.PARAM_X);
- int y = map.getInt(WearConst.PARAM_Y);
- int mode = map.getInt(WearConst.PARAM_MODE);
- Intent intent = new Intent();
- intent.setClass(this, CanvasActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(WearConst.PARAM_SOURCE_ID, nodeId);
- intent.putExtra(WearConst.PARAM_REQUEST_ID, requestId);
- intent.putExtra(WearConst.PARAM_BITMAP, profileAsset);
- intent.putExtra(WearConst.PARAM_X, x);
- intent.putExtra(WearConst.PARAM_Y, y);
- intent.putExtra(WearConst.PARAM_MODE, mode);
- startActivity(intent);
- }
- }
- }
-
- private void startSensorService(String id) {
- Intent intent = new Intent();
- intent.setAction(WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_REGISTER);
- intent.setClass(this, WearAppService.class);
- intent.putExtra(WearConst.PARAM_SENSOR_ID, id);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- startForegroundService(intent);
- } else {
- startService(intent);
- }
- }
-
- private void stopSensorService(String id) {
- Intent intent = new Intent();
- intent.setAction(WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_UNREGISTER);
- intent.setClass(this, WearAppService.class);
- intent.putExtra(WearConst.PARAM_SENSOR_ID, id);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- startForegroundService(intent);
- } else {
- startService(intent);
- }
- }
-
- @Override
- public void onMessageReceived(final MessageEvent messageEvent) {
- // get id of wear device
- String id = messageEvent.getSourceNodeId();
- String action = messageEvent.getPath();
- if (action.equals(WearConst.DEVICE_TO_WEAR_VIBRATION_RUN)) {
- startVibration(messageEvent);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_VIBRATION_DEL)) {
- stopVibration();
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_CANCAS_DELETE_IMAGE)) {
- deleteCanvas();
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_REGISTER)) {
- startSensorService(id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_UNREGISTER)) {
- stopSensorService(id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_REGISTER)) {
- startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_REGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_UNREGISTER)) {
- startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_UNREGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_REGISTER)) {
- startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_REGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_UNREGISTER)) {
- startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_UNREGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_REGISTER)) {
- startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_REGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_UNREGISTER)) {
- startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_UNREGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_REGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_REGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_REGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_REGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_REGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_REGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_REGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_REGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_REGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_REGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_REGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_REGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_REGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_REGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_UNREGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_UNREGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_UNREGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_UNREGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_UNREGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_UNREGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_UNREGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_UNREGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_UNREGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_UNREGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_UNREGISTER)) {
- startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_UNREGISTER, id);
- } else if (action.equals(WearConst.DEVICE_TO_WEAR_SET_ID)) {
- String wearId = new String(messageEvent.getData());
- ((WearApplication) getApplication()).setSelfId(wearId);
- } else {
- if (BuildConfig.DEBUG) {
- Log.e("Wear", "unknown event:" + action);
- }
- }
- }
-
- @Override
- public void onPeerConnected(final Node peer) {
- }
-
- @Override
- public void onPeerDisconnected(final Node peer) {
- }
-
- /**
- * バイブレーションを開始する.
- * @param messageEvent メッセージ
- */
- private void startVibration(final MessageEvent messageEvent) {
- // get vibration pattern
- String mPattern = new String(messageEvent.getData());
-
- // Make array of pattern
- String[] mPatternArray = mPattern.split(",", 0);
- long[] mPatternLong = new long[mPatternArray.length + 1];
- mPatternLong[0] = 0;
- for (int i = 1; i < mPatternLong.length; i++) {
- mPatternLong[i] = Integer.parseInt(mPatternArray[i - 1]);
- }
-
- Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
- vibrator.vibrate(mPatternLong, -1);
- }
-
- /**
- * バイブレーションを停止する.
- */
- private void stopVibration() {
- Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
- // 停止のパターンの時にバイブレーションを止めようとした時にcancelが効かないため、
- // バイブレーションが停止している時は、一度バイブレーションを鳴らしたのちに停止を行う。
- vibrator.vibrate(new long[]{100}, -1);
- vibrator.cancel();
- }
-
- /**
- * Canvasの画面を削除する.
- */
- private void deleteCanvas() {
- Intent intent = new Intent();
- intent.setClass(this, CanvasActivity.class);
- intent.setAction(WearConst.ACTION_DELETE_CANVAS);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- }
-
- /**
- * Execute Key Event Activity.
- *
- * @param regist Register string.
- */
- private void startKeyEventActivity(final String regist, String id) {
- Intent i = new Intent(this, WearKeyEventProfileActivity.class);
- i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- i.putExtra(WearConst.PARAM_KEYEVENT_REGIST, regist);
- i.putExtra(WearConst.PARAM_KEYEVENT_ID, id);
- startActivity(i);
- }
-
- /**
- * Execute Touch Activity.
- *
- * @param regist Register string.
- */
- private void startTouchActivity(final String regist, String id) {
- Intent i = new Intent(this, WearTouchProfileActivity.class);
- i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- i.putExtra(WearConst.PARAM_TOUCH_REGIST, regist);
- i.putExtra(WearConst.PARAM_TOUCH_ID, id);
- startActivity(i);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearAppService.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearAppService.java
deleted file mode 100644
index b8b0691432..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearAppService.java
+++ /dev/null
@@ -1,197 +0,0 @@
-package org.deviceconnect.android.deviceplugin.wear;
-
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.app.Service;
-import android.content.Intent;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
-import android.os.Build;
-import android.os.IBinder;
-import androidx.annotation.Nullable;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-public class WearAppService extends Service implements SensorEventListener {
- /** radian. */
- private static final double RAD2DEG = 180 / Math.PI;
-
- /** Device NodeID . */
- private final List mIds = Collections.synchronizedList(new ArrayList());
-
- /** SensorManager. */
- private SensorManager mSensorManager;
-
- /** Gyro x. */
- private float mGyroX;
-
- /** Gyro y. */
- private float mGyroY;
-
- /** Gyro z. */
- private float mGyroZ;
-
- /** The start time for measuring the interval. */
- private long mStartTime;
-
- /** GyroSensor. */
- private Sensor mGyroSensor;
-
- /** AcceleratorSensor. */
- private Sensor mAccelerometer;
-
- /**
- * スレッド管理用クラス.
- */
- private final ExecutorService mExecutorService = Executors.newSingleThreadExecutor();
-
- @Override
- public void onCreate() {
- super.onCreate();
- }
-
- @Nullable
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- if (intent != null) {
- String action = intent.getAction();
- String id = intent.getStringExtra(WearConst.PARAM_SENSOR_ID);
- if (WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_REGISTER.equals(action)) {
- if (!mIds.contains(id)) {
- mIds.add(id);
- }
- registerSensor();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- NotificationManager manager = (NotificationManager) getSystemService(Service.NOTIFICATION_SERVICE);
- String channelId = getString(R.string.android_wear_data_layer_channel_id);
- NotificationChannel channel = new NotificationChannel(
- channelId,
- getString(R.string.android_wear_data_layer_channel_title),
- NotificationManager.IMPORTANCE_LOW);
- channel.setDescription(getResources().getString(R.string.android_wear_data_layer_channel_desc));
- manager.createNotificationChannel(channel);
- Notification.Builder builder = new Notification.Builder(this, channelId);
- builder.setContentTitle(getString(R.string.android_wear_data_layer_channel_id));
- builder.setContentText(getString(R.string.android_wear_data_layer_channel_desc));
- builder.setWhen(System.currentTimeMillis());
- builder.setAutoCancel(false);
- startForeground(1, builder.build());
- }
- } else if (WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_UNREGISTER.equals(action)) {
- mIds.remove(id);
- if (mIds.isEmpty()) {
- unregisterSensor();
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- stopForeground(true);
- }
- }
- }
- return super.onStartCommand(intent, flags, startId);
- }
-
- @Override
- public void onDestroy() {
- mIds.clear();
- unregisterSensor();
- super.onDestroy();
- }
-
- @Override
- public void onSensorChanged(final SensorEvent sensorEvent) {
- if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
- long time = System.currentTimeMillis();
- long interval = time - mStartTime;
- mStartTime = time;
-
- float accelX = sensorEvent.values[0];
- float accelY = sensorEvent.values[1];
- float accelZ = sensorEvent.values[2];
- final String data = accelX + "," + accelY + "," + accelZ
- + "," + mGyroX + "," + mGyroY + "," + mGyroZ + "," + interval;
- mExecutorService.execute(() -> {
- synchronized (mIds) {
- for (String id : mIds) {
- sendSensorEvent(data, id);
- }
- }
- });
- } else if (sensorEvent.sensor.getType() == Sensor.TYPE_GYROSCOPE) {
- mGyroX = (float) (sensorEvent.values[0] * RAD2DEG);
- mGyroY = (float) (sensorEvent.values[1] * RAD2DEG);
- mGyroZ = (float) (sensorEvent.values[2] * RAD2DEG);
- }
- }
-
- @Override
- public void onAccuracyChanged(final Sensor sensor, final int accuracy) {
- }
-
-
- /**
- * センサーイベントをスマホ側に送信する.
- * @param data 送信するデータ
- * @param id 送信先のID
- */
- private void sendSensorEvent(final String data, final String id) {
- WearApplication application = getWearApplication();
- application.sendMessage(id, WearConst.WEAR_TO_DEVICE_DEIVCEORIENTATION_DATA, data);
- }
-
- /**
- * センサーを登録する.
- */
- private synchronized void registerSensor() {
- if (mSensorManager != null) {
- return;
- }
- new Thread(() -> {
- mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
- List accelSensors = mSensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
- if (accelSensors.size() > 0) {
- mAccelerometer = accelSensors.get(0);
- mSensorManager.registerListener(WearAppService.this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
- }
-
- List gyroSensors = mSensorManager.getSensorList(Sensor.TYPE_GYROSCOPE);
- if (gyroSensors.size() > 0) {
- mGyroSensor = gyroSensors.get(0);
- mSensorManager.registerListener(WearAppService.this, mGyroSensor, SensorManager.SENSOR_DELAY_NORMAL);
- }
-
- mStartTime = System.currentTimeMillis();
- }).start();
- }
-
- /**
- * センサーを解除する.
- */
- private synchronized void unregisterSensor() {
- if (mSensorManager != null) {
- mSensorManager.unregisterListener(this, mAccelerometer);
- mSensorManager.unregisterListener(this, mGyroSensor);
- mSensorManager.unregisterListener(this);
- mSensorManager = null;
- }
- }
-
- /**
- * GoogleApiClientを取得する.
- * @return GoogleApiClient
- */
- private WearApplication getWearApplication() {
- return ((WearApplication) getApplication());
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearApplication.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearApplication.java
deleted file mode 100644
index 02c9f702f4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearApplication.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-DataLayerListenerService.java
-Copyright (c) 2015 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear;
-
-import android.app.Application;
-import androidx.annotation.NonNull;
-import android.util.Log;
-
-import com.google.android.gms.tasks.OnFailureListener;
-import com.google.android.gms.tasks.OnSuccessListener;
-import com.google.android.gms.tasks.Task;
-import com.google.android.gms.wearable.Wearable;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * このアプリで共有するGoogleApiClientを保持するアプリケーションクラス.
- */
-public class WearApplication extends Application {
-
- /**
- * WearのID.
- */
- private String mSelfId;
- /**
- * スレッド管理用クラス.
- */
- private final ExecutorService mExecutorService = Executors.newSingleThreadExecutor();
-
- @Override
- public void onCreate() {
- super.onCreate();
- }
-
- @Override
- public void onTerminate() {
- super.onTerminate();
- destroy();
- }
-
- /**
- * WearのIDを設定する.
- * @param self WearのID
- */
- public synchronized void setSelfId(final String self) {
- mSelfId = self;
- }
-
- /**
- * WearのIDを返す.
- * @return WearのID
- */
- public synchronized String getSelfId() {
- return mSelfId;
- }
-
- /**
- * 後始末を行う.
- */
- public synchronized void destroy() {
- mExecutorService.shutdown();
- }
-
- /**
- * Phone側にメッセージを送る.
- * @param destinationId phone側のID
- * @param path メッセージのパス
- * @param data メッセージのデータ
- */
- public void sendMessage(final String destinationId, final String path, final String data) {
- mExecutorService.execute(() -> {
- Task sendMessageTask =
- Wearable.getMessageClient(getApplicationContext())
- .sendMessage(destinationId, path, data.getBytes());
- sendMessageTask.addOnSuccessListener((integer) -> {
- if (BuildConfig.DEBUG) {
- Log.d("WEAR", "Sent result:" + integer);
- }
- });
-
- sendMessageTask.addOnFailureListener((e) -> {
- if (BuildConfig.DEBUG) {
- Log.e("WEAR", "Sent result:" + e.getLocalizedMessage());
- }
- });
- });
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearConst.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearConst.java
deleted file mode 100755
index 11c8f0d9d1..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/WearConst.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
-WearConst.java
-Copyright (c) 2014 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear;
-
-/**
- * Wear Const.
- *
- * @author NTT DOCOMO, INC.
- */
-public final class WearConst {
-
- /** Broadcast Intent Key. */
- public static final String ACTION_WEAR_PING_SERVICE = "org.deviceconnect.wear.ping.service";
-
- /** Vibration start. */
- public static final String DEVICE_TO_WEAR_VIBRATION_RUN = "org.deviceconnect.wear.vibration.run";
-
- /** Vibration stop. */
- public static final String DEVICE_TO_WEAR_VIBRATION_DEL = "org.deviceconnect.wear.vibration.del";
-
- /** when DeviceOrientation register is opened. */
- public static final String DEVICE_TO_WEAR_DEIVCEORIENTATION_REGISTER
- = "org.deviceconnect.wear.deivceorienatation.regist";
-
- /** When Canvas deleted. */
- public static final String DEVICE_TO_WEAR_CANCAS_DELETE_IMAGE
- = "org.deviceconnect.wear.canvas.delete";
-
- /** when DeviceOrientation unregister is opened. */
- public static final String DEVICE_TO_WEAR_DEIVCEORIENTATION_UNREGISTER
- = "org.deviceconnect.wear.deivceorienatation.unregist";
-
- /** Wear to Android. */
- public static final String WEAR_TO_DEVICE_DEIVCEORIENTATION_DATA = "org.deviceconnect.wear.deivceorienatation.data";
-
- /** Register Key Event (ondown). */
- public static final String DEVICE_TO_WEAR_KEYEVENT_ONDOWN_REGISTER
- = "org.deviceconnect.wear.keyevent.ondown.regist";
-
- /** Register Key Event (onup). */
- public static final String DEVICE_TO_WEAR_KEYEVENT_ONUP_REGISTER = "org.deviceconnect.wear.keyevent.onup.regist";
- /** Register Key Event (onkeychange). */
- public static final String DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_REGISTER
- = "org.deviceconnect.wear.keyevent.onkeychange.regist";
- /** Remove Key Event (ondown). */
- public static final String DEVICE_TO_WEAR_KEYEVENT_ONDOWN_UNREGISTER
- = "org.deviceconnect.wear.keyevent.ondown.unregist";
-
- /** Remove Key Event (onup). */
- public static final String DEVICE_TO_WEAR_KEYEVENT_ONUP_UNREGISTER
- = "org.deviceconnect.wear.keyevent.onup.unregist";
- /** Remove Key Event (onkeychange). */
- public static final String DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_UNREGISTER
- = "org.deviceconnect.wear.keyevent.onkeychange.unregist";
- /** Set wear id.. */
- public static final String DEVICE_TO_WEAR_SET_ID
- = "org.deviceconnect.wear.id.set";
-
- /** Wear to Android. */
- public static final String WEAR_TO_DEVICE_KEYEVENT_DATA = "org.deviceconnect.wear.keyevent.data";
-
- /** Broadcast Intent Key. */
- public static final String PARAM_DC_WEAR_KEYEVENT_SVC_TO_ACT = "DC_WEAR_KEYEVENT_SVC_TO_ACT";
-
- /** Broadcast Intent Key. */
- public static final String PARAM_DC_WEAR_KEYEVENT_ACT_TO_SVC = "DC_WEAR_KEYEVENT_ACT_TO_SVC";
-
- /** Key Event (down). */
- public static final String PARAM_KEYEVENT_DOWN = "down";
-
- /** Key Event (up). */
- public static final String PARAM_KEYEVENT_UP = "up";
-
- /** Broadcast Data Key (Regist). */
- public static final String PARAM_KEYEVENT_REGIST = "keyeventRegist";
-
- /** Broadcast Data Key (Regist). */
- public static final String PARAM_KEYEVENT_ID = "keyeventId";
-
- /** Broadcast Data Key (Data). */
- public static final String PARAM_KEYEVENT_DATA = "data";
-
- /** Key Type (Standard Keyboard). */
- public static final int KEYTYPE_STD_KEY = 0x00000000;
-
- /** Key Type (Media Control). */
- public static final int KEYTYPE_MEDIA_CTRL = 0x00000200;
-
- /** Key Type (Directional Pad / Button). */
- public static final int KEYTYPE_DPAD_BUTTON = 0x00000400;
-
- /** Key Type (User Define). */
- public static final int KEYTYPE_USER = 0x00000800;
-
- /** Register Touch (ontouch). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCH_REGISTER
- = "org.deviceconnect.wear.touch.ontouch.regist";
-
- /** Register Touch (ontouchstart). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_REGISTER
- = "org.deviceconnect.wear.touch.ontouchstart.regist";
-
- /** Register Touch (ontouchend). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_REGISTER
- = "org.deviceconnect.wear.touch.ontouchend.regist";
-
- /** Register Touch (ondoubletap). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_REGISTER
- = "org.deviceconnect.wear.touch.ondoubletap.regist";
-
- /** Register Touch (ontouchmove). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_REGISTER
- = "org.deviceconnect.wear.touch.ontouchmove.regist";
-
- /** Register Touch (ontouchcancel). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_REGISTER
- = "org.deviceconnect.wear.touch.ontouchcancel.regist";
- /** Register Touch (ontouchchange). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_REGISTER
- = "org.deviceconnect.wear.touch.ontouchchange.regist";
-
- /** Remove Touch (ontouch). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCH_UNREGISTER
- = "org.deviceconnect.wear.touch.ontouch.unregist";
-
- /** Remove Touch (ontouchstart). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_UNREGISTER
- = "org.deviceconnect.wear.touch.ontouchstart.unregist";
-
- /** Remove Touch (ontouchend). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_UNREGISTER
- = "org.deviceconnect.wear.touch.ontouchend.unregist";
-
- /** Remove Touch (ondoubletap). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_UNREGISTER
- = "org.deviceconnect.wear.touch.ondoubletap.unregist";
-
- /** Remove Touch (ontouchmove). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_UNREGISTER
- = "org.deviceconnect.wear.touch.ontouchmove.unregist";
-
- /** Remove Touch (ontouchcancel). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_UNREGISTER
- = "org.deviceconnect.wear.touch.ontouchcancel.unregist";
- /** Remove Touch (ontouchchange). */
- public static final String DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_UNREGISTER
- = "org.deviceconnect.wear.touch.ontouchchange.unregist";
-
- /** Broadcast Data Key (Regist). */
- public static final String PARAM_TOUCH_REGIST = "touchRegist";
-
- public static final String PARAM_TOUCH_ID = "touchId";
-
- /** Broadcast Data Key (Data). */
- public static final String PARAM_TOUCH_DATA = "data";
-
- /** Broadcast Intent Key. */
- public static final String PARAM_DC_WEAR_TOUCH_SVC_TO_ACT = "DC_WEAR_TOUCH_SVC_TO_ACT";
-
- /** Broadcast Intent Key. */
- public static final String PARAM_DC_WEAR_TOUCH_ACT_TO_SVC = "DC_WEAR_TOUCH_ACT_TO_SVC";
-
- /** Wear to Android. */
- public static final String WEAR_TO_DEVICE_TOUCH_DATA = "org.deviceconnect.wear.touch.data";
-
- /** Touch (touch). */
- public static final String PARAM_TOUCH_TOUCH = "touch";
-
- /** Touch (touchstart). */
- public static final String PARAM_TOUCH_TOUCHSTART = "touchstart";
-
- /** Touch (touchend). */
- public static final String PARAM_TOUCH_TOUCHEND = "touchend";
-
- /** Touch (doubletap). */
- public static final String PARAM_TOUCH_DOUBLETAP = "doubletap";
-
- /** Touch (touchmove). */
- public static final String PARAM_TOUCH_TOUCHMOVE = "touchmove";
-
- /** Touch (touchcancel). */
- public static final String PARAM_TOUCH_TOUCHCANCEL = "touchcancel";
-
- /**
- * Canvas Profile Action.
- */
- public static final String ACTION_DELETE_CANVAS = "org.devcieconnect.wear.canvas.delete";
-
- /** Broadcast Intent Key. */
- public static final String PARAM_DC_WEAR_CANVAS_ACT_TO_SVC = "DC_WEAR_CANVAS_ACT_TO_SVC";
-
- /** Wear to Android. */
- public static final String WEAR_TO_DEVICE_CANVAS_RESULT = "org.deviceconnect.wear.canvas.result";
-
- /** リクエストID. */
- public static final String PARAM_REQUEST_ID = "requestId";
-
- /** データ変更イベントの送信元(Android端末)を特定するためのID. */
- public static final String PARAM_SOURCE_ID = "sourceId";
-
- /** メッセージの送信先(Android端末)を特定するためのID. */
- public static final String PARAM_DESTINATION_ID = "destinationId";
-
- public static final String PARAM_SENSOR_ID = "sensorId";
-
- /**
- * bitmapを受け渡しするためのキー.
- */
- public static final String PARAM_RESULT = "result";
-
- /** 成功. */
- public static final String RESULT_SUCCESS = "success";
-
- /** エラー: ビットマップサイズが大きすぎる. */
- public static final String RESULT_ERROR_TOO_LARGE_BITMAP = "errorTooLargeBitmap";
-
- /** エラー: Android端末との接続に失敗. */
- public static final String RESULT_ERROR_CONNECTION_FAILURE = "errorConnectionFailure";
-
- /** エラー: サポートしていない画像形式. */
- public static final String RESULT_ERROR_NOT_SUPPORTED_FORMAT = "errorNotSupportedFormat";
-
- /**
- * bitmapを受け渡しするためのキー.
- */
- public static final String PARAM_BITMAP = "bitmap";
-
- /**
- * x座標を受け渡しするためのキー.
- */
- public static final String PARAM_X = "x";
-
- /**
- * y座標を受け渡しするためのキー.
- */
- public static final String PARAM_Y = "y";
-
- /**
- * 描画モードを受け渡しするためのキー.
- */
- public static final String PARAM_MODE = "mode";
-
- /**
- * 画像を送信するためのパスを定義する.
- */
- public static final String PATH_CANVAS = "/canvas/profile";
-
- /**
- * 通常の描画モード.
- */
- public static final int MODE_NORMAL = 0;
-
- /**
- * 拡大の描画モード.
- */
- public static final int MODE_SCALES = 1;
-
- /**
- * リピート描画モード.
- */
- public static final int MODE_FILLS = 2;
-
- /**
- * Constructor.
- */
- private WearConst() {
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/activity/CanvasActivity.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/activity/CanvasActivity.java
deleted file mode 100644
index 94c32abc10..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/activity/CanvasActivity.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
-DataLayerListenerService.java
-Copyright (c) 2015NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.activity;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Matrix;
-import android.graphics.Shader;
-import android.graphics.drawable.BitmapDrawable;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.os.PowerManager;
-import androidx.wear.widget.BoxInsetLayout;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-
-import com.google.android.gms.tasks.Task;
-import com.google.android.gms.tasks.Tasks;
-import com.google.android.gms.wearable.Asset;
-import com.google.android.gms.wearable.DataClient;
-import com.google.android.gms.wearable.Wearable;
-
-import org.deviceconnect.android.deviceplugin.wear.R;
-import org.deviceconnect.android.deviceplugin.wear.WearApplication;
-import org.deviceconnect.android.deviceplugin.wear.WearConst;
-
-import java.io.InputStream;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import static androidx.wear.widget.BoxInsetLayout.LayoutParams.BOX_ALL;
-
-/**
- * Canvas.
- */
-public class CanvasActivity extends Activity {
- /**
- * Defines the timeout.
- */
- private static final int TIMEOUT_MS = 10000;
-
- /**
- * ImageView.
- */
- private ImageView mImageView;
-
- /**
- * Wakelock.
- */
- private PowerManager.WakeLock mWakeLock;
- /**
- * Canvas Layout.
- */
- private FrameLayout mFrameLayout;
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
- mWakeLock = powerManager.newWakeLock((PowerManager.PARTIAL_WAKE_LOCK
- | PowerManager.ACQUIRE_CAUSES_WAKEUP), "DeviceConnect:CanvasWakelockTag");
-
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- setContentView(R.layout.activity_canvas);
- if (!mWakeLock.isHeld()) {
- mWakeLock.acquire();
- }
- mImageView = (ImageView) findViewById(R.id.canvas_image);
- mImageView.setVisibility(View.INVISIBLE);
- mFrameLayout = findViewById(R.id.canvas_frame);
-
- Intent intent = getIntent();
- if (intent != null) {
- refreshImage(intent);
- }
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mWakeLock.release();
- }
-
- @Override
- protected void onNewIntent(final Intent intent) {
- super.onNewIntent(intent);
- if (intent != null) {
- refreshImage(intent);
- }
- }
-
- /**
- * Refresh image.
- * @param intent Intent
- */
- private void refreshImage(final Intent intent) {
- String action = intent.getAction();
- if (WearConst.ACTION_DELETE_CANVAS.equals(action)) {
- finish();
- return;
- }
-
- (new AsyncTask() {
- @Override
- protected LoadingResult doInBackground(Void... params) {
- Asset asset = intent.getParcelableExtra(WearConst.PARAM_BITMAP);
- return loadBitmapFromAsset(asset);
- }
- @Override
- protected void onPostExecute(LoadingResult result) {
- String sourceId = intent.getStringExtra(WearConst.PARAM_SOURCE_ID);
- String requestId = intent.getStringExtra(WearConst.PARAM_REQUEST_ID);
- sendResultToHost(sourceId, requestId, result.getResultCode());
- if (!result.isSuccess()) {
- finish();
- return;
- }
-
- Bitmap bitmap = result.getBitmap();
- if (bitmap == null) {
- return;
- }
-
- int x = intent.getIntExtra(WearConst.PARAM_X, 0);
- int y = intent.getIntExtra(WearConst.PARAM_Y, 0);
- int mode = intent.getIntExtra(WearConst.PARAM_MODE, 0);
- setImageBitmap(bitmap, mode, x, y);
- }
- }).execute();
- }
-
- private void sendResultToHost(final String destinationId, final String requestId, final String resultCode) {
- String data = requestId + "," + resultCode;
- String path = WearConst.WEAR_TO_DEVICE_CANVAS_RESULT;
- ((WearApplication) getApplication()).sendMessage(destinationId, path, data);
- }
-
- /**
- * Sets a bitmap to ImageView.
- * @param bitmap bitmap
- * @param mode mode
- * @param x x
- * @param y y
- */
- private synchronized void setImageBitmap(final Bitmap bitmap, final int mode, final int x, final int y) {
- switch (mode) {
- default:
- case WearConst.MODE_NORMAL:
- Matrix matrix = new Matrix();
- matrix.postTranslate((float) x, (float) y);
- mImageView.setImageBitmap(bitmap);
- mImageView.setScaleType(ImageView.ScaleType.MATRIX);
- mImageView.setImageMatrix(matrix);
- mImageView.setVisibility(View.VISIBLE);
- BoxInsetLayout.LayoutParams normalLayoutParam = new BoxInsetLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER, BOX_ALL);
- mFrameLayout.setLayoutParams(normalLayoutParam);
- break;
- case WearConst.MODE_SCALES:
- mImageView.setImageBitmap(bitmap);
- mImageView.setScaleType(ImageView.ScaleType.FIT_START);
- mImageView.setTranslationX(x);
- mImageView.setTranslationY(y);
- mImageView.setVisibility(View.VISIBLE);
- BoxInsetLayout.LayoutParams scaleLayoutParam = new BoxInsetLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT, Gravity.LEFT | Gravity.TOP);
- mFrameLayout.setLayoutParams(scaleLayoutParam);
- break;
- case WearConst.MODE_FILLS:
- BitmapDrawable bd = new BitmapDrawable(getResources(), bitmap);
- bd.setTileModeX(Shader.TileMode.REPEAT);
- bd.setTileModeY(Shader.TileMode.REPEAT);
- mImageView.setImageDrawable(bd);
- mImageView.setScaleType(ImageView.ScaleType.FIT_XY);
- mImageView.setTranslationX(x);
- mImageView.setTranslationY(y);
- mImageView.setVisibility(View.VISIBLE);
- BoxInsetLayout.LayoutParams fillLayoutParam = new BoxInsetLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT, Gravity.LEFT | Gravity.TOP);
- mFrameLayout.setLayoutParams(fillLayoutParam);
- break;
- }
- }
-
- /**
- * Load a bitmap from Asset.
- * @param asset asset
- * @return result of loading
- */
- private LoadingResult loadBitmapFromAsset(final Asset asset) {
- InputStream in = getInputStream(asset);
- if (in == null) {
- return LoadingResult.errorOnConnection();
- }
- try {
- Bitmap bitmap = BitmapFactory.decodeStream(in);
- if (bitmap == null) {
- return LoadingResult.errorNotSupportedFormat();
- }
- return LoadingResult.success(bitmap);
- } catch (OutOfMemoryError e) {
- return LoadingResult.errorTooLargeBitmap();
- }
- }
-
- /**
- * Get an input stream from Asset.
- * @param asset input stream of asset
- * @return input stream, null on error
- */
- private InputStream getInputStream(final Asset asset) {
- if (asset == null) {
- return null;
- }
- Task getFdForAssetResponseTask =
- Wearable.getDataClient(getApplicationContext()).getFdForAsset(asset);
-
- InputStream assetInputStream = null;
- try {
- DataClient.GetFdForAssetResponse getFdForAssetResponse = null;
- getFdForAssetResponse = Tasks.await(getFdForAssetResponseTask, TIMEOUT_MS, TimeUnit.MILLISECONDS);
- assetInputStream = getFdForAssetResponse.getInputStream();
- } catch (TimeoutException exception) {
- Log.e("WEAR", "Failed retrieving asset, Timeout failed: " + exception);
- } catch (ExecutionException exception) {
- Log.e("WEAR", "Failed retrieving asset, Task failed: " + exception);
- } catch (InterruptedException exception) {
- Log.e("WEAR", "Failed retrieving asset, interrupt occurred: " + exception);
- }
- return assetInputStream;
- }
-
-
- private static class LoadingResult {
- private Bitmap mBitmap;
- private String mResultCode;
-
- private LoadingResult() {
- }
-
- public Bitmap getBitmap() {
- return mBitmap;
- }
-
- public String getResultCode() {
- return mResultCode;
- }
-
- public boolean isSuccess() {
- return WearConst.RESULT_SUCCESS.equals(mResultCode);
- }
-
- static LoadingResult success(final Bitmap bitmap) {
- if (bitmap == null) {
- throw new IllegalArgumentException();
- }
- LoadingResult result = new LoadingResult();
- result.mResultCode = WearConst.RESULT_SUCCESS;
- result.mBitmap = bitmap;
- return result;
- }
-
- static LoadingResult errorTooLargeBitmap() {
- LoadingResult result = new LoadingResult();
- result.mResultCode = WearConst.RESULT_ERROR_TOO_LARGE_BITMAP;
- return result;
- }
-
- static LoadingResult errorOnConnection() {
- LoadingResult result = new LoadingResult();
- result.mResultCode = WearConst.RESULT_ERROR_CONNECTION_FAILURE;
- return result;
- }
-
- static LoadingResult errorNotSupportedFormat() {
- LoadingResult result = new LoadingResult();
- result.mResultCode = WearConst.RESULT_ERROR_NOT_SUPPORTED_FORMAT;
- return result;
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/activity/WearKeyEventProfileActivity.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/activity/WearKeyEventProfileActivity.java
deleted file mode 100644
index 7b7f62c1ba..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/activity/WearKeyEventProfileActivity.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
-WearKeyEventProfileActivity.java
-Copyright (c) 2015 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.activity;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.PowerManager;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.WindowManager;
-import android.widget.Button;
-
-import org.deviceconnect.android.deviceplugin.wear.R;
-import org.deviceconnect.android.deviceplugin.wear.WearApplication;
-import org.deviceconnect.android.deviceplugin.wear.WearConst;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * WearKeyEventProfileActivity.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearKeyEventProfileActivity extends Activity {
- /** Device NodeID . */
- private final List mIds = Collections.synchronizedList(new ArrayList());
-
- /** Event flag. */
- private int mRegisterEvent = 0;
- /** Event flag define (down). */
- private static final int REGIST_FLAG_KEYEVENT_DOWN = 0x01;
- /** Event flag define (up). */
- private static final int REGIST_FLAG_KEYEVENT_UP = 0x02;
- /** Event flag define (keyChange). */
- private static final int REGIST_FLAG_KEYEVENT_KEYCHANGE = 0x04;
- /** Button define. */
- private Button mBtnKeyMode, mBtnCancel, mBtnOk;
- /** Key mode. */
- private int mKeyMode = 0;
-
- /** Key mode count. */
- private static final int KM_MAX_CNT = 4;
- /** Key mode (Standard Keyboard). */
- private static final int KM_STD_KEY = 0;
- /** Key mode (Media Control). */
- private static final int KM_MEDIA_CTRL = 1;
- /** Key mode (Direction PAd / Button ). */
- private static final int KM_DPAD_BUTTON = 2;
- /** Key mode (User Define). */
- private static final int KM_USER = 3;
-
- /** Key Code define(cancel). */
- private static final int KEYCODE_CANCEL = 0;
- /** Key Code define(ok). */
- private static final int KEYCODE_OK = 1;
-
- /** Configure (Standard Keyboard). */
- private static final String[] CONFIG_STD_KEY =
- {"Cancel", "OK"};
- /** Configure (Media Control). */
- private static final String[] CONFIG_MEDIA_CTRL =
- {"stop", "play"};
- /** Configure (Directional Pad). */
- private static final String[] CONFIG_DPAD =
- {"up", "down"};
- /** Configure (User defined). */
- private static final String[] CONFIG_USER =
- {"USER_CANCEL", "USER_OK"};
-
- /**
- * Wakelock.
- */
- private PowerManager.WakeLock mWakeLock;
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
- mWakeLock = powerManager.newWakeLock((PowerManager.PARTIAL_WAKE_LOCK
- | PowerManager.ACQUIRE_CAUSES_WAKEUP), "DeviceConnect:KeyEvent");
-
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- if (!mWakeLock.isHeld()) {
- mWakeLock.acquire();
- }
- setRegisterEvent(getIntent());
- setContentView(R.layout.activity_wear_keyevent_profile);
-
- mBtnKeyMode = findViewById(R.id.button_key_mode);
- mBtnKeyMode.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(final View v) {
- // Update Key Mode.
- mKeyMode++;
- if (mKeyMode >= KM_MAX_CNT) {
- mKeyMode = KM_STD_KEY;
- }
-
- String keyMode;
- switch (mKeyMode) {
- case KM_MEDIA_CTRL:
- keyMode = getString(R.string.key_mode_media_ctrl);
- break;
- case KM_DPAD_BUTTON:
- keyMode = getString(R.string.key_mode_dpad_button);
- break;
- case KM_USER:
- keyMode = getString(R.string.key_mode_user);
- break;
- case KM_STD_KEY:
- default:
- keyMode = getString(R.string.key_mode_std_key);
- break;
- }
- mBtnKeyMode.setText(keyMode);
- }
- });
-
- mBtnCancel = findViewById(R.id.button_cancel);
- mBtnCancel.setOnTouchListener((view, event) -> {
- int action = event.getAction();
- switch (action) {
- case MotionEvent.ACTION_DOWN:
- case MotionEvent.ACTION_UP:
- sendMessageData(action, KEYCODE_CANCEL);
- break;
- default:
- break;
- }
- return false;
- });
-
- mBtnOk = findViewById(R.id.button_ok);
- mBtnOk.setOnTouchListener((view, event) -> {
- int action = event.getAction();
- switch (action) {
- case MotionEvent.ACTION_DOWN:
- case MotionEvent.ACTION_UP:
- sendMessageData(action, KEYCODE_OK);
- break;
- default:
- break;
- }
- return false;
- });
- Intent i = new Intent(WearConst.ACTION_WEAR_PING_SERVICE);
- LocalBroadcastManager.getInstance(this).sendBroadcast(i);
- }
-
- @Override
- protected void onNewIntent(Intent intent) {
- setRegisterEvent(intent);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mWakeLock.release();
- }
-
- /**
- * Get Configure string.
- *
- * @param keyMode Key Mode.
- * @param keyId Key ID.
- * @return config Configure string.
- */
- private String getConfig(final int keyMode, final int keyId) {
- String config;
- int nIndex;
- switch (keyId) {
- case KEYCODE_CANCEL:
- nIndex = 0;
- break;
- case KEYCODE_OK:
- nIndex = 1;
- break;
- default:
- nIndex = -1;
- break;
- }
-
- if (nIndex != -1) {
- switch (keyMode) {
- case KM_MEDIA_CTRL:
- config = CONFIG_MEDIA_CTRL[nIndex];
- break;
- case KM_DPAD_BUTTON:
- config = CONFIG_DPAD[nIndex];
- break;
- case KM_USER:
- config = CONFIG_USER[nIndex];
- break;
- case KM_STD_KEY:
- default:
- config = CONFIG_STD_KEY[nIndex];
- break;
- }
- } else {
- config = "";
- }
-
- return config;
- }
-
- /**
- * Send message data.
- *
- * @param action MotionEvent action.
- * @param keyId Key ID.
- */
- private void sendMessageData(final int action, final int keyId) {
- int keycode = keyId;
- String keyConfig = getConfig(mKeyMode, keycode);
- String keyAction;
- if (action == MotionEvent.ACTION_DOWN) {
- if ((mRegisterEvent & REGIST_FLAG_KEYEVENT_KEYCHANGE) == 0
- && (mRegisterEvent & REGIST_FLAG_KEYEVENT_DOWN) == 0) {
- return;
- }
- keyAction = WearConst.PARAM_KEYEVENT_DOWN;
- } else {
- if ((mRegisterEvent & REGIST_FLAG_KEYEVENT_KEYCHANGE) == 0
- && (mRegisterEvent & REGIST_FLAG_KEYEVENT_UP) == 0) {
- return;
- }
- keyAction = WearConst.PARAM_KEYEVENT_UP;
- }
-
- switch (mKeyMode) {
- case KM_MEDIA_CTRL:
- keycode += WearConst.KEYTYPE_MEDIA_CTRL;
- break;
- case KM_DPAD_BUTTON:
- keycode += WearConst.KEYTYPE_DPAD_BUTTON;
- break;
- case KM_USER:
- keycode += WearConst.KEYTYPE_USER;
- break;
- case KM_STD_KEY:
- default:
- keycode += WearConst.KEYTYPE_STD_KEY;
- break;
- }
-
- String data = keyAction + "," + String.valueOf(keycode) + "," + keyConfig;
- sendEvent(WearConst.WEAR_TO_DEVICE_KEYEVENT_DATA, data);
- }
-
- private void sendEvent(final String path, final String data) {
- synchronized (mIds) {
- for (String id : mIds) {
- ((WearApplication) getApplication()).sendMessage(id, path, data);
- }
- }
- }
-
- private void setRegisterEvent(Intent intent) {
- String type = intent.getStringExtra(WearConst.PARAM_KEYEVENT_REGIST);
- String id = intent.getStringExtra(WearConst.PARAM_KEYEVENT_ID);
- setRegisterEvent(type, id);
- }
-
- /**
- * Set register event.
- *
- * @param regist Request event.
- */
- private void setRegisterEvent(final String regist, final String id) {
- if (WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_REGISTER.equals(regist)) {
- if (!mIds.contains(id)) {
- mIds.add(id);
- }
- mRegisterEvent |= REGIST_FLAG_KEYEVENT_DOWN;
- } else if (WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_REGISTER.equals(regist)) {
- if (!mIds.contains(id)) {
- mIds.add(id);
- }
- mRegisterEvent |= REGIST_FLAG_KEYEVENT_UP;
- } else if (WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_REGISTER.equals(regist)) {
- if (!mIds.contains(id)) {
- mIds.add(id);
- }
- mRegisterEvent |= REGIST_FLAG_KEYEVENT_KEYCHANGE;
- } else if (WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_UNREGISTER.equals(regist)) {
- mIds.remove(id);
- mRegisterEvent &= ~(REGIST_FLAG_KEYEVENT_DOWN);
- if (mRegisterEvent == 0) {
- finish();
- }
- } else if (WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_UNREGISTER.equals(regist)) {
- mIds.remove(id);
- mRegisterEvent &= ~(REGIST_FLAG_KEYEVENT_UP);
- if (mRegisterEvent == 0) {
- finish();
- }
- } else if (WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_UNREGISTER.equals(regist)) {
- mIds.remove(id);
- mRegisterEvent &= ~(REGIST_FLAG_KEYEVENT_KEYCHANGE);
- if (mRegisterEvent == 0) {
- finish();
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/activity/WearTouchProfileActivity.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/activity/WearTouchProfileActivity.java
deleted file mode 100644
index 122ddc736e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/activity/WearTouchProfileActivity.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
-WearTouchProfileActivity.java
-Copyright (c) 2015 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.wear.activity;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.PowerManager;
-import androidx.annotation.NonNull;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-import android.view.GestureDetector;
-import android.view.GestureDetector.SimpleOnGestureListener;
-import android.view.MotionEvent;
-import android.view.WindowManager;
-
-import org.deviceconnect.android.deviceplugin.wear.R;
-import org.deviceconnect.android.deviceplugin.wear.WearApplication;
-import org.deviceconnect.android.deviceplugin.wear.WearConst;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * WearTouchProfileActivity.
- *
- * @author NTT DOCOMO, INC.
- */
-public class WearTouchProfileActivity extends Activity {
-
- /** Gesture detector. */
- private GestureDetector mGestureDetector;
-
- /** Device NodeID . */
- private final List mIds = Collections.synchronizedList(new ArrayList());
-
- /**
- * Wakelock.
- */
- private PowerManager.WakeLock mWakeLock;
-
- /** Event flag. */
- private int mRegisterEvent = 0;
- /** Event flag define (touch). */
- private static final int REGIST_FLAG_TOUCH_TOUCH = 0x01;
- /** Event flag define (touchstart). */
- private static final int REGIST_FLAG_TOUCH_TOUCHSTART = 0x02;
- /** Event flag define (touchend). */
- private static final int REGIST_FLAG_TOUCH_TOUCHEND = 0x04;
- /** Event flag define (doubletap). */
- private static final int REGIST_FLAG_TOUCH_DOUBLETAP = 0x08;
- /** Event flag define (touchmove). */
- private static final int REGIST_FLAG_TOUCH_TOUCHMOVE = 0x10;
- /** Event flag define (touchcancel). */
- private static final int REGIST_FLAG_TOUCH_TOUCHCANCEL = 0x20;
- /** Touch profile event flag. (ontouchchange). */
- private static final int REGIST_FLAG_TOUCH_TOUCHCHANGE = 0x0040;
- /**
- * Constructor.
- */
- public WearTouchProfileActivity() {
- }
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
- mWakeLock = powerManager.newWakeLock((PowerManager.PARTIAL_WAKE_LOCK
- | PowerManager.ACQUIRE_CAUSES_WAKEUP), "DeviceConnect:TouchWakelockTag");
-
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- if (!mWakeLock.isHeld()) {
- mWakeLock.acquire();
- }
-
- // Get intent data.
- setRegisterEvent(getIntent());
- setContentView(R.layout.activity_wear_touch_profile);
- mGestureDetector = new GestureDetector(this, mSimpleOnGestureListener);
-
- // For service destruction suppression.
- Intent i = new Intent(WearConst.ACTION_WEAR_PING_SERVICE);
- LocalBroadcastManager.getInstance(this).sendBroadcast(i);
- }
-
- @Override
- protected void onNewIntent(Intent intent) {
- setRegisterEvent(intent);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mWakeLock.release();
- }
-
- @Override
- public boolean dispatchTouchEvent(@NonNull final MotionEvent event) {
- boolean execFlag = false;
- int action = (event.getAction() & MotionEvent.ACTION_MASK);
- String strAction = null;
- switch (action) {
- case MotionEvent.ACTION_DOWN: // 1st touch only.
- case MotionEvent.ACTION_POINTER_DOWN: // Others touch.
- // "ontouch" event processing.
- if ((mRegisterEvent & REGIST_FLAG_TOUCH_TOUCH) != 0) {
- sendEventData(WearConst.PARAM_TOUCH_TOUCH, event);
- }
-
- // "ontouchstart" event processing.
- if ((mRegisterEvent & REGIST_FLAG_TOUCH_TOUCHCHANGE) != 0
- || (mRegisterEvent & REGIST_FLAG_TOUCH_TOUCHSTART) != 0) {
- strAction = WearConst.PARAM_TOUCH_TOUCHSTART;
- execFlag = true;
- }
- break;
- case MotionEvent.ACTION_UP: // Last touch remove only.
- case MotionEvent.ACTION_POINTER_UP: // Others touch move.
- // "ontouchend" event processing.
- if ((mRegisterEvent & REGIST_FLAG_TOUCH_TOUCHCHANGE) != 0
- || (mRegisterEvent & REGIST_FLAG_TOUCH_TOUCHEND) != 0) {
- strAction = WearConst.PARAM_TOUCH_TOUCHEND;
- execFlag = true;
- }
- break;
- case MotionEvent.ACTION_MOVE:
- // "ontouchmove" event processing.
- if ((mRegisterEvent & REGIST_FLAG_TOUCH_TOUCHCHANGE) != 0
- || (mRegisterEvent & REGIST_FLAG_TOUCH_TOUCHMOVE) != 0) {
- strAction = WearConst.PARAM_TOUCH_TOUCHMOVE;
- execFlag = true;
- }
- break;
- case MotionEvent.ACTION_CANCEL:
- // "ontouchcancel" event processing.
- if ((mRegisterEvent & REGIST_FLAG_TOUCH_TOUCHCHANGE) != 0
- || (mRegisterEvent & REGIST_FLAG_TOUCH_TOUCHCANCEL) != 0) {
- strAction = WearConst.PARAM_TOUCH_TOUCHCANCEL;
- execFlag = true;
- }
- break;
- default:
- return mGestureDetector.onTouchEvent(event);
- }
-
- if (execFlag) {
- sendEventData(strAction, event);
- }
- return mGestureDetector.onTouchEvent(event) || super.dispatchTouchEvent(event);
- }
-
- /**
- * Gesture Listener.
- */
- private final SimpleOnGestureListener mSimpleOnGestureListener = new SimpleOnGestureListener() {
- @Override
- public boolean onDoubleTap(final MotionEvent event) {
- if ((mRegisterEvent & REGIST_FLAG_TOUCH_TOUCHCHANGE) != 0
- || (mRegisterEvent & REGIST_FLAG_TOUCH_DOUBLETAP) != 0) {
- sendEventData(WearConst.PARAM_TOUCH_DOUBLETAP, event);
- }
- return super.onDoubleTap(event);
- }
- };
-
- /**
- * Send event data.
- *
- * @param action Action.
- * @param event MotionEvent.
- */
- private void sendEventData(final String action, final MotionEvent event) {
- int dataCount = event.getPointerCount();
- StringBuilder data = new StringBuilder(String.valueOf(dataCount));
- data.append(",").append(action);
- for (int n = 0; n < dataCount; n++) {
- int pointerId = event.getPointerId(n);
- data.append(",").append(pointerId).append(",").append(event.getX(n)).append(",").append(event.getY(n));
- }
-
- sendEvent(WearConst.WEAR_TO_DEVICE_TOUCH_DATA, data.toString());
- }
-
- private void sendEvent(final String path, final String data) {
- synchronized (mIds) {
- for (String id : mIds) {
- ((WearApplication) getApplication()).sendMessage(id, path, data);
- }
- }
- }
-
- private void setRegisterEvent(Intent intent) {
- String type = intent.getStringExtra(WearConst.PARAM_TOUCH_REGIST);
- String id = intent.getStringExtra(WearConst.PARAM_TOUCH_ID);
- setRegisterEvent(type, id);
- }
-
- /**
- * Set register event.
- *
- * @param regist Request event.
- */
- private void setRegisterEvent(final String regist, String id) {
- if (WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_REGISTER.equals(regist)) {
- if (!mIds.contains(id)) {
- mIds.add(id);
- }
- mRegisterEvent |= REGIST_FLAG_TOUCH_TOUCH;
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_REGISTER.equals(regist)) {
- if (!mIds.contains(id)) {
- mIds.add(id);
- }
- mRegisterEvent |= REGIST_FLAG_TOUCH_TOUCHSTART;
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_REGISTER.equals(regist)) {
- if (!mIds.contains(id)) {
- mIds.add(id);
- }
- mRegisterEvent |= REGIST_FLAG_TOUCH_TOUCHEND;
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_REGISTER.equals(regist)) {
- if (!mIds.contains(id)) {
- mIds.add(id);
- }
- mRegisterEvent |= REGIST_FLAG_TOUCH_DOUBLETAP;
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_REGISTER.equals(regist)) {
- if (!mIds.contains(id)) {
- mIds.add(id);
- }
- mRegisterEvent |= REGIST_FLAG_TOUCH_TOUCHMOVE;
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_REGISTER.equals(regist)) {
- if (!mIds.contains(id)) {
- mIds.add(id);
- }
- mRegisterEvent |= REGIST_FLAG_TOUCH_TOUCHCANCEL;
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_REGISTER.equals(regist)) {
- if (!mIds.contains(id)) {
- mIds.add(id);
- }
- mRegisterEvent |= REGIST_FLAG_TOUCH_TOUCHCHANGE;
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_UNREGISTER.equals(regist)) {
- mIds.remove(id);
- mRegisterEvent &= ~(REGIST_FLAG_TOUCH_TOUCH);
- if (mRegisterEvent == 0) {
- finish();
- }
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_UNREGISTER.equals(regist)) {
- mIds.remove(id);
- mRegisterEvent &= ~(REGIST_FLAG_TOUCH_TOUCHSTART);
- if (mRegisterEvent == 0) {
- finish();
- }
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_UNREGISTER.equals(regist)) {
- mIds.remove(id);
- mRegisterEvent &= ~(REGIST_FLAG_TOUCH_TOUCHEND);
- if (mRegisterEvent == 0) {
- finish();
- }
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_UNREGISTER.equals(regist)) {
- mIds.remove(id);
- mRegisterEvent &= ~(REGIST_FLAG_TOUCH_DOUBLETAP);
- if (mRegisterEvent == 0) {
- finish();
- }
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_UNREGISTER.equals(regist)) {
- mIds.remove(id);
- mRegisterEvent &= ~(REGIST_FLAG_TOUCH_TOUCHMOVE);
- if (mRegisterEvent == 0) {
- finish();
- }
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_UNREGISTER.equals(regist)) {
- mIds.remove(id);
- mRegisterEvent &= ~(REGIST_FLAG_TOUCH_TOUCHCANCEL);
- if (mRegisterEvent == 0) {
- finish();
- }
- } else if (WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_UNREGISTER.equals(regist)) {
- mIds.remove(id);
- mRegisterEvent &= ~(REGIST_FLAG_TOUCH_TOUCHCHANGE);
- if (mRegisterEvent == 0) {
- finish();
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/package-info.java b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/package-info.java
deleted file mode 100644
index eb89e6a5bd..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/java/org/deviceconnect/android/deviceplugin/wear/package-info.java
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
-org.deviceconnect.android.deviceplugin.wear
-Copyright (c) 2014 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
- */
-/**
- * Android Wear Device Plug-in package.
- * @author NTT DOCOMO, INC.
- */
-package org.deviceconnect.android.deviceplugin.wear;
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/drawable-xhdpi/dconnect_icon.png b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/drawable-xhdpi/dconnect_icon.png
deleted file mode 100755
index a3a7f4794e..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/drawable-xhdpi/dconnect_icon.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout-notround/activity_wear_keyevent_profile.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout-notround/activity_wear_keyevent_profile.xml
deleted file mode 100644
index 24f4eee90d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout-notround/activity_wear_keyevent_profile.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout-notround/activity_wear_touch_profile.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout-notround/activity_wear_touch_profile.xml
deleted file mode 100644
index f2b2a6d5b5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout-notround/activity_wear_touch_profile.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout-round/activity_wear_keyevent_profile.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout-round/activity_wear_keyevent_profile.xml
deleted file mode 100644
index 24f4eee90d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout-round/activity_wear_keyevent_profile.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout-round/activity_wear_touch_profile.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout-round/activity_wear_touch_profile.xml
deleted file mode 100644
index f2b2a6d5b5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout-round/activity_wear_touch_profile.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout/activity_canvas.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout/activity_canvas.xml
deleted file mode 100644
index 0261d85ef4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/layout/activity_canvas.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/values/dimens.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/values/dimens.xml
deleted file mode 100644
index 7794c57a73..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
- 12dp
- 12dp
- 16dp
- 12dp
- 12dp
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/values/strings.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/values/strings.xml
deleted file mode 100755
index 4866877e52..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
- dConnectWearWatch
- WearKeyEventProfileActivity
- Settings
- Standard Key
- Media Control
- DPAD / Button
- User define
- Cancel
- OK
-
- Touch Profile
- org.deviceconnect.android.intent.action.datalayer.androidwear
- Device Connect AndroidWear Data Service
- DeviceConnect\'s send data service.
-
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/values/wear.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/values/wear.xml
deleted file mode 100644
index 5115b0e4ea..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/values/wear.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
- - phone_deviceconnect
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/xml/network_security_config.xml b/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/xml/network_security_config.xml
deleted file mode 100644
index dca93c079e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceAndroidWear/wear-app/src/main/res/xml/network_security_config.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/LICENSE.TXT b/dConnectDevicePlugin/dConnectDeviceChromeCast/LICENSE.TXT
deleted file mode 100755
index 9f0bfd2fe5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/LICENSE.TXT
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2014 NTT DOCOMO, INC.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/README.md b/dConnectDevicePlugin/dConnectDeviceChromeCast/README.md
deleted file mode 100644
index 721fece730..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# Chromecast プラグイン
-
-このChromecastプラグインでは、Chromecast(Google Home)を操作するための機能を提供します。
-
-このプラグインを使用するには、Application IDの登録が必要になります。
-
-## 開発環境
-Android Studio 2.2.1以上
-
-## ビルドマニュアル
-- [Chromecastビルドマニュアル](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/ChromeCast-Build)
-
-## サポートするプロファイル
-
-* canvas
-* mediaPlayer
-* notification
-
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/build.gradle b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/build.gradle
deleted file mode 100644
index c468179db6..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/build.gradle
+++ /dev/null
@@ -1,80 +0,0 @@
-apply plugin: 'com.android.application'
-// Create github.properties in root project folder file with
-// gpr.usr=GITHUB_USER_ID
-// gpr.key=PERSONAL_ACCESS_TOKEN
-def githubPropertiesFile = rootProject.file("github.properties")
-def githubProperties = new Properties()
-if (githubPropertiesFile.exists()) {
- githubProperties.load(new FileInputStream(githubPropertiesFile))
-}
-android {
- compileSdkVersion 29
-
- def getVersionName = { ->
- def version
- if (System.getProperty('os.name').toLowerCase().contains('windows')) {
- version = ["cmd", "/c", "git describe --tags --long"].execute().in.text.trim()
- } else {
- version = ["sh", "-c", "git describe --tags --long"].execute().in.text.trim()
- }
- version = version.empty ? "2.1.0" : version
- return "${version}"
- }
-
- defaultConfig {
- applicationId "org.deviceconnect.android.deviceplugin.chromecast"
- minSdkVersion 14
- targetSdkVersion 29
- versionCode 1
- versionName getVersionName()
- }
-
- signingConfigs {
- releaseConfig {
- storeFile=file(project.properties.storeFile)
- storePassword=project.properties.storePassword
- keyAlias=project.properties.keyAlias
- keyPassword=project.properties.keyPassword
- }
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
- signingConfig signingConfigs.releaseConfig
- }
- }
-
- packagingOptions {
- exclude 'LICENSE.txt'
- exclude 'META-INF/DEPENDENCIES'
- exclude 'META-INF/LICENSE'
- exclude 'META-INF/NOTICE'
- }
- tasks.withType(JavaCompile) {
- options.encoding = 'UTF-8'
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- repositories {
- maven {
- name = "DeviceConnect-Android"
- url = uri("https://maven.pkg.github.com/DeviceConnect/DeviceConnect-Android")
-
- credentials {
- username = System.getenv("GPR_USER") ?: githubProperties['gpr.usr']
- password = System.getenv("GPR_API_KEY") ?: githubProperties['gpr.key']
- }
- }
- }
-}
-
-dependencies {
- implementation fileTree(include: '*.jar', dir: 'libs')
- implementation 'org.deviceconnect:dconnect-device-plugin-sdk:2.8.4'
- implementation 'com.google.android.gms:play-services-cast-framework:17.1.0'
-}
-
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/AndroidManifest.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/AndroidManifest.xml
deleted file mode 100755
index c74cc16567..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/fi/iki/elonen/NanoHTTPD.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/fi/iki/elonen/NanoHTTPD.java
deleted file mode 100755
index 56a03a1926..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/fi/iki/elonen/NanoHTTPD.java
+++ /dev/null
@@ -1,1435 +0,0 @@
-package fi.iki.elonen;
-
-import java.io.*;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.net.URLDecoder;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- * A simple, tiny, nicely embeddable HTTP server in Java
- *
- *
- * NanoHTTPD
- *
Copyright (c) 2012-2013 by Paul S. Hawke, 2001,2005-2013 by Jarno Elonen, 2010 by Konstantinos Togias
- *
- *
- * Features + limitations:
- *
- *
- * Only one Java file
- * Java 5 compatible
- * Released as open source, Modified BSD licence
- * No fixed config files, logging, authorization etc. (Implement yourself if you need them.)
- * Supports parameter parsing of GET and POST methods (+ rudimentary PUT support in 1.25)
- * Supports both dynamic content and file serving
- * Supports file upload (since version 1.2, 2010)
- * Supports partial content (streaming)
- * Supports ETags
- * Never caches anything
- * Doesn't limit bandwidth, request time or simultaneous connections
- * Default code serves files and shows all HTTP parameters and headers
- * File server supports directory listing, index.html and index.htm
- * File server supports partial content (streaming)
- * File server supports ETags
- * File server does the 301 redirection trick for directories without '/'
- * File server supports simple skipping for files (continue download)
- * File server serves also very long files without memory overhead
- * Contains a built-in list of most common mime types
- * All header names are converted lowercase so they don't vary between browsers/clients
- *
- *
- *
- *
- * How to use:
- *
- *
- * Subclass and implement serve() and embed to your own program
- *
- *
- *
- * See the separate "LICENSE.md" file for the distribution license (Modified BSD licence)
- */
-public abstract class NanoHTTPD {
- /**
- * Maximum time to wait on Socket.getInputStream().read() (in milliseconds)
- * This is required as the Keep-Alive HTTP connections would otherwise
- * block the socket reading thread forever (or as long the browser is open).
- */
- public static final int SOCKET_READ_TIMEOUT = 5000;
- /**
- * Common mime type for dynamic content: plain text
- */
- public static final String MIME_PLAINTEXT = "text/plain";
- /**
- * Common mime type for dynamic content: html
- */
- public static final String MIME_HTML = "text/html";
- /**
- * Pseudo-Parameter to use to store the actual query string in the parameters map for later re-processing.
- */
- private static final String QUERY_STRING_PARAMETER = "NanoHttpd.QUERY_STRING";
- private final String hostname;
- private final int myPort;
- private ServerSocket myServerSocket;
- private Set openConnections = new HashSet();
- private Thread myThread;
- /**
- * Pluggable strategy for asynchronously executing requests.
- */
- private AsyncRunner asyncRunner;
- /**
- * Pluggable strategy for creating and cleaning up temporary files.
- */
- private TempFileManagerFactory tempFileManagerFactory;
-
- /**
- * Constructs an HTTP server on given port.
- */
- public NanoHTTPD(int port) {
- this(null, port);
- }
-
- /**
- * Constructs an HTTP server on given hostname and port.
- */
- public NanoHTTPD(String hostname, int port) {
- this.hostname = hostname;
- this.myPort = port;
- setTempFileManagerFactory(new DefaultTempFileManagerFactory());
- setAsyncRunner(new DefaultAsyncRunner());
- }
-
- private static final void safeClose(Closeable closeable) {
- if (closeable != null) {
- try {
- closeable.close();
- } catch (IOException e) {
- }
- }
- }
-
- private static final void safeClose(Socket closeable) {
- if (closeable != null) {
- try {
- closeable.close();
- } catch (IOException e) {
- }
- }
- }
-
- private static final void safeClose(ServerSocket closeable) {
- if (closeable != null) {
- try {
- closeable.close();
- } catch (IOException e) {
- }
- }
- }
-
- /**
- * Start the server.
- *
- * @throws IOException if the socket is in use.
- */
- public void start() throws IOException {
- myServerSocket = new ServerSocket();
- myServerSocket.bind((hostname != null) ? new InetSocketAddress(hostname, myPort) : new InetSocketAddress(myPort));
-
- myThread = new Thread(new Runnable() {
- @Override
- public void run() {
- do {
- try {
- final Socket finalAccept = myServerSocket.accept();
- registerConnection(finalAccept);
- finalAccept.setSoTimeout(SOCKET_READ_TIMEOUT);
- final InputStream inputStream = finalAccept.getInputStream();
- asyncRunner.exec(new Runnable() {
- @Override
- public void run() {
- OutputStream outputStream = null;
- try {
- outputStream = finalAccept.getOutputStream();
- TempFileManager tempFileManager = tempFileManagerFactory.create();
- HTTPSession session = new HTTPSession(tempFileManager, inputStream, outputStream, finalAccept.getInetAddress());
- while (!finalAccept.isClosed()) {
- session.execute();
- }
- } catch (Exception e) {
- // When the socket is closed by the client, we throw our own SocketException
- // to break the "keep alive" loop above.
- if (!(e instanceof SocketException && "NanoHttpd Shutdown".equals(e.getMessage()))) {
- e.printStackTrace();
- }
- } finally {
- safeClose(outputStream);
- safeClose(inputStream);
- safeClose(finalAccept);
- unRegisterConnection(finalAccept);
- }
- }
- });
- } catch (IOException e) {
- }
- } while (!myServerSocket.isClosed());
- }
- });
- myThread.setDaemon(true);
- myThread.setName("NanoHttpd Main Listener");
- myThread.start();
- }
-
- /**
- * Stop the server.
- */
- public void stop() {
- try {
- safeClose(myServerSocket);
- closeAllConnections();
- if (myThread != null) {
- myThread.join();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Registers that a new connection has been set up.
- *
- * @param socket the {@link Socket} for the connection.
- */
- public synchronized void registerConnection(Socket socket) {
- openConnections.add(socket);
- }
-
- /**
- * Registers that a connection has been closed
- *
- * @param socket
- * the {@link Socket} for the connection.
- */
- public synchronized void unRegisterConnection(Socket socket) {
- openConnections.remove(socket);
- }
-
- /**
- * Forcibly closes all connections that are open.
- */
- public synchronized void closeAllConnections() {
- for (Socket socket : openConnections) {
- safeClose(socket);
- }
- }
-
- public final int getListeningPort() {
- return myServerSocket == null ? -1 : myServerSocket.getLocalPort();
- }
-
- public final boolean wasStarted() {
- return myServerSocket != null && myThread != null;
- }
-
- public final boolean isAlive() {
- return wasStarted() && !myServerSocket.isClosed() && myThread.isAlive();
- }
-
- /**
- * Override this to customize the server.
- *
- *
- * (By default, this delegates to serveFile() and allows directory listing.)
- *
- * @param uri Percent-decoded URI without parameters, for example "/index.cgi"
- * @param method "GET", "POST" etc.
- * @param parms Parsed, percent decoded parameters from URI and, in case of POST, data.
- * @param headers Header entries, percent decoded
- * @return HTTP response, see class Response for details
- */
- @Deprecated
- public Response serve(String uri, Method method, Map headers, Map parms,
- Map files) {
- return new Response(Response.Status.NOT_FOUND, MIME_PLAINTEXT, "Not Found");
- }
-
- /**
- * Override this to customize the server.
- *
- *
- * (By default, this delegates to serveFile() and allows directory listing.)
- *
- * @param session The HTTP session
- * @return HTTP response, see class Response for details
- */
- public Response serve(IHTTPSession session) {
- Map files = new HashMap();
- Method method = session.getMethod();
- if (Method.PUT.equals(method) || Method.POST.equals(method)) {
- try {
- session.parseBody(files);
- } catch (IOException ioe) {
- return new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage());
- } catch (ResponseException re) {
- return new Response(re.getStatus(), MIME_PLAINTEXT, re.getMessage());
- }
- }
-
- Map parms = session.getParms();
- parms.put(QUERY_STRING_PARAMETER, session.getQueryParameterString());
- return serve(session.getUri(), method, session.getHeaders(), parms, files);
- }
-
- /**
- * Decode percent encoded String values.
- *
- * @param str the percent encoded String
- * @return expanded form of the input, for example "foo%20bar" becomes "foo bar"
- */
- protected String decodePercent(String str) {
- String decoded = null;
- try {
- decoded = URLDecoder.decode(str, "UTF8");
- } catch (UnsupportedEncodingException ignored) {
- }
- return decoded;
- }
-
- /**
- * Decode parameters from a URL, handing the case where a single parameter name might have been
- * supplied several times, by return lists of values. In general these lists will contain a single
- * element.
- *
- * @param parms original NanoHttpd parameters values, as passed to the serve() method.
- * @return a map of String (parameter name) to List<String> (a list of the values supplied).
- */
- protected Map> decodeParameters(Map parms) {
- return this.decodeParameters(parms.get(QUERY_STRING_PARAMETER));
- }
-
- /**
- * Decode parameters from a URL, handing the case where a single parameter name might have been
- * supplied several times, by return lists of values. In general these lists will contain a single
- * element.
- *
- * @param queryString a query string pulled from the URL.
- * @return a map of String (parameter name) to List<String> (a list of the values supplied).
- */
- protected Map> decodeParameters(String queryString) {
- Map> parms = new HashMap>();
- if (queryString != null) {
- StringTokenizer st = new StringTokenizer(queryString, "&");
- while (st.hasMoreTokens()) {
- String e = st.nextToken();
- int sep = e.indexOf('=');
- String propertyName = (sep >= 0) ? decodePercent(e.substring(0, sep)).trim() : decodePercent(e).trim();
- if (!parms.containsKey(propertyName)) {
- parms.put(propertyName, new ArrayList());
- }
- String propertyValue = (sep >= 0) ? decodePercent(e.substring(sep + 1)) : null;
- if (propertyValue != null) {
- parms.get(propertyName).add(propertyValue);
- }
- }
- }
- return parms;
- }
-
- // ------------------------------------------------------------------------------- //
- //
- // Threading Strategy.
- //
- // ------------------------------------------------------------------------------- //
-
- /**
- * Pluggable strategy for asynchronously executing requests.
- *
- * @param asyncRunner new strategy for handling threads.
- */
- public void setAsyncRunner(AsyncRunner asyncRunner) {
- this.asyncRunner = asyncRunner;
- }
-
- // ------------------------------------------------------------------------------- //
- //
- // Temp file handling strategy.
- //
- // ------------------------------------------------------------------------------- //
-
- /**
- * Pluggable strategy for creating and cleaning up temporary files.
- *
- * @param tempFileManagerFactory new strategy for handling temp files.
- */
- public void setTempFileManagerFactory(TempFileManagerFactory tempFileManagerFactory) {
- this.tempFileManagerFactory = tempFileManagerFactory;
- }
-
- /**
- * HTTP Request methods, with the ability to decode a String back to its enum value.
- */
- public enum Method {
- GET, PUT, POST, DELETE, HEAD, OPTIONS;
-
- static Method lookup(String method) {
- for (Method m : Method.values()) {
- if (m.toString().equalsIgnoreCase(method)) {
- return m;
- }
- }
- return null;
- }
- }
-
- /**
- * Pluggable strategy for asynchronously executing requests.
- */
- public interface AsyncRunner {
- void exec(Runnable code);
- }
-
- /**
- * Factory to create temp file managers.
- */
- public interface TempFileManagerFactory {
- TempFileManager create();
- }
-
- // ------------------------------------------------------------------------------- //
-
- /**
- * Temp file manager.
- *
- * Temp file managers are created 1-to-1 with incoming requests, to create and cleanup
- * temporary files created as a result of handling the request.
- */
- public interface TempFileManager {
- TempFile createTempFile() throws Exception;
-
- void clear();
- }
-
- /**
- * A temp file.
- *
- * Temp files are responsible for managing the actual temporary storage and cleaning
- * themselves up when no longer needed.
- */
- public interface TempFile {
- OutputStream open() throws Exception;
-
- void delete() throws Exception;
-
- String getName();
- }
-
- /**
- * Default threading strategy for NanoHttpd.
- *
- * By default, the server spawns a new Thread for every incoming request. These are set
- * to daemon status, and named according to the request number. The name is
- * useful when profiling the application.
- */
- public static class DefaultAsyncRunner implements AsyncRunner {
- private long requestCount;
-
- @Override
- public void exec(Runnable code) {
- ++requestCount;
- Thread t = new Thread(code);
- t.setDaemon(true);
- t.setName("NanoHttpd Request Processor (#" + requestCount + ")");
- t.start();
- }
- }
-
- /**
- * Default strategy for creating and cleaning up temporary files.
- *
- *
This class stores its files in the standard location (that is,
- * wherever java.io.tmpdir points to). Files are added
- * to an internal list, and deleted when no longer needed (that is,
- * when clear() is invoked at the end of processing a
- * request).
- */
- public static class DefaultTempFileManager implements TempFileManager {
- private final String tmpdir;
- private final List tempFiles;
-
- public DefaultTempFileManager() {
- tmpdir = System.getProperty("java.io.tmpdir");
- tempFiles = new ArrayList();
- }
-
- @Override
- public TempFile createTempFile() throws Exception {
- DefaultTempFile tempFile = new DefaultTempFile(tmpdir);
- tempFiles.add(tempFile);
- return tempFile;
- }
-
- @Override
- public void clear() {
- for (TempFile file : tempFiles) {
- try {
- file.delete();
- } catch (Exception ignored) {
- }
- }
- tempFiles.clear();
- }
- }
-
- /**
- * Default strategy for creating and cleaning up temporary files.
- *
- *
[>By default, files are created by File.createTempFile() in
- * the directory specified.
- */
- public static class DefaultTempFile implements TempFile {
- private File file;
- private OutputStream fstream;
-
- public DefaultTempFile(String tempdir) throws IOException {
- file = File.createTempFile("NanoHTTPD-", "", new File(tempdir));
- fstream = new FileOutputStream(file);
- }
-
- @Override
- public OutputStream open() throws Exception {
- return fstream;
- }
-
- @Override
- public void delete() throws Exception {
- safeClose(fstream);
- file.delete();
- }
-
- @Override
- public String getName() {
- return file.getAbsolutePath();
- }
- }
-
- /**
- * HTTP response. Return one of these from serve().
- */
- public static class Response {
- /**
- * HTTP status code after processing, e.g. "200 OK", HTTP_OK
- */
- private IStatus status;
- /**
- * MIME type of content, e.g. "text/html"
- */
- private String mimeType;
- /**
- * Data of the response, may be null.
- */
- private InputStream data;
- /**
- * Headers for the HTTP response. Use addHeader() to add lines.
- */
- private Map header = new HashMap();
- /**
- * The request method that spawned this response.
- */
- private Method requestMethod;
- /**
- * Use chunkedTransfer
- */
- private boolean chunkedTransfer;
- /**
- * Content length.
- */
- private int contentLength = -1;
-
- /**
- * Default constructor: response = HTTP_OK, mime = MIME_HTML and your supplied message
- */
- public Response(String msg) {
- this(Status.OK, MIME_HTML, msg);
- }
-
- /**
- * Basic constructor.
- */
- public Response(IStatus status, String mimeType, InputStream data) {
- this.status = status;
- this.mimeType = mimeType;
- this.data = data;
- }
-
- /**
- * Convenience method that makes an InputStream out of given text.
- */
- public Response(IStatus status, String mimeType, String txt) {
- this.status = status;
- this.mimeType = mimeType;
- try {
- this.data = txt != null ? new ByteArrayInputStream(txt.getBytes("UTF-8")) : null;
- } catch (java.io.UnsupportedEncodingException uee) {
- uee.printStackTrace();
- }
- }
-
- /**
- * Adds given line to the header.
- */
- public void addHeader(String name, String value) {
- header.put(name, value);
- }
-
- public String getHeader(String name) {
- return header.get(name);
- }
-
- public void setContentLength(final int length) {
- this.contentLength = length;
- }
-
- private int getContentLength() throws IOException {
- if (contentLength < 0) {
- return this.data.available();
- }
- return contentLength;
- }
-
- /**
- * Sends given response to the socket.
- */
- protected void send(OutputStream outputStream) {
- String mime = mimeType;
- SimpleDateFormat gmtFrmt = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss 'GMT'", Locale.US);
- gmtFrmt.setTimeZone(TimeZone.getTimeZone("GMT"));
-
- try {
- if (status == null) {
- throw new Error("sendResponse(): Status can't be null.");
- }
- PrintWriter pw = new PrintWriter(outputStream);
- pw.print("HTTP/1.1 " + status.getDescription() + " \r\n");
-
- if (mime != null) {
- pw.print("Content-Type: " + mime + "\r\n");
- }
-
- if (header == null || header.get("Date") == null) {
- pw.print("Date: " + gmtFrmt.format(new Date()) + "\r\n");
- }
-
- if (header != null) {
- for (String key : header.keySet()) {
- String value = header.get(key);
- pw.print(key + ": " + value + "\r\n");
- }
- }
-
- sendConnectionHeaderIfNotAlreadyPresent(pw, header);
-
- if (requestMethod != Method.HEAD && chunkedTransfer) {
- sendAsChunked(outputStream, pw);
- } else {
- int pending = data != null ? getContentLength() : 0;
- sendContentLengthHeaderIfNotAlreadyPresent(pw, header, pending);
- pw.print("\r\n");
- pw.flush();
- sendAsFixedLength(outputStream, pending);
- }
- outputStream.flush();
- safeClose(data);
- } catch (IOException ioe) {
- // Couldn't write? No can do.
- }
- }
-
- protected void sendContentLengthHeaderIfNotAlreadyPresent(PrintWriter pw, Map header, int size) {
- if (!headerAlreadySent(header, "content-length")) {
- pw.print("Content-Length: "+ size +"\r\n");
- }
- }
-
- protected void sendConnectionHeaderIfNotAlreadyPresent(PrintWriter pw, Map header) {
- if (!headerAlreadySent(header, "connection")) {
- pw.print("Connection: keep-alive\r\n");
- }
- }
-
- private boolean headerAlreadySent(Map header, String name) {
- boolean alreadySent = false;
- for (String headerName : header.keySet()) {
- alreadySent |= headerName.equalsIgnoreCase(name);
- }
- return alreadySent;
- }
-
- private void sendAsChunked(OutputStream outputStream, PrintWriter pw) throws IOException {
- pw.print("Transfer-Encoding: chunked\r\n");
- pw.print("\r\n");
- pw.flush();
- int BUFFER_SIZE = 16 * 1024;
- byte[] CRLF = "\r\n".getBytes();
- byte[] buff = new byte[BUFFER_SIZE];
- int read;
- while ((read = data.read(buff)) > 0) {
- outputStream.write(String.format("%x\r\n", read).getBytes());
- outputStream.write(buff, 0, read);
- outputStream.write(CRLF);
- }
- outputStream.write(String.format("0\r\n\r\n").getBytes());
- }
-
- private void sendAsFixedLength(OutputStream outputStream, int pending) throws IOException {
- if (requestMethod != Method.HEAD && data != null) {
- int BUFFER_SIZE = 16 * 1024;
- byte[] buff = new byte[BUFFER_SIZE];
- while (pending > 0) {
- int read = data.read(buff, 0, ((pending > BUFFER_SIZE) ? BUFFER_SIZE : pending));
- if (read <= 0) {
- break;
- }
- outputStream.write(buff, 0, read);
- pending -= read;
- }
- }
- }
-
- public IStatus getStatus() {
- return status;
- }
-
- public void setStatus(Status status) {
- this.status = status;
- }
-
- public String getMimeType() {
- return mimeType;
- }
-
- public void setMimeType(String mimeType) {
- this.mimeType = mimeType;
- }
-
- public InputStream getData() {
- return data;
- }
-
- public void setData(InputStream data) {
- this.data = data;
- }
-
- public Method getRequestMethod() {
- return requestMethod;
- }
-
- public void setRequestMethod(Method requestMethod) {
- this.requestMethod = requestMethod;
- }
-
- public void setChunkedTransfer(boolean chunkedTransfer) {
- this.chunkedTransfer = chunkedTransfer;
- }
-
- public interface IStatus {
- int getRequestStatus();
- String getDescription();
- }
-
- /**
- * Some HTTP response status codes
- */
- public enum Status implements IStatus {
- SWITCH_PROTOCOL(101, "Switching Protocols"), OK(200, "OK"), CREATED(201, "Created"), ACCEPTED(202, "Accepted"), NO_CONTENT(204, "No Content"), PARTIAL_CONTENT(206, "Partial Content"), REDIRECT(301,
- "Moved Permanently"), NOT_MODIFIED(304, "Not Modified"), BAD_REQUEST(400, "Bad Request"), UNAUTHORIZED(401,
- "Unauthorized"), FORBIDDEN(403, "Forbidden"), NOT_FOUND(404, "Not Found"), METHOD_NOT_ALLOWED(405, "Method Not Allowed"), RANGE_NOT_SATISFIABLE(416,
- "Requested Range Not Satisfiable"), INTERNAL_ERROR(500, "Internal Server Error");
- private final int requestStatus;
- private final String description;
-
- Status(int requestStatus, String description) {
- this.requestStatus = requestStatus;
- this.description = description;
- }
-
- @Override
- public int getRequestStatus() {
- return this.requestStatus;
- }
-
- @Override
- public String getDescription() {
- return "" + this.requestStatus + " " + description;
- }
- }
- }
-
- public static final class ResponseException extends Exception {
-
- private final Response.Status status;
-
- public ResponseException(Response.Status status, String message) {
- super(message);
- this.status = status;
- }
-
- public ResponseException(Response.Status status, String message, Exception e) {
- super(message, e);
- this.status = status;
- }
-
- public Response.Status getStatus() {
- return status;
- }
- }
-
- /**
- * Default strategy for creating and cleaning up temporary files.
- */
- private class DefaultTempFileManagerFactory implements TempFileManagerFactory {
- @Override
- public TempFileManager create() {
- return new DefaultTempFileManager();
- }
- }
-
- /**
- * Handles one session, i.e. parses the HTTP request and returns the response.
- */
- public interface IHTTPSession {
- void execute() throws IOException;
-
- Map getParms();
-
- Map getHeaders();
-
- /**
- * @return the path part of the URL.
- */
- String getUri();
-
- String getQueryParameterString();
-
- Method getMethod();
-
- InputStream getInputStream();
-
- CookieHandler getCookies();
-
- /**
- * Adds the files in the request body to the files map.
- * @arg files - map to modify
- */
- void parseBody(Map files) throws IOException, ResponseException;
- }
-
- protected class HTTPSession implements IHTTPSession {
- public static final int BUFSIZE = 8192;
- private final TempFileManager tempFileManager;
- private final OutputStream outputStream;
- private PushbackInputStream inputStream;
- private int splitbyte;
- private int rlen;
- private String uri;
- private Method method;
- private Map parms;
- private Map headers;
- private CookieHandler cookies;
- private String queryParameterString;
-
- public HTTPSession(TempFileManager tempFileManager, InputStream inputStream, OutputStream outputStream) {
- this.tempFileManager = tempFileManager;
- this.inputStream = new PushbackInputStream(inputStream, BUFSIZE);
- this.outputStream = outputStream;
- }
-
- public HTTPSession(TempFileManager tempFileManager, InputStream inputStream, OutputStream outputStream, InetAddress inetAddress) {
- this.tempFileManager = tempFileManager;
- this.inputStream = new PushbackInputStream(inputStream, BUFSIZE);
- this.outputStream = outputStream;
- String remoteIp = inetAddress.isLoopbackAddress() || inetAddress.isAnyLocalAddress() ? "127.0.0.1" : inetAddress.getHostAddress().toString();
- headers = new HashMap();
-
- headers.put("remote-addr", remoteIp);
- headers.put("http-client-ip", remoteIp);
- }
-
- @Override
- public void execute() throws IOException {
- try {
- // Read the first 8192 bytes.
- // The full header should fit in here.
- // Apache's default header limit is 8KB.
- // Do NOT assume that a single read will get the entire header at once!
- byte[] buf = new byte[BUFSIZE];
- splitbyte = 0;
- rlen = 0;
- {
- int read = -1;
- try {
- read = inputStream.read(buf, 0, BUFSIZE);
- } catch (Exception e) {
- safeClose(inputStream);
- safeClose(outputStream);
- throw new SocketException("NanoHttpd Shutdown");
- }
- if (read == -1) {
- // socket was been closed
- safeClose(inputStream);
- safeClose(outputStream);
- throw new SocketException("NanoHttpd Shutdown");
- }
- while (read > 0) {
- rlen += read;
- splitbyte = findHeaderEnd(buf, rlen);
- if (splitbyte > 0)
- break;
- read = inputStream.read(buf, rlen, BUFSIZE - rlen);
- }
- }
-
- if (splitbyte < rlen) {
- inputStream.unread(buf, splitbyte, rlen - splitbyte);
- }
-
- parms = new HashMap();
- if(null == headers) {
- headers = new HashMap();
- }
-
- // Create a BufferedReader for parsing the header.
- BufferedReader hin = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(buf, 0, rlen)));
-
- // Decode the header into parms and header java properties
- Map pre = new HashMap();
- decodeHeader(hin, pre, parms, headers);
-
- method = Method.lookup(pre.get("method"));
- if (method == null) {
- throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Syntax error.");
- }
-
- uri = pre.get("uri");
-
- cookies = new CookieHandler(headers);
-
- // Ok, now do the serve()
- Response r = serve(this);
- if (r == null) {
- throw new ResponseException(Response.Status.INTERNAL_ERROR, "SERVER INTERNAL ERROR: Serve() returned a null response.");
- } else {
- cookies.unloadQueue(r);
- r.setRequestMethod(method);
- r.send(outputStream);
- }
- } catch (SocketException e) {
- // throw it out to close socket object (finalAccept)
- throw e;
- } catch (SocketTimeoutException ste) {
- throw ste;
- } catch (IOException ioe) {
- Response r = new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage());
- r.send(outputStream);
- safeClose(outputStream);
- } catch (ResponseException re) {
- Response r = new Response(re.getStatus(), MIME_PLAINTEXT, re.getMessage());
- r.send(outputStream);
- safeClose(outputStream);
- } finally {
- tempFileManager.clear();
- }
- }
-
- @Override
- public void parseBody(Map files) throws IOException, ResponseException {
- RandomAccessFile randomAccessFile = null;
- BufferedReader in = null;
- try {
-
- randomAccessFile = getTmpBucket();
-
- long size;
- if (headers.containsKey("content-length")) {
- size = Integer.parseInt(headers.get("content-length"));
- } else if (splitbyte < rlen) {
- size = rlen - splitbyte;
- } else {
- size = 0;
- }
-
- // Now read all the body and write it to f
- byte[] buf = new byte[512];
- while (rlen >= 0 && size > 0) {
- rlen = inputStream.read(buf, 0, (int)Math.min(size, 512));
- size -= rlen;
- if (rlen > 0) {
- randomAccessFile.write(buf, 0, rlen);
- }
- }
-
- // Get the raw body as a byte []
- ByteBuffer fbuf = randomAccessFile.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, randomAccessFile.length());
- randomAccessFile.seek(0);
-
- // Create a BufferedReader for easily reading it as string.
- InputStream bin = new FileInputStream(randomAccessFile.getFD());
- in = new BufferedReader(new InputStreamReader(bin));
-
- // If the method is POST, there may be parameters
- // in data section, too, read it:
- if (Method.POST.equals(method)) {
- String contentType = "";
- String contentTypeHeader = headers.get("content-type");
-
- StringTokenizer st = null;
- if (contentTypeHeader != null) {
- st = new StringTokenizer(contentTypeHeader, ",; ");
- if (st.hasMoreTokens()) {
- contentType = st.nextToken();
- }
- }
-
- if ("multipart/form-data".equalsIgnoreCase(contentType)) {
- // Handle multipart/form-data
- if (!st.hasMoreTokens()) {
- throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Content type is multipart/form-data but boundary missing. Usage: GET /example/file.html");
- }
-
- String boundaryStartString = "boundary=";
- int boundaryContentStart = contentTypeHeader.indexOf(boundaryStartString) + boundaryStartString.length();
- String boundary = contentTypeHeader.substring(boundaryContentStart, contentTypeHeader.length());
- if (boundary.startsWith("\"") && boundary.endsWith("\"")) {
- boundary = boundary.substring(1, boundary.length() - 1);
- }
-
- decodeMultipartData(boundary, fbuf, in, parms, files);
- } else {
- String postLine = "";
- StringBuilder postLineBuffer = new StringBuilder();
- char pbuf[] = new char[512];
- int read = in.read(pbuf);
- while (read >= 0 && !postLine.endsWith("\r\n")) {
- postLine = String.valueOf(pbuf, 0, read);
- postLineBuffer.append(postLine);
- read = in.read(pbuf);
- }
- postLine = postLineBuffer.toString().trim();
- // Handle application/x-www-form-urlencoded
- if ("application/x-www-form-urlencoded".equalsIgnoreCase(contentType)) {
- decodeParms(postLine, parms);
- } else if (postLine.length() != 0) {
- // Special case for raw POST data => create a special files entry "postData" with raw content data
- files.put("postData", postLine);
- }
- }
- } else if (Method.PUT.equals(method)) {
- files.put("content", saveTmpFile(fbuf, 0, fbuf.limit()));
- }
- } finally {
- safeClose(randomAccessFile);
- safeClose(in);
- }
- }
-
- /**
- * Decodes the sent headers and loads the data into Key/value pairs
- */
- private void decodeHeader(BufferedReader in, Map pre, Map parms, Map headers)
- throws ResponseException {
- try {
- // Read the request line
- String inLine = in.readLine();
- if (inLine == null) {
- return;
- }
-
- StringTokenizer st = new StringTokenizer(inLine);
- if (!st.hasMoreTokens()) {
- throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Syntax error. Usage: GET /example/file.html");
- }
-
- pre.put("method", st.nextToken());
-
- if (!st.hasMoreTokens()) {
- throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Missing URI. Usage: GET /example/file.html");
- }
-
- String uri = st.nextToken();
-
- // Decode parameters from the URI
- int qmi = uri.indexOf('?');
- if (qmi >= 0) {
- decodeParms(uri.substring(qmi + 1), parms);
- uri = decodePercent(uri.substring(0, qmi));
- } else {
- uri = decodePercent(uri);
- }
-
- // If there's another token, it's protocol version,
- // followed by HTTP headers. Ignore version but parse headers.
- // NOTE: this now forces header names lowercase since they are
- // case insensitive and vary by client.
- if (st.hasMoreTokens()) {
- String line = in.readLine();
- while (line != null && line.trim().length() > 0) {
- int p = line.indexOf(':');
- if (p >= 0)
- headers.put(line.substring(0, p).trim().toLowerCase(Locale.US), line.substring(p + 1).trim());
- line = in.readLine();
- }
- }
-
- pre.put("uri", uri);
- } catch (IOException ioe) {
- throw new ResponseException(Response.Status.INTERNAL_ERROR, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage(), ioe);
- }
- }
-
- /**
- * Decodes the Multipart Body data and put it into Key/Value pairs.
- */
- private void decodeMultipartData(String boundary, ByteBuffer fbuf, BufferedReader in, Map parms,
- Map files) throws ResponseException {
- try {
- int[] bpositions = getBoundaryPositions(fbuf, boundary.getBytes());
- int boundarycount = 1;
- String mpline = in.readLine();
- while (mpline != null) {
- if (!mpline.contains(boundary)) {
- throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Content type is multipart/form-data but next chunk does not start with boundary. Usage: GET /example/file.html");
- }
- boundarycount++;
- Map item = new HashMap();
- mpline = in.readLine();
- while (mpline != null && mpline.trim().length() > 0) {
- int p = mpline.indexOf(':');
- if (p != -1) {
- item.put(mpline.substring(0, p).trim().toLowerCase(Locale.US), mpline.substring(p + 1).trim());
- }
- mpline = in.readLine();
- }
- if (mpline != null) {
- String contentDisposition = item.get("content-disposition");
- if (contentDisposition == null) {
- throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Content type is multipart/form-data but no content-disposition info found. Usage: GET /example/file.html");
- }
- StringTokenizer st = new StringTokenizer(contentDisposition, ";");
- Map disposition = new HashMap();
- while (st.hasMoreTokens()) {
- String token = st.nextToken().trim();
- int p = token.indexOf('=');
- if (p != -1) {
- disposition.put(token.substring(0, p).trim().toLowerCase(Locale.US), token.substring(p + 1).trim());
- }
- }
- String pname = disposition.get("name");
- pname = pname.substring(1, pname.length() - 1);
-
- String value = "";
- if (item.get("content-type") == null) {
- while (mpline != null && !mpline.contains(boundary)) {
- mpline = in.readLine();
- if (mpline != null) {
- int d = mpline.indexOf(boundary);
- if (d == -1) {
- value += mpline;
- } else {
- value += mpline.substring(0, d - 2);
- }
- }
- }
- } else {
- if (boundarycount > bpositions.length) {
- throw new ResponseException(Response.Status.INTERNAL_ERROR, "Error processing request");
- }
- int offset = stripMultipartHeaders(fbuf, bpositions[boundarycount - 2]);
- String path = saveTmpFile(fbuf, offset, bpositions[boundarycount - 1] - offset - 4);
- files.put(pname, path);
- value = disposition.get("filename");
- value = value.substring(1, value.length() - 1);
- do {
- mpline = in.readLine();
- } while (mpline != null && !mpline.contains(boundary));
- }
- parms.put(pname, value);
- }
- }
- } catch (IOException ioe) {
- throw new ResponseException(Response.Status.INTERNAL_ERROR, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage(), ioe);
- }
- }
-
- /**
- * Find byte index separating header from body. It must be the last byte of the first two sequential new lines.
- */
- private int findHeaderEnd(final byte[] buf, int rlen) {
- int splitbyte = 0;
- while (splitbyte + 3 < rlen) {
- if (buf[splitbyte] == '\r' && buf[splitbyte + 1] == '\n' && buf[splitbyte + 2] == '\r' && buf[splitbyte + 3] == '\n') {
- return splitbyte + 4;
- }
- splitbyte++;
- }
- return 0;
- }
-
- /**
- * Find the byte positions where multipart boundaries start.
- */
- private int[] getBoundaryPositions(ByteBuffer b, byte[] boundary) {
- int matchcount = 0;
- int matchbyte = -1;
- List matchbytes = new ArrayList();
- for (int i = 0; i < b.limit(); i++) {
- if (b.get(i) == boundary[matchcount]) {
- if (matchcount == 0)
- matchbyte = i;
- matchcount++;
- if (matchcount == boundary.length) {
- matchbytes.add(matchbyte);
- matchcount = 0;
- matchbyte = -1;
- }
- } else {
- i -= matchcount;
- matchcount = 0;
- matchbyte = -1;
- }
- }
- int[] ret = new int[matchbytes.size()];
- for (int i = 0; i < ret.length; i++) {
- ret[i] = matchbytes.get(i);
- }
- return ret;
- }
-
- /**
- * Retrieves the content of a sent file and saves it to a temporary file. The full path to the saved file is returned.
- */
- private String saveTmpFile(ByteBuffer b, int offset, int len) {
- String path = "";
- if (len > 0) {
- FileOutputStream fileOutputStream = null;
- try {
- TempFile tempFile = tempFileManager.createTempFile();
- ByteBuffer src = b.duplicate();
- fileOutputStream = new FileOutputStream(tempFile.getName());
- FileChannel dest = fileOutputStream.getChannel();
- src.position(offset).limit(offset + len);
- dest.write(src.slice());
- path = tempFile.getName();
- } catch (Exception e) { // Catch exception if any
- throw new Error(e); // we won't recover, so throw an error
- } finally {
- safeClose(fileOutputStream);
- }
- }
- return path;
- }
-
- private RandomAccessFile getTmpBucket() {
- try {
- TempFile tempFile = tempFileManager.createTempFile();
- return new RandomAccessFile(tempFile.getName(), "rw");
- } catch (Exception e) {
- throw new Error(e); // we won't recover, so throw an error
- }
- }
-
- /**
- * It returns the offset separating multipart file headers from the file's data.
- */
- private int stripMultipartHeaders(ByteBuffer b, int offset) {
- int i;
- for (i = offset; i < b.limit(); i++) {
- if (b.get(i) == '\r' && b.get(++i) == '\n' && b.get(++i) == '\r' && b.get(++i) == '\n') {
- break;
- }
- }
- return i + 1;
- }
-
- /**
- * Decodes parameters in percent-encoded URI-format ( e.g. "name=Jack%20Daniels&pass=Single%20Malt" ) and
- * adds them to given Map. NOTE: this doesn't support multiple identical keys due to the simplicity of Map.
- */
- private void decodeParms(String parms, Map p) {
- if (parms == null) {
- queryParameterString = "";
- return;
- }
-
- queryParameterString = parms;
- StringTokenizer st = new StringTokenizer(parms, "&");
- while (st.hasMoreTokens()) {
- String e = st.nextToken();
- int sep = e.indexOf('=');
- if (sep >= 0) {
- p.put(decodePercent(e.substring(0, sep)).trim(),
- decodePercent(e.substring(sep + 1)));
- } else {
- p.put(decodePercent(e).trim(), "");
- }
- }
- }
-
- @Override
- public final Map getParms() {
- return parms;
- }
-
- public String getQueryParameterString() {
- return queryParameterString;
- }
-
- @Override
- public final Map getHeaders() {
- return headers;
- }
-
- @Override
- public final String getUri() {
- return uri;
- }
-
- @Override
- public final Method getMethod() {
- return method;
- }
-
- @Override
- public final InputStream getInputStream() {
- return inputStream;
- }
-
- @Override
- public CookieHandler getCookies() {
- return cookies;
- }
- }
-
- public static class Cookie {
- private String n, v, e;
-
- public Cookie(String name, String value, String expires) {
- n = name;
- v = value;
- e = expires;
- }
-
- public Cookie(String name, String value) {
- this(name, value, 30);
- }
-
- public Cookie(String name, String value, int numDays) {
- n = name;
- v = value;
- e = getHTTPTime(numDays);
- }
-
- public String getHTTPHeader() {
- String fmt = "%s=%s; expires=%s";
- return String.format(fmt, n, v, e);
- }
-
- public static String getHTTPTime(int days) {
- Calendar calendar = Calendar.getInstance();
- SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
- dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
- calendar.add(Calendar.DAY_OF_MONTH, days);
- return dateFormat.format(calendar.getTime());
- }
- }
-
- /**
- * Provides rudimentary support for cookies.
- * Doesn't support 'path', 'secure' nor 'httpOnly'.
- * Feel free to improve it and/or add unsupported features.
- *
- * @author LordFokas
- */
- public class CookieHandler implements Iterable {
- private HashMap cookies = new HashMap();
- private ArrayList queue = new ArrayList();
-
- public CookieHandler(Map httpHeaders) {
- String raw = httpHeaders.get("cookie");
- if (raw != null) {
- String[] tokens = raw.split(";");
- for (String token : tokens) {
- String[] data = token.trim().split("=");
- if (data.length == 2) {
- cookies.put(data[0], data[1]);
- }
- }
- }
- }
-
- @Override public Iterator iterator() {
- return cookies.keySet().iterator();
- }
-
- /**
- * Read a cookie from the HTTP Headers.
- *
- * @param name The cookie's name.
- * @return The cookie's value if it exists, null otherwise.
- */
- public String read(String name) {
- return cookies.get(name);
- }
-
- /**
- * Sets a cookie.
- *
- * @param name The cookie's name.
- * @param value The cookie's value.
- * @param expires How many days until the cookie expires.
- */
- public void set(String name, String value, int expires) {
- queue.add(new Cookie(name, value, Cookie.getHTTPTime(expires)));
- }
-
- public void set(Cookie cookie) {
- queue.add(cookie);
- }
-
- /**
- * Set a cookie with an expiration date from a month ago, effectively deleting it on the client side.
- *
- * @param name The cookie name.
- */
- public void delete(String name) {
- set(name, "-delete-", -30);
- }
-
- /**
- * Internally used by the webserver to add all queued cookies into the Response's HTTP Headers.
- *
- * @param response The Response object to which headers the queued cookies will be added.
- */
- public void unloadQueue(Response response) {
- for (Cookie cookie : queue) {
- response.addHeader("Set-Cookie", cookie.getHTTPHeader());
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/CastOptionsProvider.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/CastOptionsProvider.java
deleted file mode 100755
index 86388332d4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/CastOptionsProvider.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.deviceconnect.android.deviceplugin.chromecast;
-
-import android.content.Context;
-
-import com.google.android.gms.cast.MediaMetadata;
-import com.google.android.gms.cast.framework.CastOptions;
-import com.google.android.gms.cast.framework.OptionsProvider;
-import com.google.android.gms.cast.framework.SessionProvider;
-import com.google.android.gms.cast.framework.media.ImagePicker;
-import com.google.android.gms.common.images.WebImage;
-
-import java.util.List;
-
-/**
- * Implements {@link OptionsProvider} to provide {@link CastOptions}.
- */
-public class CastOptionsProvider implements OptionsProvider {
-
- @Override
- public CastOptions getCastOptions(Context context) {
- return new CastOptions.Builder()
- .setReceiverApplicationId(context.getString(R.string.application_id))
- .build();
- }
-
- @Override
- public List getAdditionalSessionProviders(Context appContext) {
- return null;
- }
-
- private static class ImagePickerImpl extends ImagePicker {
-
- @Override
- public WebImage onPickImage(MediaMetadata mediaMetadata, int type) {
- if ((mediaMetadata == null) || !mediaMetadata.hasImages()) {
- return null;
- }
- List images = mediaMetadata.getImages();
- if (images.size() == 1) {
- return images.get(0);
- } else {
- if (type == ImagePicker.IMAGE_TYPE_MEDIA_ROUTE_CONTROLLER_DIALOG_BACKGROUND) {
- return images.get(0);
- } else {
- return images.get(1);
- }
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/ChromeCastApplication.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/ChromeCastApplication.java
deleted file mode 100644
index a66dee7148..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/ChromeCastApplication.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.deviceconnect.android.deviceplugin.chromecast;
-
-import android.app.Application;
-
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastController;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastDiscovery;
-
-/**
- * ChromeCas Applicationクラス.
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastApplication extends Application {
- /** Chromecast Discovery. */
- private ChromeCastDiscovery mDiscovery;
- /** Chromecast Application. */
- private ChromeCastController mController;
-
- public void initialize() {
- String appId = getString(R.string.application_id);
-
- if (mDiscovery == null) {
- mDiscovery = new ChromeCastDiscovery(this);
-
- }
- if (mController == null) {
- mController = new ChromeCastController(this, appId);
- }
- }
-
- @Override
- public void onTerminate() {
- super.onTerminate();
- if (mController != null) {
- mController.teardown();
- }
- }
-
- /**
- * ChromeCastを制御するクラスを返す.
- * @return
- */
- public ChromeCastController getController() {
- return mController;
- }
-
- /**
- * ChromeCastを探索するクラスを返す.
- * @return
- */
- public ChromeCastDiscovery getDiscovery() {
- return mDiscovery;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/ChromeCastDeviceService.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/ChromeCastDeviceService.java
deleted file mode 100644
index 81a3e43d96..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/ChromeCastDeviceService.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.deviceconnect.android.deviceplugin.chromecast;
-
-import com.google.android.gms.cast.CastDevice;
-
-import org.deviceconnect.android.deviceplugin.chromecast.profile.ChromeCastCanvasProfile;
-import org.deviceconnect.android.deviceplugin.chromecast.profile.ChromeCastMediaPlayerProfile;
-import org.deviceconnect.android.deviceplugin.chromecast.profile.ChromeCastNotificationProfile;
-import org.deviceconnect.android.service.DConnectService;
-import org.deviceconnect.profile.ServiceDiscoveryProfileConstants;
-
-/**
- * Chromecast device service.
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastDeviceService extends DConnectService {
-
- private ChromeCastMediaPlayerProfile mMediaPlayerProfile;
-
- public ChromeCastDeviceService(final CastDevice cast) {
- super(cast.getDeviceId());
- setName(getDeviceName(cast.getFriendlyName()));
- setNetworkType(ServiceDiscoveryProfileConstants.NetworkType.WIFI);
- mMediaPlayerProfile = new ChromeCastMediaPlayerProfile();
- addProfile(new ChromeCastCanvasProfile());
- addProfile(new ChromeCastNotificationProfile());
- addProfile(mMediaPlayerProfile);
- }
-
- public ChromeCastMediaPlayerProfile getMediaPlayerProfile() {
- return mMediaPlayerProfile;
- }
- private String getDeviceName(final String name) {
- return String.format("Chromecast (%1$s)", name);
- }
-
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/ChromeCastProvider.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/ChromeCastProvider.java
deleted file mode 100755
index 92c7d35529..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/ChromeCastProvider.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- ChromeCastProvider.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast;
-
-import android.app.Service;
-
-import org.deviceconnect.android.message.DConnectMessageServiceProvider;
-
-/**
- * サービスプロバイダー (Chromecast).
- *
- * リクエストメッセージを受信し、レスポンスメッセージを送信するサービス
- *
- *
- * @param Service
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastProvider extends DConnectMessageServiceProvider {
-
- @SuppressWarnings("unchecked")
- @Override
- protected Class getServiceClass() {
- Class extends Service> clazz = ChromeCastService.class;
- return (Class) clazz;
- }
-
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/ChromeCastService.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/ChromeCastService.java
deleted file mode 100755
index 15ed772246..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/ChromeCastService.java
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
- ChromeCastService.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast;
-
-import android.content.BroadcastReceiver;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-
-import com.google.android.gms.cast.Cast;
-import com.google.android.gms.cast.CastDevice;
-import com.google.android.gms.cast.MediaInfo;
-import com.google.android.gms.cast.MediaStatus;
-import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult;
-import com.google.android.gms.common.api.GoogleApiClient;
-import com.google.android.gms.common.api.Status;
-
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastController;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastDiscovery;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastHttpServer;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastMediaPlayer;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastMessage;
-import org.deviceconnect.android.deviceplugin.chromecast.profile.ChromeCastServiceDiscoveryProfile;
-import org.deviceconnect.android.deviceplugin.chromecast.profile.ChromeCastSystemProfile;
-import org.deviceconnect.android.event.Event;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.event.cache.db.DBCacheController;
-import org.deviceconnect.android.message.DConnectMessageService;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.MediaPlayerProfile;
-import org.deviceconnect.android.profile.SystemProfile;
-import org.deviceconnect.android.service.DConnectService;
-import org.deviceconnect.android.service.DConnectServiceListener;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * メッセージサービス (Chromecast).
- *
- * Chromecastデバイスプラグインのサービス
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastService extends DConnectMessageService implements
- ChromeCastMediaPlayer.Callbacks,
- ChromeCastMessage.Callbacks,
- ChromeCastDiscovery.Callbacks,
- ChromeCastController.Result,
- DConnectServiceListener {
-
- /**
- * Chromecastのサーバポート.
- */
- private static final int SERVER_PORT = 38088;
-
- /** Chromecast MediaPlayer. */
- private ChromeCastMediaPlayer mMediaPlayer;
- /** Chromecast Message. */
- private ChromeCastMessage mMessage;
- /** ChromecastHttpServer. */
- private ChromeCastHttpServer mServer;
- /** StatusChange時のServiceId. */
- private String mServiceIdOnStatusChange = null;
- /** MediaPlayerのステータスアップデートフラグ. */
- private boolean mEnableCastMediaPlayerStatusUpdate = false;
- /**
- * ChromeCastが接続完了してからレスポンスを返すためのCallbackを返す.
- * @author NTT DOCOMO, INC.
- */
- public interface Callback {
- /**
- * レスポンス.
- * @param connected true : 接続されている, false : 接続されていない
- */
- void onResponse(final boolean connected);
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
- ChromeCastApplication app = (ChromeCastApplication) getApplication();
- app.initialize();
- app.getDiscovery().setCallbacks(this);
- app.getController().setResult(this);
- String appMsgUrn = getString(R.string.application_message_urn);
-
- int portCount = 0;
- while (portCount < 500) { // Portを決定する
- try {
- mServer = new ChromeCastHttpServer(this, "0.0.0.0", SERVER_PORT + portCount);
- mServer.start();
- break;
- } catch (IOException e) {
- portCount++;
- }
- }
-
- mMediaPlayer = new ChromeCastMediaPlayer(app.getController());
- mMediaPlayer.setCallbacks(this);
- mMessage = new ChromeCastMessage(app.getController(), appMsgUrn);
- mMessage.setCallbacks(this);
-
- EventManager.INSTANCE.setController(new DBCacheController(this));
- addProfile(new ChromeCastServiceDiscoveryProfile(getServiceProvider()));
-
- }
-
- @Override
- public void onDestroy() {
- mServer.stop();
-
- super.onDestroy();
- }
-
- @Override
- protected SystemProfile getSystemProfile() {
- return new ChromeCastSystemProfile();
- }
-
- @Override
- public void onServiceAdded(final DConnectService service) {
- if (BuildConfig.DEBUG) {
- Log.i("TEST", "onServiceAdded: " + service.getName());
- }
- // NOP.
- }
-
- @Override
- public void onServiceRemoved(final DConnectService service) {
- if (BuildConfig.DEBUG) {
- Log.i("TEST", "onServiceRemoved: " + service.getName());
- }
- ChromeCastApplication app = (ChromeCastApplication) getApplication();
- if (app != null) {
- app.getController().teardown();
- }
- }
-
- @Override
- public void onStatusChange(final DConnectService service) {
- if (BuildConfig.DEBUG) {
- Log.i("TEST", "onStatusChange: " + service.getName());
- }
- // NOP.
- }
-
- @Override
- protected void onManagerUninstalled() {
- // Managerアンインストール検知時の処理。
- if (BuildConfig.DEBUG) {
- Log.i("TEST", "Plug-in : onManagerUninstalled");
- }
- ChromeCastApplication app = (ChromeCastApplication) getApplication();
- if (app != null) {
- app.getController().teardown();
- }
- }
-
- @Override
- protected void onManagerTerminated() {
- // Manager正常終了通知受信時の処理。
- if (BuildConfig.DEBUG) {
- Log.i("TEST", "Plug-in : onManagerTerminated");
- }
- }
-
- @Override
- protected void onManagerEventTransmitDisconnected(String sessionKey) {
- // ManagerのEvent送信経路切断通知受信時の処理。
- if (BuildConfig.DEBUG) {
- Log.i("TEST", "Plug-in : onManagerEventTransmitDisconnected");
- }
- if (sessionKey != null) {
- EventManager.INSTANCE.removeEvents(sessionKey);
- } else {
- EventManager.INSTANCE.removeAll();
- }
-
- }
-
- @Override
- protected void onDevicePluginReset() {
- // Device Plug-inへのReset要求受信時の処理。
- if (BuildConfig.DEBUG) {
- Log.i("TEST", "Plug-in : onDevicePluginReset");
- }
- resetPluginResource();
- }
-
- /**
- * リソースリセット処理.
- */
- private void resetPluginResource() {
- /* 全イベント削除. */
- EventManager.INSTANCE.removeAll();
- onCastDeviceUnselected(null);
- }
-
-
- /**
- * ChromeCastDiscoveryを返す.
- * @return ChromeCastDiscovery
- */
- public ChromeCastDiscovery getChromeCastDiscovery() {
- ChromeCastApplication app = (ChromeCastApplication) getApplication();
- if (app == null) {
- return null;
- }
- return app.getDiscovery();
- }
-
- /**
- * ChromeCastMediaPlayerを返す.
- * @return ChromeCastMediaPlayer
- */
- public ChromeCastMediaPlayer getChromeCastMediaPlayer() {
- return mMediaPlayer;
- }
- /**
- * ChromeCastMessageを返す.
- * @return ChromeCastMessage
- */
- public ChromeCastMessage getChromeCastMessage() {
- return mMessage;
- }
- /**
- * ChromeCastHttpServerを返す.
- * @return ChromeCastHttpServer
- */
- public ChromeCastHttpServer getChromeCastHttpServer() {
- return mServer;
- }
-
- /**
- * StatusChange通知を有効にする.
- *
- * @param response レスポンス
- * @param serviceId デバイスを識別するID
- */
- public void registerOnStatusChange(final Intent response, final String serviceId) {
- mServiceIdOnStatusChange = serviceId;
- mEnableCastMediaPlayerStatusUpdate = true;
- response.putExtra(DConnectMessage.EXTRA_RESULT, DConnectMessage.RESULT_OK);
- response.putExtra(DConnectMessage.EXTRA_VALUE, "Register OnStatusChange event");
- sendResponse(response);
- }
-
- /**
- * StatusChange通知を無効にする.
- *
- * @param response レスポンス
- */
- public void unregisterOnStatusChange(final Intent response) {
- mServiceIdOnStatusChange = null;
- mEnableCastMediaPlayerStatusUpdate = false;
- response.putExtra(DConnectMessage.EXTRA_RESULT, DConnectMessage.RESULT_OK);
- response.putExtra(DConnectMessage.EXTRA_VALUE, "Unregister OnStatusChange event");
- sendResponse(response);
- }
-
- @Override
- public void onChromeCastMediaPlayerStatusUpdate(final MediaStatus status) {
-
- MediaInfo info = status.getMediaInfo();
- ChromeCastDeviceService service = (ChromeCastDeviceService) getServiceProvider().getService(mServiceIdOnStatusChange);
- if (service == null) {
- return;
- }
- String playStatusString = service.getMediaPlayerProfile().getPlayStatus(status.getPlayerState());
-
- if (mEnableCastMediaPlayerStatusUpdate) {
- List events = EventManager.INSTANCE.getEventList(mServiceIdOnStatusChange,
- MediaPlayerProfile.PROFILE_NAME, null,
- MediaPlayerProfile.ATTRIBUTE_ON_STATUS_CHANGE);
-
- for (int i = 0; i < events.size(); i++) {
- Event event = events.get(i);
-
- Intent intent = EventManager.createEventMessage(event);
- MediaPlayerProfile.setAttribute(intent,
- MediaPlayerProfile.ATTRIBUTE_ON_STATUS_CHANGE);
- Bundle mediaPlayer = new Bundle();
- MediaPlayerProfile.setStatus(mediaPlayer, playStatusString);
- if (info != null) {
- MediaPlayerProfile.setMediaId(mediaPlayer, info.getContentId());
- MediaPlayerProfile.setMIMEType(mediaPlayer, info.getContentType());
- } else {
- MediaPlayerProfile.setMediaId(mediaPlayer, "");
- MediaPlayerProfile.setMIMEType(mediaPlayer, "");
- }
- MediaPlayerProfile.setPos(mediaPlayer, (int) status.getStreamPosition() / 1000);
- MediaPlayerProfile.setVolume(mediaPlayer, status.getStreamVolume());
- MediaPlayerProfile.setMediaPlayer(intent, mediaPlayer);
- sendEvent(intent, event.getAccessToken());
- }
- }
- }
-
- /**
- * ステータスに基づいて、レスポンスする.
- * @param response レスポンス
- * @param result Chromecastからの状態
- * @param message Chromecastの状態
- */
- private void onChromeCastResult(final Intent response, final Status result, final String message) {
- if (result == null) {
- MessageUtils.setIllegalDeviceStateError(response, message);
- } else {
- if (result.isSuccess()) {
- response.putExtra(DConnectMessage.EXTRA_RESULT, DConnectMessage.RESULT_OK);
- } else {
- if (message == null) {
- MessageUtils.setIllegalDeviceStateError(response);
- } else {
- MessageUtils.setIllegalDeviceStateError(response, message + " is error");
- }
- }
- }
- sendResponse(response);
- }
- @Override
- public void onChromeCastMediaPlayerResult(final Intent response,
- final MediaChannelResult result, final String message) {
- if (result == null) {
- MessageUtils.setIllegalDeviceStateError(response, message);
- sendResponse(response);
- } else {
- onChromeCastResult(response, result.getStatus(), message);
- }
- }
- @Override
- public void onChromeCastMessageResult(final Intent response, final Status result, final String message) {
- onChromeCastResult(response, result, message);
- }
-
- @Override
- public void onCastDeviceUpdate(final ArrayList devices) {
- if (BuildConfig.DEBUG) {
- Log.d("TEST", "onCastDeviceUpdate#");
- }
- if (devices.size() == 0) {
- if (BuildConfig.DEBUG) {
- Log.d("TEST", "size:0");
- }
- ChromeCastApplication app = (ChromeCastApplication) getApplication();
-
- if (app.getController() != null) {
- app.getController().teardown();
- }
- }
- }
-
-
- @Override
- public void onCastDeviceSelected(final CastDevice selectedDevice) {
- if (BuildConfig.DEBUG) {
- Log.d("TEST", "onCastDeviceSelected#" + selectedDevice.getDeviceId());
- }
- ChromeCastApplication app = (ChromeCastApplication) getApplication();
- if (app == null) {
- return;
- }
-
- CastDevice currentDevice = app.getController().getSelectedDevice();
- if (currentDevice != null) {
- DConnectService castService = getServiceProvider().getService(currentDevice.getDeviceId());
- if (castService == null) {
- castService = new ChromeCastDeviceService(currentDevice);
- getServiceProvider().addService(castService);
- }
- castService.setOnline(true);
- if (!currentDevice.getDeviceId().equals(selectedDevice.getDeviceId())) {
- app.getController().setSelectedDevice(selectedDevice);
- app.getController().reconnect();
- } else {
- app.getController().connect();
- }
- } else {
- app.getController().setSelectedDevice(selectedDevice);
- app.getController().connect();
- }
- }
-
- @Override
- public void onCastDeviceUnselected(final CastDevice unselectedDevice) {
- if (BuildConfig.DEBUG) {
- Log.d("TEST", "onCastDeviceUnselected#start");
- }
- ChromeCastApplication app = (ChromeCastApplication) getApplication();
-
- if (app == null) {
- return;
- }
- CastDevice currentDevice = unselectedDevice;
- if (currentDevice == null) {
- if (app.getController().getSelectedDevice() == null) {
- return;
- }
- currentDevice = app.getController().getSelectedDevice();
- }
- if (BuildConfig.DEBUG) {
- Log.d("TEST", "onCastDeviceUnselected#start+ " + currentDevice.getDeviceId());
- }
-
- DConnectService castService = getServiceProvider().getService(currentDevice.getDeviceId());
- if (castService != null) {
- castService.setOnline(false);
- }
- app.getController().teardown();
- }
-
-
- @Override
- public synchronized void onChromeCastConnected() {
- ChromeCastApplication app = (ChromeCastApplication) getApplication();
- if (app != null) {
- CastDevice currentDevice = app.getController().getSelectedDevice();
- DConnectService castService = getServiceProvider().getService(currentDevice.getDeviceId());
- if (castService == null) {
- castService = new ChromeCastDeviceService(currentDevice);
- getServiceProvider().addService(castService);
- }
- castService.setOnline(true);
- }
- }
-
-
-
- /**
- * 選択されたChromeCastと接続する.
- * @param serviceId サービスID
- * @param callback 非同期処理用Callback
- */
- public synchronized void connectChromeCast(final String serviceId,
- final Callback callback) {
- ChromeCastApplication app = (ChromeCastApplication) getApplication();
- if (app == null) {
- callback.onResponse(false);
- return;
- }
-
- if (app.getDiscovery().getSelectedDevice() != null) {
- // Whether application that had been started before whether other apps
- try {
- GoogleApiClient client = app.getController().getGoogleApiClient();
- if (client == null || (!client.isConnected())) {
- // Request in connection queuing
- callback.onResponse(false);
- return;
- }
- callback.onResponse(true);
- } catch (IllegalStateException e) {
- callback.onResponse(false);
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/AppLocalMediaFile.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/AppLocalMediaFile.java
deleted file mode 100644
index 75787de60d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/AppLocalMediaFile.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- AppLocalMediaFile.java
- Copyright (c) 2019 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.core;
-
-import android.content.Context;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-public class AppLocalMediaFile implements MediaFile {
-
- final File mFile;
-
- public AppLocalMediaFile(final File file) {
- mFile = file;
- }
-
- @Override
- public String getName() {
- return mFile.getName();
- }
-
- @Override
- public InputStream open(final Context context) throws IOException {
- return new FileInputStream(mFile);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastController.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastController.java
deleted file mode 100755
index 8283e46a1d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastController.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- ChromeCastApplication.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.core;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.util.Log;
-
-import com.google.android.gms.cast.Cast;
-import com.google.android.gms.cast.Cast.ApplicationConnectionResult;
-import com.google.android.gms.cast.CastDevice;
-import com.google.android.gms.common.ConnectionResult;
-import com.google.android.gms.common.api.GoogleApiClient;
-import com.google.android.gms.common.api.ResultCallback;
-import com.google.android.gms.common.api.Status;
-
-import org.deviceconnect.android.deviceplugin.chromecast.BuildConfig;
-
-import java.util.ArrayList;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Chromecast Controller クラス.
- *
- * アプリケーションIDに対応したReceiverアプリのコントロール
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastController implements
- GoogleApiClient.ConnectionCallbacks,
- GoogleApiClient.OnConnectionFailedListener {
- /** ロックオブジェクト. */
-// private final Object mLockObj = new Object();
-
- /** 出力するログのタグ名. */
- private static final String TAG = ChromeCastController.class.getSimpleName();
- /** 選択したデバイスの情報. */
- private CastDevice mSelectedDevice;
- /** GoogleAPIClient. */
- private GoogleApiClient mApiClient;
- /** Castのリスナー. */
- private Cast.Listener mCastListener;
- /** コンテキスト. */
- private Context mContext;
- /** アプリID. */
- private String mAppId;
- /** ChromecastAttach/Detach用のコールバック群. */
- private ArrayList mCallbacks;
- /** Chromecast接続完了用のコールバック群. */
- private Result mResult;
- /** Application接続フラグ. */
- private boolean mIsApplicationDisconnected = false;
-
- /**
- * Chromecastとの接続結果を通知するコールバックのインターフェース.
- *
- * @author NTT DOCOMO, INC.
- */
- public interface Result {
- /**
- * ChromeCastと接続されたことを通知する。
- */
- void onChromeCastConnected();
-
- }
- /**
- * ChromecastAttach/Detachイベントを通知するコールバックのインターフェース.
- * @author NTT DOCOMO, INC.
- */
- public interface Callbacks {
- /**
- * Chromecast Applicationにアタッチする.
- */
- void onAttach();
-
- /**
- * Chromecast Applicationにデタッチする.
- */
- void onDetach();
- }
-
- /**
- * コンストラクタ.
- *
- * @param context コンテキスト
- * @param appId ReceiverアプリのアプリケーションID
- */
- public ChromeCastController(final Context context, final String appId) {
- this.mContext = context;
- this.mAppId = appId;
- this.mSelectedDevice = null;
- mCallbacks = new ArrayList();
- }
-
- @Override
- public void onConnected(final Bundle connectionHint) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "onConnected:");
- }
-
- if (mApiClient == null) {
- return;
- }
-
- if (connectionHint != null && connectionHint.getBoolean(Cast.EXTRA_APP_NO_LONGER_RUNNING)) {
- teardown();
- } else {
- launchApplication();
- }
- }
-
- @Override
- public void onConnectionSuspended(final int cause) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "onConnectionSuspended$cause: " + cause);
- }
- }
-
- @Override
- public void onConnectionFailed(final ConnectionResult result) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "onConnectionFailed$result: " + result.toString());
- }
- teardown();
- }
-
- /**
- * GoogleApiClientを取得する.
- *
- * 接続に失敗した場合にはnullを返却します。
- *
- * @return GoogleApiClient
- */
- public GoogleApiClient getGoogleApiClient() {
- if (!mApiClient.isConnected()) {
- // 一度切断する
- mApiClient.disconnect();
-
- Cast.CastOptions.Builder apiOptionsBuilder =
- new Cast.CastOptions.Builder(mSelectedDevice, mCastListener);
- mApiClient = new GoogleApiClient.Builder(mContext)
- .addApi(Cast.API, apiOptionsBuilder.build())
- .addConnectionCallbacks(this)
- .addOnConnectionFailedListener(this)
- .build();
- ConnectionResult result = mApiClient.blockingConnect(30, TimeUnit.SECONDS);
- if (!result.isSuccess()) {
- return null;
- }
- }
- return mApiClient;
- }
-
-
- /**
- * コールバックを登録する.
- *
- * @param callbacks 追加するコールバック
- */
- public void addCallbacks(final Callbacks callbacks) {
- this.mCallbacks.add(callbacks);
- }
-
- /**
- * 接続完了を通知するコールバックを登録する.
- *
- * @param result コールバック
- */
- public void setResult(final Result result) {
- this.mResult = result;
- }
-
- /**
- * Chromecastデバイスをセットする.
- *
- * @param selectedDevice 選択したChromecastのデバイス
- */
- public void setSelectedDevice(final CastDevice selectedDevice) {
- this.mSelectedDevice = selectedDevice;
- }
-
- /**
- * Chromecastデバイスを取得する.
- *
- * @return CastDevice
- */
- public CastDevice getSelectedDevice() {
- return mSelectedDevice;
- }
-
- /**
- * GooglePlayServiceに接続し、Receiverアプリケーションを起動する.
- *
- */
- public void connect() {
- if (mApiClient != null && mIsApplicationDisconnected) {
- mIsApplicationDisconnected = false;
- launchApplication();
- }
-
- if (mApiClient == null) {
- mIsApplicationDisconnected = false;
-
- mCastListener = new Cast.Listener() {
- @Override
- public void onApplicationDisconnected(final int statusCode) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "onApplicationDisconnected$statusCode: " + statusCode);
- }
- mIsApplicationDisconnected = true;
- }
- @Override
- public void onApplicationStatusChanged() {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "onApplicationStatusChanged");
- }
- }
- };
-
- Cast.CastOptions.Builder apiOptionsBuilder =
- new Cast.CastOptions.Builder(mSelectedDevice, mCastListener);
- mApiClient = new GoogleApiClient.Builder(mContext)
- .addApi(Cast.API, apiOptionsBuilder.build())
- .addConnectionCallbacks(this)
- .addOnConnectionFailedListener(this)
- .build();
- mApiClient.connect();
- }
- }
-
- /**
- * Receiverアプリケーションを終了し、GooglePlayServiceから切断し、再接続する.
- *
- */
- public void reconnect() {
- stopApplication(true);
- }
-
- /**
- * Receiverアプリケーションを終了し、GooglePlayServiceから切断する.
- *
- */
- public void teardown() {
- stopApplication(false);
- }
-
- /**
- * Receiverアプリケーションを起動する.
- *
- */
- private void launchApplication() {
- if (mApiClient != null && mApiClient.isConnected()) {
- Cast.CastApi.launchApplication(mApiClient, mAppId)
- .setResultCallback((result) -> {
- Status status = result.getStatus();
- if (status.isSuccess()) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "launchApplication$onResult: Success");
- }
- for (int i = 0; i < mCallbacks.size(); i++) {
- mCallbacks.get(i).onAttach();
- }
-
- } else {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "launchApplication$onResult: Fail");
- }
- teardown();
- }
- if (mResult != null) {
- mResult.onChromeCastConnected();
- }
- });
- }
- }
-
- /**
- * Receiverアプリケーションを停止する.
- *
- * 停止後、再接続することもできる
- *
- */
- private void stopApplication(final boolean isReconect) {
- if (mApiClient != null && mApiClient.isConnected()) {
- Cast.CastApi.stopApplication(mApiClient).setResultCallback((result) -> {
- if (result.getStatus().isSuccess()) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "stopApplication$onResult: Success");
- }
-
- for (int i = 0; i < mCallbacks.size(); i++) {
- mCallbacks.get(i).onDetach();
- }
-
- mApiClient.disconnect();
- mApiClient = null;
- mSelectedDevice = null;
- if (isReconect) {
- launchApplication();
- }
- } else {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "stopApplication$onResult: Fail");
- }
- }
- });
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastDiscovery.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastDiscovery.java
deleted file mode 100755
index a146cee4c4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastDiscovery.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- ChromeCastDiscovery.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.core;
-
-import android.content.Context;
-import android.util.Log;
-
-import com.google.android.gms.cast.CastDevice;
-import com.google.android.gms.cast.framework.CastContext;
-import com.google.android.gms.cast.framework.CastSession;
-import com.google.android.gms.cast.framework.SessionManagerListener;
-
-import org.deviceconnect.android.deviceplugin.chromecast.BuildConfig;
-
-import java.util.ArrayList;
-
-/**
- * Chromecast Discovery クラス.
- *
- *
- * ReceiverアプリのアプリケーションIDに対応した、Chromecastデバイスを探索する
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastDiscovery {
-
- /** 出力するログのタグ名. */
- private static final String TAG = ChromeCastDiscovery.class.getSimpleName();
- /** 選択されたデバイス. */
- private CastDevice mSelectedDevice;
- /** Chromecastとの接続状態を通知するコールバック. */
- private Callbacks mCallbacks;
- /** Route名のリスト. */
- private ArrayList mRouteNames;
-
- /**
- * Chromecastとの接続状態を通知するコールバックのインターフェース.
- * @author NTT DOCOMO, INC.
- */
- public interface Callbacks {
- /**
- * Chromecastデバイスの探索状態(発見or消失した場合)を通知する.
- * @param devices デバイス名のリスト
- */
- void onCastDeviceUpdate(final ArrayList devices);
- /**
- * Chromecastデバイスが選択されたときに通知する.
- *
- * @param selectedDevice 選択されたデバイス
- */
- void onCastDeviceSelected(final CastDevice selectedDevice);
- /**
- * Chromecastデバイスが非選択されたときに通知する.
- * @param unselectedDevice 選択されたデバイス
- */
- void onCastDeviceUnselected(final CastDevice unselectedDevice);
- }
-
- /**
- * コールバックを登録する.
- *
- * @param callbacks コールバック
- */
- public void setCallbacks(final Callbacks callbacks) {
- this.mCallbacks = callbacks;
- }
-
- /**
- * ChromeCastとの接続を管理する.
- */
- private CastContext mCastContext;
- /**
- * onEndingを通るかどうか.
- */
- private boolean mIsEnding;
-
- private SessionManagerListener mSessionListener = new SessionManagerListener() {
-
- @Override
- public void onSessionStarting(CastSession castSession) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "================================>");
- Log.d(TAG, "SessionManagerListener.onSessionStarting");
- Log.d(TAG, "<================================");
- }
- synchronized (this) {
- CastDevice device = castSession.getCastDevice();
- if (device != null) {
- mRouteNames.add(device);
- }
- }
- mCallbacks.onCastDeviceUpdate(mRouteNames);
- }
-
- @Override
- public void onSessionStarted(CastSession castSession, String s) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "================================>");
- Log.d(TAG, "SessionManagerListener.onSessionStarted");
- Log.d(TAG, "<================================");
- }
- mSelectedDevice = castSession.getCastDevice();
- mCallbacks.onCastDeviceSelected(mSelectedDevice);
- }
-
- @Override
- public void onSessionStartFailed(CastSession castSession, int i) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "================================>");
- Log.d(TAG, "SessionManagerListener.onSessionStartFailed");
- Log.d(TAG, "<================================");
- }
- }
-
- @Override
- public void onSessionEnding(CastSession castSession) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "================================>");
- Log.d(TAG, "SessionManagerListener.onSessionEnding");
- Log.d(TAG, "<================================");
- }
- mCallbacks.onCastDeviceUpdate(mRouteNames);
- mIsEnding = true;
- }
-
- @Override
- public void onSessionEnded(CastSession castSession, int i) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "================================>");
- Log.d(TAG, "SessionManagerListener.onSessionEnded");
- Log.d(TAG, "<================================");
- }
- // WiFiをOFFにしたのちにChromeCastへリクエストを送ると、onSessionEndingが呼ばれずにこのメソッドが呼ばれる。
- if (mIsEnding) {
- mCallbacks.onCastDeviceUnselected(mSelectedDevice);
- mSelectedDevice = null;
- }
- mIsEnding = false;
- }
-
- @Override
- public void onSessionResuming(CastSession castSession, String s) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "================================>");
- Log.d(TAG, "SessionManagerListener.onSessionResuming");
- Log.d(TAG, "<================================");
- }
- }
-
- @Override
- public void onSessionResumed(CastSession castSession, boolean b) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "================================>");
- Log.d(TAG, "SessionManagerListener.onSessionResumed: " + b);
- Log.d(TAG, "<================================");
- }
- mSelectedDevice = castSession.getCastDevice();
- mCallbacks.onCastDeviceSelected(mSelectedDevice);
- }
-
- @Override
- public void onSessionResumeFailed(CastSession castSession, int i) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "================================>");
- Log.d(TAG, "SessionManagerListener.onSessionResumeFailed");
- Log.d(TAG, "<================================");
- }
- }
-
- @Override
- public void onSessionSuspended(CastSession castSession, int i) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "================================>");
- Log.d(TAG, "SessionManagerListener.onSessionSuspended");
- Log.d(TAG, "<================================");
- }
- mCallbacks.onCastDeviceUnselected(mSelectedDevice);
- }
- };
-
- /**
- * コンストラクタ.
- *
- * ReceiverアプリのアプリケーションIDに対応した、Chromecastデバイスの探索を開始する.
- *
- *
- * @param context コンテキスト
- */
- public ChromeCastDiscovery(final Context context) {
- mCastContext = CastContext.getSharedInstance(context);
- mIsEnding = false;
- setListener();
- mRouteNames = new ArrayList<>();
- }
-
- /**
- * Listenerを登録する.
- */
- private void setListener() {
- mCastContext.getSessionManager().removeSessionManagerListener(mSessionListener, CastSession.class);
- mCastContext.getSessionManager().addSessionManagerListener(
- mSessionListener, CastSession.class);
- }
-
-
- /**
- * 選択されたChromecastデバイスを返す.
- *
- * @return 選択されたデバイス
- */
- public CastDevice getSelectedDevice() {
- return mSelectedDevice;
- }
-
- /**
- * 接続可能なChromecastデバイスのデバイス名のリストを返す.
- *
- * @return デバイス名のリスト
- */
- public ArrayList getDeviceNames() {
- return mRouteNames;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastHttpServer.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastHttpServer.java
deleted file mode 100755
index afdaa2bcd9..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastHttpServer.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- ChromeCastHttpServer.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.core;
-
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-
-import org.deviceconnect.android.deviceplugin.chromecast.BuildConfig;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import fi.iki.elonen.NanoHTTPD;
-
-/**
- * Chromecast HttpServer クラス.
- *
- *
- * HttpServer機能を提供
- * - 選択されたファイルのみ配信する
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastHttpServer extends NanoHTTPD {
-
- /** Local IP Address prefix. */
- private static final String PREFIX_LOCAL_IP = "192.168.";
- enum NetworkStatus
- {
- OFF, WIFI, MOBILE, WIMAX, BLUETOOTH, ETHERNET;
- }
- /** Logger. */
- private final Logger mLogger = Logger.getLogger("chromecast.dplugin");
-
- /** The List of media files. */
- private final List mFileList = new ArrayList();
-
- private Context mContext;
- /**
- * コンストラクタ.
- *
- * @param host ipアドレス
- * @param port ポート番号
- */
- public ChromeCastHttpServer(final Context context, final String host, final int port) {
- super(host, port);
- mContext = context;
- }
-
- /**
- * クライアントに応答する.
- *
- * @param session セッション
- * @return レスポンス
- */
- public Response serve(final IHTTPSession session) {
- mLogger.info("Received HTTP request: " + session.getUri());
-
- Map header = session.getHeaders();
- String uri = session.getUri();
- return respond(Collections.unmodifiableMap(header), session, uri);
- }
-
- /**
- * 指定されたファイルを公開する.
- *
- * @param file 公開するファイル
- * @return 公開用URI
- */
- public String exposeFile(final MediaFile file) {
- synchronized (mFileList) {
- mFileList.add(file);
- }
- String address = getIpAddress();
- if (address == null) {
- return null;
- }
- return "http://" + address + ":" + getListeningPort() + "/" + file.getName();
- }
-
- /**
- * クライアントをチェックする.
- *
- * @param headers ヘッダー
- * @return 有効か否か (true: 有効, false: 無効)
- */
- private boolean checkRemote(final Map headers) {
- String remoteAddr = headers.get("remote-addr");
- try {
- InetAddress addr = InetAddress.getByName(remoteAddr);
- return addr.isSiteLocalAddress();
- } catch (UnknownHostException e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- return false;
- }
- }
-
- /**
- * クライアントへのレスポンスを作成する.
- *
- * @param headers ヘッダー
- * @param session セッション
- * @param uri ファイルのURI
- * @return レスポンス
- */
- private Response respond(final Map headers, final IHTTPSession session, final String uri) {
- if (!checkRemote(headers)) {
- return createResponse(Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "");
- }
-
- MediaFile mediaFile = findFile(uri);
- if (mediaFile == null) {
- mLogger.info("File not found: URI=" + uri);
- return createResponse(Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT, "");
- }
- mLogger.info("Found File: " + mediaFile.getName());
-
- Response response = serveFile(headers, mediaFile, "");
- if (response == null) {
- return createResponse(Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT, "");
- }
- return response;
- }
-
- /**
- * 指定したURIで公開しているファイルを検索する.
- *
- * @param uri ファイル公開用URI
- * @return 検索により見つかったファイル. 見つからなかった場合はnull
- */
- private MediaFile findFile(final String uri) {
- synchronized (mFileList) {
- for (MediaFile file : mFileList) {
- mLogger.info(" - " + file.getName());
- if (uri.equals("/" + file.getName())) {
- return file;
- }
- }
- }
- return null;
- }
-
- /**
- * レスポンスを作成する.
- *
- * @param status ステータス
- * @param mimeType MIMEタイプ
- * @param message メッセージ (InputStream)
- * @param length 送信するデータ長
- * @return レスポンス
- */
- private Response createResponse(final Response.Status status,
- final String mimeType,
- final InputStream message,
- final int length) {
- Response res = new Response(status, mimeType, message);
- res.setContentLength(length);
- res.addHeader("Accept-Ranges", "bytes");
- return res;
- }
-
- /**
- * レスポンスを作成する.
- *
- * @param status ステータス
- * @param mimeType MIMEタイプ
- * @param message メッセージ (String)
- * @return レスポンス
- */
- private Response createResponse(final Response.Status status,
- final String mimeType,
- final String message) {
- Response res = new Response(status, mimeType, message);
- res.addHeader("Accept-Ranges", "bytes");
- return res;
- }
-
- /**
- * IPアドレスを取得する.
- *
- * @return IPアドレス
- */
- private String getIpAddress() {
- try {
- Enumeration networkInterfaces = NetworkInterface
- .getNetworkInterfaces();
- LinkedList localAddresses = new LinkedList();
- while (networkInterfaces.hasMoreElements()) {
- NetworkInterface networkInterface = networkInterfaces
- .nextElement();
- Enumeration ipAddrs = networkInterface
- .getInetAddresses();
- while (ipAddrs.hasMoreElements()) {
- InetAddress ip = ipAddrs.nextElement();
- String ipStr = ip.getHostAddress();
-
- mLogger.info("Searching IP Address: Address=" + ipStr
- + " isLoopback=" + ip.isLoopbackAddress()
- + " isSiteLocal=" + ip.isSiteLocalAddress());
- NetworkStatus status = NetworkStatus.OFF;
-
- NetworkInfo info = ((ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
-
- if ( info != null )
- {
- if ( info.isConnected() )
- {
- switch ( info.getType() )
- {
- case ConnectivityManager.TYPE_WIFI: // Wifi
- status = NetworkStatus.WIFI;
- break;
- case ConnectivityManager.TYPE_MOBILE_DUN: // Mobile 3G
- case ConnectivityManager.TYPE_MOBILE_HIPRI:
- case ConnectivityManager.TYPE_MOBILE_MMS:
- case ConnectivityManager.TYPE_MOBILE_SUPL:
- case ConnectivityManager.TYPE_MOBILE:
- status = NetworkStatus.MOBILE;
- break;
- case ConnectivityManager.TYPE_BLUETOOTH: // Bluetooth
- status = NetworkStatus.BLUETOOTH;
- break;
- case ConnectivityManager.TYPE_ETHERNET: // Ethernet
- status = NetworkStatus.ETHERNET;
- break;
- }
- }
- }
- // ipv6を除外
- if (ipStr.indexOf("127.0.0.1") == -1
- && ipStr.indexOf("::") == -1 && (status == NetworkStatus.WIFI
- || status == NetworkStatus.ETHERNET)) {
- localAddresses.addFirst(ip);
- }
- }
- }
- if (localAddresses.size() == 0) {
- return null;
- }
- return localAddresses.get(0).getHostAddress();
- } catch (SocketException e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- }
- return null;
- }
-
- /**
- * ファイルのレスポンスを作成する.
- *
- * @param header ヘッダー
- * @param file ファイル
- * @param mime MIMEタイプ
- * @return レスポンス
- */
- Response serveFile(final Map header, final MediaFile file, final String mime) {
-
- Response res;
- try {
- InputStream in = file.open(mContext);
-
- long fileLen = in.available();
- String etag = Integer.toHexString((file.getName() + "" + fileLen).hashCode());
-
- long startFrom = 0;
- long endAt = -1;
- String range = header.get("range");
- if (range != null) {
- if (range.startsWith("bytes=")) {
- range = range.substring("bytes=".length());
- int minus = range.indexOf('-');
- try {
- if (minus > 0) {
- startFrom = Long.parseLong(range
- .substring(0, minus));
- endAt = Long.parseLong(range.substring(minus + 1));
- }
- } catch (NumberFormatException ignored) {
- if (BuildConfig.DEBUG) {
- ignored.printStackTrace();
- }
- }
- }
- }
-
- if (range != null && startFrom >= 0) {
- if (startFrom >= fileLen) {
- res = createResponse(Response.Status.RANGE_NOT_SATISFIABLE, NanoHTTPD.MIME_PLAINTEXT, "");
- res.addHeader("Content-Range", "bytes 0-0/" + fileLen);
- res.addHeader("ETag", etag);
- } else {
- if (endAt < 0) {
- endAt = fileLen - 1;
- }
- long newLen = endAt - startFrom + 1;
- if (newLen < 0) {
- newLen = 0;
- }
-
- in.skip(startFrom);
- res = createResponse(Response.Status.PARTIAL_CONTENT, mime, in, (int) newLen);
- res.addHeader("Content-Length", "" + newLen);
- res.addHeader("Content-Range", "bytes " + startFrom + "-" + endAt + "/" + fileLen);
- res.addHeader("ETag", etag);
- }
- } else {
- if (etag.equals(header.get("if-none-match"))) {
- res = createResponse(Response.Status.NOT_MODIFIED, mime, "");
- } else {
- res = createResponse(Response.Status.OK, mime, in, in.available());
- res.addHeader("Content-Length", "" + fileLen);
- res.addHeader("ETag", etag);
- }
- }
- } catch (IOException ioe) {
- res = createResponse(Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "");
- }
-
- return res;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastMediaPlayer.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastMediaPlayer.java
deleted file mode 100755
index f37b7b6239..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastMediaPlayer.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- ChromeCastMediaPlayer.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.core;
-
-import android.content.Intent;
-import android.webkit.MimeTypeMap;
-
-import com.google.android.gms.cast.Cast;
-import com.google.android.gms.cast.MediaInfo;
-import com.google.android.gms.cast.MediaMetadata;
-import com.google.android.gms.cast.MediaStatus;
-import com.google.android.gms.cast.RemoteMediaPlayer;
-import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult;
-import com.google.android.gms.common.api.ResultCallback;
-
-import org.deviceconnect.android.deviceplugin.chromecast.BuildConfig;
-
-import java.util.Locale;
-
-/**
- * Chromecast MediaPlayer クラス.
- *
- *
- * MediaPlayer機能を提供する
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastMediaPlayer implements ChromeCastController.Callbacks {
-
- /** Chromecast Controller. */
- private ChromeCastController mController;
- /** RemoteMediaPlayer. */
- private RemoteMediaPlayer mRemoteMediaPlayer;
- /** Chromecastの再生状態を受け取るコールバック. */
- private Callbacks mCallbacks;
- /** Chromecastのファイルロード有効フラグ. */
- private boolean mIsLoadEnable = false;
-
- /**
- * Chromecastの再生状態を通知するためのコールバックのインターフェース.
- * @author NTT DOCOMO, INC.
- */
- public interface Callbacks {
- /**
- * 再生状態を通知する.
- *
- * @param status メディアのステータス
- */
- void onChromeCastMediaPlayerStatusUpdate(final MediaStatus status);
- /**
- * 再生処理の結果を通知する.
- *
- * @param response レスポンス
- * @param result 再生処理結果
- * @param message 再生処理のステータス
- */
- void onChromeCastMediaPlayerResult(final Intent response,
- final MediaChannelResult result, final String message);
- }
-
- /**
- * コールバックを登録する.
- *
- * @param callbacks コールバック
- */
- public void setCallbacks(final Callbacks callbacks) {
- this.mCallbacks = callbacks;
- }
-
- /**
- * コンストラクタ.
- *
- * @param controller ChromeCastApplication
- */
- public ChromeCastMediaPlayer(final ChromeCastController controller) {
- mController = controller;
- mController.addCallbacks(this);
- }
-
- /**
- * デバイスが有効か否かを返す.
- * @return デバイスが有効か否か(有効: true, 無効: false)
- */
- public boolean isDeviceEnable() {
- try {
- return (mController.getGoogleApiClient() != null);
- } catch (IllegalStateException e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- return false;
- }
- }
- @Override
- public void onAttach() {
- mRemoteMediaPlayer = new RemoteMediaPlayer();
- mRemoteMediaPlayer.setOnStatusUpdatedListener(() -> {
- if (mRemoteMediaPlayer.getMediaStatus() == null) {
- return;
- }
- mCallbacks.onChromeCastMediaPlayerStatusUpdate(mRemoteMediaPlayer.getMediaStatus());
- });
- mRemoteMediaPlayer.setOnMetadataUpdatedListener(() -> {
- });
-
- try {
- Cast.CastApi.setMessageReceivedCallbacks(mController.getGoogleApiClient(),
- mRemoteMediaPlayer.getNamespace(), mRemoteMediaPlayer);
- } catch (Exception e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- }
- }
-
- @Override
- public void onDetach() {
- if (mRemoteMediaPlayer != null) {
- try {
- Cast.CastApi.removeMessageReceivedCallbacks(mController.getGoogleApiClient(),
- mRemoteMediaPlayer.getNamespace());
- } catch (Exception e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- }
- mRemoteMediaPlayer = null;
- }
- }
-
- /**
- * メディアをロードする.
- *
- * @param response レスポンス
- * @param url メディアのURL
- * @param title メディアのタイトル
- */
- public void load(final Intent response, final String url, final String title) {
- MediaInfo mediaInfo;
-
- MediaMetadata mediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
- mediaMetadata.putString(MediaMetadata.KEY_TITLE, title);
- String ext = MimeTypeMap.getFileExtensionFromUrl(url).toLowerCase(Locale.getDefault());
- String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext);
- if (mimeType == null || mimeType.isEmpty()) {
- mimeType = "application/octet-stream";
- }
- mediaInfo = new MediaInfo.Builder(url).setContentType(mimeType)
- .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
- .setMetadata(mediaMetadata).build();
- if (mRemoteMediaPlayer != null) {
- try {
- mRemoteMediaPlayer
- .load(mController.getGoogleApiClient(), mediaInfo, false)
- .setResultCallback((result) -> {
- if (result.getStatus().isSuccess()) {
- mIsLoadEnable = true;
- } else {
- mIsLoadEnable = false;
- }
- mCallbacks.onChromeCastMediaPlayerResult(response, result, "load");
- });
- } catch (Exception e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- mCallbacks.onChromeCastMediaPlayerResult(response, null, "load");
- }
- }
- }
-
- /**
- * メディアをプレイする.
- *
- * @param response レスポンス
- */
- public void play(final Intent response) {
- MediaInfo mediaInfo = null;
- if (mIsLoadEnable) {
- mediaInfo = mRemoteMediaPlayer.getMediaInfo();
- }
-
- try {
- if (mRemoteMediaPlayer != null) {
- mRemoteMediaPlayer.load(mController.getGoogleApiClient(), mediaInfo, true).setResultCallback(
- (result) -> {
- mCallbacks.onChromeCastMediaPlayerResult(response, result, "load");
- });
- }
- } catch (Exception e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- mCallbacks.onChromeCastMediaPlayerResult(response, null, "load");
- }
- }
-
- /**
- * メディアをレジュームする.
- *
- * @param response レスポンス
- */
- public void resume(final Intent response) {
- try {
- if (mRemoteMediaPlayer != null) {
- mRemoteMediaPlayer.play(mController.getGoogleApiClient()).setResultCallback(
- (result) -> {
- mCallbacks.onChromeCastMediaPlayerResult(response, result,null);
- });
- }
- } catch (Exception e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- mCallbacks.onChromeCastMediaPlayerResult(response, null, null);
- }
- }
-
- /**
- * メディアを停止する.
- *
- * @param response レスポンス
- */
- public void stop(final Intent response) {
- try {
- if (mRemoteMediaPlayer != null) {
- mRemoteMediaPlayer.stop(mController.getGoogleApiClient()).setResultCallback(
- (result) -> {
- mCallbacks.onChromeCastMediaPlayerResult(response, result,null);
- });
- }
- } catch (Exception e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- mCallbacks.onChromeCastMediaPlayerResult(response, null, null);
- }
- }
-
- /**
- * メディアを一時停止する.
- *
- * @param response レスポンス
- */
- public void pause(final Intent response) {
- try {
- if (mRemoteMediaPlayer != null) {
- mRemoteMediaPlayer.pause(mController.getGoogleApiClient()).setResultCallback(
- (result) -> {
- mCallbacks.onChromeCastMediaPlayerResult(response, result,null);
- });
- }
- } catch (Exception e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- mCallbacks.onChromeCastMediaPlayerResult(response, null, null);
- }
- }
- /**
- * メディアをミュートする.
- *
- * @param response レスポンス
- * @param mute ミュートするか否か (true: ミュートON, false: ミュートOFF)
- */
- public void setMute(final Intent response, final boolean mute) {
- try {
- if (mRemoteMediaPlayer != null) {
- mRemoteMediaPlayer
- .setStreamMute(mController.getGoogleApiClient(), mute)
- .setResultCallback(
- (result) -> {
- mCallbacks.onChromeCastMediaPlayerResult(response, result,null);
- });
- }
- } catch (Exception e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- mCallbacks.onChromeCastMediaPlayerResult(response, null, null);
- }
- }
-
- /**
- * メディアのミュートの状態を取得する.
- *
- * @param response レスポンス
- * @return ミュート状態 (1:ミュートON, 0: ミュートOFF)
- */
- public int getMute(final Intent response) {
- if (mRemoteMediaPlayer == null) {
- return -1;
- }
- if (mRemoteMediaPlayer.getMediaStatus().isMute()) {
- return 1;
- } else {
- return 0;
- }
- }
-
- /**
- * メディアのボリュームを設定する.
- *
- * @param response レスポンス
- * @param volume ボリューム (0.0 <= volume <= 1.0)
- */
- public void setVolume(final Intent response, final double volume) {
- try {
- if (mRemoteMediaPlayer != null) {
- mRemoteMediaPlayer
- .setStreamVolume(mController.getGoogleApiClient(), volume)
- .setResultCallback((result) -> {
- mCallbacks.onChromeCastMediaPlayerResult(response, result,
- null);
- });
- }
- } catch (Exception e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- mCallbacks.onChromeCastMediaPlayerResult(response, null, null);
- }
- }
-
- /**
- * メディアのボリュームを取得する.
- *
- * @param response レスポンス
- * @return volume ボリューム (0 <= volume <= 1.0, -1: エラー)
- */
- public double getVolume(final Intent response) {
- if (mRemoteMediaPlayer != null) {
- return mRemoteMediaPlayer.getMediaStatus().getStreamVolume();
- } else {
- return -1;
- }
- }
-
- /**
- * メディアのシークを設定する.
- *
- * @param response レスポンス
- * @param pos ポジション
- */
- public void setSeek(final Intent response, final long pos) {
- try {
- if (mRemoteMediaPlayer != null) {
- mRemoteMediaPlayer
- .seek(mController.getGoogleApiClient(), pos)
- .setResultCallback((result) -> {
- mCallbacks.onChromeCastMediaPlayerResult(response, result,null);
- });
- }
- } catch (Exception e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- mCallbacks.onChromeCastMediaPlayerResult(response, null, null);
- }
- }
-
- /**
- * メディアのシークを取得する.
- *
- * @param response レスポンス
- * @return pos ポジション (-1: エラー)
- */
- public long getSeek(final Intent response) {
- if (mRemoteMediaPlayer != null) {
- return mRemoteMediaPlayer.getApproximateStreamPosition();
- } else {
- return -1;
- }
- }
-
- /**
- * メディアの状態を取得する.
- *
- * @return status メディアの状態
- */
- public MediaStatus getMediaStatus() {
- if (mRemoteMediaPlayer != null) {
- return mRemoteMediaPlayer.getMediaStatus();
- } else {
- return null;
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastMessage.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastMessage.java
deleted file mode 100755
index bf30cd4217..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/ChromeCastMessage.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- ChromeCastMessage.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.core;
-
-import android.content.Intent;
-
-import com.google.android.gms.cast.Cast;
-import com.google.android.gms.cast.Cast.MessageReceivedCallback;
-import com.google.android.gms.cast.CastDevice;
-import com.google.android.gms.common.api.ResultCallback;
-import com.google.android.gms.common.api.Status;
-
-import org.deviceconnect.android.deviceplugin.chromecast.BuildConfig;
-
-/**
- * Chromecast Message クラス.
- *
- *
- * メッセージ機能を提供する
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastMessage implements ChromeCastController.Callbacks {
-
- /** Message Channel. */
- private MessageChannel mMessageChannel;
- /** Chromecast Application. */
- private ChromeCastController mApplication;
- /** メッセージの宛先. */
- private String mUrn = null;
- /** メッセージのコールバック. */
- private Callbacks mCallbacks;
-
- /**
- * Chromecastでのメッセージの受信状況を通知する.
- *
- * @author NTT DOCOMO, INC.
- *
- */
- private class MessageChannel implements MessageReceivedCallback {
-
- /**
- * メッセージの宛先.
- */
- private String mUrn = null;
-
- /**
- * コンストラクタ.
- *
- * @param urn メッセージの宛先(名前空間)
- */
- public MessageChannel(final String urn) {
- this.mUrn = urn;
- }
-
- /**
- * メッセージの宛先(名前空間)を取得する.
- *
- * @return 名前空間
- */
- public String getNamespace() {
- return mUrn;
- }
-
- @Override
- public void onMessageReceived(final CastDevice castDevice, final String namespace, final String message) {
- }
- }
-
- /**
- * Chromecastでのメッセージ処理の結果を通知するコールバックのインターフェース.
- *
- * @author NTT DOCOMO, INC.
- */
- public interface Callbacks {
- /**
- * メッセージ処理の結果を通知する.
- *
- * @param response レスポンス
- * @param result メッセージ処理結果
- * @param message メッセージ処理のステータス
- */
- void onChromeCastMessageResult(final Intent response, final Status result, final String message);
- }
-
- /**
- * コールバックを登録する.
- *
- * @param callbacks コールバック
- */
- public void setCallbacks(final Callbacks callbacks) {
- this.mCallbacks = callbacks;
- }
-
- /**
- * コンストラクタ.
- *
- * @param application ChromeCastApplication
- * @param urn メッセージの宛先(名前空間)
- */
- public ChromeCastMessage(final ChromeCastController application, final String urn) {
- this.mApplication = application;
- this.mApplication.addCallbacks(this);
- this.mUrn = urn;
- }
-
- /**
- * デバイスが有効か否かを返す.
- *
- * @return デバイスが有効か否か(有効: true, 無効: false)
- */
- public boolean isDeviceEnable() {
- try {
- return (mApplication.getGoogleApiClient() != null);
- } catch (IllegalStateException e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- return false;
- }
- }
- @Override
- public void onAttach() {
- mMessageChannel = new MessageChannel(this.mUrn);
- try {
- Cast.CastApi.setMessageReceivedCallbacks(mApplication.getGoogleApiClient(),
- mMessageChannel.getNamespace(), mMessageChannel);
- } catch (Exception e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- }
- }
-
- @Override
- public void onDetach() {
- if (mMessageChannel != null) {
- try {
- Cast.CastApi.removeMessageReceivedCallbacks(mApplication.getGoogleApiClient(),
- mMessageChannel.getNamespace());
- } catch (Exception e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- }
- mMessageChannel = null;
- }
- }
-
- /**
- * メッセージを送信する.
- *
- * @param response レスポンス
- * @param message メッセージ
- */
- public void sendMessage(final Intent response, final String message) {
- try {
- if (mApplication.getGoogleApiClient() != null && mMessageChannel != null) {
- Cast.CastApi.sendMessage(mApplication.getGoogleApiClient(),
- mMessageChannel.getNamespace(), message)
- .setResultCallback((result) -> {
- mCallbacks.onChromeCastMessageResult(response, result, null);
- });
- }
- } catch (Exception e) {
- mCallbacks.onChromeCastMessageResult(response, null, null);
- }
- }
-
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/MediaFile.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/MediaFile.java
deleted file mode 100644
index 080dd13587..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/MediaFile.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- MediaFile.java
- Copyright (c) 2015 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.core;
-
-
-import android.content.Context;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Media file.
- * @author NTT DOCOMO, INC.
- */
-public interface MediaFile {
-
- /**
- * Get the name to expose a media file.
- * @return the path to expose a media file
- */
- String getName();
-
- /**
- * メディアの内容を取得するための入力ストリームを開く.
- *
- * @param context コンテキスト
- * @return 入力ストリーム
- * @throws IOException 入力ストリームの取得に失敗した場合
- */
- InputStream open(Context context) throws IOException;
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/MediaStoreContent.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/MediaStoreContent.java
deleted file mode 100644
index b8c27aba6a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/MediaStoreContent.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- MediaStoreContent.java
- Copyright (c) 2019 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.core;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.net.Uri;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-public class MediaStoreContent implements MediaFile {
-
- private final Uri mMediaUri;
-
- public MediaStoreContent(final Uri mediaUri) {
- if (mediaUri.getPathSegments() == null) {
- throw new IllegalArgumentException("mediaUri has no mediaId");
- }
- mMediaUri = mediaUri;
- }
-
- @Override
- public String getName() {
- return mMediaUri.getLastPathSegment();
- }
-
- @Override
- public InputStream open(final Context context) throws IOException {
- ContentResolver resolver = context.getContentResolver();
- return resolver.openInputStream(mMediaUri);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/package-info.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/package-info.java
deleted file mode 100755
index 21a4a11f51..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/core/package-info.java
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- org.deviceconnect.android.deviceplugin.chromecast.core
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-
-/**
- * Chromecastの管理を行う.
- */
-package org.deviceconnect.android.deviceplugin.chromecast.core;
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/package-info.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/package-info.java
deleted file mode 100755
index 5327c14a83..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/package-info.java
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- org.deviceconnect.android.deviceplugin.chromecast
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-
-/**
- * Device Connect Chromecast DevicePlugin の基本クラスを提供する.
- */
-package org.deviceconnect.android.deviceplugin.chromecast;
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastCanvasProfile.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastCanvasProfile.java
deleted file mode 100644
index cde03fa17b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastCanvasProfile.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- ChromeCastCanvasProfile.java
- Copyright (c) 2015 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.profile;
-
-import android.content.Intent;
-import android.webkit.URLUtil;
-
-import org.deviceconnect.android.deviceplugin.chromecast.ChromeCastService;
-import org.deviceconnect.android.deviceplugin.chromecast.core.AppLocalMediaFile;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastDiscovery;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastHttpServer;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastMessage;
-import org.deviceconnect.android.deviceplugin.chromecast.core.MediaFile;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.CanvasProfile;
-import org.deviceconnect.android.profile.api.DConnectApi;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.message.DConnectMessage;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.logging.Logger;
-
-/**
- * Canvas Profile (Chromecast).
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastCanvasProfile extends CanvasProfile implements ChromeCastConstants {
-
- /**
- * Error message when Chromecast is not enabled.
- */
- private static final String ERROR_MESSAGE_DEVICE_NOT_ENABLED = "Chromecast is not enabled.";
-
- /**
- * Prefix of image file name.
- */
- private static final String PREFIX = "dConnectDeviceChromecast_";
-
- /**
- * The instance of {@link java.text.SimpleDateFormat}.
- */
- private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
-
- /**
- * Logger.
- */
- private final Logger mLogger = Logger.getLogger("chromecast.dplugin");
-
-
-
- public ChromeCastCanvasProfile() {
- addApi(mPostDrawImageApi);
- addApi(mDeleteDrawImageApi);
- }
-
- /**
- * Generates an image file name.
- *
- * @return an image file name
- */
- private static String generateFileName() {
- Date timestamp = new Date(System.currentTimeMillis());
- return PREFIX + FORMAT.format(timestamp);
- }
-
- private final DConnectApi mPostDrawImageApi = new PostApi() {
- @Override
- public String getAttribute() {
- return CanvasProfile.ATTRIBUTE_DRAW_IMAGE;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String mimeType = CanvasProfile.getMIMEType(request);
- final String serviceId = getServiceID(request);
- final byte[] data = CanvasProfile.getData(request);
- final String uri = CanvasProfile.getURI(request);
- final double x = CanvasProfile.getX(request);
- final double y = CanvasProfile.getY(request);
- final String mode = CanvasProfile.getMode(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId, (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- if (data == null && uri == null) {
- MessageUtils.setInvalidRequestParameterError(response, "data is not specified.");
- sendResponse(response);
- return;
- }
- if (mimeType != null && !mimeType.contains("image")) {
- MessageUtils.setInvalidRequestParameterError(response,
- "Unsupported mimeType: " + mimeType);
- sendResponse(response);
- return;
- }
-
- if (uri != null && !URLUtil.isHttpsUrl(uri) && !URLUtil.isHttpUrl(uri)) {
- MessageUtils.setInvalidRequestParameterError(response, "uri is not invalid.");
- sendResponse(response);
- return;
- }
-
- try {
- String path;
- if (data != null) {
- path = exposeImage(data, mimeType);
- } else {
- path = uri;
- }
-
- mLogger.info("Exposed image: URL=" + path);
- if (path == null) {
- MessageUtils.setUnknownError(response, "The host device is not in local network.");
- sendResponse(response);
- return;
- }
- ChromeCastMessage app = ((ChromeCastService) getContext()).getChromeCastMessage();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
- JSONObject json = new JSONObject();
- json.put(KEY_FUNCTION, FUNCTION_POST_IMAGE);
- json.put(KEY_URL, path);
- json.put(KEY_MODE, mode);
- json.put(KEY_X, x);
- json.put(KEY_Y, y);
- String message = json.toString();
- mLogger.info("Send message successfully: " + message);
- setResult(response, DConnectMessage.RESULT_OK);
- app.sendMessage(response, message);
- } catch (IOException e) {
- MessageUtils.setUnknownError(response, "Failed to deploy image to Chromecast.");
- sendResponse(response);
- } catch (Exception e) {
- MessageUtils.setUnknownError(response, e.getMessage());
- sendResponse(response);
- }
- });
- return false;
- }
- };
- /**
- * Expose an image.
- *
- * @param data the binary data of an image
- * @param mimeType the mime type of an image
- * @return the path of the exposed image
- * @throws IOException if the specified image could not be exposed.
- */
- private String exposeImage(final byte[] data, final String mimeType) throws IOException {
- if (data == null) {
- throw new IllegalArgumentException("data is null.");
- }
- File file = saveFile(generateFileName(), data);
- return getHttpServer().exposeFile(new AppLocalMediaFile(file));
- }
-
- /**
- * Save binary data on local file system.
- *
- * @param fileName filename
- * @param data binary data
- * @return stored file
- * @throws IOException if the specified binary data could not be stored.
- */
- private File saveFile(final String fileName, final byte[] data) throws IOException {
- File dir = getContext().getFilesDir();
- File file = new File(dir, generateFileName());
- if (!file.exists()) {
- if (!file.createNewFile()) {
- throw new IOException("File is not be stored: " + fileName);
- }
- }
- FileOutputStream fos = new FileOutputStream(file);
- try {
- fos.write(data);
- fos.flush();
- } finally {
- fos.close();
- }
- return file;
- }
-
- /**
- * Gets HTTP server to expose images.
- *
- * @return an instance of {@link ChromeCastHttpServer}
- */
- private ChromeCastHttpServer getHttpServer() {
- return ((ChromeCastService) getContext()).getChromeCastHttpServer();
- }
-
- private final DConnectApi mDeleteDrawImageApi = new DeleteApi() {
- @Override
- public String getAttribute() {
- return CanvasProfile.ATTRIBUTE_DRAW_IMAGE;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId, (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- ChromeCastMessage app = ((ChromeCastService) getContext()).getChromeCastMessage();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
- try {
- JSONObject json = new JSONObject();
- json.put(KEY_FUNCTION, FUNCTION_DELETE_IMAGE);
- app.sendMessage(response, json.toString());
- } catch (JSONException e) {
- MessageUtils.setUnknownError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
- /**
- * デバイスが有効か否かを返す .
- * デバイスが無効の場合、レスポンスにエラーを設定する
- *
- * @param response レスポンス
- * @param app ChromeCastMediaPlayer
- * @return デバイスが有効か否か(有効: true, 無効: false)
- */
- private boolean isDeviceEnable(final Intent response, final ChromeCastMessage app) {
- if (!app.isDeviceEnable()) {
- MessageUtils.setIllegalDeviceStateError(response, ERROR_MESSAGE_DEVICE_NOT_ENABLED);
- setResult(response, DConnectMessage.RESULT_ERROR);
- return false;
- }
- return true;
- }
-
- /**
- * サービスからChromeCastDiscoveryrを取得する.
- * @return ChromeCastDiscovery
- */
- private ChromeCastDiscovery getChromeCastDiscovery() {
- return ((ChromeCastService) getContext()).getChromeCastDiscovery();
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastConstants.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastConstants.java
deleted file mode 100644
index 32ca46290b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastConstants.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- ChromeCastConstants.java
- Copyright (c) 2015 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.profile;
-
-/**
- * Constants for ChromeCast Receiver App Interface.
- * @author NTT DOCOMO, INC.
- */
-interface ChromeCastConstants {
-
- /** Parameter key: {@value}. */
- String KEY_FUNCTION = "function";
-
- /** Parameter key: {@value}. */
- String KEY_MODE = "mode";
-
- /** Parameter key: {@value}. */
- String KEY_URL = "url";
-
- /** Parameter key: {@value}. */
- String KEY_X = "x";
-
- /** Parameter key: {@value}. */
- String KEY_Y = "y";
-
- /** Parameter key: {@value}. */
- String KEY_TYPE = "type";
-
- /** Parameter key: {@value}. */
- String KEY_MESSAGE = "message";
-
- /** Function type: {@value}. */
- String FUNCTION_POST_NOTIFICATION = "write";
-
- /** Function type: {@value}. */
- String FUNCTION_DELETE_NOTIFICATION = "clear";
-
- /** Function type: {@value}. */
- String FUNCTION_POST_IMAGE = "canvas_draw";
-
- /** Function type: {@value}. */
- String FUNCTION_DELETE_IMAGE = "canvas_delete";
-
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastMediaPlayerProfile.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastMediaPlayerProfile.java
deleted file mode 100755
index a7ce2da356..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastMediaPlayerProfile.java
+++ /dev/null
@@ -1,1320 +0,0 @@
-/*
- ChromeCastMediaPlayerProfile.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.profile;
-
-import android.Manifest;
-import android.content.ContentResolver;
-import android.content.ContentUris;
-import android.content.Intent;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.provider.MediaStore;
-import androidx.annotation.NonNull;
-
-import com.google.android.gms.cast.MediaStatus;
-
-import org.deviceconnect.android.activity.PermissionUtility;
-import org.deviceconnect.android.deviceplugin.chromecast.ChromeCastService;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastDiscovery;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastHttpServer;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastMediaPlayer;
-import org.deviceconnect.android.deviceplugin.chromecast.core.MediaFile;
-import org.deviceconnect.android.deviceplugin.chromecast.core.MediaStoreContent;
-import org.deviceconnect.android.event.EventError;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.MediaPlayerProfile;
-import org.deviceconnect.android.profile.api.DConnectApi;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * MediaPlayer プロファイル (Chromecast).
- *
- * Chromecastのメディア操作を提供する
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastMediaPlayerProfile extends MediaPlayerProfile {
-
- /** イベントの登録・解除に失敗したときのエラーコード. */
- private static final int ERROR_VALUE_IS_NULL = 100;
- private static final String SAMPLE_URL = "https://github.com/DeviceConnect/DeviceConnect-Android/wiki/sphero_demo.MOV";
- /** 1ミリ秒. */
- private static final int MILLISECOND = 1000;
- /** Chromecastの再生状態がバッファリング中であることを表す. */
- private static final String MESSAGE_BUFFERING = "buffering";
- /** Chromecastの再生状態がstop状態であることを表す. */
- private static final String MESSAGE_STOP = "stop";
- /** Chromecastの再生状態がpause状態であることを表す. */
- private static final String MESSAGE_PAUSED = "pause";
- /** Chromecastの再生状態がplay状態であることを表す. */
- private static final String MESSAGE_PALYING = "play";
- /** Chromecastの再生状態がunknownであることを表す. */
- private static final String MESSAGE_UNKNOWN = "unknown";
- /** Chromecastが有効になっていない時のエラーメッセージ. */
- private static final String ERROR_MESSAGE_DEVICE_NOT_ENABLE = "Device is not enable";
- /** Chromecastに再生するメディアファイルが設定されていない時のエラーメッセージ. */
- private static final String ERROR_MESSAGE_MEDIA_NOT_SELECTED = "Media is not selected";
- /** Chromecastの再生状態がない場合のエラーメッセージ. */
- private static final String ERROR_MESSAGE_PLAYSTATE_IS_NOT = "Playstate is not";
- /** メディアファイルのPlay時のエラーメッセージ. */
- private static final String ERROR_MESSAGE_MEDIA_PLAY = ERROR_MESSAGE_PLAYSTATE_IS_NOT
- + " " + MESSAGE_STOP + " or " + MESSAGE_PAUSED;
- /** メディアファイルのResume時のエラーメッセージ. */
- private static final String ERROR_MESSAGE_MEDIA_RESUME = ERROR_MESSAGE_PLAYSTATE_IS_NOT
- + " " + MESSAGE_PAUSED;
- /** メディアファイルのStop時のエラーメッセージ. */
- private static final String ERROR_MESSAGE_MEDIA_STOP = ERROR_MESSAGE_PLAYSTATE_IS_NOT
- + " " + MESSAGE_PALYING + " or " + MESSAGE_PAUSED + " or " + MESSAGE_BUFFERING;
- /** メディアファイルのPause時のエラーメッセージ. */
- private static final String ERROR_MESSAGE_MEDIA_PAUSE = ERROR_MESSAGE_PLAYSTATE_IS_NOT
- + " " + MESSAGE_PALYING;
- /** メディアファイルがMute設定時のエラーメッセージ. */
- private static final String ERROR_MESSAGE_MEDIA_MUTE = ERROR_MESSAGE_PLAYSTATE_IS_NOT
- + " " + MESSAGE_PALYING + " or " + MESSAGE_PAUSED;
- /** メディアファイルのVolume変更時のエラーメッセージ. */
- private static final String ERROR_MESSAGE_MEDIA_VOLUME = ERROR_MESSAGE_MEDIA_MUTE;
- /** メディアファイルのSeek変更時のエラーメッセージ. */
- private static final String ERROR_MESSAGE_MEDIA_SEEK = ERROR_MESSAGE_MEDIA_MUTE;
-
- /** メディア情報の{@link java.util.Comparator}のマップ. */
- private static final Map COMPARATORS = new HashMap();
-
- /** 比較をしない{@link java.util.Comparator}. */
- private static final Comparator NOT_COMPARATOR = new Comparator() {
- @Override
- public int compare(final Bundle a, final Bundle b) {
- return 0;
- }
- };
-
- static {
- COMPARATORS.put(PARAM_TYPE, new ParamComparator(PARAM_TYPE));
- COMPARATORS.put(PARAM_LANGUAGE, new ParamComparator(PARAM_LANGUAGE));
- COMPARATORS.put(PARAM_MEDIA_ID, new ParamComparator(PARAM_MEDIA_ID));
- COMPARATORS.put(PARAM_MIME_TYPE, new ParamComparator(PARAM_MIME_TYPE));
- COMPARATORS.put(PARAM_TITLE, new ParamComparator(PARAM_TITLE));
- COMPARATORS.put(PARAM_DURATION, new ParamComparator(PARAM_DURATION));
- }
-
- public ChromeCastMediaPlayerProfile() {
- addApi(mGetMediaApi);
- addApi(mPutMediaApi);
- addApi(mGetSeekApi);
- addApi(mPutSeekApi);
- addApi(mGetVolumeApi);
- addApi(mPutMuteApi);
- addApi(mGetMuteApi);
- addApi(mDeleteMuteApi);
- addApi(mPutPauseApi);
- addApi(mPutPlayApi);
- addApi(mPutResumeApi);
- addApi(mPutStopApi);
- addApi(mPutVolumeApi);
- addApi(mPutOnStatusChangeApi);
- addApi(mDeleteOnStatusChangeApi);
- addApi(mGetMediaListApi);
- addApi(mGetPlayStatusApi);
- }
-
- /**
- * 指定したパラメータに対する{@link java.util.Comparator}を返す.
- *
- * @param paramName パラメータ名
- * @param isAsc 昇順である場合はtrue、そうでなければfalse
- * @return {@link java.util.Comparator}
- */
- private static Comparator findComparator(final String paramName, final boolean isAsc) {
- ParamComparator comparator = COMPARATORS.get(paramName);
- if (comparator != null) {
- comparator.setOrder(isAsc);
- return comparator;
- }
- return NOT_COMPARATOR;
- }
-
- /**
- * 再生状態を文字列に変換する.
- *
- * @param playState 再生状態
- * @return 再生状態の文字列を返す
- */
- public String getPlayStatus(final int playState) {
- switch (playState) {
- case MediaStatus.PLAYER_STATE_BUFFERING:
- return MESSAGE_BUFFERING;
- case MediaStatus.PLAYER_STATE_IDLE:
- return MESSAGE_STOP;
- case MediaStatus.PLAYER_STATE_PAUSED:
- return MESSAGE_PAUSED;
- case MediaStatus.PLAYER_STATE_PLAYING:
- return MESSAGE_PALYING;
- case MediaStatus.PLAYER_STATE_UNKNOWN:
- default:
- return MESSAGE_UNKNOWN;
- }
- }
-
- /**
- * サービスからChromeCastMediaPlayerを取得する.
- * @return ChromeCastMediaPlayer
- */
- private ChromeCastMediaPlayer getChromeCastMediaPlayer() {
- return ((ChromeCastService) getContext()).getChromeCastMediaPlayer();
- }
- /**
- * サービスからChromeCastDiscoveryrを取得する.
- * @return ChromeCastDiscovery
- */
- private ChromeCastDiscovery getChromeCastDiscovery() {
- return ((ChromeCastService) getContext()).getChromeCastDiscovery();
- }
- /**
- * デバイスが有効か否かを返す .
- * デバイスが無効の場合、レスポンスにエラーを設定する
- *
- * @param response レスポンス
- * @param app ChromeCastMediaPlayer
- * @return デバイスが有効か否か(有効: true, 無効: false)
- */
- private boolean isDeviceEnable(final Intent response, final ChromeCastMediaPlayer app) {
- if (!app.isDeviceEnable()) {
- MessageUtils.setIllegalDeviceStateError(response, ERROR_MESSAGE_DEVICE_NOT_ENABLE);
- return false;
- }
- return true;
- }
-
- /**
- * メディアの状態を取得する.
- * @param response レスポンス
- * @param app ChromeCastMediaPlayer
- * @return デバイスが有効か否か(有効: {@link MediaStatus}, 無効: null)
- */
- private MediaStatus getMediaStatus(final Intent response, final ChromeCastMediaPlayer app) {
- MediaStatus status = app.getMediaStatus();
- if (status == null) {
- MessageUtils.setIllegalDeviceStateError(response, ERROR_MESSAGE_MEDIA_NOT_SELECTED);
- }
- return status;
- }
-
- private final DConnectApi mPutPlayApi = new PutApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_PLAY;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId,
- (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- ChromeCastMediaPlayer app = getChromeCastMediaPlayer();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
-
- MediaStatus status = getMediaStatus(response, app);
- if (status == null) {
- sendResponse(response);
- return;
- }
-
- if (status.getPlayerState() == MediaStatus.PLAYER_STATE_PLAYING) {
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- return;
- }
- if (status.getPlayerState() == MediaStatus.PLAYER_STATE_IDLE) {
- app.play(response);
- } else if (status.getPlayerState() == MediaStatus.PLAYER_STATE_PAUSED) {
- app.resume(response);
- } else {
- MessageUtils.setIllegalDeviceStateError(response, ERROR_MESSAGE_MEDIA_PLAY);
- sendResponse(response);
- }
- });
- return false;
- }
- };
- private final DConnectApi mPutResumeApi = new PutApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_RESUME;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId, (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- } ChromeCastMediaPlayer app = getChromeCastMediaPlayer();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
- MediaStatus status = getMediaStatus(response, app);
- if (status == null) {
- sendResponse(response);
- return;
- }
-
- if (status.getPlayerState() == MediaStatus.PLAYER_STATE_PLAYING) {
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- return;
- }
- if (status.getPlayerState() == MediaStatus.PLAYER_STATE_PAUSED) {
- app.resume(response);
- } else {
- MessageUtils.setIllegalDeviceStateError(response, ERROR_MESSAGE_MEDIA_RESUME);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
-
- private final DConnectApi mPutStopApi = new PutApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_STOP;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId, (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- } ChromeCastMediaPlayer app = getChromeCastMediaPlayer();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
- MediaStatus status = getMediaStatus(response, app);
- if (status == null) {
- sendResponse(response);
- return;
- }
-
- if (status.getPlayerState() == MediaStatus.PLAYER_STATE_IDLE) {
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- return;
- }
- if (status.getPlayerState() == MediaStatus.PLAYER_STATE_PLAYING
- || status.getPlayerState() == MediaStatus.PLAYER_STATE_PAUSED
- || status.getPlayerState() == MediaStatus.PLAYER_STATE_BUFFERING) {
- app.stop(response);
- } else {
- MessageUtils.setIllegalDeviceStateError(response, ERROR_MESSAGE_MEDIA_STOP);
- sendResponse(response);
- }
- });
- return false;
- }
- };
- private final DConnectApi mPutPauseApi = new PutApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_PAUSE;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId, (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- } ChromeCastMediaPlayer app = getChromeCastMediaPlayer();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
- MediaStatus status = getMediaStatus(response, app);
- if (status == null) {
- sendResponse(response);
- return;
- }
-
- if (status.getPlayerState() == MediaStatus.PLAYER_STATE_PAUSED) {
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- return;
- }
- app.pause(response);
- });
- return false;
- }
- };
- /**
- * メディアをミュートする .
- * エラーの場合、レスポンスにエラーを設定する
- *
- * @param request リクエスト
- * @param response レスポンス
- * @param serviceId サービスID
- * @param mute ミュートするか否か(true: ミュートON, false: ミュートOFF)
- * @return result 結果を返す(true: 成功, false: 失敗)
- */
- private boolean setMute(final Intent request, final Intent response,
- final String serviceId, final boolean mute) {
- ((ChromeCastService) getContext()).connectChromeCast(serviceId, new ChromeCastService.Callback() {
-
- @Override
- public void onResponse(final boolean connected) {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- ChromeCastMediaPlayer app = getChromeCastMediaPlayer();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
- MediaStatus status = getMediaStatus(response, app);
- if (status == null) {
- sendResponse(response);
- return;
- }
- app.setMute(response, mute);
- }
- });
- return false;
- }
-
- private final DConnectApi mPutMuteApi = new PutApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_MUTE;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- return setMute(request, response, serviceId, true);
- }
- };
-
- private final DConnectApi mDeleteMuteApi = new DeleteApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_MUTE;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- return setMute(request, response, serviceId, false);
- }
- };
-
- private final DConnectApi mGetMuteApi = new GetApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_MUTE;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId, (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- ChromeCastMediaPlayer app = getChromeCastMediaPlayer();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
- if (getMediaStatus(response, app) == null) {
- sendResponse(response);
- return;
- }
-
- int mute = app.getMute(response);
- if (mute == 1) {
- setMute(response, true);
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- } else if (mute == 0) {
- setMute(response, false);
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
- });
- return false;
-
- }
- };
-
- private final DConnectApi mPutVolumeApi = new PutApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_VOLUME;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- final Double volume = MediaPlayerProfile.getVolume(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId,
- (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- ChromeCastMediaPlayer app = getChromeCastMediaPlayer();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
- MediaStatus status = getMediaStatus(response, app);
- if (status == null) {
- sendResponse(response);
- return;
- }
-
- if (volume == null) {
- MessageUtils.setInvalidRequestParameterError(response);
- } else if (0.0 > volume || volume > 1.0) {
- MessageUtils.setInvalidRequestParameterError(response);
- } else {
- app.setVolume(response, volume);
- return;
- }
- sendResponse(response);
- });
- return false;
- }
- };
-
- private final DConnectApi mGetVolumeApi = new GetApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_VOLUME;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId,
- (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- ChromeCastMediaPlayer app = getChromeCastMediaPlayer();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
- if (getMediaStatus(response, app) == null) {
- sendResponse(response);
- return;
- }
-
- double volume = app.getVolume(response);
- if (volume >= 0) {
- setVolume(response, volume);
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- } else {
- MessageUtils.setIllegalDeviceStateError(response);
- sendResponse(response);
- }
- });
- return false;
-
- }
- };
-
- private final DConnectApi mPutSeekApi = new PutApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_SEEK;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- final Integer pos = MediaPlayerProfile.getPos(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId, (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- ChromeCastMediaPlayer app = getChromeCastMediaPlayer();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
-
- if (pos == null) {
- MessageUtils.setInvalidRequestParameterError(response);
- sendResponse(response);
- } else {
- MediaStatus status = getMediaStatus(response, app);
- if (status == null) {
- sendResponse(response);
- return;
- }
-
- long posMillisecond = pos * MILLISECOND;
- if (0 > posMillisecond || posMillisecond > status.getMediaInfo().getStreamDuration()) {
- MessageUtils.setInvalidRequestParameterError(response);
- sendResponse(response);
- return;
- }
- app.setSeek(response, posMillisecond);
- }
- });
- return false;
-
- }
- };
- private final DConnectApi mGetSeekApi = new GetApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_SEEK;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId, (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- ChromeCastMediaPlayer app = getChromeCastMediaPlayer();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
- MediaStatus status = getMediaStatus(response, app);
- if (status == null) {
- sendResponse(response);
- return;
- }
- long streamPosition = status.getStreamPosition();
- long posSecond = app.getSeek(response) / MILLISECOND;
- if (posSecond > 0) {
- setPos(response, (int) posSecond);
- } else if (streamPosition > 0) {
- setPos(response, (int) streamPosition);
- } else {
- setPos(response, 0);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
-
- });
- return false;
- }
- };
-
- private final DConnectApi mGetPlayStatusApi = new GetApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_PLAY_STATUS;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
-
- ((ChromeCastService) getContext()).connectChromeCast(serviceId,
- (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- ChromeCastMediaPlayer app = getChromeCastMediaPlayer();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
-
- MediaStatus status = getMediaStatus(response, app);
- if (status == null) {
- sendResponse(response);
- return;
- }
- String playStatus = getPlayStatus(status.getPlayerState());
- response.putExtra(MediaPlayerProfile.PARAM_STATUS, playStatus);
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- });
- return false;
- }
- };
-
-
- private final DConnectApi mGetMediaApi = new GetApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_MEDIA;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- final String mediaId = MediaPlayerProfile.getMediaId(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId,(connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- if (mediaId == null) {
- MessageUtils.setInvalidRequestParameterError(response, "mediaId is null.");
- sendResponse(response);
- return;
- }
- if (mediaId.equals("")) {
- MessageUtils.setInvalidRequestParameterError(response, "mediaId is empty.");
- sendResponse(response);
- return;
- }
- Bundle media = getMedia(mediaId);
- for (String key : media.keySet()) {
- Object value = media.get(key);
- if (value instanceof String) {
- response.putExtra(key, (String) value);
- } else if (value instanceof String[]) {
- response.putExtra(key, (String[]) value);
- } else if (value instanceof Long) {
- response.putExtra(key, (Long) value);
- } else if (value instanceof Bundle) {
- response.putExtra(key, (Bundle) value);
- }
- }
-
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- });
- return false;
-
- }
- };
-
- /**
- * 指定したURIからkeyとvalueに基づき、Cursorを取得する.
- *
- * @param uri URI
- * @param key キー
- * @param value バリュー
- * @return cursor カーソル
- */
- private Cursor getCursorFrom(final Uri uri, final String key, final String value) {
- Cursor cursor = getContext().getApplicationContext()
- .getContentResolver()
- .query(uri, null, key + "=" + value + "", null, null);
- if (cursor != null) {
- if (cursor.moveToFirst()) {
- if (cursor.getCount() == 1) {
- return cursor;
- }
- cursor.close();
- }
- }
- return null;
- }
-
- /**
- * 指定したメディアをローカルサーバ上で公開する.
- *
- * @param mediaId メディアID
- * @return placeHolderUrl 代用URL
- */
- private String exposeMedia(final long mediaId) {
- Uri targetUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
- Uri mediaUri = ContentUris.withAppendedId(targetUri, mediaId);
-
- ChromeCastHttpServer server = ((ChromeCastService) getContext())
- .getChromeCastHttpServer();
- return server.exposeFile(new MediaStoreContent(mediaUri));
- }
-
- private final DConnectApi mPutMediaApi = new PutApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_MEDIA;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- final String mediaId = MediaPlayerProfile.getMediaId(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId,(connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- if (mediaId == null) {
- MessageUtils.setInvalidRequestParameterError(response, "mediaId is null.");
- sendResponse(response);
- return;
- }
- if (mediaId.equals("")) {
- MessageUtils.setInvalidRequestParameterError(response, "mediaId is empty.");
- sendResponse(response);
- return;
- }
- if (!hasMedia(mediaId)) {
- MessageUtils.setInvalidRequestParameterError(response, "media is not found.");
- sendResponse(response);
- return;
- }
-
- ChromeCastMediaPlayer app = getChromeCastMediaPlayer();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
-
- String url = null;
- String title = null;
- Integer mId = -1;
-
- try {
- mId = Integer.parseInt(mediaId);
- } catch (NumberFormatException e) {
- url = mediaId;
- }
-
- if (url == null) {
- Cursor cursor = getCursorFrom(
- MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
- MediaStore.Video.Media._ID, mediaId);
- try {
- if (cursor == null) {
- response.putExtra(DConnectMessage.EXTRA_VALUE, "mediaId is not exist");
- setResult(response, DConnectMessage.RESULT_ERROR);
- sendResponse(response);
- return;
- } else {
- title = cursor.getString(cursor
- .getColumnIndex(MediaStore.Video.Media.TITLE));
- url = exposeMedia(mId);
- if (url == null) {
- response.putExtra(DConnectMessage.EXTRA_VALUE, "url is null");
- setResult(response, DConnectMessage.RESULT_ERROR);
- sendResponse(response);
- return;
-
- }
- }
- } finally {
- if (cursor != null) {
- cursor.close();
- }
- }
- }
-
- if (title == null) {
- title = "TITLE";
- }
- app.load(response, url, title);
- });
- return false;
- }
- };
-
- /**
- * Uriからパスを取得する.
- *
- * @param mUri Uri
- * @return パス
- */
- private String getPathFromUri(final Uri mUri) {
- String filename = null;
- Cursor c = this.getContext().getContentResolver().query(mUri, null, null, null, null);
- if (c != null) {
- c.moveToFirst();
- filename = c.getString(c.getColumnIndex(MediaStore.MediaColumns.DATA));
- c.close();
- }
- return filename;
- }
-
- /**
- * bundleにメディア情報を設定する.
- *
- * @param mediaType メディアタイプ
- * @param bundle バンドル
- * @param cursor カーソル
- */
- private void setMediaInformation(final String mediaType, final Bundle bundle,
- final Cursor cursor) {
- if (mediaType.equals("Video")) {
- setType(bundle, mediaType);
- setLanguage(bundle, cursor.getString(cursor
- .getColumnIndex(MediaStore.Video.Media.LANGUAGE)));
- setMediaId(bundle, cursor.getString(cursor
- .getColumnIndex(MediaStore.Video.Media._ID)));
- setMIMEType(bundle, cursor.getString(cursor
- .getColumnIndex(MediaStore.Video.Media.MIME_TYPE)));
- setTitle(bundle, cursor.getString(cursor
- .getColumnIndex(MediaStore.Video.Media.TITLE)));
- int duration = cursor.getInt(cursor
- .getColumnIndex(MediaStore.Video.Media.DURATION));
- if (duration < 0) {
- duration = 0;
- }
- setDuration(bundle, duration);
- Bundle creator = new Bundle();
- setCreator(creator, cursor.getString(cursor
- .getColumnIndex(MediaStore.Video.Media.ARTIST)));
- setCreators(bundle, new Bundle[] {creator});
-
- } else if (mediaType.equals("Audio")) {
- setType(bundle, "Music");
- setMediaId(bundle, cursor.getString(cursor
- .getColumnIndex(MediaStore.Audio.Media._ID)));
- setMIMEType(bundle, cursor.getString(cursor
- .getColumnIndex(MediaStore.Audio.Media.MIME_TYPE)));
- setTitle(bundle, cursor.getString(cursor
- .getColumnIndex(MediaStore.Audio.Media.TITLE)));
- int duration = cursor.getInt(cursor
- .getColumnIndex(MediaStore.Video.Media.DURATION));
- if (duration < 0) {
- duration = 0;
- }
- setDuration(bundle, duration);
- Bundle creator = new Bundle();
- setCreator(creator, cursor.getString(cursor
- .getColumnIndex(MediaStore.Audio.Media.ARTIST)));
- setRole(creator, cursor.getString(cursor
- .getColumnIndex(MediaStore.Audio.Media.COMPOSER)));
- setCreators(bundle, new Bundle[] {creator});
-
- } else if (mediaType.equals("Image")) {
- setType(bundle, mediaType);
- setMediaId(bundle, cursor.getString(cursor
- .getColumnIndex(MediaStore.Images.Media._ID)));
- setMIMEType(bundle, cursor.getString(cursor
- .getColumnIndex(MediaStore.Images.Media.MIME_TYPE)));
- setTitle(bundle, cursor.getString(cursor
- .getColumnIndex(MediaStore.Images.Media.TITLE)));
- Bundle creator = new Bundle();
- setCreators(bundle, new Bundle[] {creator});
- } else {
- setType(bundle, mediaType);
- }
- }
-
- /**
- * メディア情報をリストアップする.
- *
- * @param mediaType メディアタイプ
- * @param list リスト
- * @param filter フィルター
- * @param orderBy ソートオーダー
- */
- private void listupMedia(final String mediaType, final List list, final String filter,
- final String orderBy) {
- Uri uri = null;
-
- if (mediaType.equals("Video")) {
- uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
- } else if (mediaType.equals("Audio")) {
- uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
- } else if (mediaType.equals("Image")) {
- uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
- }
- ContentResolver resolver = this.getContext().getApplicationContext().getContentResolver();
- Cursor cursor = resolver.query(uri, null, filter, null, orderBy);
- if (cursor != null) {
- if (cursor.moveToFirst()) {
- do {
- Bundle medium = new Bundle();
- setMediaInformation(mediaType, medium, cursor);
- list.add(medium);
- } while (cursor.moveToNext());
- }
- cursor.close();
- }
- }
-
- /**
- * メディア情報をリストアップする.
- *
- * @param mediaType メディアタイプ
- * @param list リスト
- * @param query クエリー
- * @param mimeType MIMEタイプ
- * @param orders ソートオーダー
- */
- private void listupMedia(final String mediaType, final List list, final String query,
- final String mimeType, final String[] orders) {
- String filter = "";
- String orderBy;
-
- if (mimeType != null) {
- String key = null;
- if (mediaType.equals("Video")) {
- key = MediaStore.Video.Media.MIME_TYPE;
- } else if (mediaType.equals("Audio")) {
- key = MediaStore.Audio.Media.MIME_TYPE;
- } else if (mediaType.equals("Image")) {
- key = MediaStore.Images.Media.MIME_TYPE;
- }
- filter = "" + key + "='" + mimeType + "'";
- }
- if (query != null) {
- if (!filter.equals("")) {
- filter += " AND ";
- }
- if (mediaType.equals("Video")) {
- filter += "(" + MediaStore.Video.Media.TITLE + " LIKE '%" + query + "%')";
- } else if (mediaType.equals("Audio")) {
- filter += "(" + MediaStore.Audio.Media.TITLE + " LIKE '%" + query + "%'";
- filter += " OR " + MediaStore.Audio.Media.COMPOSER + " LIKE '%" + query + "%')";
- } else if (mediaType.equals("Image")) {
- filter += "(" + MediaStore.Images.Media.TITLE + " LIKE '%" + query + "%')";
- }
- }
-
- if (orders != null) {
- orderBy = orders[0] + " " + orders[1];
- } else {
- orderBy = "title asc";
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- final String filt = filter;
- final String order = orderBy;
- PermissionUtility.requestPermissions(getContext(), new Handler(Looper.getMainLooper()),
- new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
- new PermissionUtility.PermissionRequestCallback() {
- @Override
- public void onSuccess() {
-
- listupMedia(mediaType, list, filt, order);
- }
-
- @Override
- public void onFail(@NonNull String deniedPermission) {
- }
- });
- } else {
- listupMedia(mediaType, list, filter, orderBy);
- }
- }
-
- /**
- * デバイス内のメディアを全検索する.
- * @param query 検索するタイトル
- * @param mimeType マイムタイプ
- * @param orders ソート
- * @return 検索結果
- */
- private List findAllMedia(final String query, final String mimeType,
- final String[] orders) {
- List list = new ArrayList();
- listupMedia("Video", list, query, mimeType, orders);
- Bundle medium = new Bundle();
- setType(medium, "Video");
- setLanguage(medium, "Language");
- setMediaId(medium, SAMPLE_URL);
- setMIMEType(medium, "video/quicktime");
- setTitle(medium, "Title: Sample");
- setDuration(medium, 9999);
- Bundle creatorVideo = new Bundle();
- setCreator(creatorVideo, "Creator: Sample");
- setCreators(medium, new Bundle[]{creatorVideo});
- list.add(medium);
-
- return list;
- }
-
- /**
- * 指定したメディアの情報を取得する.
- * @param mediaId メディアID
- * @return メディア情報
- */
- private Bundle getMedia(final String mediaId) {
- List list = findAllMedia(null, null, null);
- for (Bundle b : list) {
- String id = b.getString(PARAM_MEDIA_ID);
- if (id.equals(mediaId)) {
- return b;
- }
- }
- return null;
- }
-
- /**
- * 指定したメディアを保有しているかどうかをチェックする.
- * @param mediaId メディアID
- * @return 保有している場合はtrue、そうでない場合はfalse
- */
- private boolean hasMedia(final String mediaId) {
- return getMedia(mediaId) != null;
- }
-
- private final DConnectApi mGetMediaListApi = new GetApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_MEDIA_LIST;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- final String query = MediaPlayerProfile.getQuery(request);
- final String mimeType = MediaPlayerProfile.getMIMEType(request);
- final String[] orders = MediaPlayerProfile.getOrder(request);
- final Integer offset = MediaPlayerProfile.getOffset(request);
- final Integer limit = MediaPlayerProfile.getLimit(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId,(connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- // パラメータの型チェック
- Bundle b = request.getExtras();
- if (b.getString(PARAM_LIMIT) != null) {
- if (parseInteger(b.get(PARAM_LIMIT)) == null) {
- MessageUtils.setInvalidRequestParameterError(response);
- sendResponse(response);
- return;
- }
- }
- if (b.getString(PARAM_OFFSET) != null) {
- if (parseInteger(b.get(PARAM_OFFSET)) == null) {
- MessageUtils.setInvalidRequestParameterError(response);
- sendResponse(response);
- return;
- }
- }
-
- // パラメータの範囲チェック
- if (orders != null && orders.length != 2) {
- MessageUtils.setInvalidRequestParameterError(response, "order is invalid.");
- sendResponse(response);
- return;
- }
- final int offsetValue;
- if (offset != null) {
- if (offset >= 0) {
- offsetValue = offset;
- } else {
- MessageUtils.setInvalidRequestParameterError(response, "offset is negative.");
- sendResponse(response);
- return;
- }
- } else {
- offsetValue = 0;
- }
- if (limit != null && limit < 0) {
- MessageUtils.setInvalidRequestParameterError(response, "limit is negative.");
- sendResponse(response);
- return;
- }
-
- Comparator comparator = null;
- if (orders != null) {
- boolean isAsc;
- Order o = Order.getInstance(orders[1]);
- switch (o) {
- case ASC:
- isAsc = true;
- break;
- case DSEC:
- isAsc = false;
- break;
- default:
- MessageUtils.setInvalidRequestParameterError(response, "order is invalid.");
- sendResponse(response);
- return;
- }
- comparator = findComparator(orders[0], isAsc);
- }
- // メディアリストのソート
- List foundMedia = findAllMedia(query, mimeType, orders);
- if (comparator != null) {
- Collections.sort(foundMedia, comparator);
- }
-
- final int limitValue = limit != null ? limit : foundMedia.size();
- int endIndex = offsetValue + limitValue;
- if (endIndex > foundMedia.size()) {
- endIndex = foundMedia.size();
- }
-
- List result;
- if (offsetValue < foundMedia.size()) {
- result = foundMedia.subList(offsetValue, endIndex);
- } else {
- result = new ArrayList();
- }
-
- setCount(response, result.size());
- setMedia(response, result.toArray(new Bundle[result.size()]));
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- });
- return false;
- }
- };
-
- private final DConnectApi mPutOnStatusChangeApi = new PutApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_ON_STATUS_CHANGE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId,(connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (error == EventError.NONE) {
- ((ChromeCastService) getContext()).registerOnStatusChange(response,
- serviceId);
- } else {
- MessageUtils.setError(response, ERROR_VALUE_IS_NULL, "Can not register event.");
- sendResponse(response);
- }
- });
- return false;
- }
- };
- private final DConnectApi mDeleteOnStatusChangeApi = new DeleteApi() {
- @Override
- public String getAttribute() {
- return MediaPlayerProfile.ATTRIBUTE_ON_STATUS_CHANGE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId, (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- EventError error = EventManager.INSTANCE.removeEvent(request);
- if (error == EventError.NONE) {
- ((ChromeCastService) getContext()).unregisterOnStatusChange(response);
- } else {
- MessageUtils.setError(response, ERROR_VALUE_IS_NULL, "Can not unregister event.");
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
-
- /**
- * パラメータ比較クラス.
- */
- private static class ParamComparator implements Comparator {
-
- /** 比較するパラメータ名. */
- private final String mParamName;
- /** 昇順であることを示すフラグ. */
- private boolean mIsAsc;
-
- /**
- * コンストラクタ.
- *
- * @param paramName パラメータ名
- */
- ParamComparator(final String paramName) {
- mParamName = paramName;
- }
-
- /**
- * ソート順を設定する.
- * @param isAsc 昇順である場合はtrue、そうでなければfalse
- */
- public void setOrder(final boolean isAsc) {
- mIsAsc = isAsc;
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public int compare(final Bundle a, final Bundle b) {
- Object va = a.get(mParamName);
- Object vb = b.get(mParamName);
- if (!mIsAsc) {
- Object vt = va;
- va = vb;
- vb = vt;
- }
- if (va == null && vb == null) {
- return 0;
- }
- if (va != null && vb == null) {
- return -1;
- }
- if (va == null && vb != null) {
- return 1;
- }
- if (va.getClass() != vb.getClass()) {
- return 0;
- }
- if (va instanceof Comparable && !(vb instanceof Comparable)) {
- return -1;
- }
- if (!(va instanceof Comparable) && vb instanceof Comparable) {
- return 1;
- }
- if (!(va instanceof Comparable) && !(vb instanceof Comparable)) {
- return 0;
- }
- if (va instanceof Comparable && !(vb instanceof Comparable)) {
- return -1;
- }
- if (!(va instanceof Comparable) && vb instanceof Comparable) {
- return 1;
- }
- return ((Comparable) va).compareTo(vb);
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastNotificationProfile.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastNotificationProfile.java
deleted file mode 100755
index 4cb5f0c74f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastNotificationProfile.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- ChromeCastNotificationProfile.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.chromecast.ChromeCastService;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastMessage;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.NotificationProfile;
-import org.deviceconnect.android.profile.api.DConnectApi;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.message.DConnectMessage;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * Notification プロファイル (Chromecast).
- *
- * Chromecastのノーティフィケーションの操作機能を提供する
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastNotificationProfile extends NotificationProfile implements ChromeCastConstants {
- /** Chromecastが無効になっているときのエラーメッセージ. */
- private static final String ERROR_MESSAGE_DEVICE_NOT_ENABLED = "Chromecast is not enabled.";
-
- /** 通知ID. 全リクエストに対して共通. */
- private static final String COMMON_ID = "dConnectDeviceChromeCast";
-
- public ChromeCastNotificationProfile() {
- addApi(mPostNotificationApi);
- addApi(mDeleteNotificationApi);
- }
-
-
- /**
- * デバイスが有効か否かを返す .
- * デバイスが無効の場合、レスポンスにエラーを設定する
- *
- * @param response レスポンス
- * @param app ChromeCastMediaPlayer
- * @return デバイスが有効か否か(有効: true, 無効: false)
- */
- private boolean isDeviceEnable(final Intent response, final ChromeCastMessage app) {
- if (!app.isDeviceEnable()) {
- MessageUtils.setIllegalDeviceStateError(response, ERROR_MESSAGE_DEVICE_NOT_ENABLED);
- setResult(response, DConnectMessage.RESULT_ERROR);
- return false;
- }
- return true;
- }
-
- private final DConnectApi mPostNotificationApi = new PostApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_NOTIFY;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- final String body = NotificationProfile.getBody(request);
- final NotificationType type = NotificationProfile.getType(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId, (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- ChromeCastMessage app = ((ChromeCastService) getContext()).getChromeCastMessage();
- if (body == null) {
- MessageUtils.setInvalidRequestParameterError(response, "body is null");
- response.putExtra(DConnectMessage.EXTRA_RESULT, DConnectMessage.RESULT_ERROR);
- sendResponse(response);
- return;
- }
- switch (type) {
- case PHONE:
- break;
- case MAIL:
- break;
- case SMS:
- break;
- case EVENT:
- break;
- default:
- MessageUtils.setInvalidRequestParameterError(response, "type is null or invalid");
- response.putExtra(DConnectMessage.EXTRA_RESULT, DConnectMessage.RESULT_ERROR);
- sendResponse(response);
- return;
- }
-
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
- try {
- JSONObject json = new JSONObject();
- json.put(KEY_FUNCTION, FUNCTION_POST_NOTIFICATION);
- json.put(KEY_TYPE, type.getValue());
- json.put(KEY_MESSAGE, body);
- setNotificationId(response, COMMON_ID);
- app.sendMessage(response, json.toString());
- } catch (JSONException e) {
- MessageUtils.setUnknownError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
- private final DConnectApi mDeleteNotificationApi = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_NOTIFY;
- }
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String serviceId = getServiceID(request);
- final String notificationId = NotificationProfile.getNotificationId(request);
- ((ChromeCastService) getContext()).connectChromeCast(serviceId, (connected) -> {
- if (!connected) {
- MessageUtils.setIllegalDeviceStateError(response, "The chromecast is not in local network.");
- sendResponse(response);
- return;
- }
- if (notificationId == null || !COMMON_ID.equals(notificationId)) {
- MessageUtils.setInvalidRequestParameterError(response, "notificationId is invalid.");
- sendResponse(response);
- return;
- }
- ChromeCastMessage app = ((ChromeCastService) getContext()).getChromeCastMessage();
- if (!isDeviceEnable(response, app)) {
- sendResponse(response);
- return;
- }
- try {
- JSONObject json = new JSONObject();
- json.put(KEY_FUNCTION, FUNCTION_DELETE_NOTIFICATION);
- app.sendMessage(response, json.toString());
- } catch (JSONException e) {
- MessageUtils.setUnknownError(response);
- sendResponse(response);
- }
- });
- return false;
- }
- };
-
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastServiceDiscoveryProfile.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastServiceDiscoveryProfile.java
deleted file mode 100755
index b742165ef9..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastServiceDiscoveryProfile.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- ChromeCastServiceDiscoveryProfile.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.profile;
-
-import android.content.Intent;
-
-import com.google.android.gms.cast.CastDevice;
-
-import org.deviceconnect.android.deviceplugin.chromecast.ChromeCastDeviceService;
-import org.deviceconnect.android.deviceplugin.chromecast.ChromeCastService;
-import org.deviceconnect.android.deviceplugin.chromecast.R;
-import org.deviceconnect.android.deviceplugin.chromecast.core.ChromeCastDiscovery;
-import org.deviceconnect.android.profile.ServiceDiscoveryProfile;
-import org.deviceconnect.android.profile.api.DConnectApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.service.DConnectService;
-import org.deviceconnect.android.service.DConnectServiceProvider;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Network Service Discovery プロファイル (Chromecast).
- *
- * Chromecastの検索機能を提供する
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastServiceDiscoveryProfile extends ServiceDiscoveryProfile {
-
- /**
- * コンストラクタ.
- *
- * @param provider プロファイルプロバイダ
- */
- public ChromeCastServiceDiscoveryProfile(final DConnectServiceProvider provider) {
- super(provider);
- addApi(mServiceDiscoveryApi);
- }
-
- private final DConnectApi mServiceDiscoveryApi = new GetApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- ChromeCastDiscovery discovery = ((ChromeCastService) getContext()).getChromeCastDiscovery();
- List disappeared = getServiceProvider().getServiceList();
- for (int i = 0; i < discovery.getDeviceNames().size(); i++) {
-
- CastDevice cast = discovery.getDeviceNames().get(i);
- DConnectService castService = getServiceProvider().getService(cast.getDeviceId());
- if (castService == null) {
- castService = new ChromeCastDeviceService(cast);
- getServiceProvider().addService(castService);
- } else {
- for (int j = 0; j < disappeared.size(); j++) {
- DConnectService cache = disappeared.get(j);
- if (cache.getId().equals(castService.getId())) {
- disappeared.remove(j);
- break;
- }
- }
- }
- }
-
- // レスポンス作成.
- appendServiceList(response);
-
- return true;
- }
- };
-
- private String getDeviceName(final String name) {
- return getContext().getResources().getString(R.string.device_name, name);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastSystemProfile.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastSystemProfile.java
deleted file mode 100755
index ec4d5ea4f5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/ChromeCastSystemProfile.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- ChromeCastSystemProfile.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.profile;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.chromecast.setting.ChromeCastServiceListActivity;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.SystemProfile;
-import org.deviceconnect.android.profile.api.DConnectApi;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.message.DConnectMessage;
-
-/**
- * System プロファイル (Chromecast).
- *
- * Chromecastのシステム情報を提供する
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastSystemProfile extends SystemProfile {
- public ChromeCastSystemProfile() {
- addApi(mDeleteEventsApi);
- }
-
- @Override
- protected Class extends Activity> getSettingPageActivity(final Intent request, final Bundle param) {
- return ChromeCastServiceListActivity.class;
- }
-
- private final DConnectApi mDeleteEventsApi = new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_EVENTS;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String sessionKey = getSessionKey(request);
- if (sessionKey == null || sessionKey.length() == 0) {
- MessageUtils.setInvalidRequestParameterError(response);
- } else if (EventManager.INSTANCE.removeEvents(sessionKey)) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- MessageUtils.setUnknownError(response);
- }
-
- return true;
- }
- };
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/package-info.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/package-info.java
deleted file mode 100755
index e65082850c..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/profile/package-info.java
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- org.deviceconnect.android.deviceplugin.chromecast.profile
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-
-/**
- * Device Connect Chromecast DevicePlugin Profiles.
- */
-package org.deviceconnect.android.deviceplugin.chromecast.profile;
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastServiceListActivity.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastServiceListActivity.java
deleted file mode 100644
index cb6d5439c4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastServiceListActivity.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.deviceconnect.android.deviceplugin.chromecast.setting;
-
-import android.app.Activity;
-import android.content.res.TypedArray;
-import android.graphics.Color;
-import android.os.Bundle;
-import androidx.appcompat.widget.Toolbar;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-
-import org.deviceconnect.android.deviceplugin.chromecast.ChromeCastApplication;
-import org.deviceconnect.android.deviceplugin.chromecast.ChromeCastService;
-import org.deviceconnect.android.deviceplugin.chromecast.R;
-import org.deviceconnect.android.message.DConnectMessageService;
-import org.deviceconnect.android.service.DConnectService;
-import org.deviceconnect.android.ui.activity.DConnectServiceListActivity;
-
-/**
- * Chromecastサービス一覧画面.
- * @author NTT DOCOMO, INC.
- */
-
-public class ChromeCastServiceListActivity extends DConnectServiceListActivity {
-
- @Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Toolbar toolbar = new Toolbar(this);
- toolbar.setTitle(R.string.activity_service_list_title);
- toolbar.setTitleTextColor(Color.parseColor("#FFFFFF"));
- toolbar.setBackgroundColor(Color.parseColor("#00a0e9"));
- addContentView(toolbar, new Toolbar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
- toolbar.setNavigationIcon(R.drawable.close_icon);
- toolbar.setNavigationOnClickListener((view) -> {
- finish();
- });
- LinearLayout layout = findViewById(R.id.fragment_container);
- final TypedArray styledAttributes = getTheme().obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
- int actionBarSize = (int) styledAttributes.getDimension(0, 0);
- layout.setPadding(0, actionBarSize, 0, 0);
- }
-
- @Override
- protected Class extends DConnectMessageService> getMessageServiceClass() {
- return ChromeCastService.class;
- }
-
- @Override
- protected Class extends Activity> getSettingManualActivityClass() {
- return ChromeCastSettingFragmentActivity.class;
- }
- @Override
- public void onServiceRemoved(final DConnectService service) {
- super.onServiceRemoved(service);
- ChromeCastApplication application = (ChromeCastApplication) getApplication();
- if (application != null) {
- //ChromeCastのサービスが削除されたタイミングでChromeCastControllerを初期化する
- application.getController().reconnect();
-
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastSettingFragmentActivity.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastSettingFragmentActivity.java
deleted file mode 100755
index 54a3d82b84..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastSettingFragmentActivity.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- ChromeCastSettingFragmentActivity.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.setting;
-
-import android.os.Bundle;
-import android.os.Handler;
-import androidx.fragment.app.Fragment;
-import android.view.Menu;
-import android.view.MenuItem;
-
-import com.google.android.gms.cast.framework.CastButtonFactory;
-import com.google.android.gms.cast.framework.IntroductoryOverlay;
-
-import org.deviceconnect.android.deviceplugin.chromecast.R;
-
-import java.util.ArrayList;
-
-/**
- * チュートリアル画面(ステップ).
- *
- * 画面を作成する
- *
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastSettingFragmentActivity extends DConnectSettingCompatPageFragmentActivity {
-
- /** ページUI用Fragment. */
- private ArrayList mFragments;
- private MenuItem mediaRouteMenuItem;
- private IntroductoryOverlay mIntroductoryOverlay;
- /**
- * コンストラクタ.
- */
- public ChromeCastSettingFragmentActivity() {
- mFragments = new ArrayList<>();
- mFragments.add(new ChromeCastSettingFragmentPage1());
- mFragments.add(new ChromeCastSettingFragmentPage2());
- mFragments.add(new ChromeCastSettingFragmentPage3());
- }
- @Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
- @Override
- public int getPageCount() {
- return mFragments.size();
- }
-
- @Override
- public Fragment createPage(final int position) {
- return mFragments.get(position);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- getMenuInflater().inflate(R.menu.browse, menu);
- mediaRouteMenuItem = CastButtonFactory.setUpMediaRouteButton(this, menu,
- R.id.media_route_menu_item);
- showIntroductoryOverlay();
- return true;
- }
-
-
- /**
- * 説明を表示.
- */
- private void showIntroductoryOverlay() {
- if (mIntroductoryOverlay != null) {
- mIntroductoryOverlay.remove();
- }
- new Handler().postDelayed(() -> {
- if ((mediaRouteMenuItem != null) && mediaRouteMenuItem.isVisible()) {
- mIntroductoryOverlay = new IntroductoryOverlay.Builder(
- ChromeCastSettingFragmentActivity.this, mediaRouteMenuItem)
- .setTitleText(getString(R.string.introducing_cast))
- .setOverlayColor(R.color.primary)
- .setSingleTime()
- .setOnOverlayDismissedListener(
- () -> {
- mIntroductoryOverlay = null;
- })
- .build();
- mIntroductoryOverlay.show();
- }
- }, 500);
- }
-
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastSettingFragmentPage1.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastSettingFragmentPage1.java
deleted file mode 100755
index d806c9d09a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastSettingFragmentPage1.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- ChromeCastSettingFragmentPage1.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.setting;
-
-import android.os.Bundle;
-import androidx.fragment.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import org.deviceconnect.android.deviceplugin.chromecast.R;
-
-/**
- * チュートリアル画面.
- *
- * 画面を作成する
- *
- * Chromecastの接続
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastSettingFragmentPage1 extends Fragment {
- @Override
- public View onCreateView(final LayoutInflater inflater,
- final ViewGroup container, final Bundle savedInstanceState) {
- View root = inflater.inflate(R.layout.chromecast_settings_step_1, container, false);
- return root;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastSettingFragmentPage2.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastSettingFragmentPage2.java
deleted file mode 100755
index 7fc03eed14..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastSettingFragmentPage2.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- ChromeCastSettingFragmentPage2.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.setting;
-
-import android.os.Bundle;
-import androidx.fragment.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import org.deviceconnect.android.deviceplugin.chromecast.R;
-
-/**
- * チュートリアル画面.
- *
- * 画面を作成する
- *
- * 電源の接続
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastSettingFragmentPage2 extends Fragment {
- @Override
- public View onCreateView(final LayoutInflater inflater,
- final ViewGroup container, final Bundle savedInstanceState) {
- View root = inflater.inflate(R.layout.chromecast_settings_step_2, container, false);
- return root;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastSettingFragmentPage3.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastSettingFragmentPage3.java
deleted file mode 100755
index cf5fe22e8f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/ChromeCastSettingFragmentPage3.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- ChromeCastSettingFragmentPage3.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.setting;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import android.os.Bundle;
-import androidx.fragment.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.LinearLayout.LayoutParams;
-
-import org.deviceconnect.android.deviceplugin.chromecast.BuildConfig;
-import org.deviceconnect.android.deviceplugin.chromecast.R;
-
-/**
- * チュートリアル画面.
- *
- * 画面を作成する
- *
- * Chromecastの設定
- *
- * @author NTT DOCOMO, INC.
- */
-public class ChromeCastSettingFragmentPage3 extends Fragment {
- /** Chromecastアプリのパッケージ名. */
- private static final String PACKAGE_NAME = "com.google.android.apps.chromecast.app";
- /** バッジの横サイズ. */
- private int mBadgeWidth = 0;
- /** バッジの縦サイズ. */
- private int mBadgeHeight = 0;
-
-
- /**
- * Chromecast App (Google) のインストール状態を調べる.
- *
- * @param context コンテキスト
- * @return インストール状態 (true: インストールされている, false: インストールされていない)
- */
- private boolean isApplicationInstalled(final Context context) {
- boolean installed = false;
- try {
- context.getPackageManager().getPackageInfo(PACKAGE_NAME, PackageManager.GET_META_DATA);
- installed = true;
- } catch (NameNotFoundException e) {
- if (BuildConfig.DEBUG) {
- e.printStackTrace();
- }
- }
- return installed;
- }
-
- /**
- * Chromecast App (Google) のインストール状態に応じて、Buttonの背景を変更する.
- *
- * @param button ボタン
- */
- private void changeButtonBackground(final Button button) {
- if (isApplicationInstalled(button.getContext())) {
- button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
- button.setBackgroundResource(R.drawable.button_blue);
- button.setText(getResources().getString(R.string.chromecast_settings_step_3_button));
- } else {
- button.setLayoutParams(new LayoutParams(mBadgeWidth, mBadgeHeight));
- button.setBackgroundResource(R.drawable.button_google_play);
- button.setText("");
- }
- }
-
- @Override
- public void onStart() {
- super.onStart();
- changeButtonBackground(getActivity().findViewById(R.id.buttonChromecastSettingApp));
- }
-
- @Override
- public View onCreateView(final LayoutInflater inflater,
- final ViewGroup container, final Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.chromecast_settings_step_3, container, false);
- Button button = rootView.findViewById(R.id.buttonChromecastSettingApp);
- button.setOnClickListener((v) -> {
- Intent intent;
- if (isApplicationInstalled(v.getContext())) {
- intent = v.getContext().getPackageManager().getLaunchIntentForPackage(PACKAGE_NAME);
- } else {
- intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + PACKAGE_NAME));
- }
- startActivity(intent);
- });
-
- Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.button_google_play);
- mBadgeWidth = image.getWidth();
- mBadgeHeight = image.getHeight();
- image.recycle();
-
- return rootView;
- }
-
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/DConnectSettingCompatPageFragmentActivity.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/DConnectSettingCompatPageFragmentActivity.java
deleted file mode 100755
index 5ef980da77..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/DConnectSettingCompatPageFragmentActivity.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- DConnectSettingPageFragmentActivity.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.chromecast.setting;
-
-import android.graphics.Color;
-import android.os.Bundle;
-import androidx.fragment.app.Fragment;
-import androidx.viewpager.widget.ViewPager;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.appcompat.widget.Toolbar;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-
-import org.deviceconnect.android.R;
-import org.deviceconnect.android.ui.adapter.DConnectFragmentPagerAdapter;
-import org.deviceconnect.android.ui.adapter.DConnectPageCreater;
-
-/**
- * デバイスプラグイン設定画面用 ベースフラグメントアクティビティ.
- * @author NTT DOCOMO, INC.
- */
-public abstract class DConnectSettingCompatPageFragmentActivity extends AppCompatActivity implements
- DConnectPageCreater {
-
- /**
- * ページ用のビューページャー.
- */
- private ViewPager mViewPager;
-
- /**
- * ViewPagerを持つレイアウトを自動的に設定する.
- * サブクラスでオーバーライドする場合は setContentView を実行しないこと 。
- *
- * @param savedInstanceState パラメータ
- * @see android.app.Activity#onCreate(Bundle)
- */
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_setting_page);
-
- mViewPager = (ViewPager) findViewById(R.id.setting_pager);
- mViewPager.setAdapter(new DConnectFragmentPagerAdapter(getSupportFragmentManager(), this));
- Toolbar toolbar = new Toolbar(this);
- toolbar.setTitle(org.deviceconnect.android.deviceplugin.chromecast.R.string.activity_setting_page_title);
- toolbar.setBackgroundColor(Color.parseColor("#00a0e9"));
- toolbar.setTitleTextColor(Color.parseColor("#FFFFFF"));
- addContentView(toolbar, new Toolbar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
- toolbar.setNavigationIcon(org.deviceconnect.android.deviceplugin.chromecast.R.drawable.close_icon);
- toolbar.setNavigationOnClickListener((view) -> {
- finish();
- });
- setSupportActionBar(toolbar);
- }
-
- @Override
- public boolean onOptionsItemSelected(final MenuItem item) {
-
- if (item.getItemId() == android.R.id.home) {
- finish();
- return true;
- }
-
- return super.onOptionsItemSelected(item);
- }
-
- /**
- * ViewPagerを取得する.
- *
- * @return ViewPagerのインスタンス
- */
- protected ViewPager getViewPager() {
- return mViewPager;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/package-info.java b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/package-info.java
deleted file mode 100755
index 7c33ed3bd4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/java/org/deviceconnect/android/deviceplugin/chromecast/setting/package-info.java
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- org.deviceconnect.android.deviceplugin.chromecast.setting
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-
-/**
- * Device Connect Chromecast DevicePlugin Setting UI.
- */
-package org.deviceconnect.android.deviceplugin.chromecast.setting;
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-hdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-hdpi/ic_launcher.png
deleted file mode 100755
index a3a7f4794e..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-mdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-mdpi/ic_launcher.png
deleted file mode 100755
index a3a7f4794e..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_blue.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_blue.xml
deleted file mode 100755
index a2c51ba7bd..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_blue.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_circle_blue.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_circle_blue.xml
deleted file mode 100755
index b0b1e809d8..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_circle_blue.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- -
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_circle_red.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_circle_red.xml
deleted file mode 100755
index 98e828aa8a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_circle_red.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_google_play.png b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_google_play.png
deleted file mode 100755
index 649e782e02..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_google_play.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_red.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_red.xml
deleted file mode 100755
index d59801b1f0..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/button_red.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/chromecast_img01.png b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/chromecast_img01.png
deleted file mode 100755
index 31d03c3d12..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/chromecast_img01.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/chromecast_img02.png b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/chromecast_img02.png
deleted file mode 100755
index 4455ce83a4..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/chromecast_img02.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/chromecast_img03.png b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/chromecast_img03.png
deleted file mode 100755
index 8f05ab95eb..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/chromecast_img03.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100755
index a3a7f4794e..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xxhdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100755
index a3a7f4794e..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/layout/chromecast_settings_step_1.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/layout/chromecast_settings_step_1.xml
deleted file mode 100755
index 13248c3abb..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/layout/chromecast_settings_step_1.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/layout/chromecast_settings_step_2.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/layout/chromecast_settings_step_2.xml
deleted file mode 100755
index 6a7ab5e96c..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/layout/chromecast_settings_step_2.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/layout/chromecast_settings_step_3.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/layout/chromecast_settings_step_3.xml
deleted file mode 100755
index 2ea8aff590..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/layout/chromecast_settings_step_3.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/menu/browse.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/menu/browse.xml
deleted file mode 100755
index 44b7f0c1ef..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/menu/browse.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values-ja/strings.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values-ja/strings.xml
deleted file mode 100755
index 4c6703375a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values-ja/strings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values-v11/styles.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values-v11/styles.xml
deleted file mode 100755
index cc7b3128b5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values-v11/styles.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values-v14/styles.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values-v14/styles.xml
deleted file mode 100755
index d581045ffc..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values-v14/styles.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values-w820dp/dimens.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values-w820dp/dimens.xml
deleted file mode 100755
index f3e70203b9..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- 64dp
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values/color.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values/color.xml
deleted file mode 100755
index b185f1d715..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values/color.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- #00a0e9
- - #ffffff
- - #666666
- #03A9F4
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values/dimens.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values/dimens.xml
deleted file mode 100755
index 2a849ff36a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 16dp
- 16dp
- 24dp
- 5dp
- 20sp
- 16sp
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values/strings.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values/strings.xml
deleted file mode 100755
index ef3e307920..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- Chromecast (Device Connect Device Plug-in)
- Chromecast (%1$s)
- Chromecast 2.0.0
- [YOUR APPLICATION ID]
- urn:x-cast:com.name.space.chromecast.test.receiver
- [1/3] Chromecastの接続
- Chromecast をテレビの HDMI 入力端子につなぎます。
- [2/3] 電源の接続
- 電源ケーブルの一方の端を Chromecast に差し込み、もう一方の端を電源アダプターに差し込んでから、近くの電源コンセントにつなぎます。
- テレビにUSB ポートがある場合は直接差し込んで Chromecast に給電することもできます。
- [3/3] Chromecastの設定
- Chromecast を初めて使用する際には以下のボタンをタップしてセットアップをしてください。
- " Chromecast アプリを起動 "
- Chromecast のセットアップが完了しましたら右上のボタンを押して、使用するChromeCastと接続してください。
- " Wifi を再起動 "
-
- Play on
- Settings
- キャストするChromeCastを選んでください。
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values/styles.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values/styles.xml
deleted file mode 100755
index c615f8aa65..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/xml/network_security_config.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/xml/network_security_config.xml
deleted file mode 100644
index dca93c079e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/xml/network_security_config.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/xml/org_deviceconnect_android_deviceplugin_chromecast.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/xml/org_deviceconnect_android_deviceplugin_chromecast.xml
deleted file mode 100755
index 4e1d4d969b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/app/src/main/res/xml/org_deviceconnect_android_deviceplugin_chromecast.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/build.gradle b/dConnectDevicePlugin/dConnectDeviceChromeCast/build.gradle
deleted file mode 100644
index de97774e01..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/build.gradle
+++ /dev/null
@@ -1,17 +0,0 @@
-
-buildscript {
- repositories {
- google()
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:3.6.2'
- }
-}
-
-allprojects {
- repositories {
- jcenter()
- google()
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/gradle.properties b/dConnectDevicePlugin/dConnectDeviceChromeCast/gradle.properties
deleted file mode 100644
index 0d089abc76..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/gradle.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-storeFile=キーストアのファイル名
-storePassword=キーストアのパスワード
-keyAlias=エイリアス名
-keyPassword=エイリアスのパスワード
-android.useAndroidX=true
-android.enableJetifier=true
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/gradle/wrapper/gradle-wrapper.jar b/dConnectDevicePlugin/dConnectDeviceChromeCast/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 13372aef5e..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceChromeCast/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/gradle/wrapper/gradle-wrapper.properties b/dConnectDevicePlugin/dConnectDeviceChromeCast/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 6751739880..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Tue Apr 14 15:43:18 JST 2020
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/gradlew b/dConnectDevicePlugin/dConnectDeviceChromeCast/gradlew
deleted file mode 100755
index 9d82f78915..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/gradlew
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/gradlew.bat b/dConnectDevicePlugin/dConnectDeviceChromeCast/gradlew.bat
deleted file mode 100644
index aec99730b4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/gradlew.bat
+++ /dev/null
@@ -1,90 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/lint.xml b/dConnectDevicePlugin/dConnectDeviceChromeCast/lint.xml
deleted file mode 100755
index 09b0cef56b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/lint.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/proguard-project.txt b/dConnectDevicePlugin/dConnectDeviceChromeCast/proguard-project.txt
deleted file mode 100755
index f2fe1559a2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/dConnectDevicePlugin/dConnectDeviceChromeCast/settings.gradle b/dConnectDevicePlugin/dConnectDeviceChromeCast/settings.gradle
deleted file mode 100644
index e7b4def49c..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceChromeCast/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':app'
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/.gitignore b/dConnectDevicePlugin/dConnectDeviceFaBo/.gitignore
deleted file mode 100644
index c6cbe562a4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-*.iml
-.gradle
-/local.properties
-/.idea/workspace.xml
-/.idea/libraries
-.DS_Store
-/build
-/captures
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/README.md b/dConnectDevicePlugin/dConnectDeviceFaBo/README.md
deleted file mode 100644
index 9e8eb2662d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/README.md
+++ /dev/null
@@ -1,29 +0,0 @@
-# FaBoプラグイン
-
-このFaBoプラグインでは、FaBoのShieldに接続して、GPIOなどの操作を行うための機能を提供します。
-
-また、GPIOを仮想化して、light、temperatureといったプロファイルに機能をマッピングして使用することもできます。
-
-## 開発環境
-Android Studio 2.2.1以上
-
-## ビルドマニュアル
-- [FaBoビルドマニュアル](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/FaBo-Build)
-
-## サポートするプロファイル
-
-* gpio
-* fabo
-* driveController
-* light
-* temperature
-* vibration
-* keyEvent
-* humidity
-* illuminance
-* deviceOrientation
-* proximity
-* atmosphericPressure
-
-## 関連ページ
-- [fabo](http://fabo.io/)
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/.gitignore b/dConnectDevicePlugin/dConnectDeviceFaBo/app/.gitignore
deleted file mode 100644
index 796b96d1c4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/build.gradle b/dConnectDevicePlugin/dConnectDeviceFaBo/app/build.gradle
deleted file mode 100644
index b6c8eef391..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/build.gradle
+++ /dev/null
@@ -1,75 +0,0 @@
-apply plugin: 'com.android.library'
-// Create github.properties in root project folder file with
-// gpr.usr=GITHUB_USER_ID
-// gpr.key=PERSONAL_ACCESS_TOKEN
-def githubPropertiesFile = rootProject.file("github.properties")
-def githubProperties = new Properties()
-if (githubPropertiesFile.exists()) {
- githubProperties.load(new FileInputStream(githubPropertiesFile))
-}
-
-android {
- compileSdkVersion 29
-
- def getVersionName = { ->
- def version
- if (System.getProperty('os.name').toLowerCase().contains('windows')) {
- version = ["cmd", "/c", "git describe --tags --long"].execute().in.text.trim()
- } else {
- version = ["sh", "-c", "git describe --tags --long"].execute().in.text.trim()
- }
- version = version.empty ? "2.1.0" : version
- return "${version}"
- }
-
- defaultConfig {
- minSdkVersion 16
- targetSdkVersion 29
- versionCode 1
- versionName getVersionName()
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-
- packagingOptions {
- exclude 'META-INF/DEPENDENCIES'
- exclude 'META-INF/LICENSE'
- exclude 'META-INF/NOTICE'
- exclude 'META-INF/NOTICE.txt'
- exclude 'META-INF/LICENSE.txt'
- exclude 'META-INF/DEPENDENCIES.txt'
- }
-
-
- tasks.withType(JavaCompile) {
- options.encoding = 'UTF-8'
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- repositories {
- maven {
- name = "DeviceConnect-Android"
- url = uri("https://maven.pkg.github.com/DeviceConnect/DeviceConnect-Android")
-
- credentials {
- username = System.getenv("GPR_USER") ?: githubProperties['gpr.usr']
- password = System.getenv("GPR_API_KEY") ?: githubProperties['gpr.key']
- }
- }
- }
-}
-
-dependencies {
- implementation fileTree(include: '*.jar', dir: 'libs')
- implementation 'org.deviceconnect:dconnect-device-plugin-sdk:2.8.4'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test.ext:junit:1.1.1'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/proguard-rules.pro b/dConnectDevicePlugin/dConnectDeviceFaBo/app/proguard-rules.pro
deleted file mode 100644
index f24ffff2ad..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/sasakiakira/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/androidTest/java/org/deviceconnect/android/deviceplugin/fabo/ApplicationTest.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/androidTest/java/org/deviceconnect/android/deviceplugin/fabo/ApplicationTest.java
deleted file mode 100644
index bfa2de5e95..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/androidTest/java/org/deviceconnect/android/deviceplugin/fabo/ApplicationTest.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.runner.RunWith;
-
-/**
- * Testing Fundamentals
- */
-@RunWith(AndroidJUnit4.class)
-public class ApplicationTest {
- public ApplicationTest() {
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/AndroidManifest.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/AndroidManifest.xml
deleted file mode 100644
index d3f8a33bf3..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/assets/api/driveController.json b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/assets/api/driveController.json
deleted file mode 100644
index 567e0b938b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/assets/api/driveController.json
+++ /dev/null
@@ -1,220 +0,0 @@
-{
- "swagger": "2.0",
- "basePath": "/gotapi/driveController",
- "info": {
- "title": "DriveController Profile",
- "version": "2.0.0",
- "description": "スマートデバイスの駆動処理を提供するAPI。"
- },
- "consumes": [
- "application/x-www-form-urlencoded",
- "multipart/form-data"
- ],
- "paths": {
- "/move": {
- "post": {
- "x-type": "one-shot",
- "summary": "スマートデバイスを指定された方向に移動開始する。",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "description": "サービスID。取得対象スマートデバイス",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "angle",
- "description": "角度。デバイスの方向 (degree) 0~360",
- "in": "formData",
- "required": true,
- "type": "number",
- "minimum": -360,
- "maximum": 360
- },
- {
- "name": "speed",
- "description": "速度。デバイスの動く速度 0.0~1.0",
- "in": "formData",
- "required": true,
- "type": "number",
- "minimum": -1.0,
- "maximum": 1.0
- }
- ],
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/DriveControllerMoveResponse"
- },
- "examples": {
- "application/json": {
- "result": 0,
- "product": "Example System",
- "version": "1.0.0"
- }
- }
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "スマートデバイスに移動停止リクエストを送る。",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "description": "サービスID。取得対象スマートデバイス",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/DriveControllerStopResponse"
- },
- "examples": {
- "application/json": {
- "result": 0,
- "product": "Example System",
- "version": "1.0.0"
- }
- }
- }
- }
- }
- },
- "/rotate": {
- "put": {
- "x-type": "one-shot",
- "summary": "スマートデバイスを指定された向きに回転を行う。",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "description": "サービスID。取得対象スマートデバイス",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "angle",
- "description": "角度。デバイスの方向 (degree) 0~360",
- "in": "formData",
- "required": true,
- "type": "number",
- "minimum": -360,
- "maximum": 360
- }
- ],
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/DriveControllerRotateResponse"
- },
- "examples": {
- "application/json": {
- "result": 0,
- "product": "Example System",
- "version": "1.0.0"
- }
- }
- }
- }
- }
- },
- "/stop": {
- "delete": {
- "x-type": "one-shot",
- "summary": "スマートデバイスに移動停止リクエストを送る。",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "description": "サービスID。取得対象スマートデバイス",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/DriveControllerStopResponse"
- },
- "examples": {
- "application/json": {
- "result": 0,
- "product": "Example System",
- "version": "1.0.0"
- }
- }
- }
- }
- }
- }
- },
- "definitions": {
- "DriveControllerMoveResponse": {
- "type": "object",
- "allOf": [
- {
- "$ref": "#/definitions/CommonResponse"
- }
- ]
- },
- "DriveControllerStopResponse": {
- "type": "object",
- "allOf": [
- {
- "$ref": "#/definitions/CommonResponse"
- }
- ]
- },
- "DriveControllerRotateResponse": {
- "type": "object",
- "allOf": [
- {
- "$ref": "#/definitions/CommonResponse"
- }
- ]
- },
- "CommonResponse": {
- "type": "object",
- "required": [
- "result",
- "product",
- "version"
- ],
- "properties": {
- "result": {
- "type": "integer",
- "title": "処理結果",
- "description": "0: 正常応答 0以外: 異常応答"
- },
- "product": {
- "type": "string",
- "title": "DeviceConnectシステムの名前",
- "description": ""
- },
- "version": {
- "type": "string",
- "title": "DeviceConnectシステムのバージョン名",
- "description": ""
- },
- "hmac": {
- "type": "string",
- "title": "レスポンスに対する署名",
- "description": "アプリケーション側から事前にHMACキーを共有されていた場合は必須。"
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/assets/api/fabo.json b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/assets/api/fabo.json
deleted file mode 100755
index 61a37bf09d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/assets/api/fabo.json
+++ /dev/null
@@ -1,461 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "title": "Device Connect API",
- "version": "2.0.0",
- "description": ""
- },
- "consumes": [],
- "basePath": "/gotapi/fabo",
- "paths": {
- "/service": {
- "get": {
- "x-type": "one-shot",
- "summary": "仮想サービス一覧取得",
- "description": "仮想サービス一覧を取得します。",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "description": "サービスを識別するID",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "Service",
- "schema": {
- "$ref": "#/definitions/GetServiceResponse"
- }
- }
- }
- },
- "post" : {
- "x-type": "one-shot",
- "summary": "仮想サービス作成",
- "description": "仮想サービスを新規作成します。",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "description": "サービスを識別するID",
- "required": true,
- "type": "string"
- },
- {
- "name": "name",
- "in": "query",
- "description": "新規に作成する仮想サービスにつける名前",
- "required": true,
- "maxLength" : 32,
- "minLength" : 1,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "Service",
- "schema": {
- "$ref": "#/definitions/NewServiceResponse"
- }
- }
- }
- },
- "put" : {
- "x-type": "one-shot",
- "summary": "仮想サービス更新",
- "description": "仮想サービスを更新します。",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "description": "サービスを識別するID",
- "required": true,
- "type": "string"
- },
- {
- "name": "vid",
- "in": "query",
- "description": "仮想サービスを識別するID",
- "required": true,
- "type": "string"
- },
- {
- "name": "name",
- "in": "query",
- "description": "更新後の仮想サービスの名前",
- "required": true,
- "maxLength" : 32,
- "minLength" : 1,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "Service",
- "schema": {
- "$ref": "#/definitions/CommonResponse"
- }
- }
- }
- },
- "delete" : {
- "x-type": "one-shot",
- "summary": "仮想サービス削除",
- "description": "仮想サービスを削除します。",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "description": "サービスを識別するID",
- "required": true,
- "type": "string"
- },
- {
- "name": "vid",
- "in": "query",
- "description": "仮想サービスを識別するID",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "Service",
- "schema": {
- "$ref": "#/definitions/CommonResponse"
- }
- }
- }
- }
- },
- "/profile": {
- "get": {
- "x-type": "one-shot",
- "summary": "仮想サービスに登録されているプロファイル一覧取得",
- "description": "仮想サービスに登録されているプロファイル一覧を取得します。",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "vid",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "Service",
- "schema": {
- "$ref": "#/definitions/GetProfileResponse"
- }
- }
- }
- },
- "post" : {
- "x-type": "one-shot",
- "summary": "プロファイルを追加.",
- "description": "仮想サービスにプロファイルを追加します。",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "description": "サービスを識別するID",
- "required": true,
- "type": "string"
- },
- {
- "name": "vid",
- "in": "query",
- "description": "仮想サービスを識別するID",
- "required": true,
- "type": "string"
- },
- {
- "name": "type",
- "in": "query",
- "description": "FaBoが保持するプロファイルの種別",
- "required": true,
- "type": "integer",
- "enum": [
- 1, 2, 3, 4, 5, 6, 7, 100, 101, 102, 103, 104, 105, 106, 107, 108
- ]
- },
- {
- "name": "pins",
- "in": "query",
- "description": "プロファイルに対応するピン番号の配列。 「,」区切りでピン番号を指定します。",
- "required": false,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "Service",
- "schema": {
- "$ref": "#/definitions/CommonResponse"
- }
- }
- }
- },
- "put" : {
- "x-type": "one-shot",
- "summary": "プロファイルの更新.",
- "description": "仮想サービスにありプロファイルを更新します。",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "description": "サービスを識別するID",
- "required": true,
- "type": "string"
- },
- {
- "name": "vid",
- "in": "query",
- "description": "仮想サービスを識別するID",
- "required": true,
- "type": "string"
- },
- {
- "name": "type",
- "in": "query",
- "description": "FaBoが保持するプロファイルの種別",
- "required": true,
- "type": "integer",
- "enum": [
- 1, 2, 3, 4, 5, 6, 7, 100, 101, 102, 103, 104, 105, 106, 107, 108
- ]
- },
- {
- "name": "pins",
- "in": "query",
- "description": "プロファイルが対応するピン番号。",
- "required": false,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "Service",
- "schema": {
- "$ref": "#/definitions/CommonResponse"
- }
- }
- }
- },
-
- "delete" : {
- "x-type": "one-shot",
- "summary": "プロファイルを削除.",
- "description": "仮想サービスにプロファイルを削除します。",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "description": "サービスを識別するID",
- "required": true,
- "type": "string"
- },
- {
- "name": "vid",
- "in": "query",
- "description": "仮想サービスを識別するID",
- "required": true,
- "type": "string"
- },
- {
- "name": "type",
- "in": "query",
- "description": "FaBoが保持するプロファイルの種別",
- "required": true,
- "type": "integer",
- "enum": [
- 1, 2, 3, 4, 5, 6, 7, 100, 101, 102, 103, 104, 105, 106, 107, 108
- ]
- }
- ],
- "responses": {
- "200": {
- "description": "Service",
- "schema": {
- "$ref": "#/definitions/CommonResponse"
- }
- }
- }
- }
- }
- },
-
- "definitions": {
- "GetProfileResponse": {
- "type": "object",
- "allOf": [
- {
- "$ref": "#/definitions/CommonResponse"
- },
- {
- "type": "object",
- "required": ["profiles"],
- "properties": {
- "profiles": {
- "type": "array",
- "description": "プロファイルの配列",
- "items": {
- "type": "object",
- "required": [
- "type",
- "name",
- "brick"
- ],
- "properties": {
- "type": {
- "type" : "integer",
- "description": "プロファイルの種別"
- },
- "name": {
- "type" : "string",
- "description": "プロファイルの名"
- },
- "brick": {
- "type" : "string",
- "description": "対応するBrick名"
- },
- "pins" : {
- "type": "array",
- "description": "ピン情報",
- "items": {
- "type" : "integer"
- }
- }
- }
- }
- }
- }
- }
- ]
- },
-
- "GetServiceResponse": {
- "type": "object",
- "allOf": [
- {
- "$ref": "#/definitions/CommonResponse"
- },
- {
- "type": "object",
- "required": [ "services" ],
- "properties": {
- "services": {
- "type": "array",
- "description": "仮想サービスの配列",
- "items" : {
- "type": "object",
- "required": [
- "vid",
- "name",
- "profiles"
- ],
- "properties": {
- "vid": {
- "type": "string",
- "description": "仮想サービスのID"
- },
- "name": {
- "type": "string",
- "description": "仮想サービスの名前"
- },
- "profiles": {
- "type": "array",
- "description": "仮想サービスが持つプロファイル一覧",
- "items": {
- "type": "object",
- "required": [
- "type",
- "name",
- "brick"
- ],
- "properties": {
- "type": {
- "type" : "integer",
- "description": "プロファイルの種別"
- },
- "name": {
- "type" : "string",
- "description": "プロファイルの名"
- },
- "brick": {
- "type" : "string",
- "description": "対応するBrick名"
- },
- "pins" : {
- "type": "array",
- "description": "ピン情報",
- "items": {
- "type" : "integer"
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- ]
- },
-
- "NewServiceResponse": {
- "type": "object",
- "allOf": [
- {
- "$ref": "#/definitions/CommonResponse"
- },
- {
- "type": "object",
- "required": [ "vid" ],
- "properties": {
- "vid": {
- "type": "string",
- "description": "新規に作成された仮想サービスのID"
- }
- }
- }
- ]
- },
-
- "CommonResponse": {
- "type": "object",
- "required": [
- "result",
- "product",
- "version"
- ],
- "properties": {
- "result": {
- "type": "integer",
- "description": "0:正常応答 0以外:異常応答"
- },
- "product": {
- "type": "string",
- "description": "DeviceConnectシステムの名前。"
- },
- "version": {
- "type": "string",
- "description": "DeviceConnectシステムのバージョン名。"
- },
- "hmac": {
- "type": "string",
- "description": "レスポンスに対する署名。アプリケーション側から事前にHMACキーを共有されていた場合は必須。"
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/assets/api/gpio.json b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/assets/api/gpio.json
deleted file mode 100644
index 8c8a546817..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/assets/api/gpio.json
+++ /dev/null
@@ -1,2399 +0,0 @@
-{
- "swagger": "2.0",
- "basePath": "/gotapi/gpio",
- "info": {
- "title": "GPIO Profile",
- "version": "2.0.0",
- "description": ""
- },
- "consumes": [
- "application/x-www-form-urlencoded",
- "multipart/form-data"
- ],
- "paths": {
- "/export/D0": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D1": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D2": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D3": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D4": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D5": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D6": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D7": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D8": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D9": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D10": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D11": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D12": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/D13": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/A0": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/A1": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/A2": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/A3": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/A4": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/export/A5": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- },
- {
- "name": "mode",
- "in": "query",
- "required": true,
- "type": "number",
- "enum": [0, 1, 2, 3]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D0": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D1": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D2": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D3": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D4": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D5": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D6": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D7": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D8": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D9": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D10": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D11": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D12": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/D13": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/A0": {
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/A1": {
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/A2": {
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/A3": {
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/A4": {
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/digital/A5": {
- "put": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "integer",
- "enum": [0, 1]
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/analog/A0": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/analog/A1": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/analog/A2": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/analog/A3": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/analog/A4": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/analog/A5": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/analog/D3": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "number"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/analog/D5": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "number"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/analog/D6": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "number"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/analog/D9": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "number"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/analog/D10": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "number"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/analog/D11": {
- "post": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- },
- {
- "name": "value",
- "in": "formData",
- "required": true,
- "type": "number"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- },
- "/onChange": {
- "get": {
- "x-type": "one-shot",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "put": {
- "x-type": "event",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "formData",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- },
- "delete": {
- "x-type": "event",
- "summary": "",
- "description": "",
- "parameters": [
- {
- "name": "serviceId",
- "in": "query",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": ""
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoDeviceService.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoDeviceService.java
deleted file mode 100644
index 387cd55fc0..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoDeviceService.java
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- FaBoDeviceService.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.fabo;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-
-import org.deviceconnect.android.deviceplugin.fabo.core.BuildConfig;
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoConst;
-import org.deviceconnect.android.deviceplugin.fabo.profile.FaBoGPIOProfile;
-import org.deviceconnect.android.deviceplugin.fabo.profile.FaBoSystemProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.FaBoService;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.VirtualService;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.VirtualServiceFactory;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ServiceData;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.VirtualServiceDBHelper;
-import org.deviceconnect.android.event.Event;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.DConnectMessageService;
-import org.deviceconnect.android.profile.DConnectProfile;
-import org.deviceconnect.android.profile.SystemProfile;
-import org.deviceconnect.android.profile.spec.DConnectServiceSpec;
-import org.deviceconnect.android.profile.spec.models.Swagger;
-import org.deviceconnect.android.service.DConnectService;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.logging.Logger;
-
-/**
- * 本デバイスプラグインのプロファイルをDeviceConnectに登録するサービス.
- *
- * @author NTT DOCOMO, INC.
- */
-public abstract class FaBoDeviceService extends DConnectMessageService {
-
- /**
- * デバッグフラグ.
- */
- private static final boolean DEBUG = BuildConfig.DEBUG;
-
- /**
- * Tag.
- */
- private static final String TAG = "FaBo";
-
- /**
- * ロガー.
- */
- private final Logger mLogger = Logger.getLogger("fabo.dplugin");
-
- /**
- * 仮想サービスを管理するクラス.
- */
- private VirtualServiceDBHelper mDBHelper;
-
- /**
- * FaBoデバイスを操作するためのクラス.
- */
- private FaBoDeviceControl mFaBoDeviceControl;
-
- /**
- * 監視用Thread.
- */
- private WatchFirmataThread mWatchFirmataThread;
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- // FaBoを直接操作するためのサービス
- getServiceProvider().addService(new FaBoService());
-
- // 仮想サービスの初期化
- initVirtualService();
-
- // FaBoデバイス操作クラスの初期化
- initFaBoDeviceControl();
- }
-
- @Override
- public void onDestroy() {
- endWatchFirmata();
-
- if (mFaBoDeviceControl != null) {
- mFaBoDeviceControl.destroy();
- mFaBoDeviceControl = null;
- }
-
- super.onDestroy();
- }
-
- @Override
- protected void onManagerUninstalled() {
- // Managerアンインストール検知時の処理.
- if (DEBUG) {
- mLogger.info("Plug-in : onManagerUninstalled");
- }
- }
-
- @Override
- protected void onManagerTerminated() {
- // Manager正常終了通知受信時の処理.
- if (DEBUG) {
- mLogger.info("Plug-in : onManagerTerminated");
- }
- }
-
- @Override
- protected void onManagerEventTransmitDisconnected(final String origin) {
- // ManagerのEvent送信経路切断通知受信時の処理.
- if (DEBUG) {
- mLogger.info("Plug-in : onManagerEventTransmitDisconnected");
- }
- if (origin != null) {
- EventManager.INSTANCE.removeEvents(origin);
- List events = EventManager.INSTANCE.getEventList(FaBoGPIOProfile.PROFILE_NAME,
- FaBoGPIOProfile.ATTRIBUTE_ON_CHANGE);
- for (Event event : events) {
- if (event.getOrigin().equals(origin)) {
- String serviceId = event.getServiceId();
- Iterator serviceIds = mServiceIdStore.iterator();
- while (serviceIds.hasNext()) {
- String tmpServiceId = (String) serviceIds.next();
- if (tmpServiceId.equals(serviceId)) {
- serviceIds.remove();
- }
- }
- }
- }
- } else {
- resetPluginResource();
- }
- }
-
- @Override
- protected void onDevicePluginReset() {
- // Device Plug-inへのReset要求受信時の処理.
- if (DEBUG) {
- mLogger.info("Plug-in : onDevicePluginReset");
- }
- resetPluginResource();
- }
-
- @Override
- protected SystemProfile getSystemProfile() {
- return new FaBoSystemProfile();
- }
-
- /**
- * FaBoを操作するクラスを取得します.
- * @return FaBoDeviceControlのインスタンス
- */
- protected abstract FaBoDeviceControl createFaBoDeviceControl();
-
- /**
- * FaBoを操作するためのクラスを取得します.
- * @return FaBoを操作するクラス
- */
- public FaBoDeviceControl getFaBoDeviceControl() {
- return mFaBoDeviceControl;
- }
-
- /**
- * FaBoDeviceControlを初期化します.
- */
- private void initFaBoDeviceControl() {
- mFaBoDeviceControl = createFaBoDeviceControl();
- mFaBoDeviceControl.setOnFaBoDeviceControlListener(new FaBoDeviceControl.OnFaBoDeviceControlListener() {
- @Override
- public void onConnected() {
- startWatchFirmata();
- setOnline(true);
- sendResultToActivity(FaBoConst.SUCCESS_CONNECT_FIRMATA);
- }
-
- @Override
- public void onDisconnected() {
- endWatchFirmata();
- setOnline(false);
- }
-
- @Override
- public void onFailedConnected() {
- setOnline(false);
- sendResultToActivity(FaBoConst.FAILED_CONNECT_ARDUINO);
- }
- });
- mFaBoDeviceControl.initialize();
- }
-
- /**
- * リソースリセット処理.
- */
- private void resetPluginResource() {
- EventManager.INSTANCE.removeAll();
-
- if (mFaBoDeviceControl != null) {
- mFaBoDeviceControl.destroy();
- }
- initFaBoDeviceControl();
- }
-
- /**
- * テスト用仮想データ.
- */
- private void createTestData() {
- if (mDBHelper.getServiceDataList().isEmpty()) {
- ServiceData serviceData = new ServiceData();
- serviceData.setName("RobotCar(Mouse)");
- serviceData.setServiceId("mouse_service_id");
-
- ProfileData profileData = new ProfileData();
- profileData.setServiceId("mouse_service_id");
- profileData.setType(ProfileData.Type.I2C_MOUSE_DRIVE_CONTROLLER);
- serviceData.addProfileData(profileData);
-
- mDBHelper.addServiceData(serviceData);
- }
- }
-
- /**
- * 仮想サービスのデータをDBに追加します.
- * @param serviceData 追加する仮想サービスのデータ
- * @return 追加したVirtualService
- */
- public VirtualService addServiceData(final ServiceData serviceData) {
- String serviceId = mDBHelper.createServiceId();
- serviceData.setServiceId(serviceId);
- boolean result = mDBHelper.addServiceData(serviceData) >= 0;
- if (result) {
- VirtualService service = VirtualServiceFactory.createService(serviceData);
- service.setOnline(FaBoConst.STATUS_FABO_RUNNING == mFaBoDeviceControl.getStatus());
- getServiceProvider().addService(service);
- return service;
- }
- return null;
- }
-
- /**
- * 仮想サービスのデータを更新します.
- * @param serviceData 更新する仮想サービスのデータ
- * @return 更新したVirtualService
- */
- public VirtualService updateServiceData(final ServiceData serviceData) {
- boolean result = mDBHelper.updateServiceData(serviceData) >= 0;
- if (result) {
- DConnectService service = getServiceProvider().getService(serviceData.getServiceId());
- if (service != null && service instanceof VirtualService) {
- service.setName(serviceData.getName());
- ((VirtualService)service).setServiceData(serviceData);
-
- // プロファイルを一度全て削除してから、プロファイルを追加します
- for (DConnectProfile p : service.getProfileList()) {
- if (canRemoveProfile(p.getProfileName())) {
- service.removeProfile(p);
- }
- }
-
- for (ProfileData p : serviceData.getProfileDataList()) {
- DConnectProfile profile = VirtualServiceFactory.createProfile(p);
- if (profile != null) {
- service.addProfile(profile);
- profile.setContext(this);
- }
- }
- return ((VirtualService) service);
- }
- }
- return null;
- }
-
- /**
- * 仮想サービスのデータを削除します.
- * @param serviceData 削除する仮想サービスのデータ
- */
- public void removeServiceData(final ServiceData serviceData) {
- getServiceProvider().removeService(serviceData.getServiceId());
- mDBHelper.removeServiceData(serviceData);
- }
-
- /**
- * 指定されたvidに対応する仮想サービスデータを取得します.
- *
- * 指定されたvidに対応する仮想サービスが存在しない場合にはnullを返却します.
- *
- * @param vid 仮想サービスデータのID
- * @return ServiceDataのインスタンス
- */
- public ServiceData getServiceData(final String vid) {
- return mDBHelper.getServiceData(vid);
- }
-
- /**
- * 削除できるプロファイルか確認を行う.
- * @param profileName 削除できるかを確認するプロファイル名
- * @return 削除できる場合はtrue、それ以外はfalse
- */
- private boolean canRemoveProfile(final String profileName) {
- return !"serviceInformation".equalsIgnoreCase(profileName);
- }
-
- /**
- * 仮想サービスの初期化を行います.
- */
- private void initVirtualService() {
- if (DEBUG) {
- Log.i(TAG, "------------------------------------");
- Log.i(TAG, "Create virtual service list.");
- Log.i(TAG, "------------------------------------");
- }
-
- mDBHelper = new VirtualServiceDBHelper(getApplicationContext());
- createTestData();
-
- List serviceDataList = mDBHelper.getServiceDataList();
- for (ServiceData serviceData : serviceDataList) {
- DConnectService service = VirtualServiceFactory.createService(serviceData);
- getServiceProvider().addService(service);
- }
- }
-
- /**
- * DConnectServiceのOnline状況を設定します.
- *
- * @param online オンライン状態
- */
- private void setOnline(final boolean online) {
- for (DConnectService service : getServiceProvider().getServiceList()) {
- service.setOnline(online);
- }
- }
-
- /**
- * Activityにメッセージを返信する.
- *
- * @param resultId 結果のID.
- */
- private void sendResultToActivity(final int resultId) {
- Intent intent = new Intent(FaBoConst.DEVICE_TO_ARDUINO_OPEN_USB_RESULT);
- intent.putExtra("resultId", resultId);
- sendBroadcast(intent);
- }
-
- /**
- * 値監視用のThread.
- */
- private void startWatchFirmata() {
- if (mWatchFirmataThread == null) {
- mWatchFirmataThread = new WatchFirmataThread();
- mWatchFirmataThread.start();
- }
- }
-
- /**
- * Threadを停止.
- */
- private void endWatchFirmata() {
- if (mWatchFirmataThread != null) {
- mWatchFirmataThread.stopWatchFirmata();
- mWatchFirmataThread = null;
- }
- }
-
- /**
- * ServiceIDを保持する.
- */
- private List mServiceIdStore = new ArrayList<>();
-
- /**
- * onChangeイベントの登録.
- *
- * @param serviceId 現在接続中のデバイスプラグインのServiceId.
- */
- public void registerOnChange(final String serviceId) {
- mServiceIdStore.add(serviceId);
- }
-
- /**
- * onChangeイベントの削除.
- */
- public void unregisterOnChange(final String serviceId) {
- Iterator serviceIds = mServiceIdStore.iterator();
- while (serviceIds.hasNext()) {
- String tmpServiceId = (String) serviceIds.next();
- if (tmpServiceId.equals(serviceId)) {
- serviceIds.remove();
- }
- }
- }
-
- /**
- * 監視用スレッド.
- */
- private class WatchFirmataThread extends Thread {
- /**
- * 監視スレッド停止フラグ.
- */
- private boolean mStopFlag;
-
- @Override
- public void run() {
- if (DEBUG) {
- Log.i(TAG, "---------------------------------");
- Log.i(TAG, "Start watch a fragment_fabo_firmata.");
- Log.i(TAG, "---------------------------------");
- }
-
- while (!mStopFlag) {
- for (int s = 0; s < mServiceIdStore.size(); s++) {
- String serviceId = mServiceIdStore.get(s);
- List events = EventManager.INSTANCE.getEventList(serviceId,
- FaBoGPIOProfile.PROFILE_NAME, null, FaBoGPIOProfile.ATTRIBUTE_ON_CHANGE);
-
- for (Event event : events) {
- Bundle pins = new Bundle();
- for (FaBoShield.Pin pin : FaBoShield.Pin.values()) {
- if (getFaBoDeviceControl().isPinSupported(pin)) {
- switch (pin.getMode()) {
- case GPIO_IN:
- pins.putInt(pin.getPinNames()[1], getFaBoDeviceControl().getDigital(pin).getValue());
- break;
- case ANALOG:
- pins.putInt(pin.getPinNames()[1], getFaBoDeviceControl().getAnalog(pin));
- break;
- }
- }
- }
-
- if (pins.size() > 0) {
- // Eventに値をおくる.
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra("pins", pins);
- sendEvent(intent, event.getAccessToken());
- }
- }
- }
-
- try {
- Thread.sleep(30);
- } catch (InterruptedException e) {
- break;
- }
- }
-
- if (DEBUG) {
- Log.i(TAG, "---------------------------------");
- Log.i(TAG, "Stop watch a fragment_fabo_firmata.");
- Log.i(TAG, "---------------------------------");
- }
- }
-
- /**
- * 監視用スレッドを停止します.
- */
- void stopWatchFirmata() {
- mStopFlag = true;
- interrupt();
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/FaBoDeviceControl.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/FaBoDeviceControl.java
deleted file mode 100644
index 948048b1ed..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/FaBoDeviceControl.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device;
-
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-
-/**
- * FaBoデバイスを操作するためのインターフェース.
- */
-public interface FaBoDeviceControl {
- /**
- * FaBoデバイスの初期化を行います.
- */
- void initialize();
-
- /**
- * FaBoデバイスとの接続を破棄します.
- */
- void destroy();
-
- /**
- * 指定されたピンがサポートされているか確認を行います.
- * @param pin サポートされているか確認するピン
- * @return サポートされている場合はtrue、それ以外はfalse
- */
- boolean isPinSupported(final FaBoShield.Pin pin);
-
- /**
- * アナログピンに対して書き込みを行います.
- * @param pin アナログピン
- * @param value 書き込む値
- */
- void writeAnalog(final FaBoShield.Pin pin, final int value);
-
- /**
- * デジタルピンに対して書き込みを行います.
- * @param pin デジタルピン
- * @param hl 書き込む値(HIGH or LOW)
- */
- void writeDigital(final FaBoShield.Pin pin, final FaBoShield.Level hl);
-
- /**
- * アナログピンのデータを取得します.
- * @param pin アナログピン
- * @return アナログ値
- */
- int getAnalog(final FaBoShield.Pin pin);
-
- /**
- * デジタルピンのデータを取得します.
- * @param pin デジタルピン
- * @return デジタル値
- */
- FaBoShield.Level getDigital(final FaBoShield.Pin pin);
-
- /**
- * 各PINのモードを設定します.
- * @param pin ピン
- * @param mode モード
- */
- void setPinMode(final FaBoShield.Pin pin, final FaBoShield.Mode mode);
-
- /**
- * FaBoデバイスの接続状態を取得します.
- * @return 接続状態
- */
- int getStatus();
-
- /**
- * RobotCarを操作するためのインターフェースを取得します.
- * @return IRobotCarを実装したクラス
- */
- IRobotCar getRobotCar();
-
- /**
- * MouseCarを操作するためのインターフェースを取得します.
- * @return IMouseCarを実装したクラス
- */
- IMouseCar getMouseCar();
-
- /**
- * ADXL345を操作するためのインターフェースを取得します.
- * @return IADXL345を実装したクラス
- */
- IADXL345 getADXL345();
-
- /**
- * ADT7410を操作するためのインターフェースを取得します.
- * @return IADT7410を実装したクラス
- */
- IADT7410 getADT7410();
-
- /**
- * HTS221を操作するためのインターフェースを取得します.
- * @return IHTS221を実装したクラス
- */
- IHTS221 getHTS221();
-
- /**
- * VCNL4010を操作するためのインターフェースを取得します.
- * @return VCNL4010を実装したクラス
- */
- IVCNL4010 getVCNL4010();
-
- /**
- * ISL29034を操作するためのインターフェースを取得します.
- * @return ISL29034を実装したクラス
- */
- IISL29034 getISL29034();
-
- /**
- * MPL115を操作するためのインターフェースを取得します.
- * @return MPL115を実装したクラス
- */
- IMPL115 getMPL115();
-
- /**
- * LIDARLite v3を操作するためのインターフェースを取得します.
- * @return ILIDARLiteV3を実装したクラス
- */
- ILIDARLiteV3 getLIDARLite();
-
- /**
- * FaBoデバイスの接続状態通知リスナーを設定します.
- * @param listener リスナー
- */
- void setOnFaBoDeviceControlListener(final OnFaBoDeviceControlListener listener);
-
- /**
- * GPIOのイベント通知リスナーを追加します.
- * @param listener 追加するリスナー
- */
- void addOnGPIOListener(final OnGPIOListener listener);
-
- /**
- * GPIOのイベント通知リスナーを削除します.
- * @param listener 削除するリスナー
- */
- void removeOnGPIOListener(final OnGPIOListener listener);
-
- /**
- * FaBoデバイスの接続状態を通知するためのリスナー.
- */
- interface OnFaBoDeviceControlListener {
- /**
- * FaBoが接続された時のイベントを通知します.
- */
- void onConnected();
-
- /**
- * FaBoが切断された時のイベントを通知します.
- */
- void onDisconnected();
-
- /**
- * 接続に失敗した時のイベントを通知します.
- */
- void onFailedConnected();
- }
-
- /**
- * GPIOのイベントを通知するリスナー.
- */
- interface OnGPIOListener {
- /**
- * アナログのデータを受信したことを通知します.
- */
- void onAnalog();
-
- /**
- * デジタルのデータを受信したことを通知します.
- */
- void onDigital();
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IADT7410.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IADT7410.java
deleted file mode 100644
index 1e6ae3123a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IADT7410.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device;
-
-/**
- * ADT7410を操作するためのインターフェース.
- */
-public interface IADT7410 {
-
- /**
- * ADT7410の温度センサーを取得します.
- * @param listener 取得した温度を通知するリスナー
- */
- void read(final OnADT7410Listener listener);
-
- /**
- * ADT7410の温度センサーを開始します.
- * @param listener 取得した温度を通知するリスナー
- */
- void startRead(final OnADT7410Listener listener);
-
- /**
- * ADT7410の温度センサーを停止します.
- * @param listener 取得した温度を通知するリスナー
- */
- void stopRead(final OnADT7410Listener listener);
-
- /**
- * ADT7410からのデータを受け取るリスナー.
- */
- interface OnADT7410Listener {
- /**
- * 温度センサー開始成功通知を受け取ります.
- */
- void onStarted();
-
- /**
- * 温度センサーを受け取ります.
- * @param temperature 温度
- */
- void onData(final double temperature);
-
- /**
- * 温度センサーでエラーが発生したことを受け取ります.
- * @param message
- */
- void onError(final String message);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IADXL345.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IADXL345.java
deleted file mode 100644
index 3dfc7006a4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IADXL345.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device;
-
-/**
- * ADXL345を操作するためのインターフェース.
- */
-public interface IADXL345 {
-
- /**
- * ADXL345の加速度を取得します.
- * @param listener 加速度の通知を受けるリスナー
- */
- void read(final OnADXL345Listener listener);
-
- /**
- * ADXL345の加速度センサーを開始します.
- * @param listener 加速度の通知を受けるリスナー
- */
- void startRead(final OnADXL345Listener listener);
-
- /**
- * ADXL345の加速度センサーを停止します.
- * @param listener 加速度の通知を受けるリスナー
- */
- void stopRead(final OnADXL345Listener listener);
-
- /**
- * ADXL345からのデータを受け取るリスナー.
- */
- interface OnADXL345Listener {
- /**
- * 加速度センサー開始成功通知を受け取ります.
- */
- void onStarted();
-
- /**
- * 加速度センサーを受け取ります.
- * @param x x軸の加速度
- * @param y y軸の加速度
- * @param z z軸の加速度
- */
- void onData(final double x, final double y, final double z);
-
- /**
- * 加速度センサーでエラーが発生したことを受け取ります.
- * @param message エラーメッセージ
- */
- void onError(final String message);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IHTS221.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IHTS221.java
deleted file mode 100644
index 10d70fb8aa..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IHTS221.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device;
-
-/**
- * HTS221を操作するためのインターフェース.
- */
-public interface IHTS221 {
- /**
- * HTS221から湿度の取得を行います.
- * @param callback 湿度のデータを通知するコールバック
- */
- void readHumidity(final OnHumidityCallback callback);
-
- /**
- * HTS221の温度の取得を行います.
- * @param callback 温度のデータを通知するコールバック
- */
- void readTemperature(final OnTemperatureCallback callback);
-
- /**
- * 湿度のデータを通知するコールバック.
- */
- interface OnHumidityCallback {
- void onHumidity(final double humidity);
- void onError(final String message);
- }
-
- /**
- * 温度のデータを通知するコールバック.
- */
- interface OnTemperatureCallback {
- void onTemperature(final double temperature);
- void onError(final String message);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IISL29034.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IISL29034.java
deleted file mode 100644
index a45a5f62c3..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IISL29034.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device;
-
-/**
- * ISL29034を操作するためのインターフェース.
- */
-public interface IISL29034 {
- /**
- * 照度センサー値を取得します.
- * @param lightListener 照度センサー値を受け取るリスナー
- */
- void read(final OnAmbientLightListener lightListener);
-
- /**
- * 照度センサー値の連続取得を開始します.
- * @param lightListener 照度センサー値を受け取るリスナー
- */
- void startRead(final OnAmbientLightListener lightListener);
-
- /**
- * 照度センサー値の連続取得を停止します.
- * @param lightListener 照度センサー値を受け取るリスナー
- */
- void stopRead(final OnAmbientLightListener lightListener);
-
- /**
- * 照度センサー値の通知を行うリスナー.
- */
- interface OnAmbientLightListener {
- /**
- * 照度センサーの開始成功通知を受け取ります.
- */
- void onStarted();
-
- /**
- * 照度センサー値の通知を受け取ります.
- * @param lux 照度
- */
- void onData(final double lux);
-
- /**
- * 照度センサー値の取得失敗通知を受け取ります.
- * @param message エラーメッセージ
- */
- void onError(final String message);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/ILIDARLiteV3.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/ILIDARLiteV3.java
deleted file mode 100644
index 9e9c004aab..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/ILIDARLiteV3.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device;
-
-/**
- * ILIDARLiteV3を操作するためのインターフェース.
- */
-public interface ILIDARLiteV3 {
-
- /**
- * LIDARLite v3から距離を取得します.
- * @param listener 加速度の通知を受けるリスナー
- */
- void read(final OnLIDARLiteListener listener);
-
- /**
- * LIDARLite v3から距離センサーを開始します.
- * @param listener 加速度の通知を受けるリスナー
- */
- void startRead(final OnLIDARLiteListener listener);
-
- /**
- * LIDARLite v3から距離センサーを停止します.
- * @param listener 加速度の通知を受けるリスナー
- */
- void stopRead(final OnLIDARLiteListener listener);
-
-
- /**
- * LIDARLite v3からのデータを受け取るリスナー.
- */
- interface OnLIDARLiteListener {
- /**
- * 距離センサー開始成功通知を受け取ります.
- */
- void onStarted();
-
- /**
- * 距離センサーを受け取ります.
- * @param distance 距離
- */
- void onData(final int distance);
-
- /**
- * 距離センサーでエラーが発生したことを受け取ります.
- * @param message エラーメッセージ
- */
- void onError(final String message);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IMPL115.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IMPL115.java
deleted file mode 100644
index 147fb6b5cc..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IMPL115.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device;
-
-/**
- * MPL115を操作するためのインターフェース.
- */
-public interface IMPL115 {
- /**
- * 気圧センサーの値を取得します.
- * @param listener 値を受け取るリスナー
- */
- void readAtmosphericPressure(final OnAtmosphericPressureListener listener);
-
- /**
- * 気圧センサーの値を受け取るリスナー.
- */
- interface OnAtmosphericPressureListener {
- /**
- * 気圧の値を受け取ります.
- * @param hpa 気圧(ヘクトパスカル)
- * @param temperature 温度
- */
- void onData(final double hpa, final double temperature);
-
- /**
- * 気圧の取得に失敗通知を受け取ります.
- * @param message エラーメッセージ
- */
- void onError(final String message);
- }
-
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IMouseCar.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IMouseCar.java
deleted file mode 100644
index 186219346e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IMouseCar.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device;
-
-/**
- * マウス型RobotCarを操作するためのインターフェース.
- */
-public interface IMouseCar {
- /**
- * Mouse move.
- *
- * 左右のスピードを変えて回転します。
- *
- * @param leftSpeed 移動するスピード(-1.0〜1.0)
- * @param rightSpeed 移動するスピード(-1.0〜1.0)
- */
- void move(final float rightSpeed, final float leftSpeed);
-
- /**
- * 停止します.
- */
- void stop();
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IRobotCar.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IRobotCar.java
deleted file mode 100644
index e7d4767433..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IRobotCar.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device;
-
-/**
- * RobotCarを操作するためのインターフェース.
- */
-public interface IRobotCar {
- /**
- * ハンドルを切ります.
- * @param direction 向き(-1.0〜1.0)
- */
- void turnHandle(final float direction);
-
- /**
- * 移動します.
- * @param speed 移動するスピード(-1.0〜1.0)
- */
- void move(final float speed);
-
- /**
- * 停止します.
- */
- void stop();
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IVCNL4010.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IVCNL4010.java
deleted file mode 100644
index cdd2c39193..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/IVCNL4010.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device;
-
-/**
- * VCNL4010を操作するためのインターフェース.
- */
-public interface IVCNL4010 {
-
- /**
- * 近距離センサーの値を取得します.
- * @param listener 通知を受け取るリスナー
- */
- void readProximity(final OnProximityListener listener);
-
- /**
- * 近距離センサー値の連続取得を開始します.
- * @param listener 通知を受け取るリスナー
- */
- void startProximity(final OnProximityListener listener);
-
- /**
- * 近距離センサー値の連続取得を停止します.
- * @param listener 通知を受け取るリスナー
- */
- void stopProximity(final OnProximityListener listener);
-
- /**
- * 照度センサーの値を取得します.
- */
- void readAmbientLight(final OnAmbientLightListener listener);
-
- /**
- * 照度センサー値の連続取得を開始します.
- */
- void startAmbientLight(final OnAmbientLightListener listener);
-
- /**
- * 照度センサー値の連続取得を停止します.
- */
- void stopAmbientLight(final OnAmbientLightListener listener);
-
- /**
- * 近距離センサー値の通知を受けるリスナー.
- */
- interface OnProximityListener {
- /**
- * 近距離センサーの開始通知を受け取ります.
- */
- void onStarted();
-
- /**
- * 近距離センサー値を受け取ります.
- * @param proximity 距離
- */
- void onData(final boolean proximity);
-
- /**
- * 近距離センサー値の取得失敗通知を受け取ります.
- * @param message エラーメッセージ
- */
- void onError(final String message);
- }
-
- interface OnAmbientLightListener {
- void onStarted();
- void onData(final double ambient);
- void onError(final String message);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/param/FaBoConst.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/param/FaBoConst.java
deleted file mode 100644
index fdbcebece8..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/param/FaBoConst.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- FaBoConst.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.fabo.param;
-
-/**
- * FaBoデバイスプラグインの汎用定数.
- */
-public class FaBoConst {
-
- /** Command of open usb. */
- public static final String DEVICE_TO_ARDUINO_OPEN_USB
- = "org.deviceconnect.gpio.usb.open";
-
- /** Command of check usb. */
- public static final String DEVICE_TO_ARDUINO_CHECK_USB
- = "org.deviceconnect.gpio.usb.check";
-
- /** Command of check usb. */
- public static final String DEVICE_TO_ARDUINO_CHECK_USB_RESULT
- = "org.deviceconnect.gpio.usb.check.result";
-
- /** Command of close usb. */
- public static final String DEVICE_TO_ARDUINO_CLOSE_USB
- = "org.deviceconnect.gpio.usb.close";
-
- /** Result of usb connection. */
- public static final String DEVICE_TO_ARDUINO_OPEN_USB_RESULT
- = "org.deviceconnect.gpio.usb.open.result";
-
- /** USBが未接続. */
- public static final int CAN_NOT_FIND_USB = 1;
-
- /** USBに接続失敗. */
- public static final int FAILED_OPEN_USB = 2;
-
- /** Arduinoに接続成功. */
- public static final int SUCCESS_CONNECT_ARDUINO = 3;
-
- /** Arduinoに接続失敗. */
- public static final int FAILED_CONNECT_ARDUINO = 4;
-
- /** Firmataに接続成功. */
- public static final int SUCCESS_CONNECT_FIRMATA = 5;
-
- /** Firmataに接続失敗. */
- public static final int FAILED_CONNECT_FIRMATA = 6;
-
- /** 停止中. */
- public static final int STATUS_FABO_NOCONNECT = 101;
-
- /** 初期化中. */
- public static final int STATUS_FABO_INIT = 102;
-
- /** 起動中. */
- public static final int STATUS_FABO_RUNNING = 103;
-
- /** ACTIVITY非表示. */
- public static final int STATUS_ACTIVITY_PAUSE = 201;
-
- /** ACTIVITY表示. */
- public static final int STATUS_ACTIVITY_DISPLAY = 202;
-
-
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/param/FaBoShield.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/param/FaBoShield.java
deleted file mode 100644
index 2e637c41eb..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/param/FaBoShield.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- ArduinoUno.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.fabo.param;
-
-import static org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield.Mode.ANALOG;
-import static org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield.Mode.GPIO_OUT;
-
-/**
- * FaBoShieldのPin情報.
- */
-public class FaBoShield {
- // pin modes
- public static final byte PIN_MODE_GPIO_IN = (byte) 0x00;
- public static final byte PIN_MODE_GPIO_OUT = (byte) 0x01;
- public static final byte PIN_MODE_ANALOG = (byte) 0x02;
- public static final byte PIN_MODE_PWM = (byte) 0x03;
- public static final byte PIN_MODE_SERVO = (byte) 0x04;
-
- // PORT0
- public final static int BIT_D0 = (int)0x0001; // 00000000 00000001
- public final static int BIT_D1 = (int)0x0002; // 00000000 00000010
- public final static int BIT_D2 = (int)0x0004; // 00000000 00000100
- public final static int BIT_D3 = (int)0x0008; // 00000000 00001000
- public final static int BIT_D4 = (int)0x0010; // 00000000 00010000
- public final static int BIT_D5 = (int)0x0020; // 00000000 00100000
- public final static int BIT_D6 = (int)0x0040; // 00000000 01000000
- public final static int BIT_D7 = (int)0x0100; // 00000001 00000000
-
- // PORT1
- public final static int BIT_D8 = (int)0x0001; // 00000000 00000001
- public final static int BIT_D9 = (int)0x0002; // 00000000 00000010
- public final static int BIT_D10 = (int)0x0004; // 00000000 00000100
- public final static int BIT_D11 = (int)0x0008; // 00000000 00001000
- public final static int BIT_D12 = (int)0x0010; // 00000000 00010000
- public final static int BIT_D13 = (int)0x0020; // 00000000 00100000
- public final static int BIT_A0 = (int)0x0040; // 00000000 01000000
- public final static int BIT_A1 = (int)0x0100; // 00000001 00000000
-
- // PORT2
- public final static int BIT_A2 = (int)0x0001; // 00000000 00000001
- public final static int BIT_A3 = (int)0x0002; // 00000000 00000010
- public final static int BIT_A4 = (int)0x0004; // 00000000 00000100
- public final static int BIT_A5 = (int)0x0008; // 00000000 00001000
-
- // PORT0
- public final static int PORT_D0 = 0;
- public final static int PORT_D1 = 0;
- public final static int PORT_D2 = 0;
- public final static int PORT_D3 = 0;
- public final static int PORT_D4 = 0;
- public final static int PORT_D5 = 0;
- public final static int PORT_D6 = 0;
- public final static int PORT_D7 = 0;
-
- // PORT1
- public final static int PORT_D8 = 1;
- public final static int PORT_D9 = 1;
- public final static int PORT_D10 = 1;
- public final static int PORT_D11 = 1;
- public final static int PORT_D12 = 1;
- public final static int PORT_D13 = 1;
- public final static int PORT_A0 = 1;
- public final static int PORT_A1 = 1;
-
- // PORT2
- public final static int PORT_A2 = 2;
- public final static int PORT_A3 = 2;
- public final static int PORT_A4 = 2;
- public final static int PORT_A5 = 2;
-
- // PIN NO
- public final static int PIN_NO_D0 = 0;
- public final static int PIN_NO_D1 = 1;
- public final static int PIN_NO_D2 = 2;
- public final static int PIN_NO_D3 = 3;
- public final static int PIN_NO_D4 = 4;
- public final static int PIN_NO_D5 = 5;
- public final static int PIN_NO_D6 = 6;
- public final static int PIN_NO_D7 = 7;
- public final static int PIN_NO_D8 = 8;
- public final static int PIN_NO_D9 = 9;
- public final static int PIN_NO_D10 = 10;
- public final static int PIN_NO_D11 = 11;
- public final static int PIN_NO_D12 = 12;
- public final static int PIN_NO_D13 = 13;
- public final static int PIN_NO_A0 = 14;
- public final static int PIN_NO_A1 = 15;
- public final static int PIN_NO_A2 = 16;
- public final static int PIN_NO_A3 = 17;
- public final static int PIN_NO_A4 = 18;
- public final static int PIN_NO_A5 = 19;
-
- /**
- * ピンの設定レベル.
- */
- public enum Level {
- /**
- * HIGHレベル.
- */
- HIGH(1, "HIGH"),
-
- /**
- * LOWレベル.
- */
- LOW(0, "LOW");
-
- private int mValue;
- private String mName;
-
- Level(final int value, final String name) {
- mValue = value;
- mName = name;
- }
-
- public int getValue() {
- return mValue;
- }
-
- public String getName() {
- return mName;
- }
-
- public static Level getLevel(final int value) {
- for (Level level : values()) {
- if (level.getValue() == value) {
- return level;
- }
- }
- return null;
- }
- }
-
- /**
- * ピンのモード.
- */
- public enum Mode {
- GPIO_IN(PIN_MODE_GPIO_IN, "GPIOIN"),
- GPIO_OUT(PIN_MODE_GPIO_OUT, "GPIOOUT"),
- ANALOG(PIN_MODE_ANALOG, "ANALOG"),
- PWM(PIN_MODE_PWM, "PWM"),
- SERVO(PIN_MODE_SERVO, "SERVO");
-
- private int mValue;
- private String mName;
-
- Mode(final int value, final String name) {
- mValue = value;
- mName = name;
- }
-
- public int getValue() {
- return mValue;
- }
-
- public String getName() {
- return mName;
- }
-
- public static Mode getMode(final int value) {
- for (Mode mode : values()) {
- if (mode.getValue() == value) {
- return mode;
- }
- }
- return null;
- }
- }
-
- /**
- * ピン情報の構造体.
- */
- public enum Pin {
- PIN_D0(PIN_NO_D0, PORT_D0, BIT_D0, GPIO_OUT, "0", "D0"),
- PIN_D1(PIN_NO_D1, PORT_D1, BIT_D1, GPIO_OUT, "1", "D1"),
- PIN_D2(PIN_NO_D2, PORT_D2, BIT_D2, GPIO_OUT, "2", "D2"),
- PIN_D3(PIN_NO_D3, PORT_D3, BIT_D3, GPIO_OUT, "3", "D3"),
- PIN_D4(PIN_NO_D4, PORT_D4, BIT_D4, GPIO_OUT, "4", "D4"),
- PIN_D5(PIN_NO_D5, PORT_D5, BIT_D5, GPIO_OUT, "5", "D5"),
- PIN_D6(PIN_NO_D6, PORT_D6, BIT_D6, GPIO_OUT, "6", "D6"),
- PIN_D7(PIN_NO_D7, PORT_D7, BIT_D7, GPIO_OUT, "7", "D7"),
- PIN_D8(PIN_NO_D8, PORT_D8, BIT_D8, GPIO_OUT, "8", "D8"),
- PIN_D9(PIN_NO_D9, PORT_D9, BIT_D9, GPIO_OUT, "9", "D9"),
- PIN_D10(PIN_NO_D10, PORT_D10, BIT_D10, GPIO_OUT, "10", "D10"),
- PIN_D11(PIN_NO_D11, PORT_D11, BIT_D11, GPIO_OUT, "11", "D11"),
- PIN_D12(PIN_NO_D12, PORT_D12, BIT_D12, GPIO_OUT, "12", "D12"),
- PIN_D13(PIN_NO_D13, PORT_D13, BIT_D13, GPIO_OUT, "13", "D13"),
- PIN_A0(PIN_NO_A0, PORT_A0, BIT_A0, ANALOG, "14", "A0"),
- PIN_A1(PIN_NO_A1, PORT_A1, BIT_A1, ANALOG, "15", "A1"),
- PIN_A2(PIN_NO_A2, PORT_A2, BIT_A2, ANALOG, "16", "A2"),
- PIN_A3(PIN_NO_A3, PORT_A3, BIT_A3, ANALOG, "17", "A3"),
- PIN_A4(PIN_NO_A4, PORT_A4, BIT_A4, ANALOG, "18", "A4"),
- PIN_A5(PIN_NO_A5, PORT_A5, BIT_A5, ANALOG, "19", "A5");
-
- private final int mPinNumber;
- private final int mPort;
- private final int mBit;
- private final String[] mPinNames;
- private Mode mMode;
- private int mValue;
-
- Pin(final int pinNumber, final int port, final int bit, final Mode mode, final String... pinNames) {
- mPinNumber = pinNumber;
- mPort = port;
- mBit = bit;
- mMode = mode;
- mPinNames = pinNames;
- }
-
- /**
- * ピン番号を取得します.
- * @return ピン番号
- */
- public int getPinNumber() {
- return mPinNumber;
- }
-
- /**
- * 値を保持するための配列番号を取得します.
- * @return
- */
- public int getPort() {
- return mPort;
- }
-
- /**
- * デジタル値を格納するビットを取得します.
- * @return デジタル値を格納するビット
- */
- public int getBit() {
- return mBit;
- }
-
- /**
- * ピンの名前を取得します.
- * @return ピンの名前
- */
- public String[] getPinNames() {
- return mPinNames;
- }
-
- /**
- * ピンのモードを取得します.
- * @return ピンのモード
- */
- public Mode getMode() {
- return mMode;
- }
-
- /**
- * ピンのモードを設定します.
- * @param mode ピンのモード
- */
- public void setMode(final Mode mode) {
- mMode = mode;
- }
-
- /**
- * ピンの値を取得します.
- * @return ピンの値
- */
- public int getValue() {
- return mValue;
- }
-
- /**
- * ピンの値を設定します.
- * @param value ピンの値
- */
- public void setValue(final int value) {
- mValue = value;
- }
-
- /**
- * ピン番号からPinのインスタンスを取得します.
- * @param number ピン番号
- * @return Pinのインスタンス
- */
- public static Pin getPin(final int number) {
- for (Pin pin : values()) {
- if (pin.getPinNumber() == number) {
- return pin;
- }
- }
- return null;
- }
-
- /**
- * ピンの名前からPinのインスタンスを取得します.
- * @param pinName ピン名
- * @return Pinのインスタンス
- */
- public static Pin getPin(final String pinName) {
- for (Pin pin : values()) {
- if (pin.getPinNames()[1].equalsIgnoreCase(pinName)) {
- return pin;
- }
- }
- return null;
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/profile/FaBoGPIOProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/profile/FaBoGPIOProfile.java
deleted file mode 100644
index 055e5dbeec..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/profile/FaBoGPIOProfile.java
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
-FaBoGPIOProfile
-Copyright (c) 2014 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
-*/
-package org.deviceconnect.android.deviceplugin.fabo.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.fabo.FaBoDeviceService;
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.event.EventError;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.GPIOProfile;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.android.profile.api.PutApi;
-
-import static org.deviceconnect.message.DConnectMessage.RESULT_OK;
-
-/**
- * GPIO Profile.
- * @author NTT DOCOMO, INC.
- */
-public class FaBoGPIOProfile extends GPIOProfile {
-
- private void addGetAnalogApi(final FaBoShield.Pin pin) {
- // GET /gpio/analog/{pinName}
- switch (pin) {
- case PIN_A0:
- case PIN_A1:
- case PIN_A2:
- case PIN_A3:
- case PIN_A4:
- case PIN_A5:
- for (final String pinName : pin.getPinNames()) {
- addApi(new GetApi() {
- @Override
- public String getInterface() {
- return INTERFACE_ANALOG;
- }
-
- @Override
- public String getAttribute() {
- return pinName;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- if (!isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else {
- if (getFaBoDeviceControl().isPinSupported(pin)) {
- int value = getFaBoDeviceControl().getAnalog(pin);
- setValue(response, value);
- setResult(response, RESULT_OK);
- } else {
- MessageUtils.setNotSupportAttributeError(response, pin.getPinNames()[1] + " is not supported.");
- }
- }
- return true;
- }
- });
- }
- break;
- default:
- break;
- }
- }
-
- private void addGetDigitalApi(final FaBoShield.Pin pin) {
- // GET /gpio/digital/{pinName}
- switch (pin) {
- case PIN_D0:
- case PIN_D1:
- case PIN_D2:
- case PIN_D3:
- case PIN_D4:
- case PIN_D5:
- case PIN_D6:
- case PIN_D7:
- case PIN_D8:
- case PIN_D9:
- case PIN_D10:
- case PIN_D11:
- case PIN_D12:
- case PIN_D13:
- for (final String pinName : pin.getPinNames()) {
- addApi(new GetApi() {
- @Override
- public String getInterface() {
- return INTERFACE_DIGITAL;
- }
-
- @Override
- public String getAttribute() {
- return pinName;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- if (!isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else {
- if (getFaBoDeviceControl().isPinSupported(pin)) {
- FaBoShield.Level value = getFaBoDeviceControl().getDigital(pin);
- setValue(response, value.getValue());
- setResult(response, RESULT_OK);
- } else {
- MessageUtils.setNotSupportAttributeError(response, pin.getPinNames()[1] + " is not support.");
- }
- }
- return true;
- }
- });
- }
- break;
- default:
- break;
- }
- }
-
- private void addPostExportApi(final FaBoShield.Pin pin) {
- // POST /gpio/export/{pinName}
- for (final String pinName : pin.getPinNames()) {
- addApi(new PostApi() {
- @Override
- public String getInterface() {
- return INTERFACE_EXPORT;
- }
-
- @Override
- public String getAttribute() {
- return pinName;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- if (!isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else {
- if (getFaBoDeviceControl().isPinSupported(pin)) {
- Integer modeValue = parseInteger(request, "mode");
- if (modeValue != null) {
- FaBoShield.Mode mode = FaBoShield.Mode.getMode(modeValue);
- if (mode != null) {
- getFaBoDeviceControl().setPinMode(pin, mode);
- setMessage(response, pinName + "を" + mode.getName() + "モードに設定しました。");
- setResult(response, RESULT_OK);
- } else {
- MessageUtils.setInvalidRequestParameterError(response, "The value of mode must be defined 0-4.");
- }
- } else {
- MessageUtils.setInvalidRequestParameterError(response, "The value of mode is null.");
- }
- } else {
- MessageUtils.setNotSupportAttributeError(response, pin.getPinNames()[1] + " is not supported.");
- }
- }
- return true;
- }
- });
- }
- }
-
- private void addPostDigitalApi(final FaBoShield.Pin pin) {
- // POST /gpio/digital/{pinName}
- for (final String pinName : pin.getPinNames()) {
- addApi(new PostApi() {
- @Override
- public String getInterface() {
- return INTERFACE_DIGITAL;
- }
-
- @Override
- public String getAttribute() {
- return pinName;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- if (!isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else {
- if (getFaBoDeviceControl().isPinSupported(pin)) {
- Integer hlValue = parseInteger(request, PARAM_VALUE);
- if (hlValue != null) {
- FaBoShield.Level level = FaBoShield.Level.getLevel(hlValue);
- if (level != null) {
- getFaBoDeviceControl().writeDigital(pin, level);
- setMessage(response, pinName + "の値を" + level.getName() + "(" + level.getValue() + ")に変更");
- setResult(response, RESULT_OK);
- } else {
- MessageUtils.setInvalidRequestParameterError(response, "Value must be defined 1 or 0.");
- }
- } else {
- MessageUtils.setInvalidRequestParameterError(response, "Value is null.");
- }
- } else {
- MessageUtils.setNotSupportAttributeError(response, pin.getPinNames()[1] + " is not supported.");
- }
- }
- return true;
- }
- });
- }
- }
-
- private void addPostAnalogApi(final FaBoShield.Pin pin) {
- // POST /gpio/analog/{pinName}
- switch (pin) {
- case PIN_D3:
- case PIN_D5:
- case PIN_D6:
- case PIN_D9:
- case PIN_D10:
- case PIN_D11:
- for (final String pinName : pin.getPinNames()) {
- addApi(new PostApi() {
- @Override
- public String getInterface() {
- return INTERFACE_ANALOG;
- }
-
- @Override
- public String getAttribute() {
- return pinName;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- if (!isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else {
- if (getFaBoDeviceControl().isPinSupported(pin)) {
- Integer hlValue = parseInteger(request, PARAM_VALUE);
- if (hlValue != null) {
- if (hlValue >= 0 && hlValue <= 255) {
- getFaBoDeviceControl().writeAnalog(pin, hlValue);
- setResult(response, RESULT_OK);
- } else {
- MessageUtils.setInvalidRequestParameterError(response, "Value must be defined under 255.");
- }
- } else {
- MessageUtils.setInvalidRequestParameterError(response, "Value is null.");
- }
- } else {
- MessageUtils.setNotSupportAttributeError(response, pin.getPinNames()[1] + " is not supported.");
- }
- }
- return true;
- }
- });
- }
- break;
- default:
- break;
- }
- }
-
- private void addPutOnChangeApi() {
- // PUT /gpio/onChange
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_CHANGE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- EventError error = EventManager.INSTANCE.addEvent(request);
- if (EventError.NONE == error) {
- getFaBoDeviceService().registerOnChange(getServiceID(request));
- setResult(response, RESULT_OK);
- return true;
- } else {
- MessageUtils.setError(response, 100, "Failed add event.");
- return true;
- }
- }
- });
- }
-
- private void addPutDigitalApi(final FaBoShield.Pin pin) {
- // PUT /gpio/digital/{pinName}
- for (final String pinName : pin.getPinNames()) {
- addApi(new PutApi() {
- @Override
- public String getInterface() {
- return INTERFACE_DIGITAL;
- }
-
- @Override
- public String getAttribute() {
- return pinName;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- if (!isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else {
- if (getFaBoDeviceControl().isPinSupported(pin)) {
- getFaBoDeviceControl().writeDigital(pin, FaBoShield.Level.HIGH);
- setMessage(response, pinName + "の値をHIGH(1)に変更");
- setResult(response, RESULT_OK);
- } else {
- MessageUtils.setNotSupportAttributeError(response, pin.getPinNames()[1] + " is not supported.");
- }
- }
- return true;
- }
- });
- }
- }
-
- private void addDeleteOnChangeApi() {
- // DELETE /gpio/onChange
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return ATTRIBUTE_ON_CHANGE;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- boolean result = EventManager.INSTANCE.removeEvents(getOrigin(request));
- if (result) {
- getFaBoDeviceService().unregisterOnChange(getServiceID(request));
- setResult(response, RESULT_OK);
- return true;
- } else {
- MessageUtils.setError(response, 100, "Failed delete event.");
- return true;
- }
- }
- });
- }
-
- private void addDeleteDigitalApi(final FaBoShield.Pin pin) {
- // DELETE /gpio/digital/{pinName}
- for (final String pinName : pin.getPinNames()) {
- addApi(new DeleteApi() {
- @Override
- public String getInterface() {
- return INTERFACE_DIGITAL;
- }
-
- @Override
- public String getAttribute() {
- return pinName;
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- if (!isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else {
- if (getFaBoDeviceControl().isPinSupported(pin)) {
- getFaBoDeviceControl().writeDigital(pin, FaBoShield.Level.LOW);
- setMessage(response, pinName + "の値をLOW(0)に変更");
- setResult(response, RESULT_OK);
- } else {
- MessageUtils.setNotSupportAttributeError(response, pin.getPinNames()[1] + " is not supported.");
- }
- }
- return true;
- }
- });
- }
- }
-
- public FaBoGPIOProfile() {
- for (FaBoShield.Pin pin : FaBoShield.Pin.values()) {
- addGetAnalogApi(pin);
- addGetDigitalApi(pin);
- addPostExportApi(pin);
- addPostDigitalApi(pin);
- addPostAnalogApi(pin);
- addPutDigitalApi(pin);
- addDeleteDigitalApi(pin);
- }
- addPutOnChangeApi();
- addDeleteOnChangeApi();
- }
-
- private boolean isOnline() {
- return getService().isOnline();
- }
-
- private FaBoDeviceControl getFaBoDeviceControl() {
- return getFaBoDeviceService().getFaBoDeviceControl();
- }
-
- private FaBoDeviceService getFaBoDeviceService() {
- return (FaBoDeviceService) getContext();
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/profile/FaBoProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/profile/FaBoProfile.java
deleted file mode 100644
index d3736cbfc7..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/profile/FaBoProfile.java
+++ /dev/null
@@ -1,502 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.profile;
-
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.fabo.FaBoDeviceService;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.VirtualService;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileDataUtil;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ServiceData;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.DConnectProfile;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.android.service.DConnectService;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield.PIN_NO_A0;
-
-public class FaBoProfile extends DConnectProfile {
-
- public FaBoProfile() {
- // GET /gotapi/fabo/service
- addApi(new GetApi() {
- @Override
- public String getAttribute() {
- return "service";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- List services = new ArrayList<>();
-
- for (DConnectService service : getFaBoDeviceService().getServiceProvider().getServiceList()) {
- if (service instanceof VirtualService) {
- ServiceData serviceData = ((VirtualService) service).getServiceData();
-
- Bundle serviceBundle = new Bundle();
- serviceBundle.putString("vid", serviceData.getServiceId());
- serviceBundle.putString("name", serviceData.getName());
-
- List profiles = new ArrayList<>();
- for (ProfileData p : serviceData.getProfileDataList()) {
- profiles.add(createProfileData(p));
- }
- serviceBundle.putParcelableArray("profiles", profiles.toArray(new Bundle[profiles.size()]));
-
- services.add(serviceBundle);
- }
- }
-
- response.putExtra("services", services.toArray(new Bundle[services.size()]));
- setResult(response, DConnectMessage.RESULT_OK);
- return true;
- }
- });
-
- // POST /gotapi/fabo/service
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "service";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String name = request.getStringExtra("name");
-
- ServiceData serviceData = new ServiceData();
- serviceData.setName(name);
-
- VirtualService s = getFaBoDeviceService().addServiceData(serviceData);
- if (s != null) {
- response.putExtra("vid", s.getServiceData().getServiceId());
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- MessageUtils.setUnknownError(response, "Failed to create a virtual service.");
- }
-
- return true;
- }
- });
-
- // PUT /gotapi/fabo/service
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "service";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String name = request.getStringExtra("name");
- String vid = request.getStringExtra("vid");
-
- ServiceData serviceData = getFaBoDeviceService().getServiceData(vid);
- if (serviceData == null) {
- MessageUtils.setInvalidRequestParameterError(response, "Not found the virtual service. vid=" + vid);
- } else {
- serviceData.setName(name);
-
- VirtualService s = getFaBoDeviceService().updateServiceData(serviceData);
- if (s != null) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- MessageUtils.setUnknownError(response, "Failed to create a virtual service.");
- }
- }
-
- return true;
- }
- });
-
- // DELETE /gotapi/fabo/service
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "service";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String vid = request.getStringExtra("vid");
-
- ServiceData serviceData = getFaBoDeviceService().getServiceData(vid);
- if (serviceData == null) {
- MessageUtils.setInvalidRequestParameterError(response, "Not found the virtual service. vid=" + vid);
- } else {
- getFaBoDeviceService().removeServiceData(serviceData);
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- // GET /gotapi/fabo/profile
- addApi(new GetApi() {
- @Override
- public String getAttribute() {
- return "profile";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String vid = request.getStringExtra("vid");
-
- ServiceData serviceData = getFaBoDeviceService().getServiceData(vid);
- if (serviceData == null) {
- MessageUtils.setInvalidRequestParameterError(response, "Not found the virtual service. vid=" + vid);
- } else {
- List profiles = new ArrayList<>();
- for (ProfileData p : serviceData.getProfileDataList()) {
- profiles.add(createProfileData(p));
- }
- response.putExtra("profiles", profiles.toArray(new Bundle[profiles.size()]));
- setResult(response, DConnectMessage.RESULT_OK);
- }
-
- return true;
- }
- });
-
- // POST /gotapi/fabo/profile
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "profile";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String vid = request.getStringExtra("vid");
- Integer type = parseInteger(request, "type");
- String pins = request.getStringExtra("pins");
-
- ProfileData.Type profileType = ProfileData.Type.getType(type);
- ServiceData serviceData = getFaBoDeviceService().getServiceData(vid);
- List pinList = toPinList(pins);
- if (serviceData == null) {
- MessageUtils.setInvalidRequestParameterError(response, "Not found the virtual service.");
- } else if (pinList == null) {
- MessageUtils.setInvalidRequestParameterError(response, "Format of pins is invalid.");
- } else if (profileType == null) {
- MessageUtils.setInvalidRequestParameterError(response, "Not found the profile type.");
- } else if (profileType.getCategory() == ProfileData.Category.GPIO && pinList.isEmpty()) {
- MessageUtils.setInvalidRequestParameterError(response, "For GPIO, pins is required.");
- } else if (profileType.getCategory() == ProfileData.Category.GPIO && !ProfileDataUtil.isMultiChoicePin(profileType) && pinList.size() > 1) {
- MessageUtils.setInvalidRequestParameterError(response, "There is only one pin.");
- } else if (profileType.getCategory() == ProfileData.Category.GPIO && usedPin(serviceData, profileType, pinList)) {
- MessageUtils.setInvalidRequestParameterError(response, "pins already used in the " + serviceData.getName());
- } else if (profileType.getCategory() == ProfileData.Category.GPIO && !isPinsSupported(pinList)) {
- MessageUtils.setNotSupportAttributeError(response, "pins contains unsupported PIN.");
- } else if (profileType.getCategory() == ProfileData.Category.GPIO && !checkPinType(profileType, pinList)) {
- MessageUtils.setInvalidRequestParameterError(response, "Pins that can not be used are included.");
- } else if (containsProfile(serviceData, profileType)) {
- MessageUtils.setInvalidRequestParameterError(response, "This service already has the same profile.");
- } else {
- ProfileData p = new ProfileData();
- p.setServiceId(vid);
- p.setType(profileType);
- p.setPinList(pinList);
-
- serviceData.addProfileData(p);
-
- VirtualService s = getFaBoDeviceService().updateServiceData(serviceData);
- if (s != null) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- MessageUtils.setUnknownError(response, "Failed to update the service data.");
- }
- }
-
- return true;
- }
- });
-
- // PUT /gotapi/fabo/profile
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "profile";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String vid = request.getStringExtra("vid");
- Integer type = parseInteger(request, "type");
- String pins = request.getStringExtra("pins");
-
- ProfileData.Type profileType = ProfileData.Type.getType(type);
- ServiceData serviceData = getFaBoDeviceService().getServiceData(vid);
- List pinList = toPinList(pins);
- if (serviceData == null) {
- MessageUtils.setInvalidRequestParameterError(response, "Not found the virtual service.");
- } else if (pinList == null) {
- MessageUtils.setInvalidRequestParameterError(response, "Format of pins is invalid.");
- } else if (profileType == null) {
- MessageUtils.setInvalidRequestParameterError(response, "Not found the profile type.");
- } else if (profileType.getCategory() == ProfileData.Category.GPIO && pinList.isEmpty()) {
- MessageUtils.setInvalidRequestParameterError(response, "For GPIO, pins is required.");
- } else if (profileType.getCategory() == ProfileData.Category.GPIO && !ProfileDataUtil.isMultiChoicePin(profileType) && pinList.size() > 1) {
- MessageUtils.setInvalidRequestParameterError(response, "There is only one pin.");
- } else if (profileType.getCategory() == ProfileData.Category.GPIO && usedPin(serviceData, profileType, pinList)) {
- MessageUtils.setInvalidRequestParameterError(response, "pins already used in the " + serviceData.getName());
- } else if (profileType.getCategory() == ProfileData.Category.GPIO && !isPinsSupported(pinList)) {
- MessageUtils.setNotSupportAttributeError(response, "pins contains unsupported PIN.");
- } else if (profileType.getCategory() == ProfileData.Category.GPIO && !checkPinType(profileType, pinList)) {
- MessageUtils.setInvalidRequestParameterError(response, "Pins that can not be used are included.");
- } else if (!isSameProfile(serviceData, profileType) && containsProfile(serviceData, profileType)) {
- MessageUtils.setInvalidRequestParameterError(response, "This service already has the same profile.");
- } else {
- ProfileData p = new ProfileData();
- p.setServiceId(vid);
- p.setType(profileType);
- p.setPinList(pinList);
-
- serviceData.addProfileData(p);
-
- VirtualService s = getFaBoDeviceService().updateServiceData(serviceData);
- if (s != null) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- MessageUtils.setUnknownError(response, "Failed to update the service data.");
- }
- }
-
- return true;
- }
- });
-
- // DELETE /gotapi/fabo/profile
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "profile";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String vid = request.getStringExtra("vid");
- Integer type = parseInteger(request, "type");
-
- ProfileData.Type profileType = ProfileData.Type.getType(type);
- ServiceData serviceData = getFaBoDeviceService().getServiceData(vid);
- if (serviceData == null) {
- MessageUtils.setInvalidRequestParameterError(response, "Not found the virtual service.");
- } else if (profileType == null) {
- MessageUtils.setInvalidRequestParameterError(response, "Not found the profile type.");
- } else {
- ProfileData profileData = serviceData.getProfileData(profileType);
- if (profileData == null) {
- MessageUtils.setInvalidRequestParameterError(response, "Virtual service has not the " + type);
- } else {
- serviceData.removeProfileData(profileData);
-
- VirtualService s = getFaBoDeviceService().updateServiceData(serviceData);
- if (s != null) {
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- MessageUtils.setUnknownError(response, "Failed to update the service data.");
- }
- }
- }
-
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "fabo";
- }
-
- /**
- * 指定されたサービスデータが指定されたプロファイルデータを持っているか確認します.
- *
- * Brickが異なっても同じプロファイルの場合には同じプロファイルとしてみなす。
- *
- * @param serviceData サービスデータ
- * @param type プロファイルタイプ
- * @return プロファイルデータを持っている場合はtrue、それ以外はfalse
- */
- private boolean containsProfile(final ServiceData serviceData, final ProfileData.Type type) {
- for (ProfileData profileData : serviceData.getProfileDataList()) {
- if (profileData.getType().getProfileName().equals(type.getProfileName())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * 同じプロファイルを持っているか確認を行います.
- *
- * Brickとプロファイル療法が同じ場合に同じプロファイルとみなす。
- *
- * @param serviceData サービスデータ
- * @param type プロファイルタイプ
- * @return 同じプロファイルを持つ場合はtrue、それ以外はfalse
- */
- private boolean isSameProfile(final ServiceData serviceData, final ProfileData.Type type) {
- for (ProfileData profileData : serviceData.getProfileDataList()) {
- if (profileData.getType() == type) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * ListString[]に変換します.
- *
- * 引数にnullが指定された場合は、空の配列を返却します。
- *
- * @param list 変換前のリスト
- * @return 変換後int[]
- */
- private String[] toArray(final List list) {
- if (list == null) {
- return new String[0];
- }
- String[] b = new String[list.size()];
- for (int i = 0; i < list.size(); i++) {
- b[i] = FaBoShield.Pin.getPin(list.get(i)).getPinNames()[1];
- }
- return b;
- }
-
- /**
- * プロファイルデータ用のBundleを作成します.
- * @param p プロファイルデータ
- * @return プロファイルデータを格納したBundle
- */
- private Bundle createProfileData(final ProfileData p) {
- Bundle b = new Bundle();
- b.putInt("type", p.getType().getValue());
- b.putString("name", ProfileDataUtil.getProfileName(getContext(), p.getType()));
- b.putString("brick", p.getType().getBrick());
- b.putStringArray("pins", toArray(p.getPinList()));
- b.putString("category", p.getType().getCategory().getValue());
- return b;
- }
-
- /**
- * カンマ区切りで送られてきた文字列をListに変換します.
- * @param pins ピンのデータ
- * @return ピンのデータ
- */
- private List toPinList(final String pins) {
- if (pins == null || pins.isEmpty()) {
- return new ArrayList<>();
- }
- List pinList = new ArrayList<>();
- String[] split = pins.split(",");
- for (String s : split) {
- try {
- FaBoShield.Pin pin = FaBoShield.Pin.getPin(s);
- if (pin != null) {
- if (!pinList.contains(pin.getPinNumber())) {
- pinList.add(pin.getPinNumber());
- }
- } else {
- Integer i = Integer.parseInt(s);
- if (isPin(i) && !pinList.contains(i)) {
- pinList.add(i);
- } else {
- return null;
- }
- }
- } catch (NumberFormatException e) {
- return null;
- }
- }
- return pinList;
- }
-
- /**
- * 指定された番号がピンに存在するか確認します.
- * @param pin ピン番号
- * @return ピンが存在する場合はtrue、それ以外はfalse
- */
- private boolean isPin(final int pin) {
- return FaBoShield.Pin.getPin(pin) != null;
- }
-
- /**
- * 指定されたピンのリストがサポートされているか確認します.
- * @param pins 確認するピンのリスト
- * @return 全てのピンがサポートされている場合はtrue、それ以外はfalse
- */
- private boolean isPinsSupported(final List pins) {
- for (int pin : pins) {
- if (!isPinSupported(pin)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * 指定されたピンがサポートされているか確認します.
- * @param pinNum 確認するピン番号
- * @return サポートされている場合はtrue、それ以外はfalse
- */
- private boolean isPinSupported(final int pinNum) {
- FaBoShield.Pin pin = FaBoShield.Pin.getPin(pinNum);
- return pin != null && getFaBoDeviceService().getFaBoDeviceControl().isPinSupported(pin);
- }
-
- /**
- * ピンのタイプを確認します.
- * @param type ピンのタイプ
- * @param pins ピン
- * @return ピンのタイプが合って入ればtrue、それ以外はfalse
- */
- private boolean checkPinType(final ProfileData.Type type, final List pins) {
- ProfileDataUtil.PinType pinType = ProfileDataUtil.getPinType(type);
- for (int pin : pins) {
- switch (pinType) {
- case ANALOG:
- if (pin < PIN_NO_A0) {
- return false;
- }
- break;
- case DIGITAL:
- if (pin >= PIN_NO_A0) {
- return false;
- }
- break;
- }
- }
- return true;
- }
-
- /**
- * 指定されたピンが仮想サービスで使用されているか確認を行います。
- * @param serviceData 仮想サービスデータ
- * @param type プロファイルのタイプ
- * @param pins 確認を行うピンのリスト
- * @return 既に使用されている場合はtrue、それ以外はfalse
- */
- private boolean usedPin(final ServiceData serviceData, final ProfileData.Type type, final List pins) {
- ProfileData profileData = serviceData.getProfileData(type);
- for (Integer p : pins) {
- if ((profileData == null || !profileData.usedPin(p)) && serviceData.usedPin(p)) {
- return true;
- }
- }
- return false;
- }
-
- private FaBoDeviceService getFaBoDeviceService() {
- return (FaBoDeviceService) getContext();
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/profile/FaBoSystemProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/profile/FaBoSystemProfile.java
deleted file mode 100644
index 64933bec3c..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/profile/FaBoSystemProfile.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-FaBoSystemProfile
-Copyright (c) 2014 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
-*/
-package org.deviceconnect.android.deviceplugin.fabo.profile;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.fabo.setting.FaBoServiceListActivity;
-import org.deviceconnect.android.profile.SystemProfile;
-
-/**
- * FaBoデバイスプラグイン, System プロファイル.
- * @author NTT DOCOMO, INC.
- */
-public class FaBoSystemProfile extends SystemProfile {
-
- @Override
- protected Class extends Activity> getSettingPageActivity(final Intent request, final Bundle param) {
- return FaBoServiceListActivity.class;
- }
-
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/FaBoService.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/FaBoService.java
deleted file mode 100644
index b91bbe9fb5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/FaBoService.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service;
-
-import org.deviceconnect.android.deviceplugin.fabo.profile.FaBoGPIOProfile;
-import org.deviceconnect.android.deviceplugin.fabo.profile.FaBoProfile;
-import org.deviceconnect.android.service.DConnectService;
-
-/**
- * FaBoを直接操作するためのサービス.
- */
-public class FaBoService extends DConnectService {
- /**
- * サービスを識別するID.
- */
- private static final String SERVICE_ID = "gpio_service_id";
-
- /**
- * サービス名.
- */
- private static final String DEVICE_NAME = "FaBo Device";
-
- /**
- * コンストラクタ.
- */
- public FaBoService() {
- super(SERVICE_ID);
- setName(DEVICE_NAME);
- setNetworkType(NetworkType.UNKNOWN);
- setOnline(true);
- addProfile(new FaBoGPIOProfile());
- addProfile(new FaBoProfile());
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/VirtualService.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/VirtualService.java
deleted file mode 100644
index 3bd0fbfab8..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/VirtualService.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual;
-
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ServiceData;
-import org.deviceconnect.android.service.DConnectService;
-
-/**
- * 仮想サービス.
- */
-public class VirtualService extends DConnectService {
-
- /**
- * 仮想サービスのデータ.
- */
- private ServiceData mServiceData;
-
- /**
- * コンストラクタ.
- * @param serviceData 仮想サービスデータ
- */
- VirtualService(final ServiceData serviceData) {
- super(serviceData.getServiceId());
- mServiceData = serviceData;
- }
-
- /**
- * 仮想サービスデータを取得します.
- * @return 仮想サービスデータ
- */
- public ServiceData getServiceData() {
- return mServiceData;
- }
-
- /**
- * サービスデータを設定します.
- * @param serviceData 設定するサービスデータ
- */
- public void setServiceData(final ServiceData serviceData) {
- mServiceData = serviceData;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/VirtualServiceFactory.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/VirtualServiceFactory.java
deleted file mode 100644
index 2962aad88e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/VirtualServiceFactory.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual;
-
-import android.util.Log;
-
-import org.deviceconnect.android.deviceplugin.fabo.core.BuildConfig;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ServiceData;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.GPIOHumidityProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.GPIOIlluminanceProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.GPIOKeyEventProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.GPIOLightProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.GPIOProximityProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.GPIOTemperatureProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.GPIOVibrationProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.I2C3AxisDeviceOrientationProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.I2CAtmosphericPressureProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.I2CHumidityProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.I2CIlluminanceProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.I2CLIDARLiteProximityProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.I2CMouseCarDriveControllerProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.I2CProximityProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.I2CRobotCarDriveControllerProfile;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile.I2CTemperatureProfile;
-import org.deviceconnect.android.profile.DConnectProfile;
-import org.deviceconnect.profile.ServiceDiscoveryProfileConstants;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 仮想サービスを作成するためのファクトリークラス.
- */
-public final class VirtualServiceFactory {
- /**
- * デバッグフラグ.
- */
- private static final boolean DEBUG = BuildConfig.DEBUG;
-
- /**
- * デバッグ用タグ.
- */
- private static final String TAG = "FaBo";
-
- /**
- * 仮想サービスデータからDConnectServiceのインスタンスを作成します.
- * @param serviceData 仮想サービスデータ
- * @return DConnectServiceのインスタンス
- */
- public static VirtualService createService(final ServiceData serviceData) {
- if (DEBUG) {
- Log.d(TAG, "==========================");
- Log.d(TAG, "Create virtual service.");
- Log.d(TAG, "ID: " + serviceData.getServiceId());
- Log.d(TAG, "Name: " + serviceData.getName());
- }
-
- VirtualService service = new VirtualService(serviceData);
- service.setName(serviceData.getName());
- service.setNetworkType(ServiceDiscoveryProfileConstants.NetworkType.UNKNOWN);
- for (ProfileData p : serviceData.getProfileDataList()) {
- DConnectProfile profile = createProfile(p);
- if (profile != null) {
- service.addProfile(profile);
- }
- }
- if (DEBUG) {
- Log.d(TAG, "==========================");
- }
- return service;
- }
-
- /**
- * プロファイルデータからプロファイルを作成します.
- * @param profileData プロファイルデータ
- * @return DConnectProfileのインスタンス
- */
- public static DConnectProfile createProfile(final ProfileData profileData) {
- if (DEBUG) {
- Log.d(TAG, " Add " + profileData.getType());
- }
-
- switch (profileData.getType()) {
- case GPIO_LIGHT:
- return new GPIOLightProfile(conv(profileData.getPinList()));
-
- case GPIO_TEMPERATURE:
- return new GPIOTemperatureProfile(conv(profileData.getPinList()));
-
- case GPIO_VIBRATION:
- return new GPIOVibrationProfile(conv(profileData.getPinList()));
-
- case GPIO_ILLUMINANCE:
- return new GPIOIlluminanceProfile(conv(profileData.getPinList()));
-
- case GPIO_HUMIDITY:
- return new GPIOHumidityProfile(conv(profileData.getPinList()));
-
- case GPIO_KEY_EVENT:
- return new GPIOKeyEventProfile(conv(profileData.getPinList()));
-
- case GPIO_PROXIMITY:
- return new GPIOProximityProfile(conv(profileData.getPinList()));
-
- case I2C_MOUSE_DRIVE_CONTROLLER:
- return new I2CMouseCarDriveControllerProfile();
-
- case I2C_ROBOT_DRIVE_CONTROLLER:
- return new I2CRobotCarDriveControllerProfile();
-
- case I2C_3AXIS_DEVICE_ORIENTATION:
- return new I2C3AxisDeviceOrientationProfile();
-
- case I2C_TEMPERATURE:
- return new I2CTemperatureProfile();
-
- case I2C_HUMIDITY:
- return new I2CHumidityProfile();
-
- case I2C_PROXIMITY:
- return new I2CProximityProfile();
-
- case I2C_ILLUMINANCE:
- return new I2CIlluminanceProfile();
-
- case I2C_ATMOSPHERIC_PRESSURE:
- return new I2CAtmosphericPressureProfile();
-
- case I2C_LIDARLITE_PROXIMITY:
- return new I2CLIDARLiteProximityProfile();
-
- default:
- if (DEBUG) {
- Log.w(TAG, "Not found the profile.");
- Log.w(TAG, "ID: " + profileData.getServiceId());
- Log.w(TAG, "Type: " + profileData.getType());
- }
- break;
- }
- return null;
- }
-
- /**
- * ピン情報をArudinoUno.Pinのリストに変換します.
- * @param pins 変換前のピン情報
- * @return ArudinoUno.Pinのリスト
- */
- private static List conv(List pins) {
- List pinList = new ArrayList<>();
- for (Integer i : pins) {
- pinList.add(FaBoShield.Pin.getPin(i));
- }
- return pinList;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/db/ProfileData.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/db/ProfileData.java
deleted file mode 100644
index 27e379bdf2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/db/ProfileData.java
+++ /dev/null
@@ -1,374 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.db;
-
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * プロファイルデータ.
- */
-public class ProfileData implements Parcelable {
-
- /**
- * カテゴリ.
- */
- public enum Category {
- /**
- * GPIOを表すカテゴリー.
- */
- GPIO("GPIO"),
-
- /**
- * I2Cを表すカテゴリー.
- */
- I2C("I2C");
-
- private String mValue;
-
- Category(final String value) {
- mValue = value;
- }
-
- public String getValue() {
- return mValue;
- }
- }
-
- /**
- * 仮想サービスに登録するプロファイルのタイプ.
- */
- public enum Type {
- /**
- * GPIO用Lightプロファイル.
- *
- * Brick: #101
- *
- */
- GPIO_LIGHT(1, "#101", Category.GPIO, "light"),
-
- /**
- * GPIO用Temperatureプロファイル.
- *
- * Brick: #108
- *
- */
- GPIO_TEMPERATURE(2, "#108", Category.GPIO, "temperature"),
-
- /**
- * GPIO用Vibrationプロファイル.
- *
- * Brick: #105
- *
- */
- GPIO_VIBRATION(3, "#105", Category.GPIO, "vibration"),
-
- /**
- * GPIO用Illuminanceプロファイル.
- *
- * Brick: #109
- *
- */
- GPIO_ILLUMINANCE(4, "#109", Category.GPIO, "illuminace"),
-
- /**
- * GPIO用KeyEventプロファイル.
- *
- * Brick: #103
- *
- */
- GPIO_KEY_EVENT(5, "#103", Category.GPIO, "keyEvent"),
-
- /**
- * GPIO用Humidityプロファイル.
- *
- * Brick: #115
- *
- */
- GPIO_HUMIDITY(6, "#115", Category.GPIO, "humidity"),
-
- /**
- * GPIO用Proximityプロファイル.
- *
- * Brick: #1116
- *
- */
- GPIO_PROXIMITY(7, "#116", Category.GPIO, "proximity"),
-
- /**
- * I2C用RobotCar用DriveControllerプロファイル.
- */
- I2C_ROBOT_DRIVE_CONTROLLER(100, null, Category.I2C, "driveController"),
-
- /**
- * I2C用RobotCar(Mouse)用DriveControllerプロファイル.
- */
- I2C_MOUSE_DRIVE_CONTROLLER(101, null, Category.I2C, "driveController"),
-
- /**
- * I2C用DeviceOrientation(3axis)プロファイル.
- *
- * Brick: #201
- *
- */
- I2C_3AXIS_DEVICE_ORIENTATION(102, "#201", Category.I2C, "deviceOrientation"),
-
- /**
- * I2C用Temperatureプロファイル.
- *
- * Brick: #207
- *
- */
- I2C_TEMPERATURE(103, "#207", Category.I2C, "temperature"),
-
- /**
- * I2C用Humidityプロファイル.
- *
- * Brick: #208
- *
- */
- I2C_HUMIDITY(104, "#208", Category.I2C, "humidity"),
-
- /**
- * I2C用Proximityプロファイル.
- *
- * Brick: #205
- *
- */
- I2C_PROXIMITY(105, "#205", Category.I2C, "proximity"),
-
- /**
- * I2C用Illuminanceプロファイル.
- *
- * Brick: #217
- *
- */
- I2C_ILLUMINANCE(106, "#217", Category.I2C, "illuminace"),
-
- /**
- * I2C用AtmosphericPressureプロファイル.
- *
- * Brick: #204
- *
- */
- I2C_ATMOSPHERIC_PRESSURE(107, "#204", Category.I2C, "atmosphericPressure"),
-
- /**
- * I2C用Proximityプロファイル.
- *
- * Brick: #222
- *
- */
- I2C_LIDARLITE_PROXIMITY(108, "#222", Category.I2C, "proximity");
-
- /**
- * プロファイルの種別.
- */
- private int mValue;
-
- /**
- * BrickのID.
- */
- private String mBrick;
-
- /**
- * カテゴリ-.
- */
- private Category mCategory;
-
- /**
- * プロファイル名.
- */
- private String mProfileName;
-
- Type(final int value, final String brick, final Category category, final String profileName) {
- mValue = value;
- mBrick = brick;
- mCategory = category;
- mProfileName = profileName;
- }
-
- /**
- * プロファイルの種別を取得します.
- * @return プロファイルの種別
- */
- public int getValue() {
- return mValue;
- }
-
- /**
- * プロファイルが対応するBrick番号を取得します.
- * @return Brickを識別するID
- */
- public String getBrick() {
- return mBrick;
- }
-
- /**
- * プロファイルのカテゴリーを取得します.
- * @return CATEGORY_GPIO もしくは CATEGORY_I2C
- */
- public Category getCategory() {
- return mCategory;
- }
-
- /**
- * プロファイル名を取得します.
- * @return プロファイル名
- */
- public String getProfileName() {
- return mProfileName;
- }
-
- /**
- * 指定された値からプロファイルのタイプを取得します.
- * @param type プロファイルのタイプ
- * @return プロファイルタイプ
- */
- public static Type getType(final int type) {
- for (Type t : values()) {
- if (t.getValue() == type) {
- return t;
- }
- }
- return null;
- }
- }
-
- /**
- * プロファイルが属する仮想サービスのID.
- */
- private String mServiceId;
-
- /**
- * プロファイルタイプ.
- */
- private Type mType;
-
- /**
- * プロファイルが操作を行うピン一覧.
- */
- private List mPinList = new ArrayList<>();
-
- /**
- * コンストラクタ.
- */
- public ProfileData() {
- }
-
- /**
- * Parcelable用のコンストラクタ.
- * @param parcel Parcel
- */
- private ProfileData(final Parcel parcel) {
- mType = Type.getType(parcel.readInt());
- mServiceId = parcel.readString();
- parcel.readList(mPinList, ProfileData.class.getClassLoader());
- }
-
- /**
- * プロファイルが属するサービスIDを取得します.
- * @return サービスID
- */
- public String getServiceId() {
- return mServiceId;
- }
-
- /**
- * プロファイルが属するサービスIDを設定します.
- * @param serviceId サービスID
- */
- public void setServiceId(final String serviceId) {
- mServiceId = serviceId;
- }
-
- /**
- * プロファイルのタイプを取得します.
- * @return プロファイルのタイプ
- */
- public Type getType() {
- return mType;
- }
-
- /**
- * プロファイルのタイプを設定します.
- * @param type プロファイルのタイプ
- */
- public void setType(final Type type) {
- mType = type;
- }
-
- /**
- * プロファイルが操作するピンのリストを取得します.
- * @return プロファイルが操作するピンのリスト
- */
- public List getPinList() {
- return mPinList;
- }
-
- /**
- * プロファイルが操作するピンのリストを設定します.
- * @param pinList プロファイルが操作するピンのリスト
- */
- public void setPinList(final List pinList) {
- mPinList = pinList;
- }
-
- /**
- * プロファイルが操作するピンをリストに追加します.
- * @param pin 追加するピン
- */
- public void addPin(final int pin) {
- mPinList.add(pin);
- }
-
- public boolean usedPin(final int pin) {
- return mPinList.contains(pin);
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(final Parcel parcel, final int flags) {
- parcel.writeInt(mType.getValue());
- parcel.writeString(mServiceId);
- parcel.writeList(mPinList);
- }
-
- public static final Creator CREATOR = new Creator() {
- @Override
- public ProfileData createFromParcel(final Parcel source) {
- return new ProfileData(source);
- }
- @Override
- public ProfileData[] newArray(final int size) {
- return new ProfileData[size];
- }
- };
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + mType.getValue();
- result = prime * result + ((mServiceId == null) ? 0 : mServiceId.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
- ProfileData other = (ProfileData) obj;
- return mType == other.mType && mServiceId.equals(other.getServiceId());
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/db/ProfileDataUtil.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/db/ProfileDataUtil.java
deleted file mode 100644
index c2e15141aa..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/db/ProfileDataUtil.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.db;
-
-import android.content.Context;
-
-import org.deviceconnect.android.deviceplugin.fabo.core.R;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData.Type.GPIO_HUMIDITY;
-import static org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData.Type.GPIO_ILLUMINANCE;
-import static org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData.Type.GPIO_KEY_EVENT;
-import static org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData.Type.GPIO_LIGHT;
-import static org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData.Type.GPIO_PROXIMITY;
-import static org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData.Type.GPIO_TEMPERATURE;
-import static org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData.Type.GPIO_VIBRATION;
-
-public final class ProfileDataUtil {
-
- private ProfileDataUtil() {}
-
- /**
- * プロファイルが使用できるピンのタイプを保持するマップ.
- */
- private static Map mPinTypeMap = new HashMap<>();
-
- /**
- * プロファイルが複数のピンの操作ができるのかを保持するマップ.
- */
- private static Map mMultiChoiceMap = new HashMap<>();
-
- static {
- mPinTypeMap.put(GPIO_LIGHT, PinType.DIGITAL);
- mPinTypeMap.put(GPIO_TEMPERATURE, PinType.ANALOG);
- mPinTypeMap.put(GPIO_VIBRATION, PinType.DIGITAL);
- mPinTypeMap.put(GPIO_ILLUMINANCE, PinType.ANALOG);
- mPinTypeMap.put(GPIO_KEY_EVENT, PinType.ALL);
- mPinTypeMap.put(GPIO_HUMIDITY, PinType.ANALOG);
- mPinTypeMap.put(GPIO_PROXIMITY, PinType.ANALOG);
-
- mMultiChoiceMap.put(GPIO_LIGHT, true);
- mMultiChoiceMap.put(GPIO_TEMPERATURE, false);
- mMultiChoiceMap.put(GPIO_VIBRATION, true);
- mMultiChoiceMap.put(GPIO_ILLUMINANCE, false);
- mMultiChoiceMap.put(GPIO_KEY_EVENT, true);
- mMultiChoiceMap.put(GPIO_HUMIDITY, false);
- mMultiChoiceMap.put(GPIO_PROXIMITY, false);
- }
-
- /**
- * プロファイルの名前を取得します.
- * @param context コンテキスト
- * @param type プロファイルのタイプ
- * @return プロファイル名
- */
- public static String getProfileName(final Context context, final ProfileData.Type type) {
- switch (type) {
- case GPIO_LIGHT:
- return context.getString(R.string.activity_fabo_virtual_gpio_light);
- case GPIO_TEMPERATURE:
- return context.getString(R.string.activity_fabo_virtual_gpio_temperature);
- case GPIO_VIBRATION:
- return context.getString(R.string.activity_fabo_virtual_gpio_vibration);
- case GPIO_ILLUMINANCE:
- return context.getString(R.string.activity_fabo_virtual_gpio_illuminance);
- case GPIO_KEY_EVENT:
- return context.getString(R.string.activity_fabo_virtual_gpio_key_event);
- case GPIO_HUMIDITY:
- return context.getString(R.string.activity_fabo_virtual_gpio_humidity);
- case GPIO_PROXIMITY:
- return context.getString(R.string.activity_fabo_virtual_gpio_proximity);
- case I2C_ROBOT_DRIVE_CONTROLLER:
- return context.getString(R.string.activity_fabo_virtual_i2c_robot_drivecontroller);
- case I2C_MOUSE_DRIVE_CONTROLLER:
- return context.getString(R.string.activity_fabo_virtual_i2c_mouse_drivecontroller);
- case I2C_3AXIS_DEVICE_ORIENTATION:
- return context.getString(R.string.activity_fabo_virtual_i2c_3axis_device_orientation);
- case I2C_TEMPERATURE:
- return context.getString(R.string.activity_fabo_virtual_i2c_temperature);
- case I2C_HUMIDITY:
- return context.getString(R.string.activity_fabo_virtual_i2c_humidity);
- case I2C_PROXIMITY:
- return context.getString(R.string.activity_fabo_virtual_i2c_proximity);
- case I2C_ILLUMINANCE:
- return context.getString(R.string.activity_fabo_virtual_i2c_illuminace);
- case I2C_ATMOSPHERIC_PRESSURE:
- return context.getString(R.string.activity_fabo_virtual_i2c_atmospheric_pressure);
- case I2C_LIDARLITE_PROXIMITY:
- return context.getString(R.string.activity_fabo_virtual_i2c_lidarlite_proximity);
- }
- return null;
- }
-
- /**
- * プロファイルが使用できるピンのタイプを取得します.
- * @param profileData プロファイルデータ
- * @return 使用できるピンのタイプ
- */
- public static PinType getPinType(final ProfileData profileData) {
- return mPinTypeMap.get(profileData.getType());
- }
-
-
- /**
- * プロファイルが使用できるピンのタイプを取得します.
- * @param type プロファイルタイプ
- * @return 使用できるピンのタイプ
- */
- public static PinType getPinType(final ProfileData.Type type) {
- return mPinTypeMap.get(type);
- }
-
- /**
- * プロファイルが複数のピンを使用できるかを確認します.
- * @param profileData プロファイルデータ
- * @return 複数選択できる場合はtrue、それ以外はfalse
- */
- public static boolean isMultiChoicePin(final ProfileData profileData) {
- return mMultiChoiceMap.get(profileData.getType());
- }
-
- /**
- * プロファイルが複数のピンを使用できるかを確認します.
- * @param type プロファイルデータ
- * @return 複数選択できる場合はtrue、それ以外はfalse
- */
- public static boolean isMultiChoicePin(final ProfileData.Type type) {
- return mMultiChoiceMap.get(type);
- }
-
-
- /**
- * プロファイルが使用できるピンのタイプ.
- */
- public enum PinType {
- /**
- * AnalogとDigitalの療法が使用できます.
- */
- ALL,
-
- /**
- * Analogが使用できます.
- */
- ANALOG,
-
- /**
- * Digitalが使用できます.
- */
- DIGITAL
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/db/ServiceData.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/db/ServiceData.java
deleted file mode 100644
index 70179ba881..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/db/ServiceData.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.db;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 仮想サービスデータ.
- */
-public class ServiceData implements Parcelable {
- /**
- * 仮想サービスのID.
- */
- private String mServiceId;
-
- /**
- * 仮想サービスの名前.
- */
- private String mName;
-
- /**
- * 仮想サービスが保持するプロファイルデータ.
- */
- private List mProfileDataList = new ArrayList<>();
-
- /**
- * コンストラクタ.
- */
- public ServiceData() {
- }
-
- /**
- * Parcelable用のコンストラクタ.
- * @param parcel Parcel
- */
- private ServiceData(final Parcel parcel) {
- mServiceId = parcel.readString();
- mName = parcel.readString();
- parcel.readList(mProfileDataList, ServiceData.class.getClassLoader());
- }
-
- /**
- * サービスIDを取得します.
- * @return サービスID
- */
- public String getServiceId() {
- return mServiceId;
- }
-
- /**
- * サービスIDを設定します.
- * @param serviceId サービスID
- */
- public void setServiceId(final String serviceId) {
- mServiceId = serviceId;
- for (ProfileData p : mProfileDataList) {
- p.setServiceId(serviceId);
- }
- }
-
- /**
- * サービスの名前を取得します.
- * @return サービスの名前
- */
- public String getName() {
- return mName;
- }
-
- /**
- * サービスの名前を設定します.
- * @param name サービスの名前
- */
- public void setName(final String name) {
- mName = name;
- }
-
- /**
- * サービスが持つプロファイルのリストを取得します.
- * @return プロファイルのリスト
- */
- public List getProfileDataList() {
- return mProfileDataList;
- }
-
- public ProfileData getProfileData(final ProfileData.Type type) {
- for (ProfileData p : mProfileDataList) {
- if (p.getType() == type) {
- return p;
- }
- }
- return null;
- }
-
- /**
- * サービスが持つプロファイルのリストを設定します.
- * @param profileDataList プロファイルのリスト
- */
- public void setProfileDataList(final List profileDataList) {
- mProfileDataList = profileDataList;
- for (ProfileData p : mProfileDataList) {
- p.setServiceId(mServiceId);
- }
- }
-
- /**
- * サービスが持つプロファイルのリストに追加します.
- *
- * 既に同じプロファイルを持っている場合には、新しいプロファイルに置き換えます。
- *
- * @param profileData 追加するプロファイル
- */
- public void addProfileData(final ProfileData profileData) {
- if (mProfileDataList.contains(profileData)) {
- for (int i = 0; i < mProfileDataList.size(); i++) {
- if (mProfileDataList.get(i).equals(profileData)) {
- mProfileDataList.set(i, profileData);
- break;
- }
- }
- } else {
- mProfileDataList.add(profileData);
- }
- profileData.setServiceId(mServiceId);
- }
-
- /**
- * 削除します.
- * @param profileData
- */
- public void removeProfileData(final ProfileData profileData) {
- mProfileDataList.remove(profileData);
- }
-
- /**
- * 仮想サービスが使用しているピンの一覧を取得します.
- * @return ピンの一覧
- */
- public List getUsePins() {
- List pins = new ArrayList<>();
- for (ProfileData p : mProfileDataList) {
- for (Integer i : p.getPinList()) {
- pins.add(i);
- }
- }
- return pins;
- }
-
- /**
- * 指定されたピン番号が使用されているか確認を行います.
- * @param pinNumber 確認を行うピン番号
- * @return 使用されている場合にはtrue、それ以外はfalse
- */
- public boolean usedPin(final int pinNumber) {
- for (ProfileData p : mProfileDataList) {
- for (Integer i : p.getPinList()) {
- if (pinNumber == i) {
- return true;
- }
- }
- }
- return false;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(final Parcel parcel, final int flags) {
- parcel.writeString(mServiceId);
- parcel.writeString(mName);
- parcel.writeList(mProfileDataList);
- }
-
- public static final Creator CREATOR = new Creator() {
- @Override
- public ServiceData createFromParcel(final Parcel source) {
- return new ServiceData(source);
- }
- @Override
- public ServiceData[] newArray(final int size) {
- return new ServiceData[size];
- }
- };
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/db/VirtualServiceDBHelper.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/db/VirtualServiceDBHelper.java
deleted file mode 100644
index 4ddf7c7553..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/db/VirtualServiceDBHelper.java
+++ /dev/null
@@ -1,382 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.db;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.provider.BaseColumns;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 仮想サービスのデータを管理します.
- */
-public class VirtualServiceDBHelper {
- /**
- * データベースを保持するファイル名.
- */
- private static final String DB_NAME = "virtual_service.db";
-
- /**
- * データベールのバージョン.
- */
- private static final int DB_VERSION = 1;
-
- private static final String TBL_SERVICE_NAME = "virtual_service_tbl";
- private static final String COL_SERVICE_ID = "serviceId";
- private static final String COL_SERVICE_NAME = "name";
-
- private static final String TBL_PROFILE_NAME = "virtual_profile_tbl";
- private static final String COL_PROFILE_SERVICE_ID = "serviceId";
- private static final String COL_PROFILE_TYPE = "type";
- private static final String COL_PROFILE_PIN = "pin";
-
- /**
- * pinを区切る文字列.
- */
- private static final String SEPARATOR = ",";
-
- /**
- * DBを操作するためのヘルパークラス.
- */
- private DBHelper mDBHelper;
-
- /**
- * コンストラクタ.
- * @param context コンテキスト
- */
- public VirtualServiceDBHelper(final Context context) {
- mDBHelper = new DBHelper(context);
- }
-
- /**
- * サービスIDを作成します.
- * @return サービスID
- */
- public String createServiceId() {
- return "fabo_" + getServiceBaseId() + "_service_id";
- }
-
- /**
- * DBに仮想サービスデータを追加します.
- * @param serviceData 追加を行うサービスデータ
- * @return 挿入したデータのrow情報
- */
- public long addServiceData(final ServiceData serviceData) {
- ContentValues values = new ContentValues();
- values.put(COL_SERVICE_ID, serviceData.getServiceId());
- values.put(COL_SERVICE_NAME, serviceData.getName());
-
- SQLiteDatabase db = mDBHelper.getWritableDatabase();
- try {
- long row = db.insert(TBL_SERVICE_NAME, null, values);
- if (row > 0) {
- for (ProfileData p : serviceData.getProfileDataList()) {
- addProfileData(p);
- }
- }
- return row;
- } finally {
- db.close();
- }
- }
-
- /**
- * DBから仮想サービスデータを削除します.
- * @param serviceData 削除を行うサービスデータ
- */
- public long removeServiceData(final ServiceData serviceData) {
- String whereClause = COL_SERVICE_ID + "=?";
- String[] whereArgs = {
- serviceData.getServiceId()
- };
-
- for (ProfileData p : serviceData.getProfileDataList()) {
- removeProfileData(p);
- }
-
- SQLiteDatabase db = mDBHelper.getWritableDatabase();
- try {
- return db.delete(TBL_SERVICE_NAME, whereClause, whereArgs);
- } finally {
- db.close();
- }
- }
-
- /**
- * 仮想サービスデータを更新します.
- * @param serviceData 更新する仮想サービスデータ
- * @return 更新したDBのカラム数
- */
- public long updateServiceData(final ServiceData serviceData) {
- ContentValues values = new ContentValues();
- values.put(COL_SERVICE_NAME, serviceData.getName());
-
- String whereClause = COL_SERVICE_ID + "=?";
- String[] whereArgs = {
- serviceData.getServiceId()
- };
-
-
- List old = getProfileDataList(serviceData.getServiceId());
-
- for (ProfileData p : serviceData.getProfileDataList()) {
- // アップデートに失敗した場合には、プロファイルが存在しなかった
- // 可能性があるので、追加処理を行っておく。
- if (updateProfileData(p) <= 0) {
- addProfileData(p);
- }
- old.remove(p);
- }
-
- // 削除されたプロファイルはDBからも削除しておく
- for (ProfileData p : old) {
- removeProfileData(p);
- }
-
- SQLiteDatabase db = mDBHelper.getWritableDatabase();
- try {
- return db.update(TBL_SERVICE_NAME, values, whereClause, whereArgs);
- } finally {
- db.close();
- }
- }
-
- /**
- * 指定された仮想サービスのIDに対応するサービスデータを取得します.
- * @param vid 仮想サービスのID
- * @return ServiceDataのインスタンス
- */
- public ServiceData getServiceData(final String vid) {
- String sql = "SELECT * FROM " + TBL_SERVICE_NAME + " WHERE " + COL_SERVICE_ID + "=?";
- String[] selectionArgs = {
- vid
- };
-
- SQLiteDatabase db = mDBHelper.getReadableDatabase();
- Cursor cursor = db.rawQuery(sql, selectionArgs);
- try {
- boolean next = cursor.moveToFirst();
- if (next) {
- ServiceData service = new ServiceData();
- service.setServiceId(cursor.getString(cursor.getColumnIndex(COL_SERVICE_ID)));
- service.setName(cursor.getString(cursor.getColumnIndex(COL_SERVICE_NAME)));
- service.setProfileDataList(getProfileDataList(service.getServiceId()));
- return service;
- }
- return null;
- } finally {
- cursor.close();
- db.close();
- }
- }
-
- /**
- * DBから仮想サービスデータのリストを取得します.
- *
- * 一つも登録されていない場合には、空のListを返却します。
- *
- * @return 仮想サービスデータのリスト
- */
- public List getServiceDataList() {
- String sql = "SELECT * FROM " + TBL_SERVICE_NAME;
- String[] selectionArgs = {};
-
- SQLiteDatabase db = mDBHelper.getReadableDatabase();
- Cursor cursor = db.rawQuery(sql, selectionArgs);
- try {
- List serviceDatas = new ArrayList<>();
- boolean next = cursor.moveToFirst();
- while (next) {
- ServiceData service = new ServiceData();
- service.setServiceId(cursor.getString(cursor.getColumnIndex(COL_SERVICE_ID)));
- service.setName(cursor.getString(cursor.getColumnIndex(COL_SERVICE_NAME)));
- service.setProfileDataList(getProfileDataList(service.getServiceId()));
- serviceDatas.add(service);
- next = cursor.moveToNext();
- }
- return serviceDatas;
- } finally {
- cursor.close();
- db.close();
- }
- }
-
- /**
- * プロファイルデータを追加します.
- * @param profileData 追加するプロファイルデータ
- */
- public long addProfileData(final ProfileData profileData) {
- ContentValues values = new ContentValues();
- values.put(COL_PROFILE_SERVICE_ID, profileData.getServiceId());
- values.put(COL_PROFILE_TYPE, profileData.getType().getValue());
- values.put(COL_PROFILE_PIN, convertList2String(profileData.getPinList()));
-
- SQLiteDatabase db = mDBHelper.getWritableDatabase();
- try {
- return db.insert(TBL_PROFILE_NAME, null, values);
- } finally {
- db.close();
- }
- }
-
- /**
- * プロファイルデータを削除します.
- * @param profileData 削除するプロファイルデータ
- */
- public long removeProfileData(final ProfileData profileData) {
- String whereClause = COL_PROFILE_SERVICE_ID + "=? AND " + COL_PROFILE_TYPE + "=?";
- String[] whereArgs = {
- profileData.getServiceId(),
- "" + profileData.getType().getValue()
- };
-
- SQLiteDatabase db = mDBHelper.getWritableDatabase();
- try {
- return db.delete(TBL_PROFILE_NAME, whereClause, whereArgs);
- } finally {
- db.close();
- }
- }
-
- /**
- * 指定されたプロファイルデータの情報を更新します.
- * @param profileData 更新するプロファイルデータ
- * @return 更新したDBのカラム数
- */
- public long updateProfileData(final ProfileData profileData) {
- ContentValues values = new ContentValues();
- values.put(COL_PROFILE_PIN, convertList2String(profileData.getPinList()));
-
- String whereClause = COL_PROFILE_SERVICE_ID + "=? AND " + COL_PROFILE_TYPE + "=?";
- String[] whereArgs = {
- profileData.getServiceId(),
- String.valueOf(profileData.getType().getValue())
- };
-
- SQLiteDatabase db = mDBHelper.getWritableDatabase();
- try {
- return db.update(TBL_PROFILE_NAME, values, whereClause, whereArgs);
- } finally {
- db.close();
- }
- }
-
- /**
- * 指定されたサービスIDに対応するDBからプロファイルデータのリストを取得します.
- *
- * 一つも登録されていない場合には、空のListを返却します。
- *
- * @param serviceId サービスID
- * @return プロファイルデータのリスト
- */
- public List getProfileDataList(final String serviceId) {
- String sql = "SELECT * FROM " + TBL_PROFILE_NAME + " WHERE " + COL_PROFILE_SERVICE_ID + "=?";
- String[] selectionArgs = { serviceId };
-
- SQLiteDatabase db = mDBHelper.getReadableDatabase();
- Cursor cursor = db.rawQuery(sql, selectionArgs);
- try {
- List profileDatas = new ArrayList<>();
- boolean next = cursor.moveToFirst();
- while (next) {
- ProfileData profile = new ProfileData();
- profile.setServiceId(cursor.getString(cursor.getColumnIndex(COL_PROFILE_SERVICE_ID)));
- profile.setType(ProfileData.Type.getType(cursor.getInt(cursor.getColumnIndex(COL_PROFILE_TYPE))));
- profile.setPinList(convertString2List(cursor.getString(cursor.getColumnIndex(COL_PROFILE_PIN))));
- profileDatas.add(profile);
- next = cursor.moveToNext();
- }
- return profileDatas;
- } finally {
- cursor.close();
- db.close();
- }
- }
-
- /**
- * サービスデータのテーブルにあるBaseColumns._IDの最大値を取得します.
- * @return テーブルにあるBaseColumns._IDの最大値
- */
- private int getServiceBaseId() {
- String sql = "SELECT * FROM " + TBL_SERVICE_NAME + " ORDER BY " + BaseColumns._ID + " DESC";
- SQLiteDatabase db = mDBHelper.getReadableDatabase();
- Cursor cursor = db.rawQuery(sql, null);
- try {
- if (cursor.moveToFirst()) {
- return cursor.getInt(cursor.getColumnIndex(BaseColumns._ID)) + 1;
- }
- } finally {
- cursor.close();
- db.close();
- }
- return 0;
- }
-
- private String convertList2String(final List pins) {
- StringBuilder sb = new StringBuilder();
- for (Integer str : pins) {
- if (sb.length() > 0) {
- sb.append(SEPARATOR);
- }
- sb.append(str);
- }
- return sb.toString();
- }
-
- private List convertString2List(final String str) {
- List list = new ArrayList<>();
- for (String s : str.split(SEPARATOR)) {
- try {
- list.add(Integer.parseInt(s));
- } catch (NumberFormatException e) {
- // do noting.
- }
- }
- return list;
- }
-
- /**
- * DB操作を行うためのヘルパークラス.
- */
- private class DBHelper extends SQLiteOpenHelper {
- /**
- * コンストラクタ.
- * @param context コンテキスト
- */
- DBHelper(final Context context) {
- super(context, DB_NAME, null, DB_VERSION);
- }
-
- @Override
- public void onCreate(final SQLiteDatabase db) {
- createDB(db);
- }
-
- @Override
- public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
- db.execSQL("DROP TABLE IF EXISTS " + TBL_SERVICE_NAME);
- db.execSQL("DROP TABLE IF EXISTS " + TBL_PROFILE_NAME);
- createDB(db);
- }
-
- private void createDB(final SQLiteDatabase db) {
- String sql = "CREATE TABLE " + TBL_SERVICE_NAME + " ("
- + BaseColumns._ID + " INTEGER PRIMARY KEY, "
- + COL_SERVICE_ID + " TEXT NOT NULL, "
- + COL_SERVICE_NAME + " TEXT NOT NULL"
- + ");";
- db.execSQL(sql);
-
- String sql2 = "CREATE TABLE " + TBL_PROFILE_NAME + " ("
- + BaseColumns._ID + " INTEGER PRIMARY KEY, "
- + COL_PROFILE_SERVICE_ID + " TEXT NOT NULL, "
- + COL_PROFILE_TYPE + " INTEGER, "
- + COL_PROFILE_PIN + " TEXT NOT NULL"
- + ");";
- db.execSQL(sql2);
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/BaseFaBoProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/BaseFaBoProfile.java
deleted file mode 100644
index 82ac36deb2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/BaseFaBoProfile.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import org.deviceconnect.android.deviceplugin.fabo.FaBoDeviceService;
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.profile.DConnectProfile;
-
-abstract class BaseFaBoProfile extends DConnectProfile {
- /**
- * FaBoDeviceServiceを取得します.
- *
- * 返り値がnullになる場合には、プログラムがおかしいので注意。
- *
- * @return FaBoDeviceServiceのインスタンス
- */
- FaBoDeviceService getFaBoDeviceService() {
- return (FaBoDeviceService) getContext();
- }
-
-// /**
-// * 接続されているFaBoを操作するためのFaBoUsbManagerを取得します.
-// *
-// * 接続されていない場合にはnullを返却します。
-// *
-// * @return FaBoUsbManagerのインスタンス
-// */
-// FaBoUsbManager getFaBoUsbManager() {
-// return getFaBoDeviceService().getFaBoUsbManager();
-// }
-
- FaBoDeviceControl getFaBoDeviceControl() {
- return getFaBoDeviceService().getFaBoDeviceControl();
- }
-
- /**
- * Arduinoから渡されてくる値を変換します.
- * @param x Arduinoから取得した値
- * @param inMin Arduinoから取得できる最小値
- * @param inMax Arduinoから取得できる最大値
- * @param outMin 変換後の最小値
- * @param outMax 変換後の最大値
- * @return 変換された値
- */
- int calcArduinoMap(final int x, final int inMin, final int inMax, final int outMin, final int outMax) {
- return (x - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/FlashingExecutor.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/FlashingExecutor.java
deleted file mode 100644
index 6f1b89faa5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/FlashingExecutor.java
+++ /dev/null
@@ -1,138 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-class FlashingExecutor {
-
- /**
- * ライトの点灯・消灯タイミング通知リスナー.
- */
- interface LightControllable {
- /**
- * ライトの点灯・消灯の変更要求.
- *
- * CompleteListener#onComplete()を呼び出すと次の点滅処理を行います。
- *
- * @param isOn true: 点灯、false: 消灯
- * @param listener 点灯・消灯完了通知を行うリスナー
- */
- void changeLight(boolean isOn, CompleteListener listener);
- }
-
- /**
- * ライトの状態変更通知リスナー.
- */
- interface CompleteListener {
- /**
- * ライトの状態が変更できたことを通知します。
- */
- void onComplete();
- }
-
- private LightControllable mListener;
- private ScheduledExecutorService mFlashingService = Executors.newSingleThreadScheduledExecutor();
- private ScheduledFuture mLatestScheduledFuture;
- private Queue mFlashingQueue = new ConcurrentLinkedQueue();
- private boolean mIsOn = true;
- private int mLastIdentifier = 0;
-
- FlashingExecutor() {
- }
-
- synchronized void setLightControllable(LightControllable controllable) {
- mListener = controllable;
- }
-
- synchronized void start(long[] flashing) {
- cancelSchedule();
- updateQueue(flashing);
- setOn(true);
- schedule(new Runnable() {
- @Override
- public void run() {
- controlLight(this);
- }
- }, getNextFlashingInterval());
- }
-
- private synchronized void controlLight(final Runnable runnable) {
- if (mFlashingQueue.isEmpty()) {
- onFinish();
- }
- mLastIdentifier++;
- final int identifier = mLastIdentifier;
- LightControllable listener = getLightControllable();
- if (listener == null) {
- next(runnable, identifier);
- return;
- }
- listener.changeLight(isOn(), new CompleteListener() {
- @Override
- public void onComplete() {
- next(runnable, identifier);
- }
- });
- }
-
- private synchronized void next(Runnable runnable, int identifier) {
- //Return if other execution has been begin.
- if (mLastIdentifier != identifier) {
- return;
- }
- toggleOnOff();
- Long interval = getNextFlashingInterval();
- if (interval != null) {
- schedule(runnable, interval);
- } else {
- onFinish();
- }
- }
-
- private synchronized void onFinish() {
- mListener = null;
- mLatestScheduledFuture = null;
- }
-
- private synchronized LightControllable getLightControllable() {
- return mListener;
- }
-
- private synchronized void cancelSchedule() {
- if (mLatestScheduledFuture != null && !mLatestScheduledFuture.isCancelled()) {
- mLatestScheduledFuture.cancel(false);
- }
- }
-
- private synchronized void schedule(Runnable runnable, long interval) {
- mLatestScheduledFuture = mFlashingService.schedule(runnable, interval, TimeUnit.MILLISECONDS);
- }
-
- private synchronized void updateQueue(long[] flashing) {
- mFlashingQueue.clear();
- mFlashingQueue.add(0L);
- for (long value : flashing) {
- mFlashingQueue.add(value);
- }
- }
-
- private synchronized Long getNextFlashingInterval() {
- return mFlashingQueue.poll();
- }
-
- private synchronized void setOn(boolean isOn) {
- mIsOn = isOn;
- }
-
- private synchronized boolean isOn() {
- return mIsOn;
- }
-
- private synchronized void toggleOnOff() {
- mIsOn = !mIsOn;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOHumidityProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOHumidityProfile.java
deleted file mode 100644
index 8209638bdd..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOHumidityProfile.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.List;
-
-/**
- * GPIO用Humidityプロファイル.
- *
- * ID: #115
- * Name: Humidity Brick
- *
- */
-public class GPIOHumidityProfile extends BaseFaBoProfile {
- /**
- * Humidity操作を行うピンのリスト.
- */
- private List mPinList;
-
- public GPIOHumidityProfile(final List pinList) {
- mPinList = pinList;
-
- addApi(new GetApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else {
- FaBoShield.Pin pin = mPinList.get(0);
-
- // TODO 要確認
- int value = getFaBoDeviceControl().getAnalog(pin);
- int humidity = value & 0xFFFF;
-
- response.putExtra("humidity", humidity / 100.0f);
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "humidity";
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOIlluminanceProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOIlluminanceProfile.java
deleted file mode 100644
index 7c38fc1574..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOIlluminanceProfile.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.List;
-
-/**
- * GPIO用のIlluminanceプロファイル.
- *
- * ID: #109
- * Name: Light Brick
- *
- */
-public class GPIOIlluminanceProfile extends BaseFaBoProfile {
- /**
- * Illuminance操作を行うピンのリスト.
- */
- private List mPinList;
-
- public GPIOIlluminanceProfile(final List pinList) {
- mPinList = pinList;
-
- // GET /gotpai/illuminance
- addApi(new GetApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else {
- FaBoShield.Pin pin = mPinList.get(0);
-
- int value = getFaBoDeviceControl().getAnalog(pin);
- value = 5000 - calcArduinoMap(value, 0, 2013, 0, 5000);
- value = value / 10;
-
- response.putExtra("illuminance", value);
-
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "illuminance";
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOKeyEventProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOKeyEventProfile.java
deleted file mode 100644
index c8bd1cb024..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOKeyEventProfile.java
+++ /dev/null
@@ -1,363 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.event.Event;
-import org.deviceconnect.android.event.EventError;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * GPIO用のKeyEventプロファイル.
- *
- * ID: #103
- * Name: Button Brick
- *
- */
-public class GPIOKeyEventProfile extends BaseFaBoProfile {
-
- /**
- * KeyEvent操作を行うピンのリスト.
- */
- private List mPinList;
-
- /**
- * ピンの値を保持するためのMap.
- */
- private Map mValues = new HashMap<>();
-
- /**
- * コンストラクタ.
- *
- * @param pinList KeyEventに対応するPinのリスト
- */
- public GPIOKeyEventProfile(final List pinList) {
- mPinList = pinList;
-
- // PUT /gotapi/keyEvent/onDown
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "onDown";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- EventError error = EventManager.INSTANCE.addEvent(request);
- switch (error) {
- case NONE:
- getFaBoDeviceControl().addOnGPIOListener(mOnGPIOListenerImpl);
- for (FaBoShield.Pin pin : mPinList) {
- if (pin.getMode() == FaBoShield.Mode.ANALOG) {
- mValues.put(pin, getFaBoDeviceControl().getAnalog(pin));
- } else {
- getFaBoDeviceControl().setPinMode(pin, FaBoShield.Mode.GPIO_IN);
- mValues.put(pin, getFaBoDeviceControl().getDigital(pin).getValue());
- }
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- return true;
- }
- });
-
- // DELETE /gotapi/keyEvent/onDown
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "onDown";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- EventError error = EventManager.INSTANCE.removeEvent(request);
- switch (error) {
- case NONE:
- if (isEmptyEvent()) {
- getFaBoDeviceControl().removeOnGPIOListener(mOnGPIOListenerImpl);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- case NOT_FOUND:
- MessageUtils.setIllegalDeviceStateError(response, "Not register event.");
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- return true;
- }
- });
-
- // PUT /gotapi/keyEvent/onUp
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "onUp";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- EventError error = EventManager.INSTANCE.addEvent(request);
- switch (error) {
- case NONE:
- getFaBoDeviceControl().addOnGPIOListener(mOnGPIOListenerImpl);
- for (FaBoShield.Pin pin : mPinList) {
- if (pin.getMode() == FaBoShield.Mode.ANALOG) {
- mValues.put(pin, getFaBoDeviceControl().getAnalog(pin));
- } else {
- getFaBoDeviceControl().setPinMode(pin, FaBoShield.Mode.GPIO_IN);
- mValues.put(pin, getFaBoDeviceControl().getDigital(pin).getValue());
- }
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- return true;
- }
- });
-
- // DELETE /gotapi/keyEvent/onUp
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "onUp";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- EventError error = EventManager.INSTANCE.removeEvent(request);
- switch (error) {
- case NONE:
- if (isEmptyEvent()) {
- getFaBoDeviceControl().removeOnGPIOListener(mOnGPIOListenerImpl);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- case NOT_FOUND:
- MessageUtils.setIllegalDeviceStateError(response, "Not register event.");
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- return true;
- }
- });
-
- // PUT /gotapi/keyEvent/onKeyChange
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "onKeyChange";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- EventError error = EventManager.INSTANCE.addEvent(request);
- switch (error) {
- case NONE:
- getFaBoDeviceControl().addOnGPIOListener(mOnGPIOListenerImpl);
- for (FaBoShield.Pin pin : mPinList) {
- if (pin.getMode() == FaBoShield.Mode.ANALOG) {
- mValues.put(pin, getFaBoDeviceControl().getAnalog(pin));
- } else {
- getFaBoDeviceControl().setPinMode(pin, FaBoShield.Mode.GPIO_IN);
- mValues.put(pin, getFaBoDeviceControl().getDigital(pin).getValue());
- }
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- return true;
- }
- });
-
- // DELETE /gotapi/keyEvent/onKeyChange
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "onKeyChange";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- EventError error = EventManager.INSTANCE.removeEvent(request);
- switch (error) {
- case NONE:
- if (isEmptyEvent()) {
- getFaBoDeviceControl().removeOnGPIOListener(mOnGPIOListenerImpl);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- case NOT_FOUND:
- MessageUtils.setIllegalDeviceStateError(response, "Not register event.");
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "keyEvent";
- }
-
- /**
- * イベント登録が空か確認を行います.
- * @return イベント登録がされていない場合はtrue、それ以外はfalse
- */
- private boolean isEmptyEvent() {
- String serviceId = getService().getId();
-
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "keyEvent", null, "onKeyChange");
- if (!events.isEmpty()) {
- return false;
- }
-
- events = EventManager.INSTANCE.getEventList(serviceId,
- "keyEvent", null, "onDown");
- if (!events.isEmpty()) {
- return false;
- }
-
- events = EventManager.INSTANCE.getEventList(serviceId,
- "keyEvent", null, "onUp");
-
- return events.isEmpty();
- }
-
- /**
- * KeyDownイベントを通知します.
- * @param pin Keyが押されたピン
- */
- private synchronized void notifyKeyDown(final FaBoShield.Pin pin) {
- String serviceId = getService().getId();
-
- {
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "keyEvent", null, "onKeyChange");
- for (Event event : events) {
- Bundle keyEvent = new Bundle();
- keyEvent.putString("state", "down");
- keyEvent.putInt("id", pin.getPinNumber());
- keyEvent.putString("config", pin.getPinNames()[1]);
-
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra("keyevent", keyEvent);
- sendEvent(intent, event.getAccessToken());
- }
- }
-
- {
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "keyEvent", null, "onDown");
- for (Event event : events) {
- Bundle keyEvent = new Bundle();
- keyEvent.putInt("id", pin.getPinNumber());
- keyEvent.putString("config", pin.getPinNames()[1]);
-
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra("keyevent", keyEvent);
- sendEvent(intent, event.getAccessToken());
- }
- }
- }
-
- /**
- * KeyUpイベントを通知します.
- * @param pin Keyが離されたピン
- */
- private synchronized void notifyKeyUp(final FaBoShield.Pin pin) {
- String serviceId = getService().getId();
- {
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "keyEvent", null, "onKeyChange");
- for (Event event : events) {
- Bundle keyEvent = new Bundle();
- keyEvent.putString("state", "up");
- keyEvent.putInt("id", pin.getPinNumber());
- keyEvent.putString("config", pin.getPinNames()[1]);
-
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra("keyevent", keyEvent);
- sendEvent(intent, event.getAccessToken());
- }
- }
- {
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "keyEvent", null, "onUp");
- for (Event event : events) {
- Bundle keyEvent = new Bundle();
- keyEvent.putInt("id", pin.getPinNumber());
- keyEvent.putString("config", pin.getPinNames()[1]);
-
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra("keyevent", keyEvent);
- sendEvent(intent, event.getAccessToken());
- }
- }
- }
-
- /**
- * GPIOの値変化の通知を受け取るリスナー.
- */
- private FaBoDeviceControl.OnGPIOListener mOnGPIOListenerImpl = new FaBoDeviceControl.OnGPIOListener() {
- @Override
- public void onAnalog() {
- for (FaBoShield.Pin pin : mPinList) {
- if (pin.getMode() == FaBoShield.Mode.ANALOG) {
- int oldValue = mValues.get(pin);
- int newValue = getFaBoDeviceControl().getAnalog(pin);
- if (oldValue < 10 && newValue > 1000) {
- notifyKeyDown(pin);
- } else if (oldValue > 1000 && newValue < 10) {
- notifyKeyUp(pin);
- }
- mValues.put(pin, newValue);
- }
- }
- }
-
- @Override
- public void onDigital() {
- for (FaBoShield.Pin pin : mPinList) {
- if (pin.getMode() != FaBoShield.Mode.ANALOG) {
- int oldValue = mValues.get(pin);
- int newValue = getFaBoDeviceControl().getDigital(pin).getValue();
- if (oldValue == 0 && newValue == 1) {
- notifyKeyDown(pin);
- } else if (oldValue == 1 && newValue == 0) {
- notifyKeyUp(pin);
- }
- mValues.put(pin, newValue);
- }
- }
- }
- };
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOLightProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOLightProfile.java
deleted file mode 100644
index 2d3df91bd3..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOLightProfile.java
+++ /dev/null
@@ -1,249 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * GPIO用のLightプロファイル.
- *
- * ID: #101
- * Name: LED Brick
- *
- */
-public class GPIOLightProfile extends BaseFaBoProfile {
-
- /**
- * ライト操作を行うピンのリスト.
- */
- private List mPinList;
-
- /**
- * ライトフラッシング管理マップ.
- */
- private final Map mFlashingMap = new HashMap<>();
-
- /**
- * コンストラクタ.
- * @param pinList ライトに対応するPinのリスト
- */
- public GPIOLightProfile(final List pinList) {
- mPinList = pinList;
-
- // GET /gotpai/light
- addApi(new GetApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Bundle[] lightList = new Bundle[mPinList.size()];
- for (int i = 0; i < mPinList.size(); i++) {
- FaBoShield.Pin pin = mPinList.get(i);
- lightList[i] = new Bundle();
- lightList[i].putString("lightId", String.valueOf(pin.getPinNumber()));
- lightList[i].putString("name", pin.getPinNames()[1]);
- lightList[i].putBoolean("on", getFaBoDeviceControl().getDigital(pin) == FaBoShield.Level.HIGH);
- lightList[i].putString("config", "");
- }
- response.putExtra("lights", lightList);
- setResult(response, DConnectMessage.RESULT_OK);
- return true;
- }
- });
-
- // POST /gotpai/light
- addApi(new PostApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- return lightOn(request, response);
- }
- });
-
- // PUT /gotpai/light
- addApi(new PutApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- return lightOn(request, response);
- }
- });
-
- // DELETE /gotpai/light
- addApi(new DeleteApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String lightId = request.getStringExtra("lightId");
-
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (mPinList.isEmpty()) {
- MessageUtils.setInvalidRequestParameterError(response, "Light does not exist.");
- } else {
- FaBoShield.Pin pin = findLight(lightId);
- if (pin != null) {
- sendLightOff(pin);
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- MessageUtils.setInvalidRequestParameterError(response, "Not found the light. lightId=" + lightId);
- }
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "light";
- }
-
- /**
- * LEDを点灯します.
- * @param request リクエスト
- * @param response レスポンス
- * @return 即座にレスポンスを返却するフラグ
- */
- private boolean lightOn(final Intent request, final Intent response) {
- String lightId = request.getStringExtra("lightId");
- Float brightness = parseFloat(request, "brightness");
-
- long[] flashing;
- try {
- flashing = getFlashing(request);
- } catch (Exception e) {
- MessageUtils.setInvalidRequestParameterError(response, "Format of flashing is invalid.");
- return true;
- }
-
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (mPinList.isEmpty()) {
- MessageUtils.setInvalidRequestParameterError(response, "Light does not exist.");
- } else {
- FaBoShield.Pin pin = findLight(lightId);
- if (pin != null) {
- if (flashing != null) {
- flashing(pin, flashing);
- } else {
- sendLightOn(pin);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- MessageUtils.setInvalidRequestParameterError(response, "Not found the light. lightId=" + lightId);
- }
- }
- return true;
- }
-
- /**
- * 点滅間隔を取得する.
- *
- * flashingが省略された場合にはnullを返却する。
- *
- * @param request リクエスト
- * @return 点滅間隔
- * @throws IllegalArgumentException flashingのフォーマットが不正な場合に発生
- */
- private static long[] getFlashing(final Intent request) {
- String flashing = request.getStringExtra("flashing");
- if (flashing == null) {
- return null;
- }
- if (flashing.length() == 0) {
- throw new IllegalArgumentException("flashing is invalid.");
- }
- String[] split = flashing.split(",");
- long[] list = new long[split.length];
- for (int i = 0; i < split.length; i++) {
- try {
- list[i] = Integer.parseInt(split[i]);
- if (list[i] <= 0) {
- throw new IllegalArgumentException("flashing is negative value.");
- }
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException("flashing is invalid.");
- }
- }
- return list;
- }
-
- /**
- * 指定されたlightIdに対応するPinを取得します.
- *
- * 対応するPinが存在しない場合にはnullを返却します。
- *
- * @param lightId ライトID
- * @return 対応するPinのインスタンス
- */
- private FaBoShield.Pin findLight(final String lightId) {
- if (lightId == null) {
- return mPinList.get(0);
- }
- try {
- int id = Integer.parseInt(lightId);
- for (FaBoShield.Pin pin : mPinList) {
- if (id == pin.getPinNumber()) {
- return pin;
- }
- }
- return null;
- } catch (NumberFormatException e) {
- return null;
- }
- }
-
- /**
- * 指定されたPinのLEDを点滅させます.
- * @param pin ピン情報
- * @param flashing フラッシュ
- */
- private void flashing(final FaBoShield.Pin pin, final long[] flashing) {
- FlashingExecutor exe = mFlashingMap.get("" + pin.getPinNumber());
- if (exe == null) {
- exe = new FlashingExecutor();
- mFlashingMap.put("" + pin.getPinNumber(), exe);
- }
- exe.setLightControllable(new FlashingExecutor.LightControllable() {
- @Override
- public void changeLight(final boolean isOn, final FlashingExecutor.CompleteListener listener) {
- if (isOn) {
- sendLightOn(pin);
- } else {
- sendLightOff(pin);
- }
- listener.onComplete();
- }
- });
- exe.start(flashing);
- }
-
- /**
- * LEDを点灯します.
- * @param pin LEDが挿さっているピン
- */
- private void sendLightOn(final FaBoShield.Pin pin) {
- if (pin.getMode() != FaBoShield.Mode.GPIO_OUT) {
- getFaBoDeviceControl().setPinMode(pin, FaBoShield.Mode.GPIO_OUT);
- }
- getFaBoDeviceControl().writeDigital(pin, FaBoShield.Level.HIGH);
- }
-
- /**
- * LEDを消灯します.
- * @param pin LEDが挿さっているピン
- */
- private void sendLightOff(final FaBoShield.Pin pin) {
- if (pin.getMode() != FaBoShield.Mode.GPIO_OUT) {
- getFaBoDeviceControl().setPinMode(pin, FaBoShield.Mode.GPIO_OUT);
- }
- getFaBoDeviceControl().writeDigital(pin, FaBoShield.Level.LOW);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOProximityProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOProximityProfile.java
deleted file mode 100644
index cfadfe4c8f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOProximityProfile.java
+++ /dev/null
@@ -1,184 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.event.Event;
-import org.deviceconnect.android.event.EventError;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.List;
-
-import static org.deviceconnect.android.event.EventManager.INSTANCE;
-
-/**
- * GPIO用のProximityプロファイル.
- *
- * 以下のFaBoのBrickに対応します。
- * ID: #116
- * Name: Distance Brick
- *
- */
-public class GPIOProximityProfile extends BaseFaBoProfile {
- /**
- * Proximity操作を行うピンのリスト.
- */
- private List mPinList;
-
- /**
- * コンストラクタ.
- * @param pinList 操作を行うピンのリスト
- */
- public GPIOProximityProfile(final List pinList) {
- mPinList = pinList;
-
- // GET /gotapi/proximity/onDeviceProximity
- addApi(new GetApi() {
- @Override
- public String getAttribute() {
- return "onDeviceProximity";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- FaBoShield.Pin pin = mPinList.get(0);
-
- int value = getFaBoDeviceControl().getAnalog(pin);
- value = calcArduinoMap(value, 0, 1023, 0, 5000);
- value = calcArduinoMap(value, 3200, 500, 5, 80);
-
- response.putExtra("proximity", createProximity(value));
- setResult(response, DConnectMessage.RESULT_OK);
- return true;
- }
- });
-
- // PUT /gotapi/proximity/onDeviceProximity
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "onDeviceProximity";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- EventError error = INSTANCE.addEvent(request);
- switch (error) {
- case NONE:
- getFaBoDeviceControl().addOnGPIOListener(mOnGPIOListenerImpl);
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- return true;
- }
- });
-
- // DELETE /gotapi/proximity/onDeviceProximity
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "onDeviceProximity";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- EventError error = INSTANCE.removeEvent(request);
- switch (error) {
- case NONE:
- if (isEmptyEvent()) {
- getFaBoDeviceControl().removeOnGPIOListener(mOnGPIOListenerImpl);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- case NOT_FOUND:
- MessageUtils.setIllegalDeviceStateError(response, "Not register event.");
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "proximity";
- }
-
- /**
- * 登録されているイベントが空か確認します.
- * @return イベントが登録されていない場合はtrue、それ以外はfalse
- */
- private boolean isEmptyEvent() {
- String serviceId = getService().getId();
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "proximity", null, "onDeviceProximity");
- return events.isEmpty();
- }
-
- /**
- * Proximityのオブジェクトを作成します.
- * @param value 距離
- * @return Proximityのオブジェクト
- */
- private Bundle createProximity(final int value) {
- Bundle proximity = new Bundle();
- proximity.putInt("min", 10);
- proximity.putInt("max", 80);
- proximity.putInt("value", value);
- return proximity;
- }
-
- /**
- * Arduinoから渡されてきた値をProximityとして通知します.
- * @param pin 値が渡されてきたピン
- */
- private void notifyProximity(final FaBoShield.Pin pin) {
- String serviceId = getService().getId();
-
- int value = getFaBoDeviceControl().getAnalog(pin);
- value = calcArduinoMap(value, 0, 1023, 0, 5000);
- value = calcArduinoMap(value, 3200, 500, 5, 80);
-
- // この範囲以外はデータおかしいので弾く
- if (value < 10 || value > 80) {
- return;
- }
-
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "proximity", null, "onDeviceProximity");
- for (Event event : events) {
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra("proximity", createProximity(value));
- sendEvent(intent, event.getAccessToken());
- }
- }
-
- /**
- * GPIOの値変化の通知を受け取るリスナー.
- */
- private FaBoDeviceControl.OnGPIOListener mOnGPIOListenerImpl = new FaBoDeviceControl.OnGPIOListener() {
- @Override
- public void onAnalog() {
- for (FaBoShield.Pin pin : mPinList) {
- notifyProximity(pin);
- }
- }
-
- @Override
- public void onDigital() {
- }
- };
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOTemperatureProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOTemperatureProfile.java
deleted file mode 100644
index cb4f31c97b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOTemperatureProfile.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.List;
-
-/**
- * GPIO用のTemperatureプロファイル.
- *
- * 以下のFaBoのBrickに対応します。
- * ID: #108
- * Name: Temperature Brick
- *
- */
-public class GPIOTemperatureProfile extends BaseFaBoProfile {
- /**
- * Temperatureを取得するピン.
- */
- private List mPinList;
-
- /**
- * コンストラクタ.
- * @param pinList 操作を行うピンのリスト
- */
- public GPIOTemperatureProfile(final List pinList) {
- mPinList = pinList;
-
- // GET /gotpai/temperature
- addApi(new GetApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final Integer type = parseInteger(request, "type");
-
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else {
- FaBoShield.Pin pin = mPinList.get(0);
-
- int value = getFaBoDeviceControl().getAnalog(pin);
- value = calcArduinoMap(value, 0, 1023, 0, 5000);
- value = calcArduinoMap(value, 300, 1600, -30, 100);
- value = Math.round(value * 10) / 10;
-
- if (type == null || type == 1) {
- response.putExtra("temperature", value);
- } else {
- response.putExtra("temperature", convertC2F(value));
- }
-
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "temperature";
- }
-
- /**
- * 摂氏を華氏に変換します.
- * @param temp 摂氏
- * @return 華氏
- */
- private double convertC2F(double temp) {
- return temp * 1.8 + 32;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOVibrationProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOVibrationProfile.java
deleted file mode 100644
index ab9c8bdf74..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/GPIOVibrationProfile.java
+++ /dev/null
@@ -1,217 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * GPIO用のVibrationプロファイル.
- *
- * 以下のFaBoのBrickに対応します。
- * ID: #105
- * Name: Vibration Brick
- *
- */
-public class GPIOVibrationProfile extends BaseFaBoProfile {
-
- /**
- * 振動パターンで使われる区切り文字.
- *
- */
- private static final String VIBRATION_PATTERN_DELIM = ",";
-
- /**
- * バイブレーションに接続されているピンのリスト.
- */
- private List mPinList;
-
- /**
- * ライトフラッシング管理マップ.
- */
- private FlashingExecutor mFlashingExecutor;
-
- /**
- * コンストラクタ.
- * @param pinList 操作を行うピンのリスト
- */
- public GPIOVibrationProfile(final List pinList) {
- mPinList = pinList;
-
- // PUT /gotapi/vibration/vibrate
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "vibrate";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final long[] pattern = parsePattern(request);
-
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (mPinList.isEmpty()) {
- MessageUtils.setInvalidRequestParameterError(response, "Vibration does not exist.");
- } else {
- if (pattern != null) {
- flashing(pattern);
- } else {
- for (FaBoShield.Pin pin : mPinList) {
- sendVibrateOn(pin);
- }
- }
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
-
- // DELETE /gotapi/vibration/vibrate
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "vibrate";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (mPinList.isEmpty()) {
- MessageUtils.setInvalidRequestParameterError(response, "Vibration does not exist.");
- } else {
- for (FaBoShield.Pin pin : mPinList) {
- sendVibrateOff(pin);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "vibration";
- }
-
- /**
- * 鳴動パターンを文字列から解析し、数値の配列に変換する.
- * 数値の前後の半角のスペースは無視される。その他の半角、全角のスペースは不正なフォーマットとして扱われる。
- *
- * @param request リクエスト
- * @return 鳴動パターンの配列。解析できないフォーマットの場合nullを返す。
- */
- private long[] parsePattern(final Intent request) {
- final String pattern = request.getStringExtra("pattern");
-
- if (pattern == null || pattern.length() == 0) {
- return new long[] { 500 };
- }
-
- long[] result = null;
-
- if (pattern.contains(VIBRATION_PATTERN_DELIM)) {
- String[] times = pattern.split(VIBRATION_PATTERN_DELIM);
- ArrayList values = new ArrayList();
- for (String time : times) {
- try {
- String valueStr = time.trim();
- if (valueStr.length() == 0) {
- if (values.size() != times.length - 1) {
- // 数値の間にスペースがある場合はフォーマットエラー
- // ex. 100, , 100
- values.clear();
- }
- break;
- }
- long value = Long.parseLong(time.trim());
- if (value < 0) {
- // 数値が負の値の場合はフォーマットエラー
- values.clear();
- break;
- }
- values.add(value);
- } catch (NumberFormatException e) {
- values.clear();
- mLogger.warning("Exception in the VibrationProfile#parsePattern() method. " + e.toString());
- break;
- }
- }
-
- if (values.size() != 0) {
- result = new long[values.size()];
- for (int i = 0; i < values.size(); i++) {
- result[i] = values.get(i);
- }
- }
- } else {
- try {
- long time = Long.parseLong(pattern);
- if (time >= 0) {
- result = new long[] {time};
- }
- } catch (NumberFormatException e) {
- mLogger.warning("Exception in the VibrationProfile#parsePattern() method. " + e.toString());
- }
- }
-
- return result;
- }
-
- /**
- * 指定されたPinのLEDを点滅させます.
- * @param flashing フラッシュ
- */
- private void flashing(final long[] flashing) {
- if (mFlashingExecutor == null) {
- mFlashingExecutor = new FlashingExecutor();
- }
- mFlashingExecutor.setLightControllable(new FlashingExecutor.LightControllable() {
- @Override
- public void changeLight(final boolean isOn, final FlashingExecutor.CompleteListener listener) {
- if (isOn) {
- for (FaBoShield.Pin pin : mPinList) {
- sendVibrateOn(pin);
- }
- } else {
- for (FaBoShield.Pin pin : mPinList) {
- sendVibrateOff(pin);
- }
- }
- listener.onComplete();
- }
- });
- mFlashingExecutor.start(flashing);
- }
-
- /**
- * Vibratorを振動させます.
- * @param pin Vibratorが挿さっているピン
- */
- private void sendVibrateOn(final FaBoShield.Pin pin) {
- if (pin.getMode() != FaBoShield.Mode.GPIO_OUT) {
- getFaBoDeviceControl().setPinMode(pin, FaBoShield.Mode.GPIO_OUT);
- }
- getFaBoDeviceControl().writeDigital(pin, FaBoShield.Level.HIGH);
- }
-
- /**
- * Vibratorの振動を止めます.
- * @param pin Vibratorが挿さっているピン
- */
- private void sendVibrateOff(final FaBoShield.Pin pin) {
- if (pin.getMode() != FaBoShield.Mode.GPIO_OUT) {
- getFaBoDeviceControl().setPinMode(pin, FaBoShield.Mode.GPIO_OUT);
- }
- getFaBoDeviceControl().writeDigital(pin, FaBoShield.Level.LOW);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2C3AxisDeviceOrientationProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2C3AxisDeviceOrientationProfile.java
deleted file mode 100644
index 2743c4443c..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2C3AxisDeviceOrientationProfile.java
+++ /dev/null
@@ -1,238 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IADXL345;
-import org.deviceconnect.android.event.Event;
-import org.deviceconnect.android.event.EventError;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.List;
-
-/**
- * I2C用加速度センサープロファイル.
- *
- * 以下のFaBoのBrickに対応します。
- * ID: #201
- * Name: 3Axis I2C Brick
- *
- */
-public class I2C3AxisDeviceOrientationProfile extends BaseFaBoProfile {
-
- /**
- * イベントを送信するためのインターバル.
- */
- private long mInterval = 100;
-
- /**
- * 前回送信したイベントの時間.
- */
- private long mSendTime;
-
- /**
- * ADXL345からのデータを受け取るためのリスナー.
- */
- private IADXL345.OnADXL345Listener mOnADXL345Listener;
-
- public I2C3AxisDeviceOrientationProfile() {
- // GET /gotapi/deviceOrientation/onDeviceOrientation
- addApi(new GetApi() {
- @Override
- public String getAttribute() {
- return "onDeviceOrientation";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else {
- IADXL345 adxl345 = getFaBoDeviceControl().getADXL345();
- if (adxl345 != null) {
- adxl345.read(new IADXL345.OnADXL345Listener() {
- @Override
- public void onStarted() {
- }
-
- @Override
- public void onData(final double x, final double y, final double z) {
- response.putExtra("orientation", createOrientation(x, y, z));
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
-
- @Override
- public void onError(final String message) {
- MessageUtils.setIllegalDeviceStateError(response, message);
- sendResponse(response);
- }
- });
- }
- }
- return false;
- }
- });
-
- // PUT /gotapi/deviceOrientation/onDeviceOrientation
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "onDeviceOrientation";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final IADXL345 adxl345 = getFaBoDeviceControl().getADXL345();
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (adxl345 == null) {
- MessageUtils.setNotSupportAttributeError(response, "Not support.");
- } else {
- Long interval = parseLong(request, "interval");
- if (interval != null) {
- mInterval = interval;
- } else {
- mInterval = 100;
- }
-
- boolean empty = isEmptyEvent();
-
- EventError error = EventManager.INSTANCE.addEvent(request);
- switch (error) {
- case NONE:
- if (empty) {
- mOnADXL345Listener = new IADXL345.OnADXL345Listener() {
- @Override
- public void onStarted() {
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
-
- @Override
- public void onError(final String message) {
- MessageUtils.setIllegalDeviceStateError(response, message);
- sendResponse(response);
- EventManager.INSTANCE.removeEvent(request);
- adxl345.stopRead(mOnADXL345Listener);
- }
-
- @Override
- public void onData(final double x, final double y, final double z) {
- notifySensorEvent(x, y, z);
- }
- };
- adxl345.startRead(mOnADXL345Listener);
- return false;
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- }
- return true;
- }
- });
-
- // DELETE /gotapi/deviceOrientation/onDeviceOrientation
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "onDeviceOrientation";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- IADXL345 adxl345 = getFaBoDeviceControl().getADXL345();
- if (adxl345 == null) {
- MessageUtils.setNotSupportProfileError(response, "Not support");
- } else {
- EventError error = EventManager.INSTANCE.removeEvent(request);
- switch (error) {
- case NONE:
- if (isEmptyEvent()) {
- adxl345.stopRead(mOnADXL345Listener);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- case NOT_FOUND:
- MessageUtils.setIllegalDeviceStateError(response, "Not register event.");
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "deviceOrientation";
- }
-
- /**
- * イベント登録が空か確認を行う.
- * @return イベントが空の場合はtrue、それ以外はfalse
- */
- private boolean isEmptyEvent() {
- String serviceId = getService().getId();
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "deviceOrientation", null, "onDeviceOrientation");
- return events.isEmpty();
- }
-
- /**
- * Orientationオブジェクトを作成します.
- * @param x x軸への加速度
- * @param y y軸への加速度
- * @param z z¥軸への加速度
- * @return Orientationオブジェクト
- */
- private Bundle createOrientation(final double x, final double y, final double z) {
- Bundle accelerationIncludingGravity = new Bundle();
- accelerationIncludingGravity.putDouble("x", x);
- accelerationIncludingGravity.putDouble("y", y);
- accelerationIncludingGravity.putDouble("z", z);
-
- Bundle orientation = new Bundle();
- orientation.putParcelable("accelerationIncludingGravity",
- accelerationIncludingGravity);
- return orientation;
- }
-
- /**
- * 加速度センサーの値を通知します.
- * @param x x軸への加速度
- * @param y y軸への加速度
- * @param z z¥軸への加速度
- */
- private void notifySensorEvent(final double x, final double y, final double z) {
- long interval = (System.currentTimeMillis() - mSendTime);
- if (interval >= mInterval) {
- String serviceId = getService().getId();
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "deviceOrientation", null, "onDeviceOrientation");
-
- for (Event event : events) {
- Bundle orientation = createOrientation(x, y, z);
- orientation.putLong("interval", interval);
-
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra("orientation", orientation);
- sendEvent(intent, event.getAccessToken());
- }
-
- mSendTime = System.currentTimeMillis();
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2C9AxisDeviceOrientationProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2C9AxisDeviceOrientationProfile.java
deleted file mode 100644
index 0139fef102..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2C9AxisDeviceOrientationProfile.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PutApi;
-
-/**
- * I2C用加速度センサープロファイル.
- *
- * 以下のFaBoのBrickに対応します。
- * ID: #202
- * Name: 9Axis I2C Brick
- *
- */
-public class I2C9AxisDeviceOrientationProfile extends BaseFaBoProfile {
-
- public I2C9AxisDeviceOrientationProfile() {
- // GET /gotapi/deviceOrientation/onDeviceOrientation
- addApi(new GetApi() {
- @Override
- public String getAttribute() {
- return "onDeviceOrientation";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- MessageUtils.setNotSupportProfileError(response, "Not implements yet.");
- return true;
- }
- });
-
- // PUT /gotapi/deviceOrientation/onDeviceOrientation
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "onDeviceOrientation";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- MessageUtils.setNotSupportProfileError(response, "Not implements yet.");
- return true;
- }
- });
-
- // DELETE /gotapi/deviceOrientation/onDeviceOrientation
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "onDeviceOrientation";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- MessageUtils.setNotSupportProfileError(response, "Not implements yet.");
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "deviceOrientation";
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CAtmosphericPressureProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CAtmosphericPressureProfile.java
deleted file mode 100644
index 4bc929feaf..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CAtmosphericPressureProfile.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IMPL115;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.message.DConnectMessage;
-
-/**
- * I2C用気圧センサープロファイル.
- *
- * 以下のFaBoのBrickに対応します。
- * ID: #204
- * Name: Barometer I2C Brick
- *
- */
-public class I2CAtmosphericPressureProfile extends BaseFaBoProfile {
- public I2CAtmosphericPressureProfile() {
- addApi(new GetApi() {
- @Override
- public boolean onRequest(Intent request, final Intent response) {
- IMPL115 mpl115 = getFaBoDeviceControl().getMPL115();
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (mpl115 == null) {
- MessageUtils.setNotSupportAttributeError(response, "Not support.");
- } else {
- mpl115.readAtmosphericPressure(new IMPL115.OnAtmosphericPressureListener() {
- @Override
- public void onData(double hpa, double temperature) {
- response.putExtra("atmosphericPressure", hpa);
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
-
- @Override
- public void onError(String message) {
- MessageUtils.setIllegalDeviceStateError(response, message);
- sendResponse(response);
- }
- });
- return false;
- }
- return true;
- }
- });
- }
- @Override
- public String getProfileName() {
- return "atmosphericPressure";
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CBarLightProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CBarLightProfile.java
deleted file mode 100644
index dff95c8dcc..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CBarLightProfile.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-/**
- * I2C用Lightプロファイル.
- *
- * ID: #403
- * Name: ColorLED Bar Brick
- *
- */
-public class I2CBarLightProfile extends BaseFaBoProfile {
- @Override
- public String getProfileName() {
- return "light";
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CHumidityProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CHumidityProfile.java
deleted file mode 100644
index bdce8a99a2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CHumidityProfile.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IHTS221;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.message.DConnectMessage;
-
-/**
- * I2C用Humidityプロファイル.
- *
- * ID: #208
- * Name: Humidity I2C Brick
- *
- */
-public class I2CHumidityProfile extends BaseFaBoProfile {
-
- public I2CHumidityProfile() {
- // GET /gotapi/humidity
- addApi(new GetApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- IHTS221 hts221 = getFaBoDeviceControl().getHTS221();
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (hts221 == null) {
- MessageUtils.setNotSupportAttributeError(response, "Not support");
- } else {
- hts221.readHumidity(new IHTS221.OnHumidityCallback() {
- @Override
- public void onHumidity(final double humidity) {
- response.putExtra("humidity", humidity / 100.0);
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
-
- @Override
- public void onError(final String message) {
- MessageUtils.setIllegalDeviceStateError(response, message);
- sendResponse(response);
- }
- });
- return false;
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "humidity";
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CIlluminanceProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CIlluminanceProfile.java
deleted file mode 100644
index 78fa884c59..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CIlluminanceProfile.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IISL29034;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.message.DConnectMessage;
-
-/**
- * I2C用Illuminaceプロファイル.
- *
- * ID #217
- * Name: Ambient Light I2C Brick
- *
- */
-public class I2CIlluminanceProfile extends BaseFaBoProfile {
-
- public I2CIlluminanceProfile() {
- // GET /gotpai/illuminance
- addApi(new GetApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- IISL29034 isl29034 = getFaBoDeviceControl().getISL29034();
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (isl29034 == null) {
- MessageUtils.setNotSupportAttributeError(response, "Not support.");
- } else {
- isl29034.read(new IISL29034.OnAmbientLightListener() {
- @Override
- public void onStarted() {
- }
-
- @Override
- public void onData(double lux) {
- response.putExtra("illuminance", lux);
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
-
- @Override
- public void onError(String message) {
- MessageUtils.setIllegalDeviceStateError(response, message);
- sendResponse(response);
- }
- });
- return false;
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "illuminance";
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CLIDARLiteProximityProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CLIDARLiteProximityProfile.java
deleted file mode 100644
index 6d63a3b48a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CLIDARLiteProximityProfile.java
+++ /dev/null
@@ -1,194 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.ILIDARLiteV3;
-import org.deviceconnect.android.event.Event;
-import org.deviceconnect.android.event.EventError;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.List;
-
-import static org.deviceconnect.android.event.EventManager.INSTANCE;
-
-public class I2CLIDARLiteProximityProfile extends BaseFaBoProfile {
- private ILIDARLiteV3.OnLIDARLiteListener mOnLIDARLiteListener;
-
- public I2CLIDARLiteProximityProfile() {
- // GET /gotapi/proximity/onUserProximity
- addApi(new GetApi() {
- @Override
- public String getAttribute() {
- return "onDeviceProximity";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- ILIDARLiteV3 lidarLite = getFaBoDeviceControl().getLIDARLite();
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (lidarLite == null) {
- MessageUtils.setNotSupportAttributeError(response, "Not support.");
- } else {
- lidarLite.read(new ILIDARLiteV3.OnLIDARLiteListener() {
- @Override
- public void onStarted() {
- }
-
- @Override
- public void onData(final int distance) {
- response.putExtra("proximity", createProximity(distance));
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
-
- @Override
- public void onError(final String message) {
- MessageUtils.setIllegalDeviceStateError(response, message);
- sendResponse(response);
- }
- });
- }
- return false;
- }
- });
-
-
- // PUT /gotapi/proximity/onUserProximity
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "onDeviceProximity";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final ILIDARLiteV3 lidarLite = getFaBoDeviceControl().getLIDARLite();
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (lidarLite == null) {
- MessageUtils.setNotSupportAttributeError(response, "Not support.");
- } else {
- boolean empty = isEmptyEvent();
- EventError error = INSTANCE.addEvent(request);
- switch (error) {
- case NONE:
- if (empty) {
- mOnLIDARLiteListener = new ILIDARLiteV3.OnLIDARLiteListener() {
- @Override
- public void onStarted() {
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
-
- @Override
- public void onData(final int proximity) {
- notifyProximity(proximity);
- }
-
- @Override
- public void onError(final String message) {
- MessageUtils.setIllegalDeviceStateError(response, message);
- sendResponse(response);
- INSTANCE.removeEvent(request);
- lidarLite.stopRead(this);
-
- }
- };
- lidarLite.startRead(mOnLIDARLiteListener);
- return false;
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- }
- return true;
- }
- });
-
- // DELETE /gotapi/proximity/onUserProximity
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "onDeviceProximity";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final ILIDARLiteV3 lidarLite = getFaBoDeviceControl().getLIDARLite();
- if (lidarLite == null) {
- MessageUtils.setNotSupportAttributeError(response, "Not support.");
- } else {
- EventError error = INSTANCE.removeEvent(request);
- switch (error) {
- case NONE:
- if (isEmptyEvent() && mOnLIDARLiteListener != null) {
- lidarLite.stopRead(mOnLIDARLiteListener);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- case NOT_FOUND:
- MessageUtils.setIllegalDeviceStateError(response, "Not register event.");
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "proximity";
- }
-
-
- /**
- * 登録されているイベントが空か確認します.
- * @return イベントが登録されていない場合はtrue、それ以外はfalse
- */
- private boolean isEmptyEvent() {
- String serviceId = getService().getId();
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "proximity", null, "onDeviceProximity");
- return events.isEmpty();
- }
-
- /**
- * Proximityのオブジェクトを作成します.
- * @param value 距離
- * @return Proximityのオブジェクト
- */
- private Bundle createProximity(final int value) {
- Bundle proximity = new Bundle();
- proximity.putInt("value", value);
- return proximity;
- }
-
- /**
- * Arduinoから渡されてきた値をProximityとして通知します.
- * @param value 値が渡されてきたピン
- */
- private void notifyProximity(final int value) {
- String serviceId = getService().getId();
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "proximity", null, "onDeviceProximity");
- for (Event event : events) {
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra("proximity", createProximity(value));
- sendEvent(intent, event.getAccessToken());
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CMatrixLightProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CMatrixLightProfile.java
deleted file mode 100644
index 30504d0515..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CMatrixLightProfile.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-/**
- * I2C用Lightプロファイル.
- *
- * ID: #404
- * Name: ColorLED Matrix Brick
- *
- */
-public class I2CMatrixLightProfile extends BaseFaBoProfile {
- @Override
- public String getProfileName() {
- return "light";
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CMouseCarDriveControllerProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CMouseCarDriveControllerProfile.java
deleted file mode 100644
index 0c41fd9fb4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CMouseCarDriveControllerProfile.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.device.IMouseCar;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-/**
- * RobotCar (Mouseタイプ)を操作するためのDriveControllerプロファイル.
- *
- * ID: #1201
- * Name: RobotCar Kit
- *
- */
-public class I2CMouseCarDriveControllerProfile extends BaseFaBoProfile {
-
- /**
- * RobotCarの向きを保持します.
- *
- * この角度でRobotCarが回転します。
- *
- */
- private float mAngle = 0;
-
- /**
- * RobotCarの速度を保持します.
- */
- private float mSpeed = 0;
-
- /**
- * コンストラクタ.
- */
- public I2CMouseCarDriveControllerProfile() {
- // PUT /driveController/rotate
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "rotate";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Float angle = parseFloat(request, "angle");
-
- if (angle != null) {
- mAngle = angle;
- }
-
- FaBoDeviceControl mgr = getFaBoDeviceControl();
- if (!getService().isOnline() || mgr == null) {
- MessageUtils.setIllegalDeviceStateError(response);
- return true;
- }
-
- // 速度が入っている場合には動作しているの移動する
- if (mSpeed != 0) {
- moveRobotCar();
- }
-
- setResult(response, DConnectMessage.RESULT_OK);
- return true;
- }
- });
-
- // POST /driveController/move
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "move";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Float angle = parseFloat(request, "angle");
- Float speed = parseFloat(request, "speed");
-
- if (angle != null) {
- mAngle = angle;
- }
-
- if (speed != null) {
- mSpeed = speed;
- }
-
- FaBoDeviceControl mgr = getFaBoDeviceControl();
- if (!getService().isOnline() || mgr == null) {
- MessageUtils.setIllegalDeviceStateError(response);
- return true;
- }
-
- moveRobotCar();
-
- setResult(response, DConnectMessage.RESULT_OK);
- return true;
- }
- });
-
- // DELETE /driveController/stop
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "stop";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
-
- // 停止したので速度を0にしておく
- mSpeed = 0;
-
- FaBoDeviceControl mgr = getFaBoDeviceControl();
- if (!getService().isOnline() || mgr == null) {
- MessageUtils.setIllegalDeviceStateError(response);
- return true;
- }
-
- IMouseCar mouseCar = mgr.getMouseCar();
- mouseCar.stop();
-
- setResult(response, DConnectMessage.RESULT_OK);
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "driveController";
- }
-
- /**
- * RobotCar(Mouse)を移動させます.
- */
- private void moveRobotCar() {
- float speed_right;
- float speed_left;
- if (mAngle >= 0) {
- float gain = mAngle / 360.0f;
- speed_right = mSpeed;
- speed_left = mSpeed * (1 - gain);
- } else {
- float gain = -mAngle / 360.0f;
- speed_right = mSpeed * (1 - gain);
- speed_left = mSpeed;
- }
-
- FaBoDeviceControl mgr = getFaBoDeviceControl();
- IMouseCar mouseCar = mgr.getMouseCar();
- mouseCar.move(speed_right, speed_left);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2COneLightProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2COneLightProfile.java
deleted file mode 100644
index 0f3480fb77..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2COneLightProfile.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-/**
- * I2C用Lightプロファイル.
- *
- * ID: #401
- * Name: ColorLED One Brick
- *
- */
-public class I2COneLightProfile extends BaseFaBoProfile {
- @Override
- public String getProfileName() {
- return "light";
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CProximityProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CProximityProfile.java
deleted file mode 100644
index 9551c3f77d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CProximityProfile.java
+++ /dev/null
@@ -1,205 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IVCNL4010;
-import org.deviceconnect.android.event.Event;
-import org.deviceconnect.android.event.EventError;
-import org.deviceconnect.android.event.EventManager;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-import java.util.List;
-
-import static org.deviceconnect.android.event.EventManager.INSTANCE;
-
-/**
- * I2C用Proximityプロファイル.
- *
- * ID: #205
- * Name: Proximity I2C Brick
- *
- */
-public class I2CProximityProfile extends BaseFaBoProfile {
-
- /**
- * VCNL4010からの通知を受け取るリスナー.
- */
- private IVCNL4010.OnProximityListener mOnProximityListener;
-
- /**
- * コンストラクタ.
- */
- public I2CProximityProfile() {
- // GET /gotapi/proximity/onUserProximity
- addApi(new GetApi() {
- @Override
- public String getAttribute() {
- return "onUserProximity";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- IVCNL4010 ivcnl4010 = getFaBoDeviceControl().getVCNL4010();
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (ivcnl4010 == null) {
- MessageUtils.setNotSupportAttributeError(response, "Not support.");
- } else {
- ivcnl4010.readProximity(new IVCNL4010.OnProximityListener() {
- @Override
- public void onStarted() {
- }
-
- @Override
- public void onData(final boolean proximity) {
- response.putExtra("proximity", createProximity(proximity));
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
-
- @Override
- public void onError(String message) {
- MessageUtils.setIllegalDeviceStateError(response, message);
- sendResponse(response);
- }
- });
- }
- return false;
- }
- });
-
- // PUT /gotapi/proximity/onUserProximity
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "onUserProximity";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final IVCNL4010 ivcnl4010 = getFaBoDeviceControl().getVCNL4010();
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (ivcnl4010 == null) {
- MessageUtils.setNotSupportAttributeError(response, "Not support.");
- } else {
- boolean empty = isEmptyEvent();
- EventError error = INSTANCE.addEvent(request);
- switch (error) {
- case NONE:
- if (empty) {
- mOnProximityListener = new IVCNL4010.OnProximityListener() {
- @Override
- public void onStarted() {
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
-
- @Override
- public void onData(final boolean proximity) {
- notifyProximity(proximity);
- }
-
- @Override
- public void onError(final String message) {
- MessageUtils.setIllegalDeviceStateError(response, message);
- sendResponse(response);
- EventManager.INSTANCE.removeEvent(request);
- ivcnl4010.stopProximity(mOnProximityListener);
-
- }
- };
- ivcnl4010.startProximity(mOnProximityListener);
- return false;
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- }
- return true;
- }
- });
-
- // DELETE /gotapi/proximity/onUserProximity
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "onUserProximity";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- IVCNL4010 ivcnl4010 = getFaBoDeviceControl().getVCNL4010();
- if (ivcnl4010 == null) {
- MessageUtils.setNotSupportAttributeError(response, "Not support.");
- } else {
- EventError error = INSTANCE.removeEvent(request);
- switch (error) {
- case NONE:
- if (isEmptyEvent() && mOnProximityListener != null) {
- ivcnl4010.stopProximity(mOnProximityListener);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- break;
- case NOT_FOUND:
- MessageUtils.setIllegalDeviceStateError(response, "Not register event.");
- break;
- default:
- MessageUtils.setUnknownError(response);
- break;
- }
- }
- return true;
- }
- });
- }
- @Override
- public String getProfileName() {
- return "proximity";
- }
-
- /**
- * 登録されているイベントが空か確認します.
- * @return イベントが登録されていない場合はtrue、それ以外はfalse
- */
- private boolean isEmptyEvent() {
- String serviceId = getService().getId();
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "proximity", null, "onUserProximity");
- return events.isEmpty();
- }
-
- /**
- * Proximityのオブジェクトを作成します.
- * @param value 距離
- * @return Proximityのオブジェクト
- */
- private Bundle createProximity(final boolean value) {
- Bundle proximity = new Bundle();
- proximity.putBoolean("near", value);
- return proximity;
- }
-
- /**
- * Arduinoから渡されてきた値をProximityとして通知します.
- * @param value 値が渡されてきたピン
- */
- private void notifyProximity(final boolean value) {
- String serviceId = getService().getId();
- List events = EventManager.INSTANCE.getEventList(serviceId,
- "proximity", null, "onUserProximity");
- for (Event event : events) {
- Intent intent = EventManager.createEventMessage(event);
- intent.putExtra("proximity", createProximity(value));
- sendEvent(intent, event.getAccessToken());
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CRingLightProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CRingLightProfile.java
deleted file mode 100644
index 4e1a45168a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CRingLightProfile.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-/**
- * I2C用Lightプロファイル.
- *
- * ID: #402
- * Name: ColorLED Ring Brick
- *
- */
-public class I2CRingLightProfile extends BaseFaBoProfile {
- @Override
- public String getProfileName() {
- return "light";
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CRobotCarDriveControllerProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CRobotCarDriveControllerProfile.java
deleted file mode 100644
index b4c7771f4b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CRobotCarDriveControllerProfile.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.device.IRobotCar;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.android.profile.api.PutApi;
-import org.deviceconnect.message.DConnectMessage;
-
-/**
- * RobotCar (Carタイプ)を操作するためのDriveControllerプロファイル.
- */
-public class I2CRobotCarDriveControllerProfile extends BaseFaBoProfile {
-
- /**
- * コンストラクタ.
- */
- public I2CRobotCarDriveControllerProfile() {
- // PUT /driveController/rotate
- addApi(new PutApi() {
- @Override
- public String getAttribute() {
- return "rotate";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Float angle = parseFloat(request, "angle");
-
- FaBoDeviceControl mgr = getFaBoDeviceControl();
- if (!getService().isOnline() || mgr == null) {
- MessageUtils.setIllegalDeviceStateError(response);
- return true;
- }
-
- IRobotCar robotCar = mgr.getRobotCar();
- if (angle != null) {
- robotCar.turnHandle(calcAngle(angle));
- }
-
- setResult(response, DConnectMessage.RESULT_OK);
- return true;
- }
- });
-
- // POST /driveController/move
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "move";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Float angle = parseFloat(request, "angle");
- Float speed = parseFloat(request, "speed");
-
- FaBoDeviceControl mgr = getFaBoDeviceControl();
- if (!getService().isOnline() || mgr == null) {
- MessageUtils.setIllegalDeviceStateError(response);
- return true;
- }
-
- IRobotCar robotCar = mgr.getRobotCar();
- if (speed != null) {
- if (speed == 0) {
- robotCar.stop();
- } else {
- robotCar.move(speed);
- }
- }
-
- if (angle != null) {
- robotCar.turnHandle(calcAngle(angle));
- }
-
- setResult(response, DConnectMessage.RESULT_OK);
- return true;
- }
- });
-
- // DELETE /driveController/stop
- addApi(new DeleteApi() {
- @Override
- public String getAttribute() {
- return "stop";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- FaBoDeviceControl mgr = getFaBoDeviceControl();
- if (!getService().isOnline() || mgr == null) {
- MessageUtils.setIllegalDeviceStateError(response);
- return true;
- }
-
- IRobotCar robotCar = mgr.getRobotCar();
- robotCar.stop();
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "driveController";
- }
-
- /**
- * 角度(-360〜360)を-1.0〜1.0の範囲に変換します.
- * @param angle 角度
- * @return 返還後の値
- */
- private float calcAngle(final float angle) {
- if (angle > 360) {
- return 1.0f;
- }
- if (angle < -360) {
- return -1.0f;
- }
- return angle / 360.0f;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CTemperatureProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CTemperatureProfile.java
deleted file mode 100644
index 375e181d15..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/service/virtual/profile/I2CTemperatureProfile.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.service.virtual.profile;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IADT7410;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.message.DConnectMessage;
-
-/**
- * I2C用Temperatureプロファイル.
- *
- * ID: #207
- * Name: Temperature I2C Brick
- *
- */
-public class I2CTemperatureProfile extends BaseFaBoProfile {
- /**
- * コンストラクタ.
- */
- public I2CTemperatureProfile() {
- // GET /gotpai/temperature
- addApi(new GetApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final Integer type = parseInteger(request, "type");
- final IADT7410 adt = getFaBoDeviceControl().getADT7410();
- if (!getService().isOnline()) {
- MessageUtils.setIllegalDeviceStateError(response, "FaBo device is not connected.");
- } else if (adt == null) {
- MessageUtils.setNotSupportAttributeError(response, "Not support.");
- } else {
- adt.read(new IADT7410.OnADT7410Listener() {
- @Override
- public void onStarted() {
- }
-
- @Override
- public void onError(final String message) {
- MessageUtils.setIllegalDeviceStateError(response, message);
- sendResponse(response);
- }
-
- @Override
- public void onData(final double temperature) {
- if (type == null || type == 1) {
- response.putExtra("temperature", temperature);
- } else {
- response.putExtra("temperature", convertC2F(temperature));
- }
- setResult(response, DConnectMessage.RESULT_OK);
- sendResponse(response);
- }
- });
- return false;
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "temperature";
- }
-
- /**
- * 摂氏を華氏に変換します.
- * @param temp 摂氏
- * @return 華氏
- */
- private double convertC2F(double temp) {
- return temp * 1.8 + 32;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoPinListActivity.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoPinListActivity.java
deleted file mode 100644
index b9852e07a1..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoPinListActivity.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.setting;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.FragmentManager;
-import android.app.FragmentTransaction;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.Button;
-
-import org.deviceconnect.android.deviceplugin.fabo.core.R;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileDataUtil;
-import org.deviceconnect.android.deviceplugin.fabo.setting.fragment.FaBoBasePinFragment;
-import org.deviceconnect.android.deviceplugin.fabo.setting.fragment.FaBoPinCheckBoxFragment;
-import org.deviceconnect.android.deviceplugin.fabo.setting.fragment.FaBoPinRadioGroupFragment;
-
-import java.util.List;
-
-/**
- * 使用するピンを選択するための画面を表示するActivity.
- */
-public class FaBoPinListActivity extends Activity {
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_fabo_pin_list);
-
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- }
-
- setTitle(R.string.activity_fabo_virtual_service_pin_title);
-
- ProfileData p = getIntent().getParcelableExtra("profile");
- if (ProfileDataUtil.isMultiChoicePin(p)) {
- showPinFragment(new FaBoPinCheckBoxFragment());
- } else {
- showPinFragment(new FaBoPinRadioGroupFragment());
- }
-
- Button saveBtn = findViewById(R.id.activity_fabo_pin_save_btn);
- saveBtn.setOnClickListener((view) -> {
- savePinList();
- });
-
- // バックキーを押下された時を考慮してキャンセルを設定しておく
- setResult(RESULT_CANCELED, new Intent());
- }
-
- @Override
- public boolean onOptionsItemSelected(final MenuItem item) {
- switch(item.getItemId()) {
- case android.R.id.home:
- finish();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- /**
- * ピンを選択するフラグメントを表示します.
- * @param fragment 表示するフラグメント
- */
- private void showPinFragment(final FaBoBasePinFragment fragment) {
- FragmentManager manager = getFragmentManager();
- FragmentTransaction transaction = manager.beginTransaction();
- transaction.replace(R.id.container, fragment);
- transaction.commit();
- }
-
- /**
- * ピンが一つも選択されていない場合にエラーダイアログを表示します.
- */
- private void showNoSelectPin() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_fabo_virtual_service_error_title)
- .setMessage(R.string.activity_fabo_virtual_service_pin_no_select_message)
- .setPositiveButton(R.string.activity_fabo_virtual_service_error_ok, null)
- .show();
- }
-
- /**
- * プロファイルで使用するピンのリストを返却します.
- */
- private void savePinList() {
- FaBoBasePinFragment fragment = (FaBoBasePinFragment) getFragmentManager().findFragmentById(R.id.container);
-
- List pins = fragment.getSelectedPins();
- if (pins.isEmpty()) {
- showNoSelectPin();
- } else {
- ProfileData p = getIntent().getParcelableExtra("profile");
- p.setPinList(pins);
-
- Intent intent = new Intent();
- intent.putExtra("profile", p);
- setResult(RESULT_OK, intent);
- finish();
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoProfileListActivity.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoProfileListActivity.java
deleted file mode 100644
index 82006ef534..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoProfileListActivity.java
+++ /dev/null
@@ -1,212 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.setting;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.BaseAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import org.deviceconnect.android.deviceplugin.fabo.core.R;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileDataUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * プロファイル一覧を表示するActivity.
- */
-public class FaBoProfileListActivity extends Activity {
- /**
- * リクエストコード.
- */
- private static final int REQUEST_CODE = 201;
-
- /**
- * プロファイルを表示するアダプタ.
- */
- private ProfileAdapter mProfileAdapter;
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_fabo_profile_list);
-
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- }
-
- setTitle(R.string.activity_fabo_virtual_service_profile_title);
-
- Intent intent = getIntent();
- if (intent == null) {
- finish();
- return;
- }
-
- mProfileAdapter = new ProfileAdapter(getProfileTypes());
-
- ListView listView = findViewById(R.id.activity_fabo_profile_list_view);
- listView.setOnItemClickListener((adapterView, view, position, id) -> {
- ProfileData.Type type = (ProfileData.Type) mProfileAdapter.getItem(position);
- if (type.getValue() < 100) {
- openPinActivity(type.getValue());
- } else {
- selectedProfileData(type.getValue(), null);
- }
- });
- listView.setAdapter(mProfileAdapter);
-
- // バックキーを押下された時を考慮してキャンセルを設定しておく
- setResult(RESULT_CANCELED, new Intent());
- }
-
- @Override
- public boolean onOptionsItemSelected(final MenuItem item) {
- switch(item.getItemId()) {
- case android.R.id.home:
- finish();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
- switch (requestCode) {
- case REQUEST_CODE:
- if (resultCode == RESULT_OK) {
- ProfileData profileData = data.getParcelableExtra("profile");
- selectedProfileData(profileData);
- }
- break;
- }
- }
-
- /**
- * 追加できるプロファイルのリストを取得します.
- * @return 追加できるプロファイルリスト
- */
- private List getProfileTypes() {
- ArrayList profileDatas = getIntent().getParcelableArrayListExtra("profile");
- List typeList = new ArrayList<>();
- for (ProfileData.Type type : ProfileData.Type.values()) {
- if (!containsProfileData(profileDatas, type)) {
- typeList.add(type);
- }
- }
- return typeList;
- }
-
- /**
- * プロファイルのリストに指定されたプロファイルが存在するか確認します.
- * @param list プロファイルのリスト
- * @param type 確認するプロファイル
- * @return 存在する場合にはtrue、それ以外はfalse
- */
- private boolean containsProfileData(final List list, final ProfileData.Type type) {
- if (list == null) {
- return true;
- }
-
- for (ProfileData p : list) {
- if (p.getType().getProfileName().equals(type.getProfileName())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * 選択されたプロファイルデータを返却して、Activityを終了します.
- * @param profileType プロファイルタイプ
- * @param pins プロファイルが使用するピンのリスト
- */
- private void selectedProfileData(final int profileType, final List pins) {
- ProfileData profileData = new ProfileData();
- profileData.setType(ProfileData.Type.getType(profileType));
- if (pins != null) {
- profileData.setPinList(pins);
- }
- selectedProfileData(profileData);
- }
-
- /**
- * プロファイルデータを選択し、Activityを終了します.
- *
- * @param profileData 選択するプロファイルデータ
- */
- private void selectedProfileData(final ProfileData profileData) {
- Intent intent = new Intent();
- intent.putExtra("profile", profileData);
- setResult(RESULT_OK, intent);
- finish();
- }
-
- /**
- * GPIOのピン選択画面を開きます.
- *
- * @param profileType 送信するプロファイルデータ
- */
- private void openPinActivity(final int profileType) {
- ProfileData data = new ProfileData();
- data.setType(ProfileData.Type.getType(profileType));
-
- Intent intent = new Intent();
- intent.setClass(this, FaBoPinListActivity.class);
- intent.putExtra("profile", data);
- intent.putExtra("pins", getIntent().getIntegerArrayListExtra("pins"));
- startActivityForResult(intent, REQUEST_CODE);
- }
-
- /**
- * プロファイルを格納するアダプタ.
- */
- private class ProfileAdapter extends BaseAdapter {
-
- private List mTypeList;
-
- ProfileAdapter(final List typeList) {
- mTypeList = typeList;
- }
-
- @Override
- public int getCount() {
- return mTypeList.size();
- }
-
- @Override
- public Object getItem(final int position) {
- return mTypeList.get(position);
- }
-
- @Override
- public long getItemId(final int id) {
- return id;
- }
-
- @Override
- public View getView(final int position, View convertView, final ViewGroup parent) {
- if (convertView == null) {
- LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.item_fabo_profile, null);
- }
-
- ProfileData.Type type = (ProfileData.Type) getItem(position);
-
- TextView nameTV = (TextView) convertView.findViewById(R.id.item_fabo_profile_name);
- nameTV.setText(ProfileDataUtil.getProfileName(FaBoProfileListActivity.this, type));
-
- return convertView;
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoServiceListActivity.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoServiceListActivity.java
deleted file mode 100644
index 2faaaab303..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoServiceListActivity.java
+++ /dev/null
@@ -1,591 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.setting;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Fragment;
-import android.app.FragmentManager;
-import android.app.FragmentTransaction;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.BaseAdapter;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import org.deviceconnect.android.deviceplugin.fabo.FaBoDeviceService;
-import org.deviceconnect.android.deviceplugin.fabo.core.R;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.VirtualService;
-import org.deviceconnect.android.message.DConnectMessageService;
-import org.deviceconnect.android.service.DConnectService;
-import org.deviceconnect.android.service.DConnectServiceListener;
-import org.deviceconnect.android.service.DConnectServiceProvider;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * FaBoプラグインが管理するサービスのリストを表示するActivity.
- */
-public class FaBoServiceListActivity extends Activity {
-
- /**
- * プラグインのサービス.
- */
- private DConnectMessageService mMessageService;
-
- /**
- * DConnectServiceの状態を監視・管理するクラス.
- */
- private DConnectServiceProvider mProvider;
-
- /**
- * サービスとのバインド状態.
- */
- private boolean mIsBound;
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_service_list);
-
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_HOME);
- actionBar.setTitle(R.string.activity_service_list_title);
- }
-
- bindMessageService();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- updateServiceList();
- }
-
- @Override
- protected void onDestroy() {
- unbindMessageService();
- super.onDestroy();
- }
-
- @Override
- public boolean onOptionsItemSelected(final MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- finish();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- /**
- * DConnectMessageServiceとバインドします.
- */
- private void bindMessageService() {
- if (!mIsBound) {
- Intent intent = new Intent(getApplicationContext(), Util.getDConnectMessageServiceClass(this));
- bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
- }
- }
-
- /**
- * DConnectMessageServiceとアンバインドします.
- */
- private void unbindMessageService() {
- if (mIsBound) {
- unbindService(mConnection);
- mIsBound = false;
- }
- }
-
- /**
- * FaBoが持っているサービスを表示するフラグメントを表示します.
- */
- private void showViewerFragment() {
- FragmentManager mgr = getFragmentManager();
- FragmentTransaction transaction = mgr.beginTransaction();
- ViewerFragment fragment = new ViewerFragment();
- transaction.replace(R.id.fragment_container, fragment);
- transaction.commit();
- }
-
- /**
- * FaBoが持っているサービスを削除するフラグメントを表示します.
- */
- private void showRemoverFragment() {
- FragmentManager mgr = getFragmentManager();
- FragmentTransaction transaction = mgr.beginTransaction();
- RemoverFragment fragment = new RemoverFragment();
- transaction.replace(R.id.fragment_container, fragment);
- transaction.commit();
- }
-
- /**
- * FaBoが持っているサービスを管理するクラスを取得します.
- *
- * DConnectMessageServiceとバインドされていない場合にはnullを返却します.
- *
- * @return DConnectServiceProviderのインスタンス
- */
- private DConnectServiceProvider getProvider() {
- return mProvider;
- }
-
- /**
- * 指定されたリストを削除します.
- * @param services 削除するサービスリスト
- */
- private void removeServices(final List services) {
- for (DConnectService service : services) {
- mProvider.removeService(service.getId());
-
- if (service instanceof VirtualService) {
- FaBoDeviceService faBo = (FaBoDeviceService) mMessageService;
- faBo.removeServiceData(((VirtualService) service).getServiceData());
- }
- }
- }
-
- /**
- * VirtualServiceActivityを開きます.
- *
- * @param service 仮想サービス
- */
- private void openVirtualServiceActivity(final VirtualService service) {
- Intent intent = new Intent();
- intent.setClass(this, FaBoVirtualServiceActivity.class);
- if (service != null) {
- intent.putExtra("service", service.getServiceData());
- }
- startActivity(intent);
- }
-
- /**
- * DConnectMessageServiceとのバインドを状態のイベントを受け取るクラス.
- */
- private ServiceConnection mConnection = new ServiceConnection() {
- @Override
- public void onServiceConnected(final ComponentName name, final IBinder service) {
- runOnUiThread(() -> {
- mMessageService = ((DConnectMessageService.LocalBinder) service).getMessageService();
- mProvider = mMessageService.getServiceProvider();
- mProvider.addServiceListener(mDConnectServiceListener);
- mIsBound = true;
-
- showViewerFragment();
- });
- }
-
- @Override
- public void onServiceDisconnected(final ComponentName name) {
- mIsBound = false;
- mProvider.removeServiceListener(mDConnectServiceListener);
- mMessageService = null;
- }
- };
-
- /**
- * DConnectServiceの状態通知を受け取るリスナー.
- */
- private DConnectServiceListener mDConnectServiceListener = new DConnectServiceListener() {
- @Override
- public void onServiceAdded(final DConnectService service) {
- updateServiceList();
- }
-
- @Override
- public void onServiceRemoved(final DConnectService service) {
- updateServiceList();
- }
-
- @Override
- public void onStatusChange(final DConnectService service) {
- updateServiceList();
- }
- };
-
- /**
- * DConnectServiceのリスト更新を行います.
- */
- private void updateServiceList() {
- runOnUiThread(() -> {
- FragmentManager mgr = getFragmentManager();
- Fragment f = mgr.findFragmentById(R.id.fragment_container);
- if (f != null && f instanceof BaseFragment) {
- ((BaseFragment) f).notifyServiceStatusChange();
- }
- });
- }
-
- /**
- * DConnectServiceを表示するための基底フラグメント.
- */
- public static class BaseFragment extends Fragment {
- /**
- * 共通で使用するDConnectServiceのリストを管理するアダプタ.
- */
- protected ServiceListAdapter mListAdapter;
-
- /**
- * DConnectServiceの状態が変わったこと通知します.
- */
- protected void notifyServiceStatusChange() {
- mListAdapter.notifyDataSetChanged();
- }
-
- /**
- * DConnectServiceProviderのインスタンスを取得します.
- *
- * DConnectMessageServiceとバインドされていない場合にはnullを返却します.
- *
- * @return DConnectServiceProviderのインスタンス
- */
- protected DConnectServiceProvider getProvider() {
- return ((FaBoServiceListActivity) getActivity()).getProvider();
- }
- }
-
- /**
- * DConnectServiceを表示するためのフラグメント.
- */
- public static class ViewerFragment extends BaseFragment {
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
- final Bundle savedInstanceState) {
- setHasOptionsMenu(true);
-
- View root = inflater.inflate(R.layout.fragment_service_list_viewer, container, false);
-
- mListAdapter = new ServiceListAdapter(getActivity(), getProvider(), false);
-
- ListView listView = root.findViewById(R.id.activity_fabo_service_list_view);
- listView.setAdapter(mListAdapter);
- listView.setItemsCanFocus(true);
- listView.setClickable(true);
- listView.setOnItemClickListener((parent, view, position, id) -> {
- Object service = mListAdapter.getItem(position);
- if (service instanceof VirtualService) {
- openVirtualServiceActivity((VirtualService) service);
- }
- });
-
- Button newServiceButton = root.findViewById(R.id.activity_fabo_service_add_btn);
- newServiceButton.setOnClickListener((v) -> {
- openVirtualServiceActivity(null);
- });
-
- return root;
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- super.onCreateOptionsMenu(menu, inflater);
- inflater.inflate(R.menu.menu_fabo_service_list_viewer, menu);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == R.id.menu_fabo_service_remove) {
- showRemoverFragment();
- }
- return true;
- }
-
- /**
- * 仮想サービス管理Activityを表示します.
- * @param service 表示するサービス
- */
- private void openVirtualServiceActivity(final VirtualService service) {
- ((FaBoServiceListActivity) getActivity()).openVirtualServiceActivity(service);
- }
-
- /**
- * 仮想サービス削除用フラグメントを表示します.
- */
- private void showRemoverFragment() {
- ((FaBoServiceListActivity) getActivity()).showRemoverFragment();
- }
- }
-
- /**
- * DConnectServiceを削除するためのフラグメント.
- */
- public static class RemoverFragment extends BaseFragment implements ServiceListAdapter.OnStatusChangeListener {
- /**
- * 削除ボタン.
- */
- private Button mRemoveBtn;
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
- final Bundle savedInstanceState) {
- View root = inflater.inflate(R.layout.fragment_service_list_remover, container, false);
-
- mListAdapter = new ServiceListAdapter(getActivity(), getProvider(), true);
- mListAdapter.setOnStatusChangeListener(this);
-
- ListView listView = root.findViewById(R.id.activity_fabo_service_list_view);
- listView.setAdapter(mListAdapter);
- listView.setItemsCanFocus(true);
- listView.setClickable(true);
- listView.setOnItemClickListener((parent, view, position, id) -> {
- Object service = mListAdapter.getItem(position);
- if (service instanceof VirtualService) {
- VirtualService vs = (VirtualService) service;
- if (vs.isOnline()) {
- showOnlineDialog();
- } else {
- mListAdapter.toggleCheckBox((DConnectService) service);
- CheckBox checkBox = view.findViewById(R.id.activity_fabo_service_removal_checkbox);
- if (checkBox != null) {
- checkBox.toggle();
- }
- }
- } else {
- showImmortalDialog();
- }
- });
-
- Button cancelButton = root.findViewById(R.id.activity_fabo_service_cancel_btn);
- cancelButton.setOnClickListener((v) -> {
- showViewerFragment();
- });
-
- mRemoveBtn = (Button) root.findViewById(R.id.activity_fabo_service_remove_btn);
- mRemoveBtn.setOnClickListener((v) -> {
- showRemovalConfirmation();
- });
- mRemoveBtn.setEnabled(false);
-
- return root;
- }
-
- /**
- * 削除確認用ダイアログを表示します.
- */
- private void showRemovalConfirmation() {
- new AlertDialog.Builder(getActivity())
- .setTitle(R.string.activity_fabo_service_dialog_title_service_removal_confirmation)
- .setMessage(R.string.activity_fabo_service_dialog_message_service_removal_confirmation)
- .setCancelable(false)
- .setPositiveButton(R.string.activity_fabo_service_dialog_button_service_removal_ok,
- (dialog, which) -> {
- removeService();
- })
- .setNegativeButton(R.string.activity_fabo_service_dialog_button_service_removal_cancel, null)
- .create().show();
- }
-
- /**
- * オンラインのために削除できないことを通知するダイアログを表示します.
- */
- private void showOnlineDialog() {
- new AlertDialog.Builder(getActivity())
- .setTitle(R.string.activity_fabo_service_dialog_title_online)
- .setMessage(R.string.activity_fabo_service_dialog_message_online)
- .setCancelable(true)
- .setPositiveButton(R.string.activity_fabo_service_dialog_button_service_removal_ok, null)
- .create().show();
- }
-
- /**
- * FaBoServiceは削除できないので、エラーダイアログを表示します.
- */
- private void showImmortalDialog() {
- new AlertDialog.Builder(getActivity())
- .setTitle(R.string.activity_fabo_service_dialog_title_immortal)
- .setMessage(R.string.activity_fabo_service_dialog_message_immortal)
- .setCancelable(true)
- .setPositiveButton(R.string.activity_fabo_service_dialog_button_service_removal_ok, null)
- .create().show();
- }
-
- /**
- * DConnectServiceを削除します.
- */
- private void removeService() {
- ((FaBoServiceListActivity) getActivity()).removeServices(mListAdapter.getRemoveServices());
- mListAdapter.getRemoveServices().clear();
- showViewerFragment();
- }
-
- /**
- * DConnectService表示用フラグメントを表示します.
- */
- private void showViewerFragment() {
- ((FaBoServiceListActivity) getActivity()).showViewerFragment();
- }
-
- @Override
- public void onStatusChange(boolean flag) {
- mRemoveBtn.setEnabled(flag);
- }
- }
-
- /**
- * サービスリストを管理するアダプタ.
- */
- private static class ServiceListAdapter extends BaseAdapter {
- /**
- * DConnectServiceを管理するクラス.
- */
- private DConnectServiceProvider mProvider;
-
- /**
- * インフレータ.
- */
- private LayoutInflater mInflater;
-
- /**
- * CheckBoxの表示フラグ.
- *
- * trueの場合はCheckBoxを表示します。
- *
- */
- private boolean mHasCheckbox;
-
- /**
- * 削除用のCheckBoxの状態が変更されたことを通知するためのリスナー.
- */
- private OnStatusChangeListener mOnStatusChangeListener;
-
- /**
- * 削除するDConnectServiceを保持するリスト.
- */
- private final List mRemoveServices = new ArrayList<>();
-
- /**
- * コンストラクタ.
- * @param context コンテキスト
- * @param provider DConnectServiceを管理するクラス
- * @param hasCheckbox CheckBox表示の有無
- */
- ServiceListAdapter(final Context context, final DConnectServiceProvider provider, final boolean hasCheckbox) {
- mProvider = provider;
- mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- mHasCheckbox = hasCheckbox;
- }
-
- /**
- * CheckBox状態変更通知リスナーを設定します.
- * @param listener リスナー
- */
- void setOnStatusChangeListener(final OnStatusChangeListener listener) {
- mOnStatusChangeListener = listener;
- }
-
- @Override
- public int getCount() {
- if (mProvider == null) {
- return 0;
- } else {
- return mProvider.getServiceList().size();
- }
- }
-
- @Override
- public Object getItem(final int position) {
- return mProvider.getServiceList().get(position);
- }
-
- @Override
- public long getItemId(final int position) {
- return position;
- }
-
- @Override
- public View getView(final int position, View convertView, ViewGroup viewGroup) {
- if (convertView == null) {
- convertView = mInflater.inflate(R.layout.item_fabo_service_list, null);
- }
-
- final DConnectService service = (DConnectService) getItem(position);
- convertView.setTag(service);
- convertView.setBackgroundResource(service.isOnline() ?
- R.color.service_list_item_background_online :
- R.color.service_list_item_background_offline);
-
- TextView statusView = convertView.findViewById(R.id.service_online_status);
- statusView.setText(service.isOnline() ?
- R.string.activity_fabo_service_online :
- R.string.activity_fabo_service_offline);
-
- TextView nameView = convertView.findViewById(R.id.service_name);
- nameView.setText(service.getName());
-
- CheckBox checkBox = convertView.findViewById(R.id.activity_fabo_service_removal_checkbox);
- checkBox.setVisibility(hasCheckbox(service) ? View.VISIBLE : View.GONE);
- checkBox.setChecked(mRemoveServices.contains(service));
-
- ImageView imageView = (ImageView) convertView.findViewById(R.id.activity_fabo_service_edit);
- imageView.setVisibility(hasImageView(service) ? View.VISIBLE : View.GONE);
-
- return convertView;
- }
-
- /**
- * 削除するDConnectServiceのリストを取得します.
- * @return 削除するDConnectServiceのリスト
- */
- private List getRemoveServices() {
- return mRemoveServices;
- }
-
- /**
- * 削除するDConnectServiceを切り替えます.
- * @param service 変更するDConnectService
- */
- private void toggleCheckBox(final DConnectService service) {
- if (!mRemoveServices.contains(service)) {
- mRemoveServices.add(service);
- } else {
- mRemoveServices.remove((service));
- }
-
- if (mOnStatusChangeListener != null) {
- mOnStatusChangeListener.onStatusChange(!mRemoveServices.isEmpty());
- }
- }
-
- /**
- * DConnectServiceのカラムにCheckBoxを表示するかを確認します.
- * @param service 確認するDConnectMessage
- * @return CheckBoxを表示する場合はtrue、それ以外はfalse
- */
- private boolean hasCheckbox(final DConnectService service) {
- return mHasCheckbox && !service.isOnline() && service instanceof VirtualService;
- }
-
- private boolean hasImageView(final DConnectService service) {
- return !mHasCheckbox && service instanceof VirtualService;
- }
-
- /**
- * CheckBoxの状態変更を通知するリスナー.
- */
- interface OnStatusChangeListener {
- /**
- * 状態変更があったことを通知します.
- * @param flag 削除するDConnectServiceがある場合にはtrue、ない場合にはfalse
- */
- void onStatusChange(final boolean flag);
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoVirtualServiceActivity.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoVirtualServiceActivity.java
deleted file mode 100644
index c044e7def5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoVirtualServiceActivity.java
+++ /dev/null
@@ -1,429 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.setting;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import org.deviceconnect.android.deviceplugin.fabo.FaBoDeviceService;
-import org.deviceconnect.android.deviceplugin.fabo.core.R;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.VirtualService;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileDataUtil;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ServiceData;
-import org.deviceconnect.android.message.DConnectMessageService;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 仮想サービスの設定を行うActivity.
- */
-public class FaBoVirtualServiceActivity extends Activity {
-
- /**
- * プロファイル追加リクエストコード.
- */
- private static final int REQUEST_CODE_ADD_PROFILE = 101;
-
- /**
- * プロファイル更新リクエストコード.
- */
- private static final int REQUEST_CODE_UPDATE_PROFILE = 102;
-
- /**
- * 新規作成フラグ.
- *
- * 新規作成の仮想サービスの場合はtrue、それ以外はfalse。
- *
- */
- private boolean mNewCreateFlag = false;
-
- /**
- * 仮想サービスデータ.
- */
- private ServiceData mServiceData;
-
- /**
- * FaBoDeviceServiceのインスタンス.
- */
- private FaBoDeviceService mFaBoDeviceService;
-
- /**
- * FaBoDeviceServiceにバインドフラグ.
- * trueの時は接続中
- */
- private boolean mIsBound;
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_fabo_virtual_service);
-
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- }
-
- setTitle(R.string.activity_fabo_virtual_service_title);
-
- Intent intent = getIntent();
- if (intent != null) {
- mServiceData = intent.getParcelableExtra("service");
- }
-
- if (mServiceData == null) {
- mNewCreateFlag = true;
- mServiceData = new ServiceData();
- mServiceData.setName("New Service");
- }
-
- TextView serviceIdTV = findViewById(R.id.activity_fabo_service_id);
- serviceIdTV.setText(mServiceData.getServiceId());
-
- EditText serviceNameET = findViewById(R.id.activity_fabo_service_name);
- serviceNameET.setText(mServiceData.getName());
- serviceNameET.setOnKeyListener((view, keyCode, event) -> {
- if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) {
- InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
- return true;
- }
- return false;
- });
-
- Button saveBtn = findViewById(R.id.activity_fabo_service_save_btn);
- saveBtn.setOnClickListener((view) -> {
- saveVirtualService();
- });
-
- Button addBtn = findViewById(R.id.activity_fabo_profile_add_btn);
- addBtn.setOnClickListener((view) -> {
- openProfileActivity();
- });
-
- LinearLayout profileLayout = findViewById(R.id.activity_fabo_profile_list);
- for (ProfileData profileData : mServiceData.getProfileDataList()) {
- View view = createProfileView(profileData);
- profileLayout.addView(view);
- }
- }
-
- @Override
- protected void onPause() {
- unbindMessageService();
- super.onPause();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- bindMessageService();
- }
-
- @Override
- public boolean onOptionsItemSelected(final MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- finish();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
- switch (requestCode) {
- case REQUEST_CODE_ADD_PROFILE:
- if (resultCode == RESULT_OK) {
- ProfileData profileData = data.getParcelableExtra("profile");
- mServiceData.addProfileData(profileData);
-
- View view = createProfileView(profileData);
- LinearLayout profileLayout = findViewById(R.id.activity_fabo_profile_list);
- profileLayout.addView(view);
- }
- break;
-
- case REQUEST_CODE_UPDATE_PROFILE:
- if (resultCode == RESULT_OK) {
- ProfileData profileData = data.getParcelableExtra("profile");
- List list = mServiceData.getProfileDataList();
- for (ProfileData pd : list) {
- if (pd.getType() == profileData.getType()) {
- pd.setPinList(profileData.getPinList());
- }
- }
- resetProfileLayout();
- }
- break;
- }
- }
-
- /**
- * サービスとバインドします.
- */
- private void bindMessageService() {
- if (!mIsBound) {
- Intent intent = new Intent(getApplicationContext(), Util.getDConnectMessageServiceClass(this));
- bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
- }
- }
-
- /**
- * サービスをアンバインドします.
- */
- private void unbindMessageService() {
- if (mIsBound) {
- unbindService(mConnection);
- mIsBound = false;
- }
- }
-
- /**
- * プロファイルのリストをを再設定します.
- */
- private void resetProfileLayout() {
- LinearLayout profileLayout = findViewById(R.id.activity_fabo_profile_list);
- profileLayout.removeAllViews();
-
- for (ProfileData profileData : mServiceData.getProfileDataList()) {
- View view = createProfileView(profileData);
- profileLayout.addView(view);
- }
- }
-
- /**
- * プロファイル選択画面を開きます.
- */
- private void openProfileActivity() {
- ArrayList list = new ArrayList<>();
- for (ProfileData p : mServiceData.getProfileDataList()) {
- list.add(p);
- }
- Intent intent = new Intent();
- intent.setClass(this, FaBoProfileListActivity.class);
- intent.putParcelableArrayListExtra("profile", list);
- intent.putIntegerArrayListExtra("pins", new ArrayList<>(getUsePins()));
- startActivityForResult(intent, REQUEST_CODE_ADD_PROFILE);
- }
-
- /**
- * プロファイルを表示するためのViewを作成します.
- *
- * @param profileData プロファイルデータ
- * @return プロファイルを表示するためのView
- */
- private View createProfileView(final ProfileData profileData) {
- LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View view = inflater.inflate(R.layout.item_fabo_profile_a, null);
- if (profileData.getType().getValue() < 100) {
- view.setOnClickListener((v) -> {
- openPinActivity(profileData);
- });
- }
- TextView nameTV = view.findViewById(R.id.item_fabo_profile_name);
- nameTV.setText(ProfileDataUtil.getProfileName(this, profileData.getType()));
-
- TextView pinsTV = view. findViewById(R.id.item_fabo_profile_pins);
- pinsTV.setText(createPinInfo(profileData));
-
- view.findViewById(R.id.item_fabo_remove_profile_btn).setOnClickListener((v) -> {
- showConfirmRemoveProfile(profileData);
- });
-
- return view;
- }
-
- /**
- * 使用しているピンの一覧を文字列にして取得します.
- * @param profileData プロファイル
- * @return ピンの一覧の文字列
- */
- private String createPinInfo(ProfileData profileData) {
- StringBuilder sb = new StringBuilder();
- for (Integer i : profileData.getPinList()) {
- if (sb.length() > 0) {
- sb.append(",");
- }
- FaBoShield.Pin pin = FaBoShield.Pin.getPin(i);
- if (pin != null) {
- sb.append(pin.getPinNames()[1]);
- }
- }
- return getString(R.string.activity_fabo_virtual_service_profile_pins, sb.toString());
- }
-
- /**
- * ピンの設定画面を開きます.
- *
- * @param profileData 設定画面
- */
- private void openPinActivity(final ProfileData profileData) {
- Intent intent = new Intent();
- intent.setClass(this, FaBoPinListActivity.class);
- intent.putExtra("profile", profileData);
- intent.putIntegerArrayListExtra("pins", new ArrayList<>(getUsePins()));
- startActivityForResult(intent, REQUEST_CODE_UPDATE_PROFILE);
- }
-
- /**
- * 仮想サービスで使用されているピンの一覧を取得します.
- * @return ピンの一覧
- */
- private List getUsePins() {
- return mServiceData.getUsePins();
- }
-
- /**
- * FaBoDeviceServiceと接続できていない場合のエラーダイアログを表示します.
- */
- private void showNotConnectServiceError() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_fabo_virtual_service_error_title)
- .setMessage(R.string.activity_fabo_virtual_service_not_bind)
- .setPositiveButton(R.string.activity_fabo_virtual_service_error_ok, null)
- .show();
- }
-
- /**
- * サービス名が登録されていない場合のエラーダイアログを表示します.
- */
- private void showNoNameError() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_fabo_virtual_service_error_title)
- .setMessage(R.string.activity_fabo_virtual_service_no_name)
- .setPositiveButton(R.string.activity_fabo_virtual_service_error_ok, null)
- .show();
- }
-
- /**
- * 文字数が長すぎる場合のエラーダイアログを表示します.
- */
- private void showTooLong() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_fabo_virtual_service_error_title)
- .setMessage(R.string.activity_fabo_virtual_service_name_too_long)
- .setPositiveButton(R.string.activity_fabo_virtual_service_error_ok, null)
- .show();
- }
-
- /**
- * プロファイルが登録されていない場合のエラーダイアログを表示します.
- */
- private void showNoProfileError() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_fabo_virtual_service_error_title)
- .setMessage(R.string.activity_fabo_virtual_service_no_select_message)
- .setPositiveButton(R.string.activity_fabo_virtual_service_error_ok, null)
- .show();
- }
-
- /**
- * ServiceDataの保存完了ダイアログを表示します.
- */
- private void showSaveServiceData() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_fabo_virtual_service_dialog_title)
- .setMessage(R.string.activity_fabo_virtual_service_save_message)
- .setPositiveButton(R.string.activity_fabo_virtual_service_error_ok,
- (dialogInterface, i) -> {
- finish();
- })
- .show();
- }
-
- /**
- * プロファイル削除確認ダイアログを表示します.
- * @param profileData 削除確認を行うプロファイルデータ
- */
- private void showConfirmRemoveProfile(final ProfileData profileData) {
- String name = ProfileDataUtil.getProfileName(this, profileData.getType());
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_fabo_virtual_service_remove_profile_title)
- .setMessage(getString(R.string.activity_fabo_virtual_service_remove_profile_message, name))
- .setPositiveButton(R.string.activity_fabo_virtual_service_error_ok,
- (dialogInterface, i) -> {
- mServiceData.removeProfileData(profileData);
- resetProfileLayout();
- })
- .setNegativeButton(R.string.activity_fabo_virtual_service_error_no, null)
- .show();
- }
-
- /**
- * ServiceDataの保存に失敗した場合のエラーダイアログを表示します.
- */
- private void showSaveServiceDataError() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_fabo_virtual_service_remove_profile_title)
- .setMessage(getString(R.string.activity_fabo_virtual_service_remove_error_message))
- .setPositiveButton(R.string.activity_fabo_virtual_service_error_ok, null)
- .show();
- }
-
- /**
- * 仮想サービスを保存します.
- */
- private void saveVirtualService() {
- if (mFaBoDeviceService == null) {
- showNotConnectServiceError();
- return;
- }
-
- EditText nameET = (EditText) findViewById(R.id.activity_fabo_service_name);
- String serviceName = nameET.getText().toString();
- if (serviceName.isEmpty()) {
- showNoNameError();
- } else if (serviceName.length() > 32) {
- showTooLong();
- } else if (mServiceData.getProfileDataList().isEmpty()) {
- showNoProfileError();
- } else {
- mServiceData.setName(serviceName);
-
- VirtualService service;
- if (mNewCreateFlag) {
- service = mFaBoDeviceService.addServiceData(mServiceData);
- } else {
- service = mFaBoDeviceService.updateServiceData(mServiceData);
- }
-
- if (service != null) {
- showSaveServiceData();
- } else {
- showSaveServiceDataError();
- }
- }
- }
-
- private ServiceConnection mConnection = new ServiceConnection() {
- @Override
- public void onServiceConnected(final ComponentName name, final IBinder service) {
- mFaBoDeviceService = (FaBoDeviceService) ((DConnectMessageService.LocalBinder) service).getMessageService();
- mIsBound = true;
- }
-
- @Override
- public void onServiceDisconnected(final ComponentName name) {
- mFaBoDeviceService = null;
- mIsBound = false;
- }
- };
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/Util.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/Util.java
deleted file mode 100644
index 04039f11b2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/Util.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.setting;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-
-import org.deviceconnect.android.message.DConnectMessageService;
-import org.deviceconnect.android.message.DConnectMessageServiceProvider;
-
-import java.lang.reflect.Method;
-
-final class Util {
- private Util() {
- }
-
- /**
- * デバイスプラグインに格納されるメタタグ名.
- */
- private static final String PLUGIN_META_DATA = "org.deviceconnect.android.deviceplugin";
-
- /**
- * DConnectMessageServiceのClassを取得します.
- *
- * Classが見つからなかった場合にはnullを返却します。
- *
- * @param context コンテキスト
- * @return DConnectMessageServiceのClass
- */
- static Class extends DConnectMessageService> getDConnectMessageServiceClass(final Context context) {
- PackageManager pm = context.getPackageManager();
- try {
- PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_RECEIVERS);
- ActivityInfo[] receivers = packageInfo.receivers;
- if (receivers != null) {
- for (ActivityInfo receiver : receivers) {
- String packageName = receiver.packageName;
- String className = receiver.name;
-
- ComponentName component = new ComponentName(packageName, className);
- ActivityInfo receiverInfo = pm.getReceiverInfo(component, PackageManager.GET_META_DATA);
- if (receiverInfo.metaData != null) {
- Object value = receiverInfo.metaData.get(PLUGIN_META_DATA);
- if (value != null) {
- try {
- Class> clazz = context.getClassLoader().loadClass(className);
- DConnectMessageServiceProvider obj = (DConnectMessageServiceProvider) clazz.newInstance();
- Method method = clazz.getDeclaredMethod("getServiceClass");
- method.setAccessible(true);
- return (Class extends DConnectMessageService>) method.invoke(obj);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
- } catch (PackageManager.NameNotFoundException e) {
- e.printStackTrace();
- }
-
- return null;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoBasePinFragment.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoBasePinFragment.java
deleted file mode 100644
index 1d40fea60a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoBasePinFragment.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.setting.fragment;
-
-import android.app.Fragment;
-
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileData;
-import org.deviceconnect.android.deviceplugin.fabo.service.virtual.db.ProfileDataUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * ピンを選択するための画面を作成するための基底フラグメント.
- */
-public abstract class FaBoBasePinFragment extends Fragment {
-
- /**
- * 使用できるピンのリストを取得します.
- *
- * @return ピンのリスト
- */
- List getCanUsePinList() {
- List names = new ArrayList<>();
- for (FaBoShield.Pin pin : FaBoShield.Pin.values()) {
- if (checkCanUsePin(pin)) {
- names.add(pin);
- }
- }
- return names;
- }
-
- /**
- * 指定されたピンが使用できるか確認します.
- * @param pin 確認するピン
- * @return 使用できる場合はtrue、それ以外はfalse
- */
- private boolean checkCanUsePin(final FaBoShield.Pin pin) {
- ProfileDataUtil.PinType type = getPinType();
- if (type == ProfileDataUtil.PinType.ANALOG && pin.getPinNumber() > FaBoShield.PIN_NO_D13) {
- return true;
- } else if (type == ProfileDataUtil.PinType.DIGITAL && pin.getPinNumber() <= FaBoShield.PIN_NO_D13) {
- return true;
- }
- return type == ProfileDataUtil.PinType.ALL;
- }
-
- /**
- * 使用できるピンのタイプを取得します.
- *
- * @return ピンのタイプ
- */
- private ProfileDataUtil.PinType getPinType() {
- ProfileData p = getActivity().getIntent().getParcelableExtra("profile");
- return ProfileDataUtil.getPinType(p);
- }
-
-
- /**
- * 指定されたピンがmProfileDataに含まれているか確認します.
- * @param pin ピン
- * @return 含まれている場合はtrue、それ以外はfalse
- */
- protected boolean containsPin(final int pin) {
- ProfileData profileData = getActivity().getIntent().getParcelableExtra("profile");
- if (profileData == null) {
- return false;
- }
- for (int pinNum : profileData.getPinList()) {
- if (pin == pinNum) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * 指定されたピンが使用されているかを確認します.
- * @param pin 使用されているか確認をするピン
- * @return 使用されている場合はtrue、それ以外はfalse
- */
- protected boolean usedPin(final int pin) {
- if (containsPin(pin)) {
- return false;
- }
- ArrayList pins = getActivity().getIntent().getIntegerArrayListExtra("pins");
- for (int p : pins) {
- if (p == pin) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * 選択されているピンのリストを取得します.
- *
- * @return 選択されているピンのリスト
- */
- public abstract List getSelectedPins();
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoPinCheckBoxFragment.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoPinCheckBoxFragment.java
deleted file mode 100644
index c5e1afb611..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoPinCheckBoxFragment.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.setting.fragment;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.CheckBox;
-import android.widget.ListView;
-
-import org.deviceconnect.android.deviceplugin.fabo.core.R;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 使用するピンを複数選択するためのフラグメント.
- */
-public class FaBoPinCheckBoxFragment extends FaBoBasePinFragment {
-
- /**
- * ピン情報を格納するアダプタ.
- *
- * FaBoShield.Pin.getPinNumber()の値を保持します.
- *
- */
- private MultiSelectPinAdapter mPinAdapter;
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_fabo_pin_list, container, false);
-
- mPinAdapter = new MultiSelectPinAdapter();
-
- ListView listView = (ListView) view.findViewById(R.id.activity_fabo_pin_list_view);
- listView.setAdapter(mPinAdapter);
-
- return view;
- }
-
- @Override
- public List getSelectedPins() {
- ArrayList pins = new ArrayList<>();
- for (int i = 0; i < mPinAdapter.getCount(); i++) {
- if (mPinAdapter.mCheckedFlag.get(i)) {
- pins.add(((FaBoShield.Pin) mPinAdapter.getItem(i)).getPinNumber());
- }
- }
- return pins;
- }
-
- /**
- * 複数のピン選択するためのデータを格納するアダプタ.
- */
- private class MultiSelectPinAdapter extends BaseAdapter {
-
- /**
- * 選択状態を保持するリスト.
- */
- private List mCheckedFlag = new ArrayList<>();
-
- /**
- * ピンのリスト.
- */
- private List mPinList;
-
- /**
- * コンストラクタ.
- */
- MultiSelectPinAdapter() {
- mPinList = getCanUsePinList();
- for (int i = 0; i < getCount(); i++) {
- mCheckedFlag.add(containsPin(i));
- }
- }
-
- @Override
- public int getCount() {
- return mPinList.size();
- }
-
- @Override
- public Object getItem(final int position) {
- return mPinList.get(position);
- }
-
- @Override
- public long getItemId(final int id) {
- return id;
- }
-
- @Override
- public View getView(final int position, View convertView, final ViewGroup parent) {
- if (convertView == null) {
- LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.item_fabo_check_box_pin, null);
- }
-
- FaBoShield.Pin pin = (FaBoShield.Pin) getItem(position);
-
- CheckBox checkBox = convertView.findViewById(R.id.item_fabo_check_box_pin);
- checkBox.setText(pin.getPinNames()[1]);
- checkBox.setChecked(mCheckedFlag.get(position));
- checkBox.setEnabled(!usedPin(pin.getPinNumber()));
- // CheckBox#setOnCheckedChangeListenerを使用するとListViewで
- // スクロールした時点でヘックが外れてしまう。
- // ここでは、その問題を回避するためにOnClickListenerを使用します。
- checkBox.setOnClickListener((view) -> {
- boolean isChecked = ((CheckBox) view).isChecked();
- mCheckedFlag.set(position, isChecked);
- });
-
- return convertView;
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoPinRadioGroupFragment.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoPinRadioGroupFragment.java
deleted file mode 100644
index 6583480459..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoPinRadioGroupFragment.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.setting.fragment;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.CompoundButton;
-import android.widget.LinearLayout;
-import android.widget.RadioButton;
-import android.widget.RadioGroup;
-
-import org.deviceconnect.android.deviceplugin.fabo.core.R;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 使用するピンを1つだけ選択するためのフラグメント.
- */
-public class FaBoPinRadioGroupFragment extends FaBoBasePinFragment {
-
- /**
- * 選択されたPin.
- */
- private FaBoShield.Pin mSelectedPin;
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_fabo_pin_group, container, false);
-
- List pins = getCanUsePinList();
-
- RadioGroup group = view.findViewById(R.id.activity_fabo_pin_layout);
- for (FaBoShield.Pin pin : pins) {
- group.addView(createRadioButton(inflater, pin),
- new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.WRAP_CONTENT));
- }
-
- for (FaBoShield.Pin pin : pins) {
- if (containsPin(pin.getPinNumber())) {
- RadioButton radioButton = group.findViewWithTag(pin);
- radioButton.setChecked(true);
- mSelectedPin = pin;
- }
- }
-
- return view;
- }
-
- /**
- * ピンを選択するためのRadioButtonを作成します.
- * @param inflater インフレータ
- * @param pin ピン
- * @return RadioButtonのインスタンス
- */
- private RadioButton createRadioButton(final LayoutInflater inflater,final FaBoShield.Pin pin) {
- RadioButton radio = (RadioButton) inflater.inflate(R.layout.item_fabo_radio_button_pin, null, false);
- radio.setText(pin.getPinNames()[1]);
- radio.setTag(pin);
- radio.setEnabled(!usedPin(pin.getPinNumber()));
- radio.setOnCheckedChangeListener((compoundButton, b) -> {
- if (b) {
- mSelectedPin = pin;
- }
- });
- return radio;
- }
-
- @Override
- public List getSelectedPins() {
- List pins = new ArrayList<>();
- if (mSelectedPin != null) {
- pins.add(mSelectedPin.getPinNumber());
- }
- return pins;
- }
-}
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/profile/GPIOProfile.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/profile/GPIOProfile.java
deleted file mode 100644
index 94f0bd5852..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/android/profile/GPIOProfile.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.deviceconnect.android.profile;
-
-
-import android.content.Intent;
-
-import org.deviceconnect.profile.GPIOProfileConstants;
-
-public class GPIOProfile extends DConnectProfile implements GPIOProfileConstants {
-
- @Override
- public String getProfileName() {
- return PROFILE_NAME;
- }
-
- public static void setValue(final Intent message, final int value) {
- message.putExtra(PARAM_VALUE, value);
- }
-
- public static void setMessage(final Intent message, final String msg) {
- message.putExtra(PARAM_MSG, msg);
- }
-
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/profile/GPIOProfileConstants.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/profile/GPIOProfileConstants.java
deleted file mode 100644
index 3baee418fb..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/java/org/deviceconnect/profile/GPIOProfileConstants.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.deviceconnect.profile;
-
-
-public interface GPIOProfileConstants extends DConnectProfileConstants {
-
- String PROFILE_NAME = "gpio";
-
- String INTERFACE_EXPORT = "export";
-
- String INTERFACE_DIGITAL = "digital";
-
- String INTERFACE_ANALOG = "analog";
-
- String ATTRIBUTE_ON_CHANGE = "onChange";
-
- String PARAM_VALUE = "value";
-
- String PARAM_MSG = "msg";
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/decelerate_quint.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/decelerate_quint.xml
deleted file mode 100755
index 77eea6afdb..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/decelerate_quint.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/fragment_slide_left_enter.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/fragment_slide_left_enter.xml
deleted file mode 100755
index 7dea4c493a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/fragment_slide_left_enter.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/fragment_slide_left_exit.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/fragment_slide_left_exit.xml
deleted file mode 100755
index c317df2959..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/fragment_slide_left_exit.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/fragment_slide_right_enter.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/fragment_slide_right_enter.xml
deleted file mode 100755
index c04b58390e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/fragment_slide_right_enter.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/fragment_slide_right_exit.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/fragment_slide_right_exit.xml
deleted file mode 100755
index f9ab739bf9..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/anim/fragment_slide_right_exit.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-hdpi/dconnect_icon.png b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-hdpi/dconnect_icon.png
deleted file mode 100644
index 35a40d9e4c..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-hdpi/dconnect_icon.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-mdpi/dconnect_icon.png b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-mdpi/dconnect_icon.png
deleted file mode 100644
index 871b14f757..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-mdpi/dconnect_icon.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-xhdpi/dconnect_icon.png b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-xhdpi/dconnect_icon.png
deleted file mode 100644
index 54775953e0..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-xhdpi/dconnect_icon.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-xxhdpi/dconnect_icon.png b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-xxhdpi/dconnect_icon.png
deleted file mode 100644
index b342dc3a3c..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-xxhdpi/dconnect_icon.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-xxhdpi/fabo_arrow.png b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-xxhdpi/fabo_arrow.png
deleted file mode 100644
index 7ba2cd2de3..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable-xxhdpi/fabo_arrow.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/button_blue.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/button_blue.xml
deleted file mode 100644
index b4510ed970..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/button_blue.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
- -
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/button_blue_circle.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/button_blue_circle.xml
deleted file mode 100644
index fe9fbc5df3..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/button_blue_circle.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/button_blue_text.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/button_blue_text.xml
deleted file mode 100644
index 54e4d7945d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/button_blue_text.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/button_red.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/button_red.xml
deleted file mode 100644
index 53c16e2caf..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/button_red.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
- -
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/divider.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/divider.xml
deleted file mode 100644
index 067273ee7c..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/drawable/divider.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/activity_fabo_pin_list.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/activity_fabo_pin_list.xml
deleted file mode 100644
index 166fc37a1e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/activity_fabo_pin_list.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/activity_fabo_profile_list.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/activity_fabo_profile_list.xml
deleted file mode 100644
index 2fb7845a09..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/activity_fabo_profile_list.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/activity_fabo_virtual_service.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/activity_fabo_virtual_service.xml
deleted file mode 100644
index d32721ef25..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/activity_fabo_virtual_service.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/fragment_fabo_pin_group.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/fragment_fabo_pin_group.xml
deleted file mode 100644
index b0e9049fee..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/fragment_fabo_pin_group.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/fragment_fabo_pin_list.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/fragment_fabo_pin_list.xml
deleted file mode 100644
index 73de10f4c0..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/fragment_fabo_pin_list.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/fragment_service_list_remover.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/fragment_service_list_remover.xml
deleted file mode 100644
index d10cce6379..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/fragment_service_list_remover.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/fragment_service_list_viewer.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/fragment_service_list_viewer.xml
deleted file mode 100644
index 1ec1e07100..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/fragment_service_list_viewer.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_check_box_pin.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_check_box_pin.xml
deleted file mode 100644
index c312224942..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_check_box_pin.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_profile.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_profile.xml
deleted file mode 100644
index b4c8cef878..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_profile.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_profile_a.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_profile_a.xml
deleted file mode 100644
index 2ba2aad9c6..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_profile_a.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_radio_button_pin.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_radio_button_pin.xml
deleted file mode 100644
index dee6aec1b9..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_radio_button_pin.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_service_list.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_service_list.xml
deleted file mode 100644
index 55dee6e8d5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/layout/item_fabo_service_list.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/menu/menu_fabo_service_list_viewer.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/menu/menu_fabo_service_list_viewer.xml
deleted file mode 100644
index 717b1d5bdd..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/menu/menu_fabo_service_list_viewer.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-hdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bccce..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-mdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index c133a0cbd3..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index bfa42f0e7b..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index 324e72cdd7..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index aee44e1384..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/raw/standardfirmata_hex b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/raw/standardfirmata_hex
deleted file mode 100644
index 001cd1ce88..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/raw/standardfirmata_hex
+++ /dev/null
@@ -1,764 +0,0 @@
-:100000000C9474000C949C000C949C000C949C0028
-:100010000C949C000C949C000C949C000C949C00F0
-:100020000C949C000C949C000C949C000C949307E2
-:100030000C949C000C949C000C949C000C949C00D0
-:100040000C9445100C949C000C9485130C94B713DD
-:100050000C949C000C949C000C949C000C949C00B0
-:100060000C94570B0C949C00D906F5061706F50660
-:100070008006F506F505A205F506F506F506F50672
-:10008000F506B904F5068805F506DC05000000084C
-:10009000000201000003040700000000000000004F
-:1000A000010204081020408001020408102001020F
-:1000B00004081020040404040404040402020202DC
-:1000C00002020303030303030000000025002800CD
-:1000D0002B0000000000240027002A001E04750ADF
-:1000E00036103A10E713701411241FBECFEFD8E07A
-:1000F000DEBFCDBF11E0A0E0B1E0E6ECFEE202C061
-:1001000005900D92AC3DB107D9F724E0ACEDB1E01C
-:1001100001C01D92AC3AB207E1F710E0C8EED0E0A2
-:1001200004C02297FE010E94E815CC3DD107C9F713
-:100130000E9480140C9461170C940000833008F026
-:1001400062C0482F440F440F440F485F453108F008
-:1001500044E1582F550F550F550F90E071E054179B
-:10016000E8F42EEF250F2231B0F4E52FF0E0DF01A7
-:10017000A756BD4F2C91223070F4972BEE0FFF1F26
-:10018000E259FD4F21E030E0A72FA62311F420E033
-:1001900030E031832083770F5F5FE1CF81110AC0A8
-:1001A0009C7FF8942BB1892F809582239623892BED
-:1001B0008BB928C08130C9F46923F89425B1892FFF
-:1001C0008F7380958223262F2F73822B85B988B158
-:1001D00062956695669563709295969596959370DF
-:1001E00090959823692B68B90DC09F70F89428B139
-:1001F000892F880F880F809582236923660F660FE9
-:10020000862B88B9789408950F931F93CF93DF932B
-:10021000EB01843180F5082F10E0F801E756FD4F1F
-:1002200090819330A1F0943031F582508231E0F426
-:10023000F801E551FE4F208130E0C901880F991F78
-:10024000820F931F81509E4F0E9430090DC0833052
-:1002500041F09BEF980F923020F097EF980F93307A
-:1002600018F4BE010E944911F801EE0FFF1FE25978
-:10027000FD4FD183C083DF91CF911F910F910895DE
-:10028000CF93C82F863058F54091B3025091B402F5
-:1002900021E030E0082E02C0220F331F0A94E2F75B
-:1002A000672B49F420953095242335233093B402ED
-:1002B0002093B30214C0242B352B3093B402209327
-:1002C000B3028091DC0181110AC08C2F0E942C1195
-:1002D000AC016C2F8BE993E0CF910C94FF0DCF9183
-:1002E0000895DB019A019091DD019C30D0F5409199
-:1002F000DE01682F70E0442369F0E42FF0E0E25261
-:10030000FE4F8081FB01E551FE4F808341504093B9
-:10031000DE0107C0FB01E551FE4F90839F5F909384
-:10032000DD01FB01E551FE4F1A161B067CF4121687
-:10033000130664F4408150E0CA01880F991F840FAE
-:10034000951FAD0181509E4F0C946B08208130E0C9
-:10035000C901880F991F820F931F81509E4F0C94E3
-:10036000E9086EE071E08BE993E00C948E0ECF9378
-:10037000DF93C82FD0E0C551DE4F288130E0C9019E
-:10038000880F991F820F931F81509E4F0E94EF0884
-:1003900088819091DD01891306C0882379F081500E
-:1003A0008093DD010BC0992349F0E091DE01EF5FFE
-:1003B000E093DE01F0E0E252FE4F80838FEF88830E
-:1003C000DF91CF9108951F93CF93DF93162FC82FFE
-:1003D000D0E0FE01EA56FD4F90811923C355DD4F51
-:1003E000411103C09881911741F0412F50E0682FCF
-:1003F0008BE993E00E94180E1883DF91CF911F9133
-:100400000895833020F5282F30E0F901E055FD4FA5
-:100410006083672BE1F0F901EA56FD4F908181116D
-:1004200003C069B16C7F0FC0813049F463B126B15C
-:1004300040E4249F900111246F73622B04C066B1C5
-:100440006C7366956695692341E00C94E301089509
-:100450008091B002882349F069B1809196026823A7
-:100460006C7F40E080E00E94E3018091B10288232C
-:1004700079F063B186B120E4829FC00111246F73CB
-:10048000682B80919702682340E081E00E94E3019D
-:100490008091B202882359F066B16C7366956695B7
-:1004A00080919802682340E082E00C94E301089573
-:1004B000109225028FEF80930A010895AF92BF92A8
-:1004C000DF92EF92FF920F931F93CF93DF9300D0B1
-:1004D000CDB7DEB7D82E5B01E82EF12C8701075689
-:1004E0001D4FF80180818F3709F402C1863049F42D
-:1004F00080912502882329F06630710511F00E9451
-:1005000058024EEF4D0D4231C0F484E0A816B104FC
-:10051000A1F0F701E551FE4F20812C3070F430E05E
-:10052000C901880F991F820F931F81509E4F4A83E4
-:100530000E9495094A818111C3C092EF9D0D9630AA
-:1005400078F461E070E0E2E0AE16B10411F060E032
-:1005500070E0892F4A8399830E94400199814A81E2
-:100560004231D8F4ED2DE695E695E6958D2D877010
-:10057000F0E0EA56FD4F21E030E0082E01C0220FE6
-:100580000A94EAF7A114B10421F48081822B8083BC
-:1005900004C02095808128232083F701EE0FFF1FE0
-:1005A000E259FD4F11821082F2E0AF16B104A1F0C2
-:1005B0003CF4A114B104F9F0AA94AB2851F16FC036
-:1005C000F4E0AF16B10409F448C084F1E6E0AE16D9
-:1005D000B10409F45CC063C0963008F089C04231B0
-:1005E00040F460E08D2D0E94D11160E08D2D0E94BD
-:1005F0000A1282E051C0423108F07AC060E08D2DCD
-:100600000E94D11160E08D2D0E940A12F801108223
-:100610006FC0423108F06CC060E08D2D0E940A125C
-:1006200061E08D2D0E94D11181E036C0F3E0DF162C
-:1006300049F08BEF8D0D823028F087EF8D0D8330E0
-:1006400008F056C061E08D2D0E94D11160E070E08D
-:100650008D2D0E94491183E01FC0423108F048C02F
-:1006600084E0F8018083F701E551FE4F80818F3FE0
-:1006700069F190E09C01220F331F280F391FC90137
-:1006800081509E4F0E949509811132C01FC08EEE8D
-:100690008D0D823068F586E0F801808329C062E222
-:1006A00071E08BE993E00F900F90DF91CF911F9154
-:1006B0000F91FF90EF90DF90BF90AF900C948E0E53
-:1006C0008D2D4A830E94B7014A8137CF4FEF5FEFEC
-:1006D0006FEF7FEF8D2D0F900F90DF91CF911F91D6
-:1006E0000F91FF90EF90DF90BF90AF900C9471014D
-:1006F0000F900F90DF91CF911F910F91FF90EF908E
-:10070000DF90BF90AF900895CF93C0E08EEE8C0F36
-:10071000823028F466E070E08C2F0E945E02CF5F8A
-:10072000C431A1F781E0809325028BED92E0CF9157
-:100730000C943B0A0F931F93CF93DF9381E0809338
-:10074000DC018091250281110E9458021092B002B2
-:10075000109296021092AD021092B102109297027E
-:100760001092AE021092B202109298021092AF0252
-:10077000CBEED1E010E00FEF82EF810F863018F45E
-:1007800062E070E002C061E070E0812F0E945E02D2
-:1007900009931F5F143181F71092B4021092B302D3
-:1007A0001092DE011092DD011092DC01DF91CF91F9
-:1007B0001F910F91089524E042E063E371E08BE91B
-:1007C00093E00E94260D44E051E060EE8BE993E057
-:1007D0000E949C0E4EE950E060E98BE993E00E9494
-:1007E0009C0E40E451E060EC8BE993E00E949C0E8B
-:1007F00041E052E060ED8BE993E00E949C0E4EE5F3
-:1008000052E064EF8BE993E00E949C0E45EA54E0CD
-:1008100060EF8BE993E00E94C70E4AE953E06FEF67
-:100820008BE993E00E94BF0E40E051EE60E070E083
-:100830008BE993E00E941F100C949A03CF93DF93EF
-:10084000CFEFD1E0CE010E944F08239682E0C33261
-:10085000D807C1F7DF91CF910895682F8BED92E013
-:100860000C94FC098BED92E00E94AC090895DF9294
-:10087000EF92FF920F931F93CF93DF93F82EEB012C
-:10088000D42E6F3F8FEF7807A9F06F2D8BED92E09C
-:100890000E94550A8C2F0E942D048BED92E00E943D
-:1008A000720A8091230290912402009729F00E94FD
-:1008B000E61002C0C0E0D0E04D2D6F2D8BED92E030
-:1008C0000E94520A0D2D10E08BED92E00E94A409C7
-:1008D000081719071CF467E471E009C08BED92E07A
-:1008E0000E94A4098017910734F464E671E08BE953
-:1008F00093E00E948E0EF0922602C093270268E2D7
-:10090000E62E62E0F62EC0E0D0E0C017D10784F0FA
-:1009100042E04D0D26E232E067E78BE993E0DF919C
-:10092000CF911F910F91FF90EF90DF900C94460EA6
-:100930008BED92E00E94A409892B51F30E943204AE
-:10094000F70181937F012196E0CFEF92FF920F9301
-:100950001F93CF93DF93162FEA0190E0FC01E95635
-:10096000F109E231F10508F040C2EC5CFF4F0C9454
-:10097000E6158981982F987185FF03C060E871E0C2
-:1009800056C08881983071F148F491112EC2682FB9
-:100990008BED92E00E94550A02E007C0903109F405
-:1009A00040C0983109F471C020C2011768F4FE01FB
-:1009B000E00FF11D9181808120E8929F8019112420
-:1009C0000E942D040E5FF1CF8BED92E00E94720A1F
-:1009D00086E490E0DF91CF911F910F91FF90EF900F
-:1009E0000C94E6104A816B81163069F430E8639FFD
-:1009F000B0011124640F711D9D814C8150E8959FB9
-:100A00004019112406C090E8699F401911246FEF26
-:100A10007FEFDF91CF911F910F91FF90EF900C949A
-:100A20003704E0910A01E73064F060EA71E08BE995
-:100A300093E0DF91CF911F910F91FF90EF900C9475
-:100A40008E0E9A812B81F0E8663061F42F9F900121
-:100A50001124290F311D4D819C8150E8459F90192B
-:100A6000112405C02F9F901911242FEF3FEFEF5F46
-:100A7000E0930A0144E0E402F0011124EA5BFD4F37
-:100A80008083328321839383B0C150910A0115166C
-:100A900034F440E0252F332727FD30950EC08FEF2B
-:100AA00080930A01A2C1EE0FFF1FEE0FFF1FEA5B4A
-:100AB000FD4F9081981719F14F5FE42FF0E02E174A
-:100AC0003F078CF740E01BC04830C0F4DF01AA0F9D
-:100AD000BB1FAA0FBB1FA65BBD4F8C91EE0FFF1F64
-:100AE000EE0FFF1FEA5BFD4F808311968D919C9165
-:100AF00012979283818313968C9183834F5FE42FA7
-:100B0000F0E02E173F0704F7515050930A016DC1D2
-:100B10002881898150E8859FC0011124820F911D91
-:100B2000009721F090932402809323028091250264
-:100B300081115BC1DF91CF911F910F91FF90EF90D9
-:100B40000C948403653008F450C118810981FA803F
-:100B5000EB80CC818EEF810F823108F046C1E12F0E
-:100B6000F0E0E551FE4FE081EC3060F4F0E0CF01C1
-:100B7000880F991F8E0F9F1F81509E4F0E949509CD
-:100B800081112FC180E8C89FA00111244E0D511D75
-:100B900090E8F99EB0011124600F711D812F0E9411
-:100BA000710164E070E0812FDF91CF911F910F916F
-:100BB000FF90EF900C945E02623008F416C1288119
-:100BC0008981E0E88E9FC0011124820F911D9093CE
-:100BD0000C0180930B010A9708F007C18AE090E0AE
-:100BE00090930C0180930B0100C1623008F4FDC0AA
-:100BF000698170E0123091F08A81F0E88F9FC00126
-:100C00001124682B792B133049F08B8190E090E40C
-:100C1000899F902D88271124682B792B8881DF915B
-:100C2000CF911F910F91FF90EF900C94040160EF12
-:100C30008BE993E00E94920E6CE68BE993E00E94B0
-:100C4000920ECEEF84EF8C0F863058F462E08BE981
-:100C500093E00E94920E6AE08BE993E00E94920E6C
-:100C60000DC0C13059F463E08BE993E00E94920E0D
-:100C700068E08BE993E00E94920E08C08DEF8C0F24
-:100C8000823088F389EF8C0F833068F3C23150F4DF
-:100C900064E08BE993E00E94920E6EE08BE993E0B2
-:100CA0000E94920E80EF8C0F823050F466E08BE948
-:100CB00093E00E94920E61E08BE993E00E94920E15
-:100CC0006FE78BE993E00E94920ECF5FC23169F12A
-:100CD000C23108F0B7CF60E08BE993E00E94920E3A
-:100CE00061E08BE993E00E94920E61E08BE993E072
-:100CF0000E94920E61E08BE993E00E94920EA2CFD7
-:100D0000662309F472C0C88160EF8BE993E00E940A
-:100D1000920E6EE68BE993E00E94920E6C2F8BE9A7
-:100D200093E00E94920EC43158F067EF8BE993E094
-:100D3000DF91CF911F910F91FF90EF900C94920E45
-:100D4000D0E0FE01E756FD4F60818BE993E00E9401
-:100D5000920ECC0FDD1F8E0102591D4FF8016081EC
-:100D60006F778BE993E00E94920EF80160817181A8
-:100D7000CB018078892B49F0660F672F661F770BB0
-:100D80006F778BE993E00E94920EC259DD4F688124
-:100D90007981CB018827907C892B39F2770F660BFC
-:100DA000770F762F661F6F778BE993E00E94920E84
-:100DB000BCCF60EF8BE993E00E94920E6AE68BE96C
-:100DC00093E00E94920EC2EFC63010F06FE701C0B0
-:100DD0006C2F8BE993E00E94920ECF5FC630A1F793
-:100DE000A4CF812F0E94B701CDCEDF91CF911F916B
-:100DF0000F91FF90EF9008958F929F92AF92BF92C4
-:100E0000CF92DF92EF92FF920F931F93CF93DF93D6
-:100E10000E9428028BE993E00E94860D892B29F01D
-:100E20008BE993E00E94F20EF5CF0E948F10609341
-:100E30006A0270936B0280936C0290936D02C09073
-:100E40006602D0906702E0906802F09069024091DB
-:100E50000B0150910C014A01A12CB12C8B019C017A
-:100E60000C191D092E093F0980169106A206B3062A
-:100E700008F04CC0D501C4018C0D9D1DAE1DBF1DD9
-:100E80008093660290936702A0936802B093690210
-:100E9000C9E9D2E012EF1630C0F488818230A9F49B
-:100EA0002091B3023091B402012E02C035952795EE
-:100EB0000A94E2F720FF09C0812F0E942C11AC0197
-:100EC000612F8BE993E00E94FF0D1F5F2196163082
-:100ED00011F780910A0187FD19C0C0E0EC2FF0E006
-:100EE00080910A01992787FD90958E179F0774F0CE
-:100EF000EE0FFF1FEE0FFF1FEA5BFD4F6181728156
-:100F0000438180810E943704CF5FE8CFDF91CF918A
-:100F10001F910F91FF90EF90DF90CF90BF90AF9017
-:100F20009F908F9008951F920F920FB60F921124E9
-:100F30002F933F934F935F936F937F938F939F93E1
-:100F4000AF93BF93EF93FF938091B60287FF05C0E5
-:100F500010928500109284001AC02091B6023327A7
-:100F600027FD30958091B50290E0281739077CF471
-:100F70008091B602992787FD9095FC01EE0FFF1F27
-:100F8000E80FF91FE954FD4F808186FD15C080915F
-:100F9000B6028F5F8093B6022091B602332727FDF9
-:100FA00030958091B50290E028173907BCF4809104
-:100FB000B6028C305CF112C08091B602992787FD91
-:100FC0009095FC01EE0FFF1FE80FF91FE954FD4F4C
-:100FD000808160E08F730E940A12D9CF80918400D3
-:100FE00090918500049680349C4918F480E49CE933
-:100FF00005C08091840090918500049690938900AB
-:10100000809388008FEF8093B60238C020918400CF
-:10101000309185008091B602992787FD9095FC015B
-:10102000EE0FFF1FE80FF91FE954FD4F81819281F8
-:10103000820F931F90938900809388008091B6025D
-:10104000992787FD9095FC01EE0FFF1FE80FF91F10
-:10105000E954FD4F808186FF11C08091B602992727
-:1010600087FD9095FC01EE0FFF1FE80FF91FE95473
-:10107000FD4F808161E08F730E940A12FF91EF9112
-:10108000BF91AF919F918F917F916F915F914F91A0
-:101090003F912F910F900FBE0F901F9018952091A8
-:1010A000B5022C30A0F431E0320F3093B502FC01D0
-:1010B0002083822F90E0FC01EE0FFF1FE80FF91F45
-:1010C000E954FD4F88EB9BE09283818308952FEFD5
-:1010D000FC0120830895DF92EF92FF920F931F93FC
-:1010E000CF93DF93EC01D62E7A01890188818C3071
-:1010F00008F066C061E08D2D0E94D1118881A82F73
-:10110000B0E0FD01EE0FFF1FEA0FFB1FE954FD4F9A
-:101110002D2D2F739081907C922B908360E272E052
-:101120006E197F0977FF02C06D5F7F4F75956795D8
-:1011300075956795698340E659E0401B510B57FF51
-:1011400002C04D5F5F4F55954795559547954A832A
-:101150006CE00E9499159CE0899FB001112420E069
-:1011600030E0A901460F571FFA01EE0FFF1FE40FF1
-:10117000F51FE954FD4F908196FD16C02F5F3F4F3C
-:101180002C30310571F781110FC01092800082E080
-:10119000809381001092850010928400B19A809112
-:1011A0006F00826080936F00888190E0FC01EE0FF9
-:1011B000FF1FE80FF91FE954FD4F80818064808391
-:1011C0008881DF91CF911F910F91FF90EF90DF9079
-:1011D000089520E639E040E252E00C946B08FC01EF
-:1011E000808190E0FC01EE0FFF1FE80FF91FE9542A
-:1011F000FD4F80818F7B80830895FC0180818C303E
-:1012000070F5918128E830E0291B310997FD33956D
-:10121000220F331F220F331F621773077CF0928156
-:1012200028E532E0291B310997FD3395220F331F42
-:10123000220F331F621773070CF49B0122503109F0
-:10124000220F331F4FB7F89490E0FC01EE0FFF1F01
-:10125000E80FF91FE954FD4F328321834FBF0895F2
-:101260004F925F926F927F92AF92BF92CF92DF9236
-:10127000EF92FF920F931F93CF93DF93EC016032B5
-:1012800082E078070CF040C077FD06C0653B710531
-:101290002CF064EB70E002C060E070E0898128E827
-:1012A00030E0281B310987FD3395220F331F220FB1
-:1012B000331F5901CC24B7FCC094DC2C882777FD60
-:1012C0008095982F2A8148E552E0421B510927FD5D
-:1012D0005395440F551F440F551F2A01662457FC90
-:1012E0006094762C7F926F925F924F9214EBE12E76
-:1012F000F12C00E010E020E030E0A9010E9441154F
-:101300000F900F900F900F90CE01DF91CF911F9112
-:101310000F91FF90EF90DF90CF90BF90AF907F90B4
-:101320006F905F904F900C94FD08FC01808190E0DD
-:10133000FC01EE0FFF1FE80FF91FE954FD4F8081FC
-:1013400086FB882780F9089580910B0390E0209117
-:101350000C03821B9109089520910C0380910B03CB
-:10136000281750F4E22FF0E0E35FFC4F808190E01B
-:101370002F5F20930C0308958FEF9FEF0895E09166
-:101380000C0380910B03E81730F4F0E0E35FFC4FAF
-:10139000808190E008958FEF9FEF08950895CF9298
-:1013A000DF92EF92FF920F931F93CF93DF937C0115
-:1013B000CB018A012091E702222389F0EB016B0126
-:1013C000C40ED51ECC15DD0569F06991D701ED91EC
-:1013D000FC910190F081E02DC7010995F3CF642FB6
-:1013E0000E942E0BC801DF91CF911F910F91FF90AA
-:1013F000EF90DF90CF900895CF93DF931F92CDB7FA
-:10140000DEB769832091E7022223D1F02091E80220
-:10141000203240F021E030E0FC013383228380E081
-:1014200090E015C08091E902E82FF0E0E651FD4F11
-:10143000998190838F5F8093E9028093E80205C0D1
-:1014400061E0CE0101960E942E0B81E090E00F90AA
-:10145000DF91CF910895FC011382128248EE53E090
-:1014600060E070E0448355836683778385EB91E089
-:1014700091838083089510920C0310920B031092B5
-:10148000E9021092E8020C94790A862F413208F0A2
-:1014900040E26DE073E00E94970A10920C03809383
-:1014A0000B03089521E00C94450A81E08093E70244
-:1014B00060930A031092E9021092E80208950F93D4
-:1014C000062F21E04091E8026AEE72E080910A0363
-:1014D0000E94DB0A1092E9021092E8021092E702E1
-:1014E0000F91089561E00C945F0A8BED92E00C94EB
-:1014F0002B0A10929A0381E080939803109297032D
-:1015000061E082E10E940A1261E083E10E940A1216
-:10151000E9EBF0E080818E7F808380818D7F808306
-:1015200088E48093B80085E48093BC00089541323C
-:1015300008F03FC090919A039111FCCF91E09093F5
-:101540009A03209398032FEF20932D031092720398
-:10155000240F209371039093990390919903880F1E
-:10156000892B8093990380919703813041F41092E5
-:101570009703809199038093BB0085EC01C085EEB1
-:101580008093BC0080919A038130E1F380917203D3
-:10159000841710F44091720323E733E0FB01D90173
-:1015A0008A2F821B841718F48D918193F9CF842F91
-:1015B000089580E008950F93413208F046C090915D
-:1015C0009A039111FCCF92E090939A0300939803B1
-:1015D0009FEF90932D031092720340937103FB01D0
-:1015E00063E773E0DB019A2F961B941718F491912F
-:1015F0009D93F9CF1092990390919903880F892BAD
-:101600008093990380919703813041F4109297035E
-:10161000809199038093BB0085EC01C085EE809397
-:10162000BC00222321F080919A038230E1F3809163
-:101630002D038F3F61F080912D03803251F0809116
-:101640002D03803341F483E007C081E005C080E0D2
-:1016500003C082E001C084E00F910895613298F4E4
-:1016600020919A03243089F460934F03FC0181E5B3
-:1016700093E0DC012A2F281B261718F421912D93C3
-:10168000F9CF80E0089581E0089582E0089585ED26
-:101690008093BC008091BC0084FDFCCF10929A0323
-:1016A000089585EC8093BC0010929A0308951F92D0
-:1016B0000F920FB60F9211242F933F934F935F9386
-:1016C0006F937F938F939F93AF93BF93EF93FF930A
-:1016D0008091B900887F803609F49CC068F5883213
-:1016E00009F45BC090F4803109F454C038F48823C5
-:1016F00009F4F5C0883009F44DC0F5C0883109F40B
-:101700004CC0803209F45DC0EEC0803409F468C07A
-:1017100048F4803309F455C0883309F0E4C080935D
-:101720002D03A8C0803509F44FC0883509F45DC089
-:10173000883409F0D8C0D5C0883909F4C6C0A8F4E7
-:10174000883709F467C038F4883609F463C08037F5
-:1017500009F460C0C8C0883809F4B7C0803909F4FA
-:101760005FC0803809F0BFC05BC0803B09F485C012
-:1017700038F4803A09F466C0883A09F47EC0B3C0F0
-:10178000803C09F4A6C0883C09F4A3C0883B09F456
-:1017900089C0A9C08091990310C090917203809173
-:1017A0007103981770F5E091720381E08E0F8093BA
-:1017B0007203F0E0ED58FC4F80818093BB0085EC14
-:1017C00085C080932D038DC0E091720381E08E0F60
-:1017D000809372038091BB00F0E0ED58FC4F808352
-:1017E00090917203809171036DC0E091720381E06A
-:1017F0008E0F809372038091BB00F0E0ED58FC4F98
-:1018000080838091980381116CC081E0809397035D
-:1018100084EA60C083E080939A0310922E03CFCFB6
-:1018200080912E03803208F050C0E0912E0381E0B9
-:101830008E0F80932E038091BB00F0E0E15DFC4FA2
-:101840008083BDCF80912E03803230F4E0912E034F
-:10185000F0E0E15DFC4F10820E94470B60912E0387
-:1018600070E0E0919303F09194038FE293E0099587
-:1018700010922E030E94510B36C084E080939A038D
-:101880001092500310924F03E0919503F09196034C
-:10189000099580914F03811105C081E080934F032A
-:1018A00010925103E091500381E08E0F809350031A
-:1018B000F0E0EF5AFC4F80818093BB009091500381
-:1018C00080914F03981708F47ACF85E88093BC0085
-:1018D0000AC085EC8093BC0010929A0304C0109259
-:1018E0002D030E94470BFF91EF91BF91AF919F9104
-:1018F0008F917F916F915F914F913F912F910F90B9
-:101900000FBE0F901F9018950F931F93CF93DF93E7
-:10191000EC018B0188819981DC01ED91FC916F775D
-:101920000190F081E02D099588819981DC01ED918C
-:10193000FC91B801660F672F661F770B6F770190D8
-:10194000F081E02DDF91CF911F910F910994DC017F
-:101950008D919C91DC01ED91FC910190F081E02D45
-:1019600060EF0994DC018D919C91DC01ED91FC917B
-:101970000190F081E02D67EF0994CF93DF93EC01A4
-:1019800088819981DC01ED91FC910190F081E02D3D
-:1019900069EF099588819981DC01ED91FC910190B5
-:1019A000F081E02D62E0099588819981DC01ED915B
-:1019B000FC910190F081E02D64E0DF91CF910994DA
-:1019C0001F93CF93DF93EC018A818823D9F1CE0155
-:1019D0000E94A70C88819981DC01ED91FC91019016
-:1019E000F081E02D69E7099588819981DC01ED910D
-:1019F000FC91AB81BC810190F081E02D6C91099547
-:101A000088819981DC01ED91FC91AB81BC810190D1
-:101A1000F081E02D11966C91099512E08A811817DA
-:101A200058F4EB81FC81E10FF11D608170E0CE0183
-:101A30000E94840C1F5FF2CFCE01DF91CF911F91E6
-:101A40000C94B20CDF91CF911F910895CF92DF9249
-:101A5000EF92FF920F931F93CF93DF938C01EB01D3
-:101A6000C42ED22E61EC71E0CE010E9447177C019A
-:101A70006FE270E0CE010E943C17009739F46CE5EC
-:101A800070E0CE010E943C17009711F0EC01219606
-:101A9000E114F10451F4FE0101900020E9F7EC1B80
-:101AA000EF5FD8011296EC9306C0EC1AFD0AE3949E
-:101AB000E394F801E282D80113968D919C911497DA
-:101AC0000E949E16F801E280F12CC70101960E9447
-:101AD0000616D80114969C938E931397FC01EE0D75
-:101AE000FF1D1082FC01C082D18212964C9150E001
-:101AF00042505109BE010296DF91CF911F910F9183
-:101B0000FF90EF90DF90CF900C942D17DC018D911A
-:101B10009C91DC01ED91FC910480F581E02D09940C
-:101B20000F931F93CF93DF93FC012085213749F05A
-:101B3000293709F049C0DF91CF911F910F910C9483
-:101B4000E00CFC01E95AFF4F0190F081E02D309745
-:101B500009F450C0DC01A75BBF4F4D915C919A0125
-:101B60002150310937FD9A01B90175956795062F06
-:101B700040E050E020E030E04E5F5F4F2017A0F4DF
-:101B8000EC01C40FD51F1F81DC01A20FB31F1896F3
-:101B90001C931897C885D0E8CD9F1019112418966A
-:101BA0001C932F5F3F4FE8CFDC01A60FB11D1796A6
-:101BB0002C911797222311F018961C920896DF910A
-:101BC000CF911F910F910994FC01E75AFF4F0190AB
-:101BD000F081E02D309771F0AC01475F5F4FDC0181
-:101BE000A75BBF4F6C916150822FDF91CF911F9106
-:101BF0000F910994DF91CF911F910F9108950F9349
-:101C00001F93CF93DF93EC018A0188819981DC01D6
-:101C1000ED91FC916F70606E0190F081E02D09955F
-:101C2000B801CE01DF91CF911F910F910C94840CDC
-:101C30000F931F93CF93DF93EC018A0188819981E1
-:101C4000DC01ED91FC916F7060690190F081E02DF5
-:101C5000099588819981DC01ED91FC91602F6F7766
-:101C60000190F081E02D099588819981DC01ED9149
-:101C7000FC91B801660F672F661F770B0190F0810A
-:101C8000E02DDF91CF911F910F910994CF92DF92B8
-:101C9000EF92FF920F931F93CF93DF9300D01F9289
-:101CA000CDB7DEB78C01F42E2A833B8369830E9473
-:101CB000A70CD8018D919C91DC01ED91FC910190D4
-:101CC000F081E02D698109952A81E22EC22E3B81A7
-:101CD000D32E8C2D8E198F1540F4F60161916F0172
-:101CE00070E0C8010E94840CF4CFC8010F900F90DF
-:101CF0000F90DF91CF911F910F91FF90EF90DF90A8
-:101D0000CF900C94B20C9A01FA0101900020E9F7EF
-:101D10003197E41BF50B4E2F0C94460EAB0161E797
-:101D20000C94830EDC018D919C91DC01ED91FC9172
-:101D30000190F081E02D0994603DB9F028F46039FC
-:101D400061F0603C71F00895603E19F0643F89F0E5
-:101D50000895FC01E55BFF4F0FC0FC01E35BFF4F03
-:101D60000BC0FC01E15BFF4F07C0FC01EF5AFF4FC6
-:101D700003C0FC01ED5AFF4F5183408308956F3F2C
-:101D800029F4FC01EB5AFF4F518340830895875A91
-:101D90009F4FFC01518340830895FC0115821682F8
-:101DA000178280E090E0DF01A80FB91F18961C92FF
-:101DB000019680349105B9F7DF01A85BBF4F1C92F3
-:101DC00011961D921C92EB5AFF4F0190F081E02D6D
-:101DD000309709F009940895FC011282148213824D
-:101DE0000C94CD0ECF93DF93EC0188819981DC01B7
-:101DF000ED91FC910680F781E02D0995FE01E85BED
-:101E0000FF4F20812223B1F0873F910531F41082EA
-:101E1000CE01DF91CF910C94900DFE01E75BFF4F57
-:101E200020813181C20FD31F88872F5F3F4F3183BD
-:101E300020839DC02D81222309F45EC08038910546
-:101E40000CF05AC09FEF920F9D83FE01E90FF11D28
-:101E5000808791118CC08E81882309F488C0803DD1
-:101E6000E9F148F48039E9F0803C09F043C0FE0113
-:101E7000E15BFF4F36C0803E19F0843F19F13AC054
-:101E8000FE01E55BFF4F0190F081E02D309791F16D
-:101E90008885698570E0B0E88B9F600D711D112405
-:101EA00027C0FE01E35BFF4F0190F081E02D3097EA
-:101EB00009F18885698570E090E8899F600D711D42
-:101EC000112416C0FE01ED5AFF4F0190F081E02D64
-:101ED000309781F0688570E089850BC0FE01EF5A6C
-:101EE000FF4F0190F081E02D309721F0688570E080
-:101EF0008F8109951E823BC0803F91052CF4282FCD
-:101F00002F702F83807F9927803E910521F154F413
-:101F1000803C910511F1803D9105F9F080399105E2
-:101F200031F519C0843F9105B1F054F4803F91051B
-:101F3000F1F481E08083C75BDF4F1982188217C0FC
-:101F4000893F910571F08F3F910589F4CE01DF91B2
-:101F5000CF910C94CD0E92E001C091E09D838E83D1
-:101F600006C08BE993E0DF91CF910C94BD0CDF911B
-:101F7000CF9108958F929F92AF92BF92CF92DF92AE
-:101F8000EF92FF921F93CF93DF93EB014A01690118
-:101F900061E08DE00E94D11110E0EE24D7FCE094C6
-:101FA000FE2CAA2497FCA094BA2C812F90E08C17C9
-:101FB0009D0794F4C701B6010E94BE1061E08DE058
-:101FC0000E940A12C501B4010E94BE1060E08DE0BB
-:101FD0000E940A121F5FE9CFDF91CF911F91FF90FE
-:101FE000EF90DF90CF90BF90AF909F908F9008952B
-:101FF000CF93DF93EC0161E08DE00E94D11122EDDF
-:1020000030E048E250E062E070E0CE010E94BA0F9A
-:102010006AEF70E080E090E00E94BE1022ED30E0B8
-:1020200048E250E064E070E0CE010E94BA0F6DE734
-:1020300070E080E090E0DF91CF910C94BE10CF93E0
-:10204000DF93EC0126E085E094E00E94231385E015
-:1020500094E099838883CE010E94F80FCE010E94FC
-:10206000BD0CCE01DF91CF910C94E00C8BE993E095
-:102070000C94EC0E0F9300E020E040E060E086EF6F
-:1020800093E00E9464140F9108951F920F920FB66F
-:102090000F9211242F933F938F939F93AF93BF93EE
-:1020A0008091FD039091FE03A091FF03B091000485
-:1020B0003091FC0323E0230F2D3720F40196A11D5E
-:1020C000B11D05C026E8230F0296A11DB11D209366
-:1020D000FC038093FD039093FE03A093FF03B09352
-:1020E00000048091010490910204A0910304B09136
-:1020F00004040196A11DB11D809301049093020474
-:10210000A0930304B0930404BF91AF919F918F916A
-:102110003F912F910F900FBE0F901F9018952FB7E2
-:10212000F8946091FD037091FE038091FF039091FC
-:1021300000042FBF08953FB7F89480910104909157
-:102140000204A0910304B091040426B5A89B05C025
-:102150002F3F19F00196A11DB11D3FBF6627782FB3
-:10216000892F9A2F620F711D811D911D42E0660F0C
-:10217000771F881F991F4A95D1F70895CF92DF9254
-:10218000EF92FF92CF93DF936B017C010E949B1033
-:10219000EB01C114D104E104F10489F00E94881517
-:1021A0000E949B106C1B7D0B683E734090F381E096
-:1021B000C81AD108E108F108C851DC4FEACFDF9115
-:1021C000CF91FF90EF90DF90CF90089582309105EE
-:1021D00038F0880F991F880F991F05970197F1F71D
-:1021E0000895789484B5826084BD84B5816084BD8F
-:1021F00085B5826085BD85B5816085BDEEE6F0E080
-:10220000808181608083E1E8F0E0108280818260DB
-:102210008083808181608083E0E8F0E0808181605C
-:102220008083E1EBF0E0808184608083E0EBF0E08C
-:10223000808181608083EAE7F0E080818460808330
-:1022400080818260808380818160808380818068DA
-:1022500080831092C10008958E3008F08E508770F0
-:1022600020910D0190E4299F90011124822B8093ED
-:102270007C0080917A00806480937A0080917A005B
-:1022800086FDFCCF809178002091790090E0922B20
-:1022900008951F93CF93DF93182FEB0161E00E9405
-:1022A000D111209711F460E004C0CF3FD10539F47B
-:1022B00061E0812FDF91CF911F910C940A12E12FE1
-:1022C000F0E0E457FF4FE491E330F9F048F4E130F7
-:1022D000B9F0E230A1F584B5806284BDC8BD34C0D8
-:1022E000E730E9F0E83019F1E43049F580918000F9
-:1022F000806280938000D0938B00C0938A0024C0BA
-:1023000084B5806884BDC7BD1FC08091800080688F
-:1023100080938000D0938900C093880015C080917D
-:10232000B00080688093B000C093B3000DC080916E
-:10233000B00080628093B000C093B40005C0C03884
-:10234000D1050CF0B5CFAFCFDF91CF911F9108959C
-:10235000833081F028F4813099F08230A1F0089523
-:102360008730A9F08830B9F08430D1F480918000B2
-:102370008F7D03C0809180008F77809380000895C7
-:1023800084B58F7702C084B58F7D84BD0895809118
-:10239000B0008F7703C08091B0008F7D8093B00034
-:1023A0000895CF93DF9390E0FC01E056FF4F249116
-:1023B000FC01EC54FF4F8491882349F190E0880F91
-:1023C000991FFC01EE52FF4FA591B49188539F4F86
-:1023D000FC01C591D4919FB7611108C0F8948C910C
-:1023E000209582238C93888182230AC0623051F425
-:1023F000F8948C91322F309583238C938881822B93
-:10240000888304C0F8948C91822B8C939FBFDF91BA
-:10241000CF9108950F931F93CF93DF931F92CDB762
-:10242000DEB7282F30E0F901E457FF4F8491F9011E
-:10243000E056FF4F1491F901EC54FF4F0491002333
-:10244000C9F0882321F069830E94A8116981E02FD7
-:10245000F0E0EE0FFF1FE853FF4FA591B4919FB737
-:10246000F8948C91611103C01095812301C0812BD8
-:102470008C939FBF0F90DF91CF911F910F91089583
-:10248000FC01818D228D90E0805C9F4F821B910921
-:102490008F7399270895FC01918D828D981731F0E3
-:1024A000828DE80FF11D858D90E008958FEF9FEFED
-:1024B0000895FC01918D828D981761F0828DDF0166
-:1024C000A80FB11D5D968C91928D9F5F9F73928F27
-:1024D00090E008958FEF9FEF08958DED93E1892BA4
-:1024E00049F080E090E0892B29F00E94DD138111F2
-:1024F0000C9400000895FC01848DDF01A80FB11D2C
-:10250000A35ABF4F2C91848D90E001968F73992729
-:10251000848FA689B7892C93A089B1898C91806416
-:102520008C93938D848D981306C00288F389E02DD7
-:1025300080818F7D80830895CF93DF93EC01888D18
-:102540008823C9F0EA89FB89808185FD05C0A889B7
-:10255000B9898C9186FD0FC00FB607FCF5CF80813D
-:1025600085FFF2CFA889B9898C9185FFEDCFCE0187
-:102570000E947B12E7CFDF91CF910895CF92DF9237
-:10258000FF920F931F93CF93DF931F92CDB7DEB7C8
-:102590006C0181E0D60158968C9358975B969C917C
-:1025A0005B975C968C915C97981307C05096ED9161
-:1025B000FC915197808185FD2EC0F601038D10E0BE
-:1025C0000F5F1F4F0F731127F02EF601848DF81245
-:1025D00011C00FB607FCF9CFD6015096ED91FC91D2
-:1025E0005197808185FFF1CFC60169830E947B12DC
-:1025F0006981EBCF838DE80FF11DE35AFF4F6083B4
-:10260000D6015B960C935B975296ED91FC91539794
-:10261000808180620CC0D6015696ED91FC9157974F
-:1026200060835096ED91FC91519780818064808306
-:1026300081E090E00F90DF91CF911F910F91FF907B
-:10264000DF90CF900895BF92CF92DF92EF92FF92EA
-:10265000CF93DF93EC016A017B01B22EE889F989FF
-:1026600082E08083411581EE580761057105A1F074
-:1026700060E079E08DE390E0A70196010E94A51546
-:1026800021503109410951095695479537952795AC
-:10269000211580E1380798F0E889F989108260E80F
-:1026A00074E88EE190E0A70196010E94A5152150E3
-:1026B0003109410951095695479537952795EC857C
-:1026C000FD853083EE85FF852083188EEC89FD899A
-:1026D000B082EA89FB89808180618083EA89FB89F5
-:1026E000808188608083EA89FB898081806880831B
-:1026F000EA89FB8980818F7D8083DF91CF91FF9074
-:10270000EF90DF90CF90BF9008951F920F920FB679
-:102710000F9211242F938F939F93EF93FF93E09148
-:102720001504F09116048081E0911B04F0911C04C3
-:1027300082FD12C0908180911E048F5F8F73209163
-:102740001F04821751F0E0911E04F0E0EB5FFB4F95
-:10275000958F80931E0401C08081FF91EF919F911E
-:102760008F912F910F900FBE0F901F9018951F9271
-:102770000F920FB60F9211242F933F934F935F93B5
-:102780006F937F938F939F93AF93BF93EF93FF9339
-:1027900085E094E00E947B12FF91EF91BF91AF9191
-:1027A0009F918F917F916F915F914F913F912F9169
-:1027B0000F900FBE0F901F90189585E094E00E9437
-:1027C000401221E0892B09F420E0822F0895109215
-:1027D00008041092070488EE93E0A0E0B0E0809334
-:1027E000090490930A04A0930B04B0930C048AECA0
-:1027F00091E0909306048093050485EC90E090931B
-:1028000012048093110484EC90E09093140480935C
-:10281000130480EC90E0909316048093150481ECEF
-:1028200090E0909318048093170482EC90E09093CA
-:102830001A048093190486EC90E090931C04809312
-:102840001B0410921E0410921F0410922004109278
-:1028500021040895AF92BF92CF92DF92EF92FF9240
-:102860000F931F93CF93DF936C017B01C0E0D0E007
-:1028700000E010E0F601EC0FFD1F4AE050E062813D
-:10288000C7010E943A155C016EE2C7010E94CD1497
-:102890008A0D9B1D080F191F2196C330D10551F7D2
-:1028A0004AE050E0F6016581C7010E943A15800FA9
-:1028B000911FDF91CF911F910F91FF90EF90DF90CB
-:1028C000CF90BF90AF9008950F93FC018AED91E0F7
-:1028D0009183808362834383248305830F910895CA
-:1028E0008AED91E09093A3048093A2041092A40433
-:1028F0001092A5041092A6041092A70408950895BA
-:102900000E94F1100E947F140E94DB03CDE6D2E109
-:102910000E94FC062097E1F30E946D12F9CFCF923E
-:10292000DF92EF92FF920F931F93CF93DF936C018F
-:102930007A01EB01E60EF71E00E010E0CE15DF0590
-:1029400061F06991D601ED91FC910190F081E02D4B
-:10295000C6010995080F191FF1CFC801DF91CF916A
-:102960001F910F91FF90EF90DF90CF900895611528
-:10297000710581F0DB010D900020E9F7AD014150B8
-:102980005109461B570BDC01ED91FC910280F3814C
-:10299000E02D099480E090E00895DC01ED91FC9138
-:1029A0000190F081E02D09948F929F92AF92BF9297
-:1029B000CF92DF92EF92FF920F931F93CF93DF930B
-:1029C000CDB7DEB7A1970FB6F894DEBF0FBECDBF6F
-:1029D0007C01C42EE52FCB01D22E19A221E02D15AA
-:1029E00010F02AE0D22E8E010F5D1F4F8D2C912CFE
-:1029F000A12CB12C6C2D7E2FA50194010E94A51550
-:102A00008C2DD29E80191124015011098A3014F4A2
-:102A1000805D01C0895CF801808321153105410585
-:102A2000510521F0C22EE32FCA01E4CFB801C7013E
-:102A30000E94B714A1960FB6F894DEBF0FBECDBFAB
-:102A4000DF91CF911F910F91FF90EF90DF90CF908A
-:102A5000BF90AF909F908F9008952115310541F45C
-:102A6000DC01ED91FC910190F081E02D642F09943F
-:102A70000C94D4149A01462F50E060E070E00C945E
-:102A80002D154F925F926F927F92AF92BF92CF922D
-:102A9000DF92EF92FF920F931F93CF93DF93CDB707
-:102AA000DEB729013A01621B730B840B950B298950
-:102AB0003A894B895C892A193B094C095D09298BA4
-:102AC0003A8B4B8B5C8B9B01AC0169897A898B8932
-:102AD0009C890E948915E418F50806091709A801C0
-:102AE00097010E94C7152A0D3B1D4C1D5D1DCA0193
-:102AF000B901DF91CF911F910F91FF90EF90DF907F
-:102B0000CF90BF90AF907F906F905F904F9008955F
-:102B10000895DB018F939F930E94EC15BF91AF91B5
-:102B2000A29F800D911DA39F900DB29F900D112427
-:102B30000895991B79E004C0991F961708F0961B19
-:102B4000881F7A95C9F780950895A1E21A2EAA1BCD
-:102B5000BB1BFD010DC0AA1FBB1FEE1FFF1FA2174D
-:102B6000B307E407F50720F0A21BB30BE40BF50B4A
-:102B7000661F771F881F991F1A9469F760957095D3
-:102B8000809590959B01AC01BD01CF010895052E64
-:102B900097FB1EF400940E94DE1557FD07D00E949B
-:102BA000A51507FC03D04EF40C94DE155095409506
-:102BB000309521953F4F4F4F5F4F089590958095E9
-:102BC000709561957F4F8F4F9F4F0895EE0FFF1FB8
-:102BD0000590F491E02D09940E94F715A59F900DA2
-:102BE000B49F900DA49F800D911D11240895A29F64
-:102BF000B001B39FC001A39F700D811D1124911DD1
-:102C0000B29F700D811D1124911D0895CF93DF9304
-:102C10008230910510F482E090E0E091AA04F091F6
-:102C2000AB0420E030E0A0E0B0E0309739F1408123
-:102C3000518148175907B8F04817590771F4828134
-:102C40009381109729F013969C938E9312972CC022
-:102C50009093AB048093AA0427C02115310531F06D
-:102C60004217530718F0A901DB0101C0EF019A01D7
-:102C7000BD01DF010280F381E02DD7CF21153105A1
-:102C8000F9F0281B390B2430310580F48A819B81AF
-:102C90006115710521F0FB019383828304C0909339
-:102CA000AB048093AA04FE01329644C0FE01E20FF9
-:102CB000F31F8193919322503109398328833AC0BD
-:102CC0002091A8043091A904232B41F42091020102
-:102CD000309103013093A9042093A80420910001AE
-:102CE000309101012115310541F42DB73EB74091D6
-:102CF000040150910501241B350BE091A804F091CB
-:102D0000A904E217F307A0F42E1B3F0B281739077D
-:102D100078F0AC014E5F5F4F2417350748F04E0F37
-:102D20005F1F5093A9044093A8048193919302C01C
-:102D3000E0E0F0E0CF01DF91CF910895CF93DF93F2
-:102D4000009709F487C0FC01329713821282C09168
-:102D5000AA04D091AB04209781F420813181280FFF
-:102D6000391F8091A8049091A9048217930779F5DF
-:102D7000F093A904E093A8046DC0DE0120E030E0E8
-:102D8000AE17BF0750F412964D915C9113979D01B9
-:102D90004115510509F1DA01F3CFB383A2834081D4
-:102DA0005181840F951F8A179B0771F48D919C9117
-:102DB0001197840F951F02969183808312968D91AF
-:102DC0009C911397938382832115310529F4F09305
-:102DD000AB04E093AA043EC0D9011396FC93EE9392
-:102DE00012974D915D91A40FB51FEA17FB0779F477
-:102DF00080819181840F951F0296D90111969C9331
-:102E00008E938281938113969C938E931297E0E028
-:102E1000F0E08A819B81009719F0FE01EC01F9CF67
-:102E2000CE01029628813981820F931F2091A80438
-:102E30003091A9042817390769F4309729F41092C2
-:102E4000AB041092AA0402C013821282D093A90488
-:102E5000C093A804DF91CF910895FB01DC0141509C
-:102E6000504048F001900D920020C9F701C01D921A
-:102E700041505040E0F70895FC0181E090E001905E
-:102E8000061609F4CF010020D1F701970895FB0140
-:102E900051915523A9F0BF01DC014D914517411116
-:102EA000E1F759F4CD010190002049F04D91401512
-:102EB0004111C9F3FB014111EFCF81E090E001978F
-:062EC0000895F894FFCF15
-:102EC6000000AC04800001000000FF1300014D610A
-:102ED6007820736572766F732061747461636865B8
-:102EE6006400556E6B6E6F776E2070696E206D6F25
-:102EF6006465005374616E646172644669726D61E3
-:102F060074612E696E6F004932433A20546F6F2008
-:102F16006D616E7920627974657320726563656987
-:102F2600766564004932433A20546F6F20666577B0
-:102F360020627974657320726563656976656400DD
-:102F460031302D6269742061646472657373696ED1
-:102F560067206E6F7420737570706F72746564008D
-:102F6600746F6F206D616E79207175657269657316
-:102F76000000000000FC09CF09A409AC09BF09CE76
-:102F8600092E6370700000000000BE128F144012FC
-:0C2F960059124B129C12000000002A147B
-:00000001FF
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values-w820dp/dimens.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc816444..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/anim.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/anim.xml
deleted file mode 100644
index a6b3daec93..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/anim.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/colors.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/colors.xml
deleted file mode 100644
index fbaa27a0c2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
- - #00a0e9
- - #ffffff
- - #666666
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/dimens.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/dimens.xml
deleted file mode 100644
index 2bcf0d4ad2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 16dp
- 16dp
- 24dp
- 5dp
- 20sp
- 16sp
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/strings.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/strings.xml
deleted file mode 100644
index 2d85edefc2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
- FaBo (Device Connect Device Plug-in)
-
- サービスを追加
- キャンセル
- 削除
- オンライン
- オフライン
- No Name
-
- 確認
- 選択したサービスを削除しますか?
-
- はい
- いいえ
-
- 確認
- オンラインのサービスは削除することができません。\nFaBoとの接続を一度切ってから再度行なってください。
- 確認
- このサービスは削除することができません。
-
- 仮想サービス設定
- サービスID
- サービス名
- プロファイル
- 保存
- 決定
- 仮想サービスで使用するプロファイルを選択してください。
- プロファイルが使用するピンを選択してください。
- +
- 削除
- PIN: %1$s
-
- プロファイル設定
- ピン設定
-
- サービス
- 警告
- はい
- いいえ
- ピンが選択されていません。
- プロファイルが登録されていません。
- 名前が記入されていません。
- 名前が長すきます。
- 仮想サービスを保存しました。
- FaBoDeviceServiceにバインドされていません。\n設定画面から再起動をお願いします。
- 削除確認
- %1$sを削除して良いでしょうか?
- サービスの削除に失敗しました。
-
- Light(GPIO) #101
- Humidity(GPIO) #115
- KeyEvent(GPIO) #103
- Temperature(GPIO) #108
- Vibration(GPIO) #105
- Illuminace(GPIO) #109
- Proximity(GPIO) #116
- DriveController(RobotCar)
- DriveController(MouseCar)
- DeviceOrientation(3AXIS) #201
- Temperature(I2C) #207
- Humidity(I2C) #208
- Proximity(I2C) #205
- Illuminace(I2C) #217
- AtmosphericPressure(I2C) #204
- Proximity(I2C) LIDARLite v3
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/styles.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/styles.xml
deleted file mode 100644
index 5460fc97c4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/xml/device_filter.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/xml/device_filter.xml
deleted file mode 100644
index 09e408aa85..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/xml/device_filter.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/xml/org_deviceconnect_android_deviceplugin_fabo.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/xml/org_deviceconnect_android_deviceplugin_fabo.xml
deleted file mode 100644
index 1927e8232b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/main/res/xml/org_deviceconnect_android_deviceplugin_fabo.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/test/java/org/deviceconnect/android/deviceplugin/fabo/ExampleUnitTest.java b/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/test/java/org/deviceconnect/android/deviceplugin/fabo/ExampleUnitTest.java
deleted file mode 100644
index b29d95075c..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/app/src/test/java/org/deviceconnect/android/deviceplugin/fabo/ExampleUnitTest.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * To work on unit tests, switch the Test Artifact in the Build Variants view.
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/build.gradle b/dConnectDevicePlugin/dConnectDeviceFaBo/build.gradle
deleted file mode 100644
index ab42e4ce2f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/build.gradle
+++ /dev/null
@@ -1,25 +0,0 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
- repositories {
- google()
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:3.6.2'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
-}
-
-allprojects {
- repositories {
- jcenter()
- google()
- }
-}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/gradle.properties b/dConnectDevicePlugin/dConnectDeviceFaBo/gradle.properties
deleted file mode 100644
index 53587a3d07..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/gradle.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
-# Gradle settings configured through the IDE *will override*
-# any settings specified in this file.
-
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
-storeFile=キーストアのファイル名
-storePassword=キーストアのパスワード
-keyAlias=エイリアス名
-keyPassword=エイリアスのパスワード
-android.useAndroidX=true
-android.enableJetifier=true
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/gradle/wrapper/gradle-wrapper.jar b/dConnectDevicePlugin/dConnectDeviceFaBo/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 13372aef5e..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceFaBo/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/gradle/wrapper/gradle-wrapper.properties b/dConnectDevicePlugin/dConnectDeviceFaBo/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index d11699e03f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Tue Apr 14 15:51:28 JST 2020
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/gradlew b/dConnectDevicePlugin/dConnectDeviceFaBo/gradlew
deleted file mode 100755
index 9d82f78915..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/gradlew
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/gradlew.bat b/dConnectDevicePlugin/dConnectDeviceFaBo/gradlew.bat
deleted file mode 100644
index aec99730b4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/gradlew.bat
+++ /dev/null
@@ -1,90 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/.gitignore b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/.gitignore
deleted file mode 100644
index 796b96d1c4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/build.gradle b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/build.gradle
deleted file mode 100644
index 83487c7943..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/build.gradle
+++ /dev/null
@@ -1,82 +0,0 @@
-apply plugin: 'com.android.application'
-// Create github.properties in root project folder file with
-// gpr.usr=GITHUB_USER_ID
-// gpr.key=PERSONAL_ACCESS_TOKEN
-def githubPropertiesFile = rootProject.file("github.properties")
-def githubProperties = new Properties()
-if (githubPropertiesFile.exists()) {
- githubProperties.load(new FileInputStream(githubPropertiesFile))
-}
-android {
- compileSdkVersion 29
-
- def getVersionName = { ->
- def version
- if (System.getProperty('os.name').toLowerCase().contains('windows')) {
- version = ["cmd", "/c", "git describe --tags --long"].execute().in.text.trim()
- } else {
- version = ["sh", "-c", "git describe --tags --long"].execute().in.text.trim()
- }
- version = version.empty ? "2.1.0" : version
- return "${version}"
- }
-
- defaultConfig {
- applicationId "org.deviceconnect.android.deviceplugin.fabo"
- minSdkVersion 16
- targetSdkVersion 29
- versionCode 1
- versionName getVersionName()
-
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- }
-
- signingConfigs {
- releaseConfig {
- storeFile=file(project.properties.storeFile)
- storePassword=project.properties.storePassword
- keyAlias=project.properties.keyAlias
- keyPassword=project.properties.keyPassword
- }
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- signingConfig signingConfigs.releaseConfig
- }
- }
-
- tasks.withType(JavaCompile) {
- options.encoding = 'UTF-8'
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- repositories {
- maven {
- name = "DeviceConnect-Android"
- url = uri("https://maven.pkg.github.com/DeviceConnect/DeviceConnect-Android")
-
- credentials {
- username = System.getenv("GPR_USER") ?: githubProperties['gpr.usr']
- password = System.getenv("GPR_API_KEY") ?: githubProperties['gpr.key']
- }
- }
- }
-}
-
-repositories {
- maven { url "https://raw.githubusercontent.com/FaBoPlatform/FaBo-Serial-Kit/master/repository/" }
- maven { url 'https://raw.githubusercontent.com/FaBoPlatform/STK500-Android/master/stk500/repository/' }
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation project(':app')
- implementation 'org.deviceconnect:dconnect-device-plugin-sdk:2.8.4'
- implementation 'io.fabo:serialkit:0.9.6'
- implementation 'io.fabo.android.stk500:stk500-aar:1.0.4'
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/proguard-rules.pro b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/proguard-rules.pro
deleted file mode 100644
index 36d448c0fa..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/proguard-rules.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/kobayashinobuo/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/androidTest/java/org/deviceconnect/android/deviceplugin/fabo/ExampleInstrumentedTest.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/androidTest/java/org/deviceconnect/android/deviceplugin/fabo/ExampleInstrumentedTest.java
deleted file mode 100644
index bd39284f67..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/androidTest/java/org/deviceconnect/android/deviceplugin/fabo/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("org.deviceconnect.android.deviceplugin.fabo", appContext.getPackageName());
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/AndroidManifest.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/AndroidManifest.xml
deleted file mode 100644
index 4f8b455870..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoArduinoDeviceProvider.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoArduinoDeviceProvider.java
deleted file mode 100644
index 6b17a976cf..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoArduinoDeviceProvider.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- FaBoDeviceProvider.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.fabo;
-
-import android.app.Service;
-
-import org.deviceconnect.android.message.DConnectMessageServiceProvider;
-
-/**
- * Device Connect Manager本体からのインテントを受信するクラス.
- * @author NTT DOCOMO, INC.
- * @param FaBoデバイスプラグインのプロファイルを公開するサービスのクラス
- */
-public class FaBoArduinoDeviceProvider extends DConnectMessageServiceProvider {
-
- @SuppressWarnings("unchecked")
- @Override
- protected Class getServiceClass() {
- Class extends Service> clazz = (Class extends Service>) FaBoArduinoDeviceService.class;
- return (Class) clazz;
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoArduinoDeviceService.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoArduinoDeviceService.java
deleted file mode 100644
index 044d33812b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoArduinoDeviceService.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- FaBoDeviceService.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.fabo;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.device.arduino.FaBoUsbDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.setting.FaBoSettingActivity;
-import org.deviceconnect.android.profile.SystemProfile;
-
-/**
- * 本デバイスプラグインのプロファイルをDeviceConnectに登録するサービス.
- *
- * @author NTT DOCOMO, INC.
- */
-public class FaBoArduinoDeviceService extends FaBoDeviceService {
-
- /**
- * Local OAuthの設定を切り替えるアクション.
- */
- public static final String ACTION_SET_LOCAL_OAUTH = "org.deviceconnect.android.deviceplugin.fabo.ACTION_SET_LOCAL_OAUTH";
-
- /**
- * FaBoの設定を保持するクラス.
- */
- private FaBoSettings mFaBoSettings;
-
- @Override
- public void onCreate() {
- super.onCreate();
- mFaBoSettings = new FaBoSettings(this);
- setUseLocalOAuth(mFaBoSettings.isUseLocalOAuth());
- }
-
- @Override
- public void onDestroy() {
- mFaBoSettings = null;
- super.onDestroy();
- }
-
- @Override
- public int onStartCommand(final Intent intent, final int flags, final int startId) {
- if (intent != null && ACTION_SET_LOCAL_OAUTH.equals(intent.getAction())) {
- setUseLocalOAuth(mFaBoSettings.isUseLocalOAuth());
- }
-
- return super.onStartCommand(intent, flags, startId);
- }
-
- @Override
- protected FaBoDeviceControl createFaBoDeviceControl() {
- return new FaBoUsbDeviceControl(this);
- }
-
-
- @Override
- protected SystemProfile getSystemProfile() {
- return new FaBoSystemProfile();
- }
-
- /**
- * Arduino用のSystemプロファイル.
- */
- private class FaBoSystemProfile extends SystemProfile {
- @Override
- protected Class extends Activity> getSettingPageActivity(final Intent request, final Bundle param) {
- return FaBoSettingActivity.class;
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoSettings.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoSettings.java
deleted file mode 100644
index 9deac1d543..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoSettings.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-class FaBoSettings {
-
- /**
- * 情報を共有するプリファレンス.
- */
- private SharedPreferences mPreferences;
-
- /**
- * コンテキスト.
- */
- private Context mContext;
-
- /**
- * コンストラクタ.
- * @param context コンテキスト
- */
- FaBoSettings(final Context context) {
- mContext = context;
- mPreferences = context.getSharedPreferences(context.getPackageName() + "_preferences",
- Context.MODE_PRIVATE);
- }
-
- /**
- * Local OAuth使用フラグを取得します.
- *
- * @return Local OAuthを使用する場合はtrue、それ以外はfalse
- */
- boolean isUseLocalOAuth() {
- return mPreferences.getBoolean(mContext.getString(R.string.key_settings_security_local_oauth), false);
- }
-
- /**
- * Local OAuth使用フラグを設定します.
- *
- * @param flag 使用フラグ
- */
- void setUseLocalOAuth(final boolean flag) {
- SharedPreferences.Editor editor = mPreferences.edit();
- editor.putBoolean(mContext.getString(R.string.key_settings_security_local_oauth), flag);
- editor.apply();
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/ADT7410.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/ADT7410.java
deleted file mode 100644
index 7244d67e69..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/ADT7410.java
+++ /dev/null
@@ -1,271 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IADT7410;
-
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataUtil.decodeByte;
-
-/**
- * ADT7410を操作するクラス.
- */
-class ADT7410 extends BaseI2C implements IADT7410 {
-
- /**
- * ADT7410のアドレス.
- */
- private static final byte ADT7410_DEVICE_ADDR = 0x48;
-
- /**
- * ADT7410のコンフィグ用のレジスタ.
- */
- private static final int REGISTER_CONFIG = 0x03;
-
- /**
- * ADT7410のデバイスID取得レジスタ.
- */
- private static final int DEVICE_REG = 0x0B;
-
- /**
- * ADT7410のデバイスID.
- */
- private static final int DEVICE_ID = 0x0C;
-
- /**
- * 16bitの分解度を定義.
- */
- private static final int BIT16_RESOLUTION = 0x80;
- private static final int BIT16_OP_MODE_1FAULT = 0x00;
-
- /**
- * ADXL実行カウント.
- */
- private int mRunningCount = 0;
-
- /**
- * 取得した値を通知するリスナ.
- */
- private final List mOnADT7410Listeners = new CopyOnWriteArrayList<>();
-
- @Override
- public void read(final OnADT7410Listener listener) {
- OnADT7410ListenerImpl impl = new OnADT7410ListenerImpl();
- impl.setListener(listener);
- impl.setOnceRead(true);
- impl.start();
- mOnADT7410Listeners.add(impl);
- }
-
- @Override
- public void startRead(final OnADT7410Listener listener) {
- OnADT7410ListenerImpl impl = new OnADT7410ListenerImpl();
- impl.setListener(listener);
- impl.setOnceRead(false);
- impl.start();
- mOnADT7410Listeners.add(impl);
- }
-
- @Override
- public void stopRead(final OnADT7410Listener listener) {
- OnADT7410ListenerImpl impl = get(listener);
- if (impl != null) {
- mOnADT7410Listeners.remove(impl);
- }
- stopRead();
- }
-
- // BaseI2C interface
-
- @Override
- byte getAddress() {
- return ADT7410_DEVICE_ADDR;
- }
-
- @Override
- void onReadData(final byte[] data) {
- int offset = 3;
- int register = decodeByte(data[offset++], data[offset++]);
- switch (register) {
- case DEVICE_REG:
- int deviceId = decodeByte(data[offset++], data[offset]);
- if ((deviceId & DEVICE_ID) != 0) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- setADT7410();
- startRead(ADT7410_DEVICE_ADDR, REGISTER_CONFIG, 2);
- }
- }).start();
- } else {
- for (OnADT7410Listener listener : mOnADT7410Listeners) {
- listener.onError("ADT7410 is not connect.");
- }
- }
- break;
-
- case REGISTER_CONFIG:
- double temp = convertTemperature(FirmataUtil.decodeUShort2(data, offset));
- for (OnADT7410Listener listener : mOnADT7410Listeners) {
- listener.onData(temp);
- }
- break;
- }
- }
-
- /**
- * ADT7410の初期化を行います.
- */
- private void setADT7410() {
- write(ADT7410_DEVICE_ADDR, REGISTER_CONFIG, BIT16_RESOLUTION);
- }
-
- /**
- * センサーの値を摂氏に変換します.
- * @param value センサーの値
- * @return 摂氏
- */
- private double convertTemperature(int value) {
- if ((value & 0x8000) != 0) {
- value = value - 65536;
- }
- return value / 128.0;
- }
-
- /**
- * センサーの値の読み込みを開始します.
- */
- private void startRead() {
- mRunningCount++;
-
- if (mRunningCount == 1) {
- setI2CConfig();
- read(ADT7410_DEVICE_ADDR, DEVICE_REG, 1);
- }
- }
-
- /**
- * センサーの値の読み込みを停止します.
- */
- private void stopRead() {
- if (mRunningCount > 0) {
- mRunningCount--;
-
- if (mRunningCount == 0) {
- stopRead(ADT7410_DEVICE_ADDR, REGISTER_CONFIG);
- }
- }
- }
-
- /**
- * 指定されたリスナーをもつOnADXL345ListenerImplを取得します.
- * @param listener リスナー
- * @return OnADXL345ListenerImplのインスタンス
- */
- private OnADT7410ListenerImpl get(final OnADT7410Listener listener) {
- for (OnADT7410ListenerImpl impl : mOnADT7410Listeners) {
- if (impl.mListener == listener) {
- return impl;
- }
- }
- return null;
- }
-
- private class OnADT7410ListenerImpl implements OnADT7410Listener {
-
- /**
- * タイムアウトを監視するタイマー.
- */
- private Timer mTimer;
-
- /**
- * 通知を行うリスナー.
- */
- private OnADT7410Listener mListener;
-
- /**
- * 一度だけ読み込む場合.
- */
- private boolean mOnceRead;
-
- /**
- * 開始フラグ.
- */
- private boolean mStartFlag;
-
- /**
- * センサー開始とタイムアウト用のタイマーの開始を行います.
- */
- void start() {
- mTimer = new Timer();
- mTimer.schedule(new TimerTask() {
- @Override
- public void run() {
- onError("timeout");
- }
- }, 1000);
- startRead();
- }
-
- /**
- * リスナーを設定します.
- * @param listener リスナー
- */
- void setListener(final OnADT7410Listener listener) {
- mListener = listener;
- }
-
- /**
- * 一度だけ読み込みを行います.
- * @param onceRead フラグ
- */
- void setOnceRead(final boolean onceRead) {
- mOnceRead = onceRead;
- }
-
- /**
- * タイマーをキャンセルします.
- */
- void cancelTimer() {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer = null;
- }
- }
-
- /**
- * 後始末処理を行います.
- */
- void onFinish() {
- cancelTimer();
- stopRead();
- mOnADT7410Listeners.remove(this);
- }
-
- @Override
- public void onStarted() {
- }
-
- @Override
- public void onData(double temperature) {
- if (!mStartFlag) {
- mStartFlag = true;
- cancelTimer();
- mListener.onStarted();
- }
- mListener.onData(temperature);
-
- if (mOnceRead) {
- onFinish();
- }
- }
-
- @Override
- public void onError(String message) {
- mListener.onError(message);
- onFinish();
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/ADXL345.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/ADXL345.java
deleted file mode 100644
index 06f5696f10..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/ADXL345.java
+++ /dev/null
@@ -1,282 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IADXL345;
-
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataUtil.decodeByte;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataUtil.decodeShort;
-
-/**
- * ADXL345を操作するクラス.
- */
-class ADXL345 extends BaseI2C implements IADXL345 {
-
- /**
- * ADXL345のアドレス.
- */
- private static final byte ADXL345_DEVICE_ADDR = 0x53;
-
- /**
- * ADXL345のデバイスID取得レジスタ.
- */
- private static final int REGISTER_RA_DEVID = 0x0;
-
- /**
- * ADXL345のパワー設定レジスタ.
- */
- private static final int REGISTER_RA_POWER_CTL = 0x2D;
-
- /**
- * ADXL345のデータフォーマット設定レジスタ.
- */
- private static final int REGISTER_RA_DATA_FORMAT = 0x31;
-
- /**
- * ADXL345のデータ取得レジスタ.
- */
- private static final int REGISTER_RA_DATAX0 = 0x32;
-
- /**
- * ADXL345のデバイスID.
- */
- private static final int DEVICE_ID = 0xE5;
-
- /**
- * 13bitの分解能.
- */
- private static final double RESOLUTION = (16 + 16) / Math.pow(2, 13);
-
- /**
- * 取得した値を通知するリスナ.
- */
- private final List mOnADXL345Listeners = new CopyOnWriteArrayList<>();
-
- /**
- * ADXL実行カウント.
- */
- private int mRunningCount = 0;
-
- @Override
- public synchronized void read(final OnADXL345Listener listener) {
- OnADXL345ListenerImpl impl = new OnADXL345ListenerImpl();
- impl.setOnADXL345Listener(listener);
- impl.setOnceRead(true);
- impl.startADXL345();
- mOnADXL345Listeners.add(impl);
- }
-
- @Override
- public synchronized void startRead(final OnADXL345Listener listener) {
- OnADXL345ListenerImpl impl = new OnADXL345ListenerImpl();
- impl.setOnADXL345Listener(listener);
- impl.setOnceRead(false);
- impl.startADXL345();
- mOnADXL345Listeners.add(impl);
- }
-
- @Override
- public synchronized void stopRead(final OnADXL345Listener listener) {
- OnADXL345ListenerImpl impl = get(listener);
- if (impl != null) {
- mOnADXL345Listeners.remove(impl);
- }
- stopRead();
- }
-
- // BaseI2C interface
-
- @Override
- byte getAddress() {
- return ADXL345_DEVICE_ADDR;
- }
-
- @Override
- void onReadData(final byte[] data) {
- int offset = 3;
- int register = decodeByte(data[offset++], data[offset++]);
- if (register == REGISTER_RA_DEVID) {
- int deviceId = decodeByte(data[offset++], data[offset]);
- if (deviceId == DEVICE_ID) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- setADXL345();
- startRead(ADXL345_DEVICE_ADDR, REGISTER_RA_DATAX0, 6);
- }
- }).start();
- } else {
- for (OnADXL345Listener listener : mOnADXL345Listeners) {
- listener.onError("ADXL345 is not connect.");
- }
- }
- } else if (register == REGISTER_RA_DATAX0) {
- int ax = decodeShort(data, offset);
- offset += 4;
- int ay = decodeShort(data, offset);
- offset += 4;
- int az = decodeShort(data, offset);
-
- double gx = convertResolution(ax);
- double gy = convertResolution(ay);
- double gz = convertResolution(az);
-
- for (OnADXL345Listener listener : mOnADXL345Listeners) {
- listener.onData(gx, gy, gz);
- }
- }
- }
-
- /**
- * ADXL345の初期化を行います.
- */
- private void setADXL345() {
- write(ADXL345_DEVICE_ADDR, REGISTER_RA_DATA_FORMAT, 0x0B);
- write(ADXL345_DEVICE_ADDR, REGISTER_RA_POWER_CTL, 0x08);
- }
-
- /**
- * センサーの値の読み込みを開始します.
- */
- private void startRead() {
- mRunningCount++;
-
- if (mRunningCount == 1) {
- setI2CConfig();
- read(ADXL345_DEVICE_ADDR, REGISTER_RA_DEVID, 1);
- }
- }
-
- /**
- * センサーの値の読み込みを停止します.
- */
- private void stopRead() {
- if (mRunningCount > 0) {
- mRunningCount--;
-
- if (mRunningCount == 0) {
- stopRead(ADXL345_DEVICE_ADDR, REGISTER_RA_DATAX0);
- }
- }
- }
-
- /**
- * 指定されたリスナーをもつOnADXL345ListenerImplを取得します.
- * @param listener リスナー
- * @return OnADXL345ListenerImplのインスタンス
- */
- private OnADXL345ListenerImpl get(final OnADXL345Listener listener) {
- for (OnADXL345ListenerImpl impl : mOnADXL345Listeners) {
- if (impl.mListener == listener) {
- return impl;
- }
- }
- return null;
- }
-
- /**
- * 加速度センサーの値を重力加速度に変換します.
- * @param data 加速度センサーからの値
- * @return 重力加速度
- */
- private double convertResolution(final int data) {
- return data * RESOLUTION;
- }
-
- /**
- * タイマー付きでADXL345のセンサー値を開始します.
- */
- private class OnADXL345ListenerImpl implements OnADXL345Listener {
- /**
- * タイムアウトを監視するタイマー.
- */
- private Timer mTimer;
-
- /**
- * 通知を行うリスナー.
- */
- private OnADXL345Listener mListener;
-
- /**
- * 一度だけ読み込む場合.
- */
- private boolean mOnceRead;
-
- /**
- * 開始フラグ.
- */
- private boolean mStartFlag;
-
- /**
- * ADXL345のセンサー開始とタイムアウト用のタイマーの開始を行います.
- */
- void startADXL345() {
- mTimer = new Timer();
- mTimer.schedule(new TimerTask() {
- @Override
- public void run() {
- onError("timeout");
- }
- }, 1000);
- startRead();
- }
-
- void setOnADXL345Listener(final OnADXL345Listener listener) {
- mListener = listener;
- }
-
- /**
- * 一度だけ読み込みを行います.
- * @param onceRead
- */
- void setOnceRead(final boolean onceRead) {
- mOnceRead = onceRead;
- }
-
- /**
- * タイマーをキャンセルします.
- */
- void cancelTimer() {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer = null;
- }
- }
-
- /**
- * 後始末処理を行います.
- */
- void onFinish() {
- cancelTimer();
- stopRead();
- mOnADXL345Listeners.remove(this);
- }
-
- @Override
- public void onStarted() {
- }
-
- @Override
- public void onData(final double x, final double y, final double z) {
- if (!mStartFlag) {
- mStartFlag = true;
- cancelTimer();
- mListener.onStarted();
- }
- mListener.onData(x, y, z);
-
- if (mOnceRead) {
- onFinish();
- }
- }
-
- @Override
- public void onError(final String message) {
- mListener.onError(message);
- onFinish();
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/BaseI2C.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/BaseI2C.java
deleted file mode 100644
index 97767c4d0e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/BaseI2C.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.END_SYSEX;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.I2C_CONFIG;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.I2C_READ;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.I2C_READ_CONTINUOUSLY;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.I2C_REQUEST;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.I2C_STOP_READING;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.I2C_WRITE;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.START_SYSEX;
-
-class BaseI2C {
-
- /**
- * Usbに接続されたデバイスを管理するクラス.
- */
- private FaBoUsbDeviceControl mFaBoDeviceControl;
-
- /**
- * FaBoDeviceControlのインスタンスを取得します.
- * @return FaBoDeviceControlのインスタンス
- */
- FaBoUsbDeviceControl getFaBoDeviceControl() {
- return mFaBoDeviceControl;
- }
-
- /**
- * FaBoDeviceControlのインスタンスを設定します.
- * @param controller FaBoDeviceControlのインスタンス
- */
- void setFaBoDeviceControl(final FaBoUsbDeviceControl controller) {
- mFaBoDeviceControl = controller;
- }
-
- /**
- * I2Cコンフィグを送信します.
- */
- void setI2CConfig() {
- byte[] config = {
- START_SYSEX,
- I2C_CONFIG,
- (byte) 0x00,
- (byte) 0x00,
- END_SYSEX
- };
- writeI2C(config);
- }
-
- /**
- * I2Cにデータを送信します.
- * @param data 送信するデータ
- */
- void writeI2C(final byte[] data) {
- getFaBoDeviceControl().writeI2C(data);
- }
-
- /**
- * 指定されたアドレスにSysex messageを送信します.
- * @param address アドレス
- * @param a 送信するデータ1
- * @param b 送信するデータ2
- */
- void write(final byte address, final int a, final int b) {
- byte[] config = {
- START_SYSEX,
- I2C_REQUEST,
- address,
- I2C_WRITE,
- (byte) (a & 0x7f),
- (byte) ((a >> 7) & 0x7f),
- (byte) (b & 0x7f),
- (byte) ((b >> 7) & 0x7f),
- END_SYSEX
- };
- writeI2C(config);
- }
-
- /**
- * 指定されたアドレスからデータを読み込みます.
- * @param address アドレス
- * @param register レジスタ
- * @param size 読み込むデータサイズ
- */
- void read(final byte address, final int register, final int size) {
- byte[] command = {
- START_SYSEX,
- I2C_REQUEST,
- address,
- I2C_READ,
- (byte) (register & 0x7f),
- (byte) ((register >> 7) & 0x7f),
- (byte) (size & 0x7f),
- (byte) ((size >> 7) & 0x7f),
- END_SYSEX
- };
- writeI2C(command);
- }
-
- /**
- * 指定されたアドレスからデータを読み込みを開始します.
- * @param address アドレス
- * @param register レジスタ
- * @param size 読み込むデータサイズ
- */
- void startRead(final byte address, final int register, final int size) {
- byte[] command = {
- START_SYSEX,
- I2C_REQUEST,
- address,
- I2C_READ_CONTINUOUSLY,
- (byte) (register & 0x7f),
- (byte) ((register >> 7) & 0x7f),
- (byte) (size & 0x7f),
- (byte) ((size >> 7) & 0x7f),
- END_SYSEX
- };
- writeI2C(command);
- }
-
- /**
- * 指定されたアドレスからデータを読み込みを停止します.
- * @param address アドレス
- * @param register レジスタ
- */
- void stopRead(final byte address, final int register) {
- byte[] command = {
- START_SYSEX,
- I2C_REQUEST,
- address,
- I2C_STOP_READING,
- (byte) (register & 0x7f),
- (byte) ((register >> 7) & 0x7f),
- END_SYSEX
- };
- writeI2C(command);
- }
-
- /**
- * I2Cのアドレスを取得します.
- * @return アドレス
- */
- byte getAddress() {
- return -1;
- }
-
- /**
- * I2Cから読み込まれたデータ.
- * @param data データ
- */
- void onReadData(final byte[] data) {}
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/FaBoUsbDeviceControl.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/FaBoUsbDeviceControl.java
deleted file mode 100644
index 94c3c69273..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/FaBoUsbDeviceControl.java
+++ /dev/null
@@ -1,925 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbManager;
-import android.os.Build;
-import android.os.Handler;
-import android.os.Looper;
-import android.util.Log;
-
-import org.deviceconnect.android.deviceplugin.fabo.BuildConfig;
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.device.IADT7410;
-import org.deviceconnect.android.deviceplugin.fabo.device.IADXL345;
-import org.deviceconnect.android.deviceplugin.fabo.device.IHTS221;
-import org.deviceconnect.android.deviceplugin.fabo.device.IISL29034;
-import org.deviceconnect.android.deviceplugin.fabo.device.ILIDARLiteV3;
-import org.deviceconnect.android.deviceplugin.fabo.device.IMPL115;
-import org.deviceconnect.android.deviceplugin.fabo.device.IMouseCar;
-import org.deviceconnect.android.deviceplugin.fabo.device.IRobotCar;
-import org.deviceconnect.android.deviceplugin.fabo.device.IVCNL4010;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoConst;
-
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import io.fabo.serialkit.FaBoUsbConst;
-import io.fabo.serialkit.FaBoUsbListenerInterface;
-import io.fabo.serialkit.FaBoUsbManager;
-
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataUtil.decodeByte;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.ANALOG_MESSAGE;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.DIGITAL_MESSAGE;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.END_SYSEX;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.REPORT_VERSION;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.START_SYSEX;
-import static org.deviceconnect.android.deviceplugin.fabo.param.FaBoConst.STATUS_FABO_INIT;
-
-/**
- * Usb経由でFaBoデバイスを操作するクラス.
- */
-public class FaBoUsbDeviceControl implements FaBoDeviceControl {
-
- /**
- * デバッグフラグ.
- */
- private static final boolean DEBUG = BuildConfig.DEBUG;
-
- /**
- * Tag.
- */
- private static final String TAG = "FaBo";
-
- /**
- * USB Serial Manager.
- */
- private FaBoUsbManager mFaBoUsbManager;
-
- /**
- * Port status.
- */
- private int[] mDigitalPortStatus = {0, 0, 0};
-
- /**
- * FirmataのVersion.
- */
- private static final int[] VERSION = {0x02, 0x05};
-
- /**
- * Statusを保持.
- */
- private int mStatus;
-
- /**
- * USB機器へのアクセス許可を行なっているかフラグ.
- */
- private boolean mRequestPermission;
-
- /**
- * GPIOの値変更通知リスナー.
- */
- private final List mOnGPIOListeners = new ArrayList<>();
-
- /**
- * FaBoデバイスの接続状態などを通知するリスナー.
- */
- private OnFaBoDeviceControlListener mOnFaBoDeviceControlListener;
-
- /**
- * コンテキスト.
- */
- private Context mContext;
-
- /**
- * sysex messageを解析中フラグ.
- *
- * sysex messageを解析している間はtrue、それ以外はfalse
- *
- */
- private boolean mParsingSysex;
-
- /**
- * Arduinoから送られてきたピン番号.
- */
- private int mChannel;
-
- /**
- * Arduinoから送られてきたコマンド.
- *
- * 以下のコマンドが存在します。
- * - DIGITAL_MESSAGE
- * - ANALOG_MESSAGE
- * - REPORT_ANALOG
- * - REPORT_DIGITAL
- *
- */
- private byte mCommand;
-
- /**
- * コマンドのデータカウント.
- */
- private int mWaitForData;
-
- /**
- * Arduinoから送られてきたデータを一時的に格納するバッファ.
- */
- private ByteArrayOutputStream mStoredInputData;
-
- /**
- * マウス型RobotCarを操作するクラス.
- */
- private MouseCar mMouseCar;
-
- /**
- * RobotCarを操作するクラス.
- */
- private RobotCar mRobotCar;
-
- /**
- * Brick #201 を操作するためのクラス.
- */
- private ADXL345 mADXL345;
-
- /**
- * Brick #207 を操作するためのクラス.
- */
- private ADT7410 mADT7410;
-
- /**
- * Brick #208 を操作するためのクラス.
- */
- private HTS221 mHTS221;
-
- /**
- * Brick #217 を操作するクラス.
- */
- private ISL29034 mISL29034;
-
- /**
- * Brick #204 を操作するクラス.
- */
- private MPL115 mMPL115;
-
- /**
- * Brick # 205 を操作するクラス.
- */
- private VCNL4010 mVCNL4010;
-
- /**
- * LIDARLite v3を操作するクラス.
- */
- private LIDARLiteV3 mLIDARLiteV3;
-
- /**
- * I2Cを格納するリスト.
- */
- private List mI2CList = new ArrayList<>();
-
- /**
- * コンストラクタ.
- * @param context コンテキスト
- */
- public FaBoUsbDeviceControl(final Context context) {
- mContext = context.getApplicationContext();
- }
-
- @Override
- public void initialize() {
- mStoredInputData = new ByteArrayOutputStream();
- mParsingSysex = false;
-
- // Set status.
- setStatus(FaBoConst.STATUS_FABO_NOCONNECT);
-
- // USBのEvent用のBroadcast Receiverを設定.
- IntentFilter filter = new IntentFilter();
- filter.addAction(FaBoConst.DEVICE_TO_ARDUINO_OPEN_USB);
- filter.addAction(FaBoConst.DEVICE_TO_ARDUINO_CHECK_USB);
- filter.addAction(FaBoConst.DEVICE_TO_ARDUINO_CLOSE_USB);
- filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
- mContext.registerReceiver(mUsbEventReceiver, filter);
-
- initUsbDevice();
- initI2CSDevice();
- }
-
- @Override
- public void destroy() {
- mOnFaBoDeviceControlListener = null;
- mOnGPIOListeners.clear();
- mI2CList.clear();
- closeUsb();
- mContext.unregisterReceiver(mUsbEventReceiver);
- }
-
- @Override
- public boolean isPinSupported(final FaBoShield.Pin pin) {
- return true;
- }
-
- @Override
- public void writeAnalog(final FaBoShield.Pin pin, final int value) {
- byte[] bytes = new byte[5];
- bytes[0] = (byte) START_SYSEX;
- bytes[1] = (byte) (0x6F);
- bytes[2] = (byte) pin.getPinNumber();
- bytes[3] = (byte) value;
- bytes[4] = (byte) END_SYSEX;
- sendMessage(bytes);
- }
-
- @Override
- public void writeDigital(final FaBoShield.Pin pin, final FaBoShield.Level hl) {
- int port = pin.getPort();
- int pinBit = pin.getBit();
- if (hl == FaBoShield.Level.HIGH) {
- int status = getPortStatus(port) | pinBit;
- byte[] bytes = new byte[3];
- bytes[0] = (byte) (DIGITAL_MESSAGE | port);
- bytes[1] = (byte) (status & 0xFF);
- bytes[2] = (byte) ((status >> 8) & 0xFF);
- sendMessage(bytes);
- setPortStatus(port, status);
- } else if (hl == FaBoShield.Level.LOW) {
- int status = getPortStatus(port) & ~pinBit;
- byte[] bytes = new byte[3];
- bytes[0] = (byte) (DIGITAL_MESSAGE | port);
- bytes[1] = (byte) (status & 0xFF);
- bytes[2] = (byte) ((status >> 8) & 0xFF);
- sendMessage(bytes);
- setPortStatus(port, status);
- }
- }
-
- @Override
- public int getAnalog(final FaBoShield.Pin pin) {
- return pin.getValue();
- }
-
- @Override
- public FaBoShield.Level getDigital(final FaBoShield.Pin pin) {
- int port = pin.getPort();
- int pinBit = pin.getBit();
- int value = mDigitalPortStatus[port];
- if ((value & pinBit) == pinBit) {
- return FaBoShield.Level.HIGH;
- } else {
- return FaBoShield.Level.LOW;
- }
- }
-
- @Override
- public void setPinMode(final FaBoShield.Pin pin, final FaBoShield.Mode mode) {
- byte[] command = new byte[3];
- command[0] = (byte) (FirmataV32.SET_PIN_MODE);
- command[1] = (byte) (pin.getPinNumber());
- command[2] = (byte) (mode.getValue());
- sendMessage(command);
- pin.setMode(mode);
- }
-
- @Override
- public int getStatus() {
- return mStatus;
- }
-
- @Override
- public IRobotCar getRobotCar() {
- mRobotCar.setFaBoDeviceControl(this);
- return mRobotCar;
- }
-
- @Override
- public IMouseCar getMouseCar() {
- mMouseCar.setFaBoDeviceControl(this);
- return mMouseCar;
- }
-
- @Override
- public IADXL345 getADXL345() {
- mADXL345.setFaBoDeviceControl(this);
- return mADXL345;
- }
-
- @Override
- public IADT7410 getADT7410() {
- mADT7410.setFaBoDeviceControl(this);
- return mADT7410;
- }
-
- @Override
- public IHTS221 getHTS221() {
- mHTS221.setFaBoDeviceControl(this);
- return mHTS221;
- }
-
- @Override
- public IVCNL4010 getVCNL4010() {
- mVCNL4010.setFaBoDeviceControl(this);
- return mVCNL4010;
- }
-
- @Override
- public IISL29034 getISL29034() {
- mISL29034.setFaBoDeviceControl(this);
- return mISL29034;
- }
-
- @Override
- public IMPL115 getMPL115() {
- mMPL115.setFaBoDeviceControl(this);
- return mMPL115;
- }
-
- @Override
- public ILIDARLiteV3 getLIDARLite() {
- mLIDARLiteV3.setFaBoDeviceControl(this);
- return mLIDARLiteV3;
- }
-
- @Override
- public void setOnFaBoDeviceControlListener(final OnFaBoDeviceControlListener listener) {
- mOnFaBoDeviceControlListener = listener;
- }
-
- @Override
- public void addOnGPIOListener(final OnGPIOListener listener) {
- synchronized (mOnGPIOListeners) {
- if (!mOnGPIOListeners.contains(listener)) {
- mOnGPIOListeners.add(listener);
- }
- }
- }
-
- @Override
- public void removeOnGPIOListener(final OnGPIOListener listener) {
- synchronized (mOnGPIOListeners) {
- mOnGPIOListeners.remove(listener);
- }
- }
-
- /**
- * I2Cデバイスを初期化します.
- */
- private void initI2CSDevice() {
- mRobotCar = new RobotCar();
- mMouseCar = new MouseCar();
- mADXL345 = new ADXL345();
- mADT7410 = new ADT7410();
- mHTS221 = new HTS221();
- mVCNL4010 = new VCNL4010();
- mISL29034 = new ISL29034();
- mMPL115 = new MPL115();
- mLIDARLiteV3 = new LIDARLiteV3();
-
- mI2CList.add(mADXL345);
- mI2CList.add(mADT7410);
- mI2CList.add(mHTS221);
- mI2CList.add(mVCNL4010);
- mI2CList.add(mISL29034);
- mI2CList.add(mMPL115);
- mI2CList.add(mLIDARLiteV3);
- }
-
- /**
- * GPIOのPIN情報を初期化します.
- */
- private void initGPIO() {
- for (FaBoShield.Pin pin : FaBoShield.Pin.values()) {
- if (pin.getPinNumber() < FaBoShield.PIN_NO_A0) {
- pin.setMode(FaBoShield.Mode.GPIO_OUT);
- } else {
- pin.setMode(FaBoShield.Mode.ANALOG);
- }
- pin.setValue(0);
- }
-
- // Portの状態をすべて0(Low)にする.
- mDigitalPortStatus[0] = 0; // 0000 0000
- mDigitalPortStatus[1] = 0; // 0000 0000
- mDigitalPortStatus[2] = 0; // 0000 0000
- }
-
- /**
- * USBをOpenする.
- */
- private synchronized void openUsb(final UsbDevice usbDevice) {
- if (DEBUG) {
- Log.i(TAG, "----------------------------------------");
- Log.i(TAG, "Open USB.");
- Log.i(TAG, "DeviceName: " + usbDevice.getDeviceName());
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- Log.i(TAG, "DeviceProductName: " + usbDevice.getProductName());
- }
- Log.i(TAG, "----------------------------------------");
- }
-
- mParsingSysex = false;
-
- if (mFaBoUsbManager != null) {
- mFaBoUsbManager.closeConnection();
- mFaBoUsbManager.checkDevice(usbDevice);
- mFaBoUsbManager.connection(usbDevice);
- } else {
- mFaBoUsbManager = new FaBoUsbManager(mContext);
- mFaBoUsbManager.setParameter(FaBoUsbConst.BAUNDRATE_57600,
- FaBoUsbConst.PARITY_NONE,
- FaBoUsbConst.STOP_1,
- FaBoUsbConst.FLOW_CONTROL_OFF,
- FaBoUsbConst.BITRATE_8);
- mFaBoUsbManager.setListener(mInterface);
- mFaBoUsbManager.checkDevice(usbDevice);
- mFaBoUsbManager.connection(usbDevice);
- }
- }
-
- /**
- * USBをClose.
- */
- private synchronized void closeUsb() {
- if (DEBUG) {
- Log.i(TAG, "----------------------------------------");
- Log.i(TAG, "Close USB.");
- Log.i(TAG, "----------------------------------------");
- }
-
- if (mFaBoUsbManager != null) {
- mFaBoUsbManager.closeConnection();
- mFaBoUsbManager.unregisterMyReceiver();
- mFaBoUsbManager = null;
- }
-
- setStatus(FaBoConst.STATUS_FABO_NOCONNECT);
-
- notifyDisconnectFaBoDevice();
-
- mRequestPermission = false;
- }
-
- /**
- * ステータスを変化する.
- *
- * @param status ステータス
- */
- private void setStatus(int status) {
- mStatus = status;
-
- if (DEBUG) {
- Log.i(TAG, "status:" + status);
- }
- }
-
- /**
- * シリアル通信を開始.
- */
- private void onDeviceStateChange() {
- setStatus(STATUS_FABO_INIT);
-
- // Arduinoの初期化が行われるまで少し待つ
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- // GPIOを格納しているクラスの初期化
- initGPIO();
-
- // FirmataのVersion取得のコマンドを送付
- byte command[] = { REPORT_VERSION };
- sendMessage(command);
-
- // 5秒たってFirmataを検出できない場合はエラー.
- Handler handler = new Handler(Looper.getMainLooper());
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- if (mStatus == STATUS_FABO_INIT) {
- setStatus(FaBoConst.STATUS_FABO_NOCONNECT);
- if (mOnFaBoDeviceControlListener != null) {
- mOnFaBoDeviceControlListener.onFailedConnected();
- }
- }
- }
- }, 5000);
-
- // Statusをinitへ.
- setStatus(STATUS_FABO_INIT);
- }
-
- /**
- * Firmataの初期設定.
- */
- private void intFirmata() {
- if (DEBUG) {
- Log.i(TAG, "initFirmata");
- }
-
- byte[] command = new byte[2];
-
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- // AnalogPin A0-A5の値に変化があったら通知する設定をおこなう(Firmata)
- for (int analogPin = 0; analogPin < 7; analogPin++) {
- command[0] = (byte) (FirmataV32.REPORT_ANALOG + analogPin);
- command[1] = (byte) FirmataV32.ENABLE;
- sendMessage(command);
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- // Portのデジタル値に変化があったら通知する設定をおこなう(Firmata)
- for (int digitalPort = 0; digitalPort < 3; digitalPort++) {
- command[0] = (byte) (FirmataV32.REPORT_DIGITAL + digitalPort);
- command[1] = (byte) FirmataV32.ENABLE;
- sendMessage(command);
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Usbデバイスを初期化します.
- *
- * Usbに接続されたデバイスの中にFaboデバイスが存在した場合に接続を行います。
- * Faboデバイスの場合には何もしません。
- *
- */
- private void initUsbDevice() {
- if (DEBUG) {
- Log.i(TAG, "initUsbDevice");
- }
-
- notifyDisconnectFaBoDevice();
-
- setStatus(FaBoConst.STATUS_FABO_NOCONNECT);
-
- UsbManager manager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE);
- HashMap deviceList = manager.getDeviceList();
-
- for (final UsbDevice device : deviceList.values()) {
- switch (device.getVendorId()) {
- case FaBoUsbConst.ARDUINO_UNO_VID:
- case FaBoUsbConst.ARDUINO_CC_UNO_VID:
- if (DEBUG) {
- Log.i(TAG, "Find device connecting arduino");
- }
- if (manager.hasPermission(device)) {
- openUsb(device);
- } else {
- Intent i = new Intent(FaBoConst.DEVICE_TO_ARDUINO_OPEN_USB);
- PendingIntent p = PendingIntent.getBroadcast(mContext, 0, i, 0);
- manager.requestPermission(device, p);
- }
- break;
-
- default:
- if (DEBUG) {
- Log.w(TAG, "Found the device that is not FaBo device.");
- Log.w(TAG, " VendorId: " + device.getVendorId());
- Log.w(TAG, " DeviceName: " + device.getDeviceName());
- }
- break;
- }
- }
- }
-
- /**
- * Broadcast receiver for usb event.
- */
- private BroadcastReceiver mUsbEventReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(final Context context, final Intent intent) {
- String action = intent.getAction();
- switch (action) {
- case FaBoConst.DEVICE_TO_ARDUINO_OPEN_USB: {
- mRequestPermission = false;
- UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
- if (device != null) {
- UsbManager m = (UsbManager) mContext.getSystemService(Context.USB_SERVICE);
- if (m.hasPermission(device)) {
- openUsb(device);
- }
- }
- } break;
-
- case FaBoConst.DEVICE_TO_ARDUINO_CHECK_USB:
- case UsbManager.ACTION_USB_DEVICE_ATTACHED: {
- UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
- if (device != null) {
- UsbManager m = (UsbManager) mContext.getSystemService(Context.USB_SERVICE);
- if (m.hasPermission(device)) {
- openUsb(device);
- } else {
- if (mRequestPermission) {
- // 既に許可のリクエストを投げている場合に処理しない
- return;
- }
- mRequestPermission = true;
-
- Intent i = new Intent(FaBoConst.DEVICE_TO_ARDUINO_OPEN_USB);
- PendingIntent p = PendingIntent.getBroadcast(context, 0, i, 0);
- m.requestPermission(device, p);
- }
- }
- } break;
-
- case FaBoConst.DEVICE_TO_ARDUINO_CLOSE_USB:
- case UsbManager.ACTION_USB_DEVICE_DETACHED:
- closeUsb();
- break;
- }
- }
- };
-
- /**
- * I2Cへの書き込みを行います.
- * @param buffer 書き込むバッファ
- */
- void writeI2C(final byte[] buffer) {
- sendMessage(buffer);
- }
-
- /**
- * メッセージの送信
- *
- * @param buf Byte型のメッセージ
- */
- private synchronized void sendMessage(final byte[] buf) {
- if (buf != null && mFaBoUsbManager != null) {
- mFaBoUsbManager.writeBuffer(buf);
- }
- }
-
- /**
- * Portの状態の保存.
- *
- * @param port Port番号
- * @param status Portのステータス
- */
- private void setPortStatus(final int port, final int status) {
- mDigitalPortStatus[port] = status;
- }
-
- /**
- * Portの状態の取得.
- *
- * @param port Port番号
- */
- private int getPortStatus(final int port) {
- return mDigitalPortStatus[port];
- }
-
- /**
- * FaBoデバイスと接続されたことを通知します.
- */
- private void notifyConnectFaBoDevice() {
- if (mOnFaBoDeviceControlListener != null) {
- mOnFaBoDeviceControlListener.onConnected();
- }
- }
-
- /**
- * FaBoデバイスが切断されたことを通知します.
- */
- private void notifyDisconnectFaBoDevice() {
- if (mOnFaBoDeviceControlListener != null) {
- mOnFaBoDeviceControlListener.onDisconnected();
- }
- }
-
- /**
- * アナログのピンデータが変更されたことを通知します.
- */
- private void notifyAnalog() {
- synchronized (mOnGPIOListeners) {
- for (OnGPIOListener l : mOnGPIOListeners) {
- l.onAnalog();
- }
- }
- }
-
- /**
- * デジタルのピンデータが変更されたことを通知します.
- */
- private void notifyDigital() {
- synchronized (mOnGPIOListeners) {
- for (OnGPIOListener l : mOnGPIOListeners) {
- l.onDigital();
- }
- }
- }
-
- /**
- * REPORT_VERIONの解析を行います.
- * @param data データ
- */
- private void reportVersion(final byte[] data) {
- if (DEBUG) {
- Log.i(TAG, "REPORT_VERSION");
- Log.i(TAG, " Version: " + data[0] + "." + data[1]);
- }
-
- if ((byte) (data[0] & 0xFF) == (byte) VERSION[0] && (byte) (data[1] & 0xFF) == (byte) VERSION[1]) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- setStatus(FaBoConst.STATUS_FABO_RUNNING);
- intFirmata();
- notifyConnectFaBoDevice();
- }
- }).start();
- } else {
- if (DEBUG) {
- Log.w(TAG, "Not support version.");
- }
- }
- }
-
- /**
- * Arduinoから送られてきたアナログのデータを設定します.
- * @param port ピン番号
- * @param value 値
- */
- private void setAnalogData(final int port, final int value) {
- if (port < 7) {
- FaBoShield.Pin p = FaBoShield.Pin.getPin(port + 14);
- if (p != null) {
- p.setValue(value);
- }
- notifyAnalog();
- }
- }
-
- /**
- * Arduinoから送られてきたデジタルのデータを設定します.
- * @param port ピン番号
- * @param value 値
- */
- private void setDigitalData(final int port, final int value) {
- if (port < 3) {
- mDigitalPortStatus[port] = value;
- notifyDigital();
- }
- }
-
- /**
- * sysex messageを解析します.
- * @param data sysex messageのデータ
- */
- private void parseSysExMessage(final byte[] data) {
- switch (data[0]) {
- case FirmataV32.REPORT_FIRMWARE:
- break;
-
- case FirmataV32.I2C_REPLY:
- int offset = 1;
- int address = decodeByte(data[offset++], data[offset]);
- for (BaseI2C i2c : mI2CList) {
- if (address == i2c.getAddress()) {
- i2c.onReadData(data);
- }
- }
- break;
-
- case FirmataV32.STRING_DATA:
- if (DEBUG) {
- Log.i(TAG, "FirmataV32.STRING_DATA");
- Log.i(TAG, FirmataUtil.decodeString(data, 1, data.length));
- }
- break;
-
- default:
- if (DEBUG) {
- Log.e(TAG, "Unknown: " + data[0]);
- }
- break;
- }
- }
-
- /**
- * Arduinoから読み込んだデータを処理します.
- * @param inputData 読み込んだデータ
- */
- private void processInput(final byte inputData) {
- if (mParsingSysex) {
- if (inputData == END_SYSEX) {
- parseSysExMessage(mStoredInputData.toByteArray());
- mParsingSysex = false;
- } else {
- mStoredInputData.write(inputData);
- }
- } else if (mWaitForData > 0 && (inputData & 0x80) != 0x80) {
- mWaitForData--;
- mStoredInputData.write(inputData);
-
- if (mWaitForData == 0) {
- switch (mCommand) {
- case DIGITAL_MESSAGE:
- setDigitalData(mChannel, FirmataUtil.decodeByte(mStoredInputData.toByteArray()));
- break;
- case ANALOG_MESSAGE:
- setAnalogData(mChannel, FirmataUtil.decodeByte(mStoredInputData.toByteArray()));
- break;
- case REPORT_VERSION:
- reportVersion(mStoredInputData.toByteArray());
- break;
- }
- }
- } else {
- byte command;
- if ((inputData & 0xFF) < 0xF0) {
- command = (byte) (inputData & 0xF0);
- } else {
- command = inputData;
- }
-
- switch (command) {
- case START_SYSEX:
- mParsingSysex = true;
- mStoredInputData.reset();
- break;
-
- case DIGITAL_MESSAGE:
- case ANALOG_MESSAGE:
- case REPORT_VERSION:
- mWaitForData = 2;
- mStoredInputData.reset();
- mCommand = command;
- mChannel = (byte) (inputData & 0x0F);
- break;
- }
- }
- }
-
- /**
- * FaBoUsbManagerからの通知を受け取るリスナー.
- */
- private FaBoUsbListenerInterface mInterface = new FaBoUsbListenerInterface() {
-
- @Override
- public void onFind(final UsbDevice usbDevice, final int type) {
- if (DEBUG) {
- Log.i(TAG, "onFind:" + usbDevice.getDeviceName());
- Log.i(TAG, "onFind: type = " + type);
- }
- }
-
- @Override
- public void onStatusChanged(final UsbDevice usbDevice, final int status) {
- if (DEBUG) {
- Log.i(TAG, "onStatusChanged: status=" + status + " device=" + usbDevice.getDeviceName());
- }
-
- if (status == FaBoUsbConst.CONNECTED) {
- if (DEBUG) {
- Log.i(TAG, "onStatusChanged:CONNECTED");
- }
- onDeviceStateChange();
- }
- }
-
- @Override
- public void readBuffer(final int deviceId, final byte[] datas) {
-
-// if (DEBUG) {
-// final StringBuilder sb = new StringBuilder();
-// for (byte data : datas) {
-// sb.append(Integer.toHexString(data & 0xff));
-// sb.append(" ");
-// }
-// Log.i(TAG, " readBuffer: " + sb.toString());
-// }
-
- try {
- for (byte data : datas) {
- processInput(data);
- }
- } catch (OutOfMemoryError e) {
- mStoredInputData = new ByteArrayOutputStream();
- mParsingSysex = false;
- } catch (Exception e) {
- mStoredInputData.reset();
- mParsingSysex = false;
- }
- }
- };
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/FirmataUtil.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/FirmataUtil.java
deleted file mode 100644
index 84f0d0f8e4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/FirmataUtil.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-final class FirmataUtil {
-
- private FirmataUtil() {
- }
-
- /**
- * 送られてきたデータをbyteに変換して取得します.
- *
- * 2byteを1byteにします。
- *
- * @param buffer データ
- * @return byteデータ
- */
- static int decodeByte(final byte[] buffer) {
- return decodeByte(buffer, 0);
- }
-
- /**
- * 送られてきたデータをbyteに変換して取得します.
- *
- * 2byteを1byteにします。
- *
- * @param buffer データ
- * @param startIndex オフセット
- * @return byteデータ
- */
- static int decodeByte(final byte[] buffer, final int startIndex) {
- int offset = startIndex;
- return decodeByte(buffer[offset++], buffer[offset]);
- }
-
- /**
- * 下位ビットと上位ビットを合わせてbyteデータに変換します.
- * @param lsb 下位ビット
- * @param msb 上位ビット
- * @return byteデータ
- */
- static int decodeByte(final int lsb, final int msb) {
- return (msb << 7) + lsb;
- }
-
- /**
- * 送られてきたデータを文字列に変換して取得します.
- * @param buffer 送られてきたデータ
- * @param startIndex 開始位置
- * @param endIndex 修了位置
- * @return 文字列
- */
- static String decodeString(final byte[] buffer, final int startIndex, final int endIndex) {
- StringBuilder sb = new StringBuilder();
- int offset = startIndex;
- int length = (endIndex - startIndex + 1) / 2;
- for (int i = 0; i < length; i++) {
- sb.append((char) decodeByte(buffer[offset++], buffer[offset++]));
- }
- return sb.toString();
- }
-
- /**
- * 送られてきたデータをshortに変換して取得します.
- *
- * 4byteをshortにします。
- *
- *
- * リトルエンディアン.
- *
- * @param buffer 送られてきたデータ
- * @param startIndex 開始位置
- * @return shortデータ
- */
- static int decodeShort(final byte[] buffer, final int startIndex) {
- int offset = startIndex;
- byte lsb = (byte) (decodeByte(buffer[offset++], buffer[offset++]) & 0xFF);
- byte msb = (byte) (decodeByte(buffer[offset++], buffer[offset]) & 0xFF);
- return ((msb << 8) | (lsb & 0xFF));
- }
-
- /**
- * 送られてきたデータをshortに変換して取得します.
- *
- * 4byteをshortにします。
- *
- *
- * ビックエンディアン.
- *
- * @param buffer 送られてきたデータ
- * @param startIndex 開始位置
- * @return shortデータ
- */
- static int decodeShort2(final byte[] buffer, final int startIndex) {
- int offset = startIndex;
- byte lsb = (byte) (decodeByte(buffer[offset++], buffer[offset++]) & 0xFF);
- byte msb = (byte) (decodeByte(buffer[offset++], buffer[offset]) & 0xFF);
- return (lsb << 8 | (msb & 0xFF));
- }
-
- /**
- * 送られてきたデータをshortに変換して取得します.
- *
- * 4byteをunsigned shortにします。
- *
- *
- * ビックエンディアン.
- *
- * @param buffer 送られてきたデータ
- * @param startIndex 開始位置
- * @return shortデータ
- */
- static int decodeUShort2(final byte[] buffer, final int startIndex) {
- int offset = startIndex;
- byte lsb = (byte) (decodeByte(buffer[offset++], buffer[offset++]) & 0xFF);
- byte msb = (byte) (decodeByte(buffer[offset++], buffer[offset]) & 0xFF);
- return ((lsb & 0xFF) << 8 | (msb & 0xFF));
- }
-
- static int dataConv(final int data1, final int data2) {
- int value = data1 | (data2 << 8);
- if ((value & (1 << 16 - 1)) != 0) {
- value -= (1 << 16);
- }
- return value;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/FirmataV32.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/FirmataV32.java
deleted file mode 100644
index bc49dd9f35..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/FirmataV32.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- FirmataV32.java
- Copyright (c) 2014 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-/**
- * Firmata version 3.2のCommand.
- *
- */
-class FirmataV32 {
-
- // Firmata Buadrate
- public static final int BAUDRATE = 57600;
-
- // message command bytes (128-255/0x80-0xFF)
-
- public static final byte DIGITAL_MESSAGE = (byte)0x90; // send data for a digital port (collection of 8 pins)
- public static final byte ANALOG_MESSAGE = (byte)0xE0; // send data for an analog pin (or PWM)
- public static final byte REPORT_ANALOG = (byte)0xC0; // enable analog input by pin #
- public static final byte REPORT_DIGITAL = (byte)0xD0; // enable digital input by port pair
-
- public static final byte SET_PIN_MODE = (byte)0xF4; // set a pin to INPUT/OUTPUT/PWM/etc
- public static final byte SET_DIGITAL_PIN_VALUE = (byte)0xF5; // set value of an individual digital pin
-
- public static final byte REPORT_VERSION = (byte)0xF9; // report protocol version
- public static final byte SYSTEM_RESET = (byte)0xFF; // reset from MIDI
-
- public static final byte START_SYSEX = (byte)0xF0; // start a MIDI Sysex message
- public static final byte END_SYSEX = (byte)0xF7; // end a MIDI Sysex message
-
- // extended command set using sysex (0-127/0x00-0x7F)
- // 0x00-0x0F reserved for user-defined commands
-
- public static final byte SERIAL_DATA = 0x60; // communicate with serial devices, including other boards
- public static final byte ENCODER_DATA = 0x61; // reply with encoders current positions
- public static final byte SERVO_CONFIG = 0x70; // set max angle, minPulse, maxPulse, freq
- public static final byte STRING_DATA = 0x71; // a string message with 14-bits per char
- public static final byte STEPPER_DATA = 0x72; // control a stepper motor
- public static final byte ONEWIRE_DATA = 0x73; // send an OneWire read/write/reset/select/skip/search request
- public static final byte SHIFT_DATA = 0x75; // a bitstream to/from a shift register
- public static final byte I2C_REQUEST = 0x76; // send an I2C read/write request
- public static final byte I2C_REPLY = 0x77; // a reply to an I2C read request
- public static final byte I2C_CONFIG = 0x78; // config I2C settings such as delay times and power pins
- public static final byte REPORT_FIRMWARE = 0x79; // report name and version of the firmware
- public static final byte EXTENDED_ANALOG = 0x6F; // analog write (PWM, Servo, etc) to any pin
- public static final byte PIN_STATE_QUERY = 0x6D; // ask for a pin's current mode and value
- public static final byte PIN_STATE_RESPONSE = 0x6E; // reply with pin's current mode and value
- public static final byte CAPABILITY_QUERY = 0x6B; // ask for supported modes and resolution of all pins
- public static final byte CAPABILITY_RESPONSE = 0x6C; // reply with supported modes and resolution
- public static final byte ANALOG_MAPPING_QUERY = 0x69; // ask for mapping of analog to pin numbers
- public static final byte ANALOG_MAPPING_RESPONSE = 0x6A; // reply with mapping info
- public static final byte SAMPLING_INTERVAL = 0x7A; // set the poll rate of the main loop
- public static final byte SCHEDULER_DATA = 0x7B; // send a createtask/deletetask/addtotask/schedule/querytasks/querytask request to the scheduler
- public static final byte SYSEX_NON_REALTIME = 0x7E; // MIDI Reserved for non-realtime messages
- public static final byte SYSEX_REALTIME = 0x7F; // MIDI Reserved for realtime messages
-
- // Param
- public static final byte DISABLE = (byte)0x00;
- public static final byte ENABLE = (byte)0x01;
-
- // I2C
- public static final byte I2C_WRITE = 0x00;
- public static final byte I2C_READ = 0x08;
- public static final byte I2C_READ_CONTINUOUSLY = 0x10;
- public static final byte I2C_STOP_READING = 0x18;
-}
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/HTS221.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/HTS221.java
deleted file mode 100644
index ea71ca5cbf..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/HTS221.java
+++ /dev/null
@@ -1,526 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IHTS221;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataUtil.decodeByte;
-
-class HTS221 extends BaseI2C implements IHTS221 {
-
- /**
- * HTS221のアドレス.
- */
- private static final byte HTS221_SLAVE_ADDRESS = 0x5F;
-
- /**
- * HTS221のデバイスID.
- */
- private static final int DEVICE_ID = 0xBC;
-
- // AV_CONF:AVGH
- // Averaged humidity samples configuration
- // AVGH_4 : 0b00000000
- private static final byte AVGH_4 = 0x00;
- // AVGH_8 : 0b00000001
- private static final byte AVGH_8 = 0x01;
- // AVGH_16 : 0b00000010
- private static final byte AVGH_16 = 0x02;
- // AVGH_32 : 0b00000011 // defalut
- private static final byte AVGH_32 = 0x03;
- // AVGH_64 : 0b00000100
- private static final byte AVGH_64 = 0x04;
- // AVGH_128 : 0b00000101
- private static final byte AVGH_128 = 0x05;
- // AVGH_256 : 0b00000110
- private static final byte AVGH_256 = 0x06;
- // AVGH_512 : 0b00000111
- private static final byte AVGH_512 = 0x07;
-
- // AV_CONF:AVGT
- // Averaged temperature samples configuration
- // AVGT_2 : 0b00000000
- private static final byte AVGT_2 = 0x00;
- // AVGT_4 : 0b00001000
- private static final byte AVGT_4 = 0x08;
- // AVGT_8 : 0b00010000
- private static final byte AVGT_8 = 0x10;
- // AVGT_16 : 0b00011000 // defalut
- private static final byte AVGT_16 = 0x18;
- // AVGT_32 : 0b00100000
- private static final byte AVGT_32 = 0x20;
- // AVGT_64 : 0b00101000
- private static final byte AVGT_64 = 0x28;
- // AVGT_128 : 0b00110000
- private static final byte AVGT_128 = 0x30;
- // AVGT_256 : 0b00111000
- private static final byte AVGT_256 = 0x38;
-
- // CTRL_REG1
- // Power Down control : 0b10000000
- private static final byte PD = (byte) 0x80;
- // Block Data Update control : 0b00000100
- private static final byte BDU = 0x04;
- // Output Data Rate : One Shot : 0b00000000
- private static final byte ODR_ONE = 0x00;
- // Output Data Rate : 1Hz : 0b00000001
- private static final byte ODR_1HZ = 0x01;
- // Output Data Rate : 7Hz : 0b00000010
- private static final byte ODR_7HZ = 0x02;
- // Output Data Rate : 12.5Hz : 0b00000011
- private static final byte ODR_125HZ = 0x03;
-
- // CTRL_REG2
- // Reboot memory content : 0b10000000
- private static final byte BOOT = (byte) 0x80;
- // Heater : 0b00000010
- private static final byte HEATER = 0x02;
- // One shot enable : 0b00000001
- private static final byte ONE_SHOT = 0x01;
-
- // CTRL_REG3
- // DRDY pin is no connect in FaBo Brick
- private static final byte CTRL_REG3_DEFAULT = 0x00;
-
- // REGISTER_STATUS_REG
- // Humidity Data Available
- private static final byte H_DA = 0x02;
- // Temperature Data Available
- private static final byte T_DA = 0x01;
-
- private static final int REGISTER_DEVICE_REG = 0x0F;
- private static final int REGISTER_AV_CONF = 0x10;
- private static final int REGISTER_CTRL_REG1 = 0x20;
- private static final int REGISTER_CTRL_REG2 = 0x21;
- private static final int REGISTER_CTRL_REG3 = 0x22;
- private static final int REGISTER_STATUS_REG = 0x27;
- private static final int REGISTER_HUMIDITY_OUT_L = 0x28;
- private static final int REGISTER_HUMIDITY_OUT_H = 0x29;
- private static final int REGISTER_TEMP_OUT_L = 0x2A;
- private static final int REGISTER_TEMP_OUT_H = 0x2B;
- private static final int REGISTER_H0_RH_X2 = 0x30;
- private static final int REGISTER_H1_RH_X2 = 0x31;
- private static final int REGISTER_T0_DEGC_X8 = 0x32;
- private static final int REGISTER_T1_DEGC_X8 = 0x33;
- private static final int REGISTER_T1_T0_MSB = 0x35;
- private static final int REGISTER_H0_T0_OUT_L = 0x36;
- private static final int REGISTER_H0_T0_OUT_H = 0x37;
- private static final int REGISTER_H1_T0_OUT_L = 0x3A;
- private static final int REGISTER_H1_T0_OUT_H = 0x3B;
- private static final int REGISTER_T0_OUT_L = 0x3C;
- private static final int REGISTER_T0_OUT_H = 0x3D;
- private static final int REGISTER_T1_OUT_L = 0x3E;
- private static final int REGISTER_T1_OUT_H = 0x3F;
-
- private List mOnHumidityCallbacks = new ArrayList<>();
- private List mOnTemperatureCallbacks = new ArrayList<>();
-
- private Humidity mHumidity = new Humidity();
- private Temperature mTemperature = new Temperature();
-
- @Override
- public synchronized void readHumidity(final OnHumidityCallback callback) {
- mOnHumidityCallbacks.add(callback);
-
- if (mHumidity.isMeasuring()) {
- return;
- }
- mHumidity.start();
- }
-
- @Override
- public synchronized void readTemperature(final OnTemperatureCallback callback) {
- mOnTemperatureCallbacks.add(callback);
-
- if (mTemperature.isMeasuring()) {
- return;
- }
- mTemperature.start();
- }
-
- @Override
- byte getAddress() {
- return HTS221_SLAVE_ADDRESS;
- }
-
- @Override
- synchronized void onReadData(final byte[] data) {
- int offset = 3;
- int register = decodeByte(data[offset++], data[offset]);
- switch (register) {
- case REGISTER_DEVICE_REG:
- mHumidity.onReadData(data, register);
- mTemperature.onReadData(data, register);
- break;
-
- // humidity
-
- case REGISTER_H0_RH_X2:
- case REGISTER_H1_RH_X2:
- case REGISTER_H0_T0_OUT_L:
- case REGISTER_H0_T0_OUT_H:
- case REGISTER_H1_T0_OUT_L:
- case REGISTER_H1_T0_OUT_H:
- case REGISTER_HUMIDITY_OUT_L:
- case REGISTER_HUMIDITY_OUT_H:
- mHumidity.onReadData(data, register);
- break;
-
- // temperature
-
- case REGISTER_T1_T0_MSB:
- case REGISTER_T0_DEGC_X8:
- case REGISTER_T1_DEGC_X8:
- case REGISTER_T0_OUT_L:
- case REGISTER_T0_OUT_H:
- case REGISTER_T1_OUT_L:
- case REGISTER_T1_OUT_H:
- case REGISTER_TEMP_OUT_L:
- case REGISTER_TEMP_OUT_H:
- mTemperature.onReadData(data, register);
- break;
-
- case REGISTER_STATUS_REG:
- break;
- }
- }
-
- private void powerOn() {
- write(HTS221_SLAVE_ADDRESS, REGISTER_CTRL_REG1, PD | ODR_1HZ);
- }
-
- private void configDevice() {
- write(HTS221_SLAVE_ADDRESS, REGISTER_AV_CONF, AVGH_32 | AVGT_16);
- }
-
- private int dataConv(int data1, int data2) {
- int value = (data1 & 0xff) | ((data2 & 0xff) << 8);
- if ((value & 0x8000) != 0) {
- value -= (1 << 16);
- }
- return value;
- }
-
- private abstract class HTSS221State {
-
- /**
- * 現在のステート.
- *
- * 現在、取得しているレジスタの番号になります。
- *
- */
- int mState = -1;
-
- /**
- * タイムアウトを監視するタイマー.
- */
- private Timer mTimer;
-
- /**
- * 湿度の計測中フラグ.
- * @return 計測中の場合にはtrue、それ以外はfalse
- */
- boolean isMeasuring() {
- return mState != -1;
- }
-
- /**
- * 湿度の計測を開始します.
- */
- void start() {
- setI2CConfig();
-
- mTimer = new Timer();
- mTimer.schedule(new TimerTask() {
- @Override
- public void run() {
- onError("timeout");
- }
- }, 1000);
-
- next(REGISTER_DEVICE_REG);
- }
-
- /**
- * 次のレジスタの値を取得します.
- * @param register 次に取得するレジスタ
- */
- void next(final int register) {
- mState = register;
- read(HTS221_SLAVE_ADDRESS, register, 1);
- }
-
- /**
- * エラーが発生した場合の処理を行います.
- * @param message エラーメッセージ
- */
- void onError(final String message) {
- onFinish();
- }
-
- /**
- * 後始末処理を行います.
- */
- void onFinish() {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer = null;
- }
- mState = -1;
- }
-
- /**
- * HTS221から送られてきたデータを解析して、次のステップに進みます.
- * @param data 送られてきたデータ
- * @param register レジスタ番号
- */
- abstract void onReadData(final byte[] data, final int register);
- }
-
-
- /**
- * HTS221から湿度を取得するためのステートを管理するクラス.
- */
- private class Humidity extends HTSS221State {
-
- private int h0_rh_x2;
- private int h1_rh_x2;
- private int h0_t0_l;
- private int h0_t0_h;
- private int h1_t0_l;
- private int h1_t0_h;
-
- private int humidity_out_l;
- private int humidity_out_h;
-
- /**
- * HTS221から送られてきたデータを湿度に変換します.
- * @return 変換した湿度
- */
- private double convertHumidity() {
- int h_out = dataConv(humidity_out_l, humidity_out_h);
-
- double t_H0_rH = h0_rh_x2 / 2.0;
- double t_H1_rH = h1_rh_x2 / 2.0;
-
- int h0_t0_out = dataConv(h0_t0_l, h0_t0_h);
- int h1_t0_out = dataConv(h1_t0_l, h1_t0_h);
-
- return t_H0_rH + (t_H1_rH - t_H0_rH) * (h_out - h0_t0_out) / (h1_t0_out - h0_t0_out);
- }
-
- /**
- * 取得した湿度の値を配信します.
- */
- private void onReadHumidity() {
- double humidity = convertHumidity();
- for (OnHumidityCallback callback : mOnHumidityCallbacks) {
- callback.onHumidity(humidity);
- }
- mOnHumidityCallbacks.clear();
- onFinish();
- }
-
- @Override
- void onError(final String message) {
- for (OnHumidityCallback callback : mOnHumidityCallbacks) {
- callback.onError(message);
- }
- mOnHumidityCallbacks.clear();
- super.onError(message);
- }
-
- @Override
- void onReadData(final byte[] data, final int register) {
-
- if (mState != register) {
- // レジスタが一致しない場合には、不正なデータなので無視
- return;
- }
-
- int offset = 5;
- switch(register) {
- case REGISTER_DEVICE_REG:
- int deviceId = decodeByte(data[offset++], data[offset]);
- if (deviceId == DEVICE_ID) {
- powerOn();
- configDevice();
- next(REGISTER_H0_RH_X2);
- } else {
- onError("HTS221 is not connect.");
- }
- break;
-
- case REGISTER_H0_RH_X2:
- h0_rh_x2 = decodeByte(data[offset++], data[offset]);
- next(REGISTER_H1_RH_X2);
- break;
-
- case REGISTER_H1_RH_X2:
- h1_rh_x2 = decodeByte(data[offset++], data[offset]);
- next(REGISTER_H0_T0_OUT_L);
- break;
-
- case REGISTER_H0_T0_OUT_L:
- h0_t0_l = decodeByte(data[offset++], data[offset]);
- next(REGISTER_H0_T0_OUT_H);
- break;
-
- case REGISTER_H0_T0_OUT_H:
- h0_t0_h = decodeByte(data[offset++], data[offset]);
- next(REGISTER_H1_T0_OUT_L);
- break;
-
- case REGISTER_H1_T0_OUT_L:
- h1_t0_l = decodeByte(data[offset++], data[offset]);
- next(REGISTER_H1_T0_OUT_H);
- break;
-
- case REGISTER_H1_T0_OUT_H:
- h1_t0_h = decodeByte(data[offset++], data[offset]);
- next(REGISTER_HUMIDITY_OUT_L);
- break;
-
- case REGISTER_HUMIDITY_OUT_L:
- humidity_out_l = decodeByte(data[offset++], data[offset]);
- next(REGISTER_HUMIDITY_OUT_H);
- break;
-
- case REGISTER_HUMIDITY_OUT_H:
- humidity_out_h = decodeByte(data[offset++], data[offset]);
- onReadHumidity();
- break;
- }
- }
- }
-
- /**
- * HTS221から温度を取得するためのステートを管理するクラス.
- */
- private class Temperature extends HTSS221State {
-
- private int t1_t0_msb;
-
- private int t0_degc_x8;
- private int t1_degc_x8;
-
- private int t0_l;
- private int t0_h;
-
- private int t1_l;
- private int t1_h;
-
- private int temp_out_l;
- private int temp_out_h;
-
- /**
- * HTS221から送られてきたデータを温度に変換します.
- * @return 変換した温度
- */
- private double convertTemperature() {
- int t_out = dataConv(temp_out_l, temp_out_h);
-
- double t_T0_degC = t0_degc_x8 / 8.0;
- double t_T1_degC = t1_degc_x8 / 8.0;
-
- int t0_out = dataConv(t0_l, t0_h);
- int t1_out = dataConv(t1_l, t1_h);
-
- return t_T0_degC + (t_T1_degC - t_T0_degC) * (t_out - t0_out) / (t1_out - t0_out);
- }
-
- /**
- * 計測した結果を配信します.
- */
- private void onReadTemperature() {
- double temperature = convertTemperature();
- for (OnTemperatureCallback callback : mOnTemperatureCallbacks) {
- callback.onTemperature(temperature);
- }
- mOnTemperatureCallbacks.clear();
- onFinish();
- }
-
- @Override
- void onError(final String message) {
- for (OnTemperatureCallback callback : mOnTemperatureCallbacks) {
- callback.onError(message);
- }
- mOnTemperatureCallbacks.clear();
- super.onError(message);
- }
-
- @Override
- void onReadData(final byte[] data, final int register) {
-
- if (mState != register) {
- // レジスタが一致しない場合には、不正なデータなので無視
- return;
- }
-
- int offset = 5;
- switch (register) {
- case REGISTER_DEVICE_REG:
- int deviceId = decodeByte(data[offset++], data[offset]);
- if (deviceId == DEVICE_ID) {
- powerOn();
- configDevice();
- next(REGISTER_T1_T0_MSB);
- } else {
- onError("HTS221 is not connect.");
- }
- break;
-
- case REGISTER_T1_T0_MSB:
- t1_t0_msb = decodeByte(data[offset++], data[offset]);
- next(REGISTER_T0_DEGC_X8);
- break;
-
- case REGISTER_T0_DEGC_X8:
- int a = decodeByte(data[offset++], data[offset]);
- t0_degc_x8 = ((t1_t0_msb & 0x3) << 8) | a;
- next(REGISTER_T1_DEGC_X8);
- break;
-
- case REGISTER_T1_DEGC_X8:
- int b = decodeByte(data[offset++], data[offset]);
- t1_degc_x8 = ((t1_t0_msb & 0xC) << 6) | b;
- next(REGISTER_T0_OUT_L);
- break;
-
- case REGISTER_T0_OUT_L:
- t0_l = decodeByte(data[offset++], data[offset]);
- next(REGISTER_T0_OUT_H);
- break;
-
- case REGISTER_T0_OUT_H:
- t0_h = decodeByte(data[offset++], data[offset]);
- next(REGISTER_T1_OUT_L);
- break;
-
- case REGISTER_T1_OUT_L:
- t1_l = decodeByte(data[offset++], data[offset]);
- next(REGISTER_T1_OUT_H);
- break;
-
- case REGISTER_T1_OUT_H:
- t1_h = decodeByte(data[offset++], data[offset]);
- next(REGISTER_TEMP_OUT_L);
- break;
-
- case REGISTER_TEMP_OUT_L:
- temp_out_l = decodeByte(data[offset++], data[offset]);
- next(REGISTER_TEMP_OUT_H);
- break;
-
- case REGISTER_TEMP_OUT_H:
- temp_out_h = decodeByte(data[offset++], data[offset]);
- onReadTemperature();
- break;
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/ISL29034.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/ISL29034.java
deleted file mode 100644
index edc9389d8c..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/ISL29034.java
+++ /dev/null
@@ -1,285 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IISL29034;
-
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataUtil.decodeByte;
-
-class ISL29034 extends BaseI2C implements IISL29034 {
-
- // ISL29034 I2C Slave Address
- private static final byte SLAVE_ADDRESS = 0x44;
-
- // ISL29034 Device ID(xx101xxx)
- private static final int DEVICE_ID = 0x28;
-
- // Register Addresses
- private static final int REG_CMD1 = 0x00;
- private static final int REG_CMD2 = 0x01;
- private static final int REG_DATA_L = 0x02;
- private static final int REG_DATA_H = 0x03;
- private static final int REG_ID = 0x0F;
-
- // Operation Mode
- private static final int OP_PWR_DOWN = 0x00; // Power-down the device(Default)
- private static final int OP_ALS_CONT = 0xA0; // Measures ALS continuously
-
- // FULL SCALE LUX RANGE
- private static final int FS_0 = 0x00; // 1,000(Default)
- private static final int FS_1 = 0x01; // 4,000
- private static final int FS_2 = 0x02; // 16,000
- private static final int FS_3 = 0x03; // 64,000
-
- // ADC RESOLUTION
- private static final int RES_16 = 0x00; // 16bit(Default)
- private static final int RES_12 = 0x04; // 12bit
- private static final int RES_8 = 0x08; // 8bit
- private static final int RES_4 = 0x0C; // 4bit
-
- private static final int ID_MASK = 0x38; // ISL29034 Device ID Mask(00111000)
-
- /**
- * ISL29034に設定する範囲.
- */
- private int mRange = FS_0;
-
- /**
- * ISL29034に設定する解像度.
- */
- private int mResolution = RES_4;
-
- /**
- * 通知するリスナーのリスト.
- */
- private final List mListeners = new CopyOnWriteArrayList<>();
-
- /**
- * 現在のステート.
- *
- * 現在、取得しているレジスタの番号になります。
- *
- */
- private int mState = -1;
-
- /**
- * タイムアウトを監視するタイマー.
- */
- private Timer mTimer;
-
- @Override
- public void read(final OnAmbientLightListener listener) {
- mListeners.add(listener);
-
- if (mState != -1) {
- return;
- }
- mState = REG_ID;
-
- mTimer = new Timer();
- mTimer.schedule(new TimerTask() {
- @Override
- public void run() {
- onError("timeout");
- }
- }, 1000);
-
- setI2CConfig();
- read(SLAVE_ADDRESS, REG_ID, 1);
- }
-
- @Override
- public void startRead(final OnAmbientLightListener listener) {
-
- }
-
- @Override
- public void stopRead(final OnAmbientLightListener listener) {
-
- }
-
- /**
- * 範囲の値を取得します.
- * @return 範囲
- */
- private int getRange() {
- switch (mRange) {
- case FS_0:
- return 1000;
- case FS_1:
- return 4000;
- case FS_2:
- return 16000;
- case FS_3:
- return 64000;
- default:
- return -1;
- }
- }
-
- /**
- * 解像度の値を取得します.
- * @return 解像度
- */
- private int getResolution() {
- switch (mResolution) {
- case RES_16:
- return 65535;
- case RES_12:
- return 4095;
- case RES_8:
- return 255;
- case RES_4:
- return 15;
- default:
- return -1;
- }
- }
-
- /**
- * ISL29034の設定を行います.
- */
- private void setISL29034() {
- setOperation(OP_ALS_CONT);
- setCMD2(FS_3, RES_16);
- }
-
- /**
- * Set Operation Mode.
- * @param config Operation Mode DEFAULT:Power-down the device
- */
- private void setOperation(int config) {
- write(SLAVE_ADDRESS, REG_CMD1, config);
- }
-
- /**
- * CMD2にrangeとresolutionを設定します.
- * @param range luxの範囲
- * @param resolution 解像度
- */
- private void setCMD2(final int range, final int resolution) {
- mRange = range;
- mResolution = resolution;
- mState = REG_CMD2;
- read(SLAVE_ADDRESS, REG_CMD2, 1);
- }
-
- /**
- * CMD2の設定をISL29034に送信します.
- * @param value ISL29034の設定
- */
- private void writeCMD2(byte value) {
- value &= 0xFC;
- value |= mRange;
-
- value &= 0xF3;
- value |= mResolution;
-
- write(SLAVE_ADDRESS, REG_CMD2, value);
- }
-
- /**
- * Analog to Digital Converterの値を読み込みます.
- */
- private void readADC() {
- mState = REG_DATA_L;
- read(SLAVE_ADDRESS, REG_DATA_L, 2);
- }
-
- /**
- * Analog to Digital Converterの値をluxに変換します.
- * @param adc Analog to Digital Converterの値
- * @return lux
- */
- private float convert(final int adc) {
- int range = getRange();
- int count = getResolution();
- return (range / (float) count) * adc;
- }
-
- /**
- * Luxの値を通知します.
- * @param adc Analog to Digital Converterの値
- */
- private void notifyLux(final int adc) {
- float lux = convert(adc);
- for (OnAmbientLightListener listener : mListeners) {
- listener.onData(lux);
- }
- mListeners.clear();
- mState = -1;
- cancelTimer();
- }
-
- /**
- * エラーが発生したことを通知します.
- * @param message エラーメッセージ
- */
- private void onError(final String message) {
- for (OnAmbientLightListener listener : mListeners) {
- listener.onError(message);
- }
- mListeners.clear();
- mState = -1;
- cancelTimer();
- }
-
- /**
- * タイマーをキャンセルします.
- */
- private void cancelTimer() {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer = null;
- }
- }
-
- @Override
- byte getAddress() {
- return SLAVE_ADDRESS;
- }
-
- @Override
- void onReadData(final byte[] data) {
- int offset = 3;
- int register = decodeByte(data[offset++], data[offset++]);
- switch (register) {
- case REG_ID:
- int deviceId = decodeByte(data[offset++], data[offset]);
- if ((deviceId & ID_MASK) == DEVICE_ID) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- setISL29034();
- }
- }).start();
- } else {
- onError("ISL29034 is not connect.");
- }
- break;
-
- case REG_CMD2:
- final int cmd = decodeByte(data[offset++], data[offset]);
- new Thread(new Runnable() {
- @Override
- public void run() {
- writeCMD2((byte) cmd);
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- readADC();
- }
- }).start();
- break;
-
- case REG_DATA_L:
- notifyLux(FirmataUtil.decodeShort(data, offset));
- break;
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/LIDARLiteV3.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/LIDARLiteV3.java
deleted file mode 100644
index 33bedf34f6..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/LIDARLiteV3.java
+++ /dev/null
@@ -1,258 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.ILIDARLiteV3;
-
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataUtil.decodeByte;
-
-class LIDARLiteV3 extends BaseI2C implements ILIDARLiteV3 {
-
- // I2C LIDARLite v3 Slave Address
- private static final byte SLAVE_ADDRESS = 0x62;
-
- private List mOnLIDARLiteListeners = new CopyOnWriteArrayList<>();
-
- @Override
- public void read(final OnLIDARLiteListener listener) {
- setI2CConfig();
- setLIDARLiteConfig(1);
-
- OnLIDARLiteListenerImpl impl = new OnLIDARLiteListenerImpl();
- impl.setListener(listener);
- impl.setOnceRead(true);
- impl.start();
- mOnLIDARLiteListeners.add(impl);
- }
-
- @Override
- public void startRead(final OnLIDARLiteListener listener) {
- setI2CConfig();
- setLIDARLiteConfig(1);
-
- OnLIDARLiteListenerImpl impl = new OnLIDARLiteListenerImpl();
- impl.setListener(listener);
- impl.setOnceRead(false);
- impl.start();
- mOnLIDARLiteListeners.add(impl);
- }
-
- @Override
- public void stopRead(final OnLIDARLiteListener listener) {
- OnLIDARLiteListenerImpl impl = get(listener);
- if (impl != null) {
- impl.stop();
- }
- }
-
- @Override
- byte getAddress() {
- return SLAVE_ADDRESS;
- }
-
- @Override
- void onReadData(byte[] data) {
- int offset = 3;
- int register = decodeByte(data[offset++], data[offset++]);
- switch (register) {
- case 0x8F:
- int distance = FirmataUtil.decodeUShort2(data, offset);
- for (OnLIDARLiteListener listener : mOnLIDARLiteListeners) {
- listener.onData(distance);
- }
-
- if (!mOnLIDARLiteListeners.isEmpty()) {
- // LIDARLiteは連続で読み込みができないので、
- // ここで、再度readを呼び出します。
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- Thread.sleep(33);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- startRead();
- }
- }).start();
- }
- break;
- }
- }
-
- /**
- * 指定されたリスナーをもつOnLIDARLiteListenerImplを取得します.
- * @param listener リスナー
- * @return OnLIDARLiteListenerImplのインスタンス
- */
- private OnLIDARLiteListenerImpl get(final OnLIDARLiteListener listener) {
- for (OnLIDARLiteListenerImpl impl : mOnLIDARLiteListeners) {
- if (impl.mListener == listener) {
- return impl;
- }
- }
- return null;
- }
-
- /**
- * LIDARLite v3の設定を行います.
- * @param configuration 設定番号
- */
- private synchronized void setLIDARLiteConfig(final int configuration) {
- switch (configuration) {
- case 0: // Default mode, balanced performance
- write(SLAVE_ADDRESS, 0x02, 0x80); // Default
- write(SLAVE_ADDRESS, 0x04, 0x08); // Default
- write(SLAVE_ADDRESS, 0x1C, 0x00); // Default
- break;
-
- case 1: // Short range, high speed
- write(SLAVE_ADDRESS, 0x02, 0x1d);
- write(SLAVE_ADDRESS, 0x04, 0x08); // Default
- write(SLAVE_ADDRESS, 0x1c, 0x00); // Default
- break;
-
- case 2: // Default range, higher speed short range
- write(SLAVE_ADDRESS, 0x02, 0x80); // Default
- write(SLAVE_ADDRESS, 0x04, 0x00);
- write(SLAVE_ADDRESS, 0x1c, 0x00); // Default
- break;
-
- case 3: // Maximum range
- write(SLAVE_ADDRESS, 0x02, 0xff);
- write(SLAVE_ADDRESS, 0x04, 0x08); // Default
- write(SLAVE_ADDRESS, 0x1c, 0x00); // Default
- break;
-
- case 4: // High sensitivity detection, high erroneous measurements
- write(SLAVE_ADDRESS, 0x02, 0x80); // Default
- write(SLAVE_ADDRESS, 0x04, 0x08); // Default
- write(SLAVE_ADDRESS, 0x1c, 0x80);
- break;
-
- case 5: // Low sensitivity detection, low erroneous measurements
- write(SLAVE_ADDRESS, 0x02, 0x80); // Default
- write(SLAVE_ADDRESS, 0x04, 0x08); // Default
- write(SLAVE_ADDRESS, 0x1c, 0xb0);
- break;
- }
- }
-
- /**
- * センサーの値の読み込みを開始します.
- */
- private synchronized void startRead() {
- write(SLAVE_ADDRESS, 0x00, 0x04);
- try {
- Thread.sleep(3);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- read(SLAVE_ADDRESS, 0x8F, 2);
- }
-
- private class OnLIDARLiteListenerImpl implements OnLIDARLiteListener {
-
- /**
- * タイムアウトを監視するタイマー.
- */
- private Timer mTimer;
-
- /**
- * 通知を行うリスナー.
- */
- private OnLIDARLiteListener mListener;
-
- /**
- * 一度だけ読み込む場合.
- */
- private boolean mOnceRead;
-
- /**
- * 開始フラグ.
- */
- private boolean mStartFlag;
-
- /**
- * センサー開始とタイムアウト用のタイマーの開始を行います.
- */
- void start() {
- mTimer = new Timer();
- mTimer.schedule(new TimerTask() {
- @Override
- public void run() {
- onError("timeout");
- }
- }, 1000);
- startRead();
- }
-
- /**
- * リスナーを設定します.
- * @param listener リスナー
- */
- void setListener(final OnLIDARLiteListener listener) {
- mListener = listener;
- }
-
- /**
- * 一度だけ読み込みを行います.
- * @param onceRead trueの場合は1だけ読み込み、falseの場合は連続で読み込む
- */
- void setOnceRead(final boolean onceRead) {
- mOnceRead = onceRead;
- }
-
- /**
- * 停止フラグを設定します.
- */
- void stop() {
- onFinish();
- }
-
- /**
- * タイマーをキャンセルします.
- */
- void cancelTimer() {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer = null;
- }
- }
-
- /**
- * 後始末処理を行います.
- */
- void onFinish() {
- cancelTimer();
- mOnLIDARLiteListeners.remove(this);
- }
-
- @Override
- public void onStarted() {
- }
-
- @Override
- public void onData(final int distance) {
- if (!mStartFlag) {
- mStartFlag = true;
- cancelTimer();
- mListener.onStarted();
- }
- mListener.onData(distance);
-
- if (mOnceRead) {
- onFinish();
- }
- }
-
- @Override
- public void onError(final String message) {
- mListener.onError(message);
- onFinish();
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/MPL115.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/MPL115.java
deleted file mode 100644
index ee6172e0e2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/MPL115.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IMPL115;
-
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataUtil.decodeByte;
-
-class MPL115 extends BaseI2C implements IMPL115 {
-
- // MPL115A2 I2C slave address
- private static final byte SLAVE_ADDRESS = 0x60;
-
- // MPL115A2 Register Address
- private static final int PADC_MSB = 0x00;
- private static final int PADC_LSB = 0x01;
- private static final int TADC_MSB = 0x02;
- private static final int TACD_LSB = 0x03;
- private static final int A0_MSB = 0x04;
- private static final int A0_LSB = 0x05;
- private static final int B1_MSB = 0x06;
- private static final int B1_LSB = 0x07;
- private static final int B2_MSB = 0x08;
- private static final int B2_LSB = 0x09;
- private static final int C12_MSB = 0x0A;
- private static final int C12_LSB = 0x0B;
- private static final int CONVERT = 0x12;
-
- private List mOnAtmosphericPressureListeners = new CopyOnWriteArrayList<>();
-
- private float mA0;
- private float mB1;
- private float mB2;
- private float mC12;
-
- private Timer mTimer;
-
- private boolean mRunningFlag;
-
- @Override
- public void readAtmosphericPressure(final OnAtmosphericPressureListener listener) {
- mOnAtmosphericPressureListeners.add(listener);
-
- if (mRunningFlag) {
- return;
- }
- mRunningFlag = true;
-
- mTimer = new Timer();
- mTimer.schedule(new TimerTask() {
- @Override
- public void run() {
- onError("timeout");
- }
- }, 1000);
-
- setI2CConfig();
- readCoef();
- }
-
- // BaseI2C interface
-
- @Override
- byte getAddress() {
- return SLAVE_ADDRESS;
- }
-
- @Override
- void onReadData(final byte[] data) {
- int offset = 3;
- int register = decodeByte(data[offset++], data[offset++]);
- switch (register) {
- case A0_MSB: {
- int[] value = new int[8];
- for (int i = 0; i < value.length; i++) {
- value[i] = decodeByte(data[offset++], data[offset++]);
- }
- onReadCoef(value);
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- readData();
- }
- }).start();
- } break;
-
- case PADC_MSB: {
- int[] value = new int[4];
- for (int i = 0; i < value.length; i++) {
- value[i] = decodeByte(data[offset++], data[offset++]);
- }
- onReadData(value);
- } break;
- }
- }
-
- private void cancelTimer() {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer = null;
- }
- }
-
- private void onError(final String message) {
- cancelTimer();
-
- for (OnAtmosphericPressureListener listener : mOnAtmosphericPressureListeners) {
- listener.onError(message);
- }
- mRunningFlag = false;
- }
-
- private void readCoef() {
- read(SLAVE_ADDRESS, A0_MSB, 8);
- }
-
- private void onReadCoef(final int[] data) {
- mA0 = FirmataUtil.dataConv(data[1], data[0]) / (float) (1 << 3);
- mB1 = FirmataUtil.dataConv(data[3], data[2]) / (float) (1 << 13);
- mB2 = FirmataUtil.dataConv(data[5], data[4]) / (float) (1 << 14);
- mC12 = FirmataUtil.dataConv(data[7], data[6]) / (float) (1 << 24);
- }
-
- private void readData() {
- write(SLAVE_ADDRESS, CONVERT, 0x01);
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- read(SLAVE_ADDRESS, PADC_MSB, 4);
- }
-
- private void onReadData(final int[] data) {
- int padc = ((data[0] << 8) | data[1]) >> 6;
- int tadc = ((data[2] << 8) | data[3]) >> 6;
-
- double pcomp = mA0 + (mB1 + mC12 * tadc) * padc + mB2 * tadc;
- double hpa = pcomp * ((1150.0 - 500.0) / 1023.0) + 500.0;
- double temp = 25.0 - (tadc - 512.0) / 5.35;
-
- for (OnAtmosphericPressureListener listener : mOnAtmosphericPressureListeners) {
- listener.onData(hpa, temp);
- }
- mOnAtmosphericPressureListeners.clear();
-
- cancelTimer();
-
- mRunningFlag = false;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/MouseCar.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/MouseCar.java
deleted file mode 100644
index dd8d44b0f1..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/MouseCar.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IMouseCar;
-
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.END_SYSEX;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.I2C_REQUEST;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.I2C_WRITE;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.START_SYSEX;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.RobotCarUtil.DRV8830_BACK;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.RobotCarUtil.DRV8830_FORWARD;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.RobotCarUtil.DRV8830_STOP;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.RobotCarUtil.calcSpeed;
-
-/**
- * マウス型RobotCarを操作しるためのクラス.
- */
-class MouseCar extends BaseI2C implements IMouseCar {
- /**
- * 左側のモータへのアドレス.
- */
- private static final byte DRV8830_LEFT_ADDRESS = 0x64;
-
- /**
- * 右側のモータへのアドレス.
- */
- private static final byte DRV8830_RIGHT_ADDRESS = 0x63;
-
- @Override
- public void move(final float rightSpeed, final float leftSpeed) {
- setI2CConfig();
-
- int rightDir = 0;
- int leftDir = 0;
- float tmpLeftSpeed = 0;
- float tmpRightSpeed = 0;
-
- if (rightSpeed > 0) {
- rightDir = DRV8830_BACK;
- tmpRightSpeed = rightSpeed;
- } else if (rightSpeed < 0) {
- rightDir = DRV8830_FORWARD;
- tmpRightSpeed = -rightSpeed;
- }
-
- if (leftSpeed > 0) {
- leftDir = DRV8830_BACK;
- tmpLeftSpeed = leftSpeed;
- } else if (leftSpeed < 0) {
- leftDir = DRV8830_FORWARD;
- tmpLeftSpeed = -leftSpeed;
- }
-
- moveMotor((rightDir | ((calcSpeed(tmpRightSpeed) + 5) << 2)), (leftDir | ((calcSpeed(tmpLeftSpeed) + 5) << 2)));
- }
-
- /**
- * 停止します.
- */
- @Override
- public void stop() {
- setI2CConfig();
- moveMotor(DRV8830_STOP, DRV8830_STOP);
- }
-
- /**
- * モータの回転を送信します.
- * @param valueLeft 左側のモーター
- * @param valueRight 右側のモーター
- */
- private void moveMotor(final int valueLeft, final int valueRight) {
- byte[] commandDataLeft = {
- START_SYSEX,
- I2C_REQUEST,
- DRV8830_LEFT_ADDRESS,
- I2C_WRITE,
- 0x00,
- 0x00,
- (byte) (valueLeft & 0x7f),
- (byte) ((valueLeft >> 7) & 0x7f),
- END_SYSEX
- };
- getFaBoDeviceControl().writeI2C(commandDataLeft);
-
- byte[] commandDataRight = {
- START_SYSEX,
- I2C_REQUEST,
- DRV8830_RIGHT_ADDRESS,
- I2C_WRITE,
- 0x00,
- 0x00,
- (byte) (valueRight & 0x7f),
- (byte) ((valueRight >> 7) & 0x7f),
- END_SYSEX
- };
- getFaBoDeviceControl().writeI2C(commandDataRight);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/RobotCar.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/RobotCar.java
deleted file mode 100644
index e072cb60cb..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/RobotCar.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IRobotCar;
-
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.END_SYSEX;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.I2C_REQUEST;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.I2C_WRITE;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataV32.START_SYSEX;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.RobotCarUtil.DRV8830_BACK;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.RobotCarUtil.DRV8830_FORWARD;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.RobotCarUtil.DRV8830_STOP;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.RobotCarUtil.calcHandleDirection;
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.RobotCarUtil.calcSpeed;
-
-/**
- * RobotCarを操作するためのクラス.
- */
-class RobotCar extends BaseI2C implements IRobotCar {
- /**
- * モータへのアドレス.
- */
- private static final byte DRV8830_ADDRESS = 0x64;
-
- /**
- * サーボへのアドレス.
- */
- private static final byte EXTENDED_ANALOG = 0x6F;
-
- /**
- * ピン設定モード.
- */
- private static final byte SET_PIN_MODE = (byte)0xF4;
-
- @Override
- public void turnHandle(final float direction) {
- byte[] commandData = {
- SET_PIN_MODE,
- (byte) 0x09,
- (byte) 0x04
- };
- getFaBoDeviceControl().writeI2C(commandData);
-
- int pwm = calcHandleDirection(direction);
- byte pwmLsb = (byte)(pwm & 0x7f);
- byte pwmMsb = (byte)((pwm >> 7) & 0x7f);
- byte[] commandSend = {
- START_SYSEX,
- EXTENDED_ANALOG,
- 0x09,
- pwmLsb,
- pwmMsb,
- END_SYSEX
- };
- getFaBoDeviceControl().writeI2C(commandSend);
- }
-
- @Override
- public void move(final float speed) {
- setI2CConfig();
- if (speed > 0) {
- moveMotor((DRV8830_FORWARD | ((calcSpeed(speed) + 5) << 2)));
- } else {
- moveMotor((DRV8830_BACK | ((calcSpeed(speed) + 5) << 2)));
- }
- }
-
- @Override
- public void stop() {
- setI2CConfig();
- moveMotor(DRV8830_STOP);
- }
-
- /**
- * モータの回転を送信します.
- * @param value 送信する値
- */
- private void moveMotor(final int value) {
- setI2CConfig();
- byte[] commandData = {
- START_SYSEX,
- I2C_REQUEST,
- DRV8830_ADDRESS,
- I2C_WRITE,
- 0x00,
- 0x00,
- (byte) (value & 0x7f),
- (byte) ((value >> 7) & 0x7f),
- END_SYSEX
- };
- getFaBoDeviceControl().writeI2C(commandData);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/RobotCarUtil.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/RobotCarUtil.java
deleted file mode 100644
index cca690aa2f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/RobotCarUtil.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-class RobotCarUtil {
- /**
- * モータの回転数の上限を定義.
- */
- private static final int MAX_MOTOR = 55;
-
- static final byte DRV8830_FORWARD = 0x01;
- static final byte DRV8830_BACK = 0x02;
- static final byte DRV8830_STOP = 0x00;
-
- /**
- * 0.0f〜1.0fの値を0〜55の値に変換します.
- * @param speed スピード(0.0f〜1.0f)
- * @return 0〜MAX_MOTORの値
- */
- static int calcSpeed(final float speed) {
- float tmp = Math.abs(speed);
- if (tmp > 1.0f) {
- return MAX_MOTOR;
- }
- return (int) (MAX_MOTOR * tmp);
- }
-
- /**
- * タイヤの回す角度を計算します。
- * @param x 回す値
- * @return 角度
- */
- static int calcHandleDirection(final float x) {
- return (int) (90 + x * 40);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/VCNL4010.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/VCNL4010.java
deleted file mode 100644
index caea19b4d9..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/arduino/VCNL4010.java
+++ /dev/null
@@ -1,452 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.arduino;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IVCNL4010;
-
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import static org.deviceconnect.android.deviceplugin.fabo.device.arduino.FirmataUtil.decodeByte;
-
-class VCNL4010 extends BaseI2C implements IVCNL4010 {
- // I2C VCNL4010 Slave Address
- private static final byte SLAVE_ADDRESS = 0x13;
-
- // Product,Revision ID Value
- private static final int DEVICE_ID = 0x21;
-
- // Register Addresses
- private static final int REG_CMD = 0x80;
- private static final int DEVICE_REG = 0x81;
- private static final int REG_PROX_RATE = 0x82;
- private static final int REG_LED_CRNT = 0x83;
- private static final int REG_AMBI_PARM = 0x84;
- private static final int REG_AMBI_DATA_H = 0x85;
- private static final int REG_AMBI_DATA_L = 0x86;
- private static final int REG_PROX_DATA_H = 0x87;
- private static final int REG_PROX_DATA_L = 0x88;
- private static final int REG_INT_CTRL = 0x89;
- private static final int REG_INT_LOW_H = 0x8A;
- private static final int REG_INT_LOW_L = 0x8B;
- private static final int REG_INT_HIGH_H = 0x8C;
- private static final int REG_INT_HIGH_L= 0x8D;
- private static final int REG_INT_STAT = 0x8E;
- private static final int REG_PROX_ADJ = 0x8F;
-
- // Commands
- private static final int CMD_SELFTIMED_EN = 0x01;
- private static final int CMD_PROX_EN = 0x02;
- private static final int CMD_ALS_EN = 0x04;
- private static final int CMD_PROX_OD = 0x08;
- private static final int CMD_ALS_OD = 0x10;
- private static final int CMD_PROX_DRDY = 0x20;
- private static final int CMD_ALS_DRDY = 0x40;
-
- // Proximity Measurement Rate
- private static final int PROX_RATE_1 = 0x00;
- private static final int PROX_RATE_3 = 0x01;
- private static final int PROX_RATE_7 = 0x02;
- private static final int PROX_RATE_16 = 0x03;
- private static final int PROX_RATE_31 = 0x04;
- private static final int PROX_RATE_62 = 0x05;
- private static final int PROX_RATE_125 = 0x06;
- private static final int PROX_RATE_250 = 0x07;
-
- // Ambient Light Parameter
- private static final int AMBI_CONT_CONV_MODE = 0x80;
- private static final int AMBI_RATE_1 = 0x00;
- private static final int AMBI_RATE_2 = 0x10;
- private static final int AMBI_RATE_3 = 0x20;
- private static final int AMBI_RATE_4 = 0x30;
- private static final int AMBI_RATE_5 = 0x40;
- private static final int AMBI_RATE_6 = 0x50;
- private static final int AMBI_RATE_8 = 0x60;
- private static final int AMBI_RATE_10 = 0x70;
- private static final int AMBI_AUTO_OFFSET = 0x08;
- private static final int AMBI_AVE_NUM_1 = 0x00;
- private static final int AMBI_AVE_NUM_2 = 0x01;
- private static final int AMBI_AVE_NUM_4 = 0x02;
- private static final int AMBI_AVE_NUM_8 = 0x03;
- private static final int AMBI_AVE_NUM_16 = 0x04;
- private static final int AMBI_AVE_NUM_32 = 0x05;
- private static final int AMBI_AVE_NUM_64 = 0x06;
- private static final int AMBI_AVE_NUM_128 = 0x07;
-
- private static final double THRESHOLD = 1.8;
-
- private List mOnProximityListeners = new CopyOnWriteArrayList<>();
- private List mOnAmbientLightListeners = new CopyOnWriteArrayList<>();
-
- private Proximity mProximity = new Proximity();
- private Ambi mAmbi = new Ambi();
-
- @Override
- public void readProximity(final OnProximityListener listener) {
- mOnProximityListeners.add(new OnProximityListener() {
- @Override
- public void onStarted() {
- listener.onStarted();
- }
-
- @Override
- public void onData(final boolean proximity) {
- listener.onData(proximity);
- stopProximity(this);
- }
-
- @Override
- public void onError(final String message) {
- listener.onError(message);
- stopProximity(this);
- }
- });
- if (mProximity.isMeasuring()) {
- return;
- }
- mProximity.start();
- }
-
- @Override
- public void startProximity(final OnProximityListener listener) {
- if (!mOnProximityListeners.contains(listener)) {
- mOnProximityListeners.add(listener);
- }
-
- if (mProximity.isMeasuring()) {
- return;
- }
- mProximity.start();
- }
-
- @Override
- public void stopProximity(final OnProximityListener listener) {
- if (mProximity.isMeasuring()) {
- mProximity.stop();
- }
- mOnProximityListeners.remove(listener);
- }
-
- @Override
- public void readAmbientLight(final OnAmbientLightListener listener) {
- if (!mOnAmbientLightListeners.contains(listener)) {
- mOnAmbientLightListeners.add(listener);
- }
-
- if (mAmbi.isMeasuring()) {
- return;
- }
- mAmbi.start();
- }
-
- @Override
- public void startAmbientLight(final OnAmbientLightListener listener) {
- if (!mOnAmbientLightListeners.contains(listener)) {
- mOnAmbientLightListeners.add(listener);
- }
-
- }
-
- @Override
- public void stopAmbientLight(final OnAmbientLightListener listener) {
- if (mAmbi.isMeasuring()) {
- mAmbi.stop();
- }
- mOnAmbientLightListeners.remove(listener);
- }
-
- // BaseI2C interface
-
- @Override
- byte getAddress() {
- return SLAVE_ADDRESS;
- }
-
- @Override
- void onReadData(final byte[] data) {
- int offset = 3;
- int register = decodeByte(data[offset++], data[offset]);
- switch (register) {
- case DEVICE_REG:
- mProximity.onReadData(data, register);
- mAmbi.onReadData(data, register);
- break;
- case REG_PROX_DATA_H:
- mProximity.onReadData(data, register);
- break;
- case REG_AMBI_DATA_H:
- mAmbi.onReadData(data, register);
- break;
- }
- }
-
- /**
- * VCNL4010の設定を行います.
- */
- private void setVCNL4010() {
- setCommand(CMD_SELFTIMED_EN | CMD_PROX_EN | CMD_ALS_EN);
- setProxRate(PROX_RATE_250);
- setLedCurrent(20);
- setAmbiParm(AMBI_RATE_10 | AMBI_AUTO_OFFSET | AMBI_AVE_NUM_128);
- }
-
- /**
- * コマンドを送信します.
- * @param config 送信するコマンド設定
- */
- private void setCommand(final int config) {
- write(SLAVE_ADDRESS, REG_CMD, config);
- }
-
- /**
- * Proximityのレートを送信します.
- * @param config 送信するレート
- */
- private void setProxRate(final int config) {
- write(SLAVE_ADDRESS, REG_PROX_RATE, config);
- }
-
- /**
- * LED Currentの値を送信します.
- * @param config 送信する値
- */
- private void setLedCurrent(final int config) {
- write(SLAVE_ADDRESS, REG_LED_CRNT, config);
- }
-
- /**
- * Ambient Lightの設定を送信します.
- * @param config 送信する設定
- */
- private void setAmbiParm(final int config) {
- write(SLAVE_ADDRESS, REG_AMBI_PARM, config);
- }
-
- /**
- * 距離(cm)に変換します.
- * @param proximity センサーからの値
- * @return 距離(cm)
- */
- private double convert(final int proximity) {
- return 0.1 + ((65535 - proximity) / 65535.0) * 2.0;
- }
-
- /**
- * VCNL4010と通信する場合のステートを管理するクラス.
- */
- private abstract class VCNL4010State {
-
- /**
- * 現在のステート.
- *
- * 現在、取得しているレジスタの番号になります。
- *
- */
- int mState = -1;
-
- /**
- * タイムアウトを監視するタイマー.
- */
- private Timer mTimer;
-
- /**
- * 開始フラグ.
- */
- boolean mStartFlag;
-
- /**
- * 湿度の計測中フラグ.
- * @return 計測中の場合にはtrue、それ以外はfalse
- */
- boolean isMeasuring() {
- return mState != -1;
- }
-
- /**
- * 湿度の計測を開始します.
- */
- void start() {
- setI2CConfig();
-
- mTimer = new Timer();
- mTimer.schedule(new TimerTask() {
- @Override
- public void run() {
- onError("timeout");
- }
- }, 1000);
-
- mStartFlag = false;
-
- next(DEVICE_REG);
- }
-
- /**
- * 次のレジスタの値を取得します.
- * @param register 次に取得するレジスタ
- */
- void next(final int register) {
- mState = register;
- read(SLAVE_ADDRESS, register, 1);
- }
-
- /**
- * エラーが発生した場合の処理を行います.
- * @param message エラーメッセージ
- */
- void onError(final String message) {
- for (OnProximityListener listener : mOnProximityListeners) {
- listener.onError(message);
- }
- onFinish();
- }
-
- /**
- * タイマーをキャンセルします.
- */
- void cancelTimer() {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer = null;
- }
- }
-
- /**
- * 後始末処理を行います.
- */
- void onFinish() {
- cancelTimer();
- mState = -1;
- }
-
- /**
- * 読み込みを停止します.
- */
- abstract void stop();
-
- /**
- * HTS221から送られてきたデータを解析して、次のステップに進みます.
- * @param data 送られてきたデータ
- * @param register レジスタ番号
- */
- abstract void onReadData(final byte[] data, final int register);
- }
-
- private class Proximity extends VCNL4010State {
-
- private double mOldProximity;
-
- @Override
- void stop() {
- stopRead(SLAVE_ADDRESS, REG_PROX_DATA_H);
- onFinish();
- }
-
- @Override
- void onReadData(final byte[] data, final int register) {
-
- if (mState != register) {
- // レジスタが一致しない場合には、不正なデータなので無視
- return;
- }
-
- int offset = 5;
- switch(register) {
- case DEVICE_REG:
- int deviceId = decodeByte(data[offset++], data[offset]);
- if (deviceId == DEVICE_ID) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- setVCNL4010();
-
- // 設定が反映されるまで、少し時間がかかるのスリープを入れておく
- try {
- Thread.sleep(33);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- mState = REG_PROX_DATA_H;
- startRead(SLAVE_ADDRESS, REG_PROX_DATA_H, 2);
- }
- }).start();
- } else {
- onError("VCNL4010 is not connect.");
- }
- break;
-
- case REG_PROX_DATA_H:
- if (!mStartFlag) {
- for (OnProximityListener listener : mOnProximityListeners) {
- listener.onStarted();
- }
- mStartFlag = true;
- cancelTimer();
- }
-
- double proximity = convert(FirmataUtil.decodeUShort2(data, offset));
- if (mOldProximity > THRESHOLD && proximity < THRESHOLD) {
- for (OnProximityListener l : mOnProximityListeners) {
- l.onData(true);
- }
- } else if (mOldProximity < THRESHOLD && proximity > THRESHOLD) {
- for (OnProximityListener l : mOnProximityListeners) {
- l.onData(false);
- }
- }
- mOldProximity = proximity;
-
- break;
- }
- }
- }
-
- private class Ambi extends VCNL4010State {
- @Override
- void stop() {
- stopRead(SLAVE_ADDRESS, REG_AMBI_DATA_H);
- onFinish();
- }
-
- @Override
- void onReadData(final byte[] data, final int register) {
-
- if (mState != register) {
- // レジスタが一致しない場合には、不正なデータなので無視
- return;
- }
-
- int offset = 5;
- switch(register) {
- case DEVICE_REG:
- int deviceId = decodeByte(data[offset++], data[offset]);
- if (deviceId == DEVICE_ID) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- setVCNL4010();
-
- // 設定が反映されるまで、少し時間がかかるのスリープを入れておく
- try {
- Thread.sleep(33);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- mState = REG_AMBI_DATA_H;
- startRead(SLAVE_ADDRESS, REG_AMBI_DATA_H, 2);
- }
- }).start();
- } else {
- onError("VCNL4010 is not connect.");
- }
- break;
-
- case REG_AMBI_DATA_H:
- int lux = FirmataUtil.decodeUShort2(data, offset);
- break;
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoArduinoActivity.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoArduinoActivity.java
deleted file mode 100644
index b19cefa031..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoArduinoActivity.java
+++ /dev/null
@@ -1,203 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.setting;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.app.Fragment;
-import android.app.FragmentManager;
-import android.app.FragmentTransaction;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.view.MenuItem;
-
-import org.deviceconnect.android.deviceplugin.fabo.FaBoArduinoDeviceService;
-import org.deviceconnect.android.deviceplugin.fabo.R;
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.setting.fragment.FaBoArduinoFragment;
-import org.deviceconnect.android.deviceplugin.fabo.setting.fragment.FaBoConnectFragment;
-import org.deviceconnect.android.deviceplugin.fabo.setting.fragment.FaBoFirmwareFragment;
-import org.deviceconnect.android.message.DConnectMessageService;
-
-public class FaBoArduinoActivity extends Activity {
- /**
- * プラグインのサービス.
- */
- private DConnectMessageService mMessageService;
-
- /**
- * サービスとのバインド状態.
- */
- private boolean mIsBound;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_fabo_arduino);
-
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_HOME);
- actionBar.setTitle(R.string.activity_setting_arduino_title);
- }
-
- Intent a = new Intent();
- a.setClass(this, FaBoArduinoDeviceService.class);
- startService(a);
-
- boolean finishFlag = true;
- Intent intent = getIntent();
- if (intent != null) {
- String page = intent.getStringExtra("page");
- if ("firmata".equals(page)) {
- showFirmwareFragment();
- return;
- } else if ("connect".equals(page)) {
- finishFlag = false;
- }
- }
- showConnectFragment(finishFlag);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- bindMessageService();
- }
-
- @Override
- protected void onPause() {
- unbindMessageService();
- super.onPause();
- }
-
- @Override
- public boolean onOptionsItemSelected(final MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- finish();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- /**
- * Arduinoとの接続を監視するフラグメントを表示します.
- * @param flag 終了フラグ
- */
- private void showConnectFragment(final boolean flag) {
- Bundle args = new Bundle();
- args.putBoolean(FaBoConnectFragment.EXTRA_FINISH_FLAG, flag);
-
- FaBoConnectFragment fragment = new FaBoConnectFragment();
- fragment.setArguments(args);
-
- FragmentManager manager = getFragmentManager();
- FragmentTransaction transaction = manager.beginTransaction();
- transaction.replace(R.id.fragment_container, fragment);
- transaction.commit();
- }
-
- /**
- * ファームウェア更新用フラグメントを表示します.
- */
- private void showFirmwareFragment() {
- FaBoFirmwareFragment fragment = new FaBoFirmwareFragment();
- FragmentManager manager = getFragmentManager();
- FragmentTransaction transaction = manager.beginTransaction();
- transaction.replace(R.id.fragment_container, fragment);
- transaction.commit();
- }
-
- /**
- * DConnectMessageServiceとバインドします.
- */
- private void bindMessageService() {
- if (!mIsBound) {
- Intent intent = new Intent(getApplicationContext(), FaBoArduinoDeviceService.class);
- bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
- }
- }
-
- /**
- * DConnectMessageServiceとアンバインドします.
- */
- private void unbindMessageService() {
- if (mIsBound) {
- unbindService(mConnection);
- mIsBound = false;
- }
- }
-
- /**
- * バインドしたサービスを取得します.
- * @return バインドしたサービス
- */
- private FaBoArduinoDeviceService getService() {
- return (FaBoArduinoDeviceService) mMessageService;
- }
-
- /**
- * FaBoDeviceControlのインスタンスを取得します.
- *
- * バインドしていなかったり、USBに接続出来ていない場合にはnullを返却します。
- *
- * @return FaBoDeviceControlのインスタンス
- */
- public FaBoDeviceControl getFaBoDeviceControl() {
- FaBoArduinoDeviceService s = getService();
- if (s != null) {
- return s.getFaBoDeviceControl();
- }
- return null;
- }
-
- /**
- * サービスとバインドされたことをを通知します.
- */
- private void notifyBindService() {
- FragmentManager manager = getFragmentManager();
- Fragment f = manager.findFragmentById(R.id.fragment_container);
- if (f != null && f instanceof FaBoArduinoFragment) {
- ((FaBoArduinoFragment) f).onBindService();
- }
-
- }
-
- /**
- * サービスとアンバインドされたことを通知します.
- */
- private void notifyUnbindService() {
- FragmentManager manager = getFragmentManager();
- Fragment f = manager.findFragmentById(R.id.fragment_container);
- if (f != null && f instanceof FaBoArduinoFragment) {
- ((FaBoArduinoFragment) f).onUnbindService();
- }
- }
-
- /**
- * DConnectMessageServiceとのバインドを状態のイベントを受け取るクラス.
- */
- private ServiceConnection mConnection = new ServiceConnection() {
- @Override
- public void onServiceConnected(final ComponentName name, final IBinder service) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mMessageService = ((DConnectMessageService.LocalBinder) service).getMessageService();
- mIsBound = true;
- notifyBindService();
- }
- });
- }
-
- @Override
- public void onServiceDisconnected(final ComponentName name) {
- notifyUnbindService();
- mIsBound = false;
- mMessageService = null;
- }
- };
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoSettingActivity.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoSettingActivity.java
deleted file mode 100644
index 6458f45e04..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/FaBoSettingActivity.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-FaBoSettingActivity
-Copyright (c) 2014 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
-*/
-package org.deviceconnect.android.deviceplugin.fabo.setting;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.MenuItem;
-
-import org.deviceconnect.android.deviceplugin.fabo.R;
-
-/**
- * 設定用Activity.
- *
- * @author NTT DOCOMO, INC.
- */
-public class FaBoSettingActivity extends Activity {
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_fabo_setting);
-
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_HOME);
- actionBar.setTitle(R.string.activity_setting_arduino_title);
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(final MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- finish();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoArduinoFragment.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoArduinoFragment.java
deleted file mode 100644
index 599a3dff9c..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoArduinoFragment.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.setting.fragment;
-
-import android.app.Fragment;
-
-/**
- * Arduino接続・ファームウェア更新フラグメントの基底クラス.
- */
-public class FaBoArduinoFragment extends Fragment {
- /**
- * サービスがバインドされた時に呼び出されます.
- */
- public void onBindService() {
- }
-
- /**
- * サービスがアンバインドされた時に呼び出されます.
- */
- public void onUnbindService() {
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoConnectFragment.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoConnectFragment.java
deleted file mode 100644
index f46ddac234..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoConnectFragment.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
-FaBoConnectFragment
-Copyright (c) 2014 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
-*/
-package org.deviceconnect.android.deviceplugin.fabo.setting.fragment;
-
-import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbManager;
-import android.os.Build;
-import android.os.Bundle;
-import android.text.Html;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import org.deviceconnect.android.deviceplugin.fabo.R;
-import org.deviceconnect.android.deviceplugin.fabo.core.BuildConfig;
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoConst;
-import org.deviceconnect.android.deviceplugin.fabo.setting.FaBoArduinoActivity;
-
-import java.util.HashMap;
-
-import io.fabo.serialkit.FaBoUsbConst;
-
-/**
- * 設定画面用Fragment.
- *
- * @author NTT DOCOMO, INC.
- */
-public class FaBoConnectFragment extends FaBoArduinoFragment {
-
- /**
- * デバッグ用TAG.
- */
- private static final String TAG = "FABO_PLUGIN_SETTING";
-
- /**
- * デバッグ用フラグ.
- */
- private static final boolean DEBUG = BuildConfig.DEBUG;
-
- /**
- * Arduinoとの接続が完了した時にActivityを終了するフラグを格納するキー.
- */
- public static final String EXTRA_FINISH_FLAG = "flag";
-
- /**
- * 作業内容を表示するためのTextView.
- */
- private TextView mTextViewComment;
-
- /**
- * ログを表示するためのTextView.
- */
- private TextView mTextViewLog;
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
- View root = inflater.inflate(R.layout.fragment_fabo_connect, container, false);
- mTextViewComment = (TextView) root.findViewById(R.id.textViewComment);
- mTextViewLog = (TextView) root.findViewById(R.id.textViewLog);
- return root;
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- // USBの結果受信用のBroadcast Receiverを設定.
- IntentFilter filter = new IntentFilter();
- filter.addAction(FaBoConst.DEVICE_TO_ARDUINO_OPEN_USB_RESULT);
- filter.addAction(FaBoConst.DEVICE_TO_ARDUINO_CHECK_USB_RESULT);
- filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
- getActivity().registerReceiver(mUSBResultReceiver, filter);
-
- FaBoArduinoActivity a = (FaBoArduinoActivity) getActivity();
- FaBoDeviceControl ctrl = a.getFaBoDeviceControl();
- if (ctrl != null) {
- checkUsbDevice();
- }
- }
-
- @Override
- public void onStop() {
- getActivity().unregisterReceiver(mUSBResultReceiver);
- super.onStop();
- }
-
- @Override
- public void onBindService() {
- checkUsbDevice();
- }
-
- @Override
- public void onUnbindService() {
- }
-
- /**
- * 終了フラグを確認して、Activityを終了します.
- */
- private void checkAndFinish() {
- Activity activity = getActivity();
- if (activity == null) {
- return;
- }
-
- if (isFinishFlag()) {
- activity.finish();
- }
- }
-
- /**
- * 接続した時にActivityを終了するか確認します.
- * @return trueの場合はActivityを終了、それ以外は終了しません。
- */
- private boolean isFinishFlag() {
- Bundle args = getArguments();
- return args == null || args.getBoolean(EXTRA_FINISH_FLAG, true);
- }
-
- /**
- * USB機器の確認を行います.
- */
- private void checkUsbDevice() {
- if (DEBUG) {
- Log.i(TAG, "checkUsbDevice()");
- }
-
- final Activity activity = getActivity();
- if (activity == null) {
- return;
- }
-
- FaBoArduinoActivity a = (FaBoArduinoActivity) activity;
- final FaBoDeviceControl ctrl = a.getFaBoDeviceControl();
- if (ctrl == null) {
- return;
- }
-
- clearLogMessage();
-
- UsbManager manager = (UsbManager) activity.getSystemService(Context.USB_SERVICE);
- HashMap deviceList = manager.getDeviceList();
- for (final UsbDevice device : deviceList.values()) {
- if (device.getVendorId() == FaBoUsbConst.ARDUINO_UNO_VID) {
- mTextViewComment.setText(R.string.arduinoorg_find);
- addLogMessage(R.string.fragment_connect_org_recognition);
-
- int status = ctrl.getStatus();
- if (status == FaBoConst.STATUS_FABO_RUNNING) {
- mTextViewComment.setText(R.string.success_connect);
- checkAndFinish();
- } else if (status == FaBoConst.STATUS_FABO_NOCONNECT) {
- sendOpenUsbDevice(activity, device);
- }
- } else if (device.getVendorId() == FaBoUsbConst.ARDUINO_CC_UNO_VID) {
- mTextViewComment.setText(R.string.arduinocc_find);
- addLogMessage(R.string.fragment_connect_cc_recognition);
-
- int status = ctrl.getStatus();
- if (status == FaBoConst.STATUS_FABO_RUNNING) {
- mTextViewComment.setText(R.string.success_connect);
- checkAndFinish();
- } else if (status == FaBoConst.STATUS_FABO_NOCONNECT) {
- sendOpenUsbDevice(activity, device);
- }
- }
- }
- }
-
- /**
- * Usb機器のオープンリクエストを送信します.
- * @param context コンテキスト
- * @param device USB機器
- */
- private void sendOpenUsbDevice(Context context, UsbDevice device) {
- Intent intent = new Intent(FaBoConst.DEVICE_TO_ARDUINO_CHECK_USB);
- intent.putExtra(UsbManager.EXTRA_DEVICE, device);
- context.sendBroadcast(intent);
- }
-
- /**
- * FaboDeviceServiceからのUSB接続結果を処理します.
- *
- * @param intent USB接続処理結果
- */
- private void checkOpenUsbResult(final Intent intent) {
- if (DEBUG) {
- Log.i(TAG, "checkOpenUsbResult");
- }
-
- int resultId = intent.getIntExtra("resultId", 0);
- if (resultId == FaBoConst.FAILED_CONNECT_ARDUINO) {
- mTextViewComment.setText(R.string.failed_connect_arduino);
- checkAndFinish();
- } else if (resultId == FaBoConst.SUCCESS_CONNECT_ARDUINO) {
- mTextViewComment.setText(R.string.success_connect_arduino);
- } else if (resultId == FaBoConst.SUCCESS_CONNECT_FIRMATA) {
- mTextViewComment.setText(R.string.success_connect);
- addLogMessage(R.string.fragment_connect_check_firmata);
- checkAndFinish();
- }
- }
-
- /**
- * USBが外された時の処理を行います.
- */
- private void detachedUsbDevice() {
- if (DEBUG) {
- Log.i(TAG, "detachedUsbDevice()");
- }
-
- Activity activity = getActivity();
- if (activity == null) {
- return;
- }
- clearLogMessage();
- mTextViewComment.setText(R.string.disconnect_usb);
- checkAndFinish();
- }
-
- /**
- * Broadcast receiver for usb event.
- */
- private BroadcastReceiver mUSBResultReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(final Context context, final Intent intent) {
- String action = intent.getAction();
- if (DEBUG) {
- Log.i(TAG, "Received action=" + action);
- }
-
- if (FaBoConst.DEVICE_TO_ARDUINO_OPEN_USB_RESULT.equals(action)) {
- checkOpenUsbResult(intent);
- } else if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
- detachedUsbDevice();
- }
- }
- };
-
- /**
- * ログ表示用TextViewのメッセージをクリアします.
- */
- private void clearLogMessage() {
- mTextViewLog.setText("");
- }
-
- /**
- * ログ表示用TextViewにメッセージを追加します.
- *
- * @param resId リソースID
- */
- private void addLogMessage(final int resId) {
- addLogMessage(getString(resId));
- }
-
- /**
- * ログ表示用TextViewにメッセージを追加します.
- *
- * @param msg 追加するメッセージ
- */
- private synchronized void addLogMessage(final String msg) {
- String lastMsg = mTextViewLog.getText().toString();
- if (DEBUG) {
- Log.i(TAG, "lastMsg" + lastMsg);
- }
-
- String newMsg = lastMsg;
- if (!lastMsg.isEmpty()) {
- newMsg += " ";
- }
- newMsg += " ✓ " + msg;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- mTextViewLog.setText(Html.fromHtml(newMsg, 0));
- } else {
- mTextViewLog.setText(Html.fromHtml(newMsg));
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoFirmwareFragment.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoFirmwareFragment.java
deleted file mode 100644
index 5843561a51..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoFirmwareFragment.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
-FaBoFirmwareFragment
-Copyright (c) 2014 NTT DOCOMO,INC.
-Released under the MIT license
-http://opensource.org/licenses/mit-license.php
-*/
-package org.deviceconnect.android.deviceplugin.fabo.setting.fragment;
-
-import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbManager;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.TextView;
-
-import org.deviceconnect.android.deviceplugin.fabo.R;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoConst;
-import org.deviceconnect.android.deviceplugin.fabo.setting.FaBoArduinoActivity;
-
-import java.util.HashMap;
-
-import io.fabo.android.stk500.StkWriter;
-import io.fabo.android.stk500.StkWriterListenerInterface;
-import io.fabo.serialkit.FaBoUsbConst;
-
-/**
- * 設定画面用Fragment.
- *
- * @author NTT DOCOMO, INC.
- */
-public class FaBoFirmwareFragment extends FaBoArduinoFragment implements StkWriterListenerInterface {
-
- /**
- * Context.
- */
- private Context mContext;
-
- /**
- * Connect button.
- */
- private Button mButtonConnect;
-
- /**
- * Send button.
- */
- private Button mButtonSend;
-
- /**
- * Back button.
- */
- private Button mButtonBack;
-
- /**
- * TextView.
- */
- private TextView mTextViewComment;
-
- /**
- * STK500.
- */
- private StkWriter mStkWriter;
-
- /**
- * Parent activity.
- */
- private FaBoArduinoActivity mParent;
-
- /**
- * Activity.
- */
- private Activity mActivity;
-
- /**
- * newInstance.
- *
- * @return fragment Fragment instance.
- */
- public static FaBoFirmwareFragment newInstance() {
- FaBoFirmwareFragment fragment = new FaBoFirmwareFragment();
- return fragment;
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
- // Root view.
- View root = inflater.inflate(R.layout.fragment_fabo_firmata, container, false);
-
- // Get context.
- mContext = getActivity().getBaseContext();
- mActivity = getActivity();
-
- // Get ui component.
- mTextViewComment = (TextView) root.findViewById(R.id.textViewComment);
- mButtonConnect = (Button) root.findViewById(R.id.buttonConnect);
- mButtonSend = (Button) root.findViewById(R.id.buttonSend);
- mButtonBack = (Button) root.findViewById(R.id.buttonBack);
-
- // USBへの接続ボタン
- mButtonConnect.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
-
- // FaBoとの接続用のUSBをCloseする.
- Intent intent = new Intent(FaBoConst.DEVICE_TO_ARDUINO_CLOSE_USB);
- mContext.sendBroadcast(intent);
-
- // ボタンがクリックされた時にUSBを開く.
- if (mStkWriter.openUsb()) {
- mButtonSend.setVisibility(Button.VISIBLE);
- mButtonSend.setEnabled(true);
- }
- }
- });
-
- // 戻るボタン.
- mButtonBack.setOnClickListener(new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
-
- // FaBoとの接続用のUSBをCloseする.
- Intent intent = new Intent(FaBoConst.DEVICE_TO_ARDUINO_CHECK_USB);
- mContext.sendBroadcast(intent);
-
- // 前のページに戻る.
-// mParent.moveConnectFirmata();
- }
- });
-
- // Firmwareの送信ボタン
- mButtonSend.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mButtonSend.setEnabled(false);
-
- // Firmwareを転送.
- mStkWriter.setData(R.raw.standardfirmata_hex);
- mStkWriter.sendFirmware();
- }
- });
-
- // USBの装着、脱着をReceiverで取得.
- IntentFilter filter = new IntentFilter();
- filter.addAction(StkWriter.ACTION_USB_PERMISSION);
- filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
- getActivity().registerReceiver(mUsbReceiver, filter);
-
- return root;
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- // SerialPortの生成
- //mStkWriter = new StkWriter(getActivity().getBaseContext());
- //mStkWriter.setListener(this);
-
- // USBデバイスのチェック.
- UsbManager manager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE);
- HashMap deviceList = manager.getDeviceList();
-
- for (UsbDevice device : deviceList.values()) {
- if (device.getVendorId() == FaBoUsbConst.ARDUINO_UNO_VID) {
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mTextViewComment.setText(R.string.arduinoorg_find);
- mButtonConnect.setEnabled(false);
- mButtonSend.setVisibility(Button.INVISIBLE);
- mButtonBack.setVisibility(Button.INVISIBLE);
- }
- });
- } else if (device.getVendorId() == FaBoUsbConst.ARDUINO_CC_UNO_VID) {
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mTextViewComment.setText(R.string.arduinocc_find);
- mButtonConnect.setEnabled(true);
- mButtonSend.setVisibility(Button.INVISIBLE);
- mButtonBack.setVisibility(Button.INVISIBLE);
- }
- });
- break;
- }
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
-
- // SerialPortを閉じる
- //mStkWriter.closeUsb();
- //mStkWriter = null;
- try {
- getActivity().unregisterReceiver(mUsbReceiver);
- } catch (Exception ignored) {
- }
- }
-
- private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
-
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
-
- if (StkWriter.ACTION_USB_PERMISSION.equals(action)) {
-
- } else if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
- // USBを閉じる
- /*
- mStkWriter.closeUsb();
- mTextViewComment.setText(R.string.disconnect_usb);
- mButtonConnect.setEnabled(false);
- mButtonSend.setVisibility(Button.INVISIBLE);
- mButtonBack.setVisibility(Button.INVISIBLE);
- */
- }
- }
- };
-
- @Override
- public void onChangeStatus(int status) {
-
- switch (status) {
- case StkWriter.STATUS_USB_INIT:
- break;
- case StkWriter.STATUS_USB_OPEN:
- break;
- case StkWriter.STATUS_USB_CONNECT:
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mButtonSend.setVisibility(Button.VISIBLE);
- mButtonSend.setEnabled(true);
- mButtonConnect.setEnabled(false);
- mTextViewComment.setText(R.string.firmware_usb_find);
- }
- });
- break;
- case StkWriter.STATUS_USB_CLOSE:
- break;
- case StkWriter.STATUS_UART_START:
- break;
- case StkWriter.STATUS_FIRMWARE_SEND_INIT:
- break;
- case StkWriter.STATUS_FIRMWARE_SEND_START:
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mTextViewComment.setText(R.string.firmware_start_send);
- }
- });
- break;
- case StkWriter.STATUS_FIRMWARE_SEND_FINISH:
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mStkWriter.closeUsb();
- mTextViewComment.setText(R.string.firmware_success_send);
- mButtonBack.setVisibility(Button.VISIBLE);
- }
- });
- break;
- }
- }
-
- @Override
- public void onError(int status) {
- switch (status) {
- case StkWriter.ERROR_FAILED_CONNECTION:
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mTextViewComment.setText(R.string.can_not_connet_usb);
- mButtonConnect.setEnabled(true);
- mButtonSend.setVisibility(Button.INVISIBLE);
- }
- });
- break;
- case StkWriter.ERROR_FAILED_OPEN:
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mTextViewComment.setText(R.string.can_not_open_usb);
- mButtonConnect.setEnabled(true);
- mButtonSend.setVisibility(Button.INVISIBLE);
- }
- });
- break;
- case StkWriter.ERROR_FAILED_SEND_FIRMRARE:
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mTextViewComment.setText(R.string.failed_send_firmata);
- mButtonConnect.setEnabled(true);
- mButtonSend.setVisibility(Button.INVISIBLE);
- }
- });
- break;
- case StkWriter.ERROR_NO_FOUND_FIRMARE:
- break;
- case StkWriter.ERROR_NOT_INIT_USB:
- break;
- case StkWriter.ERROR_NOT_WRITE_UART:
- break;
- }
- }
-
- @Override
- public void onAttach(Activity activity) {
- mParent = (FaBoArduinoActivity) activity;
- super.onAttach(activity);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoSettingFragment.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoSettingFragment.java
deleted file mode 100644
index e962a7a068..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/setting/fragment/FaBoSettingFragment.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.setting.fragment;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.preference.CheckBoxPreference;
-import android.preference.Preference;
-import android.preference.PreferenceFragment;
-
-import org.deviceconnect.android.deviceplugin.fabo.FaBoArduinoDeviceService;
-import org.deviceconnect.android.deviceplugin.fabo.R;
-
-/**
- * FaBoの設定画面用のフラグメント.
- */
-public class FaBoSettingFragment extends PreferenceFragment {
- @Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.settings_fabo);
-
- CheckBoxPreference oauthCheckBox = (CheckBoxPreference) getPreferenceScreen()
- .findPreference(getString(R.string.key_settings_security_local_oauth));
- oauthCheckBox.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(final Preference preference, final Object newValue) {
- final String key = preference.getKey();
- if (preference instanceof CheckBoxPreference) {
- if (getString(R.string.key_settings_security_local_oauth).equals(key)) {
- notifyChangeLocalOAuth();
- }
- }
- return true;
- }
- });
- }
-
- /**
- * Local OAuthの設定が切り替わったことを通知します.
- */
- private void notifyChangeLocalOAuth() {
- Intent intent = new Intent();
- intent.setClass(getActivity(), FaBoArduinoDeviceService.class);
- intent.setAction(FaBoArduinoDeviceService.ACTION_SET_LOCAL_OAUTH);
- getActivity().startService(intent);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/layout/activity_fabo_arduino.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/layout/activity_fabo_arduino.xml
deleted file mode 100644
index bb8df859fd..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/layout/activity_fabo_arduino.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/layout/activity_fabo_setting.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/layout/activity_fabo_setting.xml
deleted file mode 100644
index 536363976d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/layout/activity_fabo_setting.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/layout/fragment_fabo_connect.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/layout/fragment_fabo_connect.xml
deleted file mode 100644
index c5de00bc56..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/layout/fragment_fabo_connect.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/layout/fragment_fabo_firmata.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/layout/fragment_fabo_firmata.xml
deleted file mode 100644
index d60ab9e450..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/layout/fragment_fabo_firmata.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/values/keys.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/values/keys.xml
deleted file mode 100644
index 622587c513..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/values/keys.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- settings_security_local_oauth
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/values/strings.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/values/strings.xml
deleted file mode 100644
index 4fc4c50132..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
- FaBo (Device Connect Device Plug-in)
-
- Arduino Unoが見つかりませんでした。
- USBデバイスに接続できませんでした。
- USBデバイスが開けませんでした。
- Arduino Uno接続設定
- Firmataファームウェア転送
- Arduino Unoと接続してください。
- FirmataデバイスとAndroid UnoをUSB接続します。接続に設定するとFirmataファームウェアを転送ボタンが出てくるので選択します。
- Arduino Unoと接続
- Firmataファームウェアを転送
- FaBoデバイスへの接続画面に戻る
- USBをオープンしました。
- FaBoデバイスが接続されていません。\n\nArduino UnoをUSBでAndroidに接続してください。
- Arduino.cc製のArduinoを認識しました。\n\nArduino Unoと接続処理を行なっています。
- Arduino.org製のArduino Unoを認識しました。\n\nArduino Unoと接続処理を行なっています。
- USBデバイスの接続に失敗しました。
- Arduinoに接続に失敗しました。
- Arduinoへの接続に成功しました。
- FaBoデバイスプラグイン動作中。\n動作を終了する場合は、USBを抜いてください。
- Firmataへの接続に失敗しました。
- Firwareの転送に失敗しました。
- FaBoデバイスが切断されました。
- USBデバイスが切断されました。
- USBデバイスに接続しました。\n\nFirmataファームウェアを転送ボタンを押し、ファームウェアを転送します。
- ファームウェア転送を開始します。3-5秒程度の時間がかかります。
- ファームウェアの転送に失敗。\n\nArdino Unoと接続ボタンを押し、再度転送しなおしてください。
- ファームウェアの転送に成功。
-
- FaBo設定(Arduino)
-
- Arduino
- Arduino接続
- Firmataファームウェア転送
-
- サービス
- サービス一覧
-
- セキュリティ
- ユーザ認可
- ユーザによってプラグインの使用を認可します。
-
- "Arduino Uno(ORG)を認識"
- "Arduino(CC)を認識"
- Firmataの動作を確認
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/xml/settings_fabo.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/xml/settings_fabo.xml
deleted file mode 100644
index d7156793d5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/main/res/xml/settings_fabo.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/test/java/org/deviceconnect/android/deviceplugin/fabo/ExampleUnitTest.java b/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/test/java/org/deviceconnect/android/deviceplugin/fabo/ExampleUnitTest.java
deleted file mode 100644
index 2711734c5b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/plugin/src/test/java/org/deviceconnect/android/deviceplugin/fabo/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/settings.gradle b/dConnectDevicePlugin/dConnectDeviceFaBo/settings.gradle
deleted file mode 100644
index 39a95a9834..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':app', ':plugin', ':things-plugin'
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/.gitignore b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/.gitignore
deleted file mode 100644
index 796b96d1c4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/build.gradle b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/build.gradle
deleted file mode 100644
index f8278d2b2b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/build.gradle
+++ /dev/null
@@ -1,80 +0,0 @@
-apply plugin: 'com.android.application'
-// Create github.properties in root project folder file with
-// gpr.usr=GITHUB_USER_ID
-// gpr.key=PERSONAL_ACCESS_TOKEN
-def githubPropertiesFile = rootProject.file("github.properties")
-def githubProperties = new Properties()
-if (githubPropertiesFile.exists()) {
- githubProperties.load(new FileInputStream(githubPropertiesFile))
-}
-android {
- compileSdkVersion 29
-
- def getVersionName = { ->
- def version
- if (System.getProperty('os.name').toLowerCase().contains('windows')) {
- version = ["cmd", "/c", "git describe --tags --long"].execute().in.text.trim()
- } else {
- version = ["sh", "-c", "git describe --tags --long"].execute().in.text.trim()
- }
- version = version.empty ? "2.1.0" : version
- return "${version}"
- }
-
- defaultConfig {
- applicationId "org.deviceconnect.android.deviceplugin.fabo"
- minSdkVersion 16
- targetSdkVersion 29
- versionCode 1
- versionName getVersionName()
-
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- }
-
- signingConfigs {
- releaseConfig {
- storeFile=file(project.properties.storeFile)
- storePassword=project.properties.storePassword
- keyAlias=project.properties.keyAlias
- keyPassword=project.properties.keyPassword
- }
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- signingConfig signingConfigs.releaseConfig
- }
- }
-
- tasks.withType(JavaCompile) {
- options.encoding = 'UTF-8'
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- repositories {
- maven {
- name = "DeviceConnect-Android"
- url = uri("https://maven.pkg.github.com/DeviceConnect/DeviceConnect-Android")
-
- credentials {
- username = System.getenv("GPR_USER") ?: githubProperties['gpr.usr']
- password = System.getenv("GPR_API_KEY") ?: githubProperties['gpr.key']
- }
- }
- }
-}
-
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation project(':app')
- implementation 'org.deviceconnect:dconnect-device-plugin-sdk:2.8.4'
- compileOnly 'com.google.android.things:androidthings:1.0'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test.ext:junit:1.1.1'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/proguard-rules.pro b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/proguard-rules.pro
deleted file mode 100644
index 36d448c0fa..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/proguard-rules.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/kobayashinobuo/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/androidTest/java/org/deviceconnect/android/deviceplugin/fabo/ExampleInstrumentedTest.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/androidTest/java/org/deviceconnect/android/deviceplugin/fabo/ExampleInstrumentedTest.java
deleted file mode 100644
index a6730ed0f4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/androidTest/java/org/deviceconnect/android/deviceplugin/fabo/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo;
-
-import android.content.Context;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.platform.app.InstrumentationRegistry;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getInstrumentation().getContext();
-
- assertEquals("org.deviceconnect.android.deviceplugin.fabo", appContext.getPackageName());
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/AndroidManifest.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/AndroidManifest.xml
deleted file mode 100644
index 11eea9aa12..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoThingsDeviceProvider.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoThingsDeviceProvider.java
deleted file mode 100644
index 89ae3a0a37..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoThingsDeviceProvider.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo;
-
-import android.app.Service;
-
-import org.deviceconnect.android.message.DConnectMessageServiceProvider;
-
-public class FaBoThingsDeviceProvider extends DConnectMessageServiceProvider {
-
- @SuppressWarnings("unchecked")
- @Override
- protected Class getServiceClass() {
- Class extends Service> clazz = FaBoThingsDeviceService.class;
- return (Class) clazz;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoThingsDeviceService.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoThingsDeviceService.java
deleted file mode 100644
index 78076ae572..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/FaBoThingsDeviceService.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.device.things.FaBoThingsDeviceControl;
-
-/**
- * Android Things用のサービス.
- */
-public class FaBoThingsDeviceService extends FaBoDeviceService {
-
- @Override
- public void onCreate() {
- super.onCreate();
- // 画面がないのでLocal OAuthはfalseにしておく
- setUseLocalOAuth(false);
- }
-
- @Override
- protected FaBoDeviceControl createFaBoDeviceControl() {
- return new FaBoThingsDeviceControl();
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/ADT7410.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/ADT7410.java
deleted file mode 100644
index 3f8eedc347..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/ADT7410.java
+++ /dev/null
@@ -1,240 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.things;
-
-import com.google.android.things.pio.I2cDevice;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IADT7410;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * ADT7410を操作するクラス.
- *
- * Brick #207
- *
- */
-class ADT7410 extends BaseI2C implements IADT7410 {
- /**
- * ADT7410のアドレス.
- */
- private static final byte ADT7410_DEVICE_ADDR = 0x48;
-
- /**
- * ADT7410のコンフィグ用のレジスタ.
- */
- private static final int REGISTER_CONFIG = 0x03;
-
- /**
- * ADT7410のデバイスID取得レジスタ.
- */
- private static final int DEVICE_REG = 0x0B;
-
- /**
- * ADT7410のデバイスID.
- */
- private static final int DEVICE_ID = 0x0C;
-
- /**
- * 16bitの分解度を定義.
- */
- private static final int BIT16_RESOLUTION = 0x80;
-
- /**
- * I2Cデバイス.
- */
- private I2cDevice mI2cDevice;
-
- /**
- * 温度の値を保持するバッファ.
- */
- private byte[] mBuffer = new byte[2];
-
- /**
- * 温度監視用スレッド.
- */
- private WatchThread mWatchThread;
-
- /**
- * コンストラクタ.
- * @param control コントローラ
- */
- ADT7410(final FaBoThingsDeviceControl control) {
- mI2cDevice = control.getI2cDevice(ADT7410_DEVICE_ADDR);
- }
-
- @Override
- public void read(final OnADT7410Listener listener) {
- if (!checkDevice()) {
- listener.onError("ADT7410 is not connect.");
- } else {
- try {
- setADT7410();
-
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- readADT7410(mBuffer, mBuffer.length);
- listener.onData(convertTemperature(decodeUShort2(mBuffer, 0)));
- } catch (IOException e) {
- listener.onError(e.getMessage());
- }
- }
- }
-
- @Override
- public synchronized void startRead(final OnADT7410Listener listener) {
- if (!checkDevice()) {
- listener.onError("ADT7410 is not connect.");
- } else {
- if (mWatchThread == null) {
- mWatchThread = new WatchThread();
- mWatchThread.addListener(listener);
- mWatchThread.start();
- } else {
- mWatchThread.addListener(listener);
- }
- }
- }
-
- @Override
- public synchronized void stopRead(final OnADT7410Listener listener) {
- if (mWatchThread != null) {
- mWatchThread.removeListener(listener);
- if (mWatchThread.isEmptyListener()) {
- mWatchThread.stopWatch();
- mWatchThread = null;
- }
- }
- }
-
- @Override
- synchronized void destroy() {
- if (mWatchThread != null) {
- mWatchThread.stopWatch();
- mWatchThread = null;
- }
- }
-
- /**
- * 接続されているデバイスがADT7410か確認を行う.
- * @return ADT7410ならtrue、それ以外ならfalse
- */
- private boolean checkDevice() {
- if (mI2cDevice == null) {
- return false;
- } else {
- try {
- byte deviceId = mI2cDevice.readRegByte(DEVICE_REG);
- return (deviceId & DEVICE_ID) != 0;
- } catch (IOException e) {
- return false;
- }
- }
- }
-
- /**
- * ADT7410の初期化を行います.
- */
- private void setADT7410() throws IOException {
- mI2cDevice.writeRegByte(REGISTER_CONFIG, (byte) BIT16_RESOLUTION);
- }
-
- /**
- * ADT7410から温度を読み込みます.
- * @param buffer バッファ
- * @param length サイズ
- * @throws IOException 読み込みに失敗した場合に発生
- */
- private void readADT7410(final byte[] buffer, final int length) throws IOException {
- mI2cDevice.readRegBuffer(REGISTER_CONFIG, buffer, length);
- }
-
- /**
- * センサーの値を摂氏に変換します.
- * @param value センサーの値
- * @return 摂氏
- */
- private double convertTemperature(int value) {
- if ((value & 0x8000) != 0) {
- value = value - 65536;
- }
- return value / 128.0;
- }
-
- private class WatchThread extends Thread {
- /**
- * 停止フラグ.
- */
- private boolean mStopFlag;
-
- /**
- * リスナー.
- */
- private List mListeners = new CopyOnWriteArrayList<>();
-
- /**
- * リスナーを追加します.
- * @param listener 追加するリスナー
- */
- void addListener(final OnADT7410Listener listener) {
- mListeners.add(listener);
- listener.onStarted();
- }
-
- /**
- * リスナーを削除します.
- * @param listener 削除するリスナー
- */
- void removeListener(final OnADT7410Listener listener) {
- mListeners.remove(listener);
- }
-
- /**
- * 登録されているリスナーが空か確認します.
- * @return 空の場合はtrue、それ以外はfalse
- */
- boolean isEmptyListener() {
- return mListeners.isEmpty();
- }
-
- /**
- * 監視を停止します.
- */
- void stopWatch() {
- mListeners.clear();
- mStopFlag = true;
- interrupt();
- }
-
- @Override
- public void run() {
- final byte[] buffer = new byte[2];
- try {
- setADT7410();
-
- while (!mStopFlag) {
- readADT7410(buffer, buffer.length);
-
- double t = convertTemperature(decodeUShort2(buffer, 0));
- for (OnADT7410Listener l : mListeners) {
- l.onData(t);
- }
-
- try {
- Thread.sleep(33);
- } catch (InterruptedException e) {
- break;
- }
- }
- } catch (IOException e) {
- for (OnADT7410Listener l : mListeners) {
- l.onError(e.getMessage());
- }
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/ADXL345.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/ADXL345.java
deleted file mode 100644
index 3c03277b4e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/ADXL345.java
+++ /dev/null
@@ -1,263 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.things;
-
-import com.google.android.things.pio.I2cDevice;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IADXL345;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * ADXL345を操作するクラス.
- *
- * Brick #201
- *
- */
-class ADXL345 extends BaseI2C implements IADXL345 {
-
- /**
- * ADXL345のアドレス.
- */
- private static final byte ADXL345_DEVICE_ADDR = 0x53;
-
- /**
- * ADXL345のデバイスID取得レジスタ.
- */
- private static final int REGISTER_RA_DEVID = 0x0;
-
- /**
- * ADXL345のパワー設定レジスタ.
- */
- private static final int REGISTER_RA_POWER_CTL = 0x2D;
-
- /**
- * ADXL345のデータフォーマット設定レジスタ.
- */
- private static final int REGISTER_RA_DATA_FORMAT = 0x31;
-
- /**
- * ADXL345のデータ取得レジスタ.
- */
- private static final int REGISTER_RA_DATAX0 = 0x32;
-
- /**
- * ADXL345のデバイスID.
- */
- private static final int DEVICE_ID = 0xE5;
-
- /**
- * 13bitの分解能.
- */
- private static final double RESOLUTION = (16 + 16) / Math.pow(2, 13);
-
- /**
- * I2Cデバイス.
- */
- private I2cDevice mI2cDevice;
-
- /**
- * 加速度の値を保持するバッファ.
- */
- private byte[] mBuffer = new byte[6];
-
- /**
- * 加速度センサーの値を監視するスレッド.
- */
- private WatchThread mWatchThread;
-
- /**
- * コンストラクタ.
- * @param control コントローラ
- */
- ADXL345(final FaBoThingsDeviceControl control) {
- mI2cDevice = control.getI2cDevice(ADXL345_DEVICE_ADDR);
- }
-
- @Override
- public void read(final OnADXL345Listener listener) {
- try {
- if (!checkDevice()) {
- listener.onError("ADXL345 is not connect.");
- } else {
- startADXL345();
-
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- readADXL345(mBuffer, mBuffer.length);
-
- double x = convertResolution(decodeShort(mBuffer, 0));
- double y = convertResolution(decodeShort(mBuffer, 2));
- double z = convertResolution(decodeShort(mBuffer, 4));
-
- listener.onData(x, y, z);
- }
- } catch (IOException e) {
- listener.onError(e.getMessage());
- }
- }
-
- @Override
- public synchronized void startRead(final OnADXL345Listener listener) {
- if (!checkDevice()) {
- listener.onError("ADXL345 is not connect.");
- } else {
- if (mWatchThread == null) {
- mWatchThread = new WatchThread();
- mWatchThread.addListener(listener);
- mWatchThread.start();
- } else {
- mWatchThread.addListener(listener);
- }
- }
- }
-
- @Override
- public synchronized void stopRead(final OnADXL345Listener listener) {
- if (mWatchThread != null) {
- mWatchThread.removeListener(listener);
- if (mWatchThread.isEmptyListener()) {
- mWatchThread.stopWatch();
- mWatchThread = null;
- }
- }
- }
-
- @Override
- synchronized void destroy() {
- if (mWatchThread != null) {
- mWatchThread.stopWatch();
- mWatchThread = null;
- }
- }
-
- /**
- * 接続されているデバイスがADXL345か確認を行う.
- * @return ADXL345ならtrue、それ以外ならfalse
- */
- private boolean checkDevice() {
- if (mI2cDevice == null) {
- return false;
- } else {
- try {
- byte deviceId = mI2cDevice.readRegByte(REGISTER_RA_DEVID);
- return (deviceId & 0xFF) == DEVICE_ID;
- } catch (IOException e) {
- return false;
- }
- }
- }
-
- /**
- * ADXL345の加速度センサー開始要求を送信します.
- * @throws IOException 送信に失敗した場合に発生
- */
- private void startADXL345() throws IOException {
- mI2cDevice.writeRegByte(REGISTER_RA_DATA_FORMAT, (byte) 0x0B);
- mI2cDevice.writeRegByte(REGISTER_RA_POWER_CTL, (byte) 0x08);
- }
-
- /**
- * ADXL345から加速度センサーの値を取得します.
- * @param buffer バッファ
- * @param length バッファサイズ
- * @throws IOException 読み込みに失敗した場合に発生
- */
- private void readADXL345(final byte[] buffer, final int length) throws IOException {
- mI2cDevice.readRegBuffer(REGISTER_RA_DATAX0, buffer, length);
- }
-
- /**
- * 加速度センサーの値を重力加速度に変換します.
- * @param data 加速度センサーからの値
- * @return 重力加速度
- */
- private double convertResolution(final int data) {
- return data * RESOLUTION;
- }
-
- /**
- * 加速度センサーの値を取得するスレッド.
- */
- private class WatchThread extends Thread {
- /**
- * 停止フラグ.
- */
- private boolean mStopFlag;
-
- /**
- * リスナー.
- */
- private List mListeners = new CopyOnWriteArrayList<>();
-
- /**
- * リスナーを追加します.
- * @param listener 追加するリスナー
- */
- void addListener(final OnADXL345Listener listener) {
- mListeners.add(listener);
- listener.onStarted();
- }
-
- /**
- * リスナーを削除します.
- * @param listener 削除するリスナー
- */
- void removeListener(final OnADXL345Listener listener) {
- mListeners.remove(listener);
- }
-
- /**
- * 登録されているリスナーが空か確認します.
- * @return 空の場合はtrue、それ以外はfalse
- */
- boolean isEmptyListener() {
- return mListeners.isEmpty();
- }
-
- /**
- * 監視を停止します.
- */
- void stopWatch() {
- mListeners.clear();
- mStopFlag = true;
- interrupt();
- }
-
- @Override
- public void run() {
- final byte[] buffer = new byte[6];
-
- try {
- startADXL345();
-
- while (!mStopFlag) {
- readADXL345(buffer, buffer.length);
-
- double x = convertResolution(decodeShort(buffer, 0));
- double y = convertResolution(decodeShort(buffer, 2));
- double z = convertResolution(decodeShort(buffer, 4));
-
- for (OnADXL345Listener l : mListeners) {
- l.onData(x, y, z);
- }
-
- try {
- Thread.sleep(33);
- } catch (InterruptedException e) {
- break;
- }
- }
- } catch (IOException e) {
- for (OnADXL345Listener l : mListeners) {
- l.onError(e.getMessage());
- }
- mListeners.clear();
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/BaseI2C.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/BaseI2C.java
deleted file mode 100644
index 0ea7654ba5..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/BaseI2C.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.things;
-
-abstract class BaseI2C {
-
- void destroy() {}
-
- /**
- * 送られてきたデータをshortに変換して取得します.
- *
- * 4byteをshortにします。
- *
- *
- * リトルエンディアン.
- *
- * @param buffer 送られてきたデータ
- * @param startIndex 開始位置
- * @return shortデータ
- */
- static int decodeShort(final byte[] buffer, final int startIndex) {
- byte lsb = (byte) (buffer[startIndex] & 0xFF);
- byte msb = (byte) (buffer[startIndex + 1] & 0xFF);
- return ((msb << 8) | (lsb & 0xFF));
- }
-
- /**
- * 送られてきたデータをshortに変換して取得します.
- *
- * 4byteをunsigned shortにします。
- *
- *
- * ビックエンディアン.
- *
- * @param buffer 送られてきたデータ
- * @param startIndex 開始位置
- * @return shortデータ
- */
- static int decodeUShort2(final byte[] buffer, final int startIndex) {
- byte lsb = (byte) (buffer[startIndex] & 0xFF);
- byte msb = (byte) (buffer[startIndex + 1] & 0xFF);
- return ((lsb & 0xFF) << 8 | (msb & 0xFF));
- }
-
- static int dataConv(int data1, int data2) {
- int value = (data1 & 0xFF) | ((data2 & 0xFF) << 8);
- if ((value & 0x8000) != 0) {
- value -= (1 << 16);
- }
- return value;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/FaBoThingsDeviceControl.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/FaBoThingsDeviceControl.java
deleted file mode 100644
index 6d6300ef12..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/FaBoThingsDeviceControl.java
+++ /dev/null
@@ -1,496 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.things;
-
-import android.os.Handler;
-import android.os.Looper;
-import android.util.Log;
-
-import com.google.android.things.pio.Gpio;
-import com.google.android.things.pio.GpioCallback;
-import com.google.android.things.pio.I2cDevice;
-import com.google.android.things.pio.PeripheralManager;
-
-import org.deviceconnect.android.deviceplugin.fabo.BuildConfig;
-import org.deviceconnect.android.deviceplugin.fabo.device.FaBoDeviceControl;
-import org.deviceconnect.android.deviceplugin.fabo.device.IADT7410;
-import org.deviceconnect.android.deviceplugin.fabo.device.IADXL345;
-import org.deviceconnect.android.deviceplugin.fabo.device.IHTS221;
-import org.deviceconnect.android.deviceplugin.fabo.device.IISL29034;
-import org.deviceconnect.android.deviceplugin.fabo.device.ILIDARLiteV3;
-import org.deviceconnect.android.deviceplugin.fabo.device.IMPL115;
-import org.deviceconnect.android.deviceplugin.fabo.device.IMouseCar;
-import org.deviceconnect.android.deviceplugin.fabo.device.IRobotCar;
-import org.deviceconnect.android.deviceplugin.fabo.device.IVCNL4010;
-import org.deviceconnect.android.deviceplugin.fabo.param.FaBoShield;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.deviceconnect.android.deviceplugin.fabo.param.FaBoConst.STATUS_FABO_RUNNING;
-
-/**
- * Android Things版FaBoを操作するためのクラス.
- */
-public class FaBoThingsDeviceControl implements FaBoDeviceControl {
-
- /**
- * デバッグ用タグ.
- */
- private static final String TAG = "FaBo";
-
- /**
- * デバッグフラグ.
- */
- private static final boolean DEBUG = BuildConfig.DEBUG;
-
- /**
- * GPIOを保持するマップ.
- */
- private Map mGpioMap = new HashMap<>();
-
- /**
- * I2Cデバイスを保持するマップ.
- */
- private Map mI2cDeviceMap = new HashMap<>();
-
- /**
- * RobotCarを操作するためのクラス.
- */
- private RobotCar mRobotCar;
-
- /**
- * RobotCar(Mouse)を操作するためのクラス.
- */
- private MouseCar mMouseCar;
-
- /**
- * Brick #201 を操作するためのクラス.
- */
- private ADXL345 mADXL345;
-
- /**
- * Brick #207 を操作するためのクラス.
- */
- private ADT7410 mADT7410;
-
- /**
- * Brick #208 を操作するためのクラス.
- */
- private HTS221 mHTS221;
-
- /**
- * Brick #217 を操作するクラス.
- */
- private ISL29034 mISL29034;
-
- /**
- * Brick #204 を操作するクラス.
- */
- private MPL115 mMPL115;
-
- /**
- * Brick # 205 を操作するクラス.
- */
- private VCNL4010 mVCNL4010;
-
- /**
- * LIDARLite v3を操作するクラス.
- */
- private LIDARLiteV3 mLIDARLiteV3;
-
- /**
- * FaBoとの接続状態を通知するリスナー.
- */
- private OnFaBoDeviceControlListener mOnFaBoDeviceControlListener;
-
- /**
- * GPIOの値変更通知リスナー.
- */
- private final List mOnGPIOListeners = new ArrayList<>();
-
- /**
- * GPIO,I2cなどのデバイスを管理するクラス.
- */
- private PeripheralManager mManagerService;
-
- /**
- * GPIOの処理を行うハンドラ.
- */
- private Handler mHandler = new Handler(Looper.getMainLooper());
-
- /**
- * コンストラクタ.
- */
- public FaBoThingsDeviceControl() {
- }
-
- @Override
- public void initialize() {
- if (DEBUG) {
- Log.i(TAG, "FaBoThingsDeviceControl::initialize");
- }
-
- mManagerService = PeripheralManager.getInstance();
-
- initGpio();
- }
-
- @Override
- public void destroy() {
- if (DEBUG) {
- Log.i(TAG, "FaBoThingsDeviceControl::destroy");
- }
-
- synchronized (mOnGPIOListeners) {
- mOnGPIOListeners.clear();
- }
-
- for (Gpio gpio : mGpioMap.values()) {
- try {
- gpio.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- mGpioMap.clear();
-
- if (mADXL345 != null) {
- mADXL345.destroy();
- mADXL345 = null;
- }
-
- if (mADT7410 != null) {
- mADT7410.destroy();
- mADT7410 = null;
- }
-
- if (mHTS221 != null) {
- mHTS221.destroy();
- mHTS221 = null;
- }
-
- if (mISL29034 != null) {
- mISL29034.destroy();
- mISL29034 = null;
- }
-
- if (mMPL115 != null) {
- mMPL115.destroy();
- mMPL115 = null;
- }
-
- if (mVCNL4010 != null) {
- mVCNL4010.destroy();
- mVCNL4010 = null;
- }
-
- if (mLIDARLiteV3 != null) {
- mLIDARLiteV3.destroy();
- mLIDARLiteV3 = null;
- }
-
- for (I2cDevice device : mI2cDeviceMap.values()) {
- try {
- device.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- mI2cDeviceMap.clear();
- }
-
- @Override
- public boolean isPinSupported(final FaBoShield.Pin pin) {
- return mGpioMap.containsKey(pin.getPinNumber());
- }
-
- @Override
- public void writeAnalog(final FaBoShield.Pin pin, final int value) {
- throw new RuntimeException("Analog is not supported.");
- }
-
- @Override
- public void writeDigital(final FaBoShield.Pin pin, final FaBoShield.Level hl) {
- try {
- Gpio gpio = mGpioMap.get(pin.getPinNumber());
- if (gpio != null) {
- gpio.setValue(hl == FaBoShield.Level.HIGH);
- }
- } catch (Exception e) {
- if (DEBUG) {
- Log.w(TAG, "", e);
- }
- }
- }
-
- @Override
- public int getAnalog(final FaBoShield.Pin pin) {
- throw new RuntimeException("Analog is not supported.");
- }
-
- @Override
- public FaBoShield.Level getDigital(final FaBoShield.Pin pin) {
- try {
- Gpio gpio = mGpioMap.get(pin.getPinNumber());
- if (gpio != null) {
- return gpio.getValue() ? FaBoShield.Level.HIGH : FaBoShield.Level.LOW;
- }
- return null;
- } catch (Exception e) {
- return null;
- }
- }
-
- @Override
- public void setPinMode(final FaBoShield.Pin pin, final FaBoShield.Mode mode) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- try {
- Gpio gpio = mGpioMap.get(pin.getPinNumber());
- if (gpio != null && pin.getMode() != mode) {
- switch (mode) {
- case GPIO_IN:
- gpio.setEdgeTriggerType(Gpio.EDGE_NONE);
- gpio.setDirection(Gpio.DIRECTION_IN);
- gpio.setActiveType(Gpio.ACTIVE_HIGH);
- gpio.setEdgeTriggerType(Gpio.EDGE_BOTH);
- break;
-
- case GPIO_OUT:
- gpio.setEdgeTriggerType(Gpio.EDGE_NONE);
- gpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
- gpio.setActiveType(Gpio.ACTIVE_HIGH);
- break;
- }
- pin.setMode(mode);
- }
- } catch (IOException e) {
- if (DEBUG) {
- Log.w(TAG, "setPinMode", e);
- }
- }
- }
- });
- }
-
- @Override
- public int getStatus() {
- return STATUS_FABO_RUNNING;
- }
-
- @Override
- public IRobotCar getRobotCar() {
- if (mRobotCar == null) {
- mRobotCar = new RobotCar(this);
- }
- return mRobotCar;
- }
-
- @Override
- public IMouseCar getMouseCar() {
- if (mMouseCar == null) {
- mMouseCar = new MouseCar(this);
- }
- return mMouseCar;
- }
-
- @Override
- public IADXL345 getADXL345() {
- if (mADXL345 == null) {
- mADXL345 = new ADXL345(this);
- }
- return mADXL345;
- }
-
- @Override
- public IADT7410 getADT7410() {
- if (mADT7410 == null) {
- mADT7410 = new ADT7410(this);
- }
- return mADT7410;
- }
-
- @Override
- public IHTS221 getHTS221() {
- if (mHTS221 == null) {
- mHTS221 = new HTS221(this);
- }
- return mHTS221;
- }
-
- @Override
- public IVCNL4010 getVCNL4010() {
- if (mVCNL4010 == null) {
- mVCNL4010 = new VCNL4010(this);
- }
- return mVCNL4010;
- }
-
- @Override
- public IISL29034 getISL29034() {
- if (mISL29034 == null) {
- mISL29034 = new ISL29034(this);
- }
- return mISL29034;
- }
-
- @Override
- public IMPL115 getMPL115() {
- if (mMPL115 == null) {
- mMPL115 = new MPL115(this);
- }
- return mMPL115;
- }
-
- @Override
- public ILIDARLiteV3 getLIDARLite() {
- if (mLIDARLiteV3 == null) {
- mLIDARLiteV3 = new LIDARLiteV3(this);
- }
- return mLIDARLiteV3;
- }
-
- @Override
- public void setOnFaBoDeviceControlListener(final OnFaBoDeviceControlListener listener) {
- mOnFaBoDeviceControlListener = listener;
- }
-
- @Override
- public void addOnGPIOListener(final OnGPIOListener listener) {
- synchronized (mOnGPIOListeners) {
- if (!mOnGPIOListeners.contains(listener)) {
- mOnGPIOListeners.add(listener);
- }
- }
- }
-
- @Override
- public void removeOnGPIOListener(final OnGPIOListener listener) {
- synchronized (mOnGPIOListeners) {
- mOnGPIOListeners.remove(listener);
- }
- }
-
- /**
- * デジタルのピンデータが変更されたことを通知します.
- */
- private void notifyDigital() {
- synchronized (mOnGPIOListeners) {
- for (OnGPIOListener l : mOnGPIOListeners) {
- l.onDigital();
- }
- }
- }
-
- /**
- * GPIOからの通知を受け取るコールバック.
- */
- private GpioCallback mGpioCallback = new GpioCallback() {
- @Override
- public boolean onGpioEdge(final Gpio gpio) {
- if (DEBUG) {
- try {
- Log.e(TAG, "GPIO: " + gpio.getValue());
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- notifyDigital();
- return true;
- }
- @Override
- public void onGpioError(final Gpio gpio, final int error) {
- if (DEBUG) {
- Log.w(TAG, gpio + ": Error event " + error);
- }
- }
- };
-
- /**
- * GPIOを初期化します.
- */
- private void initGpio() {
- List portList = mManagerService.getGpioList();
- if (portList.isEmpty()) {
- if (DEBUG) {
- Log.i(TAG, "No GPIO port available on this device.");
- }
-
- if (mOnFaBoDeviceControlListener != null) {
- mOnFaBoDeviceControlListener.onFailedConnected();
- }
- } else {
- if (DEBUG) {
- Log.i(TAG, "List of available ports: " + portList);
- }
-
- Map pins = new HashMap<>();
- pins.put("BCM4", FaBoShield.Pin.PIN_D4);
- pins.put("BCM5", FaBoShield.Pin.PIN_D5);
- pins.put("BCM6", FaBoShield.Pin.PIN_D6);
- pins.put("BCM12", FaBoShield.Pin.PIN_D12);
-
- for (String name : portList) {
- try {
- FaBoShield.Pin pin = pins.get(name);
- if (pin != null) {
- Gpio gpio = mManagerService.openGpio(name);
- gpio.setEdgeTriggerType(Gpio.EDGE_NONE);
- gpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
- gpio.setActiveType(Gpio.ACTIVE_HIGH);
- gpio.registerGpioCallback(mGpioCallback);
- gpio.setValue(false);
-
- mGpioMap.put(pin.getPinNumber(), gpio);
- }
- } catch (IOException e) {
- if (DEBUG) {
- Log.w(TAG, " ", e);
- }
- }
- }
-
- if (mOnFaBoDeviceControlListener != null) {
- mOnFaBoDeviceControlListener.onConnected();
- }
- }
- }
-
- /**
- * I2cDeviceを取得します.
- *
- * 取得できなかった場合はnullを返却します。
- *
- *
- * 一度開いているI2cDeviceは、マップで管理して、取得します。
- *
- * @param address アドレス
- * @return I2cDeviceのインスタンス
- */
- I2cDevice getI2cDevice(final int address) {
- if (mI2cDeviceMap.containsKey(address)) {
- return mI2cDeviceMap.get(address);
- }
-
- List i2cList = mManagerService.getI2cBusList();
- if (i2cList.isEmpty()) {
- if (DEBUG) {
- Log.i(TAG, "No I2C port available on this device.");
- }
- return null;
- } else {
- try {
- I2cDevice device = mManagerService.openI2cDevice(i2cList.get(0), address);
- if (device != null) {
- mI2cDeviceMap.put(address, device);
- }
- return device;
- } catch (IOException e) {
- return null;
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/HTS221.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/HTS221.java
deleted file mode 100644
index 2ab506fbd9..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/HTS221.java
+++ /dev/null
@@ -1,248 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.things;
-
-import com.google.android.things.pio.I2cDevice;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IHTS221;
-
-import java.io.IOException;
-
-/**
- * HTS221を操作するクラス.
- *
- * Brick #208
- *
- */
-class HTS221 extends BaseI2C implements IHTS221 {
-
- /**
- * HTS221のアドレス.
- */
- private static final byte HTS221_SLAVE_ADDRESS = 0x5F;
-
- /**
- * HTS221のデバイスID.
- */
- private static final int DEVICE_ID = 0xBC;
-
- // AV_CONF:AVGH
- // Averaged humidity samples configuration
- // AVGH_4 : 0b00000000
- private static final byte AVGH_4 = 0x00;
- // AVGH_8 : 0b00000001
- private static final byte AVGH_8 = 0x01;
- // AVGH_16 : 0b00000010
- private static final byte AVGH_16 = 0x02;
- // AVGH_32 : 0b00000011 // defalut
- private static final byte AVGH_32 = 0x03;
- // AVGH_64 : 0b00000100
- private static final byte AVGH_64 = 0x04;
- // AVGH_128 : 0b00000101
- private static final byte AVGH_128 = 0x05;
- // AVGH_256 : 0b00000110
- private static final byte AVGH_256 = 0x06;
- // AVGH_512 : 0b00000111
- private static final byte AVGH_512 = 0x07;
-
- // AV_CONF:AVGT
- // Averaged temperature samples configuration
- // AVGT_2 : 0b00000000
- private static final byte AVGT_2 = 0x00;
- // AVGT_4 : 0b00001000
- private static final byte AVGT_4 = 0x08;
- // AVGT_8 : 0b00010000
- private static final byte AVGT_8 = 0x10;
- // AVGT_16 : 0b00011000 // defalut
- private static final byte AVGT_16 = 0x18;
- // AVGT_32 : 0b00100000
- private static final byte AVGT_32 = 0x20;
- // AVGT_64 : 0b00101000
- private static final byte AVGT_64 = 0x28;
- // AVGT_128 : 0b00110000
- private static final byte AVGT_128 = 0x30;
- // AVGT_256 : 0b00111000
- private static final byte AVGT_256 = 0x38;
-
- // CTRL_REG1
- // Power Down control : 0b10000000
- private static final byte PD = (byte) 0x80;
- // Block Data Update control : 0b00000100
- private static final byte BDU = 0x04;
- // Output Data Rate : One Shot : 0b00000000
- private static final byte ODR_ONE = 0x00;
- // Output Data Rate : 1Hz : 0b00000001
- private static final byte ODR_1HZ = 0x01;
- // Output Data Rate : 7Hz : 0b00000010
- private static final byte ODR_7HZ = 0x02;
- // Output Data Rate : 12.5Hz : 0b00000011
- private static final byte ODR_125HZ = 0x03;
-
- // CTRL_REG2
- // Reboot memory content : 0b10000000
- private static final byte BOOT = (byte) 0x80;
- // Heater : 0b00000010
- private static final byte HEATER = 0x02;
- // One shot enable : 0b00000001
- private static final byte ONE_SHOT = 0x01;
-
- // CTRL_REG3
- // DRDY pin is no connect in FaBo Brick
- private static final byte CTRL_REG3_DEFAULT = 0x00;
-
- // REGISTER_STATUS_REG
- // Humidity Data Available
- private static final byte H_DA = 0x02;
- // Temperature Data Available
- private static final byte T_DA = 0x01;
-
- private static final int REGISTER_DEVICE_REG = 0x0F;
- private static final int REGISTER_AV_CONF = 0x10;
- private static final int REGISTER_CTRL_REG1 = 0x20;
- private static final int REGISTER_CTRL_REG2 = 0x21;
- private static final int REGISTER_CTRL_REG3 = 0x22;
- private static final int REGISTER_STATUS_REG = 0x27;
- private static final int REGISTER_HUMIDITY_OUT_L = 0x28;
- private static final int REGISTER_HUMIDITY_OUT_H = 0x29;
- private static final int REGISTER_TEMP_OUT_L = 0x2A;
- private static final int REGISTER_TEMP_OUT_H = 0x2B;
- private static final int REGISTER_H0_RH_X2 = 0x30;
- private static final int REGISTER_H1_RH_X2 = 0x31;
- private static final int REGISTER_T0_DEGC_X8 = 0x32;
- private static final int REGISTER_T1_DEGC_X8 = 0x33;
- private static final int REGISTER_T1_T0_MSB = 0x35;
- private static final int REGISTER_H0_T0_OUT_L = 0x36;
- private static final int REGISTER_H0_T0_OUT_H = 0x37;
- private static final int REGISTER_H1_T0_OUT_L = 0x3A;
- private static final int REGISTER_H1_T0_OUT_H = 0x3B;
- private static final int REGISTER_T0_OUT_L = 0x3C;
- private static final int REGISTER_T0_OUT_H = 0x3D;
- private static final int REGISTER_T1_OUT_L = 0x3E;
- private static final int REGISTER_T1_OUT_H = 0x3F;
-
- /**
- * I2Cデバイス.
- */
- private I2cDevice mI2cDevice;
-
- private int h0_rh_x2;
- private int h1_rh_x2;
- private int h0_t0_out;
- private int h1_t0_out;
- private int t0_degc_x8;
- private int t1_degc_x8;
- private int t0_out;
- private int t1_out;
-
- HTS221(final FaBoThingsDeviceControl control) {
- mI2cDevice = control.getI2cDevice(HTS221_SLAVE_ADDRESS);
- }
-
- @Override
- public synchronized void readHumidity(final OnHumidityCallback callback) {
- if (!checkDevice()) {
- callback.onError("HTS221 is not connect.");
- } else {
- try {
- powerOn();
- configDevice();
-
- h0_rh_x2 = mI2cDevice.readRegByte(REGISTER_H0_RH_X2) & 0xFF;
- h1_rh_x2 = mI2cDevice.readRegByte(REGISTER_H1_RH_X2) & 0xFF;
-
- byte h0_t0_l = mI2cDevice.readRegByte(REGISTER_H0_T0_OUT_L);
- byte h0_t0_h = mI2cDevice.readRegByte(REGISTER_H0_T0_OUT_H);
- h0_t0_out = dataConv(h0_t0_l, h0_t0_h);
-
- byte h1_t0_l = mI2cDevice.readRegByte(REGISTER_H1_T0_OUT_L);
- byte h1_t0_h = mI2cDevice.readRegByte(REGISTER_H1_T0_OUT_H);
- h1_t0_out = dataConv(h1_t0_l, h1_t0_h);
-
- byte h_out_l = mI2cDevice.readRegByte(REGISTER_HUMIDITY_OUT_L);
- byte h_out_h = mI2cDevice.readRegByte(REGISTER_HUMIDITY_OUT_H);
-
- int h_out = dataConv(h_out_l, h_out_h);
-
- int t_H0_rH = h0_rh_x2 / 2;
- int t_H1_rH = h1_rh_x2 / 2;
-
- double humidity = t_H0_rH + (t_H1_rH - t_H0_rH) * (h_out - h0_t0_out) / (h1_t0_out - h0_t0_out);
- callback.onHumidity(humidity);
- } catch (IOException e) {
- callback.onError(e.getMessage());
- }
- }
- }
-
- @Override
- public synchronized void readTemperature(final OnTemperatureCallback callback) {
- if (!checkDevice()) {
- callback.onError("HTS221 is not connect.");
- } else {
- try {
- powerOn();
- configDevice();
-
- byte data = mI2cDevice.readRegByte(REGISTER_T1_T0_MSB);
-
- byte t0_degc_x8 = mI2cDevice.readRegByte(REGISTER_T0_DEGC_X8);
- byte t1_degc_x8 = mI2cDevice.readRegByte(REGISTER_T1_DEGC_X8);
- this.t0_degc_x8 = ((data & 0x3) << 8) | t0_degc_x8;
- this.t1_degc_x8 = ((data & 0xC) << 6) | t1_degc_x8;
-
- byte t0_l = mI2cDevice.readRegByte(REGISTER_T0_OUT_L);
- byte t0_h = mI2cDevice.readRegByte(REGISTER_T0_OUT_H);
- t0_out = dataConv(t0_l, t0_h);
-
- byte t1_l = mI2cDevice.readRegByte(REGISTER_T1_OUT_L);
- byte t1_h = mI2cDevice.readRegByte(REGISTER_T1_OUT_H);
- t1_out = dataConv(t1_l, t1_h);
-
- byte temp_out_l = mI2cDevice.readRegByte(REGISTER_TEMP_OUT_L);
- byte temp_out_h = mI2cDevice.readRegByte(REGISTER_TEMP_OUT_H);
- int t_out = dataConv(temp_out_l, temp_out_h);
-
- // 1/8にする
- int t_T0_degC = this.t0_degc_x8 / 8;
- int t_T1_degC = this.t1_degc_x8 / 8;
-
- // 線形補間でもとめる
- double temperature = t_T0_degC + (t_T1_degC - t_T0_degC) * (t_out - t0_out) / (t1_out - t0_out);
- callback.onTemperature(temperature);
- } catch (IOException e) {
- callback.onError(e.getMessage());
- }
- }
- }
-
- /**
- * HTS221の確認を行います.
- * @return HTS221の場合にはtrue、それ以外はfalse
- */
- private boolean checkDevice() {
- if (mI2cDevice == null) {
- return false;
- } else {
- try {
- byte deviceId = mI2cDevice.readRegByte(REGISTER_DEVICE_REG);
- return (deviceId & 0xFF) == DEVICE_ID;
- } catch (IOException e) {
- return false;
- }
- }
- }
-
- /**
- * HTS221へ起動要求を行います.
- * @throws IOException 起動要求に失敗した場合に発生.
- */
- private void powerOn() throws IOException {
- mI2cDevice.writeRegByte(REGISTER_CTRL_REG1, (byte) (PD | ODR_1HZ));
- }
-
- /**
- * HTS221へ設定要求を行います.
- * @throws IOException 設定要求に失敗した場合に発生.
- */
- private void configDevice() throws IOException {
- mI2cDevice.writeRegByte(REGISTER_AV_CONF, (byte) (AVGH_32 | AVGT_16));
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/ISL29034.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/ISL29034.java
deleted file mode 100644
index d22e549c79..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/ISL29034.java
+++ /dev/null
@@ -1,316 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.things;
-
-import com.google.android.things.pio.I2cDevice;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IISL29034;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * ISL29034を操作するクラス.
- *
- * Brick #217
- *
- */
-class ISL29034 extends BaseI2C implements IISL29034 {
-
- // ISL29034 I2C Slave Address
- private static final byte SLAVE_ADDRESS = 0x44;
-
- // ISL29034 Device ID(xx101xxx)
- private static final int DEVICE_ID = 0x28;
-
- // Register Addresses
- private static final int REG_CMD1 = 0x00;
- private static final int REG_CMD2 = 0x01;
- private static final int REG_DATA_L = 0x02;
- private static final int REG_DATA_H = 0x03;
- private static final int REG_ID = 0x0F;
-
- // Operation Mode
- private static final int OP_PWR_DOWN = 0x00; // Power-down the device(Default)
- private static final int OP_ALS_CONT = 0xA0; // Measures ALS continuously
-
- // FULL SCALE LUX RANGE
- private static final int FS_0 = 0x00; // 1,000(Default)
- private static final int FS_1 = 0x01; // 4,000
- private static final int FS_2 = 0x02; // 16,000
- private static final int FS_3 = 0x03; // 64,000
-
- // ADC RESOLUTION
- private static final int RES_16 = 0x00; // 16bit(Default)
- private static final int RES_12 = 0x04; // 12bit
- private static final int RES_8 = 0x08; // 8bit
- private static final int RES_4 = 0x0C; // 4bit
-
- private static final int ID_MASK = 0x38; // ISL29034 Device ID Mask(00111000)
-
- /**
- * ISL29034に設定する範囲.
- */
- private int mRange = FS_0;
-
- /**
- * ISL29034に設定する解像度.
- */
- private int mResolution = RES_4;
-
- /**
- * I2Cデバイス.
- */
- private I2cDevice mI2cDevice;
-
- /**
- * 管理用スレッド.
- */
- private WatchThread mWatchThread;
-
- /**
- * コンストラクタ.
- * @param control FaBoコントローラ
- */
- ISL29034(final FaBoThingsDeviceControl control) {
- mI2cDevice = control.getI2cDevice(SLAVE_ADDRESS);
- }
-
- @Override
- public void read(final OnAmbientLightListener listener) {
- if (!checkDevice()) {
- listener.onError("ISL29034 is not connect.");
- } else {
- try {
- setISL29034();
-
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- listener.onData(readADC());
- } catch (IOException e) {
- listener.onError(e.getMessage());
- }
- }
- }
-
- @Override
- public synchronized void startRead(final OnAmbientLightListener listener) {
- if (!checkDevice()) {
- listener.onError("ISL29034 is not connect.");
- } else {
- if (mWatchThread == null) {
- mWatchThread = new WatchThread();
- mWatchThread.addListener(listener);
- mWatchThread.start();
- } else {
- mWatchThread.addListener(listener);
- }
- }
- }
-
- @Override
- public synchronized void stopRead(final OnAmbientLightListener listener) {
- if (mWatchThread != null) {
- mWatchThread.removeListener(listener);
- if (mWatchThread.isEmptyListener()) {
- mWatchThread.stopWatch();
- mWatchThread = null;
- }
- }
- }
-
- @Override
- synchronized void destroy() {
- if (mWatchThread != null) {
- mWatchThread.stopWatch();
- mWatchThread = null;
- }
- }
-
- /**
- * 接続されているデバイスがISL29034か確認を行う.
- * @return ISL29034ならtrue、それ以外ならfalse
- */
- private boolean checkDevice() {
- if (mI2cDevice == null) {
- return false;
- } else {
- try {
- byte deviceId = mI2cDevice.readRegByte(REG_ID);
- return ((deviceId & ID_MASK) == DEVICE_ID);
- } catch (IOException e) {
- return false;
- }
- }
- }
-
- /**
- * 範囲の値を取得します.
- * @return 範囲
- */
- private int getRange() {
- switch (mRange) {
- case FS_0:
- return 1000;
- case FS_1:
- return 4000;
- case FS_2:
- return 16000;
- case FS_3:
- return 64000;
- default:
- return -1;
- }
- }
-
- /**
- * 解像度の値を取得します.
- * @return 解像度
- */
- private int getResolution() {
- switch (mResolution) {
- case RES_16:
- return 65535;
- case RES_12:
- return 4095;
- case RES_8:
- return 255;
- case RES_4:
- return 15;
- default:
- return -1;
- }
- }
-
- /**
- * ISL29034の設定を行います.
- */
- private void setISL29034() throws IOException {
- setOperation(OP_ALS_CONT);
- setCMD2(FS_3, RES_16);
- }
-
- /**
- * Set Operation Mode.
- * @param config Operation Mode DEFAULT:Power-down the device
- */
- private void setOperation(int config) throws IOException {
- mI2cDevice.writeRegByte(REG_CMD1, (byte) (config & 0xFF));
- }
-
- /**
- * CMD2にrangeとresolutionを設定します.
- * @param range luxの範囲
- * @param resolution 解像度
- */
- private void setCMD2(final int range, final int resolution) throws IOException {
- mRange = range;
- mResolution = resolution;
- byte value = mI2cDevice.readRegByte(REG_CMD2);
-
- value &= 0xFC;
- value |= mRange;
-
- value &= 0xF3;
- value |= mResolution;
-
- mI2cDevice.writeRegByte(REG_CMD2, value);
- }
-
- /**
- * Analog to Digital Converterの値を読み込みます.
- */
- private float readADC() throws IOException {
- byte[] buffer = new byte[2];
- mI2cDevice.readRegBuffer(REG_DATA_L, buffer, 2);
- return convert(decodeShort(buffer, 0));
- }
-
- /**
- * Analog to Digital Converterの値をluxに変換します.
- * @param adc Analog to Digital Converterの値
- * @return lux
- */
- private float convert(final int adc) {
- int range = getRange();
- int count = getResolution();
- return (range / (float) count) * adc;
- }
-
- /**
- * 管理用スレッド.
- */
- private class WatchThread extends Thread {
- /**
- * 停止フラグ.
- */
- private boolean mStopFlag;
-
- /**
- * リスナー.
- */
- private List mListeners = new CopyOnWriteArrayList<>();
-
- /**
- * リスナーを追加します.
- * @param listener 追加するリスナー
- */
- void addListener(final OnAmbientLightListener listener) {
- mListeners.add(listener);
- listener.onStarted();
- }
-
- /**
- * リスナーを削除します.
- * @param listener 削除するリスナー
- */
- void removeListener(final OnAmbientLightListener listener) {
- mListeners.remove(listener);
- }
-
- /**
- * 登録されているリスナーが空か確認します.
- * @return 空の場合はtrue、それ以外はfalse
- */
- boolean isEmptyListener() {
- return mListeners.isEmpty();
- }
-
- /**
- * 監視を停止します.
- */
- void stopWatch() {
- mListeners.clear();
- mStopFlag = true;
- interrupt();
- }
-
- @Override
- public void run() {
- try {
- setISL29034();
-
- while (!mStopFlag) {
- try {
- Thread.sleep(33);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- double lux = readADC();
- for (OnAmbientLightListener l : mListeners) {
- l.onData(lux);
- }
- }
- } catch (IOException e) {
- for (OnAmbientLightListener l : mListeners) {
- l.onError(e.getMessage());
- }
- mListeners.clear();
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/LIDARLiteV3.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/LIDARLiteV3.java
deleted file mode 100644
index 98b65e6f4f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/LIDARLiteV3.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.things;
-
-import com.google.android.things.pio.I2cDevice;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.ILIDARLiteV3;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-class LIDARLiteV3 extends BaseI2C implements ILIDARLiteV3 {
- // ISL29034 I2C Slave Address
- private static final byte SLAVE_ADDRESS = 0x62;
-
- /**
- * I2Cデバイス.
- */
- private I2cDevice mI2cDevice;
-
- /**
- * 読み込み用バッファ.
- */
- private final byte[] mBuffer = new byte[2];
-
- /**
- * 監視スレッド.
- */
- private WatchThread mWatchThread;
-
- /**
- * コンストラクタ.
- * @param control コントローラ
- */
- LIDARLiteV3(final FaBoThingsDeviceControl control) {
- mI2cDevice = control.getI2cDevice(SLAVE_ADDRESS);
- }
-
- @Override
- public void read(final OnLIDARLiteListener listener) {
- if (!checkDevice()) {
- listener.onError("LIDARLiteV3 is not connect.");
- } else {
- try {
- setLIDARLiteConfig(1);
- listener.onData(readDistance());
- } catch (IOException e) {
- listener.onError(e.getMessage());
- }
- }
- }
-
- @Override
- public synchronized void startRead(final OnLIDARLiteListener listener) {
- if (!checkDevice()) {
- listener.onError("LIDARLiteV3 is not connect.");
- } else {
- if (mWatchThread == null) {
- mWatchThread = new WatchThread();
- mWatchThread.addListener(listener);
- mWatchThread.start();
- } else {
- mWatchThread.addListener(listener);
- }
- }
- }
-
- @Override
- public synchronized void stopRead(final OnLIDARLiteListener listener) {
- if (mWatchThread != null) {
- mWatchThread.removeListener(listener);
- if (mWatchThread.isEmptyListener()) {
- mWatchThread.stopWatch();
- mWatchThread = null;
- }
- }
- }
-
- @Override
- void destroy() {
- if (mWatchThread != null) {
- mWatchThread.stopWatch();
- mWatchThread = null;
- }
- }
-
- /**
- * 接続されているデバイスがADXL345か確認を行う.
- * @return ADXL345ならtrue、それ以外ならfalse
- */
- private boolean checkDevice() {
- if (mI2cDevice == null) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * LIDARLite v3の設定を行います.
- * @param configuration 設定番号
- * @throws IOException 設定に失敗した場合に発生
- */
- private synchronized void setLIDARLiteConfig(final int configuration) throws IOException {
- switch (configuration) {
- case 0: // Default mode, balanced performance
- mI2cDevice.writeRegByte(0x02, (byte) 0x80); // Default
- mI2cDevice.writeRegByte(0x04, (byte) 0x08); // Default
- mI2cDevice.writeRegByte(0x1C, (byte) 0x00); // Default
- break;
-
- case 1: // Short range, high speed
- mI2cDevice.writeRegByte(0x02, (byte) 0x1d);
- mI2cDevice.writeRegByte(0x04, (byte) 0x08); // Default
- mI2cDevice.writeRegByte(0x1c, (byte) 0x00); // Default
- break;
-
- case 2: // Default range, higher speed short range
- mI2cDevice.writeRegByte(0x02, (byte) 0x80); // Default
- mI2cDevice.writeRegByte(0x04, (byte) 0x00);
- mI2cDevice.writeRegByte(0x1c, (byte) 0x00); // Default
- break;
-
- case 3: // Maximum range
- mI2cDevice.writeRegByte(0x02, (byte) 0xff);
- mI2cDevice.writeRegByte(0x04, (byte) 0x08); // Default
- mI2cDevice.writeRegByte(0x1c, (byte) 0x00); // Default
- break;
-
- case 4: // High sensitivity detection, high erroneous measurements
- mI2cDevice.writeRegByte(0x02, (byte) 0x80); // Default
- mI2cDevice.writeRegByte(0x04, (byte) 0x08); // Default
- mI2cDevice.writeRegByte(0x1c, (byte) 0x80);
- break;
-
- case 5: // Low sensitivity detection, low erroneous measurements
- mI2cDevice.writeRegByte(0x02, (byte) 0x80); // Default
- mI2cDevice.writeRegByte(0x04, (byte) 0x08); // Default
- mI2cDevice.writeRegByte(0x1c, (byte) 0xb0);
- break;
- }
- }
-
- /**
- * 距離センサーの値を取得します.
- * @return 距離
- * @throws IOException 距離センサーの値の読み込みに失敗した場合に発生
- */
- private synchronized int readDistance() throws IOException {
- mI2cDevice.writeRegByte(0x00, (byte) 0x04);
- try {
- Thread.sleep(3);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- mI2cDevice.readRegBuffer(0x8F, mBuffer, mBuffer.length);
- return decodeUShort2(mBuffer, 0);
- }
-
- /**
- * 距離センサーを監視するクラス.
- */
- private class WatchThread extends Thread {
- /**
- * 停止フラグ.
- */
- private boolean mStopFlag;
-
- /**
- * リスナー.
- */
- private List mListeners = new CopyOnWriteArrayList<>();
-
- /**
- * リスナーを追加します.
- * @param listener 追加するリスナー
- */
- void addListener(final OnLIDARLiteListener listener) {
- mListeners.add(listener);
- listener.onStarted();
- }
-
- /**
- * リスナーを削除します.
- * @param listener 削除するリスナー
- */
- void removeListener(final OnLIDARLiteListener listener) {
- mListeners.remove(listener);
- }
-
- /**
- * 登録されているリスナーが空か確認します.
- * @return 空の場合はtrue、それ以外はfalse
- */
- boolean isEmptyListener() {
- return mListeners.isEmpty();
- }
-
- /**
- * 監視を停止します.
- */
- void stopWatch() {
- mListeners.clear();
- mStopFlag = true;
- interrupt();
- }
-
- @Override
- public void run() {
- try {
- setLIDARLiteConfig(1);
-
- while (!mStopFlag) {
- int distance = readDistance();
-
- for (OnLIDARLiteListener l : mListeners) {
- l.onData(distance);
- }
-
- try {
- Thread.sleep(33);
- } catch (InterruptedException e) {
- break;
- }
- }
- } catch (IOException e) {
- for (OnLIDARLiteListener l : mListeners) {
- l.onError(e.getMessage());
- }
- mListeners.clear();
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/MPL115.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/MPL115.java
deleted file mode 100644
index 90ebe7bd3f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/MPL115.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.things;
-
-import com.google.android.things.pio.I2cDevice;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IMPL115;
-
-import java.io.IOException;
-
-/**
- * MPL115を操作するクラス.
- *
- * Brick #204
- *
- */
-class MPL115 extends BaseI2C implements IMPL115 {
-
- // MPL115A2 I2C slave address
- private static final byte SLAVE_ADDRESS = 0x60;
-
- // MPL115A2 Register Address
- private static final int PADC_MSB = 0x00;
- private static final int PADC_LSB = 0x01;
- private static final int TADC_MSB = 0x02;
- private static final int TACD_LSB = 0x03;
- private static final int A0_MSB = 0x04;
- private static final int A0_LSB = 0x05;
- private static final int B1_MSB = 0x06;
- private static final int B1_LSB = 0x07;
- private static final int B2_MSB = 0x08;
- private static final int B2_LSB = 0x09;
- private static final int C12_MSB = 0x0A;
- private static final int C12_LSB = 0x0B;
- private static final int CONVERT = 0x12;
-
- /**
- * I2Cデバイス.
- */
- private I2cDevice mI2cDevice;
- private float mA0;
- private float mB1;
- private float mB2;
- private float mC12;
-
- MPL115(final FaBoThingsDeviceControl control) {
- mI2cDevice = control.getI2cDevice(SLAVE_ADDRESS);
- }
-
- @Override
- public void readAtmosphericPressure(final OnAtmosphericPressureListener listener) {
- if (!checkDevice()) {
- listener.onError("MPL115 is not connected.");
- } else {
- try {
- readCoef();
-
- mI2cDevice.writeRegByte(CONVERT, (byte) 0x01);
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- byte[] buffer = new byte[4];
- mI2cDevice.readRegBuffer(PADC_MSB, buffer, 4);
-
- int padc = (((buffer[0] & 0xFF) << 8) | (buffer[1] & 0xFF)) >> 6;
- int tadc = (((buffer[2] & 0xFF) << 8) | (buffer[3] & 0xFF)) >> 6;
-
- double pcomp = mA0 + (mB1 + mC12 * tadc) * padc + mB2 * tadc;
- double hpa = pcomp * ((1150.0 - 500.0) / 1023.0) + 500.0;
- double temp = 25.0 - (tadc - 512.0) / 5.35;
-
- listener.onData(hpa, temp);
- } catch (IOException e) {
- listener.onError(e.getMessage());
- }
- }
- }
-
- /**
- * 接続されているデバイスがMPL115か確認を行う.
- * @return MPL115ならtrue、それ以外ならfalse
- */
- private boolean checkDevice() {
- return mI2cDevice != null;
- }
-
- /**
- * MPL115に設定されている値を取得します.
- * @throws IOException 設定の取得に失敗した場合に発生
- */
- private void readCoef() throws IOException {
- byte[] data = new byte[8];
- mI2cDevice.readRegBuffer(A0_MSB, data, 8);
-
- mA0 = dataConv(data[1], data[0]) / (float) (1 << 3);
- mB1 = dataConv(data[3], data[2]) / (float) (1 << 13);
- mB2 = dataConv(data[5], data[4]) / (float) (1 << 14);
- mC12 = dataConv(data[7], data[6]) / (float) (1 << 24);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/MouseCar.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/MouseCar.java
deleted file mode 100644
index ab67c2a3cb..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/MouseCar.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.things;
-
-import com.google.android.things.pio.I2cDevice;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IMouseCar;
-
-import java.io.IOException;
-
-class MouseCar implements IMouseCar {
- /**
- * 左側のモータへのアドレス.
- */
- private static final byte DRV8830_LEFT_ADDRESS = 0x64;
-
- /**
- * 右側のモータへのアドレス.
- */
- private static final byte DRV8830_RIGHT_ADDRESS = 0x65;
-
- /**
- * 前進.
- */
- private static final byte DRV8830_FORWARD = 0x01;
-
- /**
- * 行進.
- */
- private static final byte DRV8830_BACK = 0x02;
-
- /**
- * 停止.
- */
- private static final byte DRV8830_STOP = 0x00;
-
- /**
- * モータコントロール用のコマンド.
- */
- private static final int MOTOR_CONTROL = 0x00;
-
- /**
- * モータの回転数の上限を定義.
- */
- private static final int MAX_MOTOR = 55;
-
- /**
- * 左モータ用のI2Cデバイス.
- */
- private I2cDevice mLeftDevice;
-
- /**
- * 右モータ用のI2Cデバイス
- */
- private I2cDevice mRightDevice;
-
- MouseCar(final FaBoThingsDeviceControl control) {
- mRightDevice = control.getI2cDevice(DRV8830_RIGHT_ADDRESS);
- mLeftDevice = control.getI2cDevice(DRV8830_LEFT_ADDRESS);
- }
-
- @Override
- public void move(float rightSpeed, float leftSpeed) {
- int rightDir = 0;
- int leftDir = 0;
- float tmpLeftSpeed = 0;
- float tmpRightSpeed = 0;
-
- if (rightSpeed > 0) {
- rightDir = DRV8830_BACK;
- tmpRightSpeed = rightSpeed;
- } else if (rightSpeed < 0) {
- rightDir = DRV8830_FORWARD;
- tmpRightSpeed = -rightSpeed;
- }
-
- if (leftSpeed > 0) {
- leftDir = DRV8830_BACK;
- tmpLeftSpeed = leftSpeed;
- } else if (leftSpeed < 0) {
- leftDir = DRV8830_FORWARD;
- tmpLeftSpeed = -leftSpeed;
- }
-
- try {
- moveMotor((rightDir | ((calcSpeed(tmpRightSpeed) + 5) << 2)), (leftDir | ((calcSpeed(tmpLeftSpeed) + 5) << 2)));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void stop() {
- try {
- moveMotor(DRV8830_STOP, DRV8830_STOP);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * モータの回転を送信します.
- * @param valueLeft 左側のモーター
- * @param valueRight 右側のモーター
- */
- private void moveMotor(final int valueLeft, final int valueRight) throws IOException {
- mLeftDevice.writeRegByte(MOTOR_CONTROL, (byte) valueLeft);
- mRightDevice.writeRegByte(MOTOR_CONTROL, (byte) valueRight);
- }
-
- /**
- * 0.0f〜1.0fの値を0〜55の値に変換します.
- * @param speed スピード(0.0f〜1.0f)
- * @return 0〜MAX_MOTORの値
- */
- private static int calcSpeed(final float speed) {
- float tmp = Math.abs(speed);
- if (tmp > 1.0f) {
- return MAX_MOTOR;
- }
- return (int) (MAX_MOTOR * tmp);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/RobotCar.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/RobotCar.java
deleted file mode 100644
index 459eed04a3..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/RobotCar.java
+++ /dev/null
@@ -1,205 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.things;
-
-import com.google.android.things.pio.I2cDevice;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IRobotCar;
-
-import java.io.IOException;
-
-class RobotCar implements IRobotCar {
-
- private static final String TAG = "FaBo";
-
- /**
- * モータ用のI2Cデバイスのアドレス.
- */
- private static final int MOTOR_ADDRESS = 0x64;
-
- /**
- * サーボモータ用のI2Cデバイスのアドレス.
- */
- private static final int PCA9685_ADDRESS = 0x40;
-
- /**
- * モータコントロール用のコマンド.
- */
- private static final int MOTOR_CONTROL = 0x00;
-
- /**
- * モータコントロール用の前進コマンド.
- */
- private static final int MOTOR_FORWARD = 0x01;
-
- /**
- * モータコントロール用の後進コマンド.
- */
- private static final int MOTOR_BACK = 0x02;
-
- /**
- * モータコントロール用の停止コマンド.
- */
- private static final int MOTOR_STOP = 0x00;
-
- private static final int PWM0_ON_L = 0x06;
- private static final int PWM0_ON_H = 0x07;
- private static final int PWM0_OFF_L = 0x08;
- private static final int PWM0_OFF_H = 0x09;
- private static final int PRE_SCALE = 0xFE;
- private static final int SLEEP_BIT = 0x10;
- private static final int CONTROL_REG = 0x00;
- private static final int OSC_CLOCK = 25000000;
-
- /**
- * サーボモータの下限を定義.
- *
- * 前のタイヤを左端まで回す値.
- *
- */
- private static final float PWM_MIN = 6f;
-
- /**
- * サーボモータの上限を定義.
- *
- * 前のタイヤを右端まで回す値.
- *
- */
- private static final float PWM_MAX = 9f;
-
- /**
- * 初期化を行う周波数.
- */
- private static final int FREQUENCY = 50;
-
- /**
- * モータ用のI2Cデバイス.
- */
- private I2cDevice mMotorDevice;
-
- /**
- * サーボ用のI2Cデバイス
- */
- private I2cDevice mPCA9685Device;
-
- RobotCar(final FaBoThingsDeviceControl control) {
- mPCA9685Device = control.getI2cDevice(PCA9685_ADDRESS);
- mMotorDevice = control.getI2cDevice(MOTOR_ADDRESS);
- }
-
- @Override
- public void turnHandle(float direction) {
- if (direction < -1) {
- direction = -1;
- }
- if (direction > 1) {
- direction = 1;
- }
-
- try {
- setFreq(mPCA9685Device, FREQUENCY);
- setPWM(calcHandleDirection(direction));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void move(final float speed) {
- if (speed > 0) {
- move(MOTOR_FORWARD, speed);
- } else {
- move(MOTOR_BACK, Math.abs(speed));
- }
- }
-
- @Override
- public void stop() {
- try {
- mMotorDevice.writeRegByte(MOTOR_CONTROL, (byte) MOTOR_STOP);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * 移動します.
- * @param dir 向き
- * @param speed 速度
- */
- private void move(final int dir, float speed) {
- if (speed < 0) {
- speed = 0;
- }
-
- if (speed > 1) {
- speed = 1;
- }
-
- byte data = (byte) (dir | ((calcSpeed(speed) + 5) << 2));
- try {
- mMotorDevice.writeRegByte(MOTOR_CONTROL, data);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * サーボモータの回転を行います.
- * @param direction 回転する向き
- * @throws IOException サーボモータの回転に失敗した場合に発生
- */
- private void setPWM(final float direction) throws IOException {
- int value = (int) (direction * 4096 / 100);
- mPCA9685Device.writeRegByte(PWM0_ON_L, (byte) 0x00);
- mPCA9685Device.writeRegByte(PWM0_ON_H, (byte) 0x00);
- mPCA9685Device.writeRegByte(PWM0_OFF_L, (byte) (value & 0xFF));
- mPCA9685Device.writeRegByte(PWM0_OFF_H, (byte) ((value >> 8) & 0xFF));
- }
-
- /**
- * タイヤの回す角度を計算します。
- * @param x 回す値
- * @return 角度
- */
- private float calcHandleDirection(final float x) {
- float b = PWM_MAX - ((PWM_MAX - PWM_MIN) / 2.0f);
- return ((PWM_MAX - PWM_MIN) / 2.0f) * x + b;
- }
-
- /**
- * 0.0f〜1.0fの値を0〜55の値に変換します.
- * @param speed スピード(0.0f〜1.0f)
- * @return 0〜55の値
- */
- private int calcSpeed(final float speed) {
- return (int) (55 * speed);
- }
-
- /**
- * サーボモータの初期化を行います.
- * @param device サーボモータのI2Cデバイス
- * @param hz 初期化する周波数
- * @throws IOException 初期化設定に失敗した時に発生
- */
- private void setFreq(final I2cDevice device, final int hz) throws IOException {
- int value = Math.round(OSC_CLOCK / (4096 * hz)) - 1;
-
- byte ctrl_dat = device.readRegByte(CONTROL_REG);
- device.writeRegByte(CONTROL_REG, (byte) (ctrl_dat | SLEEP_BIT));
-
- try {
- Thread.sleep(1);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- device.writeRegByte(PRE_SCALE, (byte) value);
-
- try {
- Thread.sleep(5);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- device.writeRegByte(CONTROL_REG, (byte) (ctrl_dat & (~SLEEP_BIT)));
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/VCNL4010.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/VCNL4010.java
deleted file mode 100644
index aea7218dfc..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/java/org/deviceconnect/android/deviceplugin/fabo/device/things/VCNL4010.java
+++ /dev/null
@@ -1,466 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo.device.things;
-
-import com.google.android.things.pio.I2cDevice;
-
-import org.deviceconnect.android.deviceplugin.fabo.device.IVCNL4010;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * VCNL4010を操作するクラス.
- *
- * Brick #205
- *
- */
-class VCNL4010 extends BaseI2C implements IVCNL4010 {
- // I2C VCNL4010 Slave Address
- private static final byte SLAVE_ADDRESS = 0x13;
-
- // Product,Revision ID Value
- private static final int DEVICE_ID = 0x21;
-
- // Register Addresses
- private static final int REG_CMD = 0x80;
- private static final int DEVICE_REG = 0x81;
- private static final int REG_PROX_RATE = 0x82;
- private static final int REG_LED_CRNT = 0x83;
- private static final int REG_AMBI_PARM = 0x84;
- private static final int REG_AMBI_DATA_H = 0x85;
- private static final int REG_AMBI_DATA_L = 0x86;
- private static final int REG_PROX_DATA_H = 0x87;
- private static final int REG_PROX_DATA_L = 0x88;
- private static final int REG_INT_CTRL = 0x89;
- private static final int REG_INT_LOW_H = 0x8A;
- private static final int REG_INT_LOW_L = 0x8B;
- private static final int REG_INT_HIGH_H = 0x8C;
- private static final int REG_INT_HIGH_L= 0x8D;
- private static final int REG_INT_STAT = 0x8E;
- private static final int REG_PROX_ADJ = 0x8F;
-
- // Commands
- private static final int CMD_SELFTIMED_EN = 0x01;
- private static final int CMD_PROX_EN = 0x02;
- private static final int CMD_ALS_EN = 0x04;
- private static final int CMD_PROX_OD = 0x08;
- private static final int CMD_ALS_OD = 0x10;
- private static final int CMD_PROX_DRDY = 0x20;
- private static final int CMD_ALS_DRDY = 0x40;
-
- // Proximity Measurement Rate
- private static final int PROX_RATE_1 = 0x00;
- private static final int PROX_RATE_3 = 0x01;
- private static final int PROX_RATE_7 = 0x02;
- private static final int PROX_RATE_16 = 0x03;
- private static final int PROX_RATE_31 = 0x04;
- private static final int PROX_RATE_62 = 0x05;
- private static final int PROX_RATE_125 = 0x06;
- private static final int PROX_RATE_250 = 0x07;
-
- // Ambient Light Parameter
- private static final int AMBI_CONT_CONV_MODE = 0x80;
- private static final int AMBI_RATE_1 = 0x00;
- private static final int AMBI_RATE_2 = 0x10;
- private static final int AMBI_RATE_3 = 0x20;
- private static final int AMBI_RATE_4 = 0x30;
- private static final int AMBI_RATE_5 = 0x40;
- private static final int AMBI_RATE_6 = 0x50;
- private static final int AMBI_RATE_8 = 0x60;
- private static final int AMBI_RATE_10 = 0x70;
- private static final int AMBI_AUTO_OFFSET = 0x08;
- private static final int AMBI_AVE_NUM_1 = 0x00;
- private static final int AMBI_AVE_NUM_2 = 0x01;
- private static final int AMBI_AVE_NUM_4 = 0x02;
- private static final int AMBI_AVE_NUM_8 = 0x03;
- private static final int AMBI_AVE_NUM_16 = 0x04;
- private static final int AMBI_AVE_NUM_32 = 0x05;
- private static final int AMBI_AVE_NUM_64 = 0x06;
- private static final int AMBI_AVE_NUM_128 = 0x07;
-
- /**
- * 距離の閾値.
- */
- private static final double THRESHOLD = 1.8;
-
- /**
- * I2Cデバイス.
- */
- private I2cDevice mI2cDevice;
-
- /**
- * 一時的にデータを格納するバッファ.
- */
- private byte[] mBuffer = new byte[2];
-
- /**
- * Proximityの値を監視するスレッド.
- */
- private ProximityWatchTread mProximityWatchTread;
-
- /**
- * AmbientLightの値を監視するスレッド.
- */
- private AmbientLightWatchThread mAmbientLightWatchThread;
-
- /**
- * コンストラクタ.
- * @param control コントローラ
- */
- VCNL4010(final FaBoThingsDeviceControl control) {
- mI2cDevice = control.getI2cDevice(SLAVE_ADDRESS);
- }
-
- @Override
- public void readProximity(final OnProximityListener listener) {
- if (!checkDevice()) {
- listener.onError("VCNL4010 is not connect.");
- } else {
- try {
- setVCNL4010();
-
- try {
- Thread.sleep(33);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- listener.onData(readProx() < THRESHOLD);
- } catch (IOException e) {
- listener.onError(e.getMessage());
- }
- }
- }
-
- @Override
- public synchronized void startProximity(final OnProximityListener listener) {
- if (!checkDevice()) {
- listener.onError("VCNL4010 is not connect.");
- } else {
- if (mProximityWatchTread == null) {
- mProximityWatchTread = new ProximityWatchTread();
- mProximityWatchTread.addListener(listener);
- mProximityWatchTread.start();
- } else {
- mProximityWatchTread.addListener(listener);
- }
- }
- }
-
- @Override
- public synchronized void stopProximity(final OnProximityListener listener) {
- if (mProximityWatchTread != null) {
- mProximityWatchTread.removeListener(listener);
- if (mProximityWatchTread.isEmptyListener()) {
- mProximityWatchTread.stopWatch();
- mProximityWatchTread = null;
- }
- }
- }
-
- @Override
- public void readAmbientLight(final OnAmbientLightListener listener) {
- if (!checkDevice()) {
- listener.onError("VCNL4010 is not connect.");
- } else {
- try {
- setVCNL4010();
-
- try {
- Thread.sleep(33);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- listener.onData(readAmbi());
- } catch (IOException e) {
- listener.onError(e.getMessage());
- }
- }
- }
-
- @Override
- public synchronized void startAmbientLight(final OnAmbientLightListener listener) {
- if (!checkDevice()) {
- listener.onError("VCNL4010 is not connect.");
- } else {
- if (mAmbientLightWatchThread == null) {
- mAmbientLightWatchThread = new AmbientLightWatchThread();
- mAmbientLightWatchThread.addListener(listener);
- mAmbientLightWatchThread.start();
- } else {
- mAmbientLightWatchThread.addListener(listener);
- }
- }
- }
-
- @Override
- public synchronized void stopAmbientLight(final OnAmbientLightListener listener) {
- if (mAmbientLightWatchThread != null) {
- mAmbientLightWatchThread.removeListener(listener);
- if (mAmbientLightWatchThread.isEmptyListener()) {
- mAmbientLightWatchThread.stopWatch();
- mAmbientLightWatchThread = null;
- }
- }
- }
-
- @Override
- synchronized void destroy() {
- if (mProximityWatchTread != null) {
- mProximityWatchTread.stopWatch();
- mProximityWatchTread = null;
- }
-
- if (mAmbientLightWatchThread != null) {
- mAmbientLightWatchThread.stopWatch();
- mAmbientLightWatchThread = null;
- }
- }
-
- /**
- * 接続されているデバイスがVCNL4010か確認を行う.
- * @return VCNL4010ならtrue、それ以外ならfalse
- */
- private boolean checkDevice() {
- if (mI2cDevice == null) {
- return false;
- } else {
- try {
- byte deviceId = mI2cDevice.readRegByte(DEVICE_REG);
- return (deviceId & 0xFF) == DEVICE_ID;
- } catch (IOException e) {
- return false;
- }
- }
- }
-
- /**
- * VCNL4010の設定を行います.
- */
- private void setVCNL4010() throws IOException {
- setCommand(CMD_SELFTIMED_EN | CMD_PROX_EN | CMD_ALS_EN);
- setProxRate(PROX_RATE_250);
- setLedCurrent(20);
- setAmbiParm(AMBI_RATE_10 | AMBI_AUTO_OFFSET | AMBI_AVE_NUM_128);
- }
-
- /**
- * コマンドを送信します.
- * @param config 送信するコマンド設定
- */
- private void setCommand(final int config) throws IOException {
- mI2cDevice.writeRegByte(REG_CMD, (byte) config);
- }
-
- /**
- * Proximityのレートを送信します.
- * @param config 送信するレート
- */
- private void setProxRate(final int config) throws IOException {
- mI2cDevice.writeRegByte(REG_PROX_RATE, (byte) config);
- }
-
- /**
- * LED Currentの値を送信します.
- * @param config 送信する値
- */
- private void setLedCurrent(final int config) throws IOException {
- mI2cDevice.writeRegByte(REG_LED_CRNT, (byte) config);
- }
-
- /**
- * Ambient Lightの設定を送信します.
- * @param config 送信する設定
- */
- private void setAmbiParm(final int config) throws IOException {
- mI2cDevice.writeRegByte(REG_AMBI_PARM, (byte) config);
- }
-
- /**
- * 距離(cm)に変換します.
- * @param proximity センサーからの値
- * @return 距離(cm)
- */
- private double convert(final int proximity) {
- return 0.1 + ((65535 - proximity) / 65535.0) * 2.0;
- }
-
- /**
- * Proximityの値を読み込みます.
- * @return Proximityの値
- * @throws IOException Proximityの読み込みに失敗した場合に発生
- */
- private synchronized double readProx() throws IOException {
- mI2cDevice.readRegBuffer(REG_PROX_DATA_H, mBuffer, 2);
- return convert(decodeUShort2(mBuffer, 0));
- }
-
- /**
- * Ambient Lightの値を読み込みます.
- * @return Ambient Lightの値
- * @throws IOException Ambient Lightの読み込みに失敗した場合に発生
- */
- private synchronized double readAmbi() throws IOException {
- mI2cDevice.readRegBuffer(REG_AMBI_DATA_H, mBuffer, 2);
- return decodeUShort2(mBuffer, 0);
- }
-
- /**
- * 近距離を監視するスレッド.
- */
- private class ProximityWatchTread extends Thread {
- /**
- * 停止フラグ.
- */
- private boolean mStopFlag;
-
- /**
- * リスナー.
- */
- private List mListeners = new CopyOnWriteArrayList<>();
-
- /**
- * 距離.
- */
- private double mOldProximity;
-
- /**
- * リスナーを追加します.
- * @param listener 追加するリスナー
- */
- void addListener(final OnProximityListener listener) {
- mListeners.add(listener);
- listener.onStarted();
- }
-
- /**
- * リスナーを削除します.
- * @param listener 削除するリスナー
- */
- void removeListener(final OnProximityListener listener) {
- mListeners.remove(listener);
- }
-
- /**
- * 登録されているリスナーが空か確認します.
- * @return 空の場合はtrue、それ以外はfalse
- */
- boolean isEmptyListener() {
- return mListeners.isEmpty();
- }
-
- /**
- * 監視を停止します.
- */
- void stopWatch() {
- mListeners.clear();
- mStopFlag = true;
- interrupt();
- }
-
- @Override
- public void run() {
- try {
- setVCNL4010();
-
- while (!mStopFlag) {
- try {
- Thread.sleep(33);
- } catch (InterruptedException e) {
- break;
- }
-
- double proximity = readProx();
- if (mOldProximity > THRESHOLD && proximity < THRESHOLD) {
- for (OnProximityListener l : mListeners) {
- l.onData(true);
- }
- } else if (mOldProximity < THRESHOLD && proximity > THRESHOLD) {
- for (OnProximityListener l : mListeners) {
- l.onData(false);
- }
- }
- mOldProximity = proximity;
- }
- } catch (IOException e) {
- for (OnProximityListener l : mListeners) {
- l.onError(e.getMessage());
- }
- }
- }
- }
-
- /**
- * 照度を監視するスレッド.
- */
- private class AmbientLightWatchThread extends Thread {
- /**
- * 停止フラグ.
- */
- private boolean mStopFlag;
-
- /**
- * リスナー.
- */
- private List mListeners = new CopyOnWriteArrayList<>();;
-
- /**
- * リスナーを追加します.
- * @param listener 追加するリスナー
- */
- void addListener(final OnAmbientLightListener listener) {
- mListeners.add(listener);
- listener.onStarted();
- }
-
- /**
- * リスナーを削除します.
- * @param listener 削除するリスナー
- */
- void removeListener(final OnAmbientLightListener listener) {
- mListeners.remove(listener);
- }
-
- /**
- * 登録されているリスナーが空か確認します.
- * @return 空の場合はtrue、それ以外はfalse
- */
- boolean isEmptyListener() {
- return mListeners.isEmpty();
- }
-
- /**
- * 監視を停止します.
- */
- void stopWatch() {
- mListeners.clear();
- mStopFlag = true;
- interrupt();
- }
-
- @Override
- public void run() {
- try {
- setVCNL4010();
-
- while (!mStopFlag) {
- try {
- Thread.sleep(33);
- } catch (InterruptedException e) {
- break;
- }
-
- double lux = readAmbi();
- for (OnAmbientLightListener l : mListeners) {
- l.onData(lux);
- }
- }
- } catch (IOException e) {
- for (OnAmbientLightListener l : mListeners) {
- l.onError(e.getMessage());
- }
- }
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/res/values/strings.xml b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/res/values/strings.xml
deleted file mode 100644
index 24e754ade9..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- FaBo (Device Connect Device Plug-in)
-
diff --git a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/test/java/org/deviceconnect/android/deviceplugin/fabo/ExampleUnitTest.java b/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/test/java/org/deviceconnect/android/deviceplugin/fabo/ExampleUnitTest.java
deleted file mode 100644
index 2711734c5b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceFaBo/things-plugin/src/test/java/org/deviceconnect/android/deviceplugin/fabo/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.deviceconnect.android.deviceplugin.fabo;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/LICENSE.TXT b/dConnectDevicePlugin/dConnectDeviceHOGP/LICENSE.TXT
deleted file mode 100644
index be22761015..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/LICENSE.TXT
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2017 NTT DOCOMO, INC.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/README.md b/dConnectDevicePlugin/dConnectDeviceHOGP/README.md
deleted file mode 100644
index 0adb29d08d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/README.md
+++ /dev/null
@@ -1,351 +0,0 @@
-# HOGPプラグインについて
-
-このHOGPプラグインでは、HOGPを実装して、RESTfulから接続先のマウスやキーボードを操作するための機能を提供します。
-
-HOGP(HID over GATT Profile)とは、Bluetooth low energyを使用してマウスやキーボードなどを接続するためのプロファイルです。
-
-## 開発環境
-Android Studio 2.2.1以上
-
-## ビルドマニュアル
-- [HOGPビルドマニュアル](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/HOGP-Build)
-
-## サポートするプロファイル
-- hogp
-- mouse
-- keyboard
-
-# HOGPプラグインの使用方法
-HOGPプラグインの使用法について簡単に説明を行います。
-
-## HOGPサーバの有効化
-HOGPを使用するためには、まずHOGPサーバを有効にする必要があります。
-
-有効化するには、以下の2通りあります。
-
-- HOGPプラグインの設定画面を開いて、HOGPサーバを有効にする
-- HOGPプロファイルを用いてHOGPサーバを有効にする
-
-### HOGPプラグインの設定画面から有効にする場合
-HOGPプラグインの設定画面を開き「HOGPサーバ」のスイッチをONにします。
-
-HOGPサーバ設定の項目に、Mouse、Keyboardの設定がありますので、必要に応じて設定を行なってください。
-
-### HOGPプロファイルを用いてHOGPサーバを有効にする場合
-以下のAPIを使用します。
-
-```http
-POST /gotapi/hogp?serviceId=[HOGPのサービスID]&mouse=relative&keyboard=true
-```
-
-mouseには、absoluteとrelativeを指定することができます。
-mouseを使用しない場合には、noneを指定してください。
-
-Android端末では、absoluteは対応していませんので、absoluteを使用したい場合には、MacBookなど対応しているデバイスから接続を行なってください。
-
-keyboardとして使用する場合はtrue、使用しない場合はfalseを指定してください。
-
-```json
-{
- "result" : 1,
- "errorCode" : 1,
- "errorMessage" : "Failed to start HOGP Server. message=Bluetooth is disabled."
-}
-```
-
-上記のエラーが返却されてきた場合には、Bluetoothが無効になっていますので、以下のコマンドでBluetoothを有効化してください。
-
-```http
-PUT /gotapi/connection/ble?serviceId=[HOSTのサービスID]
-```
-
-## デバイスとのペアリング
-
-HOGPサーバが有効化されるとマウス・キーボードとしてBluetoothデバイスが公開されます。
-Android端末やMacBookなどから、HOGPサーバの端末を見つけてペアリングを行なってください。
-端末のデバイス名を確認するには、Android端末の設定画面からBluetooth設定を開き、メニューから「この機器の名前を変更」を選択することでできます。
-
-MacBookから接続する場合は、「システム環境設定」→「マウス」→「Bluetoothマウスを設定」を開きます。
-デバイスのリストからHOGPサーバを起動している端末を選択してペアリングを行います。
-
-Android端末から接続する場合は、端末の設定画面からBluetoothを開きます。
-使用可能なデバイスからHOGPサーバを起動している端末を選択してペアリングを行います。
-
-Android端末でペアリングを行う場合に、ペアリング確認ダイアログが画面に表示されないことがあります。
-その場合には、通知バーに登録されていますので、そちらをクリックしてダイアログを表示してください。
-通知バーにもペアリング確認ダイアログがない場合には、もう一度最初からペアリングを行なってください。
-
-## デバイスIDの取得
-
-接続ができた後は、Service Discoveryを行うことで接続しているデバイスを発見することができます。
-
-本来であれば、デバイス名が取得できるのですが、デバイス名が取得できずにBluetoothアドレスを表示することがありますので、ご注意ください。
-
-## マウス操作
-
-マウスとして接続した場合には、マウスカーソルの移動やマウスクリックをAPIで行うことができます。
-
-### relativeの場合
-relativeの場合には、相対的にマウスカーソルを移動します。x,yに指定した値の分だけ現在のカーソルの位置から移動します。
-移動量は、-1.0から1.0の範囲が指定することができます。
-
-右下に移動する場合には以下のようにxとyを指定します。
-
-```http
-POST /gotapi/mouse?serviceId=[操作する端末のID]&x=0.1&y=0.1
-```
-
-左上に移動する場合には、以下のようにxとyに負の値を指定します。
-
-```http
-POST /gotapi/mouse?serviceId=[操作する端末のID]&x=-0.1&y=-0.1
-```
-
-### absoluteの場合
-absoluteの場合には、絶対座標でマウスカーソルが移動します。
-x座標は、0.0が左端、1.0が右端になり、画面横幅の割合の位置にマウスカーソルが移動します。
-y座標は、0.0が上端、1.0が下端になり、画面縦幅の割合の位置にマウスカーソルが移動します。
-(デバイスの座標系によっては、反対になることもあります。)
-
-画面の右下にマウスカーソルを移動する場合には以下のようにxとyを指定します。
-
-```http
-POST /gotapi/mouse?serviceId=[操作する端末のID]&x=1&y=1
-```
-画面の左上にマウスカーソルを移動する場合には以下のようにxとyを指定します。
-
-```http
-POST /gotapi/mouse?serviceId=[操作する端末のID]&x=0&y=0
-```
-
-画面の中央にマウスカーソルを移動する場合には以下のようにxとyを指定します。
-
-```http
-POST /gotapi/mouse?serviceId=[操作する端末のID]&x=0.5&y=0.5
-```
-
-Android端末では、absoluteがサポートされていませんので動作しません。ご注意ください。
-
-### マウスホイール
-
-マウスホイールでスクロールする場合には、以下のAPIで行います。
-wheelに指定した分だけ現在の位置からスクロールします。
-移動量は、-1.0から1.0の範囲が指定することができます。
-
-```http
-POST /gotapi/mouse?serviceId=[操作する端末のID]&wheel=0.1
-```
-
-ホイールの回転の向きは、OSや設定によって異なりますので、ご注意ください。
-
-### マウスクリック
-
-クリックする場合には、以下のAPIで行います。
-マウスカーソルがある位置でマウスの左クリックを行います。
-
-```http
-POST /gotapi/mouse/click?serviceId=[操作する端末のサービスID]&left=true
-```
-
-右クリックを行う場合には、right=trueを指定します。
-
-```http
-POST /gotapi/mouse/click?serviceId=[操作する端末のサービスID]&right=true
-```
-
-### マウス長押し
-
-マウスの左ボタンを長押しを行う場合には、以下のAPIのようにleftButtonにtrueを指定します。
-
-```http
-POST /gotapi/mouse?serviceId=[操作する端末のID]&leftButton=true
-```
-
-長押しを解除するには、leftButtonにfalseをしています。
-(leftButtonが省略された場合もfalseの扱いになります。)
-
-```http
-POST /gotapi/mouse?serviceId=[操作する端末のID]&leftButton=false
-```
-
-以下のようにleftButton=trueを送ってから2秒待ってleftButton=falseを送ることで、2秒間の長押しを行うことができます。
-
-```http
-POST /gotapi/mouse?serviceId=[操作する端末のID]&leftButton=true
- ↓
- 2秒待つ
- ↓
-POST /gotapi/mouse?serviceId=[操作する端末のID]&leftButton=false
-```
-
-leftButton=trueを送った後にleftButton=falseを送らないとマウスの左ボタンの長押しが解除されませんので、ご注意ください。
-
-
-## キーボード操作
-キーボードとして接続した場合には、文字の入力や削除、カーソルの移動などをAPIで行うことができます。
-ただし、入力される側の端末がテキストエディタなどにフォーカスがあっていない場合には何も処理されませんのご注意ください。
-
-HIDの文字コードで入力したい場合には、以下のAPIを使用します。
-keyCodeには、HIDで定義されているキーコードを指定します。
-modifyには、shift,alt,gui,ctrlを指定します。
-
-以下のAPIを実行すると「A」が入力されます。
-
-```http
-POST /gotapi/keyboard?serviceId=[操作する端末のサービスID]&keyCode=0x04&modify=shift
-```
-
-以下のように、modifyは、カンマ区切りで送ることでモディファイキーの同時押しとして送ることができます。
-
-```http
-POST /gotapi/keyboard?serviceId=[操作する端末のサービスID]&keyCode=0x04&modify=shift,ctrl
-```
-
-HIDのキーコードでは分かりづらいので、ASCII文字列で入力できるように以下のAPIを定義しています。
-パラメータstringに指定されたASCII文字列を入力します。
-
-```http
-POST /gotapi/keyboard/ascii?serviceId=[操作する端末のサービスID]&string=A
-```
-
-入力した文字列を削除するには、以下のAPIを使用します。
-
-```http
-POST /gotapi/keyboard/del?serviceId=[操作する端末のサービスID]
-```
-
-エスケープする場合には、以下のAPIを使用します。
-Android端末の場合には、バックキーと同じ効果がありますので、画面を閉じるなどの処理が行えます。
-
-```http
-POST /gotapi/keyboard/esc?serviceId=[操作する端末のサービスID]
-```
-
-エンターキーを押下する場合には、以下のAPIを使用します。
-
-```http
-POST /gotapi/keyboard/enter?serviceId=[操作する端末のサービスID]
-```
-
-十字キーを押下する場合には、以下のAPIを使用します。
-
-```http
-POST /gotapi/keyboard/upArrow?serviceId=[操作する端末のサービスID]
-POST /gotapi/keyboard/downArrow?serviceId=[操作する端末のサービスID]
-POST /gotapi/keyboard/leftArrow?serviceId=[操作する端末のサービスID]
-POST /gotapi/keyboard/rightArrow?serviceId=[操作する端末のサービスID]
-```
-
-# サポート状況
-HOGPサーバを起動するには、Android 5.0以上が必要になり、端末のチップセットがペリフェラルに対応している必要があります。
-Nexus5などのAndroid 5.0以上でもチップセットがペリフェラルに対応していない端末では、HOGPプラグインは使用することができません。
-
-HOGPクライアントは、Android 4.4からサポートされています。
-Nexus5は、HOGPサーバとしては使用できませんが、クライアントとして接続することはできます。
-
-また、Android端末にはBluetooth接続に相性があるために、接続してもHOGPとして使用できないことがあります。
-
-動作検証を行った結果を以下の表にまとめました。
-
-### Nexus9 (7.1.1)
-
-|HOGPクライアント|動作|備考|
-|:----|:-----|:-----|
-|Nexus5(5.0.1)|○||
-|GalaxyS7Edge(7.0)|○||
-|ZenPhone(7.0)|○||
-|Xperia X compact(6.0.1)|○||
-|Xperia XZ Premium(7.1.1)|○||
-|Nexus5(4.4.3)|○||
-|AQUOS Compact SH-02H(6.0.1)|○||
-|ARROWS NX F-05F(5.0.2)|×|ペアリングはできましたが、Reportを送っても動作はしませんでした。|
-|MacBook Pro (MacOS Sierra)|○||
-
-### Xperia X compact (6.0.1)
-
-|HOGPクライアント|動作|備考|
-|:----|:-----|:-----|
-|Nexus9(7.1.1)|○||
-|Nexus5(5.0.1)|○||
-|ZenPhone(7.0)|×|ペアリングはできましたが、Reportを送っても動作はしませんでした。|
-|GalaxyS7Edge(7.0)|○||
-|Xperia XZ Premium(7.1.1)|○|処理が遅いのかマウスポインターの動きやキーボードの動きが遅いです。|
-|Nexus5(4.4.3)|○||
-|ARROWS NX F-05F(5.0.2)|×|ペアリングはできましたが、Reportを送っても動作はしませんでした。|
-|MacBook Pro (MacOS Sierra)|○||
-
-### ZenPhone (7.0)
-
-|HOGPクライアント|動作|備考|
-|:----|:-----|:-----|
-|Nexus9(7.1.1)|○||
-|Nexus5(5.0.1)|○||
-|Xperia X compact(6.0.1)|×|ペアリングができませんでした。|
-|GalaxyS7Edge(7.0)|○||
-|Xperia XZ Premium(7.1.1)|○||
-|Nexus5(4.4.3)|○||
-|ARROWS NX F-05F(5.0.2)|×|ペアリングはできましたが、Reportを送っても動作はしませんでした。|
-|MacBook Pro (MacOS Sierra)|○||
-
-### Galaxy S7 Edge (7.0)
-
-|HOGPクライアント|動作|備考|
-|:----|:-----|:-----|
-|Nexus9(7.1.1)|○||
-|Xperia X compact(6.0.1)|×|ペアリングができませんでした。|
-|Nexus5(5.0.1)|×|ペアリングはできましたが、Reportを送っても動作はしませんでした。|
-|ZenPhone(7.0)|×|ペアリングもなかなか成功せずに、ペアリングに成功して、Reportを送っても動作しませんでした。|
-|ARROWS NX F-05F(5.0.2)|×|ペアリングはできましたが、Reportを送っても動作はしませんでした。|
-|Xperia XZ Premium(7.1.1)|×|ペアリングはできましたが、Reportを送っても動作はしませんでした。|
-|MacBook Pro (MacOS Sierra)|○||
-
-### Xperia XZ Premium (7.1.1)
-
-|HOGPクライアント|動作|備考|
-|:----|:-----|:-----|
-|Nexus9(7.1.1)|○||
-|Nexus5(5.0.1)|○|ちょっと動きが遅い感じがしました。|
-|ZenPhone(7.0)|×|ペアリングはできましたが、Reportを送っても動作はしませんでした。|
-|Xperia X compact(6.0.1)|×|ペアリングはできましたが、Reportを送っても動作はしませんでした。|
-|GalaxyS7Edge(7.0)|○||
-|ARROWS NX F-05F(5.0.2)|×|ペアリングはできましたが、Reportを送っても動作はしませんでした。|
-
-### AQUOS Compact SH-02H(6.0.1)
-
-|HOGPクライアント|動作|備考|
-|:----|:-----|:-----|
-|Nexus9(7.1.1)|○||
-|Xperia X compact(6.0.1)|○||
-|Nexus5(4.4.3)|○||
-|Nexus5(5.0.1)|○||
-|GalaxyS7Edge(7.0)|○||
-|Xperia XZ Premium(7.1.1)|○||
-|ZenPhone(7.0)|○||
-|ARROWS NX F-05F(5.0.2)|×|ペアリングはできましたが、Reportを送っても動作はしませんでした。|
-|MacBook Pro (MacOS Sierra)|×|ペアリングができませんでした。ペアリング確認画面が表示されませんでした。|
-
-### Nexus6(7.1.1)
-|HOGPクライアント|動作|備考|
-|:----|:-----|:-----|
-|AQUOS Ever SH-04G(5.0.2)|o||
-|Xperia Z4 Tablet(6.0.1)|o||
-|GalaxyS5(4.4.2)|x|ペアリングできませんでした|
-|ArrowsTablet F-04H(6.0.1)|x|ペアリングはできましたが、マウスポインタなど反応がしませんでした|
-
-### Xperia Z4 Tablet(6.0.1)
-
-|HOGPクライアント|動作|備考|
-|:----|:-----|:-----|
-|AQUOS Ever SH-04G(5.0.2)|o||
-|Nexus6(7.1.1)|o||
-|GalaxyS5(4.4.2)|x|ペアリングできませんでした|
-|ArrowsTablet F-04H(6.0.1)|x|ペアリングはできましたが、マウスポインタなど反応がしませんでした|
-
-### ArrowsTablet F-04H(6.0.1)
-
-|HOGPクライアント|動作|備考|
-|:----|:-----|:-----|
-|AQUOS Ever SH-04G(5.0.2)|x|ペアリングはできましたが、マウスポインタなど反応がしませんでした|
-|Nexus6(7.1.1)|x|ペアリングはできましたが、マウスポインタなど反応がしませんでした|
-|GalaxyS5(4.4.2)|x|ペアリングできませんでした|
-|Xperia Z4 Tablet(6.0.1)|x|ペアリングはできましたが、マウスポインタなど反応がしませんでした|
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/build.gradle b/dConnectDevicePlugin/dConnectDeviceHOGP/build.gradle
deleted file mode 100644
index 7f3d7e1d7e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/build.gradle
+++ /dev/null
@@ -1,16 +0,0 @@
-buildscript {
- repositories {
- google()
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:3.6.2'
- }
-}
-
-allprojects {
- repositories {
- jcenter()
- google()
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/gradle.properties b/dConnectDevicePlugin/dConnectDeviceHOGP/gradle.properties
deleted file mode 100644
index 1d687c154b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/gradle.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-storeFile=YOUR_STORE_FILE
-storePassword=YOUR_STORE_PASSWORD
-keyAlias=YOUR_KEY_ALIAS
-keyPassword=YOUR_KEY_PASSWORD
-android.useAndroidX=true
-android.enableJetifier=true
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/gradle/wrapper/gradle-wrapper.jar b/dConnectDevicePlugin/dConnectDeviceHOGP/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 13372aef5e..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceHOGP/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/gradle/wrapper/gradle-wrapper.properties b/dConnectDevicePlugin/dConnectDeviceHOGP/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index c229cadbbb..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Tue Apr 14 16:54:18 JST 2020
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/gradlew b/dConnectDevicePlugin/dConnectDeviceHOGP/gradlew
deleted file mode 100755
index 9d82f78915..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/gradlew
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/gradlew.bat b/dConnectDevicePlugin/dConnectDeviceHOGP/gradlew.bat
deleted file mode 100644
index aec99730b4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/gradlew.bat
+++ /dev/null
@@ -1,90 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/build.gradle b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/build.gradle
deleted file mode 100644
index ceef99c72f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/build.gradle
+++ /dev/null
@@ -1,69 +0,0 @@
-apply plugin: 'com.android.application'
-// Create github.properties in root project folder file with
-// gpr.usr=GITHUB_USER_ID
-// gpr.key=PERSONAL_ACCESS_TOKEN
-def githubPropertiesFile = rootProject.file("github.properties")
-def githubProperties = new Properties()
-if (githubPropertiesFile.exists()) {
- githubProperties.load(new FileInputStream(githubPropertiesFile))
-}
-dependencies {
- implementation fileTree(include: '*.jar', dir: 'libs')
- implementation 'org.deviceconnect:dconnect-device-plugin-sdk:2.8.4'
-}
-
-android {
-
- compileSdkVersion 29
-
- defaultConfig {
- applicationId "org.deviceconnect.android.deviceplugin.hogp"
- minSdkVersion 14
- targetSdkVersion 29
- versionCode 1
- versionName '1.0.0'
- }
-
- signingConfigs {
- releaseConfig {
- storeFile=file(project.properties.storeFile)
- storePassword=project.properties.storePassword
- keyAlias=project.properties.keyAlias
- keyPassword=project.properties.keyPassword
- }
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
- signingConfig signingConfigs.releaseConfig
- }
- }
-
- packagingOptions {
- exclude 'LICENSE.txt'
- exclude 'META-INF/DEPENDENCIES'
- exclude 'META-INF/LICENSE'
- exclude 'META-INF/NOTICE'
- }
-
- tasks.withType(JavaCompile) {
- options.encoding = 'UTF-8'
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- repositories {
- maven {
- name = "DeviceConnect-Android"
- url = uri("https://maven.pkg.github.com/DeviceConnect/DeviceConnect-Android")
-
- credentials {
- username = System.getenv("GPR_USER") ?: githubProperties['gpr.usr']
- password = System.getenv("GPR_API_KEY") ?: githubProperties['gpr.key']
- }
- }
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/AndroidManifest.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/AndroidManifest.xml
deleted file mode 100644
index 0f65291c80..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/assets/api/hogp.json b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/assets/api/hogp.json
deleted file mode 100644
index 3b05740be1..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/assets/api/hogp.json
+++ /dev/null
@@ -1 +0,0 @@
-{"swagger":"2.0","info":{"description":"HID over GATT Profileの設定を行うAPI.","version":"2.0.0","title":"HOGP Profile"},"basePath":"/gotapi/hogp","consumes":["application/x-www-form-urlencoded","multipart/form-data"],"paths":{"/":{"post":{"summary":"HID over GATT Profileを有効にします。","description":"HID over GATT Profileを有効にします。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"},{"name":"mouse","in":"formData","description":"マウスの有効・無効の設定を行います.","required":false,"type":"string","enum":["absolute","relative","none"]},{"name":"keyboard","in":"formData","description":"キーボードの有効・無効の設定を行います.","required":false,"type":"boolean"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/HOGPResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"},"delete":{"summary":"HID over GATT Profileを無効にします。","description":"HID over GATT Profileを無効にします。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/HOGPResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}}},"definitions":{"CommonResponse":{"type":"object","required":["product","result","version"],"properties":{"result":{"type":"integer","description":"0:正常応答 0以外:異常応答"},"product":{"type":"string","description":"DeviceConnectシステムの名前。"},"version":{"type":"string","description":"DeviceConnectシステムのバージョン名。"},"hmac":{"type":"string","description":"レスポンスに対する署名。 アプリケーション側から事前にHMACキーを共有されていた場合は必須。"}}},"HOGPResponse":{"allOf":[{"$ref":"#/definitions/CommonResponse"}]}}}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/assets/api/joystick.json b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/assets/api/joystick.json
deleted file mode 100644
index 6de52f7d5f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/assets/api/joystick.json
+++ /dev/null
@@ -1 +0,0 @@
-{"swagger":"2.0","info":{"description":"接続されているデバイスにジョイスティック情報を送信するAPI.","version":"2.0.0","title":"Joystick Profile"},"basePath":"/gotapi/joystick","consumes":["application/x-www-form-urlencoded","multipart/form-data"],"paths":{"/":{"post":{"summary":"ジョイスティックのイベントを送信。","description":"接続されているデバイスにジョイスティックのイベントを送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/JoystickResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}}},"definitions":{"CommonResponse":{"type":"object","required":["product","result","version"],"properties":{"result":{"type":"integer","description":"0:正常応答 0以外:異常応答"},"product":{"type":"string","description":"DeviceConnectシステムの名前。"},"version":{"type":"string","description":"DeviceConnectシステムのバージョン名。"},"hmac":{"type":"string","description":"レスポンスに対する署名。 アプリケーション側から事前にHMACキーを共有されていた場合は必須。"}}},"JoystickResponse":{"allOf":[{"$ref":"#/definitions/CommonResponse"}]}}}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/assets/api/keyboard.json b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/assets/api/keyboard.json
deleted file mode 100644
index ec24c9aa64..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/assets/api/keyboard.json
+++ /dev/null
@@ -1 +0,0 @@
-{"swagger":"2.0","info":{"description":"接続されているデバイスにキーボード情報を送信するAPI.","version":"2.0.0","title":"Keyboard Profile"},"basePath":"/gotapi/keyboard","consumes":["application/x-www-form-urlencoded","multipart/form-data"],"paths":{"/":{"post":{"summary":"キーボードのイベントを送信。","description":"接続されているデバイスにキーボードのイベントを送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"},{"name":"modifier","in":"formData","description":"修飾キー。 CTRL、SHIFT、ALT、GUIなどの入力文字や機能を変えるために併用するキー。 カンマ区切りで複数指定することができます。","required":false,"type":"array","items":{"type":"string","enum":["ctrl","shift","alt","gui"]}},{"name":"keyCode","in":"formData","description":"キーコード。 カンマ区切りで配列にして最大6個送信できます。 10進数または16進数(0xXX)の値。","required":true,"type":"array","items":{"type":"string"}}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/KeyboardResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}},"/ascii":{"post":{"summary":"ASCIIの文字列をキーボードのイベントとして送信。","description":"接続されているデバイスにASCIIの文字列をキーボードのイベントとして送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"},{"name":"string","in":"formData","description":"ASCII文字列を送信します。ASCII以外の文字列は送れません。","required":true,"type":"string","maxLength":255,"minLength":1}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/KeyboardResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}},"/del":{"post":{"summary":"デリートキーのキーコードをイベントとして送信。","description":"接続されているデバイスにデリートキーのキーコードをイベントとして送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/KeyboardResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}},"/downArrow":{"post":{"summary":"下矢印のキーコードをイベントとして送信。","description":"接続されているデバイスに下矢印のキーコードをイベントとして送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/KeyboardResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}},"/enter":{"post":{"summary":"エンターキーのキーコードをイベントとして送信。","description":"接続されているデバイスにエンターキーのキーコードをイベントとして送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/KeyboardResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}},"/esc":{"post":{"summary":"エスケープキーのキーコードをイベントとして送信。","description":"接続されているデバイスにエスケープキーのキーコードをイベントとして送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/KeyboardResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}},"/leftArrow":{"post":{"summary":"左矢印のキーコードをイベントとして送信。","description":"接続されているデバイスに左矢印のキーコードをイベントとして送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/KeyboardResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}},"/rightArrow":{"post":{"summary":"右矢印のキーコードをイベントとして送信。","description":"接続されているデバイスに右矢印のキーコードをイベントとして送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/KeyboardResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}},"/upArrow":{"post":{"summary":"上矢印のキーコードをイベントとして送信。","description":"接続されているデバイスに上矢印のキーコードをイベントとして送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/KeyboardResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}}},"definitions":{"CommonResponse":{"type":"object","required":["product","result","version"],"properties":{"result":{"type":"integer","description":"0:正常応答 0以外:異常応答"},"product":{"type":"string","description":"DeviceConnectシステムの名前。"},"version":{"type":"string","description":"DeviceConnectシステムのバージョン名。"},"hmac":{"type":"string","description":"レスポンスに対する署名。 アプリケーション側から事前にHMACキーを共有されていた場合は必須。"}}},"KeyboardResponse":{"allOf":[{"$ref":"#/definitions/CommonResponse"}]}}}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/assets/api/mouse.json b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/assets/api/mouse.json
deleted file mode 100644
index 7bc348e805..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/assets/api/mouse.json
+++ /dev/null
@@ -1 +0,0 @@
-{"swagger":"2.0","info":{"description":"接続されているデバイスにマウスのイベント情報を送信するAPI.","version":"2.0.0","title":"Mouse Profile"},"basePath":"/gotapi/mouse","consumes":["application/x-www-form-urlencoded","multipart/form-data"],"paths":{"/":{"get":{"summary":"マウスの情報を取得。","description":"マウスの情報を取得します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/MouseResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0","mouse":{"type":"relative"}}}}},"x-type":"one-shot"},"post":{"summary":"マウスのイベントを送信。","description":"接続されているデバイスにマウスのイベントを送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"},{"name":"x","in":"formData","description":"x座標への移動量。 -1〜1の範囲で移動します。","required":false,"type":"number","maximum":1.0,"minimum":-1.0,"format":"float"},{"name":"y","in":"formData","description":"y座標への移動量。 -1〜1の範囲で移動します。","required":false,"type":"number","maximum":1.0,"minimum":-1.0,"format":"float"},{"name":"wheel","in":"formData","description":"ホイールの移動量。 -1〜1の範囲で移動します。","required":false,"type":"number","maximum":1.0,"minimum":-1.0,"format":"float"},{"name":"rightButton","in":"formData","description":"右ボタンのドラッグ状態。 省略された場合にはfalseとします。","required":false,"type":"boolean"},{"name":"leftButton","in":"formData","description":"左ボタンのドラッグ状態。 省略された場合にはfalseとします。","required":false,"type":"boolean"},{"name":"middleButton","in":"formData","description":"真ん中ボタンのドラッグ状態。 省略された場合にはfalseとします。","required":false,"type":"boolean"}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/MouseResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}},"/click":{"post":{"summary":"マウスのクリックイベントを送信。","description":"接続されているデバイスにマウスのクリックイベントを送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"},{"name":"button","in":"formData","description":"クリックするボタン。","required":true,"type":"string","enum":["left","right","middle"]}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/CommonResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}},"/doubleClick":{"post":{"summary":"マウスのダブルクリックイベントを送信。","description":"接続されているデバイスにマウスのダブルクリックイベントを送信します。","parameters":[{"name":"serviceId","in":"formData","description":"サービスID。取得対象スマートデバイス","required":true,"type":"string"},{"name":"button","in":"formData","description":"ダブルクリックするボタン。","required":true,"type":"string","enum":["left","right","middle"]}],"responses":{"200":{"description":"","schema":{"$ref":"#/definitions/CommonResponse"},"examples":{"application/json":{"result":0,"product":"Example System","version":"1.0.0"}}}},"x-type":"one-shot"}}},"definitions":{"CommonResponse":{"type":"object","required":["product","result","version"],"properties":{"result":{"type":"integer","description":"0:正常応答 0以外:異常応答"},"product":{"type":"string","description":"DeviceConnectシステムの名前。"},"version":{"type":"string","description":"DeviceConnectシステムのバージョン名。"},"hmac":{"type":"string","description":"レスポンスに対する署名。 アプリケーション側から事前にHMACキーを共有されていた場合は必須。"}}},"MouseResponse":{"allOf":[{"$ref":"#/definitions/CommonResponse"},{"type":"object","required":["mouse"],"properties":{"mouse":{"type":"object","description":"マウスの情報を格納するオブジェクト","title":"マウス情報","properties":{"type":{"type":"string","description":"マウスのタイプ。 absolute: 絶対座標でマウスの操作を行います。 relative: 相対座標でマウスの操作を行います。","title":"マウスのタイプ","enum":["absolute","relative"]}}}}}]}}}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/HOGPMessageService.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/HOGPMessageService.java
deleted file mode 100644
index 8d1e07e01f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/HOGPMessageService.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- HOGPMessageService.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp;
-
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.util.Log;
-
-import org.deviceconnect.android.deviceplugin.hogp.profiles.HOGPHogpProfile;
-import org.deviceconnect.android.deviceplugin.hogp.profiles.HOGPSystemProfile;
-import org.deviceconnect.android.deviceplugin.hogp.server.AbstractHOGPServer;
-import org.deviceconnect.android.deviceplugin.hogp.server.HOGPServer;
-import org.deviceconnect.android.message.DConnectMessageService;
-import org.deviceconnect.android.profile.SystemProfile;
-import org.deviceconnect.android.service.DConnectService;
-
-/**
- * HOGPプラグインの処理を行う.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPMessageService extends DConnectMessageService {
-
- /**
- * サービス名.
- */
- public static final String HOGP_NAME = "HOGP";
-
- /**
- * サービスID.
- */
- public static final String HOGP_SERVICE_ID = "hogp";
-
- /**
- * デバッグ用フラグ.
- */
- private static final boolean DEBUG = BuildConfig.DEBUG;
-
- /**
- * デバッグ用タグ.
- */
- private static final String TAG = "HOGP";
-
- /**
- * HOGPサーバ.
- */
- private AbstractHOGPServer mHOGPServer;
-
- /**
- * HOGPプラグインの設定.
- */
- private HOGPSetting mHOGPSetting;
-
- /**
- * Bluetoothの状態通知を受け取るレシーバー.
- */
- private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(final Context context, final Intent intent) {
- String action = intent.getAction();
- if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
- int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1);
- switch (state) {
- case BluetoothAdapter.STATE_OFF:
- if (DEBUG) {
- Log.i(TAG, "Bluetooth is off.");
- }
- stopHOGPServer();
- break;
-
- case BluetoothAdapter.STATE_ON:
- if (DEBUG) {
- Log.i(TAG, "Bluetooth is on.");
- }
- if (mHOGPSetting.isEnabledServer()) {
- try {
- startHOGPServer();
- } catch (Exception e) {
- if (DEBUG) {
- Log.w(TAG, "Failed to start HOGPServer.", e);
- }
- }
- }
- break;
- }
- } else if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
- int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.ERROR);
- switch (state) {
- case BluetoothDevice.BOND_BONDING:
- if (DEBUG) {
- Log.d(TAG, "Bond bonding.");
- }
- break;
-
- case BluetoothDevice.BOND_BONDED:
- if (DEBUG) {
- Log.d(TAG, "Bond bonded.");
- }
- break;
-
- default:
- if (DEBUG) {
- Log.d(TAG, "Bond error.");
- }
- try {
- BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
- if (device != null) {
- getServiceProvider().removeService(device.getAddress());
- }
- } catch (Exception e) {
- if (DEBUG) {
- Log.e(TAG, "Failed to remove device.", e);
- }
- }
- break;
- }
- }
- }
- };
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- mHOGPSetting = new HOGPSetting(getApplicationContext());
-
- DConnectService service = new DConnectService(HOGP_SERVICE_ID);
- service.addProfile(new HOGPHogpProfile());
- service.setName(HOGP_NAME);
- service.setOnline(true);
- getServiceProvider().addService(service);
-
- if (mHOGPSetting.isEnabledServer()) {
- try {
- startHOGPServer();
- } catch (Exception e) {
- if (DEBUG) {
- Log.w(TAG, "Failed to start HOGPServer.", e);
- }
- }
- }
-
- setUseLocalOAuth(mHOGPSetting.isEnabledOAuth());
-
- IntentFilter filter = new IntentFilter();
- filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
- filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
- registerReceiver(mReceiver, filter);
- }
-
- @Override
- public void onDestroy() {
- stopHOGPServer();
- unregisterReceiver(mReceiver);
- super.onDestroy();
- }
-
- @Override
- protected SystemProfile getSystemProfile() {
- return new HOGPSystemProfile();
- }
-
- @Override
- protected void onManagerUninstalled() {
- // TODO Device Connect Managerアンインストール時に実行したい処理. 実装は任意.
- }
-
- @Override
- protected void onManagerTerminated() {
- // TODO Device Connect Manager停止時に実行したい処理. 実装は任意.
- }
-
- @Override
- protected void onManagerEventTransmitDisconnected(final String origin) {
- // TODO アプリとのWebSocket接続が切断された時に実行したい処理. 実装は任意.
- // イベントのAPIがないので特に処理は行わない
- }
-
- @Override
- protected void onDevicePluginReset() {
- // TODO Device Connect Managerの設定画面上で「プラグイン再起動」を要求された場合の処理. 実装は任意.
- }
-
- /**
- * HOGPの設定を取得します.
- * @return HOGP設定
- */
- public HOGPSetting getHOGPSetting() {
- return mHOGPSetting;
- }
-
- /**
- * Local OAuthの有効・無効を設定します.
- * @param flag trueの場合はLocal OAuthを有効、falseの場合は無効
- */
- public void setEnabledOAuth(final boolean flag) {
- setUseLocalOAuth(flag);
- mHOGPSetting.setEnabledOAuth(flag);
- }
-
- /**
- * HOGPサーバを取得します.
- *
- * HOGPサーバが開始されていない場合にはnullを返却します。
- *
- * @return HOGPサーバ
- */
- public synchronized AbstractHOGPServer getHOGPServer() {
- return mHOGPServer;
- }
-
- /**
- * HOGPサーバを起動します.
- */
- public synchronized void startHOGPServer() {
- if (mHOGPServer != null) {
- if (DEBUG) {
- Log.d(TAG, "HOGP Server is already running.");
- }
- return;
- }
-
- if (DEBUG) {
- Log.i(TAG, "Start the HOGP Server.");
- Log.i(TAG, "Mouse Mode: " + mHOGPSetting.getMouseMode());
- Log.i(TAG, "Keyboard: " + mHOGPSetting.isEnabledKeyboard());
- Log.i(TAG, "Joystick: " + mHOGPSetting.isEnabledJoystick());
- }
-
- if (mHOGPSetting.getMouseMode() == HOGPServer.MouseMode.NONE && !mHOGPSetting.isEnabledKeyboard()) {
- throw new RuntimeException("The feature is not set. Please set mouse or keyboard.");
- }
-
- mHOGPServer = new HOGPServer(this, mHOGPSetting.getMouseMode(), mHOGPSetting.isEnabledKeyboard(), false);
- mHOGPServer.setOnHOGPServerListener(new AbstractHOGPServer.OnHOGPServerListener() {
- @Override
- public void onConnected(final BluetoothDevice device) {
- if (DEBUG) {
- Log.d(TAG, "Connected the device. " + device.getName());
- }
-
- DConnectService service = new HOGPService(device, mHOGPSetting);
- service.setOnline(true);
-
- getServiceProvider().removeService(device.getAddress());
- getServiceProvider().addService(service);
- }
-
- @Override
- public void onDisconnected(final BluetoothDevice device) {
- if (DEBUG) {
- Log.d(TAG, "Disconnected the device. " + device.getName());
- }
-
- DConnectService service = getServiceProvider().getService(device.getAddress());
- if (service != null) {
- service.setOnline(false);
- }
- }
- });
-
- PackageManager pm = getPackageManager();
- String appName = "";
- int versionCode = 0;
- try {
- PackageInfo packageInfo = pm.getPackageInfo(getPackageName(), 0);
- appName = packageInfo.applicationInfo.loadLabel(pm).toString();
- versionCode = packageInfo.versionCode;
- } catch (PackageManager.NameNotFoundException e) {
- if (DEBUG) {
- Log.w(TAG, "", e);
- }
- }
- mHOGPServer.setManufacturerName(getPackageName());
- mHOGPServer.setDeviceName(appName);
- mHOGPServer.setSerialNumber("" + versionCode);
- mHOGPServer.setDataSendingRate(10);
- mHOGPServer.start();
- }
-
- /**
- * HOGPサーバを停止します.
- */
- public synchronized void stopHOGPServer() {
- if (mHOGPServer != null) {
- if (DEBUG) {
- Log.i(TAG, "Stop the HOGP Server.");
- }
-
- for (DConnectService s : getServiceProvider().getServiceList()) {
- if (s instanceof HOGPService) {
- s.setOnline(false);
- }
- }
-
- mHOGPServer.stop();
- mHOGPServer = null;
- }
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/HOGPMessageServiceProvider.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/HOGPMessageServiceProvider.java
deleted file mode 100644
index c3f34fbaed..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/HOGPMessageServiceProvider.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- HOGPMessageServiceProvider.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp;
-
-import android.app.Service;
-
-import org.deviceconnect.android.message.DConnectMessageServiceProvider;
-
-/**
- * Broadcastで受け取ったIntentをServiceに渡すためのReceiver.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPMessageServiceProvider extends DConnectMessageServiceProvider {
- @SuppressWarnings("unchecked")
- @Override
- protected Class getServiceClass() {
- Class extends Service> clazz = (Class extends Service>) HOGPMessageService.class;
- return (Class) clazz;
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/HOGPService.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/HOGPService.java
deleted file mode 100644
index 3cf6457544..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/HOGPService.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- HOGPService.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp;
-
-import android.bluetooth.BluetoothDevice;
-
-import org.deviceconnect.android.deviceplugin.hogp.profiles.HOGPJoystickProfile;
-import org.deviceconnect.android.deviceplugin.hogp.profiles.HOGPKeyboardProfile;
-import org.deviceconnect.android.deviceplugin.hogp.profiles.HOGPMouseProfile;
-import org.deviceconnect.android.deviceplugin.hogp.profiles.HOGPServiceInformation;
-import org.deviceconnect.android.deviceplugin.hogp.server.HOGPServer;
-import org.deviceconnect.android.service.DConnectService;
-
-/**
- * HOGPで接続されているデバイスのサービス.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPService extends DConnectService {
-
- /**
- * 接続されているBluetoothデバイス.
- */
- private BluetoothDevice mDevice;
-
- /**
- * コンストラクタ.
- * @param device 接続されているデバイス
- */
- HOGPService(final BluetoothDevice device, final HOGPSetting setting) {
- super(device.getAddress());
- setNetworkType(NetworkType.BLE);
-
- mDevice = device;
-
- if (setting.getMouseMode() != HOGPServer.MouseMode.NONE) {
- addProfile(new HOGPMouseProfile());
- }
-
- if (setting.isEnabledKeyboard()) {
- addProfile(new HOGPKeyboardProfile());
- }
-
- if (setting.isEnabledJoystick()) {
- addProfile(new HOGPJoystickProfile());
- }
-
- addProfile(new HOGPServiceInformation());
- }
-
- @Override
- public String getName() {
- String name = mDevice.getName();
- if (name != null) {
- return name;
- }
- return mDevice.getAddress();
- }
-
- /**
- * 接続されているBluetoothデバイス
- * @return Bluetoothデバイス
- */
- public BluetoothDevice getDevice() {
- return mDevice;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/HOGPSetting.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/HOGPSetting.java
deleted file mode 100644
index fc13dfd19a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/HOGPSetting.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- HOGPSetting.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-import org.deviceconnect.android.deviceplugin.hogp.server.HOGPServer;
-
-/**
- * HOGPの設定情報を管理するクラス.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPSetting {
-
- /**
- * ファイル名.
- */
- private static final String FILE_NAME = "hogp.dat";
-
- /**
- * HOGPサーバのOn/Off設定を格納するキー.
- */
- private static final String KEY_ENABLED_SERVER = "server_enabled";
-
- /**
- * Local OAuthのOn/Off設定を格納するキー.
- */
- private static final String KEY_ENABLED_OAUTH = "local_oauth_enabled";
-
- /**
- * キーボードの有効・無効設定を格納するキー.
- */
- private static final String KEY_ENABLED_KEYBOARD = "hid_keyboard";
-
- /**
- * マウスのモード設定を格納するキー.
- */
- private static final String KEY_MOUSE_MODE = "hid_mouse";
-
- /**
- * ジョイスティックの有効・無効設定を格納するキー.
- */
- private static final String KEY_ENABLED_JOYSTICK = "hid_joystick";
-
- /**
- * 設定を保存するプリファレンス.
- */
- private SharedPreferences mSharedPreferences;
-
- /**
- * コンストラクタ.
- * @param context コンテキスト
- */
- HOGPSetting(final Context context) {
- mSharedPreferences = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
- }
-
- /**
- * HOGPサーバのOn/Off設定を取得します.
- * @return HOGPサーバのOn/Off設定
- */
- public boolean isEnabledServer() {
- return mSharedPreferences.getBoolean(KEY_ENABLED_SERVER, false);
- }
-
- /**
- * HOGPサーバのOn/Off設定を設定します.
- * @param flag Onの場合はtrue、Offの場合はfalse
- */
- public void setEnabledServer(final boolean flag) {
- SharedPreferences.Editor editor = mSharedPreferences.edit();
- editor.putBoolean(KEY_ENABLED_SERVER, flag);
- editor.apply();
- }
-
- /**
- * Local OAuthのOn/Off設定を取得します.
- * @return Local OAuthのOn/Off設定
- */
- public boolean isEnabledOAuth() {
- return mSharedPreferences.getBoolean(KEY_ENABLED_OAUTH, false);
- }
-
- /**
- * Local OAuthのOn/Off設定を行います.
- * @param flag Onの場合はtrue、Offの場合はfalse
- */
- public void setEnabledOAuth(final boolean flag) {
- SharedPreferences.Editor editor = mSharedPreferences.edit();
- editor.putBoolean(KEY_ENABLED_OAUTH, flag);
- editor.apply();
- }
-
- /**
- * キーボードの有効・無効設定を行います.
- * @return キーボードの有効・無効
- */
- public boolean isEnabledKeyboard() {
- return mSharedPreferences.getBoolean(KEY_ENABLED_KEYBOARD, false);
- }
-
- /**
- * キーボードの有効・無効設定を行います.
- * @param flag 有効の場合はtrue、無効の場合はfalse
- */
- public void setEnabledKeyboard(final boolean flag) {
- SharedPreferences.Editor editor = mSharedPreferences.edit();
- editor.putBoolean(KEY_ENABLED_KEYBOARD, flag);
- editor.apply();
- }
-
- /**
- * マウスのモードを取得します.
- * @return マウスモード
- */
- public HOGPServer.MouseMode getMouseMode() {
- return HOGPServer.MouseMode.valueOf(mSharedPreferences.getInt(KEY_MOUSE_MODE, HOGPServer.MouseMode.RELATIVE.getValue()));
- }
-
- /**
- * マウスのモードを設定します.
- * @param mode マウスモード
- */
- public void setMouseMode(final HOGPServer.MouseMode mode) {
- SharedPreferences.Editor editor = mSharedPreferences.edit();
- editor.putInt(KEY_MOUSE_MODE, mode.getValue());
- editor.apply();
- }
-
- /**
- * ジョイスティックの有効・無効設定を行います.
- * @return ジョイスティックの有効・無効
- */
- public boolean isEnabledJoystick() {
- return mSharedPreferences.getBoolean(KEY_ENABLED_JOYSTICK, false);
- }
-
- /**
- * ジョイスティックの有効・無効設定を行います.
- * @param flag 有効の場合はtrue、無効の場合はfalse
- */
- public void setEnabledJoystick(final boolean flag) {
- SharedPreferences.Editor editor = mSharedPreferences.edit();
- editor.putBoolean(KEY_ENABLED_JOYSTICK, flag);
- editor.apply();
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/activity/HOGPBaseActivity.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/activity/HOGPBaseActivity.java
deleted file mode 100644
index a09a630c44..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/activity/HOGPBaseActivity.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- HOGPBaseActivity.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.activity;
-
-import android.app.Activity;
-import android.content.ComponentName;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.util.Log;
-
-import androidx.annotation.Nullable;
-
-import org.deviceconnect.android.deviceplugin.hogp.BuildConfig;
-import org.deviceconnect.android.deviceplugin.hogp.HOGPMessageService;
-import org.deviceconnect.android.deviceplugin.hogp.server.AbstractHOGPServer;
-import org.deviceconnect.android.message.DConnectMessageService;
-
-/**
- * HOGPMessageServiceとバインド処理を行うActivity.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPBaseActivity extends Activity {
- private static final boolean DEBUG = BuildConfig.DEBUG;
- private static final String TAG = "HOGP";
-
- /**
- * サービスとのバインド状態を管理するフラグ.
- *
- * バインドされている場合はtrue。
- *
- */
- private boolean mIsBound;
-
- /**
- * バインドしたHOGPMessageServiceのインスタンス.
- */
- private HOGPMessageService mHOGPMessageService;
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- bindService();
- }
-
- @Override
- protected void onDestroy() {
- unbindService();
- super.onDestroy();
- }
-
- /**
- * HOGPMessageServiceとバインドします.
- */
- private void bindService() {
- Intent intent = new Intent(this, HOGPMessageService.class);
- bindService(intent, mConnection, BIND_AUTO_CREATE);
- }
-
- /**
- * HOGPMessageServiceとアンバインドします.
- *
- * バインドされていない場合には何もしません。
- *
- */
- private void unbindService() {
- if (mIsBound) {
- unbindService(mConnection);
-
- onServiceDisconnected();
- mHOGPMessageService = null;
- mIsBound = false;
- }
- }
-
- /**
- * HOGPMessageServiceとバインドした時のコネクション.
- */
- private ServiceConnection mConnection = new ServiceConnection() {
- @Override
- public void onServiceConnected(final ComponentName name, final IBinder service) {
- if (DEBUG) {
- Log.i(TAG, "onServiceConnected " + name);
- }
- mIsBound = true;
- mHOGPMessageService = (HOGPMessageService) ((DConnectMessageService.LocalBinder) service).getMessageService();
- HOGPBaseActivity.this.onServiceConnected();
- }
-
- @Override
- public void onServiceDisconnected(final ComponentName name) {
- if (DEBUG) {
- Log.i(TAG, "onServiceDisconnected " + name);
- }
- HOGPBaseActivity.this.onServiceDisconnected();
- mHOGPMessageService = null;
- mIsBound = false;
- }
- };
-
- /**
- * バインドされているHOGPMessageServiceを取得します.
- *
- * バインドされていない場合にはnullを返却します。
- *
- * @return HOGPMessageService
- */
- HOGPMessageService getHOGPMessageService() {
- return mHOGPMessageService;
- }
-
- /**
- * HOGPサーバのインスタンスを取得します.
- *
- * HOGPMessageServiceにバインドできていない場合や起動していない場合はnullを返却します。
- *
- * @return HOGPサーバ
- */
- AbstractHOGPServer getHOGPServer() {
- if (mHOGPMessageService != null) {
- return mHOGPMessageService.getHOGPServer();
- }
- return null;
- }
-
- /**
- * HOGPMessageServiceとバインドされた時に呼び出します.
- */
- void onServiceConnected() {
- }
-
- /**
- * HOGPMessageServiceとアンバインドされた時に呼び出します.
- */
- void onServiceDisconnected() {
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/activity/HOGPControlActivity.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/activity/HOGPControlActivity.java
deleted file mode 100644
index 8d410cd07e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/activity/HOGPControlActivity.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- HOGPControlActivity.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.activity;
-
-import android.app.ActionBar;
-import android.os.Bundle;
-import android.os.Vibrator;
-import android.view.GestureDetector;
-import android.view.MenuItem;
-import android.view.MotionEvent;
-import android.view.View;
-import android.widget.Button;
-import android.widget.CompoundButton;
-import android.widget.ToggleButton;
-
-import org.deviceconnect.android.deviceplugin.hogp.R;
-import org.deviceconnect.android.deviceplugin.hogp.server.HOGPServer;
-import org.deviceconnect.android.deviceplugin.hogp.util.KeyboardCode;
-
-import static android.view.MotionEvent.ACTION_MOVE;
-import static org.deviceconnect.android.deviceplugin.hogp.server.HOGPServer.ABSOLUTE_MOUSE_SIZE;
-
-/**
- * コントローラ画面用Activity.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPControlActivity extends HOGPBaseActivity {
- /**
- * ジェスチャー検出器.
- */
- private GestureDetector mGestureDetector;
-
- /**
- * ドラッグ状態.
- *
- * ドラッグ中の場合はtrue、それ以外はfalse
- *
- */
- private boolean mDragFlag;
-
- /**
- * 最後にタッチされたMotionEventの座標.
- */
- private float mLastX, mLastY;
-
- /**
- * MotionEventの最大個数.
- */
- private int mMaxPointerCount;
-
- /**
- * HOGPサーバ.
- */
- private HOGPServer mHOGPServer;
-
- /**
- * MotionEventを送信した時間.
- */
- private long mTime;
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_control);
-
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- }
-
- mGestureDetector = new GestureDetector(this, new GestureDetector.OnGestureListener() {
- @Override
- public boolean onDown(final MotionEvent e) {
- return false;
- }
-
- @Override
- public void onShowPress(final MotionEvent e) {
- }
-
- @Override
- public boolean onSingleTapUp(final MotionEvent e) {
- if (!mDragFlag && mHOGPServer != null) {
- switch (mHOGPServer.getMouseMode()) {
- case RELATIVE:
- mHOGPServer.movePointer(0, 0, 0, true, false, false);
- mHOGPServer.movePointer(0, 0, 0, false, false, false);
- break;
- case ABSOLUTE:
- mHOGPServer.movePointer((int) mLastX, (int) mLastY, 0, true, false, false);
- mHOGPServer.movePointer((int) mLastX, (int) mLastY, 0, false, false, false);
- break;
- }
- }
- return false;
- }
-
- @Override
- public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX, final float distanceY) {
- return false;
- }
-
- @Override
- public void onLongPress(final MotionEvent e) {
- mDragFlag = true;
-
- Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
- vibrator.vibrate(80);
- }
-
- @Override
- public boolean onFling(final MotionEvent e1, final MotionEvent e2, final float velocityX, final float velocityY) {
- return false;
- }
- });
-
- findViewById(R.id.activity_control_mouse).setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(final View view, final MotionEvent motionEvent) {
- switch (mHOGPServer.getMouseMode()) {
- case RELATIVE:
- return moveRelativeMouse(motionEvent);
- case ABSOLUTE:
- return moveAbsoluteMouse(view, motionEvent);
- default:
- return true;
- }
- }
- });
-
- final int[][] keyMap = {
- { R.id.activity_control_key_1, 0, 0x00, 0x1E },
- { R.id.activity_control_key_2, 0, 0x00, 0x1F },
- { R.id.activity_control_key_3, 0, 0x00, 0x20 },
- { R.id.activity_control_key_4, 0, 0x00, 0x21 },
- { R.id.activity_control_key_5, 0, 0x00, 0x22 },
- { R.id.activity_control_key_6, 0, 0x00, 0x23 },
- { R.id.activity_control_key_7, 0, 0x00, 0x24 },
- { R.id.activity_control_key_8, 0, 0x00, 0x25 },
- { R.id.activity_control_key_9, 0, 0x00, 0x26 },
- { R.id.activity_control_key_0, 0, 0x00, 0x27 },
-
- { R.id.activity_control_key_a, 0, 0x00, 0x04 },
- { R.id.activity_control_key_b, 0, 0x00, 0x05 },
- { R.id.activity_control_key_c, 0, 0x00, 0x06 },
- { R.id.activity_control_key_d, 0, 0x00, 0x07 },
- { R.id.activity_control_key_e, 0, 0x00, 0x08 },
- { R.id.activity_control_key_f, 0, 0x00, 0x09 },
- { R.id.activity_control_key_g, 0, 0x00, 0x0A },
- { R.id.activity_control_key_h, 0, 0x00, 0x0B },
- { R.id.activity_control_key_i, 0, 0x00, 0x0C },
- { R.id.activity_control_key_j, 0, 0x00, 0x0D },
- { R.id.activity_control_key_k, 0, 0x00, 0x0E },
- { R.id.activity_control_key_l, 0, 0x00, 0x0F },
- { R.id.activity_control_key_m, 0, 0x00, 0x10 },
- { R.id.activity_control_key_n, 0, 0x00, 0x11 },
- { R.id.activity_control_key_o, 0, 0x00, 0x12 },
- { R.id.activity_control_key_p, 0, 0x00, 0x13 },
- { R.id.activity_control_key_q, 0, 0x00, 0x14 },
- { R.id.activity_control_key_r, 0, 0x00, 0x15 },
- { R.id.activity_control_key_s, 0, 0x00, 0x16 },
- { R.id.activity_control_key_t, 0, 0x00, 0x17 },
- { R.id.activity_control_key_u, 0, 0x00, 0x18 },
- { R.id.activity_control_key_v, 0, 0x00, 0x19 },
- { R.id.activity_control_key_w, 0, 0x00, 0x1A },
- { R.id.activity_control_key_x, 0, 0x00, 0x1B },
- { R.id.activity_control_key_y, 0, 0x00, 0x1C },
- { R.id.activity_control_key_z, 0, 0x00, 0x1D },
-
- { R.id.activity_control_key_esc, 1, 0x00, 0x29 },
- { R.id.activity_control_key_up, 1, 0x00, 0x52 },
- { R.id.activity_control_key_down, 1, 0x00, 0x51 },
- { R.id.activity_control_key_left, 1, 0x00, 0x50 },
- { R.id.activity_control_key_right, 1, 0x00, 0x4F },
- { R.id.activity_control_key_delete, 1, 0x00, 0x2A },
- { R.id.activity_control_key_space, 1, 0x00, 0x2C },
- { R.id.activity_control_key_enter, 1, 0x00, 0x28 },
-
- { R.id.activity_control_key_mode, 1, 0x02, 0x2C },
- { R.id.activity_control_key_num, 1, 0x04, 0x2C },
-
- { R.id.activity_control_key_at_mark, 1, 0x00, 0x2F },
- { R.id.activity_control_key_hash, 1, 0x02, 0x20 },
- { R.id.activity_control_key_percent, 1, 0x02, 0x22 },
- { R.id.activity_control_key_yen, 1, 0x00, 0x89 },
- { R.id.activity_control_key_and, 1, 0x02, 0x23 },
- { R.id.activity_control_key_parentheses_start, 1, 0x02, 0x25 },
- { R.id.activity_control_key_parentheses_end, 1, 0x02, 0x26 },
- { R.id.activity_control_key_hyphen, 1, 0x00, 0x2D },
- { R.id.activity_control_key_slash, 1, 0x00, 0x38 },
- { R.id.activity_control_key_colon, 1, 0x00, 0x34 },
- { R.id.activity_control_key_semicolon, 1, 0x00, 0x33 },
- { R.id.activity_control_key_hat, 1, 0x00, 0x2E },
- { R.id.activity_control_key_exclamation_mark, 1, 0x02, 0x1E },
- { R.id.activity_control_key_question_mark, 1, 0x02, 0x38 },
-
- { R.id.activity_control_key_asterisk, 1, 0x02, 0x34 },
- { R.id.activity_control_key_add, 1, 0x02, 0x33 },
- { R.id.activity_control_key_lt, 1, 0x02, 0x36 },
- { R.id.activity_control_key_gt, 1, 0x02, 0x37 },
- { R.id.activity_control_key_bracket_start, 1, 0x00, 0x30 },
- { R.id.activity_control_key_bracket_end, 1, 0x00, 0x32 },
- { R.id.activity_control_key_under, 1, 0x02, 0x87 },
- };
-
- for (int[] map : keyMap) {
- final boolean useShift = (map[1] == 0);
- final byte modifier = (byte) (map[2] & 0xFF);
- final byte keyCode = (byte) (map[3] & 0xFF);
- findViewById(map[0]).setOnClickListener((v) -> {
- if (mHOGPServer != null) {
- if (useShift) {
- mHOGPServer.sendKeyDown(caps(), keyCode);
- } else {
- mHOGPServer.sendKeyDown(modifier, keyCode);
- }
- mHOGPServer.sendKeyUp();
- }
- });
- }
-
- findViewById(R.id.activity_control_key_num).setOnClickListener((v) -> {
- changeKeyboard();
- });
-
- ToggleButton toggle = findViewById(R.id.activity_control_key_caps);
- toggle.setOnCheckedChangeListener((buttonView, isChecked) -> {
- changeUppercase(isChecked);
- });
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- finish();
- return true;
- }
- return super.onMenuItemSelected(featureId, item);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- }
-
- @Override
- void onServiceConnected() {
- mHOGPServer = (HOGPServer) getHOGPServer();
- }
-
- @Override
- void onServiceDisconnected() {
- mHOGPServer = null;
- }
-
- /**
- * Absolute入力モードのマウスの移動を処理します.
- * @param view タッチされたView
- * @param motionEvent タッチイベント
- * @return
- */
- private boolean moveAbsoluteMouse(final View view, final MotionEvent motionEvent) {
- float width = view.getWidth();
- float height = view.getHeight();
-
- mLastX = (int) (ABSOLUTE_MOUSE_SIZE * motionEvent.getX() / width);
- mLastY = (int) (ABSOLUTE_MOUSE_SIZE * motionEvent.getY() / height);
-
- mGestureDetector.onTouchEvent(motionEvent);
- switch (motionEvent.getAction()) {
- case MotionEvent.ACTION_DOWN:
- case MotionEvent.ACTION_POINTER_DOWN:
- mDragFlag = false;
- if (mHOGPServer != null) {
- mHOGPServer.movePointer(
- (int) (ABSOLUTE_MOUSE_SIZE * motionEvent.getX() / width),
- (int) (ABSOLUTE_MOUSE_SIZE * motionEvent.getY() / height),
- 0,
- mDragFlag, false, false);
- }
- return true;
-
- case ACTION_MOVE:
- if (mHOGPServer != null) {
- mHOGPServer.movePointer(
- (int) (ABSOLUTE_MOUSE_SIZE * motionEvent.getX() / width),
- (int) (ABSOLUTE_MOUSE_SIZE * motionEvent.getY() / height),
- 0,
- mDragFlag, false, false);
- }
- return true;
-
- case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_POINTER_UP:
- mDragFlag = false;
- if (mHOGPServer != null) {
- mHOGPServer.movePointer(
- (int) (ABSOLUTE_MOUSE_SIZE * motionEvent.getX() / width),
- (int) (ABSOLUTE_MOUSE_SIZE * motionEvent.getY() / height),
- 0,
- mDragFlag, false, false);
- }
- return true;
- }
-
- return false;
- }
-
- /**
- * Relative入力モードのマウスの移動を処理します.
- * @param motionEvent タッチイベント
- * @return
- */
- private boolean moveRelativeMouse(final MotionEvent motionEvent) {
- mGestureDetector.onTouchEvent(motionEvent);
- switch (motionEvent.getAction()) {
- case MotionEvent.ACTION_DOWN:
- case MotionEvent.ACTION_POINTER_DOWN:
- mDragFlag = false;
- mMaxPointerCount = motionEvent.getPointerCount();
- mLastX = motionEvent.getX();
- mLastY = motionEvent.getY();
- mTime = 0;
- return true;
-
- case ACTION_MOVE:
- if (System.currentTimeMillis() - mTime < 10) {
- return true;
- }
- mMaxPointerCount = Math.max(mMaxPointerCount, motionEvent.getPointerCount());
- if (mHOGPServer != null) {
- mHOGPServer.movePointer(
- (int) (motionEvent.getX() - mLastX),
- (int) (motionEvent.getY() - mLastY),
- 0,
- mDragFlag, false, false);
- }
- mLastX = motionEvent.getX();
- mLastY = motionEvent.getY();
- mTime = System.currentTimeMillis();
- return true;
-
- case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_POINTER_UP:
- mDragFlag = false;
- if (mHOGPServer != null) {
- mHOGPServer.movePointer(
- (int) (motionEvent.getX() - mLastX),
- (int) (motionEvent.getY() - mLastY),
- 0,
- false, false, false);
- }
- mLastX = motionEvent.getX();
- mLastY = motionEvent.getY();
- return true;
- }
- return true;
- }
-
- /**
- * Capsロックを確認します.
- * @return Capsロック
- */
- private byte caps() {
- ToggleButton toggle = findViewById(R.id.activity_control_key_caps);
- return toggle.isChecked() ? (byte) KeyboardCode.MODIFIER_KEY_SHIFT : 0;
- }
-
- private void changeUppercase(final boolean flag) {
- int[] ids = {
- R.id.activity_control_key_a,
- R.id.activity_control_key_b,
- R.id.activity_control_key_c,
- R.id.activity_control_key_d,
- R.id.activity_control_key_e,
- R.id.activity_control_key_f,
- R.id.activity_control_key_g,
- R.id.activity_control_key_h,
- R.id.activity_control_key_i,
- R.id.activity_control_key_j,
- R.id.activity_control_key_k,
- R.id.activity_control_key_l,
- R.id.activity_control_key_m,
- R.id.activity_control_key_n,
- R.id.activity_control_key_o,
- R.id.activity_control_key_p,
- R.id.activity_control_key_q,
- R.id.activity_control_key_r,
- R.id.activity_control_key_s,
- R.id.activity_control_key_t,
- R.id.activity_control_key_u,
- R.id.activity_control_key_v,
- R.id.activity_control_key_w,
- R.id.activity_control_key_x,
- R.id.activity_control_key_y,
- R.id.activity_control_key_z,
- };
-
- for (int id : ids) {
- Button btn = (Button) findViewById(id);
- String t = btn.getText().toString();
- if (flag) {
- t = t.toUpperCase();
- } else {
- t = t.toLowerCase();
- }
- btn.setText(t);
- }
- }
-
- private void changeKeyboard() {
- View v1 = findViewById(R.id.activity_control_keyboard_a);
- View v2 = findViewById(R.id.activity_control_keyboard_s);
- if (v1.getVisibility() == View.GONE) {
- v1.setVisibility(View.VISIBLE);
- v2.setVisibility(View.GONE);
- } else {
- v1.setVisibility(View.GONE);
- v2.setVisibility(View.VISIBLE);
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/activity/HOGPHelpActivity.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/activity/HOGPHelpActivity.java
deleted file mode 100644
index 55800d07be..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/activity/HOGPHelpActivity.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- HOGPHelpActivity.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.activity;
-
-
-import androidx.fragment.app.Fragment;
-
-import org.deviceconnect.android.deviceplugin.hogp.fragment.HOGPHelp01Fragment;
-import org.deviceconnect.android.deviceplugin.hogp.fragment.HOGPHelp02Fragment;
-import org.deviceconnect.android.deviceplugin.hogp.fragment.HOGPHelp03Fragment;
-import org.deviceconnect.android.deviceplugin.hogp.fragment.HOGPHelp04Fragment;
-import org.deviceconnect.android.ui.activity.DConnectSettingPageFragmentActivity;
-
-/**
- * ヘルプ画面用Activity.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPHelpActivity extends DConnectSettingPageFragmentActivity {
- @Override
- public int getPageCount() {
- return 4;
- }
-
- @Override
- public Fragment createPage(final int position) {
- switch (position) {
- case 0:
- return HOGPHelp01Fragment.newInstance();
- case 1:
- return HOGPHelp02Fragment.newInstance();
- case 2:
- return HOGPHelp03Fragment.newInstance();
- case 3:
- return HOGPHelp04Fragment.newInstance();
- }
- return null;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/activity/HOGPSettingActivity.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/activity/HOGPSettingActivity.java
deleted file mode 100644
index f48f02dc6a..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/activity/HOGPSettingActivity.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- HOGPSettingActivity.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.activity;
-
-import android.app.ActionBar;
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.BaseAdapter;
-import android.widget.CompoundButton;
-import android.widget.ListView;
-import android.widget.Spinner;
-import android.widget.Switch;
-import android.widget.TextView;
-
-import org.deviceconnect.android.deviceplugin.hogp.HOGPMessageService;
-import org.deviceconnect.android.deviceplugin.hogp.HOGPService;
-import org.deviceconnect.android.deviceplugin.hogp.HOGPSetting;
-import org.deviceconnect.android.deviceplugin.hogp.R;
-import org.deviceconnect.android.deviceplugin.hogp.server.AbstractHOGPServer;
-import org.deviceconnect.android.deviceplugin.hogp.server.HOGPServer;
-import org.deviceconnect.android.deviceplugin.hogp.util.BleUtils;
-import org.deviceconnect.android.service.DConnectService;
-import org.deviceconnect.android.service.DConnectServiceListener;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 設定画面用Activity.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPSettingActivity extends HOGPBaseActivity implements DConnectServiceListener {
-
- /**
- * デバイスの一覧を格納するアダプタ.
- */
- private DeviceAdapter mDeviceAdapter;
-
- /**
- * ハンドラー.
- */
- private Handler mHandler = new Handler();
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_setting);
-
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- }
-
- Intent intent = new Intent();
- intent.setClass(this, HOGPMessageService.class);
- startService(intent);
-
- findViewById(R.id.activity_setting_device_switch).setEnabled(false);
- findViewById(R.id.activity_setting_btn).setEnabled(false);
- findViewById(R.id.activity_setting_btn).setOnClickListener((v) -> {
- if (isStartHOGPServer()) {
- openControlActivity();
- } else {
- showNotStartServer();
- }
- });
-
- mDeviceAdapter = new DeviceAdapter();
-
- ListView listView = findViewById(R.id.activity_setting_list_view);
- listView.setAdapter(mDeviceAdapter);
-
- setDeviceName();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- setDeviceName();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.activity_setting_menu, menu);
- return true;
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- finish();
- return true;
- } else if (item.getItemId() == R.id.activity_setting_menu_help) {
- openHelpActivity();
- return false;
- }
- return super.onMenuItemSelected(featureId, item);
- }
-
- @Override
- protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
-
- if (requestCode == BleUtils.REQUEST_CODE_BLUETOOTH_ENABLE) {
- if (resultCode == RESULT_OK) {
- setDeviceName();
-
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- startHOGPServer();
- }
- }, 300);
- }
- }
- }
-
- @Override
- void onServiceConnected() {
- setHOGPServerUI();
- setLocalOAuthUI();
- findViewById(R.id.activity_setting_btn).setEnabled(true);
-
- HOGPMessageService service = getHOGPMessageService();
- if (service != null) {
- service.getServiceProvider().addServiceListener(this);
- }
- }
-
- @Override
- void onServiceDisconnected() {
- Switch sw = findViewById(R.id.activity_setting_device_switch);
- sw.setOnCheckedChangeListener(null);
- sw.setEnabled(false);
- findViewById(R.id.activity_setting_btn).setEnabled(false);
-
- HOGPMessageService service = getHOGPMessageService();
- if (service != null) {
- service.getServiceProvider().removeServiceListener(this);
- }
- }
-
- @Override
- public void onServiceAdded(final DConnectService dConnectService) {
- updateHOGPService();
- }
-
- @Override
- public void onServiceRemoved(final DConnectService dConnectService) {
- updateHOGPService();
- }
-
- @Override
- public void onStatusChange(final DConnectService dConnectService) {
- if (mDeviceAdapter != null) {
- runOnUiThread(() -> {
- if (mDeviceAdapter != null) {
- mDeviceAdapter.notifyDataSetChanged();
- }
- });
- }
- }
-
- /**
- * HOGPサービスを更新します.
- */
- private void updateHOGPService() {
- HOGPMessageService service = getHOGPMessageService();
- if (service == null) {
- return;
- }
-
- final List serviceList = new ArrayList<>();
- for (DConnectService s : service.getServiceProvider().getServiceList()) {
- if (s instanceof HOGPService) {
- serviceList.add((HOGPService) s);
- }
- }
-
- runOnUiThread(() -> {
- if (mDeviceAdapter != null) {
- mDeviceAdapter.setHOGPServiceList(serviceList);
- }
- });
- }
-
- /**
- * デバイス名をSwitchのタイトルに設定します.
- */
- private void setDeviceName() {
- TextView textView = findViewById(R.id.activity_setting_device_name);
- if (BleUtils.isBluetoothEnabled(this)) {
- String name = BleUtils.getBluetoothName(this);
- if (name != null) {
- textView.setText(name);
- }
- }
- }
-
- /**
- * HOGPサーバUIの設定を行います.
- */
- private void setHOGPServerUI() {
- final HOGPMessageService service = getHOGPMessageService();
- AbstractHOGPServer server = service.getHOGPServer();
-
- final Switch sw = findViewById(R.id.activity_setting_device_switch);
- sw.setChecked(server != null);
- sw.setEnabled(true);
- sw.setOnCheckedChangeListener((buttonView, isChecked) -> {
- if (isChecked) {
- startHOGPServer();
- } else {
- service.stopHOGPServer();
- service.getHOGPSetting().setEnabledServer(false);
- setSwitchUI(false);
- }
- });
-
- findViewById(R.id.activity_setting_device_switch_title).setOnClickListener((v) -> {
- sw.setChecked(!sw.isChecked());
- });
-
- findViewById(R.id.activity_setting_hogp_keyboard_title).setOnClickListener((v) -> {
- Switch keyboard = findViewById(R.id.activity_setting_hogp_keyboard);
- keyboard.setChecked(!keyboard.isChecked());
- });
-
- Spinner mouse = findViewById(R.id.activity_setting_hogp_mouse_mode);
- mouse.setSelection(service.getHOGPSetting().getMouseMode().getValue());
- mouse.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(final AdapterView> adapter, final View v, final int position, final long id) {
- service.getHOGPSetting().setMouseMode(HOGPServer.MouseMode.valueOf(position));
- }
-
- @Override
- public void onNothingSelected(final AdapterView> adapter) {
- }
- });
-
- Switch keyboard = findViewById(R.id.activity_setting_hogp_keyboard);
- keyboard.setChecked(service.getHOGPSetting().isEnabledKeyboard());
- keyboard.setOnCheckedChangeListener((buttonView, isChecked) -> {
- service.getHOGPSetting().setEnabledKeyboard(isChecked);
- });
-
- updateHOGPService();
-
- setEnabledSetting(isStartHOGPServer());
- }
-
- /**
- * ユーザ認可UIの設定を行います.
- */
- private void setLocalOAuthUI() {
- HOGPSetting setting = getHOGPMessageService().getHOGPSetting();
- final Switch oauthSwitch = findViewById(R.id.activity_setting_device_oauth_switch);
- oauthSwitch.setChecked(setting.isEnabledOAuth());
- oauthSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
- HOGPMessageService service = getHOGPMessageService();
- if (service != null) {
- service.setEnabledOAuth(isChecked);
- }
- });
-
- findViewById(R.id.activity_setting_device_oauth_title).setOnClickListener((v) -> {
- oauthSwitch.setChecked(!oauthSwitch.isChecked());
- });
- }
-
- /**
- * HOGPサーバのOn/Offスイッチを設定します.
- * @param flag Onの場合はtrue、それ以外はfalse
- */
- private void setSwitchUI(final boolean flag) {
- ((Switch) findViewById(R.id.activity_setting_device_switch)).setChecked(flag);
- setEnabledSetting(flag);
- }
-
- /**
- * マウス・キーボード設定の有効・無効を設定します.
- * @param flag フラグ
- */
- private void setEnabledSetting(final boolean flag) {
- findViewById(R.id.activity_setting_hogp_mouse_mode).setEnabled(!flag);
- findViewById(R.id.activity_setting_hogp_keyboard).setEnabled(!flag);
- findViewById(R.id.activity_setting_hogp_keyboard_title).setEnabled(!flag);
- }
-
- /**
- * HOGPサーバが起動しているかを確認します.
- * @return HOGPサーバが起動している場合はtrue、それ以外はfalse
- */
- private boolean isStartHOGPServer() {
- HOGPMessageService service = getHOGPMessageService();
- if (service == null) {
- return false;
- }
- AbstractHOGPServer server = service.getHOGPServer();
- return server != null;
- }
-
- /**
- * 操作画面を開きます.
- */
- private void openControlActivity() {
- Intent intent = new Intent();
- intent.setClass(this, HOGPControlActivity.class);
- startActivity(intent);
- }
-
- /**
- * ヘルプ画面を開きます.
- */
- private void openHelpActivity() {
- Intent intent = new Intent();
- intent.setClass(this, HOGPHelpActivity.class);
- startActivity(intent);
- }
-
- /**
- * HOGPサーバを起動します.
- *
- * HOGPサーバを起動するための設定やサポート状況の確認を行います。
- *
- */
- private void startHOGPServer() {
- if (!BleUtils.isBluetoothEnabled(this)) {
- showDisableBluetooth();
- setSwitchUI(false);
- } else if (!BleUtils.isBleSupported(this)) {
- showNotSupportBLE();
- setSwitchUI(false);
- } else if (!BleUtils.isBlePeripheralSupported(this)) {
- showNotSupportPeripheral();
- setSwitchUI(false);
- } else if (!checkHOGPSetting()) {
- showNotSetFeature();
- setSwitchUI(false);
- } else {
- try {
- getHOGPMessageService().startHOGPServer();
- getHOGPMessageService().getHOGPSetting().setEnabledServer(true);
- setSwitchUI(true);
- } catch (Exception e) {
- showFailedStartServer();
- setSwitchUI(false);
- }
- }
- }
-
- /**
- * マウス・キーボードの設定状態を確認します.
- * @return 機能が設定されている場合はtrue、それ以外はfalse
- */
- private boolean checkHOGPSetting() {
- HOGPMessageService service = getHOGPMessageService();
- if (service == null) {
- return false;
- }
- HOGPSetting setting = service.getHOGPSetting();
- return (setting.getMouseMode() != HOGPServer.MouseMode.NONE || setting.isEnabledKeyboard());
- }
-
- /**
- * マウス・キーボードの機能が有効になっていないことを警告するダイアログを表示します.
- */
- private void showNotSetFeature() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_setting_hid_not_set_title)
- .setMessage(R.string.activity_setting_hid_not_set_message)
- .setPositiveButton(R.string.activity_setting_dialog_ok, null)
- .show();
- }
-
- /**
- * HOGPサーバの起動に失敗したことを警告するダイアログを表示します.
- */
- private void showFailedStartServer() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_setting_failed_to_start_server_title)
- .setMessage(R.string.activity_setting_failed_to_start_server_message)
- .setPositiveButton(R.string.activity_setting_dialog_ok, null)
- .show();
- }
-
- /**
- * Bluetooth設定が無効になっていることを警告するダイアログを表示します.
- */
- private void showDisableBluetooth() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_setting_bt_enabled_dialog_title)
- .setMessage(R.string.activity_setting_bt_enabled_dialog_message)
- .setPositiveButton(R.string.activity_setting_dialog_ok, (dialog, which) -> {
- BleUtils.enableBluetooth(HOGPSettingActivity.this);
- })
- .setNegativeButton(R.string.activity_setting_dialog_no, null)
- .show();
- }
-
- /**
- * BLEがサポートされていないことを警告するダイアログを表示します.
- */
- private void showNotSupportBLE() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_setting_ble_not_support_title)
- .setMessage(R.string.activity_setting_ble_not_support_message)
- .setPositiveButton(R.string.activity_setting_dialog_ok, null)
- .show();
- }
-
- /**
- * Peripheralがサポートされていないことを警告するダイアログを表示します.
- */
- private void showNotSupportPeripheral() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_setting_peripheral_not_support_title)
- .setMessage(R.string.activity_setting_peripheral_not_support_message)
- .setPositiveButton(R.string.activity_setting_dialog_ok, null)
- .show();
- }
-
- /**
- * HOGPサーバが起動されていないことを警告するダイアログを表示します.
- */
- private void showNotStartServer() {
- new AlertDialog.Builder(this)
- .setTitle(R.string.activity_setting_not_start_server_title)
- .setMessage(R.string.activity_setting_not_start_server_message)
- .setPositiveButton(R.string.activity_setting_dialog_ok, null)
- .show();
- }
-
- /**
- * 接続されているデバイス一覧を表示するためのAdapter.
- */
- private class DeviceAdapter extends BaseAdapter {
-
- /**
- * HOGPServiceのリスト.
- */
- private List mHOGPServiceList = new ArrayList<>();
-
- /**
- * サービスのリストを設定します.
- * @param serviceList サービスのリスト
- */
- void setHOGPServiceList(final List serviceList) {
- mHOGPServiceList = serviceList;
- notifyDataSetChanged();
- }
-
- @Override
- public int getCount() {
- return mHOGPServiceList.size();
- }
-
- @Override
- public Object getItem(final int position) {
- return mHOGPServiceList.get(position);
- }
-
- @Override
- public long getItemId(final int position) {
- return position;
- }
-
- @Override
- public View getView(final int position, View convertView, final ViewGroup parent) {
- if (convertView == null) {
- convertView = getLayoutInflater().inflate(R.layout.item_setting_device, null);
- }
-
- TextView nameView = convertView.findViewById(R.id.activity_setting_device_name);
- TextView statusView = convertView.findViewById(R.id.activity_setting_device_status);
-
- HOGPService service = (HOGPService) getItem(position);
- nameView.setText(service.getName());
-
- String status = service.isOnline() ? getString(R.string.activity_setting_device_online) :
- getString(R.string.activity_setting_device_offline);
-
- statusView.setText(status);
-
- return convertView;
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/fragment/HOGPHelp01Fragment.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/fragment/HOGPHelp01Fragment.java
deleted file mode 100644
index a32832e23e..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/fragment/HOGPHelp01Fragment.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- HOGPHelp01Fragment.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.fragment;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.fragment.app.Fragment;
-
-import org.deviceconnect.android.deviceplugin.hogp.R;
-
-public class HOGPHelp01Fragment extends Fragment {
-
- public static HOGPHelp01Fragment newInstance() {
- HOGPHelp01Fragment frag = new HOGPHelp01Fragment();
- return frag;
- }
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
- final Bundle savedInstanceState) {
- return inflater.inflate(R.layout.fragment_help_01, null);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/fragment/HOGPHelp02Fragment.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/fragment/HOGPHelp02Fragment.java
deleted file mode 100644
index 660be1bd1f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/fragment/HOGPHelp02Fragment.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- HOGPHelp02Fragment.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.fragment;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.fragment.app.Fragment;
-
-import org.deviceconnect.android.deviceplugin.hogp.R;
-
-public class HOGPHelp02Fragment extends Fragment {
-
- public static HOGPHelp02Fragment newInstance() {
- HOGPHelp02Fragment frag = new HOGPHelp02Fragment();
- return frag;
- }
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
- final Bundle savedInstanceState) {
- return inflater.inflate(R.layout.fragment_help_02, null);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/fragment/HOGPHelp03Fragment.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/fragment/HOGPHelp03Fragment.java
deleted file mode 100644
index 7db6a16dac..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/fragment/HOGPHelp03Fragment.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- HOGPHelp03Fragment.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.fragment;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.fragment.app.Fragment;
-
-import org.deviceconnect.android.deviceplugin.hogp.R;
-
-public class HOGPHelp03Fragment extends Fragment {
-
- public static HOGPHelp03Fragment newInstance() {
- HOGPHelp03Fragment frag = new HOGPHelp03Fragment();
- return frag;
- }
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
- final Bundle savedInstanceState) {
- return inflater.inflate(R.layout.fragment_help_03, null);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/fragment/HOGPHelp04Fragment.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/fragment/HOGPHelp04Fragment.java
deleted file mode 100644
index 8fb4c0cab7..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/fragment/HOGPHelp04Fragment.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- HOGPHelp04Fragment.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.fragment;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.fragment.app.Fragment;
-
-import org.deviceconnect.android.deviceplugin.hogp.R;
-
-public class HOGPHelp04Fragment extends Fragment {
-
- public static HOGPHelp04Fragment newInstance() {
- HOGPHelp04Fragment frag = new HOGPHelp04Fragment();
- return frag;
- }
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
- final Bundle savedInstanceState) {
- return inflater.inflate(R.layout.fragment_help_04, null);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPHogpProfile.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPHogpProfile.java
deleted file mode 100644
index a279550b71..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPHogpProfile.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- HOGPHogpProfile.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.profiles;
-
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.hogp.HOGPMessageService;
-import org.deviceconnect.android.deviceplugin.hogp.server.HOGPServer;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.DConnectProfile;
-import org.deviceconnect.android.profile.api.DeleteApi;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.message.DConnectMessage;
-
-/**
- * HOGPプロファイル.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPHogpProfile extends DConnectProfile {
-
- public HOGPHogpProfile() {
-
- // DELETE /hogp
- addApi(new DeleteApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- HOGPMessageService service = (HOGPMessageService) getContext();
- if (service.getHOGPServer() != null) {
- service.stopHOGPServer();
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP Server is not running.");
- }
- return true;
- }
- });
-
- // POST /hogp
- addApi(new PostApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String mouse = (String) request.getExtras().get("mouse");
- Boolean keyboard = parseBoolean(request, "keyboard");
-
- HOGPMessageService service = (HOGPMessageService) getContext();
- if (service.getHOGPServer() != null) {
- response.putExtra("message", "HOGP Server is already running.");
- setResult(response, DConnectMessage.RESULT_OK);
- } else {
- try {
- if (keyboard == null) {
- keyboard = false;
- }
- service.getHOGPSetting().setEnabledKeyboard(keyboard);
- service.getHOGPSetting().setMouseMode(getMouseMode(mouse));
-
- service.startHOGPServer();
- setResult(response, DConnectMessage.RESULT_OK);
- } catch (Exception e) {
- MessageUtils.setUnknownError(response, "Failed to start HOGP Server. message=" + e.getMessage());
- }
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "hogp";
- }
-
- /**
- * マウスモードを取得します.
- * @param mode マウスモード
- * @return マウスモード
- */
- private HOGPServer.MouseMode getMouseMode(final String mode) {
- if (mode == null) {
- return HOGPServer.MouseMode.NONE;
- } else if (mode.equalsIgnoreCase("absolute")) {
- return HOGPServer.MouseMode.ABSOLUTE;
- } else if (mode.equalsIgnoreCase("relative")) {
- return HOGPServer.MouseMode.RELATIVE;
- } else {
- return HOGPServer.MouseMode.NONE;
- }
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPJoystickProfile.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPJoystickProfile.java
deleted file mode 100644
index 2eb521fce1..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPJoystickProfile.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- HOGPJoystickProfile.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.profiles;
-
-import android.bluetooth.BluetoothDevice;
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.hogp.HOGPService;
-import org.deviceconnect.android.profile.DConnectProfile;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.android.service.DConnectService;
-import org.deviceconnect.message.DConnectMessage;
-
-/**
- * Joystickプロファイル.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPJoystickProfile extends DConnectProfile {
-
- public HOGPJoystickProfile() {
-
- // POST /joystick
- addApi(new PostApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- // TODO ここでAPIを実装してください. 以下はサンプルのレスポンス作成処理です.
- setResult(response, DConnectMessage.RESULT_OK);
- return true;
- }
- });
-
- }
-
- @Override
- public String getProfileName() {
- return "joystick";
- }
-
- /**
- * BluetoothDeviceを取得します.
- *
- * BluetoothDeviceが取得できない場合はnullを返却します。
- *
- * @return BluetoothDevice
- */
- private BluetoothDevice getDevice() {
- DConnectService service = getService();
- if (service instanceof HOGPService) {
- return ((HOGPService) service).getDevice();
- }
- return null;
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPKeyboardProfile.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPKeyboardProfile.java
deleted file mode 100644
index a723b2163d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPKeyboardProfile.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- HOGPKeyboardProfile.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.profiles;
-
-import android.bluetooth.BluetoothDevice;
-import android.content.Intent;
-
-import org.deviceconnect.android.deviceplugin.hogp.HOGPMessageService;
-import org.deviceconnect.android.deviceplugin.hogp.HOGPService;
-import org.deviceconnect.android.deviceplugin.hogp.HOGPSetting;
-import org.deviceconnect.android.deviceplugin.hogp.server.HOGPServer;
-import org.deviceconnect.android.deviceplugin.hogp.util.KeyboardCode;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.DConnectProfile;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.android.service.DConnectService;
-import org.deviceconnect.message.DConnectMessage;
-
-/**
- * Keyboardプロファイル.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPKeyboardProfile extends DConnectProfile {
-
- /**
- * コンストラクタ.
- */
- public HOGPKeyboardProfile() {
- // POST /keyboard
- addApi(new PostApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Byte modifier = modifier((String) request.getExtras().get("modifier"));
- byte[] keyCode = getKeyCodes(request, "keyCode");
-
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (!getSetting().isEnabledKeyboard()) {
- MessageUtils.setNotSupportProfileError(response, "Keyboard is not supported.");
- } else if (keyCode == null) {
- MessageUtils.setInvalidRequestParameterError(response, "keyCode is invalid.");
- } else if (modifier == null) {
- MessageUtils.setInvalidRequestParameterError(response, "modifier is invalid.");
- } else {
- sendKeyboard(modifier, keyCode);
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- // POST /keyboard/ascii
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "ascii";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- final String string = (String) request.getExtras().get("string");
-
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (!getSetting().isEnabledKeyboard()) {
- MessageUtils.setNotSupportProfileError(response, "Keyboard is not supported.");
- } else if (string == null) {
- MessageUtils.setInvalidRequestParameterError(response, "string is null.");
- } else if (string.isEmpty()) {
- MessageUtils.setInvalidRequestParameterError(response, "string is empty.");
- } else if (string.matches("^.*[^\\p{ASCII}].*")) {
- MessageUtils.setInvalidRequestParameterError(response, "Not ascii character contains.");
- } else {
- for (int i = 0; i < string.length(); i++) {
- String a = String.valueOf(string.charAt(i));
- byte modifier = KeyboardCode.modifier(a);
- byte keyCode = KeyboardCode.keyCode(a);
- sendKeyboard(modifier, keyCode);
- }
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- // POST /keyboard/del
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "del";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (!getSetting().isEnabledKeyboard()) {
- MessageUtils.setNotSupportProfileError(response, "Keyboard is not supported.");
- } else {
- sendKeyboard((byte) 0, KeyboardCode.KEY_DEL);
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- // POST /keyboard/downArrow
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "downArrow";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (!getSetting().isEnabledKeyboard()) {
- MessageUtils.setNotSupportProfileError(response, "Keyboard is not supported.");
- } else {
- sendKeyboard((byte) 0, KeyboardCode.KEY_DOWN_ARROW);
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- // POST /keyboard/enter
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "enter";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (!getSetting().isEnabledKeyboard()) {
- MessageUtils.setNotSupportProfileError(response, "Keyboard is not supported.");
- } else {
- sendKeyboard((byte) 0, KeyboardCode.KEY_ENTER);
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- // POST /keyboard/esc
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "esc";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (!getSetting().isEnabledKeyboard()) {
- MessageUtils.setNotSupportProfileError(response, "Keyboard is not supported.");
- } else {
- sendKeyboard((byte) 0, KeyboardCode.KEY_ESC);
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- // POST /keyboard/leftArrow
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "leftArrow";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (!getSetting().isEnabledKeyboard()) {
- MessageUtils.setNotSupportProfileError(response, "Keyboard is not supported.");
- } else {
- sendKeyboard((byte) 0, KeyboardCode.KEY_LEFT_ARROW);
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- // POST /keyboard/rightArrow
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "rightArrow";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (!getSetting().isEnabledKeyboard()) {
- MessageUtils.setNotSupportProfileError(response, "Keyboard is not supported.");
- } else {
- sendKeyboard((byte) 0, KeyboardCode.KEY_RIGHT_ARROW);
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- // POST /keyboard/upArrow
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "upArrow";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (!getSetting().isEnabledKeyboard()) {
- MessageUtils.setNotSupportProfileError(response, "Keyboard is not supported.");
- } else {
- sendKeyboard((byte) 0, KeyboardCode.KEY_UP_ARROW);
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- }
-
- @Override
- public String getProfileName() {
- return "keyboard";
- }
-
- /**
- * HOGPSettingのインスタンスを取得します.
- * @return インスタンス
- */
- private HOGPSetting getSetting() {
- HOGPMessageService service = (HOGPMessageService) getContext();
- return service.getHOGPSetting();
- }
-
- /**
- * HOGPサーバを取得します.
- * @return HOGPサーバ
- */
- private HOGPServer getHOGPServer() {
- HOGPMessageService service = (HOGPMessageService) getContext();
- return (HOGPServer) service.getHOGPServer();
- }
-
- /**
- * リクエストからキーコードの配列を取得します.
- * @param request リクエスト
- * @param name パラメータ名
- * @return キーコードの配列
- */
- private byte[] getKeyCodes(final Intent request, final String name) {
- String value = (String) request.getExtras().get(name);
- if (value == null) {
- return null;
- }
- try {
- String[] array = value.split(",");
- if (array.length > 6) {
- return null;
- }
- byte[] keyCodes = new byte[array.length];
- for (int i = 0; i < array.length; i++) {
- keyCodes[i] = getKeyCode(array[i].trim());
- }
- return keyCodes;
- } catch (Exception e) {
- return null;
- }
- }
-
- /**
- * 文字列からキーコードを取得します.
- * @param value キーコード
- * @return キーコード
- */
- private Byte getKeyCode(final String value) {
- if (value == null || value.isEmpty()) {
- throw new NumberFormatException("value is invalid.");
- }
- if (value.startsWith("0x")) {
- return Byte.decode(value);
- }
- return Byte.parseByte(value);
- }
-
- /**
- * キーボードイベントを送信します.
- * @param modifier モディファイアーキー
- * @param keyCode キーコード
- */
- private void sendKeyboard(final byte modifier, final byte keyCode) {
- HOGPServer server = getHOGPServer();
- server.sendKeyDown(getDevice(), modifier, keyCode);
- server.sendKeyUp(getDevice());
- }
-
- /**
- * キーボードイベントを送信します.
- * @param modifier モディファイアーキー
- * @param keyCode キーコード
- */
- private void sendKeyboard(final byte modifier, final byte[] keyCode) {
- HOGPServer server = getHOGPServer();
- server.sendKeyDown(getDevice(), modifier, keyCode);
- server.sendKeyUp(getDevice());
- }
-
- /**
- * モディファイアーキーを取得します.
- * @param modifier APIの引数で指定されたモディファイアーキー
- * @return 変換されたモディファイアーキー
- */
- private Byte modifier(final String modifier) {
- if (modifier == null) {
- return KeyboardCode.MODIFIER_KEY_NONE;
- }
-
- byte m = KeyboardCode.MODIFIER_KEY_NONE;
- String[] split = modifier.split(",");
- for (String s : split) {
- if ("ctrl".equals(s)) {
- m |= KeyboardCode.MODIFIER_KEY_CTRL;
- } else if ("shift".equals(s)) {
- m |= KeyboardCode.MODIFIER_KEY_SHIFT;
- } else if ("alt".equals(s)) {
- m |= KeyboardCode.MODIFIER_KEY_ALT;
- } else if ("gui".equals(s)) {
- m |= KeyboardCode.MODIFIER_KEY_GUI;
- } else {
- return null;
- }
- }
- return m;
- }
-
- /**
- * BluetoothDeviceを取得します.
- *
- * BluetoothDeviceが取得できない場合はnullを返却します。
- *
- * @return BluetoothDevice
- */
- private BluetoothDevice getDevice() {
- DConnectService service = getService();
- if (service instanceof HOGPService) {
- return ((HOGPService) service).getDevice();
- }
- return null;
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPMouseProfile.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPMouseProfile.java
deleted file mode 100644
index 77e6512049..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPMouseProfile.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- HOGPMouseProfile.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.profiles;
-
-import android.bluetooth.BluetoothDevice;
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.hogp.HOGPMessageService;
-import org.deviceconnect.android.deviceplugin.hogp.HOGPService;
-import org.deviceconnect.android.deviceplugin.hogp.HOGPSetting;
-import org.deviceconnect.android.deviceplugin.hogp.server.HOGPServer;
-import org.deviceconnect.android.message.MessageUtils;
-import org.deviceconnect.android.profile.DConnectProfile;
-import org.deviceconnect.android.profile.api.GetApi;
-import org.deviceconnect.android.profile.api.PostApi;
-import org.deviceconnect.android.service.DConnectService;
-import org.deviceconnect.message.DConnectMessage;
-
-/**
- * Mouseプロファイル.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPMouseProfile extends DConnectProfile {
-
- public HOGPMouseProfile() {
-
- // GET /mouse
- addApi(new GetApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (getSetting().getMouseMode() == HOGPServer.MouseMode.NONE) {
- MessageUtils.setNotSupportAttributeError(response, "Mouse is not supported.");
- } else {
- response.putExtra("mouse", createMouseInfo());
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- // POST /mouse
- addApi(new PostApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- Float x = parseFloat(request, "x");
- Float y = parseFloat(request, "y");
- Float wheel = parseFloat(request, "wheel");
- Boolean rightButton = parseBoolean(request, "rightButton");
- Boolean leftButton = parseBoolean(request, "leftButton");
- Boolean middleButton = parseBoolean(request, "middleButton");
-
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (getSetting().getMouseMode() == HOGPServer.MouseMode.NONE) {
- MessageUtils.setNotSupportAttributeError(response, "Mouse is not supported.");
- } else {
- if (x == null) {
- x = 0.0f;
- }
-
- if (y == null) {
- y = 0.0f;
- }
-
- if (wheel == null) {
- wheel = 0.0f;
- }
-
- if (rightButton == null) {
- rightButton = false;
- }
-
- if (leftButton == null) {
- leftButton = false;
- }
-
- if (middleButton == null) {
- middleButton = false;
- }
-
- server.movePointer(getDevice(), x, y, wheel, leftButton, rightButton, middleButton);
-
- response.putExtra("mouse", createMouseInfo());
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- // POST /mouse/click
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "click";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String button = (String) request.getExtras().get("button");
-
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (getSetting().getMouseMode() == HOGPServer.MouseMode.NONE) {
- MessageUtils.setNotSupportAttributeError(response, "Mouse is not supported.");
- } else if (!checkButton(button)) {
- MessageUtils.setNotSupportAttributeError(response, "button is invalid.");
- } else {
- BluetoothDevice device = getDevice();
- boolean leftButton = "left".equals(button);
- boolean rightButton = "right".equals(button);
- boolean middleButton = "middle".equals(button);
- server.movePointer(device, 0, 0, 0, leftButton, rightButton, middleButton);
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- server.movePointer(device, 0, 0, 0, false, false, false);
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
-
- // POST /mouse/doubleClick
- addApi(new PostApi() {
- @Override
- public String getAttribute() {
- return "doubleClick";
- }
-
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- String button = (String) request.getExtras().get("button");
-
- HOGPServer server = getHOGPServer();
- if (server == null) {
- MessageUtils.setIllegalDeviceStateError(response, "HOGP server is not running.");
- } else if (getSetting().getMouseMode() == HOGPServer.MouseMode.NONE) {
- MessageUtils.setNotSupportAttributeError(response, "Mouse is not supported.");
- } else if (!checkButton(button)) {
- MessageUtils.setNotSupportAttributeError(response, "button is invalid.");
- } else {
- BluetoothDevice device = getDevice();
- boolean leftButton = "left".equals(button);
- boolean rightButton = "right".equals(button);
- boolean middleButton = "middle".equals(button);
- server.movePointer(device, 0, 0, 0, leftButton, rightButton, middleButton);
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- server.movePointer(device, 0, 0, 0, false, false, false);
-
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- server.movePointer(device, 0, 0, 0, leftButton, rightButton, middleButton);
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- server.movePointer(device, 0, 0, 0, false, false, false);
-
- setResult(response, DConnectMessage.RESULT_OK);
- }
- return true;
- }
- });
- }
-
- @Override
- public String getProfileName() {
- return "mouse";
- }
-
- /**
- * マウスの情報を格納したBundleを取得します.
- * @return マウスの情報を格納したBundle
- */
- private Bundle createMouseInfo() {
- Bundle mouse = new Bundle();
- switch (getSetting().getMouseMode()) {
- case ABSOLUTE:
- mouse.putString("type", "absolute");
- break;
- case RELATIVE:
- mouse.putString("type", "relative");
- break;
- }
- return mouse;
- }
-
- /**
- * HOGPSettingのインスタンスを取得します.
- * @return インスタンス
- */
- private HOGPSetting getSetting() {
- HOGPMessageService service = (HOGPMessageService) getContext();
- return service.getHOGPSetting();
- }
-
- /**
- * HOGPサーバを取得します.
- * @return HOGPサーバ
- */
- private HOGPServer getHOGPServer() {
- HOGPMessageService service = (HOGPMessageService) getContext();
- return (HOGPServer) service.getHOGPServer();
- }
-
- /**
- * BluetoothDeviceを取得します.
- *
- * BluetoothDeviceが取得できない場合はnullを返却します。
- *
- * @return BluetoothDevice
- */
- private BluetoothDevice getDevice() {
- DConnectService service = getService();
- if (service instanceof HOGPService) {
- return ((HOGPService) service).getDevice();
- }
- return null;
- }
-
- /**
- * 指定されたbuttonがleft,right,middleに当てはまるか確認します.
- * @param button ボタン
- * @return 当てはまる場合はtrue、それ以外はfalse
- */
- private boolean checkButton(final String button) {
- boolean leftButton = "left".equals(button);
- boolean rightButton = "right".equals(button);
- boolean middleButton = "middle".equals(button);
- return leftButton | rightButton | middleButton;
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPServiceInformation.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPServiceInformation.java
deleted file mode 100644
index 3f0866a3cf..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPServiceInformation.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- HOGPServiceInformation.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.profiles;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Parcelable;
-
-import org.deviceconnect.android.deviceplugin.hogp.HOGPMessageService;
-import org.deviceconnect.android.deviceplugin.hogp.HOGPSetting;
-import org.deviceconnect.android.profile.ServiceInformationProfile;
-import org.deviceconnect.android.profile.api.GetApi;
-
-/**
- * ServiceInformationプロファイル.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPServiceInformation extends ServiceInformationProfile {
-
- /**
- * Constructor.
- */
- public HOGPServiceInformation() {
- addApi(new GetApi() {
- @Override
- public boolean onRequest(final Intent request, final Intent response) {
- appendServiceInformation(response);
- convertParameters(response);
- return true;
- }
- });
- }
-
- /**
- * mouseプロファイルのパラメータをAbsolute,Relativeに合わせて変更します.
- *
- * AbsoluteとRelativeでは、minimumとmaximumの範囲が異なるので、そのパラメータを変更しています。
- *
- * @param response 変更するレスポンス
- */
- private void convertParameters(final Intent response) {
- Bundle supportApis = response.getBundleExtra("supportApis");
- if (supportApis != null) {
- Bundle mouse = supportApis.getBundle("mouse");
- if (mouse != null) {
- Bundle pathsObj = mouse.getBundle("paths");
- if (pathsObj != null) {
- Bundle path = pathsObj.getBundle("/");
- if (path != null) {
- Bundle post = path.getBundle("post");
- if (post != null) {
- Parcelable[] parameters = post.getParcelableArray("parameters");
- if (parameters != null) {
- for (Parcelable p : parameters) {
- Bundle param = (Bundle) p;
- String name = param.getString("name");
- if ("x".equalsIgnoreCase(name) || "y".equalsIgnoreCase(name)) {
- switch (getHOGPSetting().getMouseMode()) {
- case ABSOLUTE:
- param.putDouble("minimum", 0.0);
- param.putDouble("maximum", 1.0);
- break;
- case RELATIVE:
- param.putDouble("minimum", -1.0);
- param.putDouble("maximum", 1.0);
- break;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- /**
- * HOGPSettingを取得します.
- * @return HOGPSettingのインスタンス
- */
- private HOGPSetting getHOGPSetting() {
- HOGPMessageService service = (HOGPMessageService) getContext();
- return service.getHOGPSetting();
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPSystemProfile.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPSystemProfile.java
deleted file mode 100644
index 869a2d7eef..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/profiles/HOGPSystemProfile.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- HOGPSystemProfile.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.profiles;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-
-import org.deviceconnect.android.deviceplugin.hogp.activity.HOGPSettingActivity;
-import org.deviceconnect.android.profile.SystemProfile;
-
-/**
- * Systemプロファイル.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPSystemProfile extends SystemProfile {
- @Override
- protected Class extends Activity> getSettingPageActivity(final Intent request, final Bundle param) {
- return HOGPSettingActivity.class;
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/server/AbstractHOGPServer.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/server/AbstractHOGPServer.java
deleted file mode 100644
index 3650987fb4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/server/AbstractHOGPServer.java
+++ /dev/null
@@ -1,996 +0,0 @@
-/*
- AbstractHOGPServer.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.server;
-
-import android.annotation.TargetApi;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothGatt;
-import android.bluetooth.BluetoothGattCharacteristic;
-import android.bluetooth.BluetoothGattDescriptor;
-import android.bluetooth.BluetoothGattServer;
-import android.bluetooth.BluetoothGattServerCallback;
-import android.bluetooth.BluetoothGattService;
-import android.bluetooth.BluetoothManager;
-import android.bluetooth.BluetoothProfile;
-import android.bluetooth.le.AdvertiseCallback;
-import android.bluetooth.le.AdvertiseData;
-import android.bluetooth.le.AdvertiseSettings;
-import android.bluetooth.le.BluetoothLeAdvertiser;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Build;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.ParcelUuid;
-import android.util.Log;
-
-import org.deviceconnect.android.deviceplugin.hogp.BuildConfig;
-import org.deviceconnect.android.deviceplugin.hogp.util.BatteryUtils;
-import org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Queue;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.CHARACTERISTIC_BATTERY_LEVEL;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.CHARACTERISTIC_HID_CONTROL_POINT;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.CHARACTERISTIC_HID_INFORMATION;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.CHARACTERISTIC_MANUFACTURER_NAME;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.CHARACTERISTIC_MODEL_NUMBER;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.CHARACTERISTIC_PROTOCOL_MODE;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.CHARACTERISTIC_REPORT;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.CHARACTERISTIC_REPORT_MAP;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.CHARACTERISTIC_SERIAL_NUMBER;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.DESCRIPTOR_CLIENT_CHARACTERISTIC_CONFIGURATION;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.DESCRIPTOR_REPORT_REFERENCE;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.DEVICE_INFO_MAX_LENGTH;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.SERVICE_BATTERY;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.SERVICE_BLE_HID;
-import static org.deviceconnect.android.deviceplugin.hogp.util.BleUuidUtils.SERVICE_DEVICE_INFORMATION;
-
-/**
- * HOGPの挙動を行うためのGattServerを実装したクラス.
- *
- * @author NTT DOCOMO, INC.
- */
-@TargetApi(Build.VERSION_CODES.LOLLIPOP)
-public abstract class AbstractHOGPServer {
- /**
- * デバッグ用フラグ.
- */
- private static final boolean DEBUG = BuildConfig.DEBUG;
-
- /**
- * デバッグ用タグ.
- */
- private static final String TAG = "HOGP";
-
- /**
- * このインスタンスが属するコンテキスト.
- */
- private final Context mApplicationContext;
-
- /**
- * アドバタイズを行うクラス.
- */
- private BluetoothLeAdvertiser mBluetoothLeAdvertiser;
-
- /**
- * Inputレポートキャラクタリスティック.
- */
- private BluetoothGattCharacteristic mInputReportCharacteristic;
-
- /**
- * GattServerのインスタンス.
- */
- private BluetoothGattServer mGattServer;
-
- /**
- * 接続したBluetoothデバイス.
- */
- private final Map mBluetoothDevicesMap = new HashMap<>();
-
- /**
- * マニファクチャー名.
- */
- private byte[] mManufacturerName;
-
- /**
- * デバイス名.
- */
- private byte[] mDeviceName;
-
- /**
- * シリアルナンバー.
- */
- private byte[] mSerialNumber;
-
- /**
- * HID Input Report
- */
- private final Queue mInputReportQueue = new ConcurrentLinkedQueue<>();
-
- /**
- * Bluetoothデバイスの処理を同期的に処理するためのハンドラ.
- */
- private Handler mHandler;
-
- /**
- * ハンドラ用のスレッド.
- */
- private HandlerThread mHandlerThread;
-
- /**
- * デバイスに送信するタイマー.
- */
- private Timer mTimer;
-
- /**
- * デバイスにHIDを送る送信レート.
- */
- private int mDataSendingRate = 10;
-
- /**
- * デバイス接続イベントを通知するリスナー.
- */
- private OnHOGPServerListener mOnHOGPServerListener;
-
- /**
- * 空のバイト配列.
- */
- private static final byte[] EMPTY_BYTES = {};
-
- /**
- * HIDインフォメーションのレスポンス.
- */
- private static final byte[] RESPONSE_HID_INFORMATION = {0x11, 0x01, 0x00, 0x03};
-
- /**
- * コンストラクタ.
- * @param context このインスタンスが属するコンテキスト
- * @throws UnsupportedOperationException BluetoothやBLEがサポートされていない場合に発生
- */
- AbstractHOGPServer(final Context context) throws UnsupportedOperationException {
- mApplicationContext = context.getApplicationContext();
-
- final BluetoothManager btMgr = (BluetoothManager) mApplicationContext.getSystemService(Context.BLUETOOTH_SERVICE);
- final BluetoothAdapter btAdapter = btMgr.getAdapter();
- if (btAdapter == null) {
- throw new UnsupportedOperationException("Bluetooth is not available.");
- }
-
- if (!btAdapter.isEnabled()) {
- throw new UnsupportedOperationException("Bluetooth is disabled.");
- }
-
- if (!btAdapter.isMultipleAdvertisementSupported()) {
- throw new UnsupportedOperationException("Bluetooth LE Advertising not supported on this device.");
- }
-
- mBluetoothLeAdvertiser = btAdapter.getBluetoothLeAdvertiser();
- if (mBluetoothLeAdvertiser == null) {
- throw new UnsupportedOperationException("Bluetooth LE Advertising not supported on this device.");
- }
- }
-
- /**
- * HIDデータ送信レートを設定します.
- * @param dataSendingRate 送信レート
- */
- public void setDataSendingRate(final int dataSendingRate) {
- mDataSendingRate = dataSendingRate;
- }
-
- /**
- * OnHOGPServerListenerを設定します.
- * @param listener リスナー
- */
- public void setOnHOGPServerListener(final OnHOGPServerListener listener) {
- mOnHOGPServerListener = listener;
- }
-
- /**
- * Manufacturer名を設定します.
- *
- * @param name Manufacturer名
- */
- public void setManufacturerName(final String name) {
- mManufacturerName = convertString2Bytes(name);
- }
-
- /**
- * デバイス名を設定します.
- *
- * @param name the name
- */
- public void setDeviceName(final String name) {
- mDeviceName = convertString2Bytes(name);
- }
-
- /**
- * シリアル番号を設定します.
- *
- * @param serialNumber the number
- */
- public final void setSerialNumber(final String serialNumber) {
- mSerialNumber = convertString2Bytes(serialNumber);
- }
-
- /**
- * 文字列をバイト配列に変換します.
- * @param name 変換する文字列
- * @return 変換されたバイト配列
- */
- private byte[] convertString2Bytes(final String name) {
- if (name == null) {
- return new byte[0];
- }
-
- final byte[] nameBytes = name.getBytes(StandardCharsets.UTF_8);
- if (nameBytes.length > DEVICE_INFO_MAX_LENGTH) {
- final byte[] bytes = new byte[DEVICE_INFO_MAX_LENGTH];
- System.arraycopy(nameBytes, 0, bytes, 0, DEVICE_INFO_MAX_LENGTH);
- return bytes;
- } else {
- return nameBytes;
- }
- }
-
- /**
- * レポートマップのキャラクタリスティックの値を取得します.
- *
- * ここで返却するレポートマップがHOGPの機能になります。
- *
- * @return Report Map data
- */
- abstract byte[] getReportMap();
-
- /**
- * HID Outputレポートを通知します.
- *
- * @param outputReport the report data
- */
- abstract void onOutputReport(final byte[] outputReport);
-
- /**
- * 送信するHIDデータを追加します.
- *
- * deviceにnullが指定された場合には接続されているデバイス全てに送信します。
- *
- * @param device 送信先のBluetoothデバイス
- * @param inputReport 追加するデータ
- */
- final void addInputReport(final BluetoothDevice device, final byte[] inputReport) {
- if (inputReport != null && inputReport.length > 0) {
- mInputReportQueue.offer(new ReportHolder(device, inputReport));
- }
- }
-
- /**
- * HOGPサーバを開始します.
- */
- public void start() {
-
- if (mGattServer != null) {
- if (DEBUG) {
- Log.w(TAG, "HOGP Server is already running.");
- }
- return;
- }
-
- BluetoothManager btMgr = (BluetoothManager) mApplicationContext.getSystemService(Context.BLUETOOTH_SERVICE);
- mGattServer = btMgr.openGattServer(mApplicationContext, mGattServerCallback);
- if (mGattServer == null) {
- throw new UnsupportedOperationException("mGattServer is null, check Bluetooth is ON.");
- }
-
- mHandlerThread = new HandlerThread(TAG);
- mHandlerThread.start();
- mHandler = new Handler(mHandlerThread.getLooper());
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- addService(setUpHidService(true, true, false));
- addService(setUpDeviceInformationService());
- addService(setUpBatteryService());
- }
- }).start();
-
- mTimer = new Timer();
- mTimer.schedule(new TimerTask() {
- @Override
- public void run() {
- final ReportHolder holder = mInputReportQueue.poll();
- if (holder != null && mInputReportCharacteristic != null) {
- mInputReportCharacteristic.setValue(holder.getReport());
- mHandler.post(new Runnable() {
- private void notifyCharacteristic(final BluetoothDevice device) {
- try {
- if (mGattServer != null) {
- mGattServer.notifyCharacteristicChanged(device, mInputReportCharacteristic, false);
- }
- } catch (final Throwable ignored) {
- // do nothing.
- }
- }
- @Override
- public void run() {
- if (holder.getDevice() != null) {
- notifyCharacteristic(holder.getDevice());
- } else {
- Set devices = getDevices();
- for (BluetoothDevice device : devices) {
- notifyCharacteristic(device);
- }
- }
- }
- });
- }
- }
- }, 0, mDataSendingRate);
-
- startAdvertising();
- }
-
- /**
- * HOGPサーバを停止します.
- */
- public void stop() {
- stopAdvertising();
- }
-
- /**
- * BluetoothGattServerにサービスを追加します.
- *
- * @param service 追加するサービス
- */
- private void addService(final BluetoothGattService service) {
- boolean serviceAdded = false;
- while (!serviceAdded) {
- try {
- // 連続でserviceを追加すると例外が発生する
- // 回避するためにsleepを入れています。
- Thread.sleep(500);
- serviceAdded = mGattServer.addService(service);
- } catch (final Exception e) {
- if (DEBUG) {
- Log.w(TAG, "Adding Service failed", e);
- }
- }
- }
- if (DEBUG) {
- Log.d(TAG, "Service: " + service.getUuid() + " added.");
- }
- }
-
- /**
- * Device Informationサービスを設定します.
- *
- * @return Device Information サービスを
- */
- private BluetoothGattService setUpDeviceInformationService() {
- final BluetoothGattService service = new BluetoothGattService(SERVICE_DEVICE_INFORMATION, BluetoothGattService.SERVICE_TYPE_PRIMARY);
- {
- final BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(
- CHARACTERISTIC_MANUFACTURER_NAME,
- BluetoothGattCharacteristic.PROPERTY_READ,
- BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED);
- service.addCharacteristic(characteristic);
- }
- {
- final BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(
- CHARACTERISTIC_MODEL_NUMBER,
- BluetoothGattCharacteristic.PROPERTY_READ,
- BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED);
- service.addCharacteristic(characteristic);
- }
- {
- final BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(
- CHARACTERISTIC_SERIAL_NUMBER,
- BluetoothGattCharacteristic.PROPERTY_READ,
- BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED);
- service.addCharacteristic(characteristic);
- }
-
- return service;
- }
-
- /**
- * Setup Battery Service
- *
- * @return the service
- */
- private BluetoothGattService setUpBatteryService() {
- final BluetoothGattService service = new BluetoothGattService(SERVICE_BATTERY, BluetoothGattService.SERVICE_TYPE_PRIMARY);
-
- // Battery Level
- final BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(
- CHARACTERISTIC_BATTERY_LEVEL,
- BluetoothGattCharacteristic.PROPERTY_NOTIFY | BluetoothGattCharacteristic.PROPERTY_READ,
- BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED);
-
- final BluetoothGattDescriptor clientCharacteristicConfigurationDescriptor = new BluetoothGattDescriptor(
- DESCRIPTOR_CLIENT_CHARACTERISTIC_CONFIGURATION,
- BluetoothGattDescriptor.PERMISSION_READ | BluetoothGattDescriptor.PERMISSION_WRITE);
- clientCharacteristicConfigurationDescriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
- characteristic.addDescriptor(clientCharacteristicConfigurationDescriptor);
-
- service.addCharacteristic(characteristic);
-
- return service;
- }
-
- /**
- * HIDサービスを設定します.
- *
- * @param isNeedInputReport true: serves 'Input Report' BLE characteristic
- * @param isNeedOutputReport true: serves 'Output Report' BLE characteristic
- * @param isNeedFeatureReport true: serves 'Feature Report' BLE characteristic
- * @return HIDサービス
- */
- private BluetoothGattService setUpHidService(final boolean isNeedInputReport, final boolean isNeedOutputReport, final boolean isNeedFeatureReport) {
- final BluetoothGattService service = new BluetoothGattService(SERVICE_BLE_HID, BluetoothGattService.SERVICE_TYPE_PRIMARY);
-
- // HID Information
- {
- final BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(
- CHARACTERISTIC_HID_INFORMATION,
- BluetoothGattCharacteristic.PROPERTY_READ,
- BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED);
-
- service.addCharacteristic(characteristic);
- }
-
- // Report Map
- {
- final BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(
- CHARACTERISTIC_REPORT_MAP,
- BluetoothGattCharacteristic.PROPERTY_READ,
- BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED);
-
- service.addCharacteristic(characteristic);
- }
-
- // Protocol Mode
- {
- final BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(
- CHARACTERISTIC_PROTOCOL_MODE,
- BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE,
- BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED | BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED);
- characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
-
- service.addCharacteristic(characteristic);
- }
-
- // HID Control Point
- {
- final BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(
- CHARACTERISTIC_HID_CONTROL_POINT,
- BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE,
- BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED);
- characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
-
- service.addCharacteristic(characteristic);
- }
-
- // Input Report
- if (isNeedInputReport) {
- final BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(
- CHARACTERISTIC_REPORT,
- BluetoothGattCharacteristic.PROPERTY_NOTIFY | BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_WRITE,
- BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED | BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED);
-
- final BluetoothGattDescriptor clientCharacteristicConfigurationDescriptor = new BluetoothGattDescriptor(
- DESCRIPTOR_CLIENT_CHARACTERISTIC_CONFIGURATION,
- BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED | BluetoothGattDescriptor.PERMISSION_WRITE_ENCRYPTED); // | BluetoothGattDescriptor.PERMISSION_WRITE
- clientCharacteristicConfigurationDescriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
- characteristic.addDescriptor(clientCharacteristicConfigurationDescriptor);
-
- final BluetoothGattDescriptor reportReferenceDescriptor = new BluetoothGattDescriptor(
- DESCRIPTOR_REPORT_REFERENCE,
- BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED | BluetoothGattDescriptor.PERMISSION_WRITE_ENCRYPTED);
- characteristic.addDescriptor(reportReferenceDescriptor);
-
- service.addCharacteristic(characteristic);
- mInputReportCharacteristic = characteristic;
- }
-
- // Output Report
- if (isNeedOutputReport) {
- final BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(
- CHARACTERISTIC_REPORT,
- BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE,
- BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED | BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED);
- characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
-
- final BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(
- DESCRIPTOR_REPORT_REFERENCE,
- BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED | BluetoothGattDescriptor.PERMISSION_WRITE_ENCRYPTED);
- characteristic.addDescriptor(descriptor);
-
- service.addCharacteristic(characteristic);
- }
-
- // Feature Report
- if (isNeedFeatureReport) {
- final BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(
- CHARACTERISTIC_REPORT,
- BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_WRITE,
- BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED | BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED);
-
- final BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(
- DESCRIPTOR_REPORT_REFERENCE,
- BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED | BluetoothGattDescriptor.PERMISSION_WRITE_ENCRYPTED);
- characteristic.addDescriptor(descriptor);
-
- service.addCharacteristic(characteristic);
- }
-
- return service;
- }
-
- /**
- * アドバタイジングを開始します.
- */
- private void startAdvertising() {
- if (DEBUG) {
- Log.d(TAG, "startAdvertising");
- }
-
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- // set up advertising setting
- final AdvertiseSettings advertiseSettings = new AdvertiseSettings.Builder()
- .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)
- .setConnectable(true)
- .setTimeout(0)
- .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
- .build();
-
- // set up advertising data
- final AdvertiseData advertiseData = new AdvertiseData.Builder()
- .setIncludeTxPowerLevel(false)
- .setIncludeDeviceName(true)
- .addServiceUuid(ParcelUuid.fromString(SERVICE_DEVICE_INFORMATION.toString()))
- .addServiceUuid(ParcelUuid.fromString(SERVICE_BLE_HID.toString()))
- .addServiceUuid(ParcelUuid.fromString(SERVICE_BATTERY.toString()))
- .build();
-
- // set up scan result
- final AdvertiseData scanResult = new AdvertiseData.Builder()
- .addServiceUuid(ParcelUuid.fromString(SERVICE_DEVICE_INFORMATION.toString()))
- .addServiceUuid(ParcelUuid.fromString(SERVICE_BLE_HID.toString()))
- .addServiceUuid(ParcelUuid.fromString(SERVICE_BATTERY.toString()))
- .build();
-
- mBluetoothLeAdvertiser.startAdvertising(advertiseSettings, advertiseData, scanResult, mAdvertiseCallback);
- }
- });
- }
-
- /**
- * アドバタイジングを停止します.
- */
- private void stopAdvertising() {
- if (DEBUG) {
- Log.d(TAG, "stopAdvertising");
- }
-
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- try {
- mBluetoothLeAdvertiser.stopAdvertising(mAdvertiseCallback);
- } catch (final IllegalStateException ignored) {
- // BT Adapter is not turned ON
- if (DEBUG) {
- Log.d(TAG, "Failed to turn off advertising.", ignored);
- }
- }
-
- try {
- if (mTimer != null) {
- mTimer.cancel();
- mTimer = null;
- }
-
- if (mGattServer != null) {
- final Collection devices = getDevices();
- for (final BluetoothDevice device : devices) {
- mGattServer.cancelConnection(device);
- }
-
- mGattServer.clearServices();
- mGattServer.close();
- mGattServer = null;
- }
- } catch (final IllegalStateException ignored) {
- // do nothing
- if (DEBUG) {
- Log.d(TAG, "Failed to stop the gatt server.", ignored);
- }
- }
-
- mHandlerThread.quit();
- mHandlerThread = null;
- }
- });
- }
-
- /**
- * 接続中のデバイス一覧を取得します.
- *
- * @return the connected Bluetooth devices
- */
- public Set getDevices() {
- final Set deviceSet = new HashSet<>();
- synchronized (mBluetoothDevicesMap) {
- deviceSet.addAll(mBluetoothDevicesMap.values());
- }
- return Collections.unmodifiableSet(deviceSet);
- }
-
- /**
- * 指定されてBluetoothデバイスとペアリングを行います.
- * @param device ペアリングを行うBluetoothデバイス
- */
- private void paringDevice(final BluetoothDevice device) {
- if (DEBUG) {
- Log.i(TAG, "AbstractHOGPServer#paringDevice.");
- }
-
- mApplicationContext.registerReceiver(new BroadcastReceiver() {
- @Override
- public void onReceive(final Context context, final Intent intent) {
- final String action = intent.getAction();
- if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
- int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.ERROR);
- switch (state) {
- case BluetoothDevice.BOND_BONDING:
- if (DEBUG) {
- Log.e(TAG, "Bond bonding.");
- }
- break;
-
- case BluetoothDevice.BOND_BONDED:
- BluetoothDevice bondedDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
- if (!bondedDevice.getAddress().equals(device.getAddress())) {
- // 違うデバイスと接続された場合
- if (DEBUG) {
- Log.w(TAG, "Connected to a different device. device=" + bondedDevice);
- }
- return;
- }
-
- context.unregisterReceiver(this);
- connectDevice(device);
- break;
-
- default:
- if (DEBUG) {
- Log.e(TAG, "Bond error.");
- }
- context.unregisterReceiver(this);
- break;
- }
- }
- }
- }, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED));
-
- try {
- device.setPairingConfirmation(true);
- } catch (Exception e) {
- if (DEBUG) {
- Log.d(TAG, "Failed to set pairing confirmation.", e);
- }
- }
-
- device.createBond();
- }
-
- /**
- * 指定されたBluetoothデバイスと接続を行います.
- * @param device 接続を行うBluetoothデバイス
- */
- private void connectDevice(final BluetoothDevice device) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- if (mGattServer != null) {
- mGattServer.connect(device, true);
- }
- }
- });
-
- synchronized (mBluetoothDevicesMap) {
- mBluetoothDevicesMap.put(device.getAddress(), device);
- }
-
- if (mOnHOGPServerListener != null) {
- mOnHOGPServerListener.onConnected(device);
- }
- }
-
- /**
- * 指定されたBluetoothデバイスが切断された時の処理を行います.
- *
- * @param device 切断されたデバイス
- */
- private void disconnectDevice(final BluetoothDevice device) {
- synchronized (mBluetoothDevicesMap) {
- mBluetoothDevicesMap.remove(device.getAddress());
- }
-
- if (mOnHOGPServerListener != null) {
- mOnHOGPServerListener.onDisconnected(device);
- }
- }
-
- /**
- * アドバタイジング用のコールバック.
- *
- * 特に何も処理しません。
- *
- */
- private final AdvertiseCallback mAdvertiseCallback = new AdvertiseCallback() {};
-
- /**
- * BluetoothGattServerからの通知を受け取るコールバック.
- */
- private final BluetoothGattServerCallback mGattServerCallback = new BluetoothGattServerCallback() {
-
- @Override
- public void onConnectionStateChange(final BluetoothDevice device, final int status, final int newState) {
- if (DEBUG) {
- Log.d(TAG, "onConnectionStateChange status: " + status + ", newState: " + newState);
- }
-
- if (mGattServer == null) {
- return;
- }
-
- switch (newState) {
- case BluetoothProfile.STATE_CONNECTED:
- if (DEBUG) {
- Log.d(TAG, "BluetoothProfile.STATE_CONNECTED bondState: " + device.getBondState());
- }
-
- // check bond status
- if (device.getBondState() == BluetoothDevice.BOND_NONE) {
- paringDevice(device);
- } else if (device.getBondState() == BluetoothDevice.BOND_BONDED) {
- connectDevice(device);
- }
- break;
-
- case BluetoothProfile.STATE_DISCONNECTED:
- if (DEBUG) {
- Log.w(TAG, "BluetoothProfile.STATE_DISCONNECTED");
- }
- disconnectDevice(device);
- break;
-
- default:
- // do nothing
- break;
- }
- }
-
- @Override
- public void onCharacteristicReadRequest(final BluetoothDevice device, final int requestId, final int offset,
- final BluetoothGattCharacteristic characteristic) {
- if (DEBUG) {
- Log.d(TAG, "onCharacteristicReadRequest characteristic: " + characteristic.getUuid() + ", offset: " + offset);
- }
-
- if (mGattServer == null) {
- return;
- }
-
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- final UUID characteristicUuid = characteristic.getUuid();
- if (BleUuidUtils.matches(CHARACTERISTIC_HID_INFORMATION, characteristicUuid)) {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, RESPONSE_HID_INFORMATION);
- } else if (BleUuidUtils.matches(CHARACTERISTIC_REPORT_MAP, characteristicUuid)) {
- if (offset == 0) {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, getReportMap());
- } else {
- final int remainLength = getReportMap().length - offset;
- if (remainLength > 0) {
- final byte[] data = new byte[remainLength];
- System.arraycopy(getReportMap(), offset, data, 0, remainLength);
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, data);
- } else {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, null);
- }
- }
- } else if (BleUuidUtils.matches(CHARACTERISTIC_HID_CONTROL_POINT, characteristicUuid)) {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, new byte []{0});
- } else if (BleUuidUtils.matches(CHARACTERISTIC_REPORT, characteristicUuid)) {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, EMPTY_BYTES);
- } else if (BleUuidUtils.matches(CHARACTERISTIC_MANUFACTURER_NAME, characteristicUuid)) {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, mManufacturerName);
- } else if (BleUuidUtils.matches(CHARACTERISTIC_SERIAL_NUMBER, characteristicUuid)) {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, mSerialNumber);
- } else if (BleUuidUtils.matches(CHARACTERISTIC_MODEL_NUMBER, characteristicUuid)) {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, mDeviceName);
- } else if (BleUuidUtils.matches(CHARACTERISTIC_BATTERY_LEVEL, characteristicUuid)) {
- byte level = (byte) (BatteryUtils.getBatteryLevel(mApplicationContext) * 100);
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, new byte[] {level});
- } else {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, characteristic.getValue());
- }
- }
- });
- }
-
- @Override
- public void onDescriptorReadRequest(final BluetoothDevice device, final int requestId, final int offset,
- final BluetoothGattDescriptor descriptor) {
- if (DEBUG) {
- Log.d(TAG, "onDescriptorReadRequest requestId: " + requestId + ", offset: " + offset + ", descriptor: " + descriptor.getUuid());
- }
-
- if (mGattServer == null) {
- return;
- }
-
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- if (BleUuidUtils.matches(DESCRIPTOR_REPORT_REFERENCE, descriptor.getUuid())) {
- final int property = descriptor.getCharacteristic().getProperties();
- if (property == (BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_NOTIFY)) {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, new byte[]{0, 1});
- } else if (property == (BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE)) {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, new byte[]{0, 2});
- } else if (property == (BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_WRITE)) {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, new byte[]{0, 3});
- } else {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_FAILURE, 0, EMPTY_BYTES);
- }
- } else {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_FAILURE, 0, EMPTY_BYTES);
- }
- }
- });
- }
-
- @Override
- public void onCharacteristicWriteRequest(final BluetoothDevice device, final int requestId,
- final BluetoothGattCharacteristic characteristic,
- final boolean preparedWrite, final boolean responseNeeded,
- final int offset, final byte[] value) {
- if (DEBUG) {
- Log.d(TAG, "onCharacteristicWriteRequest characteristic: " + characteristic.getUuid() + ", value: " + Arrays.toString(value));
- }
-
- if (mGattServer == null) {
- return;
- }
-
- if (responseNeeded) {
- if (BleUuidUtils.matches(CHARACTERISTIC_REPORT, characteristic.getUuid())) {
- if (characteristic.getProperties() == (BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE)) {
- onOutputReport(value);
- }
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, EMPTY_BYTES);
- } else {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_FAILURE, 0, EMPTY_BYTES);
- }
- }
- }
-
- @Override
- public void onDescriptorWriteRequest(final BluetoothDevice device, final int requestId,
- final BluetoothGattDescriptor descriptor, final boolean preparedWrite,
- final boolean responseNeeded, final int offset, final byte[] value) {
- if (DEBUG) {
- Log.d(TAG, "onDescriptorWriteRequest descriptor: " + descriptor.getUuid() + ", value: " + Arrays.toString(value) + ", responseNeeded: " + responseNeeded + ", preparedWrite: " + preparedWrite);
- }
-
- if (mGattServer == null) {
- return;
- }
-
- descriptor.setValue(value);
-
- if (responseNeeded) {
- if (BleUuidUtils.matches(DESCRIPTOR_CLIENT_CHARACTERISTIC_CONFIGURATION, descriptor.getUuid())) {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, EMPTY_BYTES);
- } else {
- mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_FAILURE, 0, EMPTY_BYTES);
- }
- }
- }
-
- @Override
- public void onServiceAdded(final int status, final BluetoothGattService service) {
- if (DEBUG) {
- Log.d(TAG, "onServiceAdded status: " + status + ", service: " + service.getUuid());
- if (status != 0) {
- Log.d(TAG, "onServiceAdded Adding Service failed.");
- }
- }
- }
- };
-
- /**
- * HOGPServerにデバイスが接続・切断した時の通知を行うリスナー.
- */
- public interface OnHOGPServerListener {
- /**
- * デバイスが接続された時に呼び出すメソッド.
- * @param device 接続したデバイス
- */
- void onConnected(BluetoothDevice device);
-
- /**
- * デバイスが切断された時に呼び出すメソッド.
- * @param device 切断したデバイス
- */
- void onDisconnected(BluetoothDevice device);
- }
-
- /**
- * デバイスへのレポートを保持するクラス.
- */
- private class ReportHolder {
- /**
- * 送信先のBluetoothデバイス.
- */
- private BluetoothDevice mDevice;
-
- /**
- * 送信するレポート.
- */
- private byte[] mReport;
-
- /**
- * コンストラクタ.
- * @param device 送信先のデバイス
- * @param report 送信するレポート
- */
- ReportHolder(final BluetoothDevice device, final byte[] report) {
- mDevice = device;
- mReport = report;
- }
-
- /**
- * 送信先のBluetoothデバイスを取得します.
- * @return Bluetoothデバイス
- */
- BluetoothDevice getDevice() {
- return mDevice;
- }
-
- /**
- * 送信するレポートを取得します.
- * @return レポート
- */
- byte[] getReport() {
- return mReport;
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/server/HOGPServer.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/server/HOGPServer.java
deleted file mode 100644
index ddf89dc516..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/server/HOGPServer.java
+++ /dev/null
@@ -1,688 +0,0 @@
-/*
- HOGPServer.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.server;
-
-import android.bluetooth.BluetoothDevice;
-import android.content.Context;
-import android.util.Log;
-
-import org.deviceconnect.android.deviceplugin.hogp.BuildConfig;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.COLLECTION;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.END_COLLECTION;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.INPUT;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.LOGICAL_MAXIMUM;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.LOGICAL_MINIMUM;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.LSB;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.MSB;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.OUTPUT;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.PHYSICAL_MAXIMUM;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.PHYSICAL_MINIMUM;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.REPORT_COUNT;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.REPORT_ID;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.REPORT_SIZE;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.UNIT;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.USAGE;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.USAGE_MAXIMUM;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.USAGE_MINIMUM;
-import static org.deviceconnect.android.deviceplugin.hogp.util.HIDUtils.USAGE_PAGE;
-
-/**
- * HOGPサーバ.
- *
- * @author NTT DOCOMO, INC.
- */
-public class HOGPServer extends AbstractHOGPServer {
-
- /**
- * マウスモード.
- */
- public enum MouseMode {
- /**
- * マウス無し.
- */
- NONE(0),
-
- /**
- * マウスのRelative入力モード.
- */
- RELATIVE(1),
-
- /**
- * マウスのAbsolute入力モード.
- */
- ABSOLUTE(2);
-
- /**
- * モードの値.
- */
- private int mValue;
-
- /**
- * コンストラクタ.
- * @param value モードの値
- */
- MouseMode(final int value) {
- mValue = value;
- }
-
- /**
- * 指定された値に対応するモードを取得します.
- * @param value 値
- * @return マウスモード
- */
- public static MouseMode valueOf(final int value) {
- for (MouseMode mode : values()) {
- if (mode.getValue() == value) {
- return mode;
- }
- }
- return null;
- }
-
- /**
- * モードの値を取得します.
- * @return モードの値
- */
- public int getValue() {
- return mValue;
- }
- }
-
- /**
- * マウスのサイズ.
- */
- public static final int ABSOLUTE_MOUSE_SIZE = 32767;
-
-
- /**
- * マウスのレポートID.
- */
- private static byte REPORT_ID_MOUSE = 0x01;
-
- /**
- * ジョイスティックのレポートID.
- */
- private static byte REPORT_ID_JOYSTICK = 0x02;
-
- /**
- * キーボードのレポートID.
- */
- private static byte REPORT_ID_KEYBOARD = 0x03;
-
- /**
- * レポートの先頭につけるヘッダ.
- */
- private static final byte[] REPORT_MAP_HEADER = {
- USAGE_PAGE(1), 0x01, // Generic Desktop
- };
-
- /**
- * Relativeマウス用のレポート定義マップ.
- */
- private static final byte[] REPORT_MAP_RELATIVE_MOUSE = {
- USAGE(1), 0x02, // Mouse
- COLLECTION(1), 0x01, // Application
- REPORT_ID(1), REPORT_ID_MOUSE, // Report Id
- USAGE(1), 0x01, // Pointer
- COLLECTION(1), 0x00, // Physical
- USAGE_PAGE(1), 0x09, // Buttons
- USAGE_MINIMUM(1), 0x01,
- USAGE_MAXIMUM(1), 0x03,
- LOGICAL_MINIMUM(1), 0x00, // 0
- LOGICAL_MAXIMUM(1), 0x01, // 1
- REPORT_COUNT(1), 0x03, // 3 bits (Buttons)
- REPORT_SIZE(1), 0x01,
- INPUT(1), 0x02, // Data, Variable, Absolute
-
- REPORT_COUNT(1), 0x01, // 5 bits (Padding)
- REPORT_SIZE(1), 0x05,
- INPUT(1), 0x01, // Constant
-
- USAGE_PAGE(1), 0x01, // Generic Desktop
- USAGE(1), 0x30, // X
- USAGE(1), 0x31, // Y
- USAGE(1), 0x38, // Wheel
- LOGICAL_MINIMUM(1), (byte) 0x81, // -127
- LOGICAL_MAXIMUM(1), 0x7F, // 127
- REPORT_SIZE(1), 0x08, // 8 bits
- REPORT_COUNT(1), 0x03, // 3 x 8 bits = 3 bytes
- INPUT(1), 0x06, // Data, Variable, Relative
- END_COLLECTION(0),
- END_COLLECTION(0),
- };
-
- /**
- * Absoluteマウス用のレポート定義マップ.
- */
- private static final byte[] REPORT_MAP_ABSOLUTE_MOUSE = {
- USAGE(1), 0x02, // Mouse
- COLLECTION(1), 0x01, // Application
- REPORT_ID(1), REPORT_ID_MOUSE, // Report Id
- USAGE(1), 0x01, // Pointer
- COLLECTION(1), 0x00, // Physical
- USAGE_PAGE(1), 0x09, // Buttons
- USAGE_MINIMUM(1), 0x01,
- USAGE_MAXIMUM(1), 0x03,
- LOGICAL_MINIMUM(1), 0x00, // 0
- LOGICAL_MAXIMUM(1), 0x01, // 1
- REPORT_COUNT(1), 0x03, // 3 bits (Buttons)
- REPORT_SIZE(1), 0x01,
- INPUT(1), 0x02, // Data, Variable, Absolute
-
- REPORT_COUNT(1), 0x01, // 5 bits (Padding)
- REPORT_SIZE(1), 0x05,
- INPUT(1), 0x01, // Constant
-
- USAGE_PAGE(1), 0x01, // Generic Desktop
- USAGE(1), 0x30, // X
- USAGE(1), 0x31, // Y
- LOGICAL_MINIMUM(1), 0x00, // 0
- LOGICAL_MAXIMUM(2), (byte)0xFF, 0x7F, // 32767
- REPORT_SIZE(1), 0x10,
- REPORT_COUNT(1), 0x02,
- INPUT(1), 0x02, // Data, Variable, Absolute
-
- USAGE_PAGE(1), 0x01, // Generic Desktop
- USAGE(1), 0x38, // scroll
- LOGICAL_MINIMUM(1), (byte)0x81, // -127
- LOGICAL_MAXIMUM(1), 0x7f, // 127
- REPORT_SIZE(1), 0x08,
- REPORT_COUNT(1), 0x01,
- INPUT(1), 0x06, // Data, Variable, Relative
-
- END_COLLECTION(0),
- END_COLLECTION(0)
- };
-
- /**
- * ジョイスティック用のレポート定義マップ.
- */
- private static final byte[] REPORT_MAP_JOYSTICK = {
- USAGE(1), 0x04, // Joystick
- COLLECTION(1), 0x01, // Application
- COLLECTION(1), 0x00, // Physical
- REPORT_ID(1), REPORT_ID_JOYSTICK,
- USAGE_PAGE(1), 0x09, // Buttons
- USAGE_MINIMUM(1), 0x01,
- USAGE_MAXIMUM(1), 0x03,
- LOGICAL_MINIMUM(1), 0x00,
- LOGICAL_MAXIMUM(1), 0x01,
- REPORT_COUNT(1), 0x03, // 3 bits (Buttons)
- REPORT_SIZE(1), 0x01,
- INPUT(1), 0x02, // Data, Variable, Absolute
-
- REPORT_COUNT(1), 0x01, // 5 bits (Padding)
- REPORT_SIZE(1), 0x05,
- INPUT(1), 0x01, // Constant
-
- USAGE_PAGE(1), 0x01, // Generic Desktop
- UNIT(1), 0x14, // Unit (Degrees)
- USAGE(1), 0x30, // X
- USAGE(1), 0x31, // Y
- USAGE(1), 0x32, // Z
- USAGE(1), 0x33, // Rx
- USAGE(1), 0x34, // Ry
- USAGE(1), 0x35, // Rz
- LOGICAL_MINIMUM(1), (byte) 0x81, // -127
- LOGICAL_MAXIMUM(1), 0x7F, // 127
- PHYSICAL_MINIMUM(1),(byte) 0x81, // -127
- PHYSICAL_MAXIMUM(1),0x7F, // 127
- REPORT_SIZE(1), 0x08, // 8 bits
- REPORT_COUNT(1), 0x04, // 4 x 8 bits = 4 bytes
- INPUT(1), 0x02,
-
- END_COLLECTION(0),
- END_COLLECTION(0),
- };
-
- /**
- * キーボード用のレポート定義マップ.
- */
- private static final byte[] REPORT_MAP_KEYBOARD = {
- USAGE(1), 0x06, // Keyboard
- COLLECTION(1), 0x01, // Application
- USAGE_PAGE(1), 0x07, // keyboard/Keypad
- REPORT_ID(1), REPORT_ID_KEYBOARD, // Report Id
- USAGE_MINIMUM(1), (byte) 0xE0,
- USAGE_MAXIMUM(1), (byte) 0xE7,
- LOGICAL_MINIMUM(1), 0x00,
- LOGICAL_MAXIMUM(1), 0x01,
- REPORT_SIZE(1), 0x01, // 1 byte (Modifier)
- REPORT_COUNT(1), 0x08,
- INPUT(1), 0x02, // Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position
-
- REPORT_COUNT(1), 0x01, // 1 byte (Reserved)
- REPORT_SIZE(1), 0x08,
- INPUT(1), 0x01, // Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position
-
- REPORT_COUNT(1), 0x05, // 5 bits (Num lock, Caps lock, Scroll lock, Compose, Kana)
- REPORT_SIZE(1), 0x01,
- USAGE_PAGE(1), 0x08, // LEDs
- USAGE_MINIMUM(1), 0x01, // Num Lock
- USAGE_MAXIMUM(1), 0x05, // Kana
- OUTPUT(1), 0x02, // Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile
-
- REPORT_COUNT(1), 0x01, // 3 bits (Padding)
- REPORT_SIZE(1), 0x03,
- OUTPUT(1), 0x01, // Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile
-
- REPORT_COUNT(1), 0x06, // 6 bytes (Keys)
- REPORT_SIZE(1), 0x08,
- LOGICAL_MINIMUM(1), 0x00,
- LOGICAL_MAXIMUM(1), (byte) 0xFF, // 255 keys
- USAGE_PAGE(1), 0x07, // keyboard/Keypad
- USAGE_MINIMUM(1), 0x00,
- USAGE_MAXIMUM(1), 0x65,
- INPUT(1), 0x00, // Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position
-
- END_COLLECTION(0),
- };
-
- /**
- * 空のレポート.
- */
- private static final byte[] EMPTY_REPORT = new byte[9];
-
- /**
- * 前回送ったマウス用レポート.
- */
- private byte[] mLastMouseReport = new byte[5];
-
- // 初期化
- static {
- EMPTY_REPORT[0] = REPORT_ID_KEYBOARD;
- }
-
- /**
- * マウスモード.
- */
- private MouseMode mMouseMode = MouseMode.NONE;
-
- /**
- * キーボードフラグ.
- */
- private boolean mKeyboard;
-
- /**
- * ジョイスティックフラグ.
- */
- private boolean mJoystick;
-
- /**
- * コンストラクタ.
- * @param context このクラスが属するコンテキスト
- * @param mode マウスモード
- * @param keyboard キーボードの有効・無効
- * @param joystick ジョイスティックの有効・無効
- */
- public HOGPServer(final Context context, final MouseMode mode, final boolean keyboard, final boolean joystick) {
- super(context);
-
- mMouseMode = mode;
- mKeyboard = keyboard;
- mJoystick = joystick;
- }
-
- @Override
- byte[] getReportMap() {
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- out.write(REPORT_MAP_HEADER);
-
- switch (mMouseMode) {
- case RELATIVE:
- out.write(REPORT_MAP_RELATIVE_MOUSE);
- break;
- case ABSOLUTE:
- out.write(REPORT_MAP_ABSOLUTE_MOUSE);
- break;
- }
-
- if (mJoystick) {
- out.write(REPORT_MAP_JOYSTICK);
- }
-
- if (mKeyboard) {
- out.write(REPORT_MAP_KEYBOARD);
- }
-
- return out.toByteArray();
- } catch (IOException e) {
- if (BuildConfig.DEBUG) {
- Log.e("HOGP", "Failed to write report map.", e);
- }
- return null;
- }
- }
-
- @Override
- void onOutputReport(final byte[] outputReport) {
- if (BuildConfig.DEBUG) {
- String t = "";
- for (byte report : outputReport) {
- t += String.format("%02x", report);
- }
- Log.i("HOGP", t);
- }
- }
-
- /**
- * マウスの入力モードを取得します.
- * @return マウスの入力モード
- */
- public MouseMode getMouseMode() {
- return mMouseMode;
- }
-
- /**
- * 指定された配列が0で埋め尽くされているか確認します.
- * @param array 配列
- * @return 全ての要素が0の場合はtrue、それ以外はfalse
- */
- private boolean isZero(final byte[] array) {
- for (int i = 1; i < array.length; i++) {
- if (array[i] != 0) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Mouseのレポートを送信します.
- *
- * deviceがnullの場合には、全てのデバイスに対して送信します.
- *
- * @param device 送信するBluetoothDevice
- * @param dx X座標の移動量 (-1 〜 1)
- * @param dy Y座標の移動量 (-1 〜 1)
- * @param wheel wheelの移動量 (-1 〜 1)
- * @param leftButton 左ボタンが押下されている場合はtrue
- * @param rightButton 右ボタンが押下されている場合はtrue
- * @param middleButton 真ん中ボタンが押下されている場合はtrue
- */
- public void movePointer(final BluetoothDevice device, float dx, float dy, float wheel, final boolean leftButton, final boolean rightButton, final boolean middleButton) {
- switch (mMouseMode) {
- case RELATIVE: {
- int x = (int) (127 * dx);
- int y = (int) (127 * dy);
- int w = (int) (127 * wheel);
- moveRelativePointer(device, x, y, w, leftButton, rightButton, middleButton);
- } break;
- case ABSOLUTE: {
- int x = (int) (ABSOLUTE_MOUSE_SIZE * dx);
- int y = (int) (ABSOLUTE_MOUSE_SIZE * dy);
- int w = (int) (127 * wheel);
- moveAbsolutePointer(device, x, y, w, leftButton, rightButton, middleButton);
- } break;
- }
- }
-
- /**
- * Mouseのレポートを送信します.
- *
- * 接続されている全デバイスにレポートを送信します。
- *
- * @param dx X座標の移動量 (-127 〜 127)
- * @param dy Y座標の移動量 (-127 〜 127)
- * @param wheel wheelの移動量 (-127 〜 127)
- * @param leftButton 左ボタンが押下されている場合はtrue
- * @param rightButton 右ボタンが押下されている場合はtrue
- * @param middleButton 真ん中ボタンが押下されている場合はtrue
- */
- public void movePointer(int dx, int dy, int wheel, final boolean leftButton, final boolean rightButton, final boolean middleButton) {
- movePointer(null, dx, dy, wheel, leftButton, rightButton, middleButton);
- }
-
- /**
- * Mouseのレポートを送信します.
- *
- * deviceがnullの場合には、全てのデバイスに対して送信します.
- *
- * @param device 送信するBluetoothDevice
- * @param dx X座標の移動量 (-127 〜 127)
- * @param dy Y座標の移動量 (-127 〜 127)
- * @param wheel wheelの移動量 (-127 〜 127)
- * @param leftButton 左ボタンが押下されている場合はtrue
- * @param rightButton 右ボタンが押下されている場合はtrue
- * @param middleButton 真ん中ボタンが押下されている場合はtrue
- */
- public void movePointer(final BluetoothDevice device, int dx, int dy, int wheel, final boolean leftButton, final boolean rightButton, final boolean middleButton) {
- switch (mMouseMode) {
- case RELATIVE:
- moveRelativePointer(device, dx, dy, wheel, leftButton, rightButton, middleButton);
- break;
- case ABSOLUTE:
- moveAbsolutePointer(device, dx, dy, wheel, leftButton, rightButton, middleButton);
- break;
- }
- }
-
- /**
- * Relative入力モードのMouseレポートを送信します.
- *
- * deviceがnullの場合には、全てのデバイスに対して送信します.
- *
- * @param device 送信するBluetoothDevice
- * @param dx X座標の移動量 (-127 〜 127)
- * @param dy Y座標の移動量 (-127 〜 127)
- * @param wheel wheelの移動量 (-127 〜 127)
- * @param leftButton 左ボタンが押下されている場合はtrue
- * @param rightButton 右ボタンが押下されている場合はtrue
- * @param middleButton 真ん中ボタンが押下されている場合はtrue
- */
- private void moveRelativePointer(final BluetoothDevice device, int dx, int dy, int wheel, final boolean leftButton, final boolean rightButton, final boolean middleButton) {
- if (dx > 127) dx = 127;
- if (dx < -127) dx = -127;
- if (dy > 127) dy = 127;
- if (dy < -127) dy = -127;
- if (wheel > 127) wheel = 127;
- if (wheel < -127) wheel = -127;
-
- byte button = 0;
- if (leftButton) {
- button |= 1;
- }
- if (rightButton) {
- button |= 2;
- }
- if (middleButton) {
- button |= 4;
- }
-
- final byte[] report = new byte[5];
- report[0] = REPORT_ID_MOUSE;
- report[1] = (byte) (button & 7);
- report[2] = (byte) dx;
- report[3] = (byte) dy;
- report[4] = (byte) wheel;
-
- if (isZero(mLastMouseReport) && isZero(report)) {
- return;
- }
-
- addInputReport(device, report);
-
- mLastMouseReport[0] = report[0];
- mLastMouseReport[1] = report[1];
- mLastMouseReport[2] = report[2];
- mLastMouseReport[3] = report[3];
- mLastMouseReport[4] = report[4];
- }
-
- /**
- * Absolute入力モードのMouseレポートを送信します.
- *
- * deviceがnullの場合には、全てのデバイスに対して送信します.
- *
- * @param device 送信するBluetoothDevice
- * @param dx X座標の移動量 (-127 〜 127)
- * @param dy Y座標の移動量 (-127 〜 127)
- * @param wheel wheelの移動量 (-127 〜 127)
- * @param leftButton 左ボタンが押下されている場合はtrue
- * @param rightButton 右ボタンが押下されている場合はtrue
- * @param middleButton 真ん中ボタンが押下されている場合はtrue
- */
- private void moveAbsolutePointer(final BluetoothDevice device, int dx, int dy, int wheel, final boolean leftButton, final boolean rightButton, final boolean middleButton) {
- if (dx > ABSOLUTE_MOUSE_SIZE) dx = ABSOLUTE_MOUSE_SIZE;
- if (dx < 0) dx = 0;
- if (dy > ABSOLUTE_MOUSE_SIZE) dy = ABSOLUTE_MOUSE_SIZE;
- if (dy < 0) dy = 0;
- if (wheel > 127) wheel = 127;
- if (wheel < -127) wheel = -127;
-
- byte button = 0;
- if (leftButton) {
- button |= 1;
- }
- if (rightButton) {
- button |= 2;
- }
- if (middleButton) {
- button |= 4;
- }
-
- final byte[] report = new byte[7];
- report[0] = REPORT_ID_MOUSE;
- report[1] = (byte) (button & 7);
- report[2] = LSB(dx);
- report[3] = MSB(dx);
- report[4] = LSB(dy);
- report[5] = MSB(dy);
- report[6] = (byte) wheel;
-
- addInputReport(device, report);
- }
-
-
- /**
- * キーダウンのレポートを送信します.
- *
- * @param modifier モディファイアキー
- * @param keyCode キーコード
- */
- public void sendKeyDown(final byte modifier, final byte keyCode) {
- sendKeyDown(null, modifier, keyCode);
- }
-
- /**
- * キーダウンのレポートを送信します.
- *
- * deviceがnullの場合には、全てのデバイスに対して送信します.
- *
- * @param device 送信するBluetoothDevice
- * @param modifier モディファイアキー
- * @param keyCode キーコード
- */
- public void sendKeyDown(final BluetoothDevice device, final byte modifier, final byte keyCode) {
- final byte[] report = new byte[9];
- report[0] = REPORT_ID_KEYBOARD;
- report[1] = modifier;
- report[2] = 0x00; // Reserved
- report[3] = keyCode;
- addInputReport(device, report);
- }
-
- /**
- * キーダウンのレポートを送信します.
- *
- * @param modifier モディファイアキー
- * @param keyCode キーコード
- */
- public void sendKeyDown(final byte modifier, final byte[] keyCode) {
- sendKeyDown(null, modifier, keyCode);
- }
-
- /**
- * キーダウンのレポートを送信します.
- *
- * deviceがnullの場合には、全てのデバイスに対して送信します.
- *
- * @param device 送信するBluetoothDevice
- * @param modifier モディファイアキー
- * @param keyCode キーコード
- */
- public void sendKeyDown(final BluetoothDevice device, final byte modifier, final byte[] keyCode) {
- final byte[] report = new byte[9];
- report[0] = REPORT_ID_KEYBOARD;
- report[1] = modifier;
- report[2] = 0x00; // Reserved
- for (int i = 0; i < keyCode.length && 3 + i < report.length; i++) {
- report[3 + i] = keyCode[i];
- }
- addInputReport(device, report);
- }
-
- /**
- * キーアップのレポートを送信します.
- */
- public void sendKeyUp() {
- sendKeyUp(null);
- }
-
- /**
- * キーアップのレポートを送信します.
- *
- * deviceがnullの場合には、全てのデバイスに対して送信します.
- *
- * @param device 送信するBluetoothDevice
- */
- public void sendKeyUp(final BluetoothDevice device) {
- addInputReport(device, EMPTY_REPORT);
- }
-
- /**
- * ジョイスティックのレポートを送信します.
- * @param dx x軸への移動量
- * @param dy y軸への移動量
- * @param dz z軸への移動量
- * @param rx x軸の回転量
- * @param ry y軸の回転量
- * @param rz z軸の回転量
- */
- public void sendJoystick(int dx, int dy, int dz, int rx, int ry, int rz) {
- sendJoystick(null, dx, dy, dz, rx, ry, rz);
- }
-
- /**
- * ジョイスティックのレポートを送信します.
- *
- * deviceがnullの場合には、全てのデバイスに対して送信します.
- *
- * @param device 送信するBluetoothDevice
- * @param dx x軸への移動量
- * @param dy y軸への移動量
- * @param dz z軸への移動量
- * @param rx x軸の回転量
- * @param ry y軸の回転量
- * @param rz z軸の回転量
- */
- public void sendJoystick(final BluetoothDevice device, int dx, int dy, int dz, int rx, int ry, int rz) {
- if (dx > 127) dx = 127;
- if (dx < -127) dx = -127;
- if (dy > 127) dy = 127;
- if (dy < -127) dy = -127;
- if (dz > 127) dz = 127;
- if (dz < -127) dz = -127;
-
- final byte[] report = new byte[8];
- report[0] = REPORT_ID_JOYSTICK;
- report[1] = 0x00;
- report[2] = (byte) dx;
- report[3] = (byte) dy;
- report[4] = (byte) dz;
- report[5] = (byte) rx;
- report[6] = (byte) ry;
- report[7] = (byte) rz;
-
- addInputReport(device, report);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/BatteryUtils.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/BatteryUtils.java
deleted file mode 100644
index 69dc2de933..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/BatteryUtils.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- BatteryUtils.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.util;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.BatteryManager;
-
-/**
- * バッテリーの残量を取得するためのユーティリティクラス.
- *
- * @author NTT DOCOMO, INC.
- */
-public final class BatteryUtils {
-
- private BatteryUtils() {}
-
- /**
- * バッテリーの残量を取得します.
- * @param context コンテキスト
- * @return バッテリーの残量
- */
- public static float getBatteryLevel(final Context context) {
- IntentFilter intentfilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
- Intent batteryStatus = context.registerReceiver(null, intentfilter);
- if (batteryStatus == null) {
- return 0.0f;
- } else {
- int batteryLevel = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
- int bsc = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
- return batteryLevel / (float) bsc;
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/BleUtils.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/BleUtils.java
deleted file mode 100755
index e637581931..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/BleUtils.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- BleUtils.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.util;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothManager;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.Build;
-
-import androidx.annotation.NonNull;
-
-/**
- * BLEを操作するためのユーティリティクラス.
- *
- * @author NTT DOCOMO, INC.
- */
-public class BleUtils {
-
- /**
- * BLEがサポートされているか確認します.
- *
- * @param context このアプリケーションが属するコンテキスト
- * @return サポートされている場合はtrue、それ以外はfalse
- */
- public static boolean isBleSupported(@NonNull final Context context) {
- try {
- return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 &&
- context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) &&
- getAdapter(context) != null;
- } catch (final Throwable ignored) {
- // ignore exception
- }
- return false;
- }
-
- /**
- * BLEペリフェラルがサポートされているか確認を行います.
- *
- * @param context このアプリケーションが属するコンテキスト
- * @return サポートされている場合はtrue、それ以外はfalse
- */
- @SuppressLint("NewApi")
- public static boolean isBlePeripheralSupported(@NonNull final Context context) {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
- return false;
- }
-
- BluetoothAdapter bluetoothAdapter = getAdapter(context);
- return bluetoothAdapter != null && bluetoothAdapter.isMultipleAdvertisementSupported();
- }
-
- /**
- * Bluetooth設定が有効になっているか確認を行います.
- *
- * @param context このアプリケーションが属するコンテキスト
- * @return Bluetoothが有効になっている場合はtrue
- */
- public static boolean isBluetoothEnabled(@NonNull final Context context) {
- BluetoothAdapter bluetoothAdapter = getAdapter(context);
- return bluetoothAdapter != null && bluetoothAdapter.isEnabled();
- }
-
- /**
- * Bluetoothの名前を取得します.
- * @param context このアプリケーションが属するコンテキスト
- * @return Bluetoothの名前、名前が取得できない場合はnullを返却します。
- */
- public static String getBluetoothName(@NonNull final Context context) {
- BluetoothAdapter bluetoothAdapter = getAdapter(context);
- return bluetoothAdapter != null ? bluetoothAdapter.getName() : null;
- }
-
- /**
- * BluetoothAdapterをAndroid OS別に取得します.
- * @param context このアプリケーションが属するコンテキスト
- * @return BluetoothAdapterのインスタンス
- */
- private static BluetoothAdapter getAdapter(final Context context) {
- BluetoothAdapter bluetoothAdapter;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- BluetoothManager bluetoothManager = (BluetoothManager) context.
- getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE);
- if (bluetoothManager == null) {
- return null;
- }
- bluetoothAdapter = bluetoothManager.getAdapter();
- } else {
- bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
- }
- return bluetoothAdapter;
- }
-
- /**
- * Bluetooth有効リクエストコード.
- */
- public static final int REQUEST_CODE_BLUETOOTH_ENABLE = 0xb1e;
-
- /**
- * Bluetoothを有効要求を行います.
- *
- * 引数に渡されたActivityにonActivityResultを実装して、REQUEST_CODE_BLUETOOTH_ENABLEのリクエストコードに対する応答の処理を実装します。
- *
- * @param activity the activity
- */
- public static void enableBluetooth(@NonNull final Activity activity) {
- activity.startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_CODE_BLUETOOTH_ENABLE);
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/BleUuidUtils.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/BleUuidUtils.java
deleted file mode 100755
index 74a7eedee6..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/BleUuidUtils.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- BleUuidUtils.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.util;
-
-import android.os.ParcelUuid;
-
-import androidx.annotation.NonNull;
-
-import java.util.UUID;
-
-/**
- * BLE UUIDの扱うためのユーティリティクラス.
- *
- * @author NTT DOCOMO, INC.
- */
-public final class BleUuidUtils {
-
- private static final String UUID_LONG_STYLE_PREFIX = "0000";
- private static final String UUID_LONG_STYLE_POSTFIX = "-0000-1000-8000-00805F9B34FB";
-
- /**
- * 格納できる最大文字列数.
- */
- public static final int DEVICE_INFO_MAX_LENGTH = 20;
-
- /**
- * Device Information サービス.
- *
- * @see Device Information サービス
- */
- public static final UUID SERVICE_DEVICE_INFORMATION = BleUuidUtils.fromShortValue(0x180A);
-
- /**
- * Manufacturer名を格納するキャラクタリスティック.
- */
- public static final UUID CHARACTERISTIC_MANUFACTURER_NAME = BleUuidUtils.fromShortValue(0x2A29);
-
- /**
- * モデル名を格納するキャラクタリスティック.
- */
- public static final UUID CHARACTERISTIC_MODEL_NUMBER = BleUuidUtils.fromShortValue(0x2A24);
-
- /**
- * シリアルナンバーを格納するキャラクタリスティック.
- */
- public static final UUID CHARACTERISTIC_SERIAL_NUMBER = BleUuidUtils.fromShortValue(0x2A25);
-
- /**
- * Battery サービス.
- *
- * @see Device Information サービス
- */
- public static final UUID SERVICE_BATTERY = BleUuidUtils.fromShortValue(0x180F);
-
- /**
- * バッテリー残量を格納するキャラクタリスティック.
- */
- public static final UUID CHARACTERISTIC_BATTERY_LEVEL = BleUuidUtils.fromShortValue(0x2A19);
-
- /**
- * HID サービス.
- *
- * @see Device Information サービス
- */
- public static final UUID SERVICE_BLE_HID = BleUuidUtils.fromShortValue(0x1812);
-
- /**
- * HIDの情報を格納するキャラクタリスティック.
- */
- public static final UUID CHARACTERISTIC_HID_INFORMATION = BleUuidUtils.fromShortValue(0x2A4A);
-
- /**
- * レポートマップを格納するキャラクタリスティック.
- */
- public static final UUID CHARACTERISTIC_REPORT_MAP = BleUuidUtils.fromShortValue(0x2A4B);
-
- /**
- * コントロールポイントを格納するキャラクタリスティック.
- */
- public static final UUID CHARACTERISTIC_HID_CONTROL_POINT = BleUuidUtils.fromShortValue(0x2A4C);
-
- /**
- * レポートを格納するキャラクタリスティック.
- */
- public static final UUID CHARACTERISTIC_REPORT = BleUuidUtils.fromShortValue(0x2A4D);
-
- /**
- * プロトコルモードを格納するキャラクタリスティック.
- */
- public static final UUID CHARACTERISTIC_PROTOCOL_MODE = BleUuidUtils.fromShortValue(0x2A4E);
-
- /**
- * Gatt Characteristic Descriptor.
- */
- public static final UUID DESCRIPTOR_REPORT_REFERENCE = BleUuidUtils.fromShortValue(0x2908);
- public static final UUID DESCRIPTOR_CLIENT_CHARACTERISTIC_CONFIGURATION = BleUuidUtils.fromShortValue(0x2902);
-
- private BleUuidUtils() {
- }
-
- /**
- * Parses a UUID string with the format defined by toString().
- *
- * @param uuidString the UUID string to parse.
- * @return an UUID instance.
- * @throws NullPointerException if uuid is null.
- * @throws IllegalArgumentException if uuid is not formatted correctly.
- */
- @NonNull
- public static UUID fromString(@NonNull final String uuidString) {
- try {
- return UUID.fromString(uuidString);
- } catch (IllegalArgumentException e) {
- // may be a short style
- return UUID.fromString(UUID_LONG_STYLE_PREFIX + uuidString + UUID_LONG_STYLE_POSTFIX);
- }
- }
-
- /**
- * Obtains a UUID from Short style value.
- *
- * @param uuidShortValue the Short style UUID value.
- * @return an UUID instance.
- */
- @NonNull
- public static UUID fromShortValue(final int uuidShortValue) {
- return UUID.fromString(UUID_LONG_STYLE_PREFIX + String.format("%04X", uuidShortValue & 0xffff) + UUID_LONG_STYLE_POSTFIX);
- }
-
- /**
- * Obtains a ParcelUuid from Short style value.
- *
- * @param uuidShortValue the Short style UUID value.
- * @return an UUID instance.
- */
- @NonNull
- public static ParcelUuid parcelFromShortValue(final int uuidShortValue) {
- return ParcelUuid.fromString(UUID_LONG_STYLE_PREFIX + String.format("%04X", uuidShortValue & 0xffff) + UUID_LONG_STYLE_POSTFIX);
- }
-
- /**
- * UUID to short style value
- *
- * @param uuid the UUID
- * @return short style value, -1 if the specified UUID is not short style
- */
- public static int toShortValue(@NonNull final UUID uuid) {
- return (int)(uuid.getMostSignificantBits() >> 32 & 0xffff);
- }
-
- /**
- * check if full style or short (16bits) style UUID matches
- *
- * @param src the UUID to be compared
- * @param dst the UUID to be compared
- * @return true if the both of UUIDs matches
- */
- public static boolean matches(@NonNull final UUID src, @NonNull final UUID dst) {
- if (isShortUuid(src) || isShortUuid(dst)) {
- // at least one instance is short style: check only 16bits
- final long srcShortUUID = src.getMostSignificantBits() & 0x0000ffff00000000L;
- final long dstShortUUID = dst.getMostSignificantBits() & 0x0000ffff00000000L;
- return srcShortUUID == dstShortUUID;
- } else {
- return src.equals(dst);
- }
- }
-
- /**
- * Check if the specified UUID style is short style.
- *
- * @param src the UUID
- * @return true if the UUID is short style
- */
- private static boolean isShortUuid(@NonNull final UUID src) {
- return (src.getMostSignificantBits() & 0xffff0000ffffffffL) == 0L && src.getLeastSignificantBits() == 0L;
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/HIDUtils.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/HIDUtils.java
deleted file mode 100644
index 46c3c50b25..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/HIDUtils.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- HIDUtils.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.util;
-
-/**
- * HIDのレポートマップを作成するためのユーティリティクラス.
- *
- * @author NTT DOCOMO, INC.
- */
-public final class HIDUtils {
-
- private HIDUtils() {
- }
-
- public static byte INPUT(final int size) {
- return (byte) (0x80 | size);
- }
-
- public static byte OUTPUT(final int size) {
- return (byte) (0x90 | size);
- }
-
- public static byte COLLECTION(final int size) {
- return (byte) (0xA0 | size);
- }
-
- public static byte FEATURE(final int size) {
- return (byte) (0xB0 | size);
- }
-
- public static byte END_COLLECTION(final int size) {
- return (byte) (0xC0 | size);
- }
-
- public static byte USAGE_PAGE(final int size) {
- return (byte) (0x04 | size);
- }
-
- public static byte LOGICAL_MINIMUM(final int size) {
- return (byte) (0x14 | size);
- }
-
- public static byte LOGICAL_MAXIMUM(final int size) {
- return (byte) (0x24 | size);
- }
-
- public static byte PHYSICAL_MINIMUM(final int size) {
- return (byte) (0x34 | size);
- }
-
- public static byte PHYSICAL_MAXIMUM(final int size) {
- return (byte) (0x44 | size);
- }
-
- public static byte UNIT_EXPONENT(final int size) {
- return (byte) (0x54 | size);
- }
-
- public static byte UNIT(final int size) {
- return (byte) (0x64 | size);
- }
-
- public static byte REPORT_SIZE(final int size) {
- return (byte) (0x74 | size);
- }
-
- public static byte REPORT_ID(final int size) {
- return (byte) (0x84 | size);
- }
-
- public static byte REPORT_COUNT(final int size) {
- return (byte) (0x94 | size);
- }
-
- public static byte USAGE(final int size) {
- return (byte) (0x08 | size);
- }
-
- public static byte USAGE_MINIMUM(final int size) {
- return (byte) (0x18 | size);
- }
-
- public static byte USAGE_MAXIMUM(final int size) {
- return (byte) (0x28 | size);
- }
-
- public static byte LSB(final int value) {
- return (byte) (value & 0xff);
- }
-
- public static byte MSB(final int value) {
- return (byte) (value >> 8 & 0xff);
- }
-
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/KeyboardCode.java b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/KeyboardCode.java
deleted file mode 100644
index 29ec0df2a3..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/java/org/deviceconnect/android/deviceplugin/hogp/util/KeyboardCode.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- KeyboardCode.java
- Copyright (c) 2017 NTT DOCOMO,INC.
- Released under the MIT license
- http://opensource.org/licenses/mit-license.php
- */
-package org.deviceconnect.android.deviceplugin.hogp.util;
-
-/**
- * キーボードのキーコードを扱うユーティリティクラス.
- *
- * @author NTT DOCOMO, INC.
- */
-public final class KeyboardCode {
- /**
- * モディファイアーキー無し.
- */
- public static final int MODIFIER_KEY_NONE = 0;
-
- /**
- * CTRLキー.
- */
- public static final int MODIFIER_KEY_CTRL = 1;
-
- /**
- * SHIFTキー.
- */
- public static final int MODIFIER_KEY_SHIFT = 2;
-
- /**
- * ALTキー(オプションキー).
- */
- public static final int MODIFIER_KEY_ALT = 4;
-
- /**
- * GUIキー(Windowsキー・コマンドキー).
- */
- public static final int MODIFIER_KEY_GUI = 8;
-
- public static final int KEY_F1 = 0x3a;
- public static final int KEY_F2 = 0x3b;
- public static final int KEY_F3 = 0x3c;
- public static final int KEY_F4 = 0x3d;
- public static final int KEY_F5 = 0x3e;
- public static final int KEY_F6 = 0x3f;
- public static final int KEY_F7 = 0x40;
- public static final int KEY_F8 = 0x41;
- public static final int KEY_F9 = 0x42;
- public static final int KEY_F10 = 0x43;
- public static final int KEY_F11 = 0x44;
- public static final int KEY_F12 = 0x45;
-
- public static final int KEY_PRINT_SCREEN = 0x46;
- public static final int KEY_SCROLL_LOCK = 0x47;
- public static final int KEY_CAPS_LOCK = 0x39;
- public static final int KEY_NUM_LOCK = 0x53;
- public static final int KEY_INSERT = 0x49;
- public static final int KEY_HOME = 0x4a;
- public static final int KEY_PAGE_UP = 0x4b;
- public static final int KEY_PAGE_DOWN = 0x4e;
-
- /**
- * 右矢印キー.
- */
- public static final byte KEY_RIGHT_ARROW = 0x4f;
-
- /**
- * 左矢印キー.
- */
- public static final byte KEY_LEFT_ARROW = 0x50;
-
- /**
- * 下矢印キー.
- */
- public static final byte KEY_DOWN_ARROW = 0x51;
-
- /**
- * 上矢印キー.
- */
- public static final byte KEY_UP_ARROW = 0x52;
-
- /**
- * エンターキー.
- */
- public static final byte KEY_ENTER = 0x28;
-
- /**
- * エスケープキー.
- */
- public static final byte KEY_ESC = 0x29;
-
- /**
- * 削除キー.
- */
- public static final byte KEY_DEL = 0x2A;
-
- private KeyboardCode() {}
-
- /**
- * 指定された文字からモディファイアーキーを取得します.
- *
- * @param aChar String contains one character
- * @return modifier code
- */
- public static byte modifier(final String aChar) {
- switch (aChar) {
- case "A":
- case "B":
- case "C":
- case "D":
- case "E":
- case "F":
- case "G":
- case "H":
- case "I":
- case "J":
- case "K":
- case "L":
- case "M":
- case "N":
- case "O":
- case "P":
- case "Q":
- case "R":
- case "S":
- case "T":
- case "U":
- case "V":
- case "W":
- case "X":
- case "Y":
- case "Z":
- case "!":
- case "@":
- case "#":
- case "$":
- case "%":
- case "^":
- case "&":
- case "*":
- case "(":
- case ")":
- case "_":
- case "+":
- case "{":
- case "}":
- case "|":
- case ":":
- case "\"":
- case "~":
- case "<":
- case ">":
- case "?":
- return MODIFIER_KEY_SHIFT;
- default:
- return 0;
- }
- }
-
- /**
- * 指定された文字からキーコードを取得します.
- *
- * @param aChar String contains one character
- * @return keyCode
- */
- public static byte keyCode(final String aChar) {
- switch (aChar) {
- case "A":
- case "a":
- return 0x04;
- case "B":
- case "b":
- return 0x05;
- case "C":
- case "c":
- return 0x06;
- case "D":
- case "d":
- return 0x07;
- case "E":
- case "e":
- return 0x08;
- case "F":
- case "f":
- return 0x09;
- case "G":
- case "g":
- return 0x0a;
- case "H":
- case "h":
- return 0x0b;
- case "I":
- case "i":
- return 0x0c;
- case "J":
- case "j":
- return 0x0d;
- case "K":
- case "k":
- return 0x0e;
- case "L":
- case "l":
- return 0x0f;
- case "M":
- case "m":
- return 0x10;
- case "N":
- case "n":
- return 0x11;
- case "O":
- case "o":
- return 0x12;
- case "P":
- case "p":
- return 0x13;
- case "Q":
- case "q":
- return 0x14;
- case "R":
- case "r":
- return 0x15;
- case "S":
- case "s":
- return 0x16;
- case "T":
- case "t":
- return 0x17;
- case "U":
- case "u":
- return 0x18;
- case "V":
- case "v":
- return 0x19;
- case "W":
- case "w":
- return 0x1a;
- case "X":
- case "x":
- return 0x1b;
- case "Y":
- case "y":
- return 0x1c;
- case "Z":
- case "z":
- return 0x1d;
- case "!":
- case "1":
- return 0x1e;
- case "@":
- case "2":
- return 0x1f;
- case "#":
- case "3":
- return 0x20;
- case "$":
- case "4":
- return 0x21;
- case "%":
- case "5":
- return 0x22;
- case "^":
- case "6":
- return 0x23;
- case "&":
- case "7":
- return 0x24;
- case "*":
- case "8":
- return 0x25;
- case "(":
- case "9":
- return 0x26;
- case ")":
- case "0":
- return 0x27;
- case "\n": // LF
- return 0x28;
- case "\b": // BS
- return 0x2a;
- case "\t": // TAB
- return 0x2b;
- case " ":
- return 0x2c;
- case "_":
- case "-":
- return 0x2d;
- case "+":
- case "=":
- return 0x2e;
- case "{":
- case "[":
- return 0x2f;
- case "}":
- case "]":
- return 0x30;
- case "|":
- case "\\":
- return 0x31;
- case ":":
- case ";":
- return 0x33;
- case "\"":
- case "'":
- return 0x34;
- case "~":
- case "`":
- return 0x35;
- case "<":
- case ",":
- return 0x36;
- case ">":
- case ".":
- return 0x37;
- case "?":
- case "/":
- return 0x38;
- default:
- return 0;
- }
- }
-}
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-hdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index 5e08b85c26..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-mdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index 5a49c184b9..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/hogp_help01.png b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/hogp_help01.png
deleted file mode 100644
index e0a6f26bb1..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/hogp_help01.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/hogp_help02_1.png b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/hogp_help02_1.png
deleted file mode 100644
index 4d3f9833dd..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/hogp_help02_1.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/hogp_help02_2.png b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/hogp_help02_2.png
deleted file mode 100644
index 842e2dd3e0..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/hogp_help02_2.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/hogp_help03.png b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/hogp_help03.png
deleted file mode 100644
index 4e5e53fdfe..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/hogp_help03.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index 785658e4ce..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xxhdpi/ic_launcher.png b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100644
index 50e7b09560..0000000000
Binary files a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable/hogp_button_blue.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable/hogp_button_blue.xml
deleted file mode 100644
index 9f2b0cc533..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable/hogp_button_blue.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
- -
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable/hogp_keyboard_button.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable/hogp_keyboard_button.xml
deleted file mode 100644
index cc61bb93b4..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable/hogp_keyboard_button.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
- -
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable/hogp_keyboard_select.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable/hogp_keyboard_select.xml
deleted file mode 100644
index 60544e5deb..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/drawable/hogp_keyboard_select.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- -
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/activity_control.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/activity_control.xml
deleted file mode 100644
index 9ea8cf4e52..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/activity_control.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/activity_help.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/activity_help.xml
deleted file mode 100644
index 275f9dc190..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/activity_help.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/activity_setting.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/activity_setting.xml
deleted file mode 100644
index 3c140b4e0c..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/activity_setting.xml
+++ /dev/null
@@ -1,240 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/contents_keyboard.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/contents_keyboard.xml
deleted file mode 100644
index bd42c90011..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/contents_keyboard.xml
+++ /dev/null
@@ -1,274 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/contents_keyboard_footer.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/contents_keyboard_footer.xml
deleted file mode 100644
index 761f3ba2ce..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/contents_keyboard_footer.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/contents_keyboard_menu.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/contents_keyboard_menu.xml
deleted file mode 100644
index 4f0642851d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/contents_keyboard_menu.xml
+++ /dev/null
@@ -1,146 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/contents_keyboard_special.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/contents_keyboard_special.xml
deleted file mode 100644
index 959d50551b..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/contents_keyboard_special.xml
+++ /dev/null
@@ -1,214 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/fragment_help_01.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/fragment_help_01.xml
deleted file mode 100644
index 79fe9efc99..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/fragment_help_01.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/fragment_help_02.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/fragment_help_02.xml
deleted file mode 100644
index ddf2fc7762..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/fragment_help_02.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/fragment_help_03.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/fragment_help_03.xml
deleted file mode 100644
index 11441c66c9..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/fragment_help_03.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/fragment_help_04.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/fragment_help_04.xml
deleted file mode 100644
index cf206dce3d..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/fragment_help_04.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/item_setting_device.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/item_setting_device.xml
deleted file mode 100644
index f22a4c4553..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/layout/item_setting_device.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/menu/activity_setting_menu.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/menu/activity_setting_menu.xml
deleted file mode 100644
index d440f42600..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/menu/activity_setting_menu.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/values/dimens.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/values/dimens.xml
deleted file mode 100644
index 9e8515ff7f..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- 3dp
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/values/strings.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/values/strings.xml
deleted file mode 100644
index f132afc208..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,150 +0,0 @@
-
-
-
- HOGP (Device Connect Device Plug-in)
-
- メニュー
- ヘルプ
-
- デバイス操作
- -
- 設定
- HOGPサーバ
- 外部から入力デバイスとして接続できるようにします。
- ON
- OFF
- ユーザ認可
- このプラグインに対してアクセスするときにユーザ認可を求めます。
- ON
- OFF
- HOGPサーバ設定
- Mouse
- マウスの機能を提供します。
-
- - None
- - Relative
- - Absolute
-
- Keyboard
- キーボードの機能を提供します。
- ON
- OFF
- デバイス一覧
-
- 警告
- Bluetoothが無効になっています。\n設定を有効にしますか?
- はい
- いいえ
- 警告
- Bluetooth Low Energyがサポートされていません。
- 警告
- Bluetooth Peripheralがサポートされていません。
- エラー
- HOGPサーバの起動に失敗しました。\n
- エラー
- マウスとキーボードの機能が有効になっていません。\nどちらかの機能を有効にしてください。
- 警告
- HOGPサーバが起動していません。
- 接続
- 切断
-
- 設定画面で、HOGPサーバをONにします。ここに表示されるデバイス名を覚えておきます。
- HOGPサーバに接続したいデバイスの「Bluetooth」をオンにして、周辺にあるデバイスを検出します。
- 検出したデバイスから、HOGPサーバと同じデバイス名を選択してペアリングを行います。\n
-(※ 端末によって見た目が変わる可能性がありますのでご注意してください。)\n
- ペアリングの確認画面が表示されますので、「はい」を選んでください。\n\n
-また、ペアリングのダイアログが表示されない場合があります。\n
-その場合には、通知バーに隠れている可能性がありますので、確認してください。
- ペアリングに成功すると、上記のように表示されます。\n
-「入力デバイスとして接続」されていますので、この状態で操作できるようになります。\n
-(※ 端末によって文言が異なることがありますのでご注意してください。)\n
-\n
-しばらくしても「入力デバイスとして接続」が表示されない場合には接続に失敗していますので、ペアリングを解除して、最初から接続を行ってください。\n
-\n
-また、「入力デバイスとして接続」と表示されていても動作しない場合があります。その場合には、ペアリングを解除して、最初から接続を行なってください。\n
-それでも動作しない場合には、相性が悪い可能性がありますので、デバイスを変えて接続してください。
- HOGPサーバをOFFにした後やこのデバイスのBluetooth設定を無効した後に、再度有効にして再接続しても動作しないことがあります。\nその場合には一度ペアリングを解除して、最初から接続を行なってください。\n
- \n
-「入力デバイスとして接続」が表示されたり、消えたりして接続ができない場合には、一度BluetoothをOFF→ONを行ってください。\n
-\n
-「入力デバイスとして接続」となっているのに、操作できない場合には、ペアリングを解除してからもう一度ペアリングを行ってください。\n
-\n
-上記の手順でも接続できない場合には、デバイスを再起動してください。
-
- ここをドラッグすることでマウスポインターを動かすことができます。
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-
- a
- b
- c
- d
- e
- f
- g
- h
- i
- j
- k
- l
- m
- n
- o
- p
- q
- r
- s
- t
- u
- v
- w
- x
- y
- z
-
- \@
- #
- %
- ¥
- &
- (
- )
- -
- /
- :
- ;
- ^
- !
- \?
- *
- +
- =
- <
- >
- [
- ]
- _
- .
- ,
-
-
- caps
- Enter
- del
- esc
- tab
- ↑
- ↓
- ←
- →
- あ/A
- 123
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/xml/deviceplugin.xml b/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/xml/deviceplugin.xml
deleted file mode 100644
index c1c37db533..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/plugin/src/main/res/xml/deviceplugin.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHOGP/settings.gradle b/dConnectDevicePlugin/dConnectDeviceHOGP/settings.gradle
deleted file mode 100644
index c1d1ef11f9..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHOGP/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':plugin'
diff --git a/dConnectDevicePlugin/dConnectDeviceHeartRate/README.md b/dConnectDevicePlugin/dConnectDeviceHeartRate/README.md
deleted file mode 100644
index 1cea5e4689..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHeartRate/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# HeartRateプラグイン
-
-このHeartRateプラグインでは、Bluetooth low enegryのGATTプロファイルの一つであるHeart Rate Profileから値を取得するための機能を提供します。
-
-## 開発環境
-Android Studio 2.2.1以上
-
-## ビルドマニュアル
-- [HeartRateビルドマニュアル](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/HeartRateDevice-Build)
-
-## サポートするプロファイル
-
-* health
-
-## 動作確認を行なったデバイス
-
-* MIO Alpha
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHeartRate/app/build.gradle b/dConnectDevicePlugin/dConnectDeviceHeartRate/app/build.gradle
deleted file mode 100644
index f681e818ba..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHeartRate/app/build.gradle
+++ /dev/null
@@ -1,84 +0,0 @@
-apply plugin: 'com.android.application'
-// Create github.properties in root project folder file with
-// gpr.usr=GITHUB_USER_ID
-// gpr.key=PERSONAL_ACCESS_TOKEN
-def githubPropertiesFile = rootProject.file("github.properties")
-def githubProperties = new Properties()
-if (githubPropertiesFile.exists()) {
- githubProperties.load(new FileInputStream(githubPropertiesFile))
-}
-
-android {
- compileSdkVersion 29
-
- def getVersionName = { ->
- def version
- if (System.getProperty('os.name').toLowerCase().contains('windows')) {
- version = ["cmd", "/c", "git describe --tags --long"].execute().in.text.trim()
- } else {
- version = ["sh", "-c", "git describe --tags --long"].execute().in.text.trim()
- }
- version = version.empty ? "2.1.0" : version
- return "${version}"
- }
-
- defaultConfig {
- applicationId "org.deviceconnect.android.deviceplugin.heartrate"
- minSdkVersion 18
- targetSdkVersion 29
- versionCode 1
- versionName getVersionName()
- }
-
- signingConfigs {
- releaseConfig {
- storeFile=file(project.properties.storeFile)
- storePassword=project.properties.storePassword
- keyAlias=project.properties.keyAlias
- keyPassword=project.properties.keyPassword
- }
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- signingConfig signingConfigs.releaseConfig
- }
- }
-
- packagingOptions {
- exclude 'LICENSE.txt'
- exclude 'META-INF/DEPENDENCIES'
- exclude 'META-INF/LICENSE'
- exclude 'META-INF/NOTICE'
- }
- tasks.withType(JavaCompile) {
- options.encoding = 'UTF-8'
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- repositories {
- maven {
- name = "DeviceConnect-Android"
- url = uri("https://maven.pkg.github.com/DeviceConnect/DeviceConnect-Android")
-
- credentials {
- username = System.getenv("GPR_USER") ?: githubProperties['gpr.usr']
- password = System.getenv("GPR_API_KEY") ?: githubProperties['gpr.key']
- }
- }
- }
-}
-
-
-dependencies {
- implementation fileTree(include: '*.jar', dir: 'libs')
- implementation 'org.deviceconnect:dconnect-device-plugin-sdk:2.8.4'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test.ext:junit:1.1.1'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
-}
-
diff --git a/dConnectDevicePlugin/dConnectDeviceHeartRate/app/proguard-rules.pro b/dConnectDevicePlugin/dConnectDeviceHeartRate/app/proguard-rules.pro
deleted file mode 100644
index 1c560ab8e2..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHeartRate/app/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Applications/android-sdk/android-sdk-macosx/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/dConnectDevicePlugin/dConnectDeviceHeartRate/app/src/androidTest/java/org/deviceconnect/android/deviceplugin/heartrate/ApplicationTest.java b/dConnectDevicePlugin/dConnectDeviceHeartRate/app/src/androidTest/java/org/deviceconnect/android/deviceplugin/heartrate/ApplicationTest.java
deleted file mode 100644
index 10f60c7c8c..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHeartRate/app/src/androidTest/java/org/deviceconnect/android/deviceplugin/heartrate/ApplicationTest.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.deviceconnect.android.deviceplugin.heartrate;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.runner.RunWith;
-
-/**
- * Testing Fundamentals
- */
-@RunWith(AndroidJUnit4.class)
-public class ApplicationTest {
- public ApplicationTest() {
- }
-}
\ No newline at end of file
diff --git a/dConnectDevicePlugin/dConnectDeviceHeartRate/app/src/androidTest/java/org/deviceconnect/android/deviceplugin/heartrate/ble/BleDeviceDetectorTest.java b/dConnectDevicePlugin/dConnectDeviceHeartRate/app/src/androidTest/java/org/deviceconnect/android/deviceplugin/heartrate/ble/BleDeviceDetectorTest.java
deleted file mode 100644
index f768c72efe..0000000000
--- a/dConnectDevicePlugin/dConnectDeviceHeartRate/app/src/androidTest/java/org/deviceconnect/android/deviceplugin/heartrate/ble/BleDeviceDetectorTest.java
+++ /dev/null
@@ -1,307 +0,0 @@
-package org.deviceconnect.android.deviceplugin.heartrate.ble;
-
-import android.bluetooth.BluetoothDevice;
-import android.content.Context;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import static androidx.test.InstrumentationRegistry.getContext;
-import static junit.framework.TestCase.assertNotNull;
-import static junit.framework.TestCase.assertTrue;
-import static junit.framework.TestCase.fail;
-import static org.junit.Assert.assertEquals;
-
-@RunWith(AndroidJUnit4.class)
-public class BleDeviceDetectorTest {
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
-
- @Test
- public void testBleDeviceDetector() {
- BleDeviceDetector detector = new BleDeviceDetector(getContext());
- assertNotNull(detector);
- }
-
- @Test
- public void testBleDeviceDetector_ContextIsNull() {
- try {
- new BleDeviceDetector(null);
- fail("not occurred exception");
- } catch (NullPointerException e) {
- assertTrue(true);
- } catch (Exception e) {
- fail("Illegal exception");
- }
- }
-
- @Test
- public void testInitialize() {
- BleDeviceDetector detector = new BleDeviceDetector(getContext());
- detector.initialize();
- assertTrue(true);
- }
-
- @Test
- public void testSetListener() {
- BleDeviceDetector detector = new BleDeviceDetector(getContext());
- detector.setListener(new BleDeviceDetector.BleDeviceDiscoveryListener() {
- @Override
- public void onDiscovery(List devices) {
- }
- });
- assertTrue(true);
- }
-
- @Test
- public void testSetListener_ListenerIsNull() {
- BleDeviceDetector detector = new BleDeviceDetector(getContext());
- detector.setListener(null);
- assertTrue(true);
- }
-
- @Test
- public void testIsScanning() {
- BleDeviceDetector detector = new BleDeviceDetector(getContext());
- assertEquals(false, detector.isScanning());
- }
-
- @Test
- public void testIsScanning_StartScan() {
- BleDeviceDetector detector = new BleDeviceDetector(getContext());
- try {
- detector.startScan();
- assertEquals(true, detector.isScanning());
- } finally {
- detector.stopScan();
- }
- }
-
- @Test
- public void testIsEnabled() {
- BleDeviceDetector detector = new BleDeviceDetector(getContext());
- assertEquals(true, detector.isEnabled());
- }
-
- @Test
- public void testStartScan() {
- final CountDownLatch countDownLatch = new CountDownLatch(1);
-
- BleDeviceDetector detector = new BleDeviceDetector(getContext(),
- new BleDeviceAdapterFactory() {
- @Override
- public BleDeviceAdapter createAdapter(Context context) {
- BleDeviceAdapter adapter = new BleDeviceAdapter() {
- @Override
- public void startScan(BleDeviceScanCallback callback) {
- // TODO make a mock.
- }
- @Override
- public void stopScan(BleDeviceScanCallback callback) {
- }
- @Override
- public BluetoothDevice getDevice(String address) {
- return null;
- }
- @Override
- public Set getBondedDevices() {
- return null;
- }
- @Override
- public boolean isEnabled() {
- return true;
- }
- @Override
- public boolean checkBluetoothAddress(String address) {
- return false;
- }
- };
- return adapter;
- }
- });
- detector.setListener(new BleDeviceDetector.BleDeviceDiscoveryListener() {
- @Override
- public void onDiscovery(List devices) {
- countDownLatch.countDown();
- }
- });
-
- try {
- detector.startScan();
- assertEquals(true, countDownLatch.await(20, TimeUnit.SECONDS));
- } catch (InterruptedException e) {
- fail("no discovery");
- } finally {
- detector.stopScan();
- }
- }
-
- @Test
- public void testStartScan_ScanAlreadyStarted() {
- final CountDownLatch countDownLatch = new CountDownLatch(1);
-
- BleDeviceDetector detector = new BleDeviceDetector(getContext(),
- new BleDeviceAdapterFactory() {
- @Override
- public BleDeviceAdapter createAdapter(Context context) {
- BleDeviceAdapter adapter = new BleDeviceAdapter() {
- @Override
- public void startScan(BleDeviceScanCallback callback) {
- // TODO make a mock.
- }
- @Override
- public void stopScan(BleDeviceScanCallback callback) {
- }
- @Override
- public BluetoothDevice getDevice(String address) {
- return null;
- }
- @Override
- public Set getBondedDevices() {
- return null;
- }
- @Override
- public boolean isEnabled() {
- return true;
- }
- @Override
- public boolean checkBluetoothAddress(String address) {
- return false;
- }
- };
- return adapter;
- }
- });
- detector.setListener(new BleDeviceDetector.BleDeviceDiscoveryListener() {
- @Override
- public void onDiscovery(List devices) {
- countDownLatch.countDown();
- }
- });
-
- try {
- detector.startScan();
- detector.startScan();
- assertEquals(true, countDownLatch.await(20, TimeUnit.SECONDS));
- } catch (InterruptedException e) {
- fail("no discovery");
- } finally {
- detector.stopScan();
- }
- }
-
- @Test
- public void testStopScan() {
- final CountDownLatch countDownLatch = new CountDownLatch(1);
-
- BleDeviceDetector detector = new BleDeviceDetector(getContext(),
- new BleDeviceAdapterFactory() {
- @Override
- public BleDeviceAdapter createAdapter(Context context) {
- BleDeviceAdapter adapter = new BleDeviceAdapter() {
- @Override
- public void startScan(BleDeviceScanCallback callback) {
- // TODO make a mock.
- }
- @Override
- public void stopScan(BleDeviceScanCallback callback) {
- }
- @Override
- public BluetoothDevice getDevice(String address) {
- return null;
- }
- @Override
- public Set getBondedDevices() {
- return null;
- }
- @Override
- public boolean isEnabled() {
- return true;
- }
- @Override
- public boolean checkBluetoothAddress(String address) {
- return false;
- }
- };
- return adapter;
- }
- });
- detector.setListener(new BleDeviceDetector.BleDeviceDiscoveryListener() {
- @Override
- public void onDiscovery(List devices) {
- countDownLatch.countDown();
- }
- });
-
- try {
- detector.startScan();
- detector.stopScan();
- assertEquals(false, countDownLatch.await(20, TimeUnit.SECONDS));
- } catch (InterruptedException e) {
- fail("no discovery");
- } finally {
- }
- }
-
- @Test
- public void testStopScan_NoStart() {
- BleDeviceDetector detector = new BleDeviceDetector(getContext(),
- new BleDeviceAdapterFactory() {
- @Override
- public BleDeviceAdapter createAdapter(Context context) {
- BleDeviceAdapter adapter = new BleDeviceAdapter() {
- @Override
- public void startScan(BleDeviceScanCallback callback) {
- // TODO make a mock.
- }
- @Override
- public void stopScan(BleDeviceScanCallback callback) {
- }
- @Override
- public BluetoothDevice getDevice(String address) {
- return null;
- }
- @Override
- public Set getBondedDevices() {
- return null;
- }
- @Override
- public boolean isEnabled() {
- return true;
- }
- @Override
- public boolean checkBluetoothAddress(String address) {
- return false;
- }
- };
- return adapter;
- }
- });
- detector.setListener(new BleDeviceDetector.BleDeviceDiscoveryListener() {
- @Override
- public void onDiscovery(List