diff --git a/README.md b/README.md index 705e47277c..2ae3aa0b89 100755 --- a/README.md +++ b/README.md @@ -133,7 +133,6 @@ curl -X GET \ |[dConnectDeviceChromeCast](dConnectDevicePlugin/dConnectDeviceChromeCast)|Chromecastのデバイスプラグイン。 | |[dConnectDeviceFaBo](dConnectDevicePlugin/dConnectDeviceFaBo)|FaBoのデバイスプラグイン。| |[dConnectDeviceHeartRate](dConnectDevicePlugin/dConnectDeviceHeartRate)|Mio AlphaなどのHeartRateのデバイスプラグイン。| -|[dConnectDeviceHitoe](dConnectDevicePlugin/dConnectDeviceHitoe)|Hitoeのデバイスプラグイン。| |[dConnectDeviceHOGP](dConnectDevicePlugin/dConnectDeviceHOGP)|HOGPのデバイスプラグイン。| |[dConnectDeviceHost](dConnectDevicePlugin/dConnectDeviceHost)|Androidのデバイスプラグイン。| |[dConnectDeviceHue](dConnectDevicePlugin/dConnectDeviceHue)|Hueのデバイスプラグイン。| @@ -213,7 +212,6 @@ Device Connect Managerや各デバイスプラグインを開発したい人は * [ChromeCast](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/ChromeCast-Build) * [FaBo](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/FaBo-Build) * [HeartRate](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/HeartRateDevice-Build) -* [Hitoe](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/Hitoe-Build) * [HOGP](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/HOGP-Build) * [Host](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/Host-Build) * [Hue](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/Hue-Build) diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/.gitignore b/dConnectDevicePlugin/dConnectDeviceHitoe/.gitignore deleted file mode 100644 index 9b9038d6fe..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures -/libs \ No newline at end of file diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/README.md b/dConnectDevicePlugin/dConnectDeviceHitoe/README.md deleted file mode 100644 index 6b2d39616b..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Hitoeプラグイン - -このHitoeプラグインでは、hitoeトランスミッターから心拍数や心電図などの値を取得するための機能を提供します。 - -## 開発環境 -Android Studio 2.2.1以上 - -## ビルドマニュアル -- [Hitoeビルドマニュアル](https://github.com/DeviceConnect/DeviceConnect-Android/wiki/Hitoe-Build) - -## サポートするプロファイル - -* battery -* deviceOrientation -* ecg -* health -* poseEstimation -* stressEstimation -* walkState - -## 関連 - -* [Hitoe](https://www.nttdocomo.co.jp/service/developer/smart_phone/device/hitoe/) diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/.gitignore b/dConnectDevicePlugin/dConnectDeviceHitoe/app/.gitignore deleted file mode 100644 index c23e5a2d89..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/build -/libs \ No newline at end of file diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/build.gradle b/dConnectDevicePlugin/dConnectDeviceHitoe/app/build.gradle deleted file mode 100644 index 0a9cf93be6..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/build.gradle +++ /dev/null @@ -1,67 +0,0 @@ -apply plugin: 'com.android.application' - -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.hitoe" - minSdkVersion 21 - 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 { url 'https://raw.githubusercontent.com/DeviceConnect/DeviceConnect-Android/master/dConnectSDK/dConnectSDKForAndroid/repository/' } - maven { url 'https://raw.githubusercontent.com/DeviceConnect/DeviceConnect-Android/master/dConnectDevicePlugin/dConnectDevicePluginSDK/repository/' } - maven { url 'file://' + rootDir + '/../../dConnectSDK/dConnectSDKForAndroid/repository/' } - maven { url 'file://' + rootDir + '/../../dConnectDevicePlugin/dConnectDevicePluginSDK/repository/' }} - -dependencies { - implementation fileTree(include: '*.jar', dir: 'libs') - implementation 'org.deviceconnect:dconnect-device-plugin-sdk:2.8.3' -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/proguard-rules.pro b/dConnectDevicePlugin/dConnectDeviceHitoe/app/proguard-rules.pro deleted file mode 100644 index 06c213e006..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/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/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/dConnectDeviceHitoe/app/src/androidTest/java/org/deviceconnect/android/deviceplugin/hitoe/ApplicationTest.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/androidTest/java/org/deviceconnect/android/deviceplugin/hitoe/ApplicationTest.java deleted file mode 100644 index e8ce785469..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/androidTest/java/org/deviceconnect/android/deviceplugin/hitoe/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.deviceconnect.android.deviceplugin.hitoe; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/AndroidManifest.xml b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/AndroidManifest.xml deleted file mode 100644 index a57a05c62c..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/HitoeApplication.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/HitoeApplication.java deleted file mode 100644 index 8fc7d6ba1c..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/HitoeApplication.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - HitoeApplication - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe; - -import android.app.Application; - -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; - -/** - * Implementation of Application. - * @author NTT DOCOMO, INC. - */ -public class HitoeApplication extends Application { - /** - * Instance of HitoeManager. - */ - private HitoeManager mMgr; - - /** - * Initialize the HitoeApplication. - */ - public void initialize() { - if (mMgr == null) { - mMgr = new HitoeManager(getApplicationContext()); - } - } - - /** - * Gets a instance of HitoeManager. - * @return HitoeManager - */ - public HitoeManager getHitoeManager() { - return mMgr; - } - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/HitoeDeviceService.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/HitoeDeviceService.java deleted file mode 100644 index 13f3a73454..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/HitoeDeviceService.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - HitoeDeviceService - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe; - -import android.bluetooth.BluetoothAdapter; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Handler; -import android.util.Log; - -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.profile.HitoeServiceDiscoveryProfile; -import org.deviceconnect.android.deviceplugin.hitoe.profile.HitoeSystemProfile; -import org.deviceconnect.android.event.EventManager; -import org.deviceconnect.android.event.cache.MemoryCacheController; -import org.deviceconnect.android.message.DConnectMessageService; -import org.deviceconnect.android.profile.SystemProfile; -import org.deviceconnect.android.service.DConnectService; - -import java.util.List; - -/** - * This service provide Hitoe Profile. - * @author NTT DOCOMO, INC. - */ -public class HitoeDeviceService extends DConnectMessageService { - /** - * Tag. - */ - private final String TAG = "HitoeDeviceService"; - /** - * Instance of handler. - */ - private final Handler mHandler = new Handler(); - - /** - * Received a event that Bluetooth has been changed. - */ - private final BroadcastReceiver mSensorReceiver = 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); - if (state == BluetoothAdapter.STATE_ON) { - getManager().start(); - } else if (state == BluetoothAdapter.STATE_OFF) { - getManager().stop(); - } - } - } - }; - /** - * Connected Hitoe's info listener. - */ - private final HitoeManager.OnHitoeConnectionListener mOnHitoeConnectionListener - = new HitoeManager.OnHitoeConnectionListener() { - @Override - public void onConnected(final HitoeDevice device) { - DConnectService service = new HitoeService(getManager(), device); - service.setOnline(true); - getServiceProvider().addService(service); - } - - @Override - public void onConnectFailed(final HitoeDevice device) { - if (device == null) { - return; - } - DConnectService service = getServiceProvider().getService(device.getId()); - if (service != null) { - service.setOnline(false); - } - } - - @Override - public void onDiscovery(final List devices) { - for (HitoeDevice device: devices) { - if (device.getPinCode() != null) { - DConnectService service = new HitoeService(getManager(), device); - getServiceProvider().addService(service); - } - } - } - - @Override - public void onDisconnected(final int res, final HitoeDevice device) { - DConnectService service = getServiceProvider().getService(device.getId()); - if (service != null) { - service.setOnline(false); - } - } - - @Override - public void onDeleted(final HitoeDevice device) { - DConnectService service = getServiceProvider().getService(device.getId()); - if (service != null) { - getServiceProvider().removeService(service); - } - } - - }; - - @Override - public void onCreate() { - super.onCreate(); - HitoeApplication app = (HitoeApplication) getApplication(); - app.initialize(); - EventManager.INSTANCE.setController(new MemoryCacheController()); - getManager().addHitoeConnectionListener(mOnHitoeConnectionListener); - registerBluetoothFilter(); - addProfile(new HitoeServiceDiscoveryProfile(getServiceProvider())); - HitoeManager mgr = getManager(); - if (mgr != null) { - List devices = mgr.getRegisterDevices(); - for (HitoeDevice device : devices) { - if (device.getPinCode() != null) { - getServiceProvider().addService(new HitoeService(mgr, device)); - } - } - } - } - - @Override - public void onDestroy() { - super.onDestroy(); - unregisterBluetoothFilter(); - getManager().stop(); - - } - - @Override - protected SystemProfile getSystemProfile() { - return new HitoeSystemProfile(); - } - - @Override - protected void onManagerUninstalled() { - if (BuildConfig.DEBUG) { - Log.d(TAG, "onManagerUninstalled"); - } - getManager().stop(); - EventManager.INSTANCE.removeAll(); - removeAllServices(); - - } - - @Override - protected void onManagerTerminated() { - if (BuildConfig.DEBUG) { - Log.d(TAG, "onManagerTerminated"); - } - EventManager.INSTANCE.removeAll(); - removeAllServices(); - } - - @Override - protected void onManagerEventTransmitDisconnected(final String sessionKey) { - if (BuildConfig.DEBUG) { - Log.d(TAG, "onManagerEventTransmitDisconnected: " + sessionKey); - } - - if (sessionKey != null) { - EventManager.INSTANCE.removeEvents(sessionKey); - } else { - EventManager.INSTANCE.removeAll(); - } - } - - @Override - protected void onDevicePluginReset() { - if (BuildConfig.DEBUG) { - Log.d(TAG, "onDevicePluginReset"); - } - resetService(); - } - /** - * Register a BroadcastReceiver of Bluetooth event. - */ - private void registerBluetoothFilter() { - IntentFilter filter = new IntentFilter(); - filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); - registerReceiver(mSensorReceiver, filter, null, mHandler); - } - /** - * Unregister a previously registered BroadcastReceiver. - */ - private void unregisterBluetoothFilter() { - unregisterReceiver(mSensorReceiver); - } - - /** - * Gets a instance of HeartRateManager. - * - * @return HeartRateManager - */ - private HitoeManager getManager() { - HitoeApplication app = (HitoeApplication) getApplication(); - return app.getHitoeManager(); - } - - /** - * Remove All service. - */ - private void removeAllServices() { - List services = getServiceProvider().getServiceList(); - for (DConnectService service : services) { - getServiceProvider().removeService(service); - } - } - - /** - * Reset service. - */ - private void resetService() { - removeAllServices(); - HitoeManager mgr = getManager(); - if (mgr != null) { - List devices = mgr.getRegisterDevices(); - for (HitoeDevice device : devices) { - if (device.getPinCode() != null) { - getServiceProvider().addService(new HitoeService(mgr, device)); - } - } - } - } - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/HitoeDeviceServiceProvider.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/HitoeDeviceServiceProvider.java deleted file mode 100644 index 88dc8f10e4..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/HitoeDeviceServiceProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - HitoeDeviceServiceProvider - Copyright (c) 2014 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe; - -import android.app.Service; - -import org.deviceconnect.android.message.DConnectMessageServiceProvider; - -/** - * Hitoe Device Plug-in. - * @param - * @author NTT DOCOMO, INC. - */ -public class HitoeDeviceServiceProvider extends DConnectMessageServiceProvider { - @SuppressWarnings("unchecked") - @Override - protected Class getServiceClass() { - Class clazz = HitoeDeviceService.class; - return (Class) clazz; - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/HitoeService.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/HitoeService.java deleted file mode 100644 index 63251335ad..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/HitoeService.java +++ /dev/null @@ -1,58 +0,0 @@ - -/* - HitoeService - Copyright (c) 2015 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe; - -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.profile.HitoeBatteryProfile; -import org.deviceconnect.android.deviceplugin.hitoe.profile.HitoeDeviceOrientationProfile; -import org.deviceconnect.android.deviceplugin.hitoe.profile.HitoeECGProfile; -import org.deviceconnect.android.deviceplugin.hitoe.profile.HitoeHealthProfile; -import org.deviceconnect.android.deviceplugin.hitoe.profile.HitoePoseEstimationProfile; -import org.deviceconnect.android.deviceplugin.hitoe.profile.HitoeStressEstimationProfile; -import org.deviceconnect.android.deviceplugin.hitoe.profile.HitoeWalkStateProfile; -import org.deviceconnect.android.service.DConnectService; - -/** - * Implement Hitoe's information. - * @author NTT DOCOMO, INC. - */ -public class HitoeService extends DConnectService { - /** - * コンストラクタ. - * - * @param id サービスID - */ - private final HitoeDevice mEntity; - - /** - * Construcotr. - * @param manager HitoeManager - * @param entity HitoeDevice - */ - public HitoeService(final HitoeManager manager, final HitoeDevice entity) { - super(entity.getId()); - setName(entity.getName()); - setNetworkType(NetworkType.BLE); - setConfig(""); - setOnline(entity.isRegisterFlag()); - addProfile(new HitoeHealthProfile(manager)); - addProfile(new HitoeDeviceOrientationProfile(manager)); - addProfile(new HitoeBatteryProfile()); - addProfile(new HitoeECGProfile(manager)); - addProfile(new HitoeStressEstimationProfile(manager)); - addProfile(new HitoePoseEstimationProfile(manager)); - addProfile(new HitoeWalkStateProfile(manager)); - mEntity = entity; - } - @Override - public boolean isOnline() { - return mEntity.isRegisterFlag(); - } - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/HitoeAddDeviceActivity.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/HitoeAddDeviceActivity.java deleted file mode 100644 index 470e78ee56..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/HitoeAddDeviceActivity.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - HitoeAddDeviceActivity - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.activity; - -import android.bluetooth.BluetoothAdapter; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.res.Resources; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.view.View; -import android.widget.AdapterView; -import android.widget.Button; -import android.widget.TextView; - -import org.deviceconnect.android.deviceplugin.hitoe.R; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeConstants; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.dialog.DefaultDialogFragment; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.dialog.PinCodeDialogFragment; -import org.deviceconnect.android.deviceplugin.hitoe.util.BleUtils; -import org.deviceconnect.android.deviceplugin.hitoe.util.HitoeScheduler; - -import java.util.List; - -/** - * This activity is Add Device screen. - * @author NTT DOCOMO, INC. - */ -public class HitoeAddDeviceActivity extends HitoeListActivity implements HitoeManager.OnHitoeConnectionListener, - AdapterView.OnItemClickListener, - HitoeScheduler.OnRegularNotify { - - /** - * Periodic processing object. - */ - private HitoeScheduler mScheduler; - /** - * Received a event that Bluetooth has been changed. - */ - private final BroadcastReceiver mSensorReceiver = 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); - if (state == BluetoothAdapter.STATE_ON) { - addFooterView(); - getManager().addHitoeConnectionListener(HitoeAddDeviceActivity.this); - mScheduler.scanHitoeDevice(true); - } else if (state == BluetoothAdapter.STATE_OFF) { - addFooterView(); - getManager().addHitoeConnectionListener(null); - mScheduler.scanHitoeDevice(false); - } - } - } - }; - - - @Override - protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - - - @Override - public void onResume() { - super.onResume(); - mEnableConnectedBtn = false; - mDeviceAdapter.clear(); - mDeviceAdapter.notifyDataSetChanged(); - mListView.setOnItemClickListener(this); - mScheduler = new HitoeScheduler(this, -1, -1); - DefaultDialogFragment.showHitoeONStateDialog(this); - registerBluetoothFilter(); - getManager().addHitoeConnectionListener(this); - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - mScheduler.scanHitoeDevice(true); - } else { - if (BleUtils.isBLEPermission(this)) { - mScheduler.scanHitoeDevice(true); - } - } - } - - @Override - public void onPause() { - super.onPause(); - getManager().removeHitoeConnectionListener(this); - mScheduler.scanHitoeDevice(false); - dismissProgressDialog(); - dismissErrorDialog(); - unregisterBluetoothFilter(); - } - - @Override - protected void setUI() { - TextView title = (TextView) findViewById(R.id.view_title); - title.setText(R.string.add_device_view); - Button btn = (Button) findViewById(R.id.btn_add_open); - btn.setText(R.string.action_search); - btn.setOnClickListener((view) -> { - getManager().addHitoeConnectionListener(HitoeAddDeviceActivity.this); - getManager().discoveryHitoeDevices(); - }); - } - - - /** - * Register a BroadcastReceiver of Bluetooth event. - */ - private void registerBluetoothFilter() { - IntentFilter filter = new IntentFilter(); - filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); - registerReceiver(mSensorReceiver, filter, null, mHandler); - } - - /** - * Unregister a previously registered BroadcastReceiver. - */ - private void unregisterBluetoothFilter() { - unregisterReceiver(mSensorReceiver); - } - - - - @Override - public void onConnected(final HitoeDevice device) { - - runOnUiThread(() -> { - if (mCheckDialog) { - DefaultDialogFragment.showHitoeSetShirtDialog(HitoeAddDeviceActivity.this); - } - dismissProgressDialog(); - mDeviceAdapter.remove(device); - mDeviceAdapter.notifyDataSetChanged(); - }); - } - - @Override - public void onConnectFailed(final HitoeDevice device) { - runOnUiThread(() -> { - dismissProgressDialog(); - if (device == null) { - if (mConnectingDevice != null) { - HitoeDevice container = findDeviceContainerByAddress(mConnectingDevice.getId()); - if (container != null) { - container.setPinCode(null); - mDeviceAdapter.notifyDataSetChanged(); - } - Resources res = getResources(); - showErrorDialog(res.getString(R.string.hitoe_setting_dialog_error_message03)); - } - } else { - showErrorDialogNotConnect(device.getName()); - } - }); - } - - @Override - public void onDiscovery(final List devices) { - if (mDeviceAdapter == null) { - return; - } - runOnUiThread(() -> { - mDeviceAdapter.clear(); - for (HitoeDevice device : devices) { - if (device.getPinCode() == null) { - mDeviceAdapter.add(device); - } - } - mDeviceAdapter.notifyDataSetChanged(); - }); - } - - @Override - public void onDisconnected(final int res, final HitoeDevice device) { - } - - @Override - public void onDeleted(final HitoeDevice device) { - - } - - @Override - public void onItemClick(final AdapterView adapterView, final View view, - final int i, final long l) { - final HitoeDevice hitoe = (HitoeDevice) adapterView.getItemAtPosition(i); - if (hitoe == null) { - return; - } - mConnectingDevice = hitoe; - if (hitoe.getPinCode() == null) { - final Resources res = getResources(); - PinCodeDialogFragment pinDialog = PinCodeDialogFragment.newInstance(); - pinDialog.show(getSupportFragmentManager(), "pin_dialog"); - pinDialog.setOnPinCodeListener((pin) -> { - if (pin.isEmpty()) { - showErrorDialog(res.getString(R.string.hitoe_setting_dialog_error_message02)); - return; - } - hitoe.setPinCode(pin); - for (HitoeDevice d: getManager().getRegisterDevices()) { - if (!d.getName().equals(hitoe.getName()) && d.isRegisterFlag()) { - getManager().disconnectHitoeDevice(d); - } - } - - connectDevice(hitoe); - }); - } - new Handler().postDelayed(() -> { - if (mCheckDialog) { - HitoeDevice containar = findDeviceContainerByAddress(hitoe.getId()); - if (containar != null) { - containar.setPinCode(null); - } - - runOnUiThread(() -> { - dismissProgressDialog(); - Resources res = getResources(); - showErrorDialog(res.getString(R.string.hitoe_setting_dialog_error_message04)); - }); - } - }, HitoeConstants.DISCOVERY_CYCLE_TIME); - - } - - @Override - public void onRegularNotify() { - if (BleUtils.isEnabled(this)) { - addFooterView(); - getManager().addHitoeConnectionListener(this); - getManager().discoveryHitoeDevices(); - } else { - mScheduler.scanHitoeDevice(false); - } - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/HitoeDeviceControlActivity.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/HitoeDeviceControlActivity.java deleted file mode 100644 index 1ba1ab59c3..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/HitoeDeviceControlActivity.java +++ /dev/null @@ -1,230 +0,0 @@ -package org.deviceconnect.android.deviceplugin.hitoe.activity; - -import android.app.ActionBar; -import android.bluetooth.BluetoothAdapter; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Bundle; -import android.os.Handler; -import android.view.MenuItem; - -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentActivity; -import androidx.fragment.app.FragmentTransaction; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.HitoeProfileBatteryFragment; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.HitoeProfileDeviceOrientationFragment; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.HitoeProfileECGFragment; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.HitoeProfileHealthFragment; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.HitoeProfileListFragment; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.HitoeProfilePoseEstimationFragment; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.HitoeProfileStressEstimationFragment; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.HitoeProfileWalkStateFragment; - -/** - * This activity is hitoe debug screen. - * @author NTT DOCOMO, INC. - */ -public class HitoeDeviceControlActivity extends FragmentActivity { - /** - * Feature serviceId. - */ - public static final String FEATURE_SERVICE_ID = "org.deviceconnect.android.hitoe.SERVICEID"; - - /** - * Default title. - */ - public static final String DEFAULT_TITLE = "CLOSE"; - - /** - * Main control page. - */ - public static final int CONTROL_PAGE_MAIN = 0; - /** - * Heartrate control page. - */ - public static final int CONTROL_PAGE_HEARTRATE = 1; - /** - * Battery control page. - */ - public static final int CONTROL_PAGE_BATTERY = 2; - /** - * DeviceOrientation control page. - */ - public static final int CONTROL_PAGE_DEVICEORIENTATION = 3; - /** - * ECG control page. - */ - public static final int CONTROL_PAGE_ECG = 4; - /** - * Stress Estimation control page. - */ - public static final int CONTROL_PAGE_STRESS = 5; - /** - * Pose Estimation control page. - */ - public static final int CONTROL_PAGE_POSE = 6; - /** - * Walk State control page. - */ - public static final int CONTROL_PAGE_WALK = 7; - - /** - * Selected control page no. - */ - private int mPage = CONTROL_PAGE_MAIN; - /** - * Handler. - */ - private final Handler mHandler = new Handler(); - - /** - * Received a event that Bluetooth has been changed. - */ - private final BroadcastReceiver mSensorReceiver = 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); - if (state == BluetoothAdapter.STATE_OFF) { - finish(); - } - } - } - }; - - @Override - protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - HitoeApplication app = (HitoeApplication) getApplication(); - app.initialize(); - if (getActionBar() != null) { - getActionBar().setDisplayHomeAsUpEnabled(true); - getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_HOME); - getActionBar().setTitle(DEFAULT_TITLE); - } - if (savedInstanceState == null) { - movePage(CONTROL_PAGE_MAIN); - } - } - - @Override - public void onResume() { - super.onResume(); - IntentFilter filter = new IntentFilter(); - filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); - registerReceiver(mSensorReceiver, filter, null, mHandler); - } - - @Override - public void onPause() { - super.onPause(); - unregisterReceiver(mSensorReceiver); - } - @Override - public boolean onOptionsItemSelected(final MenuItem item) { - - if (item.getItemId() == android.R.id.home) { - if (mPage == CONTROL_PAGE_MAIN) { - finish(); - } else { - movePage(CONTROL_PAGE_MAIN); - } - return true; - } - - return super.onOptionsItemSelected(item); - } - - /** - * Move Page. - * @param page page no - */ - public void movePage(final int page) { - Bundle args = new Bundle(); - Intent device = getIntent(); - if (device == null) { - return; - } - mPage = page; - String serviceId = device.getStringExtra(FEATURE_SERVICE_ID); - args.putString(FEATURE_SERVICE_ID, serviceId); - switch (page) { - case CONTROL_PAGE_MAIN: - HitoeProfileListFragment profile = new HitoeProfileListFragment(); - moveFragment(true, profile); - profile.setArguments(args); - break; - case CONTROL_PAGE_HEARTRATE: - HitoeProfileHealthFragment heartRateProfile = new HitoeProfileHealthFragment(); - moveFragment(false, heartRateProfile); - heartRateProfile.setArguments(args); - break; - case CONTROL_PAGE_BATTERY: - HitoeProfileBatteryFragment batteryProfile = new HitoeProfileBatteryFragment(); - moveFragment(false, batteryProfile); - batteryProfile.setArguments(args); - break; - case CONTROL_PAGE_DEVICEORIENTATION: - HitoeProfileDeviceOrientationFragment deviceOrientationProfile - = new HitoeProfileDeviceOrientationFragment(); - moveFragment(false, deviceOrientationProfile); - deviceOrientationProfile.setArguments(args); - break; - case CONTROL_PAGE_ECG: - HitoeProfileECGFragment ecgProfile = new HitoeProfileECGFragment(); - moveFragment(false, ecgProfile); - ecgProfile.setArguments(args); - break; - case CONTROL_PAGE_STRESS: - HitoeProfileStressEstimationFragment stressProfile = new HitoeProfileStressEstimationFragment(); - moveFragment(false, stressProfile); - stressProfile.setArguments(args); - break; - case CONTROL_PAGE_POSE: - HitoeProfilePoseEstimationFragment poseProfile = new HitoeProfilePoseEstimationFragment(); - moveFragment(false, poseProfile); - poseProfile.setArguments(args); - break; - case CONTROL_PAGE_WALK: - HitoeProfileWalkStateFragment walkProfile = new HitoeProfileWalkStateFragment(); - moveFragment(false, walkProfile); - walkProfile.setArguments(args); - break; - default: - - } - - } - /** - * Gets a instance of HitoeManager. - * - * @return HitoeManager - */ - public HitoeManager getManager() { - HitoeApplication application = - (HitoeApplication) super.getApplication(); - return application.getHitoeManager(); - } - - /** - * Move Fragment. - * @param isFirst true:main, false:sub - * @param f Fragment - */ - private void moveFragment(final boolean isFirst, final Fragment f) { - FragmentTransaction t = getSupportFragmentManager().beginTransaction(); - t.setTransition(FragmentTransaction.TRANSIT_NONE); - t.replace(android.R.id.content, f); - if (!isFirst) { - t.addToBackStack(null); - } - t.commit(); - } - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/HitoeDeviceListActivity.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/HitoeDeviceListActivity.java deleted file mode 100644 index f9ed85bc90..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/HitoeDeviceListActivity.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - HitoeDeviceListActivity - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.activity; - -import android.bluetooth.BluetoothAdapter; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.res.Resources; -import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; -import android.widget.Button; -import android.widget.TextView; -import android.widget.Toast; - -import org.deviceconnect.android.deviceplugin.hitoe.R; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.dialog.DefaultDialogFragment; - -import java.util.List; - -/** - * This activity is device list screen. - * @author NTT DOCOMO, INC. - */ -public class HitoeDeviceListActivity extends HitoeListActivity implements - HitoeManager.OnHitoeConnectionListener, - AdapterView.OnItemClickListener, - AdapterView.OnItemLongClickListener { - - /** - * Received a event that Bluetooth has been changed. - */ - private final BroadcastReceiver mSensorReceiver = new BroadcastReceiver() { - @Override - public void onReceive(final Context context, final Intent intent) { - String action = intent.getAction(); - if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) { - addFooterView(); - } - } - }; - - @Override - protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - } - - - @Override - public void onResume() { - super.onResume(); - mDeviceAdapter.clear(); - mEnableConnectedBtn = true; - mDeviceAdapter.addAll(createDeviceContainers()); - mDeviceAdapter.notifyDataSetChanged(); - mListView.setOnItemClickListener(this); - mListView.setOnItemLongClickListener(this); - getManager().addHitoeConnectionListener(this); - addFooterView(); - IntentFilter filter = new IntentFilter(); - filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); - registerReceiver(mSensorReceiver, filter, null, mHandler); - DefaultDialogFragment.showHitoeWarningMessageDialog(this); - } - - @Override - public void onPause() { - super.onPause(); - getManager().removeHitoeConnectionListener(this); - unregisterReceiver(mSensorReceiver); - } - - - @Override - protected void setUI() { - TextView title = (TextView) findViewById(R.id.view_title); - title.setText(R.string.device_list_view); - Button btn = (Button) findViewById(R.id.btn_add_open); - btn.setText(R.string.add_device_button); - btn.setOnClickListener((view) -> { - Intent intent = new Intent(); - intent.setClass(HitoeDeviceListActivity.this, HitoeAddDeviceActivity.class); - startActivity(intent); - }); - } - - @Override - public void onItemClick(final AdapterView adapterView, final View view, - final int i, final long l) { - final HitoeDevice hitoe = (HitoeDevice) adapterView.getItemAtPosition(i); - if (hitoe == null || !hitoe.isRegisterFlag()) { - Toast.makeText(this, R.string.error_disconnected_hitoe, Toast.LENGTH_SHORT).show(); - return; - } - Intent intent = new Intent(); - intent.putExtra(HitoeDeviceControlActivity.FEATURE_SERVICE_ID, hitoe.getId()); - intent.setClass(HitoeDeviceListActivity.this, HitoeDeviceControlActivity.class); - startActivity(intent); - } - - @Override - public boolean onItemLongClick(final AdapterView adapterView, final View view, - final int i, final long l) { - final HitoeDevice hitoe = (HitoeDevice) adapterView.getItemAtPosition(i); - if (hitoe == null) { - return false; - } - mConnectingDevice = hitoe; - DefaultDialogFragment.showConfirmAlert(this, hitoe.getName(), getString(R.string.confirm_delete_device), - getString(R.string.ok), (dialogInterface, ii) -> { - runOnUiThread(() -> { - disconnectDevice(hitoe); - getManager().deleteHitoeDevice(hitoe); - mDeviceAdapter.remove(hitoe); - mDeviceAdapter.notifyDataSetChanged(); - addFooterView(); - }); - }); - return true; - } - - @Override - public void onConnected(final HitoeDevice device) { - - runOnUiThread(() -> { - if (!mCheckDialog) { - return; - } - HitoeDevice container = findDeviceContainerByAddress(device.getId()); - if (container != null) { - container.setRegisterFlag(true); - container.setSessionId(device.getSessionId()); - mDeviceAdapter.notifyDataSetChanged(); - } - - dismissProgressDialog(); - }); - } - - @Override - public void onConnectFailed(final HitoeDevice device) { - runOnUiThread(() -> { - if (!mCheckDialog) { - return; - } - if (device == null && mConnectingDevice != null) { - HitoeDevice container = findDeviceContainerByAddress(mConnectingDevice.getId()); - if (container != null) { - container.setPinCode(null); - mDeviceAdapter.notifyDataSetChanged(); - } - Resources res = getResources(); - showErrorDialog(res.getString(R.string.hitoe_setting_dialog_error_message03)); - - } else if (device != null) { - showErrorDialogNotConnect(device.getName()); - } - dismissProgressDialog(); - }); - } - - @Override - public void onDiscovery(final List devices) { - if (mDeviceAdapter == null) { - return; - } - runOnUiThread(() -> { - for (HitoeDevice device : devices) { - if (!containAddressForAdapter(device.getId()) - && !device.isRegisterFlag()) { - mDeviceAdapter.add(device); - } - } - mDeviceAdapter.notifyDataSetChanged(); - }); - } - - @Override - public void onDisconnected(final int res, final HitoeDevice device) { - HitoeDevice container = findDeviceContainerByAddress(device.getId()); - if (container != null) { - if (res != 0) { - container.setRegisterFlag(true); - } - runOnUiThread(() -> { - mDeviceAdapter.notifyDataSetChanged(); - }); - } - - } - - @Override - public void onDeleted(final HitoeDevice device) { - - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/HitoeListActivity.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/HitoeListActivity.java deleted file mode 100644 index e430af8d45..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/HitoeListActivity.java +++ /dev/null @@ -1,524 +0,0 @@ -package org.deviceconnect.android.deviceplugin.hitoe.activity; - -import android.app.ActionBar; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.res.Resources; -import android.os.Bundle; -import android.os.Handler; -import android.provider.Settings; -import android.view.LayoutInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.ListView; -import android.widget.TextView; - -import androidx.fragment.app.FragmentActivity; - -import org.deviceconnect.android.activity.PermissionUtility; -import org.deviceconnect.android.deviceplugin.hitoe.BuildConfig; -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.R; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeConstants; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.dialog.ErrorDialogFragment; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.dialog.PinCodeDialogFragment; -import org.deviceconnect.android.deviceplugin.hitoe.fragment.dialog.ProgressDialogFragment; -import org.deviceconnect.android.deviceplugin.hitoe.util.BleUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * This activity is hitoe list screen. - * @author NTT DOCOMO, INC. - */ - -public abstract class HitoeListActivity extends FragmentActivity { - /** - * デフォルトのタイトル文字列. - */ - public static final String DEFAULT_TITLE = "サービス一覧"; - - /** - * Adapter. - */ - protected DeviceAdapter mDeviceAdapter; - /** - * Error Dialog. - */ - private ErrorDialogFragment mErrorDialogFragment; - /** - * Progress Dialog. - */ - private ProgressDialogFragment mProgressDialogFragment; - /** - * Handler. - */ - protected final Handler mHandler = new Handler(); - /** - * Bluetooth device list view. - */ - protected ListView mListView; - /** - * footer view. - */ - protected View mFooterView; - - /** - * Enabled connected button. - */ - protected boolean mEnableConnectedBtn; - /** - * Progress dialog flag. - */ - protected boolean mCheckDialog; - /** - * Now connecting device. - */ - protected HitoeDevice mConnectingDevice; - - @Override - protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_hitoe_device_list); - HitoeApplication app = (HitoeApplication) getApplication(); - app.initialize(); - setUI(); - - mDeviceAdapter = new DeviceAdapter(this, createDeviceContainers()); - mListView = (ListView) findViewById(R.id.device_list_view); - mListView.setAdapter(mDeviceAdapter); - mListView.setItemsCanFocus(true); - - LayoutInflater inflater = getLayoutInflater(); - mFooterView = inflater.inflate(R.layout.item_hitoe_searching, null); - if (getActionBar() != null) { - getActionBar().setDisplayHomeAsUpEnabled(true); - - getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_HOME); - getActionBar().setTitle(DEFAULT_TITLE); - } - - } - - /** - * Initialize sub classs's ui. - */ - protected abstract void setUI(); - - @Override - protected void onResume() { - super.onResume(); - addFooterView(); - } - - @Override - protected void onPause() { - super.onPause(); - mHandler.removeCallbacksAndMessages(null); - - } - /** - * Gets a instance of HitoeManager. - * - * @return HitoeManager - */ - protected HitoeManager getManager() { - HitoeApplication application = - (HitoeApplication) getApplication(); - return application.getHitoeManager(); - } - - - @Override - public boolean onOptionsItemSelected(final MenuItem item) { - - if (item.getItemId() == android.R.id.home) { - finish(); - return true; - } - - return super.onOptionsItemSelected(item); - } - - /** - * Added the view at ListView. - */ - protected void addFooterView() { - runOnUiThread(new Runnable() { - @Override - public void run() { - LayoutInflater inflater = getLayoutInflater(); - - if (mFooterView != null) { - mListView.removeFooterView(mFooterView); - } - - if (!BleUtils.isBLEPermission(HitoeListActivity.this)) { - Button btn = (Button) findViewById(R.id.btn_add_open); - btn.setVisibility(View.GONE); - mFooterView = inflater.inflate(R.layout.item_hitoe_error, null); - TextView textView = (TextView) mFooterView.findViewById(R.id.error_message); - textView.setText(getString(R.string.hitoe_setting_dialog_error_permission)); - Button permission = (Button) mFooterView.findViewById(R.id.button_permission); - permission.setVisibility(View.VISIBLE); - permission.setText(R.string.bluetooth_settings_ble_permission_off); - permission.setOnClickListener((view) -> { - PermissionUtility.requestPermissions(HitoeListActivity.this, mHandler, - BleUtils.BLE_PERMISSIONS, - new PermissionUtility.PermissionRequestCallback() { - @Override - public void onSuccess() { - } - - @Override - public void onFail(final String deniedPermission) { - } - }); - }); - - mListView.addFooterView(mFooterView); - - } else if (!BleUtils.isEnabled(HitoeListActivity.this)) { - Button btn = findViewById(R.id.btn_add_open); - btn.setVisibility(View.GONE); - - mFooterView = inflater.inflate(R.layout.item_hitoe_error, null); - TextView textView = mFooterView.findViewById(R.id.error_message); - textView.setText(getString(R.string.hitoe_setting_dialog_disable_bluetooth)); - Button bluetooth = mFooterView.findViewById(R.id.button_permission); - bluetooth.setVisibility(View.VISIBLE); - bluetooth.setText(R.string.bluetooth_settings_button); - bluetooth.setOnClickListener((view) -> { - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_BLUETOOTH_SETTINGS); - startActivity(intent); - }); - mDeviceAdapter.clear(); - mDeviceAdapter.notifyDataSetChanged(); - - mListView.addFooterView(mFooterView); - } else if (BleUtils.isEnabled(HitoeListActivity.this) - && !mEnableConnectedBtn) { - mFooterView = inflater.inflate(R.layout.item_hitoe_searching, null); - mListView.addFooterView(mFooterView); - } else if (BleUtils.isEnabled(HitoeListActivity.this) - && mEnableConnectedBtn && createDeviceContainers().size() == 0) { - Button btn = findViewById(R.id.btn_add_open); - btn.setVisibility(View.VISIBLE); - - mFooterView = inflater.inflate(R.layout.item_hitoe_error, null); - TextView textView = (TextView) mFooterView.findViewById(R.id.error_message); - textView.setText(getString(R.string.alert_add_device)); - Button bluetooth = mFooterView.findViewById(R.id.button_permission); - bluetooth.setVisibility(View.GONE); - - mListView.addFooterView(mFooterView); - } else { - Button btn = findViewById(R.id.btn_add_open); - btn.setVisibility(View.VISIBLE); - mDeviceAdapter.clear(); - mDeviceAdapter.addAll(createDeviceContainers()); - mDeviceAdapter.notifyDataSetChanged(); - - } - } - }); - } - /** - * Create a list of device. - * - * @return list of device - */ - protected List createDeviceContainers() { - getManager().readHitoeDeviceForDB(); - List resDevice = new ArrayList(); - for (HitoeDevice device:getManager().getRegisterDevices()) { - if (device.getPinCode() != null && mEnableConnectedBtn) { - resDevice.add(device); - } else if (device.getPinCode() == null && !mEnableConnectedBtn) { - resDevice.add(device); - } - } - return resDevice; - } - - /** - * Connect to the BLE device that have heart rate service. - * - * @param device BLE device that have heart rate service. - */ - protected void connectDevice(final HitoeDevice device) { - if (BleUtils.isEnabled(this) && !mCheckDialog) { - mConnectingDevice = device; - showProgressDialog(device.getName()); - getManager().connectHitoeDevice(device); - } - } - - /** - * Disconnect to the BLE device that have heart rate service. - * - * @param device BLE device that have heart rate service. - */ - protected void disconnectDevice(final HitoeDevice device) { - runOnUiThread(() -> { - getManager().disconnectHitoeDevice(device); - HitoeDevice container = findDeviceContainerByAddress(device.getId()); - if (container != null) { - container.setRegisterFlag(false); - mDeviceAdapter.notifyDataSetChanged(); - } - }); - } - - - - /** - * Display the dialog of connecting a ble device. - * - * @param name device name - */ - protected void showProgressDialog(final String name) { - dismissProgressDialog(); - - Resources res = getResources(); - String title = res.getString(R.string.hitoe_setting_connecting_title); - String message = res.getString(R.string.hitoe_setting_connecting_message, name); - mProgressDialogFragment = ProgressDialogFragment.newInstance(title, message); - mProgressDialogFragment.show(getSupportFragmentManager(), "dialog"); - mCheckDialog = true; - } - - /** - * Dismiss the dialog of connecting a ble device. - */ - protected void dismissProgressDialog() { - mCheckDialog = false; - mHandler.removeCallbacksAndMessages(null); - - if (mProgressDialogFragment != null) { - mProgressDialogFragment.dismiss(); - mProgressDialogFragment = null; - } - } - - /** - * Display the error dialog of not connect device. - * - * @param name device name - */ - protected void showErrorDialogNotConnect(final String name) { - Resources res = getResources(); - String message; - if (name == null) { - message = res.getString(R.string.hitoe_setting_dialog_error_message, - getString(R.string.hitoe_setting_default_name)); - } else { - message = res.getString(R.string.hitoe_setting_dialog_error_message, name); - } - showErrorDialog(message); - } - - - /** - * Display the error dialog. - * - * @param message error message - */ - protected void showErrorDialog(final String message) { - dismissErrorDialog(); - try { - Resources res = getResources(); - String title = res.getString(R.string.hitoe_setting_dialog_error_title); - mErrorDialogFragment = ErrorDialogFragment.newInstance(title, message); - mErrorDialogFragment.show(getSupportFragmentManager(), "error_dialog"); - mErrorDialogFragment.setOnDismissListener((dialog) -> { - mErrorDialogFragment = null; - }); - } catch (IllegalStateException e) { - if (BuildConfig.DEBUG) { - e.printStackTrace(); - } - } - } - - /** - * Dismiss the error dialog. - */ - protected void dismissErrorDialog() { - try { - if (mErrorDialogFragment != null) { - mErrorDialogFragment.dismiss(); - mErrorDialogFragment = null; - } - } catch (IllegalStateException e) { - if (BuildConfig.DEBUG) { - e.printStackTrace(); - } - - } - } - - - /** - * Look for a DeviceContainer with the given address. - * - * @param address address of device - * @return The DeviceContainer that has the given address or null - */ - protected HitoeDevice findDeviceContainerByAddress(final String address) { - int size = mDeviceAdapter.getCount(); - for (int i = 0; i < size; i++) { - HitoeDevice container = mDeviceAdapter.getItem(i); - if (container.getId().equalsIgnoreCase(address)) { - return container; - } - } - return null; - } - - - /** - * Returns true if this address contains the mDeviceAdapter. - * - * @param address address of device - * @return true if address is an element of mDeviceAdapter, false otherwise - */ - protected boolean containAddressForAdapter(final String address) { - int size = mDeviceAdapter.getCount(); - for (int i = 0; i < size; i++) { - HitoeDevice container = mDeviceAdapter.getItem(i); - if (container.getId().equals(address)) { - return true; - } - } - return false; - } - - /** - * Returns true if this address contains the mDeviceAdapter. - * - * @param address address of device - * @return true if address is an element of mDeviceAdapter, false otherwise - */ - protected boolean containAddressForList(final String address) { - List devices = createDeviceContainers(); - int size = devices.size(); - for (int i = 0; i < size; i++) { - HitoeDevice container = devices.get(i); - if (container.getId().equals(address)) { - return true; - } - } - return false; - } - - /** - * Device List's adapter. - */ - protected class DeviceAdapter extends ArrayAdapter { - /** - * Adapter inflater. - */ - private LayoutInflater mInflater; - - /** - * Constructor. - * @param context context - * @param objects hitoe's list - */ - public DeviceAdapter(final Context context, final List objects) { - super(context, 0, objects); - mInflater = (LayoutInflater) context.getSystemService( - Context.LAYOUT_INFLATER_SERVICE); - } - - @Override - public View getView(final int position, View convertView, final ViewGroup parent) { - if (convertView == null) { - convertView = mInflater.inflate(R.layout.item_hitoe_device, null); - } - - final HitoeDevice device = getItem(position); - String name = device.getName(); - if (device.isRegisterFlag()) { - if (getManager().containConnectedHitoeDevice(device.getId())) { - name += "\n" + getResources().getString(R.string.hitoe_setting_online); - } else { - name += "\n" + getResources().getString(R.string.hitoe_setting_offline); - } - } - - TextView nameView = convertView.findViewById(R.id.device_name); - nameView.setText(name); - - TextView addressView = convertView.findViewById(R.id.device_address); - addressView.setText(device.getId()); - final Button btn = convertView.findViewById(R.id.btn_connect_device); - - if (mEnableConnectedBtn) { - btn.setVisibility(View.VISIBLE); - - if (device.isRegisterFlag()) { - btn.setBackgroundResource(R.drawable.button_red); - btn.setText(R.string.hitoe_setting_disconnect); - } else { - btn.setBackgroundResource(R.drawable.button_blue); - btn.setText(R.string.hitoe_setting_connect); - } - btn.setOnClickListener((v) -> { - for (HitoeDevice d: getManager().getRegisterDevices()) { - if (!d.getName().equals(device.getName()) && d.isRegisterFlag()) { - getManager().disconnectHitoeDevice(d); - } - } - - if (device.isRegisterFlag()) { - btn.setBackgroundResource(R.drawable.button_blue); - btn.setText(R.string.hitoe_setting_connect); - disconnectDevice(device); - } else { - if (device.getPinCode() == null) { - final Resources res = getResources(); - PinCodeDialogFragment pinDialog = PinCodeDialogFragment.newInstance(); - pinDialog.show(getSupportFragmentManager(), "pin_dialog"); - pinDialog.setOnPinCodeListener((pin) -> { - if (pin.isEmpty()) { - showErrorDialog( - res.getString(R.string.hitoe_setting_dialog_error_message02)); - return; - } - device.setPinCode(pin); - connectDevice(device); - }); - } else { - connectDevice(device); - } - mHandler.postDelayed(() -> { - if (mCheckDialog) { - device.setPinCode(null); - runOnUiThread(() -> { - dismissProgressDialog(); - Resources res = getResources(); - showErrorDialog( - res.getString(R.string.hitoe_setting_dialog_error_message04)); - }); - } - }, HitoeConstants.DISCOVERY_CYCLE_TIME); - - } - }); - } else { - btn.setVisibility(View.GONE); - } - return convertView; - } - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/package-info.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/package-info.java deleted file mode 100755 index 48e9c799dc..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/activity/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/* -org.deviceconnect.android.deviceplugin.hitoe.activity -Copyright (c) 2016 NTT DOCOMO,INC. -Released under the MIT license -http://opensource.org/licenses/mit-license.php - */ - -/** - * Activity of this device plug-in. - */ -package org.deviceconnect.android.deviceplugin.hitoe.activity; - diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/AccelerationData.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/AccelerationData.java deleted file mode 100644 index 75cc27fa0b..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/AccelerationData.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - AccelerationData - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - -import android.os.Bundle; - -import org.deviceconnect.android.profile.DeviceOrientationProfile; - -/** - * This class is information of Acceleration. - * @author NTT DOCOMO, INC. - */ -public class AccelerationData { - /** Acceleration X. */ - private double mAccelX; - /** Acceleration Y. */ - private double mAccelY; - /** Acceleration Z. */ - private double mAccelZ; - /** Acceleration Gravity X. */ - private double mGravityX; - /** Acceleration Gravity Y. */ - private double mGravityY; - /** Acceleration Gravity Z. */ - private double mGravityZ; - /** Gyro X. */ - private double mGyroAlpha; - /** Gyro Y. */ - private double mGyroBeta; - /** Gyro Z. */ - private double mGyroGamma; - /** TimeStamp. */ - private long mInterval; - - /** - * Constructor. - */ - public AccelerationData() { - mInterval = 0; - } - - - /** - * Get Acceleration X. - * @return Acceleration X - */ - public double getAccelX() { - return mAccelX; - } - - /** - * Set Acceleration X. - * @param accelX Acceleration X - */ - public void setAccelX(final double accelX) { - mAccelX = accelX; - } - - /** - * Get Acceleration Y. - * @return Acceleration Y - */ - public double getAccelY() { - return mAccelY; - } - - /** - * Set Acceleration Y. - * @param accelY Acceleration Y - */ - public void setAccelY(final double accelY) { - mAccelY = accelY; - } - - /** - * Get Acceleration Z. - * @return Acceleration Z - */ - public double getAccelZ() { - return mAccelZ; - } - - /** - * Set Acceleration Z. - * @param accelZ Acceleration Z - */ - public void setAccelZ(final double accelZ) { - mAccelZ = accelZ; - } - - /** - * Get Acceleration Gravity X. - * @return Acceleration Gravity X - */ - public double getGravityX() { - return mGravityX; - } - - /** - * Set Acceleration Gravity X. - * @param gravityX Acceleration gravity X - */ - public void setGravityX(final double gravityX) { - mGravityX = gravityX; - } - - /** - * Get Acceleration Gravity Y. - * @return Acceleration Gravity Y - */ - public double getGravityY() { - return mGravityY; - } - - /** - * Set Acceleration Gravity Y. - * @param gravityY Acceleration Gravity Y - */ - public void setGravityY(final double gravityY) { - mGravityY = gravityY; - } - - /** - * Get Acceleration Gravity Z. - * @return Acceleration Gravity Z - */ - public double getGravityZ() { - return mGravityZ; - } - - /** - * Set Acceleration Gravity Z. - * @param gravityZ Acceleration Gravity Z - */ - public void setGravityZ(final double gravityZ) { - mGravityZ = gravityZ; - } - - /** - * Get Gyro Alpha. - * @return Gyro Alpha - */ - public double getGyroAlpha() { - return mGyroAlpha; - } - - /** - * Set Gyro alpha. - * @param gyroAlpha Gyro Alpha - */ - public void setGyroAlpha(final double gyroAlpha) { - mGyroAlpha = gyroAlpha; - } - - /** - * Get Gyro Beta. - * @return Gyro Beta - */ - public double getGyroBeta() { - return mGyroBeta; - } - - /** - * Set Gyro Beta. - * @param gyroBeta Gyro Beta - */ - public void setGyroBeta(final double gyroBeta) { - mGyroBeta = gyroBeta; - } - - /** - * Get Gyro Gamma. - * @return Gyro Gamma - */ - public double getGyroGamma() { - return mGyroGamma; - } - - /** - * Set Gyro Gamma. - * @param gyroGamma Gyro Gamma - */ - public void setGyroGamma(final double gyroGamma) { - mGyroGamma = gyroGamma; - } - - /** - * Get TimeStamp. - * @return timestamp - */ - public long getTimeStamp() { - return mInterval; - } - - /** - * Set TimeStamp. - * @param timeStamp timestamp - */ - public void setTimeStamp(final long timeStamp) { - mInterval = timeStamp; - } - - /** - * To Bundle. - * @return bundle - */ - public Bundle toBundle() { - Bundle orientation = new Bundle(); - - Bundle ag = new Bundle(); - DeviceOrientationProfile.setX(ag, mAccelX * 9.81); - DeviceOrientationProfile.setY(ag, mAccelY * 9.81); - DeviceOrientationProfile.setZ(ag, mAccelZ * 9.81); - - DeviceOrientationProfile.setAcceleration(orientation, ag); - DeviceOrientationProfile.setInterval(orientation, mInterval); - return orientation; - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HeartData.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HeartData.java deleted file mode 100644 index 1b474e3840..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HeartData.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - RateData - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - -import android.os.Bundle; - -import org.deviceconnect.android.profile.HealthProfile; - -/** - * This class is information of HeartRate or RRI or Energy Expended or ECG. - * @author NTT DOCOMO, INC. - */ -public class HeartData { - /** HeartRate type.*/ - public enum HeartRateType { - /** - * HeartRate. - */ - Rate, - /** - * RRI. - */ - RRI, - /** - * Energy Expended. - */ - EnergyExpended, - /** - * ECG. - */ - ECG - - } - - /** HeartRate type. */ - private HeartRateType mHeartRateType; - /** value. */ - private float mValue; - /** MDER Float value. */ - private String mMderFloat; - /** type. */ - private String mType; - /** type code. */ - private int mTypeCode; - /** unit. */ - private String mUnit; - /** unit code. */ - private int mUnitCode; - /** timestamp. */ - private long mTimeStamp; - /** timestamp string. */ - private String mTimeStampString; - - /** - * Constructor. - */ - public HeartData() { - mMderFloat = ""; - mType = ""; - mUnit = ""; - mTimeStampString = ""; - } - - /** - * Get Heart's value. - * @return heart's value - */ - public float getValue() { - return mValue; - } - - /** - * Set Heart's value. - * @param value heart's value - */ - public void setValue(final float value) { - mValue = value; - } - - /** - * Get MDER Float value. - * @return MDER Float value - */ - public String getMderFloat() { - return mMderFloat; - } - - /** - * Set MDER Float value. - * @param mderFloat MDER Float value - */ - public void setMderFloat(final String mderFloat) { - mMderFloat = mderFloat; - } - - /** - * Get Value's type. - * @return value's type - */ - public String getType() { - return mType; - } - - /** - * Set Value's type. - * @param type value's type - */ - public void setType(final String type) { - mType = type; - } - - /** - * Get Value's type code. - * @return Value's type code - */ - public int getTypeCode() { - return mTypeCode; - } - - /** - * Set Value's type code. - * @param typeCode value's type code - */ - public void setTypeCode(final int typeCode) { - mTypeCode = typeCode; - } - - /** - * Get HeartRate's unit. - * @return HeartRate's unit - */ - public String getUnit() { - return mUnit; - } - - /** - * Set HeartRate's unit. - * @param unit HeartRate's unit - */ - public void setUnit(final String unit) { - mUnit = unit; - } - - /** - * Get HeartRate's unit code. - * @return HeartRate's unit code - */ - public int getUnitCode() { - return mUnitCode; - } - - /** - * Set HeartRate's unit code. - * @param unitCode HeartRate's unit code - */ - public void setUnitCode(final int unitCode) { - mUnitCode = unitCode; - } - - /** - * Get HeartRate's timestamp. - * @return HeartRate's timestamp - */ - public long getTimeStamp() { - return mTimeStamp; - } - - /** - * Set HeartRate's timestamp. - * @param timeStamp HeartRate's timestamp - */ - public void setTimeStamp(final long timeStamp) { - mTimeStamp = timeStamp; - } - - /** - * Get HeartRate's timestamp string. - * @return HeartRate's timestamp string - */ - public String getTimeStampString() { - return mTimeStampString; - } - - /** - * Set HeartRate's timestamp string. - * @param timeStampString HeartRate's timestamp string - */ - public void setTimeStampString(final String timeStampString) { - mTimeStampString = timeStampString; - } - - /** - * Get HeartRate type. - * @return HeartRate type - */ - public HeartRateType getHeartRateType() { - return mHeartRateType; - } - - /** - * Set HeartRate type. - * @param heartRateType HeartRate type - */ - public void setHeartRateType(final HeartRateType heartRateType) { - mHeartRateType = heartRateType; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("{\"value\": ").append(mValue).append(", "); - builder.append("\"MderFloat\": ").append(mMderFloat).append(", "); - builder.append("\"type\": ").append(mType).append(", "); - builder.append("\"typeCode\": ").append(mTypeCode).append(", "); - builder.append("\"unit\": ").append(mUnit).append(", "); - builder.append("\"unitCode\": ").append(mUnitCode).append(", "); - builder.append("\"timeStamp\": ").append(mTimeStamp).append(", "); - builder.append("\"timeStampString\": ").append(mTimeStampString).append("} "); - return builder.toString(); - } - - /** - * To Bundle. - * @return Bundle - */ - public Bundle toBundle() { - Bundle heart = new Bundle(); - HealthProfile.setValue(heart, mValue); - HealthProfile.setMDERFloat(heart, mMderFloat); - HealthProfile.setType(heart, mType); - HealthProfile.setTypeCode(heart, mTypeCode); - HealthProfile.setUnit(heart, mUnit); - HealthProfile.setUnitCode(heart, mUnitCode); - HealthProfile.setTimestamp(heart, mTimeStamp); - HealthProfile.setTimestampString(heart, mTimeStampString); - return heart; - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HeartRateData.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HeartRateData.java deleted file mode 100644 index 922b706206..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HeartRateData.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - HeartRateData - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - -/** - * This class is information of a Heart Rate. - * @author NTT DOCOMO, INC. - */ -public class HeartRateData { - /** Health device info. */ - private TargetDeviceData mTarget; - /** Health device's heartrate data. */ - private HeartData mHeartRate; - /** Health device's RRInterval. */ - private HeartData mRRInterval; - /** Health device's EnergyExpended. */ - private HeartData mEnergyExpended; - /** Health device's ECG. */ - private HeartData mECG; - - /** - * Get Health device's info. - * @return Health device's info - */ - public TargetDeviceData getDevice() { - return mTarget; - } - - /** - * Set Health device's info. - * @param target Health device's info - */ - public void setDevice(final TargetDeviceData target) { - mTarget = target; - } - - /** - * Get Health device's heartrate data. - * @return Health device's heartrate data - */ - public HeartData getHeartRate() { - return mHeartRate; - } - - /** - * Set Health device's heartrate data. - * @param heartRate Health device's heartrate data - */ - public void setHeartRate(final HeartData heartRate) { - mHeartRate = heartRate; - } - - /** - * Get Health device's EnergyExpended data. - * @return Health device's Energy Expended data - */ - public HeartData getEnergyExpended() { - return mEnergyExpended; - } - - /** - * Set Health device's Energy Expended data. - * @param energyExpended Health device's Energy Expended data - */ - public void setEnergyExpended(final HeartData energyExpended) { - mEnergyExpended = energyExpended; - } - - /** - * Get Health device's RRInterval data. - * @return Health device's RRInterval data - */ - public HeartData getRRInterval() { - return mRRInterval; - } - - - /** - * Set Health device's RRInterval data. - * @param rrInterval Health device's RRInterval data - */ - public void setRRInterval(final HeartData rrInterval) { - mRRInterval = rrInterval; - } - /** - * Set Health device's ecg data. - * @param ecg Health device's ecg data - */ - public void setECG(final HeartData ecg) { - mECG = ecg; - } - /** - * Get Health device's ECG data. - * @return Health device's ECG data - */ - public HeartData getECG() { - return mECG; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("{\"heart\":{"); - builder.append("\"device\":").append(mTarget.toString()).append(", "); - builder.append("\"rate\":").append(mHeartRate.toString()).append(", "); - builder.append("\"rr\":").append(mRRInterval.toString()).append(", "); - builder.append("\"energy\":").append(mEnergyExpended.toString()).append("}} "); - return builder.toString(); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HitoeConstants.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HitoeConstants.java deleted file mode 100755 index e2c595d946..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HitoeConstants.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - HitoeConsts - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - -/** - * Hitoe's constant. - * @author NTT DOCOMO, INC. - */ -public final class HitoeConstants { - /** - * Private constructor. - */ - private HitoeConstants() { - } - - /** - * Line seperator. - */ - public static final String BR = System.getProperty("line.separator"); - /** VB. */ - public static final String VB = "\\|"; - /** Comma. */ - public static final String COMMA = ","; - /** Colon. */ - public static final String COLON = ":"; - - /** Raw data prefix.*/ - public static final String RAW_DATA_PREFFIX = "raw."; - /** Ba data prefix. */ - public static final String BA_DATA_PREFFIX = "ba."; - /** Ex data prefix. */ - public static final String EX_DATA_PREFFIX = "ex."; - - /** Raw connection prefix. */ - public static final String RAW_CONNECTION_PREFFIX = "R"; - /** Ba connection prefix. */ - public static final String BA_CONNECTION_PREFFIX = "B"; - /** Ex connection prefix. */ - public static final String EX_CONNECTION_PREFFIX = "E"; - - /** Available ex data string. */ - public static final String AVAILABLE_EX_DATA_STR = "ex.stress\nex.posture\nex.walk\nex.lr_balance"; - /** ECG Chart update cycle time. */ - public static final int ECG_CHART_UPDATE_CYCLE_TIME = 40; - /** Acceleration chart update cycle time. */ - public static final int ACC_CHART_UPDATE_CYCLE_TIME = 100; - /** HeartRate text update cycle time. */ - public static final int HR_TEXT_UPDATE_CYCLE_TIME = 1000; - /** Stress Estimation update cycle time. */ - public static final int LFHF_TEXT_UPDATE_CYCLE_TIME = 1000; - /** Pose Estimation update cycle time. */ - public static final int POSTURE_STATE_UPDATE_CYCLE_TIME = 1000; - /** Discovery Cycle time. */ - public static final int DISCOVERY_CYCLE_TIME = 30000; - - /** Ex posture unit number. */ - public static final int EX_POSTURE_UNIT_NUM = 25; - /** Ex walk unit number. */ - public static final int EX_WALK_UNIT_NUM = 100; - /** Ex Left Right balance unit number. */ - public static final int EX_LR_BALANCE_UNIT_NUM = 250; - - /** getAvailableSensor. */ - public static final int API_ID_GET_AVAILABLE_SENSOR = 0x1010; - /** connect. */ - public static final int API_ID_CONNECT = 0x1020; - /** disconnect. */ - public static final int API_ID_DISCONNECT = 0x1021; - /** getAvailableData. */ - public static final int API_ID_GET_AVAILABLE_DATA = 0x1030; - /** addReciever. */ - public static final int API_ID_ADD_RECIVER = 0x1040; - /** removeReciever. */ - public static final int API_ID_REMOVE_RECEIVER = 0x1041; - /** getStatus. */ - public static final int API_ID_GET_STATUS = 0x1090; - - /** Response id for success. */ - public static final int RES_ID_SUCCESS = 0x00; - /** Response id for failure. */ - public static final int RES_ID_FAILURE = 0x01; - /** Response id for continue. */ - public static final int RES_ID_CONTINUE = 0x05; - /** Response id for api busy. */ - public static final int RES_ID_API_BUSY = 0x09; - /** Response id for invalid argument. */ - public static final int RES_ID_INVALID_ARG = 0x10; - /** Response id for invalid parameter. */ - public static final int RES_ID_INVALID_PARAM = 0x30; - /** Response id for sensor connect. */ - public static final int RES_ID_SENSOR_CONNECT = 0x60; - /** Response id for sensor connect failure. */ - public static final int RES_ID_SENSOR_CONNECT_FAILURE = 0x61; - /** Response id for sensor connect notice. */ - public static final int RES_ID_SENSOR_CONNECT_NOTICE = 0x62; - /** Response id for sensor unauthorized. */ - public static final int RES_ID_SENSOR_UNAUTHORIZED = 0x63; - /** Response id for sensor disconnect. */ - public static final int RES_ID_SENSOR_DISCONECT = 0x65; - /** Response id for sensor disconnect notice. */ - public static final int RES_ID_SENSOR_DISCONECT_NOTICE = 0x66; - - /** Get Available sensor device type. */ - public static final String GET_AVAILABLE_SENSOR_DEVICE_TYPE = "hitoe D01"; - /** Get Available sensor parameter search time. */ - public static final int GET_AVAILABLE_SENSOR_PARAM_SEARCH_TIME = 5000; - - /** Connect disconnect retry time. */ - public static final int CONNECT_DISCONNECT_RETRY_TIME = 1000; - /** Connect disconnect retry count. */ - public static final int CONNECT_DISCONNECT_RETRY_COUNT = 3; - /** Connect no packet retry time. */ - public static final int CONNECT_NOPACKET_RETRY_TIME = 5000; - - /** Add receiver parameter ECG sampling interval. */ - public static final int ADD_RECEIVER_PARAM_ECG_SAMPLING_INTERVAL = 40; - /** Add receiver parameter Acceleration sampling interval. */ - public static final int ADD_RECEIVER_PARAM_ACC_SAMPLING_INTERVAL = 40; - /** Add receiver patameter RRI sampling interval. */ - public static final int ADD_RECEIVER_PARAM_RRI_SAMPLING_INTERVAL = 1000; - /** Add receiver parameter heartrate sampling interval. */ - public static final int ADD_RECEIVER_PARAM_HR_SAMPLING_INTERVAL = 1000; - /** Add receiver parameter battery sampling interval. */ - public static final int ADD_RECEIVER_PARAM_BAT_SAMPLING_INTERVAL = 10000; - - /** Add receiver parameter Ba samling interval. */ - public static final int ADD_RECEIVER_PARAM_BA_SAMPLING_INTERVAL = 4000; - /** Add receiver parameter Ba ECG Threshold. */ - public static final int ADD_RECEIVER_PARAM_BA_ECG_THRESHHOLD = 250; - /** Add receiver parameter Ba skip count. */ - public static final int ADD_RECEIVER_PARAM_BA_SKIP_COUNT = 50; - /** Add receiver parameter Ba RRI min. */ - public static final int ADD_RECEIVER_PARAM_BA_RRI_MIN = 240; - /** Add receiver parameter Ba RRI max. */ - public static final int ADD_RECEIVER_PARAM_BA_RRI_MAX = 3999; - /** Add receiver parameter Ba sample count. */ - public static final int ADD_RECEIVER_PARAM_BA_SAMPLE_COUNT = 20; - /** Add receiver parameter Ba RRI input. */ - public static final String ADD_RECEIVER_PARAM_BA_RRI_INPUT = "extracted_rri"; - /** Add receiver parameter Ba Frequency sampling interval. */ - public static final int ADD_RECEIVER_PARAM_BA_FREQ_SAMPLING_INTERVAL = 4000; - /** Add receiver parameter Ba frequency sampling window. */ - public static final int ADD_RECEIVER_PARAM_BA_FREQ_SAMPLING_WINDOW = 60; - /** Add receiver parameter Ba RRI sampling rate. */ - public static final int ADD_RECEIVER_PARAM_BA_RRI_SAMPLING_RATE = 8; - /** Add receiver parameter Ba time sampling interval. */ - public static final int ADD_RECEIVER_PARAM_BA_TIME_SAMPLING_INTERVAL = 4000; - /** Add receiver parameter Ba time sampling window. */ - public static final int ADD_RECEIVER_PARAM_BA_TIME_SAMPLING_WINDOW = 60; - - /** Add receiver parameter ex accleration axis xyz. */ - public static final String ADD_RECEIVER_PARAM_EX_ACC_AXIS_XYZ = "XYZ"; - /** Add receiver parameter ex psture window. */ - public static final int ADD_RECEIVER_PARAM_EX_POSTURE_WINDOW = 1; - /** Add receiver parameter ex walk stride. */ - public static final double ADD_RECEIVER_PARAM_EX_WALK_STRIDE = 0.81; - /** Add receiver parameter ex run stride cof. */ - public static final double ADD_RECEIVER_PARAM_EX_RUN_STRIDE_COF = 0.0091; - /** Add receiver parameter ex run stride int. */ - public static final double ADD_RECEIVER_PARAM_EX_RUN_STRIDE_INT = 0.1806; - - /** Back forward threshold. */ - public static final int BACK_FORWARD_THRESHOLD = 30; - /** Left right threshold. */ - public static final int LEFT_RIGHT_THRESHOLD = 20; - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HitoeDBHelper.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HitoeDBHelper.java deleted file mode 100644 index 267228fa62..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HitoeDBHelper.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - HitoeDBHelper - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - -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; - -/** - * This class manage a database. - * @author NTT DOCOMO, INC. - */ -public class HitoeDBHelper { - - /** - * Define the name of the database. - */ - private static final String DB_NAME = "hitoe_device.db"; - - /** - * Define the version of the database. - */ - private static final int DB_VERSION = 1; - /** DB Name. */ - private static final String TBL_NAME = "device_tbl"; - - /** DB column {@value} . */ - private static final String COL_TYPE = "type"; - /** DB column {@value} . */ - private static final String COL_NAME = "name"; - /** DB column {@value} . */ - private static final String COL_ID = "device_id"; - /** DB column {@value} . */ - private static final String COL_CONNECT_MODE = "connect_mode"; - /** DB column {@value} . */ - private static final String COL_PIN_CODE = "pin_code"; - /** DB column {@value} . */ - private static final String COL_REGISTER_FLAG = "register_flag"; - - /** DB Helper. */ - private DBHelper mDBHelper; - - /** - * Constructor. - * @param context application context - */ - public HitoeDBHelper(final Context context) { - mDBHelper = new DBHelper(context); - } - - /** - * Add the device to database. - * @param device device - * @return the row ID of the newly added row, or -1 if an error occurred - */ - public synchronized long addHitoeDevice(final HitoeDevice device) { - List exist = getHitoeDevices(device.getId()); - if (exist.size() > 0) { - updateHitoeDevice(device); - return -2; - } - ContentValues values = new ContentValues(); - values.put(COL_TYPE, device.getType()); - values.put(COL_NAME, device.getName()); - values.put(COL_ID, device.getId()); - values.put(COL_CONNECT_MODE, device.getConnectMode()); - values.put(COL_PIN_CODE, device.getPinCode()); - values.put(COL_REGISTER_FLAG, device.isRegisterFlag() ? 1 : 0); - - SQLiteDatabase db = mDBHelper.getWritableDatabase(); - try { - return db.insert(TBL_NAME, null, values); - } finally { - db.close(); - } - } - - /** - * Update the device in the database. - * @param device device - * @return the number of rows updated - */ - public synchronized int updateHitoeDevice(final HitoeDevice device) { - ContentValues values = new ContentValues(); - values.put(COL_REGISTER_FLAG, device.isRegisterFlag() ? 1 : 0); - - String whereClause = COL_ID + "=?"; - String[] whereArgs = { - device.getId() - }; - - SQLiteDatabase db = mDBHelper.getWritableDatabase(); - try { - return db.update(TBL_NAME, values, whereClause, whereArgs); - } finally { - db.close(); - } - } - - /** - * Delete the device in the database. - * @param device device - * @return the number of rows deleted, 0 otherwise - */ - public synchronized int removeHitoeDevice(final HitoeDevice device) { - String whereClause = COL_ID + "=?"; - String[] whereArgs = { - device.getId() - }; - - SQLiteDatabase db = mDBHelper.getWritableDatabase(); - try { - return db.delete(TBL_NAME, whereClause, whereArgs); - } finally { - db.close(); - } - } - - /** - * Get a list of device in the database. - * @return a list of device - */ - public synchronized List getHitoeDevices(final String id) { - String sql = "SELECT * FROM " + TBL_NAME; - String[] selectionArgs = {}; - if (id != null) { - sql += " WHERE " + COL_ID + "='" + id + "' "; - } - SQLiteDatabase db = mDBHelper.getReadableDatabase(); - Cursor cursor = db.rawQuery(sql, selectionArgs); - - List devices = new ArrayList<>(); - boolean next = cursor.moveToFirst(); - while (next) { - HitoeDevice device = new HitoeDevice(null); - device.setType(cursor.getString(cursor.getColumnIndex(COL_TYPE))); - device.setName(cursor.getString(cursor.getColumnIndex(COL_NAME))); - device.setId(cursor.getString(cursor.getColumnIndex(COL_ID))); - device.setConnectMode(cursor.getString(cursor.getColumnIndex(COL_CONNECT_MODE))); - device.setPinCode(cursor.getString(cursor.getColumnIndex(COL_PIN_CODE))); - device.setRegisterFlag(cursor.getInt(cursor.getColumnIndex(COL_REGISTER_FLAG)) == 1); - devices.add(device); - next = cursor.moveToNext(); - } - return devices; - } - - /** - * SQL DB Helper. - */ - private static class DBHelper extends SQLiteOpenHelper { - /** - * Constructor. - * @param context Context - */ - public 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_NAME); - createDB(db); - } - - /** - * Create DB's sql. - * @param db DB - */ - private void createDB(final SQLiteDatabase db) { - String sql = "CREATE TABLE " + TBL_NAME + " (" - + BaseColumns._ID + " INTEGER PRIMARY KEY, " - + COL_TYPE + " TEXT, " - + COL_NAME + " TEXT, " - + COL_ID + " TEXT, " - + COL_CONNECT_MODE + " TEXT, " - + COL_PIN_CODE + " TEXT, " - + COL_REGISTER_FLAG + " INTEGER" - + ");"; - db.execSQL(sql); - } - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HitoeDevice.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HitoeDevice.java deleted file mode 100644 index 5bd92e30e7..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HitoeDevice.java +++ /dev/null @@ -1,415 +0,0 @@ -/* - HitoeDevice - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class is information of a hitoe device. - * @author NTT DOCOMO, INC. - */ -public class HitoeDevice { - /** device type. */ - private String mType; - /** device name. */ - private String mName; - /** device id. */ - private String mId = "-1"; - /** device connect mode. */ - private String mConnectMode; - /** device pin code. */ - private String mPin; - /** device register flag. */ - private boolean mRegisterFlag; - /** memory setting. */ - private String mMemorySetting; - /** available raw datalist. */ - private List mAvailableRawDataList = new ArrayList<>(); - /** available ba datalist. */ - private List mAvailableBaDataList = new ArrayList<>(); - /** available ex datalist. */ - private List mAvailableExDataList = new ArrayList<>(); - - /** session id. */ - private String mSessionId; - /** Raw connection id. */ - private String mRawConnectionId; - /** Ba connection id. */ - private String mBaConnectionId; - /** Ex connection id. */ - private String mExConnectionId; - /** ex connection list. */ - private List mExConnectionList = new ArrayList<>(); - - /** Response id. */ - private int mResponseId; - - /** - * Constructor. - * @param raw raw data - */ - public HitoeDevice(final String raw) { - setData(raw); - String[] dataList = HitoeConstants.AVAILABLE_EX_DATA_STR.split("\n"); - for (int i = 0; i < dataList.length; i++) { - mAvailableExDataList.add(dataList[i]); - } - } - /** - * Get Device type. - * @return Device type - */ - public String getType() { - return mType; - } - - /** - * Set Device Type. - * @param type Device Type - */ - public void setType(final String type) { - mType = type; - } - - /** - * Get device id. - * @return device id - */ - public String getId() { - return mId; - } - - /** - * Set device id. - * @param id device id - */ - public void setId(final String id) { - mId = id; - } - - /** - * Get device Name. - * @return device name - */ - public String getName() { - return mName; - } - - /** - * Set device name. - * @param name device name - */ - public void setName(final String name) { - mName = name; - } - - /** - * Get pin code. - * @return pin code - */ - public String getPinCode() { - return mPin; - } - - /** - * Set pin code. - * @param pin pin code - */ - public void setPinCode(final String pin) { - mPin = pin; - } - - /** - * Get connect mode. - * @return connect mode - */ - public String getConnectMode() { return mConnectMode; } - - /** - * Set connect mdoe. - * @param connectMode connect mode - */ - public void setConnectMode(final String connectMode) { mConnectMode = connectMode; } - - /** - * Is register flag. - * @return register flag - */ - public boolean isRegisterFlag() { - return mRegisterFlag; - } - - /** - * Set register flag. - * @param registerFlag register flag - */ - public void setRegisterFlag(final boolean registerFlag) { - mRegisterFlag = registerFlag; - } - - /** - * Get Memory setting. - * @return memory setting - */ - public String getMemorySetting() { - return mMemorySetting; - } - - /** - * Set memory setting. - * @param memorySetting memory setting - */ - public void setMemorySetting(final String memorySetting) { - mMemorySetting = memorySetting; - } - - /** - * Get available raw data list. - * @return available raw data list - */ - public List getAvailableRawDataList() { - return mAvailableRawDataList; - } - - /** - * Set available raw data list. - * @param availableRawDataList available raw data list - */ - public void setAvailableRawDataList(final List availableRawDataList) { - mAvailableRawDataList = availableRawDataList; - } - - /** - * Get Available ba data list. - * @return available ba data list - */ - public List getAvailableBaDataList() { - return mAvailableBaDataList; - } - - /** - * Set available ba data list. - * @param availableBaDataList available ba data list - */ - public void setAvailableBaDataList(final List availableBaDataList) { - mAvailableBaDataList = availableBaDataList; - } - - /** - * Get available Ex data list. - * @return available ex data list - */ - public List getAvailableExDataList() { - return mAvailableExDataList; - } - - /** - * Set available ex data list. - * @param availableExDataList available ex data list - */ - public void setAvailableExDataList(final List availableExDataList) { - mAvailableExDataList = availableExDataList; - } - - /** - * Get session id. - * @return session id - */ - public String getSessionId() { - return mSessionId; - } - - /** - * Set session id. - * @param sessionId session id - */ - public void setSessionId(final String sessionId) { - mSessionId = sessionId; - } - - /** - * Get raw connection id. - * @return Raw connection id - */ - public String getRawConnectionId() { - return mRawConnectionId; - } - - /** - * Set raw connection id. - * @param rawConnectionId raw connection id - */ - public void setRawConnectionId(final String rawConnectionId) { - mRawConnectionId = rawConnectionId; - } - - /** - * Get ba connection id. - * @return ba connection id - */ - public String getBaConnectionId() { - return mBaConnectionId; - } - - /** - * Set ba connection id. - * @param baConnectionId ba connection id - */ - public void setBaConnectionId(final String baConnectionId) { - mBaConnectionId = baConnectionId; - } - - /** - * Get ex connection id. - * @return ex connection id - */ - public String getExConnectionId() { - return mExConnectionId; - } - - /** - * Set ex connection id. - * @param exConnectionId ex connection id - */ - public void setExConnectionId(final String exConnectionId) { - mExConnectionId = exConnectionId; - } - - /** - * Get Ex connection list. - * @return ex connection list - */ - public List getExConnectionList() { - return mExConnectionList; - } - - /** - * Set ex connection list. - * @param exConnectionList ex connection list - */ - public void setExConnectionList(final ArrayList exConnectionList) { - this.mExConnectionList = exConnectionList; - } - /** - * Get Response id. - * @return response id - */ - public int getResponseId() { - return mResponseId; - } - - /** - * Set Response id. - * @param responseId response id - */ - public void setResponseId(final int responseId) { - mResponseId = responseId; - } - - - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("{\"type\": ").append(mType).append(", "); - builder.append("\"name\": ").append(mName).append(", "); - builder.append("\"id\": ").append(mId).append(", "); - builder.append("\"address\": ").append(mPin).append(", "); - builder.append("\"connectMode\": ").append(mConnectMode).append(", "); - builder.append("\"registerFlag\": ").append(mRegisterFlag).append("} "); - return builder.toString(); - } - - /** - * Set Data. - * @param val raw data - */ - public void setData(final String val) { - - if (val == null) { - - return; - } - - String[] list = val.split(HitoeConstants.COMMA, -1); - this.mType = list[0]; - this.mName = list[1]; - this.mId = list[2]; - this.mConnectMode = list[3]; - if (list[4].equals("memory_setting")) { - this.mMemorySetting = list[4]; - } - } - - - /** - * Set available data. - * @param availableData available data - */ - public void setAvailableData(final String availableData) { - - String[] dataList = availableData.split(HitoeConstants.BR); - for (int i = 0; i < dataList.length; i++) { - if (dataList[i].startsWith(HitoeConstants.RAW_DATA_PREFFIX)) { - - if (!mAvailableRawDataList.contains(dataList[i])) { - - mAvailableRawDataList.add(dataList[i]); - } - } else if (dataList[i].startsWith(HitoeConstants.BA_DATA_PREFFIX)) { - - if (!mAvailableBaDataList.contains(dataList[i])) { - - mAvailableBaDataList.add(dataList[i]); - } - } else if (dataList[i].startsWith(HitoeConstants.EX_DATA_PREFFIX)) { - - if (!mAvailableExDataList.contains(dataList[i])) { - - mAvailableExDataList.add(dataList[i]); - } - } - } - } - - /** - * Set Connection Id. - * @param connectionId connection id - */ - public void setConnectionId(final String connectionId) { - - if (connectionId.startsWith(HitoeConstants.RAW_CONNECTION_PREFFIX)) { - - mRawConnectionId = connectionId; - } else if (connectionId.startsWith(HitoeConstants.BA_CONNECTION_PREFFIX)) { - - mBaConnectionId = connectionId; - } else if (connectionId.startsWith(HitoeConstants.EX_CONNECTION_PREFFIX)) { - getExConnectionList().add(connectionId); - } - } - - - /** - * Remove connection id. - * @param connectionId connection id - */ - public void removeConnectionId(final String connectionId) { - - if (mRawConnectionId != null && mRawConnectionId.equals(connectionId)) { - - mRawConnectionId = null; - } else if (mBaConnectionId != null && mBaConnectionId.equals(connectionId)) { - - mBaConnectionId = null; - } else if (mExConnectionList != null && mExConnectionList.contains(connectionId)) { - - mExConnectionList.remove(connectionId); - } - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HitoeManager.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HitoeManager.java deleted file mode 100644 index c0dbd6daa0..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/HitoeManager.java +++ /dev/null @@ -1,1760 +0,0 @@ -/* - HitoeManager - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothDevice; -import android.content.Context; -import android.os.Handler; -import android.util.Log; -import android.widget.Toast; - -import org.deviceconnect.android.deviceplugin.hitoe.BuildConfig; -import org.deviceconnect.android.deviceplugin.hitoe.util.RawDataParseUtils; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.ReentrantLock; - -import jp.ne.docomo.smt.dev.hitoetransmitter.HitoeSdkAPI; -import jp.ne.docomo.smt.dev.hitoetransmitter.sdk.HitoeSdkAPIImpl; - -/** - * This class manages a Hitoe devices. - * @author NTT DOCOMO, INC. - */ -public class HitoeManager { - /** Log's tag name. */ - private static final String TAG = "HitoeManager"; - - /** - * Instance of ScheduledExecutorService. - */ - private ScheduledExecutorService mExecutor = Executors.newSingleThreadScheduledExecutor(); - - /** - * ScheduledFuture of scan timer. - */ - private ScheduledFuture mScanTimerFuture; - - /** - * Defines a delay 1 second at first execution. - */ - private static final long SCAN_FIRST_WAIT_PERIOD = 30 * 1000; - - /** - * Defines a period 10 seconds between successive executions. - */ - private static final long SCAN_WAIT_PERIOD = 20 * 1000; - - /** - * Stops scanning after 1 second. - */ - private static final long SCAN_PERIOD = 2000; - /** Wait 5000 msec. */ - private static final int CONNECTING_RETRY_WAIT = 500; - /** Connecting retry count. */ - private static final int CONNECTING_RETRY_COUNT = 10; - /** Device scanning flag. */ - private boolean mScanning; - /** Device scanning running. */ - private boolean mIsCallbackRunning; - - /** Device scan timestamp. */ - private final Map mNowTimestamps; - /** Handler. */ - private Handler mHandler = new Handler(); - - /** - * Application context. - */ - private Context mContext; - /** - * Instance of {@link HitoeDBHelper}. - */ - private HitoeDBHelper mDBHelper; - /** - * Hitoe SDK API. - */ - private HitoeSdkAPI mHitoeSdkAPI; - - // ------------------------------------ - // Listener. - // ------------------------------------ - - /** Hitoe Discovery Listener. */ - private List mConnectionListeners; - /** Notify HeartRate data listener. */ - private OnHitoeHeartRateEventListener mHeartRataListener; - /** Notify Accleration data listener. */ - private OnHitoeDeviceOrientationEventListener mDeviceOrientationListener; - /** Notify ECG data listener. */ - private OnHitoeECGEventListener mECGListener; - /** Notify Pose Estimation data listener. */ - private OnHitoePoseEstimationEventListener mPoseEstimationListener; - /** Notify Stress Estimation data listener. */ - private OnHitoeStressEstimationEventListener mStressEstimationListener; - /** Notify Walk state data listener. */ - private OnHitoeWalkStateEventListener mWalkStateListener; - - - /** Registered Hitoe devices .*/ - private final List mRegisterDevices; - - /** HeartRate Datas. */ - private final Map mHRData; - /** Acceleration Datas. */ - private final Map mAccelData; - /** ECG Datas. */ - private final Map mECGData; - /** Pose Estimation datas. */ - private final Map mPoseEstimationData; - /** Stress Estimation datas. */ - private final Map mStressEstimationData; - /** Walk State datas. */ - private final Map mWalkStateData; - - /** Save data for extended analysis. */ - private ArrayList mListForEx; - /** Lock for the extension analysis. */ - private ReentrantLock mLockForEx; - /** Expanded analysis flag. */ - private boolean mFlagForEx; - /** Acceleration's interval. */ - private long mInterval = 0; - /** Temporary storage data for pose estimation. */ - private ArrayList mListForPosture; - /** Lock for pose estimation. */ - private ReentrantLock mLockForPosture; - /** Temporary storage data for walking state estimation. */ - private ArrayList mListForWalk; - /** Lock for walking state estimation. */ - private ReentrantLock mLockForWalk; - /** Temporary storage data for the left and right balance estimation. */ - private ArrayList mListForLRBalance; - /** Lock for the left and right balance estimation. */ - private ReentrantLock mLockForLRBalance; - /** Hitoe API Callback. */ - HitoeSdkAPI.APICallback mAPICallback = (apiId, responseId, responseString) -> { - - final StringBuilder messageTextBuilder = new StringBuilder(); - - if (BuildConfig.DEBUG) { - Log.d(TAG, "CbCallback:apiId=" + String.valueOf(apiId) + ",responseId=" - + String.valueOf(responseId) + ",resonseObject=" - + responseString.replace(HitoeConstants.BR, HitoeConstants.VB)); - } - switch (apiId) { - case HitoeConstants.API_ID_GET_AVAILABLE_SENSOR: - notifyDiscoveryHitoeDevice(responseId, responseString); - break; - case HitoeConstants.API_ID_CONNECT: - notifyConnectHitoeDevice(responseId, responseString); - break; - case HitoeConstants.API_ID_DISCONNECT: - // disconnect sensor - try{ - - mLockForEx.lock(); - - mListForEx.clear(); - mFlagForEx = false; - }finally { - - mLockForEx.unlock(); - } - break; - case HitoeConstants.API_ID_GET_AVAILABLE_DATA: - notifyAvailableData(responseId, responseString); - break; - case HitoeConstants.API_ID_ADD_RECIVER: - notifyAddReceiver(responseId, responseString); - break; - case HitoeConstants.API_ID_REMOVE_RECEIVER: - - notifyRemoveReceiver(responseId, responseString); - break; - case HitoeConstants.API_ID_GET_STATUS: - break; - default: - if (BuildConfig.DEBUG) { - Log.e(TAG, "etc state"); - } - break; - } - }; - - - - - /** - * Data receiver. - */ - HitoeSdkAPI.DataReceiverCallback mDataReceiverCallback = new HitoeSdkAPI.DataReceiverCallback() { - @Override - public void onDataReceive(final String connectionId, final int responseId, - final String dataKey, final String rawData) { - - int pos = getPosForConnectionId(connectionId); - if (pos == -1) { - if (BuildConfig.DEBUG) { - Log.d(TAG, "no connectionId"); - } - return; - } - HitoeDevice receiveDevice = mRegisterDevices.get(pos); - if (receiveDevice.getSessionId() == null) { - return; - } - - if (dataKey.equals("raw.ecg")) { - extractHealth(HeartData.HeartRateType.ECG, rawData, receiveDevice); - } else if (dataKey.equals("raw.acc")) { - analyzeAccelerationData(rawData, receiveDevice); - AccelerationData currentAccel = mAccelData.get(receiveDevice); - if (currentAccel == null) { - currentAccel = new AccelerationData(); - } - currentAccel = RawDataParseUtils.parseAccelerationData(currentAccel, rawData); - mAccelData.put(receiveDevice, currentAccel); - } else if (dataKey.equals("raw.rri")) { - extractHealth(HeartData.HeartRateType.RRI, rawData, receiveDevice); - } else if (dataKey.equals("raw.bat")) { - extractBattery(rawData, receiveDevice); - } else if (dataKey.equals("raw.hr")) { - extractHealth(HeartData.HeartRateType.Rate, rawData, receiveDevice); - } else if (dataKey.equals("ba.freq_domain")) { - parseFreqDomain(receiveDevice, rawData); - } else if (dataKey.equals("ex.stress")) { - StressEstimationData stress = RawDataParseUtils.parseStressEstimation(rawData); - mStressEstimationData.put(receiveDevice, stress); - } else if (dataKey.equals("ex.posture")) { - PoseEstimationData pose = RawDataParseUtils.parsePoseEstimation(rawData); - mPoseEstimationData.put(receiveDevice, pose); - } else if (dataKey.equals("ex.walk")) { - WalkStateData walk = mWalkStateData.get(receiveDevice); - if (walk == null) { - walk = new WalkStateData(); - } - walk = RawDataParseUtils.parseWalkState(walk, rawData); - mWalkStateData.put(receiveDevice, walk); - } else if (dataKey.equals("ex.lr_balance")) { - WalkStateData walk = mWalkStateData.get(receiveDevice); - if (walk == null) { - walk = new WalkStateData(); - } - walk = RawDataParseUtils.parseWalkStateForBalance(walk, rawData); - mWalkStateData.put(receiveDevice, walk); - } - - if (dataKey.startsWith(HitoeConstants.EX_DATA_PREFFIX)) { - // Expanded analysis discard the connection - receiveDevice.removeConnectionId(connectionId); - } else { - // Perform any extension - //Do not run if it is already running - TempExData exData = null; - try { - - mLockForEx.lock(); - - if (!mFlagForEx && mListForEx.size() > 0) { - mFlagForEx = true; - exData = mListForEx.get(0); - mListForEx.remove(0); - } - } finally { - - mLockForEx.unlock(); - } - if (exData != null) { - addExReceiverProcess(pos, exData); - } - } - - notifyListeners(receiveDevice); - } - }; - - - - - /** - * Constructor. - * - * @param context application context - */ - public HitoeManager(final Context context) { - mContext = context; - mDBHelper = new HitoeDBHelper(context); - mListForEx = new ArrayList<>(); - mLockForEx = new ReentrantLock(); - mRegisterDevices = Collections.synchronizedList( - new ArrayList()); - mHRData = new ConcurrentHashMap<>(); - mECGData = new ConcurrentHashMap<>(); - mPoseEstimationData = new ConcurrentHashMap<>(); - mStressEstimationData = new ConcurrentHashMap<>(); - mWalkStateData = new ConcurrentHashMap<>(); - mAccelData = new ConcurrentHashMap<>(); - mConnectionListeners = new ArrayList<>(); - mListForPosture = new ArrayList<>(); - mLockForPosture = new ReentrantLock(); - mListForWalk = new ArrayList<>(); - mLockForWalk = new ReentrantLock(); - mListForLRBalance = new ArrayList<>(); - mLockForLRBalance = new ReentrantLock(); - mListForEx = new ArrayList<>(); - mLockForEx = new ReentrantLock(); - mNowTimestamps = new ConcurrentHashMap<>(); - mHitoeSdkAPI = HitoeSdkAPIImpl.getInstance(context); - mHitoeSdkAPI.setAPICallback(mAPICallback); - readHitoeDeviceForDB(); - - } - - // ------------------------------------ - // Public Method - // ------------------------------------ - /** - * Set Hitoe Connection Listener. - * @param l listener - */ - public void addHitoeConnectionListener(final OnHitoeConnectionListener l) { - mConnectionListeners.add(l); - } - - /** - * Remove Hitoe Connection listener. - * @param l connection listener - */ - public void removeHitoeConnectionListener(final OnHitoeConnectionListener l) { - mConnectionListeners.remove(l); - } - /** - * Set Hitoe HeartRate Listener. - * @param l listener - */ - public void setHitoeHeartRateEventListener(final OnHitoeHeartRateEventListener l) { - mHeartRataListener = l; - } - /** - * Set Hitoe Acceleration Listener. - * @param l listener - */ - public void setHitoeDeviceOrientationEventListener(final OnHitoeDeviceOrientationEventListener l) { - mDeviceOrientationListener = l; - } - - /** - * Set Hitoe ECG listener. - * @param l listener - */ - public void setHitoeECGEventListener(final OnHitoeECGEventListener l) { - mECGListener = l; - } - - /** - * Set Hitoe Pose Estimation listener. - * @param l listener - */ - public void setHitoePoseEstimationEventListener(final OnHitoePoseEstimationEventListener l) { - mPoseEstimationListener = l; - } - - /** - * Set Hitoe Stress Estimation listener. - * @param l listener - */ - public void setHitoeStressEstimationEventListener(final OnHitoeStressEstimationEventListener l) { - mStressEstimationListener = l; - } - - /** - * Set Hitoe Walk state listener. - * @param l listener - */ - public void setHitoeWalkStateEventListener(final OnHitoeWalkStateEventListener l) { - mWalkStateListener = l; - } - - /** - * Gets the list of BLE device that was registered to automatic connection. - * - * @return list of BLE device - */ - public List getRegisterDevices() { - return mRegisterDevices; - } - - /** - * Read device info. - */ - public void readHitoeDeviceForDB() { - List list = mDBHelper.getHitoeDevices(null); - for (int i = 0; i < list.size(); i++) { - HitoeDevice device = list.get(i); - if (mRegisterDevices.size() > 0) { - if (!containsDevice(device.getId())) { - mRegisterDevices.add(device); - } - } else { - mRegisterDevices.add(device); - } - } - } - - /** - * Get mRegisterDevice for service id. - * @param serviceId service Id - * @return Hitoe Device object - */ - public HitoeDevice getHitoeDeviceForServiceId(final String serviceId) { - for (int i = 0; i < mRegisterDevices.size(); i++) { - if (mRegisterDevices.get(i).getId() != null) { - if (mRegisterDevices.get(i).getId().equals(serviceId)) { - return mRegisterDevices.get(i); - } - } - } - return null; - } - /** - * Get HeartRateData. - * @param serviceId index id - * @return HeartRateData - */ - public HeartRateData getHeartRateData(final String serviceId) { - int pos = getPosForServiceId(serviceId); - if (pos == -1) { - return null; - } - return mHRData.get(mRegisterDevices.get(pos)); - } - /** - * Get ECG Data. - * @param serviceId index id - * @return ECGData - */ - public HeartRateData getECGData(final String serviceId) { - int pos = getPosForServiceId(serviceId); - if (pos == -1) { - return null; - } - return mECGData.get(mRegisterDevices.get(pos)); - } - /** - * Get Stress Estimation Data. - * @param serviceId index id - * @return StressEstimationData - */ - public StressEstimationData getStressEstimationData(final String serviceId) { - int pos = getPosForServiceId(serviceId); - if (pos == -1) { - return null; - } - return mStressEstimationData.get(mRegisterDevices.get(pos)); - } - /** - * Get Pose Estimation Data. - * @param serviceId index id - * @return Pose Estimation Data - */ - public PoseEstimationData getPoseEstimationData(final String serviceId) { - int pos = getPosForServiceId(serviceId); - if (pos == -1) { - return null; - } - return mPoseEstimationData.get(mRegisterDevices.get(pos)); - } - /** - * Get Walk State Data. - * @param serviceId index id - * @return Walk State data - */ - public WalkStateData getWalkStateData(final String serviceId) { - int pos = getPosForServiceId(serviceId); - if (pos == -1) { - return null; - } - return mWalkStateData.get(mRegisterDevices.get(pos)); - } - /** - * Get AccelerationData. - * @param serviceId index id - * @return AccelerationData - */ - public AccelerationData getAccelerationData(final String serviceId) { - int pos = getPosForServiceId(serviceId); - if (pos == -1) { - return null; - } - return mAccelData.get(mRegisterDevices.get(pos)); - } - - /** - * Stats the HitoeManager. - */ - public void start() { - synchronized (mRegisterDevices) { - for (int i = 0; i < mRegisterDevices.size(); i++) { - HitoeDevice device = mRegisterDevices.get(i); - if (device.isRegisterFlag()) { - connectHitoeDevice(device); - } - } - } - - } - /** - * Stops the HitoeManager. - */ - public void stop() { - for (int i = 0; i < mRegisterDevices.size(); i++) { - mHitoeSdkAPI.disconnect(mRegisterDevices.get(i).getSessionId()); - mRegisterDevices.get(i).setRegisterFlag(false); - mDBHelper.updateHitoeDevice(mRegisterDevices.get(i)); - mRegisterDevices.get(i).setSessionId(null); - } - scanHitoeDevice(false); - } - /** - * Discovery hitoe device. - */ - public void discoveryHitoeDevices() { - StringBuilder paramStringBuilder = new StringBuilder(); - paramStringBuilder.append("search_time=") - .append(String.valueOf(HitoeConstants.GET_AVAILABLE_SENSOR_PARAM_SEARCH_TIME)); - mHitoeSdkAPI.getAvailableSensor(HitoeConstants.GET_AVAILABLE_SENSOR_DEVICE_TYPE, paramStringBuilder.toString()); - - if (mRegisterDevices.size() > 0) { - for (OnHitoeConnectionListener l: mConnectionListeners) { - if (l != null) { - l.onDiscovery(mRegisterDevices); - } - } - } - } - - - /** - * Connect to Hitoe Device by address. - * - * @param device device for hitoe device - */ - public void connectHitoeDevice(final HitoeDevice device) { - mExecutor.submit(() -> { - if (device == null || device.getPinCode() == null) { - return; - } - - - StringBuilder paramBuilder = new StringBuilder(); - paramBuilder.append("disconnect_retry_time=" + HitoeConstants.CONNECT_DISCONNECT_RETRY_TIME); - if (paramBuilder.length() > 0) { - paramBuilder.append(HitoeConstants.BR); - } - paramBuilder.append("disconnect_retry_count=" + HitoeConstants.CONNECT_DISCONNECT_RETRY_COUNT); - if (paramBuilder.length() > 0) { - paramBuilder.append(HitoeConstants.BR); - } - paramBuilder.append("nopacket_retry_time=" + HitoeConstants.CONNECT_NOPACKET_RETRY_TIME); - if (paramBuilder.length() > 0) { - paramBuilder.append(HitoeConstants.BR); - } - paramBuilder.append("pincode="); - paramBuilder.append(device.getPinCode()); - String param = paramBuilder.toString(); - BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); - BluetoothDevice remoteDevice = adapter.getRemoteDevice(device.getId()); - if (remoteDevice.getName() == null) { - // If RemoteDevice is Null, Discovery process needs to be done once. - // Retry 10 times and continue processing when RemoteDevice is found. - discoveryHitoeDevices(); - int i = 0; - for (i = 0; i < CONNECTING_RETRY_COUNT; i++) { - try { - Thread.sleep(CONNECTING_RETRY_WAIT); - } catch (InterruptedException e) { - e.printStackTrace(); - } - remoteDevice = adapter.getRemoteDevice(device.getId()); - if (remoteDevice.getName() != null) { - break; - } - } - if (i == CONNECTING_RETRY_COUNT && remoteDevice.getName() == null) { - return; - } - } - mHitoeSdkAPI.connect(device.getType(), device.getId(), device.getConnectMode(), param); - device.setResponseId(HitoeConstants.RES_ID_SENSOR_CONNECT); - mDBHelper.addHitoeDevice(device); - mStressEstimationData.put(device, new StressEstimationData()); - for (int i = 0; i < mRegisterDevices.size(); i++) { - if (mRegisterDevices.get(i).getId().equals(device.getId())) { - mRegisterDevices.set(i, device); - } else { - - mRegisterDevices.get(i).setResponseId(HitoeConstants.RES_ID_SENSOR_DISCONECT_NOTICE); - } - } - }); - } - - /** - * Disconnect hitoe device. - * @param device hitoe device - */ - public void disconnectHitoeDevice(final HitoeDevice device) { - mExecutor.submit(() -> { - HitoeDevice current = getHitoeDeviceForServiceId(device.getId()); - int res = mHitoeSdkAPI.disconnect(current.getSessionId()); - current.setRegisterFlag(false); - current.setSessionId(null); - mDBHelper.updateHitoeDevice(current); - if (!existConnected()) { - scanHitoeDevice(false); - } - for (OnHitoeConnectionListener l: mConnectionListeners) { - if (l != null) { - l.onDisconnected(res, device); - } - } - }); - - } - - /** - * Delete hitoe device info for db. - * @param device hitoe device - */ - public void deleteHitoeDevice(final HitoeDevice device) { - - mDBHelper.removeHitoeDevice(device); - - for (int i = 0; i < mRegisterDevices.size(); i++) { - if (mRegisterDevices.get(i).getId().equals(device.getId())) { - HitoeDevice d = mRegisterDevices.remove(i); - for (OnHitoeConnectionListener l: mConnectionListeners) { - if (l != null) { - l.onDeleted(d); - } - } - } - } - } - /** - * Tests whether this mConnectedDevices contains the address. - * @param id address will be checked - * @return true if address is an element of mConnectedDevices, false otherwise - */ - public boolean containConnectedHitoeDevice(final String id) { - synchronized (mRegisterDevices) { - for (HitoeDevice d : mRegisterDevices) { - if (d.getId().equals(id) && d.getSessionId() != null) { - return true; - } - } - } - return false; - } - - // Private method - // ------------------------------------ - // Notifyメソッド群 - // ------------------------------------ - - /** - * Notify for found Hitoe Devices. - * @param responseId Response id - * @param responseString Response String - */ - private void notifyDiscoveryHitoeDevice(final int responseId, final String responseString) { - if (responseId != HitoeConstants.RES_ID_SUCCESS || responseString == null) { - return; - } - - String[] sensorList = responseString.split(HitoeConstants.BR, -1); - List pins = mDBHelper.getHitoeDevices(null); - for (int i = 0; i < sensorList.length; i++) { - String sensorStr = sensorList[i].trim(); - if (sensorStr.length() == 0) { - continue; - } - if (!sensorStr.contains("memory_setting") && !sensorStr.contains("memory_get")) { - HitoeDevice device = new HitoeDevice(sensorStr); - if (mRegisterDevices.size() == 0) { - mRegisterDevices.add(device); - } - if (!containsDevice(device.getId())) { - mRegisterDevices.add(device); - } - } - } - for (HitoeDevice pin : pins) { - for (HitoeDevice register: mRegisterDevices) { - if (register.getId().equals(pin.getId())) { - register.setPinCode(pin.getPinCode()); - register.setRegisterFlag(pin.isRegisterFlag()); - } - } - } - for (OnHitoeConnectionListener l: mConnectionListeners) { - if (l != null) { - l.onDiscovery(mRegisterDevices); - } - } - } - - /** - * Notify for connected hitoe devices. - * @param responseId Response id - * @param responseString Response string - */ - private void notifyConnectHitoeDevice(final int responseId, final String responseString) { - int pos = getCurrentPos(responseId); - if (pos == -1) { - for (OnHitoeConnectionListener l: mConnectionListeners) { - if (l != null) { - l.onConnectFailed(null); - } - } - return; - } - if (responseId == HitoeConstants.RES_ID_SENSOR_DISCONECT_NOTICE) { - // 切断の場合もフラグを落とす - try{ - - mLockForEx.lock(); - - mListForEx.clear(); - mFlagForEx = false; - }finally { - - mLockForEx.unlock(); - } - for (OnHitoeConnectionListener l: mConnectionListeners) { - if (l != null) { - - l.onConnectFailed(mRegisterDevices.get(pos)); - } - } - return; - } else if (responseId == HitoeConstants.RES_ID_SENSOR_CONNECT_NOTICE) { - for (OnHitoeConnectionListener l: mConnectionListeners) { - l.onConnected(mRegisterDevices.get(pos)); - } - return; - } else if (responseId != HitoeConstants.RES_ID_SENSOR_CONNECT) { - for (OnHitoeConnectionListener l: mConnectionListeners) { - if (l != null) { - - l.onConnectFailed(mRegisterDevices.get(pos)); - } - } - return; - } - mRegisterDevices.get(pos).setSessionId(responseString); - mRegisterDevices.get(pos).setRegisterFlag(true); - mDBHelper.updateHitoeDevice(mRegisterDevices.get(pos)); - mHitoeSdkAPI.getAvailableData(mRegisterDevices.get(pos).getSessionId()); - mRegisterDevices.get(pos).setResponseId(HitoeConstants.RES_ID_SUCCESS); - for (OnHitoeConnectionListener l: mConnectionListeners) { - if (l != null) { - l.onConnected(mRegisterDevices.get(pos)); - } - } - } - - /** - * Notify AvailableData. - * @param responseId response id - * @param responseString Response string - */ - private void notifyAvailableData(final int responseId, final String responseString) { - if (responseId != HitoeConstants.RES_ID_SUCCESS || responseString == null) { - return; - } - int pos = getCurrentPos(responseId); - if (pos == -1) { - return; - } - mRegisterDevices.get(pos).setAvailableData(responseString); - List keyList = mRegisterDevices.get(pos).getAvailableRawDataList(); - - StringBuilder paramStringBuilder = new StringBuilder(); - String[] keys = new String[keyList.size()]; - String paramString; - - for (int i = 0; i < keyList.size(); i++) { - - keys[i] = keyList.get(i); - - if (keyList.get(i).equals("raw.ecg")) { - - if (paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("raw.ecg_interval=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_ECG_SAMPLING_INTERVAL)); - } else if (keyList.get(i).equals("raw.acc")) { - - if (paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("raw.acc_interval=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_ACC_SAMPLING_INTERVAL)); - } else if (keyList.get(i).equals("raw.rri")) { - - if (paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("raw.rri_interval=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_RRI_SAMPLING_INTERVAL)); - } else if (keyList.get(i).equals("raw.hr")) { - - if (paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("raw.hr_interval=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_HR_SAMPLING_INTERVAL)); - } else if (keyList.get(i).equals("raw.bat")) { - - if (paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("raw.bat_interval=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BAT_SAMPLING_INTERVAL)); - } - } - - paramString = paramStringBuilder.toString(); - mHitoeSdkAPI.addReceiver(mRegisterDevices.get(pos).getSessionId(), - keys, mDataReceiverCallback, paramString, null); - scanHitoeDevice(true); - } - - /** - * Notify add receiver. - * @param responseId response id - * @param responseString response string - */ - private void notifyAddReceiver(final int responseId, final String responseString) { - if (responseId != HitoeConstants.RES_ID_SUCCESS || responseString == null) { - mFlagForEx = false; - return; - } - int pos = getCurrentPos(responseId); - if (pos == -1) { - return; - } - mRegisterDevices.get(pos).setConnectionId(responseString); - if (responseString.startsWith(HitoeConstants.RAW_CONNECTION_PREFFIX)) { - addBaReceiverProcess(pos); - } else { - TempExData exData = null; - try { - mLockForEx.lock(); - - if (mListForEx.size() > 0) { - exData = mListForEx.get(0); - mListForEx.remove(0); - } else { - mFlagForEx = false; - } - - } finally { - - mLockForEx.unlock(); - } - if (exData != null) { - addExReceiverProcess(pos, exData); - } - } - } - - /** - * Notify Remove receiver. - * @param responseId response id - * @param responseString response string - */ - private void notifyRemoveReceiver(final int responseId, final String responseString) { - if (responseId != HitoeConstants.RES_ID_SUCCESS || responseString == null) { - return; - } - int pos = getCurrentPos(responseId); - if (pos == -1) { - return; - } - mRegisterDevices.get(pos).setRegisterFlag(false); - mRegisterDevices.get(pos).removeConnectionId(responseString); - mDBHelper.updateHitoeDevice(mRegisterDevices.get(pos)); - - if (responseString.startsWith(HitoeConstants.BA_CONNECTION_PREFFIX)) { - removeRawReceiverProcess(mRegisterDevices.get(pos).getRawConnectionId()); - } else if (responseString.startsWith(HitoeConstants.RAW_CONNECTION_PREFFIX)) { - disconnectProcess(pos); - } - } - - /** - * Notify Listeners. - * @param receiveDevice now receive device - */ - private void notifyListeners(final HitoeDevice receiveDevice) { - if (mHeartRataListener != null) { - mHeartRataListener.onReceivedData(receiveDevice, mHRData.get(receiveDevice)); - } - if (mECGListener != null) { - mECGListener.onReceivedData(receiveDevice, mHRData.get(receiveDevice)); - } - if (mPoseEstimationListener != null) { - mPoseEstimationListener.onReceivedData(receiveDevice, mPoseEstimationData.get(receiveDevice)); - } - if (mStressEstimationListener != null) { - mStressEstimationListener.onReceivedData(receiveDevice, mStressEstimationData.get(receiveDevice)); - } - if (mWalkStateListener != null) { - mWalkStateListener.onReceivedData(receiveDevice, mWalkStateData.get(receiveDevice)); - } - if (mDeviceOrientationListener != null) { - mDeviceOrientationListener.onReceivedData(receiveDevice, mAccelData.get(receiveDevice)); - } - if (mECGListener != null) { - mECGListener.onReceivedData(receiveDevice, mECGData.get(receiveDevice)); - } - if (mStressEstimationListener != null) { - mStressEstimationListener.onReceivedData(receiveDevice, mStressEstimationData.get(receiveDevice)); - } - if (mPoseEstimationListener != null) { - mPoseEstimationListener.onReceivedData(receiveDevice, mPoseEstimationData.get(receiveDevice)); - } - } - - - - - /** - * Add ba Receiver process. - * @param pos device pos - */ - private void addBaReceiverProcess(final int pos) { - List keyList = mRegisterDevices.get(pos).getAvailableBaDataList(); - - StringBuilder paramStringBuilder = new StringBuilder(); - String[] keys = new String[keyList.size()]; - String paramString; - - if (keyList.size() == 0) { - return; - } - - for (int i = 0; i < keyList.size(); i++) { - - keys[i] = keyList.get(i); - - if (keyList.get(i).equals("ba.extracted_rri")) { - - if (paramStringBuilder.indexOf("ba.sampling_interval") == -1) { - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.sampling_interval=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_SAMPLING_INTERVAL)); - } - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.ecg_threshhold=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_ECG_THRESHHOLD)); - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.ecg_skip_count=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_SKIP_COUNT)); - - } else if (keyList.get(i).equals("ba.cleaned_rri")) { - - if (paramStringBuilder.indexOf("ba.sampling_interval") == -1) { - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.sampling_interval=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_SAMPLING_INTERVAL)); - } - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.rri_min=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_RRI_MIN)); - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.rri_max=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_RRI_MAX)); - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.sample_count=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_SAMPLE_COUNT)); - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.rri_input=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_RRI_INPUT)); - } else if (keyList.get(i).equals("ba.interpolated_rri")) { - - if (paramStringBuilder.indexOf("ba.freq_sampling_interval") == -1) { - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.freq_sampling_interval=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_FREQ_SAMPLING_INTERVAL)); - } - if (paramStringBuilder.indexOf("ba.freq_sampling_window") == -1) { - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.freq_sampling_window=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_FREQ_SAMPLING_WINDOW)); - } - if (paramStringBuilder.indexOf("ba.rri_sampling_rate") == -1) { - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.rri_sampling_rate=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_RRI_SAMPLING_RATE)); - } - } else if (keyList.get(i).equals("ba.freq_domain")) { - - if (paramStringBuilder.indexOf("ba.freq_sampling_interval") == -1) { - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.freq_sampling_interval=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_FREQ_SAMPLING_INTERVAL)); - } - if (paramStringBuilder.indexOf("ba.freq_sampling_window") == -1) { - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.freq_sampling_window=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_FREQ_SAMPLING_WINDOW)); - } - if (paramStringBuilder.indexOf("ba.rri_sampling_rate") == -1) { - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.rri_sampling_rate=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_RRI_SAMPLING_RATE)); - } - } else if (keyList.get(i).equals("ba.time_domain")) { - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.time_sampling_interval=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_TIME_SAMPLING_INTERVAL)); - if (paramStringBuilder.length() > 0 - && paramStringBuilder.lastIndexOf(HitoeConstants.BR) != paramStringBuilder.length() - 1) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ba.time_sampling_window=") - .append(String.valueOf(HitoeConstants.ADD_RECEIVER_PARAM_BA_TIME_SAMPLING_WINDOW)); - } - } - - paramString = paramStringBuilder.toString(); - - int resId = mHitoeSdkAPI.addReceiver(mRegisterDevices.get(pos).getSessionId(), - keys, mDataReceiverCallback, paramString, null); - mRegisterDevices.get(pos).setResponseId(resId); - } - - /** - * Register Ex receiver. - * @param pos device pos - * @param exData ex data - */ - private void addExReceiverProcess(final int pos, final TempExData exData) { - - String keyString = exData.getKey(); - ArrayList dataList = exData.getDataList(); - - if (!mRegisterDevices.get(pos).getAvailableExDataList().contains(keyString)) { - - try { - mLockForEx.lock(); - mFlagForEx = false; - - } finally { - - mLockForEx.unlock(); - } - return; - } - - int responseId; - - String[] keys = new String[1]; - keys[0] = keyString; - - StringBuilder paramStringBuilder = new StringBuilder(); - StringBuilder dataStringBuilder = new StringBuilder(); - String paramString; - String dataString; - - for (int i = 0; i < dataList.size(); i++) { - - if (dataStringBuilder.length() > 0) { - - dataStringBuilder.append(HitoeConstants.BR); - } - dataStringBuilder.append(dataList.get(i)); - } - if (keyString.equals("ex.posture")) { - - if (paramStringBuilder.length() > 0) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ex.acc_axis_xyz=") - .append(HitoeConstants.ADD_RECEIVER_PARAM_EX_ACC_AXIS_XYZ); - if (paramStringBuilder.length() > 0) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ex.posture_window=") - .append(HitoeConstants.ADD_RECEIVER_PARAM_EX_POSTURE_WINDOW); - } else if (keyString.equals("ex.walk")) { - if (paramStringBuilder.length() > 0) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ex.acc_axis_xyz=") - .append(HitoeConstants.ADD_RECEIVER_PARAM_EX_ACC_AXIS_XYZ); - if (paramStringBuilder.length() > 0) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ex.walk_stride=") - .append(HitoeConstants.ADD_RECEIVER_PARAM_EX_WALK_STRIDE); - if (paramStringBuilder.length() > 0) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ex.run_stride_cof=") - .append(HitoeConstants.ADD_RECEIVER_PARAM_EX_RUN_STRIDE_COF); - if (paramStringBuilder.length() > 0) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ex.run_stride_int=") - .append(HitoeConstants.ADD_RECEIVER_PARAM_EX_RUN_STRIDE_INT); - } else if (keyString.equals("ex.lr_balance")) { - - if (paramStringBuilder.length() > 0) { - - paramStringBuilder.append(HitoeConstants.BR); - } - paramStringBuilder.append("ex.acc_axis_xyz=") - .append(HitoeConstants.ADD_RECEIVER_PARAM_EX_ACC_AXIS_XYZ); - } - - paramString = paramStringBuilder.toString(); - dataString = dataStringBuilder.toString(); - mHitoeSdkAPI.removeReceiver(null); - responseId = mHitoeSdkAPI.addReceiver(null, keys, mDataReceiverCallback, paramString, dataString); - if (responseId != HitoeConstants.RES_ID_SUCCESS) { - try { - mLockForEx.lock(); - mFlagForEx = false; - - } finally { - - mLockForEx.unlock(); - } - } - } - - /** - * Remove raw receiver process. - * @param rawConnectionId raw connection id - */ - private void removeRawReceiverProcess(final String rawConnectionId) { - if (rawConnectionId == null) { - return; - } - mHitoeSdkAPI.removeReceiver(rawConnectionId); - } - - /** - * Disconnect Hitoe device. - * @param pos hitoe devie position - */ - private void disconnectProcess(final int pos) { - if (pos == -1) { - return; - } - HitoeDevice device = mRegisterDevices.get(pos); - - if (device.getSessionId() == null) { - return; - } - mRegisterDevices.get(pos).setSessionId(null); - mRegisterDevices.get(pos).setRegisterFlag(false); - mDBHelper.updateHitoeDevice(mRegisterDevices.get(pos)); - mHitoeSdkAPI.disconnect(device.getSessionId()); - if (mRegisterDevices.size() == 0) { - scanHitoeDevice(false); - } - } - - /** - * Get Current register device. - * @param responseId current response id - * @return current register pos - */ - private int getCurrentPos(final int responseId) { - int pos = -1; - - for (int i = 0; i < mRegisterDevices.size(); i++) { - - if (mRegisterDevices.get(i).getResponseId() == responseId) { - pos = i; - break; - } - } - - return pos; - } - - /** - * Is exist register device. - * @param id service id - * @return true:exist false: non exist - */ - private boolean containsDevice(final String id) { - boolean isRegister = false; - for (int i = 0; i < mRegisterDevices.size(); i++) { - if (mRegisterDevices.get(i).getId().equals(id)) { - isRegister = true; - } - } - return isRegister; - } - - /** - * Get mRegisterDevice's Position for Connection id. - * @param connectionId connection Id - * @return position - */ - private int getPosForConnectionId(final String connectionId) { - int pos = -1; - for (int i = 0; i < mRegisterDevices.size(); i++) { - if (mRegisterDevices.get(i).getRawConnectionId() != null) { - if (mRegisterDevices.get(i).getRawConnectionId().equals(connectionId)) { - pos = i; - break; - } - - } - if (mRegisterDevices.get(i).getBaConnectionId() != null) { - if (mRegisterDevices.get(i).getBaConnectionId().equals(connectionId)) { - pos = i; - break; - } - } - if (mRegisterDevices.get(i).getExConnectionList().size() > 0) { - for (int j = 0; j < mRegisterDevices.get(i).getExConnectionList().size(); j++) { - String exConnectionId = mRegisterDevices.get(i).getExConnectionList().get(j); - if (exConnectionId == null) { - continue; - } - if (exConnectionId.equals(connectionId)) { - pos = i; - break; - } - } - } - } - return pos; - } - - /** - * Get mRegisterDevice's Position for service id. - * @param serviceId service Id - * @return position - */ - private int getPosForServiceId(final String serviceId) { - int pos = -1; - for (int i = 0; i < mRegisterDevices.size(); i++) { - if (mRegisterDevices.get(i).getId() != null) { - if (mRegisterDevices.get(i).getId().equals(serviceId)) { - pos = i; - break; - } - } - } - return pos; - } - - /** - * 周波数領域特徴量データをパースする. - * @param receiveDevice ReceiveDevice - * @param data 周波数領域特徴量データ - */ - private void parseFreqDomain(final HitoeDevice receiveDevice, final String data) { - - String[] lineList = data.split(HitoeConstants.BR); - ArrayList stressInputList = new ArrayList(); - - if (receiveDevice.getAvailableExDataList().contains("ex.stress")) { - for (int i = 0; i < lineList.length; i++) { - stressInputList.add(lineList[i]); - } - - try { - mLockForEx.lock(); - mListForEx.add(new TempExData("ex.stress", stressInputList)); - } finally { - mLockForEx.unlock(); - } - } - } - /** - * Extract health data. - * @param type Health data type - * @param rawData raw data - * @param receiveDevice Hitoe device - */ - private void extractHealth(final HeartData.HeartRateType type, - final String rawData, final HitoeDevice receiveDevice) { - HeartRateData currentHeartRate = mHRData.get(receiveDevice); - if (currentHeartRate == null) { - currentHeartRate = new HeartRateData(); - } - if (type == HeartData.HeartRateType.Rate) { - HeartData heart = RawDataParseUtils.parseHeartRate(rawData); - currentHeartRate.setHeartRate(heart); - mHRData.put(receiveDevice, currentHeartRate); - } else if (type == HeartData.HeartRateType.RRI) { - HeartData rri = RawDataParseUtils.parseRRI(rawData); - currentHeartRate.setRRInterval(rri); - mHRData.put(receiveDevice, currentHeartRate); - } else if (type == HeartData.HeartRateType.EnergyExpended) { - HeartData energy = RawDataParseUtils.parseEnergyExpended(rawData); - currentHeartRate.setEnergyExpended(energy); - mHRData.put(receiveDevice, currentHeartRate); - } else if (type == HeartData.HeartRateType.ECG) { - HeartData ecg = RawDataParseUtils.parseECG(rawData); - currentHeartRate.setECG(ecg); - mECGData.put(receiveDevice, currentHeartRate); - - } - } - - /** - * Extract Battery data. - * @param rawData raw data - * @param receiveDevice Hitoe device - */ - private void extractBattery(final String rawData, final HitoeDevice receiveDevice) { - String[] lineList = rawData.split(HitoeConstants.BR); - String levelString = lineList[lineList.length - 1]; - String[] level = levelString.split(",", -1); - - TargetDeviceData current = RawDataParseUtils.parseDeviceData(receiveDevice, - Float.parseFloat(level[1])); - HeartRateData currentHeartRate = mHRData.get(receiveDevice); - if (currentHeartRate == null) { - currentHeartRate = new HeartRateData(); - } - currentHeartRate.setDevice(current); - mHRData.put(receiveDevice, currentHeartRate); - } - /** - * Analyze Acceleration data. - * Get Posture Data, Walk State data, LR Balance data. - * @param rawData raw data - * @param receiveDevice receive device - */ - private void analyzeAccelerationData(final String rawData, final HitoeDevice receiveDevice) { - String[] lineList = rawData.split(HitoeConstants.BR); - ArrayList postureInputList = new ArrayList(); - ArrayList walkInputList = new ArrayList(); - ArrayList lrBalanceInputList = new ArrayList(); - - ArrayList workList = new ArrayList(); - - for (int i = 0; i < lineList.length; i++) { - - if (receiveDevice.getAvailableExDataList().contains("ex.posture")) { - try { - mLockForPosture.lock(); - mListForPosture.add(lineList[i]); - if (mListForPosture.size() > HitoeConstants.EX_POSTURE_UNIT_NUM + 5) { - - for (int j = 0; j < HitoeConstants.EX_POSTURE_UNIT_NUM; j++) { - - postureInputList.add(mListForPosture.get(j)); - } - for (int j = HitoeConstants.EX_POSTURE_UNIT_NUM; - j < HitoeConstants.EX_POSTURE_UNIT_NUM + 5; j++) { - - postureInputList.add(mListForPosture.get(j)); - } - workList = new ArrayList<>(); - for (int j = 25; j < mListForPosture.size(); j++) { - - workList.add(mListForPosture.get(j)); - } - mListForPosture = workList; - } - } finally { - - mLockForPosture.unlock(); - } - if (postureInputList.size() > 0) { - - try { - mLockForEx.lock(); - mListForEx.add(new TempExData("ex.posture", postureInputList)); - - } finally { - mLockForEx.unlock(); - } - - postureInputList.clear(); - } - } - if (receiveDevice.getAvailableExDataList().contains("ex.walk")) { - try { - mLockForWalk.lock(); - mListForWalk.add(lineList[i]); - if (mListForWalk.size() > HitoeConstants.EX_WALK_UNIT_NUM + 5) { - - for (int j = 0; j < HitoeConstants.EX_WALK_UNIT_NUM; j++) { - - walkInputList.add(mListForWalk.get(j)); - } - for (int j = HitoeConstants.EX_WALK_UNIT_NUM; - j < HitoeConstants.EX_WALK_UNIT_NUM + 5; j++) { - - walkInputList.add(mListForWalk.get(j)); - } - - workList = new ArrayList<>(); - for (int j = 25; j < mListForWalk.size(); j++) { - - workList.add(mListForWalk.get(j)); - } - mListForWalk = workList; - } - } finally { - - mLockForWalk.unlock(); - } - if (walkInputList.size() > 0) { - - try { - mLockForEx.lock(); - mListForEx.add(new TempExData("ex.walk", walkInputList)); - } finally { - mLockForEx.unlock(); - } - - walkInputList.clear(); - } - } - if (receiveDevice.getAvailableExDataList().contains("ex.lr_balance")) { - try { - mLockForLRBalance.lock(); - mListForLRBalance.add(lineList[i]); - if (mListForLRBalance.size() > HitoeConstants.EX_LR_BALANCE_UNIT_NUM + 5) { - - for (int j = 0; j < HitoeConstants.EX_LR_BALANCE_UNIT_NUM; j++) { - - lrBalanceInputList.add(mListForLRBalance.get(j)); - } - for (int j = HitoeConstants.EX_LR_BALANCE_UNIT_NUM; - j < HitoeConstants.EX_LR_BALANCE_UNIT_NUM + 5; j++) { - - lrBalanceInputList.add(mListForLRBalance.get(j)); - } - workList = new ArrayList<>(); - for (int j = 25; j < mListForLRBalance.size(); j++) { - - workList.add(mListForLRBalance.get(j)); - } - mListForLRBalance = workList; - - } - } finally { - - mLockForLRBalance.unlock(); - } - if (lrBalanceInputList.size() > 0) { - - try { - mLockForEx.lock(); - mListForEx.add(new TempExData("ex.lr_balance", lrBalanceInputList)); - } finally { - mLockForEx.unlock(); - } - - lrBalanceInputList.clear(); - } - } - } - } - - /** - * Scan Hitoe device. - * @param enable scan flag - */ - private synchronized void scanHitoeDevice(final boolean enable) { - - - if (enable) { - if (mScanning || mScanTimerFuture != null) { - // scan have already started. - return; - } - mScanning = true; - mIsCallbackRunning = true; - mNowTimestamps.clear(); - for (HitoeDevice heart: mRegisterDevices) { - mNowTimestamps.put(heart, System.currentTimeMillis()); - } - mScanTimerFuture = mExecutor.scheduleAtFixedRate(() -> { - - for (HitoeDevice heart: mHRData.keySet()) { - HeartRateData data = mHRData.get(heart); - long timestamp = data.getHeartRate().getTimeStamp(); - long history = mNowTimestamps.get(heart); - if (BuildConfig.DEBUG) { - Log.d(TAG, "================>"); - Log.d(TAG, "timestamp:" + timestamp); - Log.d(TAG, "history:" + history); - Log.d(TAG, "CallbackRunning:" + mIsCallbackRunning); - Log.d(TAG, "isRegisterFlag:" + heart.isRegisterFlag()); - Log.d(TAG, "<================"); - } - if (mIsCallbackRunning && history == timestamp && heart.isRegisterFlag()) { - final String name = heart.getName(); - - mHandler.post(new Runnable() { - @Override - public void run() { - Toast.makeText(mContext, "Disconnect to " + name, - Toast.LENGTH_SHORT).show(); - } - }); - - mIsCallbackRunning = false; - } else if (!mIsCallbackRunning && history < timestamp && heart.isRegisterFlag()) { - final String name = heart.getName(); - mHandler.post(new Runnable() { - @Override - public void run() { - Toast.makeText(mContext, "Connect to " + name, - Toast.LENGTH_SHORT).show(); - } - }); - mIsCallbackRunning = true; - } - mNowTimestamps.put(heart, timestamp); - if (!mIsCallbackRunning && heart.isRegisterFlag()) { - connectHitoeDevice(heart); - } - } - }, SCAN_FIRST_WAIT_PERIOD, SCAN_WAIT_PERIOD, TimeUnit.MILLISECONDS); - } else { - mScanning = false; - cancelScanTimer(); - } - } - - /** - * Stopped the scan timer. - */ - private synchronized void cancelScanTimer() { - if (mScanTimerFuture != null) { - mScanTimerFuture.cancel(true); - mScanTimerFuture = null; - } - } - - /** - * Is Exist Disconnected. - * @return true:exist connect, false: non exist connect - */ - private boolean existConnected() { - int connectCount = 0; - for (int i = 0; i < mRegisterDevices.size(); i++) { - if (mRegisterDevices.get(i).isRegisterFlag()) { - connectCount++; - } - } - return (connectCount > 0); - } - // ------------------------------------ - // Listener. - // ------------------------------------ - - - /** - * Hitoe Device Discovery Listener. - */ - public interface OnHitoeConnectionListener { - /** - * Connected Device. - * @param device Hitoe device - */ - void onConnected(final HitoeDevice device); - - /** - * Connect fail device. - * @param device Hitoe device - */ - void onConnectFailed(final HitoeDevice device); - /** - * Discovery Listener. - * @param devices Found hitoe devices - */ - void onDiscovery(List devices); - - /** - * Disconnected Listener. - * @param res response id - * @param device disconnect device - */ - void onDisconnected(final int res, final HitoeDevice device); - - /** - * Deleted Listener. - * @param device delte device - */ - void onDeleted(final HitoeDevice device); - } - - /** - * Hitoe Device HeartRate Listener. - */ - public interface OnHitoeHeartRateEventListener { - /** - * Received data for Hitoe HeartRate data. - * @param device Hitoe device - * @param data HeartRate data - */ - void onReceivedData(final HitoeDevice device, final HeartRateData data); - } - - /** - * Hitoe Device ECG Listener. - */ - public interface OnHitoeECGEventListener { - /** - * Received data for Hitoe ECG Data. - * @param device Hitoe device - * @param data ECG data - */ - void onReceivedData(final HitoeDevice device, final HeartRateData data); - } - - /** - * Hitoe Device Pose Estimation Listener. - */ - public interface OnHitoePoseEstimationEventListener { - /** - * Received data for Hitoe Pose estimation data. - * @param device Hitoe device - * @param data pose estimation data - */ - void onReceivedData(final HitoeDevice device, final PoseEstimationData data); - } - - /** - * Hitoe Device Stress Estimation Listener. - */ - public interface OnHitoeStressEstimationEventListener { - /** - * Received data for Hitoe Stress Estimation data. - * @param device Hitoe device - * @param data stress estimation data - */ - void onReceivedData(final HitoeDevice device, final StressEstimationData data); - } - - /** - * Hitoe Device Walk State Listener. - */ - public interface OnHitoeWalkStateEventListener { - /** - * Received data for Hitoe walk state data. - * @param device Hitoe device - * @param data walk state - */ - void onReceivedData(final HitoeDevice device, final WalkStateData data); - } - - /** - * Hitoe Device Device Orientation Listener. - */ - public interface OnHitoeDeviceOrientationEventListener { - /** - * Received data for Hitoe device orientation data. - * @param device Hitoe device - * @param data device orientation - */ - void onReceivedData(final HitoeDevice device, final AccelerationData data); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/PoseEstimationData.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/PoseEstimationData.java deleted file mode 100644 index da930cc7de..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/PoseEstimationData.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - PoseEstimationData - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - -import android.os.Bundle; - -import org.deviceconnect.android.profile.PoseEstimationProfile; -import org.deviceconnect.profile.PoseEstimationProfileConstants; - -/** - * This class is information of Pose Estimation. - * @author NTT DOCOMO, INC. - */ -public class PoseEstimationData { - - - /** Pose state. */ - private PoseEstimationProfileConstants.PoseState mState = PoseEstimationProfileConstants.PoseState.Standing; - /** Poses TimeStamp. */ - private long mTimeStamp; - /** Poses TimeStamp String. */ - private String mTimeStampString; - - /** - * Get Pose state. - * @return Pose state - */ - public PoseEstimationProfileConstants.PoseState getPoseState() { - return mState; - } - - /** - * Set Pose state. - * @param state Pose state - */ - public void setPoseState(final PoseEstimationProfileConstants.PoseState state) { - mState = state; - } - - /** - * Get TimeStamp. - * @return TimeStamp - */ - public long getTimeStamp() { - return mTimeStamp; - } - - /** - * Set TimeStamp. - * @param timeStamp TimeStamp - */ - public void setTimeStamp(final long timeStamp) { - mTimeStamp = timeStamp; - } - - /** - * Get TimeStamp String. - * @return TimeStamp String - */ - public String getTimeStampString() { - return mTimeStampString; - } - - /** - * Set TimeStamp String. - * @param timeStampString TimeStamp String - */ - public void setTimeStampString(final String timeStampString) { - mTimeStampString = timeStampString; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("{\"state\": ").append(mState.getState()).append(", "); - builder.append("\"timeStamp\": ").append(mTimeStamp).append(", "); - builder.append("\"timeStampString\": ").append(mTimeStampString).append("} "); - return builder.toString(); - } - - /** - * To bundle. - * @return bundle - */ - public Bundle toBundle() { - Bundle pose = new Bundle(); - PoseEstimationProfile.setState(pose, mState.getState()); - PoseEstimationProfile.setTimestamp(pose, mTimeStamp); - PoseEstimationProfile.setTimestampString(pose, mTimeStampString); - return pose; - } - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/StressEstimationData.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/StressEstimationData.java deleted file mode 100644 index 8f74bd586b..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/StressEstimationData.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - StressEstimationData - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - -import android.os.Bundle; - -import org.deviceconnect.android.profile.StressEstimationProfile; - -/** - * This class is information of Stress Estimation. - * @author NTT DOCOMO, INC. - */ -public class StressEstimationData { - /** LF/HF. */ - private double mLFHF; - /** LF/HF's TimeStamp. */ - private long mTimeStamp; - /** LF/HF's TimeStamp String. */ - private String mTimeStampString; - - /** - * Get LFHF's value. - * @return LFHF's value - */ - public double getLFHFValue() { - return mLFHF; - } - - /** - * Set LFHF's value. - * @param lfhf LFHF's value - */ - public void setLFHFValue(final double lfhf) { - mLFHF = lfhf; - } - - /** - * Get TimeStamp. - * @return TimeStamp - */ - public long getTimeStamp() { - return mTimeStamp; - } - - /** - * Set TimeStamp. - * @param timeStamp TimeStamp - */ - public void setTimeStamp(final long timeStamp) { - mTimeStamp = timeStamp; - } - - /** - * Get TimeStamp String. - * @return TimeStamp String - */ - public String getTimeStampString() { - return mTimeStampString; - } - - /** - * Set TimeStamp String. - * @param timeStampString TimeStamp String - */ - public void setTimeStampString(final String timeStampString) { - mTimeStampString = timeStampString; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("{\"lfhf\": ").append(mLFHF).append(", "); - builder.append("\"timeStamp\": ").append(mTimeStamp).append(", "); - builder.append("\"timeStampString\": ").append(mTimeStampString).append("} "); - return builder.toString(); - } - - /** - * To bundle. - * @return bundle - */ - public Bundle toBundle() { - Bundle stress = new Bundle(); - StressEstimationProfile.setLFHF(stress, mLFHF); - StressEstimationProfile.setTimestamp(stress, mTimeStamp); - StressEstimationProfile.setTimestampString(stress, mTimeStampString); - return stress; - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/TargetDeviceData.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/TargetDeviceData.java deleted file mode 100644 index 0b2b91b4d9..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/TargetDeviceData.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - DeviceData - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - -import android.os.Bundle; - -import org.deviceconnect.android.profile.HealthProfile; - -/** - * This class is information of HeartRate's device. - * @author NTT DOCOMO, INC. - */ -public class TargetDeviceData { - /** Target device's product name. */ - private String mProductName; - /** Target device's manufacture name. */ - private String mManufactureName; - /** Target device's model number. */ - private String mModelNumber; - /** Target device's firmware revision. */ - private String mFirmwareRevision; - /** Target device's serial number. */ - private String mSerialNumber; - /** Target device's software revision. */ - private String mSoftwareRevision; - /** Target device's hardware revision. */ - private String mHardwareRevision; - /** Target device's part number. */ - private String mPartNumber; - /** Target device's protocolRevision. */ - private String mProtocolRevision; - /** Target device's system id. */ - private String mSystemId; - /** Target device's battery level.*/ - private float mBatteryLevel; - - /** - * Constructor. - */ - public TargetDeviceData() { - mProductName = ""; - mManufactureName = ""; - mModelNumber = ""; - mFirmwareRevision = ""; - mSerialNumber = ""; - mSoftwareRevision = ""; - mHardwareRevision = ""; - mPartNumber = ""; - mProtocolRevision = ""; - mSystemId = "0x0"; - mBatteryLevel = -1.0f; - } - - /** - * Get Target device's product name. - * @return Target device's product name - */ - public String getProductName() { - return mProductName; - } - - /** - * Set Target device's product name. - * @param productName Target device's product name - */ - public void setProductName(final String productName) { - mProductName = productName; - } - - /** - * Get Target device's manufacture name. - * @return Target device's manufacture name - */ - public String getManufactureName() { - return mManufactureName; - } - - /** - * Set Target device's manufacture name. - * @param manufactureName Target device's manufacture name - */ - public void setManufactureName(final String manufactureName) { - mManufactureName = manufactureName; - } - - /** - * Get Target device's model number. - * @return Target device's model number - */ - public String getModelNumber() { - return mModelNumber; - } - - /** - * Set Target device's model number - * @param modelNumber Target device's model number - */ - public void setModelNumber(final String modelNumber) { - mModelNumber = modelNumber; - } - - /** - * Get Target device's firmware revision. - * @return Target device's firmware revision - */ - public String getFirmwareRevision() { - return mFirmwareRevision; - } - - /** - * Set Target device's firmware revision. - * @param firmwareRevision Target device's firmware revision - */ - public void setFirmwareRevision(final String firmwareRevision) { - mFirmwareRevision = firmwareRevision; - } - - /** - * Get Target device's serial number. - * @return Target device's serial number - */ - public String getSerialNumber() { - return mSerialNumber; - } - - /** - * Set Target device's serial number. - * @param serialNumber Target device's serial number - */ - public void setSerialNumber(final String serialNumber) { - mSerialNumber = serialNumber; - } - - /** - * Get Target device's software revision. - * @return Target device's software revision - */ - public String getSoftwareRevision() { - return mSoftwareRevision; - } - - /** - * Set Target device's software revision. - * @param softwareRevision Target device's software revision - */ - public void setSoftwareRevision(final String softwareRevision) { - mSoftwareRevision = softwareRevision; - } - - /** - * Get Target device's hardware revision. - * @return Target device's hardware revision - */ - public String getHardwareRevision() { - return mHardwareRevision; - } - - /** - * Set Target device's hardware revision. - * @param hardwareRevision Target device's hardware revision - */ - public void setHardwareRevision(final String hardwareRevision) { - mHardwareRevision = hardwareRevision; - } - - /** - * Get Target device's part number. - * @return Target device's part number - */ - public String getPartNumber() { - return mPartNumber; - } - - /** - * Set Target device's part number. - * @param partNumber Target device's part number - */ - public void setPartNumber(final String partNumber) { - mPartNumber = partNumber; - } - - /** - * Get Target device's protocol revision. - * @return Target device's protocol revision - */ - public String getProtocolRevision() { - return mProtocolRevision; - } - - /** - * Set Target device's protocol revision. - * @param protocolRevision Target device's protocol revision - */ - public void setProtocolRevision(final String protocolRevision) { - mProtocolRevision = protocolRevision; - } - - /** - * Get Target device's system id. - * @return Target device's system id - */ - public String getSystemId() { - return mSystemId; - } - - /** - * Set Target device's system id. - * @param systemId Target device's system id - */ - public void setSystemId(final String systemId) { - mSystemId = systemId; - } - - /** - * Get Target device's battery level. - * @return Target device's battery level - */ - public float getBatteryLevel() { - return mBatteryLevel; - } - - /** - * Set Target device's battery level. - * @param batteryLevel Target device's battery level - */ - public void setBatteryLevel(final float batteryLevel) { - mBatteryLevel = batteryLevel; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("{\"productName\": ").append(mProductName).append(", "); - builder.append("\"manufactureName\": ").append(mManufactureName).append(", "); - builder.append("\"modelNumber\": ").append(mModelNumber).append(", "); - builder.append("\"firmwareRevision\": ").append(mFirmwareRevision).append(", "); - builder.append("\"serialNumber\": ").append(mSerialNumber).append(", "); - builder.append("\"softwareRevision\": ").append(mSoftwareRevision).append(", "); - builder.append("\"hardwareRevision\": ").append(mHardwareRevision).append(", "); - builder.append("\"partNumber\": ").append(mPartNumber).append(", "); - builder.append("\"protocolRevision\": ").append(mProtocolRevision).append(", "); - builder.append("\"systemId\": ").append(mSystemId).append(", "); - builder.append("\"batteryLevel\": ").append(mBatteryLevel).append("} "); - return builder.toString(); - } - - /** - * To Bundle. - * @return bundle - */ - public Bundle toBundle() { - Bundle device = new Bundle(); - HealthProfile.setProductName(device, mProductName); - HealthProfile.setManufacturerName(device, mManufactureName); - HealthProfile.setModelNumber(device, mModelNumber); - HealthProfile.setFirmwareRevision(device, mFirmwareRevision); - HealthProfile.setSerialNumber(device, mSerialNumber); - HealthProfile.setSoftwareRevision(device, mSoftwareRevision); - HealthProfile.setHardwareRevision(device, mHardwareRevision); - HealthProfile.setPartNumber(device, mPartNumber); - HealthProfile.setProtocolRevision(device, mProtocolRevision); - HealthProfile.setSystemId(device, mSystemId); - HealthProfile.setBatteryLevel(device, mBatteryLevel); - return device; - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/TempExData.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/TempExData.java deleted file mode 100755 index 21caecdec8..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/TempExData.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - HitoeManager - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - -import java.util.ArrayList; - -/** - * Temporary holding the Exdata. - * @author NTT DOCOMO, INC. - */ -public class TempExData { - /** EX data's key. */ - private String mKey; - /** EX data's list. */ - private ArrayList mDataList; - - /** - * Consutructor. - * @param key Key - * @param dataList Ex data list - */ - public TempExData(final String key, final ArrayList dataList) { - setKey(key); - setDataList(new ArrayList<>()); - for (int i = 0; i < dataList.size(); i++) { - getDataList().add(dataList.get(i)); - } - } - - /** - * Get Ex data's key. - * @return Ex data's key - */ - public String getKey() { - return mKey; - } - - /** - * Set Ex data's key. - * @param key Ex data's key - */ - public void setKey(final String key) { - mKey = key; - } - - /** - * Get Ex data list. - * @return Ex data list - */ - public ArrayList getDataList() { - return mDataList; - } - - /** - * Set Ex data list. - * @param dataList Ex data list - */ - public void setDataList(final ArrayList dataList) { - mDataList = dataList; - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/WalkStateData.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/WalkStateData.java deleted file mode 100644 index 2049ee4727..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/WalkStateData.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - WalkStateData - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - -import android.os.Bundle; - -import org.deviceconnect.android.profile.WalkStateProfile; -import org.deviceconnect.profile.WalkStateProfileConstants; - -/** - * This class is information of WalkState. - * @author NTT DOCOMO, INC. - */ -public class WalkStateData { - - /** Step. */ - private int mStep; - /** Walk state. */ - private WalkStateProfileConstants.WalkState mState = WalkStateProfileConstants.WalkState.Stop; - /** Walk speed. */ - private double mSpeed; - /** Walk distance. */ - private double mDistance; - /** Walk balance. */ - private double mBalance; - /** Walk TimeStamp. */ - private long mTimeStamp; - /** Walk TimeStamp String. */ - private String mTimeStampString; - - /** - * Get Walk step count. - * @return Walk step count - */ - public int getStep() { - return mStep; - } - - /** - * Set Walk step count. - * @param step Walk step count - */ - public void setStep(final int step) { - mStep = step; - } - - /** - * Get Walk state. - * @return Walk state - */ - public WalkStateProfileConstants.WalkState getState() { - return mState; - } - - /** - * Set Walk state. - * @param state Walk state - */ - public void setState(final WalkStateProfileConstants.WalkState state) { - mState = state; - } - - /** - * Get walk speed. - * @return walk speed(km/s) - */ - public double getSpeed() { - return mSpeed; - } - - /** - * Set walk speed. - * @param speed walk speed - */ - public void setSpeed(final double speed) { - mSpeed = speed; - } - - /** - * Get walk distance. - * @return walk distance - */ - public double getDistance() { - return mDistance; - } - - /** - * Set walk distance. - * @param distance walk distance - */ - public void setDistance(final double distance) { - mDistance = distance; - } - - /** - * Get walk balance. - * @return walk balance - */ - public double getBalance() { - return mBalance; - } - - /** - * Set walk balance. - * @param balance walk balance - */ - public void setBalance(final double balance) { - mBalance = balance; - } - - /** - * Get TimeStamp. - * @return TimeStamp - */ - public long getTimeStamp() { - return mTimeStamp; - } - - /** - * Set TimeStamp. - * @param timeStamp TimeStamp - */ - public void setTimeStamp(final long timeStamp) { - this.mTimeStamp = timeStamp; - } - - /** - * Get TimeStamp String. - * @return TimeStamp String - */ - public String getTimeStampString() { - return mTimeStampString; - } - - /** - * Set TimeStamp string. - * @param timeStampString TimeStamp string - */ - public void setTimeStampString(final String timeStampString) { - mTimeStampString = timeStampString; - } - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("{\"steps\": ").append(mStep).append(", "); - builder.append("\"state\": ").append(mState.getState()).append(", "); - builder.append("\"speed\": ").append(mSpeed).append(", "); - builder.append("\"distance\": ").append(mDistance).append(", "); - builder.append("\"balance\": ").append(mBalance).append(", "); - builder.append("\"timeStamp\": ").append(mTimeStamp).append(", "); - builder.append("\"timeStampString\": ").append(mTimeStampString).append("} "); - return builder.toString(); - } - - /** - * To bundle. - * @return bundle - */ - public Bundle toBundle() { - Bundle walk = new Bundle(); - WalkStateProfile.setStep(walk, mStep); - WalkStateProfile.setState(walk, mState.getState()); - WalkStateProfile.setSpeed(walk, mSpeed); - WalkStateProfile.setDistance(walk, mDistance); - WalkStateProfile.setBalance(walk, mBalance); - WalkStateProfile.setTimestamp(walk, mTimeStamp); - WalkStateProfile.setTimestampString(walk, mTimeStampString); - return walk; - } - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/package-info.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/package-info.java deleted file mode 100755 index 2184271e4c..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/data/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/* -org.deviceconnect.android.deviceplugin.hitoe.data -Copyright (c) 2014 NTT DOCOMO,INC. -Released under the MIT license -http://opensource.org/licenses/mit-license.php - */ - -/** - * Data of Hitoe device. - */ -package org.deviceconnect.android.deviceplugin.hitoe.data; - diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileBatteryFragment.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileBatteryFragment.java deleted file mode 100644 index 9dac0fe874..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileBatteryFragment.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - HitoeDeviceSettingsFragment - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.R; -import org.deviceconnect.android.deviceplugin.hitoe.activity.HitoeDeviceControlActivity; -import org.deviceconnect.android.deviceplugin.hitoe.data.HeartRateData; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.data.TargetDeviceData; - - -/** - * This fragment do setting of the control battery profile. - * - * @author NTT DOCOMO, INC. - */ -public class HitoeProfileBatteryFragment extends Fragment { - - /** - * Current Hitoe Device object. - */ - private HitoeDevice mCurrentDevice; - - /** - * HeartRate TextView. - */ - private TextView mLevel; - /** - * Battery imageview. - */ - private ImageView mBatteryImage; - - @Override - public View onCreateView(final LayoutInflater inflater, final @Nullable ViewGroup container, - final @Nullable Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_battery_instructions, null); - rootView.findViewById(R.id.button_register).setOnClickListener((view) -> { - setBattery(); - }); - TextView title = rootView.findViewById(R.id.view_title); - mLevel = rootView.findViewById(R.id.battery_value); - mBatteryImage = rootView.findViewById(R.id.image_battery); - Bundle args = getArguments(); - if (args != null) { - - String serviceId = args.getString(HitoeDeviceControlActivity.FEATURE_SERVICE_ID); - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - mCurrentDevice = manager.getHitoeDeviceForServiceId(serviceId); - if (mCurrentDevice != null) { - String[] profiles = getResources().getStringArray(R.array.support_profiles); - title.setText(profiles[1] + getString(R.string.title_control)); - } - } - - return rootView; - } - - /** - * Set Battery value. - */ - public void setBattery() { - if (getActivity() == null) { - return; - } - getActivity().runOnUiThread(() -> { - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - HeartRateData heart = manager.getHeartRateData(mCurrentDevice.getId()); - TargetDeviceData device = heart.getDevice(); - if (device != null) { - float level = device.getBatteryLevel(); - if (level == 1.0) { - mBatteryImage.setImageResource(R.drawable.mark_battery01); - } else if (level == 0.75) { - mBatteryImage.setImageResource(R.drawable.mark_battery02); - } else if (level == 0.5) { - mBatteryImage.setImageResource(R.drawable.mark_battery03); - } else if (level == 0.25) { - mBatteryImage.setImageResource(R.drawable.mark_battery04); - } else { - mBatteryImage.setImageResource(R.drawable.mark_battery05); - } - mLevel.setText("" + (level * 100)); - } - }); - - } - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileDeviceOrientationFragment.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileDeviceOrientationFragment.java deleted file mode 100644 index a20c015420..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileDeviceOrientationFragment.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - HitoeProfileDeviceOrientationFragment - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment; - -import android.graphics.Color; -import android.graphics.Paint; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.LinearLayout; -import android.widget.TextView; - -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - -import org.achartengine.GraphicalView; -import org.achartengine.chart.LineChart; -import org.achartengine.chart.PointStyle; -import org.achartengine.model.XYMultipleSeriesDataset; -import org.achartengine.model.XYSeries; -import org.achartengine.renderer.XYMultipleSeriesRenderer; -import org.achartengine.renderer.XYSeriesRenderer; -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.R; -import org.deviceconnect.android.deviceplugin.hitoe.activity.HitoeDeviceControlActivity; -import org.deviceconnect.android.deviceplugin.hitoe.data.AccelerationData; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeConstants; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.util.HitoeScheduler; - -import java.util.ArrayList; -import java.util.List; - - -/** - * This fragment do setting of the control DeviceOrientation profile. - * - * @author NTT DOCOMO, INC. - */ -public class HitoeProfileDeviceOrientationFragment extends Fragment implements HitoeScheduler.OnRegularNotify { - - /** Title size. */ - public static final int CHART_TITLE_SIZE = 25; - /** Label size. */ - public static final int LABELS_SIZE = 16; - /** Axis Title. */ - public static final int AXIS_TITLE_SIZE = 25; - /** Axis color. */ - public static final int AXIS_COLOR = Color.GRAY; - /** Grid color. */ - public static final int GRID_COLOR = Color.GRAY; - /** Title color. */ - public static final int TITLE_COLOR = Color.GRAY; - /** x label color. */ - public static final int XLABEL_COLOR = Color.GRAY; - /** y label color. */ - public static final int YLABEL_COLOR = Color.GRAY; - - /** data count. */ - private static final int DATA_COUNT = 3; - /** orientation title. */ - private static final String[] TITLES = new String[] {"X", "Y", "Z" }; - /** data color. */ - private static final int[] COLORS = new int[] {Color.RED, Color.GREEN, Color.BLUE }; - /** data count. */ - private static final long MAX_RANGE = 5000; - - - /** Acc data. */ - private List mACCList = null; - /** Graph data . */ - private LineChart mLineChart; - /** Graph view. */ - private GraphicalView mGraphicalView; - /** Graph render. */ - private XYMultipleSeriesRenderer mXYMultipleSeriesRenderer; - /** min data. */ - private long mMinX = 0; - /** max data. */ - private long mMaxX = mMinX + MAX_RANGE; - - - - /** - * Current Hitoe Device object. - */ - private HitoeDevice mCurrentDevice; - - /** - * Hitoe's Scheduler. - */ - private HitoeScheduler mScheduler; - - @Override - public View onCreateView(final LayoutInflater inflater, final @Nullable ViewGroup container, - final @Nullable Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_orientation_instructions, null); - mScheduler = new HitoeScheduler(this,HitoeConstants.ACC_CHART_UPDATE_CYCLE_TIME, - HitoeConstants.ACC_CHART_UPDATE_CYCLE_TIME); - - rootView.findViewById(R.id.button_register).setOnClickListener((view) -> { - clear(); - mScheduler.scanHitoeDevice(true); - }); - rootView.findViewById(R.id.button_unregister).setOnClickListener((view) -> { - mScheduler.scanHitoeDevice(false); - }); - TextView title = (TextView) rootView.findViewById(R.id.view_title); - Bundle args = getArguments(); - if (args != null) { - - String serviceId = args.getString(HitoeDeviceControlActivity.FEATURE_SERVICE_ID); - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - mCurrentDevice = manager.getHitoeDeviceForServiceId(serviceId); - if (mCurrentDevice != null) { - String[] profiles = getResources().getStringArray(R.array.support_profiles); - title.setText(profiles[2] + getString(R.string.title_control)); - } - } - init(); - ((LinearLayout) rootView.findViewById(R.id.acc_chart)).addView(mGraphicalView); - return rootView; - } - - @Override - public void onDestroy() { - super.onDestroy(); - mScheduler.scanHitoeDevice(false); - } - - @Override - public void onRegularNotify() { - if (getActivity() == null) { - return; - } - getActivity().runOnUiThread(() -> { - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - AccelerationData acc = manager.getAccelerationData(mCurrentDevice.getId()); - if (acc != null) { - double[] accs = new double[3]; - accs[0] = acc.getAccelX(); - accs[1] = acc.getAccelY(); - accs[2] = acc.getAccelZ(); - setACC(System.currentTimeMillis(), accs); - updateChart(); - } - }); - } - - /** - * Initialilze chart. - */ - private void init() { - mACCList = new ArrayList<>(); - mACCList.add(new XYSeries(TITLES[0])); - mACCList.add(new XYSeries(TITLES[1])); - mACCList.add(new XYSeries(TITLES[2])); - XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); - dataset.addAllSeries(mACCList); - - this.mXYMultipleSeriesRenderer = buildRenderer(); - mLineChart = new LineChart(dataset, mXYMultipleSeriesRenderer); - mGraphicalView = new GraphicalView(getActivity(), mLineChart); - } - - /** - * Set Acceleration data. - * @param timestamp timestamp - * @param accList acceleration data list - */ - private void setACC(final long timestamp, final double[] accList) { - - if (this.mACCList.get(0).getItemCount() == 0) { - mMinX = timestamp; - mMaxX = timestamp + MAX_RANGE; - } - - if (timestamp > mMaxX || this.mACCList.get(0).getItemCount() > MAX_RANGE / 40) { - this.mACCList.get(0).clear(); - this.mACCList.get(1).clear(); - this.mACCList.get(2).clear(); - - mMinX = timestamp; - mMaxX = timestamp + MAX_RANGE; - } - - this.mACCList.get(0).add(timestamp, accList[0]); - this.mACCList.get(1).add(timestamp, accList[1]); - this.mACCList.get(2).add(timestamp, accList[2]); - } - - /** - * Update chart. - */ - private void updateChart() { - mXYMultipleSeriesRenderer.setXAxisMin(mMinX); - mXYMultipleSeriesRenderer.setXAxisMax(mMaxX); - - mGraphicalView.repaint(); - } - - /** - * Clear chart. - */ - private void clear() { - mACCList.get(0).clear(); - mACCList.get(1).clear(); - mACCList.get(2).clear(); - mGraphicalView.repaint(); - } - - /** - * Build chart's renderer. - * @return chart renderer - */ - private XYMultipleSeriesRenderer buildRenderer() { - - XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(); - for (int i = 0; i < DATA_COUNT; i++) { - XYSeriesRenderer r = new XYSeriesRenderer(); - r.setColor(COLORS[i]); - r.setLineWidth(4f); - r.setPointStyle(PointStyle.CIRCLE); - r.setFillPoints(true); - r.setPointStrokeWidth(1f); - renderer.addSeriesRenderer(r); - } - - renderer.setPointSize(1f); - renderer.setChartTitle("加速度"); - renderer.setChartTitleTextSize(CHART_TITLE_SIZE); - - renderer.setXTitle("経過時間 [ms]"); - renderer.setYTitle(" [G]"); - - renderer.setLabelsTextSize(LABELS_SIZE); - renderer.setLabelsColor(TITLE_COLOR); - renderer.setXLabelsAlign(Paint.Align.LEFT); - renderer.setYLabelsAlign(Paint.Align.RIGHT); - - renderer.setXLabelsColor(XLABEL_COLOR); - renderer.setYLabelsColor(0, YLABEL_COLOR); - - renderer.setAxisTitleTextSize(AXIS_TITLE_SIZE); - renderer.setAxesColor(AXIS_COLOR); - renderer.setXAxisMin(mMinX); - renderer.setXAxisMax(mMaxX); - renderer.setYAxisMin(-3.0); - renderer.setYAxisMax(3.0); - - renderer.setShowGridX(true); - renderer.setShowGridY(true); - renderer.setGridColor(GRID_COLOR); - - renderer.setApplyBackgroundColor(true); - renderer.setBackgroundColor(Color.WHITE); - - renderer.setMargins(new int[] {16, 48, 16, 8 }); - renderer.setMarginsColor(Color.argb(0, 255, 255, 255)); - - renderer.setPanEnabled(false, false); - - renderer.setShowLegend(true); - renderer.setLegendTextSize(15); - renderer.setFitLegend(false); - - renderer.setZoomButtonsVisible(false); - - renderer.setZoomEnabled(false, false); - - return renderer; - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileECGFragment.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileECGFragment.java deleted file mode 100644 index d306603f52..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileECGFragment.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - HitoeProfileECGFragment - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment; - -import android.graphics.Color; -import android.graphics.Paint; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.LinearLayout; -import android.widget.TextView; - -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - -import org.achartengine.GraphicalView; -import org.achartengine.chart.LineChart; -import org.achartengine.chart.PointStyle; -import org.achartengine.model.XYMultipleSeriesDataset; -import org.achartengine.model.XYSeries; -import org.achartengine.renderer.XYMultipleSeriesRenderer; -import org.achartengine.renderer.XYSeriesRenderer; -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.R; -import org.deviceconnect.android.deviceplugin.hitoe.activity.HitoeDeviceControlActivity; -import org.deviceconnect.android.deviceplugin.hitoe.data.HeartRateData; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeConstants; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.util.HitoeScheduler; - -import java.util.ArrayList; -import java.util.List; - - -/** - * This fragment do setting of the control ECG profile. - * - * @author NTT DOCOMO, INC. - */ -public class HitoeProfileECGFragment extends Fragment implements HitoeScheduler.OnRegularNotify { - - /** Title size. */ - public static final int CHART_TITLE_SIZE = 25; - /** Label size. */ - public static final int LABELS_SIZE = 16; - /** Axis Title. */ - public static final int AXIS_TITLE_SIZE = 25; - /** Axis color. */ - public static final int AXIS_COLOR = Color.GRAY; - /** Grid color. */ - public static final int GRID_COLOR = Color.GRAY; - /** Title color. */ - public static final int TITLE_COLOR = Color.GRAY; - /** x label color. */ - public static final int XLABEL_COLOR = Color.GRAY; - /** y label color. */ - public static final int YLABEL_COLOR = Color.GRAY; - - /** data count. */ - private static final int DATA_COUNT = 1; - /** orientation title. */ - private static final String[] TITLES = new String[] {"ECG" }; - /** data color. */ - private static final int[] COLORS = new int[] {Color.GREEN }; - /** data count. */ - private static final long MAX_RANGE = 10000; - - /** ECG. */ - private List mECGList = null; - /** Graph data . */ - private LineChart mLineChart; - /** Graph view. */ - private GraphicalView mGraphicalView; - /** Graph render. */ - private XYMultipleSeriesRenderer mXYMultipleSeriesRenderer; - /** min data. */ - private long mMinX = 0; - /** max data. */ - private long mMaxX = mMinX + MAX_RANGE; - - - - /** - * Current Hitoe Device object. - */ - private HitoeDevice mCurrentDevice; - - /** - * Hitoe Scheduler. - */ - private HitoeScheduler mScheduler; - - @Override - public View onCreateView(final LayoutInflater inflater, final @Nullable ViewGroup container, - final @Nullable Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_ecg_instructions, null); - mScheduler = new HitoeScheduler(this, HitoeConstants.ACC_CHART_UPDATE_CYCLE_TIME, - HitoeConstants.ACC_CHART_UPDATE_CYCLE_TIME); - - rootView.findViewById(R.id.button_register).setOnClickListener((view) -> { - clear(); - mScheduler.scanHitoeDevice(true); - }); - rootView.findViewById(R.id.button_unregister).setOnClickListener((view) -> { - mScheduler.scanHitoeDevice(false); - }); - TextView title = rootView.findViewById(R.id.view_title); - Bundle args = getArguments(); - if (args != null) { - - String serviceId = args.getString(HitoeDeviceControlActivity.FEATURE_SERVICE_ID); - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - mCurrentDevice = manager.getHitoeDeviceForServiceId(serviceId); - if (mCurrentDevice != null) { - String[] profiles = getResources().getStringArray(R.array.support_profiles); - title.setText(profiles[3] + getString(R.string.title_control)); - } - } - init(); - ((LinearLayout) rootView.findViewById(R.id.ecg_chart)).addView(mGraphicalView); - return rootView; - } - - @Override - public void onDestroy() { - super.onDestroy(); - mScheduler.scanHitoeDevice(false); - } - - - @Override - public void onRegularNotify() { - if (getActivity() == null) { - return; - } - getActivity().runOnUiThread(() -> { - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - HeartRateData ecg = manager.getECGData(mCurrentDevice.getId()); - if (ecg != null) { - setECG(ecg.getECG().getTimeStamp(), ecg.getECG().getValue()); - updateChart(); - } - }); - } - - /** - * Initialize ECG chart. - */ - private void init() { - this.mECGList = new ArrayList<>(); - this.mECGList.add(new XYSeries(TITLES[0])); - XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); - dataset.addAllSeries(this.mECGList); - - this.mXYMultipleSeriesRenderer = buildRenderer(); - mLineChart = new LineChart(dataset, mXYMultipleSeriesRenderer); - mGraphicalView = new GraphicalView(getActivity(), mLineChart); - } - - /** - * Set ECG data. - * @param timestamp timestamp - * @param ecg ecg data - */ - private void setECG(final long timestamp, final double ecg) { - if (mECGList.get(0).getItemCount() == 0) { - mMinX = timestamp; - mMaxX = timestamp + MAX_RANGE; - } - - if (timestamp > mMaxX || mECGList.get(0).getItemCount() > MAX_RANGE / 40) { - this.mECGList.get(0).clear(); - mMinX = timestamp; - mMaxX = timestamp + MAX_RANGE; - } - mECGList.get(0).add(timestamp, ecg / 1000); - } - - /** - * Update chart. - */ - private synchronized void updateChart() { - mXYMultipleSeriesRenderer.setXAxisMin(mMinX); - mXYMultipleSeriesRenderer.setXAxisMax(mMaxX); - - mGraphicalView.repaint(); - } - - /** - * Clear chart. - */ - private synchronized void clear() { - this.mECGList.get(0).clear(); - mGraphicalView.repaint(); - } - - /** - * Build ECG Chart renderer. - * @return ecg chart renderer - */ - private XYMultipleSeriesRenderer buildRenderer() { - - XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(); - - for (int i = 0; i < DATA_COUNT; i++) { - XYSeriesRenderer r = new XYSeriesRenderer(); - r.setColor(COLORS[i]); - r.setLineWidth(4f); - r.setPointStyle(PointStyle.CIRCLE); - r.setFillPoints(true); - r.setPointStrokeWidth(1f); - renderer.addSeriesRenderer(r); - } - - renderer.setPointSize(1f); - renderer.setChartTitle("心電"); - renderer.setChartTitleTextSize(CHART_TITLE_SIZE); - - renderer.setXTitle("経過時間 [ms]"); - renderer.setYTitle(" [μv]"); - - renderer.setLabelsTextSize(LABELS_SIZE); - renderer.setLabelsColor(TITLE_COLOR); - renderer.setXLabelsAlign(Paint.Align.LEFT); - renderer.setYLabelsAlign(Paint.Align.RIGHT); - - renderer.setXLabelsColor(XLABEL_COLOR); - renderer.setYLabelsColor(0, YLABEL_COLOR); - - renderer.setAxisTitleTextSize(AXIS_TITLE_SIZE); - renderer.setAxesColor(AXIS_COLOR); - renderer.setXAxisMin(mMinX); - renderer.setXAxisMax(mMaxX); - renderer.setYAxisMin(-3.0); - renderer.setYAxisMax(3.0); - - renderer.setShowGridX(true); - renderer.setShowGridY(true); - renderer.setGridColor(GRID_COLOR); - - renderer.setApplyBackgroundColor(true); - renderer.setBackgroundColor(Color.BLACK); - - renderer.setMargins(new int[] {16, 48, 16, 8 }); - renderer.setMarginsColor(Color.argb(0, 255, 255, 255)); - renderer.setPanEnabled(false, false); - renderer.setShowLegend(true); - renderer.setLegendTextSize(15); - renderer.setFitLegend(false); - - renderer.setZoomButtonsVisible(false); - renderer.setZoomEnabled(false, false); - - return renderer; - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileHealthFragment.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileHealthFragment.java deleted file mode 100644 index d88ad9f141..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileHealthFragment.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - HitoeProfileHealthFragment - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.R; -import org.deviceconnect.android.deviceplugin.hitoe.activity.HitoeDeviceControlActivity; -import org.deviceconnect.android.deviceplugin.hitoe.data.HeartData; -import org.deviceconnect.android.deviceplugin.hitoe.data.HeartRateData; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeConstants; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.util.HitoeScheduler; - - -/** - * This fragment do setting of the control health profile. - * - * @author NTT DOCOMO, INC. - */ -public class HitoeProfileHealthFragment extends Fragment implements HitoeScheduler.OnRegularNotify { - - /** - * Current Hitoe Device object. - */ - private HitoeDevice mCurrentDevice; - - /** - * HeartRate TextView. - */ - private TextView mHeartRate; - /** - * Hitoe Scheduler. - */ - private HitoeScheduler mScheduler; - - @Override - public View onCreateView(final LayoutInflater inflater, final @Nullable ViewGroup container, - final @Nullable Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_heartrate_instructions, null); - mScheduler = new HitoeScheduler(this, HitoeConstants.HR_TEXT_UPDATE_CYCLE_TIME, - HitoeConstants.HR_TEXT_UPDATE_CYCLE_TIME); - rootView.findViewById(R.id.button_register).setOnClickListener((view) -> { - mScheduler.scanHitoeDevice(true); - }); - rootView.findViewById(R.id.button_unregister).setOnClickListener((view) -> { - mScheduler.scanHitoeDevice(false); - }); - TextView title = rootView.findViewById(R.id.view_title); - mHeartRate = rootView.findViewById(R.id.heartrate_value); - Bundle args = getArguments(); - if (args != null) { - - String serviceId = args.getString(HitoeDeviceControlActivity.FEATURE_SERVICE_ID); - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - mCurrentDevice = manager.getHitoeDeviceForServiceId(serviceId); - if (mCurrentDevice != null) { - String[] profiles = getResources().getStringArray(R.array.support_profiles); - title.setText(profiles[0] + getString(R.string.title_control)); - } - } - - return rootView; - } - - - @Override - public void onDestroy() { - super.onDestroy(); - mScheduler.scanHitoeDevice(false); - } - - @Override - public void onRegularNotify() { - if (getActivity() == null) { - return; - } - getActivity().runOnUiThread(() -> { - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - HeartRateData heart = manager.getHeartRateData(mCurrentDevice.getId()); - if (heart != null) { - HeartData rate = heart.getHeartRate(); - if (rate != null) { - mHeartRate.setText("" + rate.getValue()); - } - } - }); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileListFragment.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileListFragment.java deleted file mode 100644 index 79da3ad1f1..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileListFragment.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - HitoeProfileListFragment - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.ListView; -import android.widget.TextView; - -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.R; -import org.deviceconnect.android.deviceplugin.hitoe.activity.HitoeDeviceControlActivity; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; - - -/** - * This fragment do setting of the control hitoe device. - * - * @author NTT DOCOMO, INC. - */ -public class HitoeProfileListFragment extends Fragment implements AdapterView.OnItemClickListener { - - /** - * Bluetooth device list view. - */ - private ListView mProfileListView; - - /** - * Current control hitoe device info object. - */ - private HitoeDevice mCurrentDevice; - - /** page title. */ - private TextView mTitle; - - - @Override - public View onCreateView(final LayoutInflater inflater, final @Nullable ViewGroup container, - final @Nullable Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.activity_hitoe_device_list, null); - Button underBtn = (Button) rootView.findViewById(R.id.btn_add_open); - underBtn.setVisibility(View.GONE); - mTitle = (TextView) rootView.findViewById(R.id.view_title); - mProfileListView = (ListView) rootView.findViewById(R.id.device_list_view); - String[] profiles = getResources().getStringArray(R.array.support_profiles); - ArrayAdapter mAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, profiles); - mProfileListView.setAdapter(mAdapter); - mProfileListView.setOnItemClickListener(this); - - Bundle args = getArguments(); - if (args != null) { - - String serviceId = args.getString(HitoeDeviceControlActivity.FEATURE_SERVICE_ID); - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - mCurrentDevice = manager.getHitoeDeviceForServiceId(serviceId); - if (mCurrentDevice != null) { - mTitle.setText(mCurrentDevice.getName() + " " + getString(R.string.title_control)); - } - } - - return rootView; - } - - - @Override - public void onItemClick(final AdapterView adapterView, final View view, final int i, final long l) { - HitoeDeviceControlActivity control = (HitoeDeviceControlActivity) getActivity(); - control.movePage(i + 1); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfilePoseEstimationFragment.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfilePoseEstimationFragment.java deleted file mode 100644 index 9194a303f2..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfilePoseEstimationFragment.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - HitoeProfileHealthFragment - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.R; -import org.deviceconnect.android.deviceplugin.hitoe.activity.HitoeDeviceControlActivity; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeConstants; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.data.PoseEstimationData; -import org.deviceconnect.android.deviceplugin.hitoe.util.HitoeScheduler; -import org.deviceconnect.profile.PoseEstimationProfileConstants; - - -/** - * This fragment do setting of the control health profile. - * - * @author NTT DOCOMO, INC. - */ -public class HitoeProfilePoseEstimationFragment extends Fragment implements HitoeScheduler.OnRegularNotify { - - /** - * Current Hitoe Device object. - */ - private HitoeDevice mCurrentDevice; - - /** - * Pose ImageView. - */ - private ImageView mPoseView; - /** - * Hitoe scheduler. - */ - private HitoeScheduler mScheduler; - - @Override - public View onCreateView(final LayoutInflater inflater, final @Nullable ViewGroup container, - final @Nullable Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_pose_instructions, null); - mScheduler = new HitoeScheduler(this, HitoeConstants.HR_TEXT_UPDATE_CYCLE_TIME, - HitoeConstants.HR_TEXT_UPDATE_CYCLE_TIME); - rootView.findViewById(R.id.button_register).setOnClickListener((view) -> { - mScheduler.scanHitoeDevice(true); - }); - rootView.findViewById(R.id.button_unregister).setOnClickListener((view) -> { - mScheduler.scanHitoeDevice(false); - }); - TextView title = rootView.findViewById(R.id.view_title); - mPoseView = rootView.findViewById(R.id.pose_image); - Bundle args = getArguments(); - if (args != null) { - - String serviceId = args.getString(HitoeDeviceControlActivity.FEATURE_SERVICE_ID); - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - mCurrentDevice = manager.getHitoeDeviceForServiceId(serviceId); - if (mCurrentDevice != null) { - String[] profiles = getResources().getStringArray(R.array.support_profiles); - title.setText(profiles[5] + getString(R.string.title_control)); - } - } - - return rootView; - } - - - @Override - public void onDestroy() { - super.onDestroy(); - mScheduler.scanHitoeDevice(false); - } - - @Override - public void onRegularNotify() { - if (getActivity() == null) { - return; - } - getActivity().runOnUiThread(() -> { - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - PoseEstimationData pose = manager.getPoseEstimationData(mCurrentDevice.getId()); - if (pose != null) { - int poseResource = R.drawable.pose_default; - if (pose.getPoseState() == PoseEstimationProfileConstants.PoseState.Backward) { - poseResource = R.drawable.pose_backward; - } else if (pose.getPoseState() == PoseEstimationProfileConstants.PoseState.FaceDown) { - poseResource = R.drawable.pose_facedown; - } else if (pose.getPoseState() == PoseEstimationProfileConstants.PoseState.FaceLeft) { - poseResource = R.drawable.pose_faceleft; - } else if (pose.getPoseState() == PoseEstimationProfileConstants.PoseState.FaceRight) { - poseResource = R.drawable.pose_faceright; - } else if (pose.getPoseState() == PoseEstimationProfileConstants.PoseState.FaceUp) { - poseResource = R.drawable.pose_faceup; - } else if (pose.getPoseState() == PoseEstimationProfileConstants.PoseState.Forward) { - poseResource = R.drawable.pose_forward; - } else if (pose.getPoseState() == PoseEstimationProfileConstants.PoseState.Leftside) { - poseResource = R.drawable.pose_leftside; - } else if (pose.getPoseState() == PoseEstimationProfileConstants.PoseState.Rightside) { - poseResource = R.drawable.pose_rightside; - } else if (pose.getPoseState() == PoseEstimationProfileConstants.PoseState.Standing) { - poseResource = R.drawable.pose_standing; - } - mPoseView.setImageResource(poseResource); - } - }); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileStressEstimationFragment.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileStressEstimationFragment.java deleted file mode 100644 index 8455305b8f..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileStressEstimationFragment.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - HitoeProfileHealthFragment - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment; - -import android.graphics.Color; -import android.graphics.drawable.GradientDrawable; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.R; -import org.deviceconnect.android.deviceplugin.hitoe.activity.HitoeDeviceControlActivity; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeConstants; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.data.StressEstimationData; -import org.deviceconnect.android.deviceplugin.hitoe.util.HitoeScheduler; - - -/** - * This fragment do setting of the control health profile. - * - * @author NTT DOCOMO, INC. - */ -public class HitoeProfileStressEstimationFragment extends Fragment implements HitoeScheduler.OnRegularNotify { - - /** - * Current Hitoe Device object. - */ - private HitoeDevice mCurrentDevice; - - /** - * HeartRate TextView. - */ - private TextView mLFHF; - /** - * Hitoe scheduler. - */ - private HitoeScheduler mScheduler; - /** LFHF view. */ - private GradientDrawable mLFHFGradientDrawable; - - @Override - public View onCreateView(final LayoutInflater inflater, final @Nullable ViewGroup container, - final @Nullable Bundle savedInstanceState) { - - View rootView = inflater.inflate(R.layout.fragment_stress_instructions, null); - mScheduler = new HitoeScheduler(this, HitoeConstants.LFHF_TEXT_UPDATE_CYCLE_TIME, - HitoeConstants.LFHF_TEXT_UPDATE_CYCLE_TIME); - rootView.findViewById(R.id.button_register).setOnClickListener((view) -> { - mScheduler.scanHitoeDevice(true); - }); - rootView.findViewById(R.id.button_unregister).setOnClickListener((view) -> { - mScheduler.scanHitoeDevice(false); - }); - TextView title = rootView.findViewById(R.id.view_title); - mLFHF = rootView.findViewById(R.id.lfhf_value); - Bundle args = getArguments(); - if (args != null) { - - String serviceId = args.getString(HitoeDeviceControlActivity.FEATURE_SERVICE_ID); - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - mCurrentDevice = manager.getHitoeDeviceForServiceId(serviceId); - if (mCurrentDevice != null) { - String[] profiles = getResources().getStringArray(R.array.support_profiles); - title.setText(profiles[4] + getString(R.string.title_control)); - } - } - mLFHFGradientDrawable = (GradientDrawable) mLFHF.getBackground(); - return rootView; - } - - @Override - public void onDestroy() { - super.onDestroy(); - mScheduler.scanHitoeDevice(false); - } - - @Override - public void onRegularNotify() { - if (getActivity() == null) { - return; - } - getActivity().runOnUiThread(() -> { - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - StressEstimationData stress = manager.getStressEstimationData(mCurrentDevice.getId()); - if (stress != null) { - updateView(stress.getTimeStamp(), stress.getLFHFValue()); - } - }); - } - - /** - * Update view. - * @param timestamp timestamp - * @param lfhf stress estimation - */ - public void updateView(final long timestamp, final double lfhf) { - - final int scoreRGB; - final int scoreR; - final int scoreG; - final int scoreB; - - if (timestamp == -1) { - - return; - } - scoreRGB = (int) (150 * (lfhf / 5)); - if(105 + scoreRGB < 255) { - scoreR = 105 + scoreRGB; - } else { - scoreR = 255; - } - if(255 - scoreRGB > 0) { - scoreG = 255 - scoreRGB; - scoreB = 255 - scoreRGB; - } else { - scoreG = 0; - scoreB = 0; - } - - mLFHF.setText("LF/HF:" + String.valueOf(lfhf)); - mLFHFGradientDrawable.setColors(new int[]{0xFFCDFFFF, Color.rgb(scoreR, scoreG, scoreB)}); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileWalkStateFragment.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileWalkStateFragment.java deleted file mode 100644 index dabe9cc9ae..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/HitoeProfileWalkStateFragment.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - HitoeProfileHealthFragment - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.R; -import org.deviceconnect.android.deviceplugin.hitoe.activity.HitoeDeviceControlActivity; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeConstants; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.data.WalkStateData; -import org.deviceconnect.android.deviceplugin.hitoe.util.HitoeScheduler; - - -/** - * This fragment do setting of the control health profile. - * - * @author NTT DOCOMO, INC. - */ -public class HitoeProfileWalkStateFragment extends Fragment implements HitoeScheduler.OnRegularNotify { - - /** - * Current Hitoe Device object. - */ - private HitoeDevice mCurrentDevice; - - /** - * Step TextView. - */ - private TextView mStep; - /** - * State TextView. - */ - private TextView mState; - - /** - * Speed TextView. - */ - private TextView mSpeed; - /** - * Distance TextView. - */ - private TextView mDistance; - /** - * Balance TextView. - */ - private TextView mBalance; - - /** Hitoe Scheduler. */ - private HitoeScheduler mScheduler; - - @Override - public View onCreateView(final LayoutInflater inflater, final @Nullable ViewGroup container, - final @Nullable Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_walk_instructions, null); - mScheduler = new HitoeScheduler(this, HitoeConstants.HR_TEXT_UPDATE_CYCLE_TIME, - HitoeConstants.HR_TEXT_UPDATE_CYCLE_TIME); - rootView.findViewById(R.id.button_register).setOnClickListener((view) -> { - mScheduler.scanHitoeDevice(true); - }); - rootView.findViewById(R.id.button_unregister).setOnClickListener((view) -> { - mScheduler.scanHitoeDevice(false); - }); - TextView title = rootView.findViewById(R.id.view_title); - mStep = rootView.findViewById(R.id.walk_step); - mState = rootView.findViewById(R.id.walk_state); - mSpeed = rootView.findViewById(R.id.walk_speed); - mDistance = rootView.findViewById(R.id.walk_distance); - mBalance = rootView.findViewById(R.id.walk_balance); - - Bundle args = getArguments(); - if (args != null) { - - String serviceId = args.getString(HitoeDeviceControlActivity.FEATURE_SERVICE_ID); - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - mCurrentDevice = manager.getHitoeDeviceForServiceId(serviceId); - if (mCurrentDevice != null) { - String[] profiles = getResources().getStringArray(R.array.support_profiles); - title.setText(profiles[6] + getString(R.string.title_control)); - } - } - - return rootView; - } - - @Override - public void onDestroy() { - super.onDestroy(); - mScheduler.scanHitoeDevice(false); - } - - @Override - public void onRegularNotify() { - if (getActivity() == null) { - return; - } - getActivity().runOnUiThread(() -> { - HitoeApplication app = (HitoeApplication) getActivity().getApplication(); - HitoeManager manager = app.getHitoeManager(); - - WalkStateData walk = manager.getWalkStateData(mCurrentDevice.getId()); - if (walk != null) { - mStep.setText("" + walk.getStep()); - mState.setText(walk.getState().getState()); - mSpeed.setText("" + walk.getSpeed()); - mDistance.setText("" + walk.getDistance()); - mBalance.setText("" + walk.getBalance()); - } - }); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/DefaultDialogFragment.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/DefaultDialogFragment.java deleted file mode 100644 index e3ef7b0b9e..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/DefaultDialogFragment.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - DefaultDialogFragment.java - Copyright (c) 2015 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment.dialog; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.app.DialogFragment; -import android.app.ProgressDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.CheckBox; -import android.widget.ImageView; -import android.widget.TextView; - -import org.deviceconnect.android.deviceplugin.hitoe.R; -import org.deviceconnect.android.deviceplugin.hitoe.util.UserSettings; - -/** - * Alert show fragment. - * @author NTT DOCOMO, INC. - */ -public class DefaultDialogFragment extends DialogFragment { - - /** - * Factory Method. - * @param title dialog's title - * @param message dialog's message - * @return dialog fragment - */ - public static DefaultDialogFragment newInstance(final String title, - final String message) { - DefaultDialogFragment instance = new DefaultDialogFragment(); - - Bundle arguments = new Bundle(); - arguments.putString("title", title); - arguments.putString("message", message); - - instance.setArguments(arguments); - - return instance; - } - - @Override - public Dialog onCreateDialog(final Bundle savedInstanceState) { - String title = getArguments().getString("title"); - String message = getArguments().getString("message"); - - ProgressDialog progressDialog = new ProgressDialog(getActivity()); - progressDialog.setTitle(title); - progressDialog.setMessage(message); - progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); - setCancelable(false); - - return progressDialog; - } - - - - /** - * Show Confirm Alert. - * @param activity Activity - * @param title title - * @param message message - * @param positiveBtnMsg Positive Button Message - * @param listener listener - */ - public static void showConfirmAlert(final Activity activity, final String title, final String message, - final String positiveBtnMsg, - final DialogInterface.OnClickListener listener) { - if (activity == null) { - return; - } - - new AlertDialog.Builder(activity) - .setTitle(title) - .setMessage(message) - .setPositiveButton(positiveBtnMsg, listener) - .setNegativeButton(R.string.cancel, null) - .show(); - } - - /** - * Show Hitoe On state dialog. - * @param activity activity - */ - public static void showHitoeONStateDialog(final Activity activity) { - if (activity == null) { - return; - } - final UserSettings userSettings = new UserSettings(activity); - if (userSettings.isNextState()) { - return; - } - LayoutInflater inflater = (LayoutInflater) activity.getSystemService( - Context.LAYOUT_INFLATER_SERVICE); - final View layout = inflater.inflate(R.layout.dialog_hitoe_on, null); - ImageView explain = (ImageView) layout.findViewById(R.id.hitoe_explain); - TextView message = (TextView) layout.findViewById(R.id.explain_message); - message.setText(R.string.dialog_message_lunch_hitoe); - explain.setVisibility(View.VISIBLE); - new AlertDialog.Builder(activity) - .setView(layout) - .setTitle(activity.getString(R.string.dialog_title_lunch_hitoe)) - .setNeutralButton(R.string.ok, (dialogInterface, i) -> { - CheckBox nextState = (CheckBox) layout.findViewById(R.id.chceck_next); - userSettings.setNextState(nextState.isChecked()); - }) - .show(); - } - - /** - * Show Hitoe set shirt dialog. - * @param activity activity - */ - public static void showHitoeSetShirtDialog(final Activity activity) { - if (activity == null) { - return; - } - LayoutInflater inflater = (LayoutInflater) activity.getSystemService( - Context.LAYOUT_INFLATER_SERVICE); - final View layout = inflater.inflate(R.layout.dialog_hitoe_set, null); - new AlertDialog.Builder(activity) - .setView(layout) - .setTitle(activity.getString(R.string.dialog_title_equip_hitoe)) - .setNeutralButton(R.string.ok, (dialogInterface,i) -> { - }) - .show(); - } - - - /** - * Show Hitoe warning message dialog. - * @param activity activity - */ - public static void showHitoeWarningMessageDialog(final Activity activity) { - if (activity == null) { - return; - } - final UserSettings userSettings = new UserSettings(activity); - if (userSettings.isWarningMessage()) { - return; - } - LayoutInflater inflater = (LayoutInflater) activity.getSystemService( - Context.LAYOUT_INFLATER_SERVICE); - final View layout = inflater.inflate(R.layout.dialog_hitoe_on, null); - ImageView explain = (ImageView) layout.findViewById(R.id.hitoe_explain); - TextView message = (TextView) layout.findViewById(R.id.explain_message); - message.setText(R.string.warning_connections); - explain.setVisibility(View.GONE); - new AlertDialog.Builder(activity) - .setView(layout) - .setTitle(activity.getString(R.string.warning_title)) - .setNeutralButton(R.string.ok, (dialogInterface, i) -> { - CheckBox nextState = layout.findViewById(R.id.chceck_next); - userSettings.setWarningMessage(nextState.isChecked()); - }) - .show(); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/ErrorDialogFragment.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/ErrorDialogFragment.java deleted file mode 100644 index bded73e96b..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/ErrorDialogFragment.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - ErrorDialogFragment - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment.dialog; - -import android.app.AlertDialog; -import android.app.Dialog; -import android.content.DialogInterface; -import android.os.Bundle; - -import androidx.annotation.NonNull; -import androidx.fragment.app.DialogFragment; - -import org.deviceconnect.android.deviceplugin.hitoe.R; - - -/** - * This fragment displays a dialog of error. - * @author NTT DOCOMO, INC. - */ -public class ErrorDialogFragment extends DialogFragment { - /** - * Title's key. - */ - private static final String PARAM_TITLE = "title"; - /** - * Message's key. - */ - private static final String PARAM_MESSAGE = "message"; - /** dialog. */ - private AlertDialog mDialog; - /** dialog's listener. */ - private DialogInterface.OnDismissListener mListener; - - /** - * Initialize error dialog. - * @param title dialog's title - * @param message dialog's message - * @return error dialog - */ - public static ErrorDialogFragment newInstance(final String title, final String message) { - ErrorDialogFragment instance = new ErrorDialogFragment(); - - Bundle arguments = new Bundle(); - arguments.putString(PARAM_TITLE, title); - arguments.putString(PARAM_MESSAGE, message); - - instance.setArguments(arguments); - - return instance; - } - @NonNull - @Override - public Dialog onCreateDialog(final Bundle savedInstanceState) { - if (mDialog != null) { - return mDialog; - } - - String title = getArguments().getString(PARAM_TITLE); - String message = getArguments().getString(PARAM_MESSAGE); - - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setTitle(title); - builder.setMessage(message); - builder.setPositiveButton(R.string.hitoe_setting_dialog_positive, - (dialog, which) -> { - dismiss(); - }); - mDialog = builder.create(); - return mDialog; - } - - @Override - public Dialog getDialog() { - return mDialog; - } - - @Override - public void onDestroy() { - super.onDestroy(); - mDialog = null; - } - - @Override - public void onDismiss(final DialogInterface dialog) { - super.onDismiss(dialog); - if (mListener != null) { - mListener.onDismiss(dialog); - } - } - - /** - * Set listener. - * @param listener listener - */ - public void setOnDismissListener(final DialogInterface.OnDismissListener listener) { - mListener = listener; - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/PinCodeDialogFragment.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/PinCodeDialogFragment.java deleted file mode 100644 index e5c64321f0..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/PinCodeDialogFragment.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - ErrorDialogFragment - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment.dialog; - -import android.app.AlertDialog; -import android.app.Dialog; -import android.content.Context; -import android.content.DialogInterface; -import android.os.Bundle; -import android.text.InputType; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.EditText; - -import androidx.annotation.NonNull; -import androidx.fragment.app.DialogFragment; - -import org.deviceconnect.android.deviceplugin.hitoe.R; - - -/** - * This fragment displays a dialog of Pincode input. - * @author NTT DOCOMO, INC. - */ -public class PinCodeDialogFragment extends DialogFragment { - /** Dialog. */ - private AlertDialog mDialog; - /** Dialog's listener. */ - private OnPinCodeListener mListener; - - /** - * Pin Code listener interface. - */ - public interface OnPinCodeListener { - /** - * Notify pin code listener. - * @param pin pin code - */ - void onPinCode(final String pin); - } - - /** - * Initialize Pin code dialog. - * @return pin code dialog - */ - public static PinCodeDialogFragment newInstance() { - return new PinCodeDialogFragment(); - } - - @NonNull - @Override - public Dialog onCreateDialog(final Bundle savedInstanceState) { - if (mDialog != null) { - return mDialog; - } - - LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService( - Context.LAYOUT_INFLATER_SERVICE); - final View layout = inflater.inflate(R.layout.dialog_hitoe_pin, null); - - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setTitle(getString(R.string.dialog_title_pin_input)); - final EditText pinEdit = (EditText) layout.findViewById(R.id.input_pin); - pinEdit.setInputType(InputType.TYPE_CLASS_NUMBER); - builder.setView(layout); - builder.setPositiveButton(R.string.hitoe_setting_dialog_positive, - (dialogInterface, i) -> { - String pinString = pinEdit.getText().toString(); - if (mListener != null) { - mListener.onPinCode(pinString); - } - }); - builder.setNegativeButton("Cancel", null); - mDialog = builder.create(); - return mDialog; - } - - @Override - public Dialog getDialog() { - return mDialog; - } - - @Override - public void onDestroy() { - super.onDestroy(); - mDialog = null; - } - - @Override - public void onDismiss(final DialogInterface dialog) { - super.onDismiss(dialog); - } - - /** - * Set Pin Code listener. - * @param listener listener - */ - public void setOnPinCodeListener(final OnPinCodeListener listener) { - mListener = listener; - } -} \ No newline at end of file diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/ProgressDialogFragment.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/ProgressDialogFragment.java deleted file mode 100644 index 07630e9b8a..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/ProgressDialogFragment.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - ProgressDialogFragment - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment.dialog; - -import android.app.AlertDialog; -import android.app.Dialog; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.fragment.app.DialogFragment; - -import org.deviceconnect.android.deviceplugin.hitoe.R; - -/** - * This fragment displays a dialog of Progress. - * @author NTT DOCOMO, INC. - */ -public class ProgressDialogFragment extends DialogFragment { - /** Title's key. */ - private static final String PARAM_TITLE = "title"; - /** Message's key. */ - private static final String PARAM_MESSAGE = "message"; - /** - * Initialize progress dialog. - * @param title dialog's title - * @param message dialog's message - * @return progress dialog - */ - public static ProgressDialogFragment newInstance(final String title, final String message) { - ProgressDialogFragment instance = new ProgressDialogFragment(); - - Bundle arguments = new Bundle(); - arguments.putString(PARAM_TITLE, title); - arguments.putString(PARAM_MESSAGE, message); - - instance.setArguments(arguments); - - return instance; - } - - @NonNull - @Override - public Dialog onCreateDialog(final Bundle savedInstanceState) { - - String title = getArguments().getString(PARAM_TITLE); - String message = getArguments().getString(PARAM_MESSAGE); - - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - LayoutInflater inflater = getActivity().getLayoutInflater(); - View v = inflater.inflate(R.layout.dialog_progress, null); - TextView titleView = v.findViewById(R.id.title); - TextView messageView = v.findViewById(R.id.message); - titleView.setText(title); - messageView.setText(message); - builder.setView(v); - setCancelable(false); - return builder.create(); - } - - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/package-info.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/package-info.java deleted file mode 100755 index 728557cc80..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/dialog/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/* -org.deviceconnect.android.deviceplugin.hitoe.fragment.dialog -Copyright (c) 2016 NTT DOCOMO,INC. -Released under the MIT license -http://opensource.org/licenses/mit-license.php - */ - -/** - * Dialog of this device plug-in. - */ -package org.deviceconnect.android.deviceplugin.hitoe.fragment.dialog; - diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/package-info.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/package-info.java deleted file mode 100755 index 2c17ee6013..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/fragment/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/* -org.deviceconnect.android.deviceplugin.heartrate.fragment -Copyright (c) 2014 NTT DOCOMO,INC. -Released under the MIT license -http://opensource.org/licenses/mit-license.php - */ - -/** - * Fragments of this device plug-in. - */ -package org.deviceconnect.android.deviceplugin.heartrate.fragment; - diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/package-info.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/package-info.java deleted file mode 100755 index 4dd7531f2b..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/* -org.deviceconnect.android.deviceplugin.hitoe -Copyright (c) 2014 NTT DOCOMO,INC. -Released under the MIT license -http://opensource.org/licenses/mit-license.php - */ - -/** - * Managed a Hitoe device Service. - */ -package org.deviceconnect.android.deviceplugin.hitoe; - diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeBatteryProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeBatteryProfile.java deleted file mode 100644 index 86a7768dfe..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeBatteryProfile.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - HitoeBatteryProfile - Copyright (c) 2015 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.profile; - -import android.content.Intent; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.HitoeDeviceService; -import org.deviceconnect.android.deviceplugin.hitoe.data.HeartRateData; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.message.MessageUtils; -import org.deviceconnect.android.profile.BatteryProfile; -import org.deviceconnect.android.profile.api.DConnectApi; -import org.deviceconnect.android.profile.api.GetApi; -import org.deviceconnect.message.DConnectMessage; - -/** - * Implement HitoeBatteryProfile. - * @author NTT DOCOMO, INC. - */ -public class HitoeBatteryProfile extends BatteryProfile { - - /** - * Constructor. - */ - public HitoeBatteryProfile() { - addApi(mGetAll); - addApi(mGetLevel); - } - - /** - * Get Battery all. - */ - private final DConnectApi mGetAll = new GetApi() { - @Override - public boolean onRequest(final Intent request, final Intent response) { - return getBattery(request, response); - } - }; - - /** - * Get Battery level. - */ - private final DConnectApi mGetLevel = new GetApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_LEVEL; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - return getBattery(request, response); - } - }; - - /** - * Get Battery info. - * @param request request - * @param response response - * @return true:sync, false:async - */ - private boolean getBattery(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - HeartRateData data = mgr.getHeartRateData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - double level = data.getDevice().getBatteryLevel(); - if (level < 0) { - MessageUtils.setUnknownError(response, "Battery level is unknown."); - } else { - setResult(response, DConnectMessage.RESULT_OK); - setLevel(response, level); - } - } - return true; - } - /** - * Gets a instance of HitoeManager. - * - * @return {@link HitoeManager}, or null on error - */ - private HitoeManager getManager() { - HitoeDeviceService service = (HitoeDeviceService) getContext(); - if (service == null) { - return null; - } - HitoeApplication app = (HitoeApplication) service.getApplication(); - if (app == null) { - return null; - } - return app.getHitoeManager(); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeDeviceOrientationProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeDeviceOrientationProfile.java deleted file mode 100644 index 6959fffba8..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeDeviceOrientationProfile.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - HitoeDeviceOrientationProfile - Copyright (c) 2015 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.profile; - -import android.content.Intent; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.HitoeDeviceService; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeConstants; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.data.AccelerationData; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.event.Event; -import org.deviceconnect.android.event.EventDispatcher; -import org.deviceconnect.android.event.EventDispatcherFactory; -import org.deviceconnect.android.event.EventDispatcherManager; -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.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.List; - -/** - * Implement DeviceOrientationProfile. - * @author NTT DOCOMO, INC. - */ -public class HitoeDeviceOrientationProfile extends DeviceOrientationProfile { - - /** - * Implementation of {@link HitoeManager.OnHitoeDeviceOrientationEventListener}. - */ - private final HitoeManager.OnHitoeDeviceOrientationEventListener mDeviceOrientationEventListener = - this::notifyAccelerationData; - - /** - * Event Dispatcher object. - */ - private EventDispatcherManager mDispatcherManager; - - /** - * Constructor. - * @param mgr instance of {@link HitoeManager} - */ - public HitoeDeviceOrientationProfile(final HitoeManager mgr) { - mgr.setHitoeDeviceOrientationEventListener(mDeviceOrientationEventListener); - mDispatcherManager = new EventDispatcherManager(); - addApi(mGetOnDeviceOrientation); - addApi(mPutOnDeviceOrientation); - addApi(mDeleteOnDeviceOrientation); - } - - /** - * Get device orientation. - */ - 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) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - - AccelerationData data = mgr.getAccelerationData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - } else { - setResult(response, DConnectMessage.RESULT_OK); - DeviceOrientationProfile.setOrientation(response, data.toBundle()); - - } - } - return true; - } - }; - - /** - * Register event device orientation. - */ - 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 serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setNotFoundServiceError(response, "Not found serviceID"); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - AccelerationData data = mgr.getAccelerationData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - } else { - EventError error = EventManager.INSTANCE.addEvent(request); - if (error == EventError.NONE) { - mgr.setHitoeDeviceOrientationEventListener(mDeviceOrientationEventListener); - String intervalString = request.getStringExtra("interval"); - long interval; - try { - interval = Long.parseLong(intervalString); - } catch (NumberFormatException e) { - interval = HitoeConstants.ADD_RECEIVER_PARAM_ACC_SAMPLING_INTERVAL; - } - getManager().getAccelerationData(serviceId).setTimeStamp(interval); - addEventDispatcher(request); - setResult(response, DConnectMessage.RESULT_OK); - } else { - MessageUtils.setUnknownError(response); - } - } - } - return true; - } - }; - - /** - * Unregister event device orientation. - */ - 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 serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - removeEventDispatcher(request); - EventError error = EventManager.INSTANCE.removeEvent(request); - if (error == EventError.NONE) { - setResult(response, DConnectMessage.RESULT_OK); - } else if (error == EventError.INVALID_PARAMETER) { - MessageUtils.setInvalidRequestParameterError(response); - } else if (error == EventError.FAILED) { - MessageUtils.setUnknownError(response, "Failed to delete event."); - } else if (error == EventError.NOT_FOUND) { - MessageUtils.setUnknownError(response, "Not found event."); - } else { - MessageUtils.setUnknownError(response); - } - } - return true; - } - }; - - /** - * Notify the device orientation event to DeviceConnectManager. - * @param device Identifies the remote device - * @param data Data of device orientation - */ - private void notifyAccelerationData(final HitoeDevice device, final AccelerationData data) { - List events = EventManager.INSTANCE.getEventList(device.getId(), - getProfileName(), null, ATTRIBUTE_ON_DEVICE_ORIENTATION); - synchronized (events) { - for (Event event : events) { - if (data == null) { - break; - } - - Intent intent = EventManager.createEventMessage(event); - - DeviceOrientationProfile.setOrientation(intent, data.toBundle()); - mDispatcherManager.sendEvent(event, intent); - } - } - } - - /** - * Add Event Dispatcher. - * @param request request parameter - */ - private void addEventDispatcher(final Intent request) { - Event event = EventManager.INSTANCE.getEvent(request); - EventDispatcher dispatcher = EventDispatcherFactory.createEventDispatcher( - (DConnectMessageService) getContext(), request); - mDispatcherManager.addEventDispatcher(event, dispatcher); - } - - /** - * Remove Event Dispatcher. - * @param request request parameter - */ - private void removeEventDispatcher(final Intent request) { - Event event = EventManager.INSTANCE.getEvent(request); - mDispatcherManager.removeEventDispatcher(event); - } - - /** - * Gets a instance of HitoeManager. - * - * @return {@link HitoeManager}, or null on error - */ - private HitoeManager getManager() { - HitoeDeviceService service = (HitoeDeviceService) getContext(); - if (service == null) { - return null; - } - HitoeApplication app = (HitoeApplication) service.getApplication(); - if (app == null) { - return null; - } - return app.getHitoeManager(); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeECGProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeECGProfile.java deleted file mode 100644 index 4cc24a4fcc..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeECGProfile.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - HitoeECGProfile - Copyright (c) 2015 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.profile; - -import android.content.Intent; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.HitoeDeviceService; -import org.deviceconnect.android.deviceplugin.hitoe.data.HeartRateData; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.event.Event; -import org.deviceconnect.android.event.EventDispatcherFactory; -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.ECGProfile; -import org.deviceconnect.android.event.EventDispatcher; -import org.deviceconnect.android.event.EventDispatcherManager; -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; - -/** - * Implement ECGProfile. - * @author NTT DOCOMO, INC. - */ -public class HitoeECGProfile extends ECGProfile { - - /** - * Implementation of {@link HitoeManager.OnHitoeECGEventListener}. - */ - private final HitoeManager.OnHitoeECGEventListener mECGEventListener = - this::notifyECGData; - /** - * Event Dispatcher object. - */ - private EventDispatcherManager mDispatcherManager; - - /** - * Constructor. - * @param mgr instance of {@link HitoeManager} - */ - public HitoeECGProfile(final HitoeManager mgr) { - mgr.setHitoeECGEventListener(mECGEventListener); - mDispatcherManager = new EventDispatcherManager(); - addApi(mGetOnECG); - addApi(mPutOnECG); - addApi(mDeleteOnECG); - } - - /** - * Get ECG. - */ - private final DConnectApi mGetOnECG = new GetApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ON_ECG; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - HeartRateData data = mgr.getECGData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - } else { - setResult(response, DConnectMessage.RESULT_OK); - setECG(response, data.getECG().toBundle()); - } - } - return true; - } - }; - - /** - * Register event ECG. - */ - private final DConnectApi mPutOnECG = new PutApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ON_ECG; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setNotFoundServiceError(response, "Not found serviceID"); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - HeartRateData data = mgr.getECGData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - } else { - EventError error = EventManager.INSTANCE.addEvent(request); - if (error == EventError.NONE) { - mgr.setHitoeECGEventListener(mECGEventListener); - addEventDispatcher(request); - setResult(response, DConnectMessage.RESULT_OK); - } else { - MessageUtils.setUnknownError(response); - } - } - } - return true; - } - }; - - /** - * Unregister event ECG. - */ - private final DConnectApi mDeleteOnECG = new DeleteApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ON_ECG; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - removeEventDispatcher(request); - EventError error = EventManager.INSTANCE.removeEvent(request); - if (error == EventError.NONE) { - setResult(response, DConnectMessage.RESULT_OK); - } else if (error == EventError.INVALID_PARAMETER) { - MessageUtils.setInvalidRequestParameterError(response); - } else if (error == EventError.FAILED) { - MessageUtils.setUnknownError(response, "Failed to delete event."); - } else if (error == EventError.NOT_FOUND) { - MessageUtils.setUnknownError(response, "Not found event."); - } else { - MessageUtils.setUnknownError(response); - } - } - return true; - } - }; - - /** - * Notify the ECG event to DeviceConnectManager. - * @param device Identifies the remote device - * @param data Data of ecg - */ - private void notifyECGData(final HitoeDevice device, final HeartRateData data) { - List events = EventManager.INSTANCE.getEventList(device.getId(), - getProfileName(), null, ATTRIBUTE_ON_ECG); - synchronized (events) { - for (Event event : events) { - if (data == null) { - break; - } - - Intent intent = EventManager.createEventMessage(event); - - setECG(intent, data.getECG().toBundle()); - mDispatcherManager.sendEvent(event, intent); - } - } - } - - /** - * Add Event Dispatcher. - * @param request request parameter - */ - private void addEventDispatcher(final Intent request) { - Event event = EventManager.INSTANCE.getEvent(request); - EventDispatcher dispatcher = EventDispatcherFactory.createEventDispatcher( - (DConnectMessageService) getContext(), request); - mDispatcherManager.addEventDispatcher(event, dispatcher); - } - - /** - * Remove Event Dispatcher. - * @param request request parameter - */ - private void removeEventDispatcher(final Intent request) { - Event event = EventManager.INSTANCE.getEvent(request); - mDispatcherManager.removeEventDispatcher(event); - } - - /** - * Gets a instance of HitoeManager. - * - * @return {@link HitoeManager}, or null on error - */ - private HitoeManager getManager() { - HitoeDeviceService service = (HitoeDeviceService) getContext(); - if (service == null) { - return null; - } - HitoeApplication app = (HitoeApplication) service.getApplication(); - if (app == null) { - return null; - } - return app.getHitoeManager(); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeHealthProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeHealthProfile.java deleted file mode 100644 index 8d3471e971..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeHealthProfile.java +++ /dev/null @@ -1,339 +0,0 @@ -/* - HitoeHealthProfile - Copyright (c) 2015 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.profile; - -import android.content.Intent; -import android.os.Bundle; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.HitoeDeviceService; -import org.deviceconnect.android.deviceplugin.hitoe.data.HeartRateData; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.event.Event; -import org.deviceconnect.android.event.EventDispatcher; -import org.deviceconnect.android.event.EventDispatcherFactory; -import org.deviceconnect.android.event.EventDispatcherManager; -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.HealthProfile; -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; - -/** - * Implement HealthProfile. - * @author NTT DOCOMO, INC. - */ -public class HitoeHealthProfile extends HealthProfile { - - /** - * Implementation of {@link HitoeManager.OnHitoeHeartRateEventListener}. - */ - private final HitoeManager.OnHitoeHeartRateEventListener mHeartRateEventListener = - this::notifyHeartRateData; - - /** - * Event Dispatcher object. - */ - private EventDispatcherManager mDispatcherManager; - - /** - * Constructor. - * @param mgr instance of {@link HitoeManager} - */ - public HitoeHealthProfile(final HitoeManager mgr) { - mgr.setHitoeHeartRateEventListener(mHeartRateEventListener); - mDispatcherManager = new EventDispatcherManager(); - addApi(mGetHeart); - addApi(mPutHeart); - addApi(mDeleteHeart); - addApi(mGetOnHeart); - addApi(mPutOnHeart); - addApi(mDeleteOnHeart); - } - - /** - * Get Heart rate. - */ - private final DConnectApi mGetHeart = new GetApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_HEART; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - return getHeart(request, response); - } - }; - - - /** - * Register event heartrate. - */ - private final DConnectApi mPutHeart = new PutApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_HEART; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - return registerHeartEvent(request, response); - } - }; - - - /** - * Unregister event heartrate. - */ - private final DConnectApi mDeleteHeart = new DeleteApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_HEART; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - unregisterHeartEvent(request, response); - return true; - } - }; - - /** - * Get Heart rate. - */ - private final DConnectApi mGetOnHeart = new GetApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ONHEART; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - return getHeart(request, response); - } - }; - - - /** - * Register event heartrate. - */ - private final DConnectApi mPutOnHeart = new PutApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ONHEART; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - return registerHeartEvent(request, response); - } - }; - - - /** - * Unregister event heartrate. - */ - private final DConnectApi mDeleteOnHeart = new DeleteApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ONHEART; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - unregisterHeartEvent(request, response); - return true; - } - }; - - - /** - * Get HeartRate Response. - * @param request Request Message - * @param response Response Message - * @return true:sync false:async - */ - private boolean getHeart(Intent request, Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - HeartRateData data = mgr.getHeartRateData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - } else { - setResult(response, DConnectMessage.RESULT_OK); - setHeart(response, getHeartRateBundle(data)); - } - } - return true; - } - - /** - * Register Heartrate Event. - * @param request Request Message - * @param response Response Message - */ - private boolean registerHeartEvent(Intent request, Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setNotFoundServiceError(response, "Not found serviceID"); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - - HeartRateData data = mgr.getHeartRateData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - } else { - EventError error = EventManager.INSTANCE.addEvent(request); - if (error == EventError.NONE) { - mgr.setHitoeHeartRateEventListener(mHeartRateEventListener); - addEventDispatcher(request); - setResult(response, DConnectMessage.RESULT_OK); - } else { - MessageUtils.setUnknownError(response); - } - } - } - return true; - } - /** - * Unregister Heartrate Event. - * @param request Request Message - * @param response Response Message - */ - private void unregisterHeartEvent(Intent request, Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - removeEventDispatcher(request); - EventError error = EventManager.INSTANCE.removeEvent(request); - if (error == EventError.NONE) { - setResult(response, DConnectMessage.RESULT_OK); - } else if (error == EventError.INVALID_PARAMETER) { - MessageUtils.setInvalidRequestParameterError(response); - } else if (error == EventError.FAILED) { - MessageUtils.setUnknownError(response, "Failed to delete event."); - } else if (error == EventError.NOT_FOUND) { - MessageUtils.setUnknownError(response, "Not found event."); - } else { - MessageUtils.setUnknownError(response); - } - } - } - - /** - * Notify the heart rate event to DeviceConnectManager. - * @param device Identifies the remote device - * @param data Data of heart rate - */ - private void notifyHeartRateData(final HitoeDevice device, final HeartRateData data) { - List events = EventManager.INSTANCE.getEventList(device.getId(), - getProfileName(), null, ATTRIBUTE_HEART); - synchronized (events) { - for (Event event : events) { - if (data == null) { - break; - } - - Intent intent = EventManager.createEventMessage(event); - - setHeart(intent, getHeartRateBundle(data)); - mDispatcherManager.sendEvent(event, intent); - } - } - events = EventManager.INSTANCE.getEventList(device.getId(), - getProfileName(), null, ATTRIBUTE_ONHEART); - synchronized (events) { - for (Event event : events) { - if (data == null) { - break; - } - - Intent intent = EventManager.createEventMessage(event); - - setHeart(intent, getHeartRateBundle(data)); - mDispatcherManager.sendEvent(event, intent); - } - } - } - - /** - * Get Heartrate bundle object. - * @param data heartrate data - * @return bundle object - */ - private Bundle getHeartRateBundle(final HeartRateData data) { - Bundle heart = new Bundle(); - HealthProfile.setRate(heart, data.getHeartRate().toBundle()); - if (data.getRRInterval() != null) { - HealthProfile.setRRI(heart, data.getRRInterval().toBundle()); - } - if (data.getEnergyExpended() != null) { - HealthProfile.setEnergyExtended(heart, data.getEnergyExpended().toBundle()); - } - if (data.getDevice() != null) { - HealthProfile.setDevice(heart, data.getDevice().toBundle()); - } - return heart; - } - - /** - * Add Event Dispatcher. - * @param request request parameter - */ - private void addEventDispatcher(final Intent request) { - Event event = EventManager.INSTANCE.getEvent(request); - EventDispatcher dispatcher = EventDispatcherFactory.createEventDispatcher( - (DConnectMessageService) getContext(), request); - mDispatcherManager.addEventDispatcher(event, dispatcher); - } - - /** - * Remove Event Dispatcher. - * @param request request parameter - */ - private void removeEventDispatcher(final Intent request) { - Event event = EventManager.INSTANCE.getEvent(request); - mDispatcherManager.removeEventDispatcher(event); - } - /** - * Gets a instance of HitoeManager. - * - * @return {@link HitoeManager}, or null on error - */ - private HitoeManager getManager() { - HitoeDeviceService service = (HitoeDeviceService) getContext(); - if (service == null) { - return null; - } - HitoeApplication app = (HitoeApplication) service.getApplication(); - if (app == null) { - return null; - } - return app.getHitoeManager(); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoePoseEstimationProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoePoseEstimationProfile.java deleted file mode 100644 index 8f663907f8..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoePoseEstimationProfile.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - HitoePoseEstimationProfile - Copyright (c) 2015 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.profile; - -import android.content.Intent; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.HitoeDeviceService; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.PoseEstimationData; -import org.deviceconnect.android.event.Event; -import org.deviceconnect.android.event.EventDispatcher; -import org.deviceconnect.android.event.EventDispatcherFactory; -import org.deviceconnect.android.event.EventDispatcherManager; -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.PoseEstimationProfile; -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; - -/** - * Implement PoseEstimationProfile. - * @author NTT DOCOMO, INC. - */ -public class HitoePoseEstimationProfile extends PoseEstimationProfile { - - /** - * Implementation of {@link HitoeManager.OnHitoePoseEstimationEventListener}. - */ - private final HitoeManager.OnHitoePoseEstimationEventListener mPoseEstimationEventListener = - this::notifyPoseEstimationData; - /** - * Event Dispatcher object. - */ - private EventDispatcherManager mDispatcherManager; - - /** - * Constructor. - * @param mgr instance of {@link HitoeManager} - */ - public HitoePoseEstimationProfile(final HitoeManager mgr) { - mgr.setHitoePoseEstimationEventListener(mPoseEstimationEventListener); - mDispatcherManager = new EventDispatcherManager(); - addApi(mGetOnPose); - addApi(mPutOnPose); - addApi(mDeleteOnPose); - } - - /** - * Get Pose estimation. - */ - private final DConnectApi mGetOnPose = new GetApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ON_POSE_ESTIMATION; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - - PoseEstimationData data = mgr.getPoseEstimationData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - } else { - setResult(response, DConnectMessage.RESULT_OK); - setPose(response, data.toBundle()); - } - } - return true; - } - }; - - /** - * Register event pose estimation. - */ - private final DConnectApi mPutOnPose = new PutApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ON_POSE_ESTIMATION; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setNotFoundServiceError(response, "Not found serviceID"); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - PoseEstimationData data = mgr.getPoseEstimationData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - } else { - EventError error = EventManager.INSTANCE.addEvent(request); - if (error == EventError.NONE) { - mgr.setHitoePoseEstimationEventListener(mPoseEstimationEventListener); - addEventDispatcher(request); - setResult(response, DConnectMessage.RESULT_OK); - } else { - MessageUtils.setUnknownError(response); - } - } - } - return true; - } - }; - - /** - * Unregister event pose estimation. - */ - private final DConnectApi mDeleteOnPose = new DeleteApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ON_POSE_ESTIMATION; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - removeEventDispatcher(request); - EventError error = EventManager.INSTANCE.removeEvent(request); - if (error == EventError.NONE) { - setResult(response, DConnectMessage.RESULT_OK); - } else if (error == EventError.INVALID_PARAMETER) { - MessageUtils.setInvalidRequestParameterError(response); - } else if (error == EventError.FAILED) { - MessageUtils.setUnknownError(response, "Failed to delete event."); - } else if (error == EventError.NOT_FOUND) { - MessageUtils.setUnknownError(response, "Not found event."); - } else { - MessageUtils.setUnknownError(response); - } - } - return true; - } - }; - - /** - * Notify the stress estimation event to DeviceConnectManager. - * @param device Identifies the remote device - * @param data Data of Stress Estimation - */ - private void notifyPoseEstimationData(final HitoeDevice device, final PoseEstimationData data) { - List events = EventManager.INSTANCE.getEventList(device.getId(), - getProfileName(), null, ATTRIBUTE_ON_POSE_ESTIMATION); - synchronized (events) { - for (Event event : events) { - if (data == null) { - break; - } - - Intent intent = EventManager.createEventMessage(event); - - setPose(intent, data.toBundle()); - mDispatcherManager.sendEvent(event, intent); - } - } - } - /** - * Add Event Dispatcher. - * @param request request parameter - */ - private void addEventDispatcher(final Intent request) { - Event event = EventManager.INSTANCE.getEvent(request); - EventDispatcher dispatcher = EventDispatcherFactory.createEventDispatcher( - (DConnectMessageService) getContext(), request); - mDispatcherManager.addEventDispatcher(event, dispatcher); - } - - /** - * Remove Event Dispatcher. - * @param request request parameter - */ - private void removeEventDispatcher(final Intent request) { - Event event = EventManager.INSTANCE.getEvent(request); - mDispatcherManager.removeEventDispatcher(event); - } - - - /** - * Gets a instance of HitoeManager. - * - * @return {@link HitoeManager}, or null on error - */ - private HitoeManager getManager() { - HitoeDeviceService service = (HitoeDeviceService) getContext(); - if (service == null) { - return null; - } - HitoeApplication app = (HitoeApplication) service.getApplication(); - if (app == null) { - return null; - } - return app.getHitoeManager(); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeServiceDiscoveryProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeServiceDiscoveryProfile.java deleted file mode 100644 index 3d6e7c8148..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeServiceDiscoveryProfile.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - HitoeServiceDiscoveryProfile - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.profile; - -import android.content.Intent; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.os.HandlerThread; - -import androidx.annotation.NonNull; - -import org.deviceconnect.android.activity.PermissionUtility; -import org.deviceconnect.android.deviceplugin.hitoe.util.BleUtils; -import org.deviceconnect.android.message.DConnectMessageService; -import org.deviceconnect.android.message.MessageUtils; -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; -import org.deviceconnect.message.DConnectMessage; - -import java.util.ArrayList; -import java.util.List; - -/** - * ServiceDiscoveryProfile. - * @author NTT DOCOMO, INC. - */ -public class HitoeServiceDiscoveryProfile extends ServiceDiscoveryProfile { - - private final HandlerThread mWorkerThread; - - private final DConnectApi mServiceDiscoveryApi = new GetApi() { - @Override - public boolean onRequest(final Intent request, final Intent response) { - if (!BleUtils.isBLESupported(getContext())) { - mLogger.warning("BLE not supported."); - List services = new ArrayList<>(); - setResult(response, DConnectMessage.RESULT_OK); - setServices(response, services); - return true; - } - - final Runnable perform = () -> { - appendServiceList(response); - }; - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - perform.run(); - return true; - } else { - if (BleUtils.isBLEPermission(getContext())) { - perform.run(); - return true; - } else { - PermissionUtility.requestPermissions(getContext(), new Handler(mWorkerThread.getLooper()), - BleUtils.BLE_PERMISSIONS, - new PermissionUtility.PermissionRequestCallback() { - @Override - public void onSuccess() { - perform.run(); - sendResponses(response); - } - - @Override - public void onFail(@NonNull String deniedPermission) { - MessageUtils.setIllegalServerStateError(response, - "Bluetooth LE scan requires permissions ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION."); - sendResponses(response); - } - }); - return false; - } - } - } - }; - - /** - * コンストラクタ. - * @param provider プロファイルプロバイダ - */ - public HitoeServiceDiscoveryProfile(final DConnectServiceProvider provider) { - super(provider); - mWorkerThread = new HandlerThread(getClass().getSimpleName() + "_" + this.hashCode()); - mWorkerThread.start(); - - addApi(mServiceDiscoveryApi); - } - - @Override - protected void finalize() throws Throwable { - super.finalize(); - mWorkerThread.quit(); - } - - private void sendResponses(final Intent response) { - DConnectMessageService s = (DConnectMessageService) getContext(); - s.sendResponse(response); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeStressEstimationProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeStressEstimationProfile.java deleted file mode 100644 index 32d02ff0b2..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeStressEstimationProfile.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - HitoeStressEstimationProfile - Copyright (c) 2015 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.profile; - -import android.content.Intent; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.HitoeDeviceService; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.data.StressEstimationData; -import org.deviceconnect.android.event.Event; -import org.deviceconnect.android.event.EventDispatcher; -import org.deviceconnect.android.event.EventDispatcherFactory; -import org.deviceconnect.android.event.EventDispatcherManager; -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.StressEstimationProfile; -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; - -/** - * Implement StressEstimationProfile. - * @author NTT DOCOMO, INC. - */ -public class HitoeStressEstimationProfile extends StressEstimationProfile { - - /** - * Implementation of {@link HitoeManager.OnHitoeStressEstimationEventListener}. - */ - private final HitoeManager.OnHitoeStressEstimationEventListener mStressEstimationEventListener = - new HitoeManager.OnHitoeStressEstimationEventListener() { - @Override - public void onReceivedData(final HitoeDevice device, final StressEstimationData data) { - notifyStressEstimationData(device, data); - } - }; - /** - * Event Dispatcher object. - */ - private EventDispatcherManager mDispatcherManager; - - /** - * Constructor. - * @param mgr instance of {@link HitoeManager} - */ - public HitoeStressEstimationProfile(final HitoeManager mgr) { - mgr.setHitoeStressEstimationEventListener(mStressEstimationEventListener); - mDispatcherManager = new EventDispatcherManager(); - addApi(mGetOnStress); - addApi(mPutOnStress); - addApi(mDeleteOnStress); - } - - /** - * Get Stress estimation. - */ - private final DConnectApi mGetOnStress = new GetApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ON_STRESS_ESTIMATION; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - StressEstimationData data = mgr.getStressEstimationData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - } else { - setResult(response, DConnectMessage.RESULT_OK); - setStress(response, data.toBundle()); - } - } - return true; - } - }; - - /** - * Register event stress estimation. - */ - private final DConnectApi mPutOnStress = new PutApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ON_STRESS_ESTIMATION; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setNotFoundServiceError(response, "Not found serviceID"); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - StressEstimationData data = mgr.getStressEstimationData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - } else { - EventError error = EventManager.INSTANCE.addEvent(request); - if (error == EventError.NONE) { - mgr.setHitoeStressEstimationEventListener(mStressEstimationEventListener); - addEventDispatcher(request); - setResult(response, DConnectMessage.RESULT_OK); - } else { - MessageUtils.setUnknownError(response); - } - } - } - return true; - } - }; - - /** - * Unregister event stress estimation. - */ - private final DConnectApi mDeleteOnStress = new DeleteApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ON_STRESS_ESTIMATION; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - removeEventDispatcher(request); - EventError error = EventManager.INSTANCE.removeEvent(request); - if (error == EventError.NONE) { - setResult(response, DConnectMessage.RESULT_OK); - } else if (error == EventError.INVALID_PARAMETER) { - MessageUtils.setInvalidRequestParameterError(response); - } else if (error == EventError.FAILED) { - MessageUtils.setUnknownError(response, "Failed to delete event."); - } else if (error == EventError.NOT_FOUND) { - MessageUtils.setUnknownError(response, "Not found event."); - } else { - MessageUtils.setUnknownError(response); - } - } - return true; - } - }; - - /** - * Notify the stress estimation event to DeviceConnectManager. - * @param device Identifies the remote device - * @param data Data of Stress Estimation - */ - private void notifyStressEstimationData(final HitoeDevice device, final StressEstimationData data) { - List events = EventManager.INSTANCE.getEventList(device.getId(), - getProfileName(), null, ATTRIBUTE_ON_STRESS_ESTIMATION); - synchronized (events) { - for (Event event : events) { - if (data == null) { - break; - } - Intent intent = EventManager.createEventMessage(event); - - setStress(intent, data.toBundle()); - mDispatcherManager.sendEvent(event, intent); - } - } - } - - /** - * Add Event Dispatcher. - * @param request request parameter - */ - private void addEventDispatcher(final Intent request) { - Event event = EventManager.INSTANCE.getEvent(request); - EventDispatcher dispatcher = EventDispatcherFactory.createEventDispatcher( - (DConnectMessageService) getContext(), request); - mDispatcherManager.addEventDispatcher(event, dispatcher); - } - - /** - * Remove Event Dispatcher. - * @param request request parameter - */ - private void removeEventDispatcher(final Intent request) { - Event event = EventManager.INSTANCE.getEvent(request); - mDispatcherManager.removeEventDispatcher(event); - } - - - /** - * Gets a instance of HitoeManager. - * - * @return {@link HitoeManager}, or null on error - */ - private HitoeManager getManager() { - HitoeDeviceService service = (HitoeDeviceService) getContext(); - if (service == null) { - return null; - } - HitoeApplication app = (HitoeApplication) service.getApplication(); - if (app == null) { - return null; - } - return app.getHitoeManager(); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeSystemProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeSystemProfile.java deleted file mode 100644 index 752b89440a..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeSystemProfile.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - HitoeSystemProfile - Copyright (c) 2015 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.profile; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; - -import org.deviceconnect.android.deviceplugin.hitoe.activity.HitoeDeviceListActivity; -import org.deviceconnect.android.profile.SystemProfile; - -/** - * Implement SystemProfile. - * @author NTT DOCOMO, INC. - */ -public class HitoeSystemProfile extends SystemProfile { - @Override - protected Class getSettingPageActivity(final Intent request, final Bundle param) { - return HitoeDeviceListActivity.class; - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeWalkStateProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeWalkStateProfile.java deleted file mode 100644 index f585371cfa..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/HitoeWalkStateProfile.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - HitoeWalkStateProfile - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.profile; - -import android.content.Intent; - -import org.deviceconnect.android.deviceplugin.hitoe.HitoeApplication; -import org.deviceconnect.android.deviceplugin.hitoe.HitoeDeviceService; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeManager; -import org.deviceconnect.android.deviceplugin.hitoe.data.WalkStateData; -import org.deviceconnect.android.event.Event; -import org.deviceconnect.android.event.EventDispatcher; -import org.deviceconnect.android.event.EventDispatcherFactory; -import org.deviceconnect.android.event.EventDispatcherManager; -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.WalkStateProfile; -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; - -/** - * Implement WalkStateProfile. - * @author NTT DOCOMO, INC. - */ -public class HitoeWalkStateProfile extends WalkStateProfile { - - /** - * Implementation of {@link HitoeManager.OnHitoeWalkStateEventListener}. - */ - private final HitoeManager.OnHitoeWalkStateEventListener mWalkStateEventListener = - this::notifyWalkStateData; - /** - * Event Dispatcher object. - */ - private EventDispatcherManager mDispatcherManager; - - - /** - * Constructor. - * @param mgr instance of {@link HitoeManager} - */ - public HitoeWalkStateProfile(final HitoeManager mgr) { - mgr.setHitoeWalkStateEventListener(mWalkStateEventListener); - mDispatcherManager = new EventDispatcherManager(); - addApi(mGetOnWalk); - addApi(mPutOnWalk); - addApi(mDeleteOnWalk); - - } - - /** - * Get walk state. - */ - private final DConnectApi mGetOnWalk = new GetApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ON_WALK_STATE; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - WalkStateData data = mgr.getWalkStateData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - } else { - setResult(response, DConnectMessage.RESULT_OK); - setWalk(response, data.toBundle()); - } - } - return true; - } - }; - - /** - * Register event walk state. - */ - private final DConnectApi mPutOnWalk = new PutApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ON_WALK_STATE; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setNotFoundServiceError(response, "Not found serviceID"); - } else { - HitoeManager mgr = getManager(); - if (mgr == null) { - MessageUtils.setNotFoundServiceError(response); - return true; - } - WalkStateData data = mgr.getWalkStateData(serviceId); - if (data == null) { - MessageUtils.setNotFoundServiceError(response); - } else { - EventError error = EventManager.INSTANCE.addEvent(request); - if (error == EventError.NONE) { - mgr.setHitoeWalkStateEventListener(mWalkStateEventListener); - addEventDispatcher(request); - setResult(response, DConnectMessage.RESULT_OK); - } else { - MessageUtils.setUnknownError(response); - } - } - } - return true; - } - }; - - /** - * Unregister event walk state. - */ - private final DConnectApi mDeleteOnWalk = new DeleteApi() { - @Override - public String getAttribute() { - return ATTRIBUTE_ON_WALK_STATE; - } - - @Override - public boolean onRequest(final Intent request, final Intent response) { - String serviceId = getServiceID(request); - if (serviceId == null) { - MessageUtils.setEmptyServiceIdError(response); - } else { - removeEventDispatcher(request); - EventError error = EventManager.INSTANCE.removeEvent(request); - if (error == EventError.NONE) { - setResult(response, DConnectMessage.RESULT_OK); - } else if (error == EventError.INVALID_PARAMETER) { - MessageUtils.setInvalidRequestParameterError(response); - } else if (error == EventError.FAILED) { - MessageUtils.setUnknownError(response, "Failed to delete event."); - } else if (error == EventError.NOT_FOUND) { - MessageUtils.setUnknownError(response, "Not found event."); - } else { - MessageUtils.setUnknownError(response); - } - } - return true; - } - }; - - /** - * Notify the stress estimation event to DeviceConnectManager. - * @param device Identifies the remote device - * @param data Data of Stress Estimation - */ - private void notifyWalkStateData(final HitoeDevice device, final WalkStateData data) { - List events = EventManager.INSTANCE.getEventList(device.getId(), - getProfileName(), null, ATTRIBUTE_ON_WALK_STATE); - synchronized (events) { - for (Event event : events) { - if (data == null) { - break; - } - - Intent intent = EventManager.createEventMessage(event); - setWalk(intent, data.toBundle()); - mDispatcherManager.sendEvent(event, intent); - } - } - } - - /** - * Add Event Dispatcher. - * @param request request parameter - */ - private void addEventDispatcher(final Intent request) { - Event event = EventManager.INSTANCE.getEvent(request); - EventDispatcher dispatcher = EventDispatcherFactory.createEventDispatcher( - (DConnectMessageService) getContext(), request); - mDispatcherManager.addEventDispatcher(event, dispatcher); - } - - /** - * Remove Event Dispatcher. - * @param request request parameter - */ - private void removeEventDispatcher(final Intent request) { - Event event = EventManager.INSTANCE.getEvent(request); - mDispatcherManager.removeEventDispatcher(event); - } - - /** - * Gets a instance of HitoeManager. - * - * @return {@link HitoeManager}, or null on error - */ - private HitoeManager getManager() { - HitoeDeviceService service = (HitoeDeviceService) getContext(); - if (service == null) { - return null; - } - HitoeApplication app = (HitoeApplication) service.getApplication(); - if (app == null) { - return null; - } - return app.getHitoeManager(); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/package-info.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/package-info.java deleted file mode 100755 index 892d25746f..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/profile/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/* -org.deviceconnect.android.deviceplugin.hitoe.profile -Copyright (c) 2014 NTT DOCOMO,INC. -Released under the MIT license -http://opensource.org/licenses/mit-license.php - */ - -/** - * Profiles of this device plug-in. - */ -package org.deviceconnect.android.deviceplugin.hitoe.profile; - diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/BleUtils.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/BleUtils.java deleted file mode 100644 index 11292ded9b..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/BleUtils.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - BleUtils - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.util; - -import android.Manifest; -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothManager; -import android.content.Context; -import android.content.pm.PackageManager; -import android.os.Build; - -/** - * A class containing utility methods related to BLE. - * @author NTT DOCOMO, INC. - */ -public final class BleUtils { - - // 1800 Generic Access - public static final String SERVICE_GENERIC_ACCESS = "00001800-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_DEVICE_NAME = "00002a00-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_APPEARANCE = "00002a01-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_PERIPHERAL_PRIVACY_FLAG = "00002a02-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_RECONNECTION_ADDRESS = "00002a03-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_PERIPHERAL_PREFERRED_CONNECTION_PARAMETERS = "00002a04-0000-1000-8000-00805f9b34fb"; - - // 1801 Generic Attribute - public static final String SERVICE_GENERIC_ATTRIBUTE = "00001801-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_SERVICE_CHANGED = "00002a05-0000-1000-8000-00805f9b34fb"; - - // 1802 Immediate Alert - public static final String SERVICE_IMMEDIATE_ALERT = "00001802-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_ALERT_LEVEL = "00002a06-0000-1000-8000-00805f9b34fb"; - // StickNFindではCHAR_ALERT_LEVELに0x01をWriteすると光り、0x02では音が鳴り、0x03では光って鳴る。 - - // 180a Device Information - public static final String SERVICE_DEVICE_INFORMATION = "0000180a-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_MANUFACTURER_NAME_STRING = "00002a29-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_MODEL_NUMBER_STRING = "00002a24-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_SERIAL_NUMBER_STRING = "00002a25-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_HARDWARE_REVISION_STRING = "00002a27-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_FIRMWARE_REVISION_STRING = "00002a26-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_SOFTWARE_REVISION_STRING = "00002a28-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_SYSTEM_ID = "00002a23-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_IEEE_11073_20601_REGULATORY_CERTIFICATION_DATA_LIST = "00002a2A-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_PNP_ID = "00002a50-0000-1000-8000-00805f9b34fb"; - - // 180F Battery Service - public static final String SERVICE_BATTERY_SERVICE = "0000180f-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_BATTERY_LEVEL = "00002a19-0000-1000-8000-00805f9b34fb"; - - // 180D Heart Reate Service - public static final String SERVICE_HEART_RATE_SERVICE = "0000180d-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_HEART_RATE_MEASUREMENT = "00002a37-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_BODY_SENSOR_LOCATION = "00002a38-0000-1000-8000-00805f9b34fb"; - public static final String CHAR_HEART_RATE_CONTROL_POINT = "00002a39-0000-1000-8000-00805f9b34fb"; - - /** - * Defined the permission of BLE scan. - */ - public static final String[] BLE_PERMISSIONS = new String[] { - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION - }; - - /** - * Private constructor. - */ - private BleUtils() { - } - - /** - * Checks whether device(smart phone) supports BLE. - * @param context context of application - * @return Returns true if the device supports BLE, else - * false. - */ - public static boolean isBLESupported(final Context context) { - return Build.VERSION.SDK_INT >= 18 - && context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE); - } - - /** - * Gets instance of BluetoothManager. - * @param context context of application - * @return Instance of BluetoothManager or null if the BluetoothManager does not exist. - */ - public static BluetoothManager getManager(final Context context) { - return (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE); - } - - /** - * Checks whether permission allow by user. - * @param context context of application - * @return Returns true if permission allow, otherwise false - */ - public static boolean isBLEPermission(final Context context) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - return true; - } else { - boolean result = true; - for (int i = 0; i < BLE_PERMISSIONS.length; i++) { - if (context.checkSelfPermission(BLE_PERMISSIONS[i]) != PackageManager.PERMISSION_GRANTED) { - result = false; - } - } - return result; - } - } - - /** - * Checks whether bluetooth on/off. - * @param context context of application - * @return Returns true if bluetooth on, otherwise false - */ - public static boolean isEnabled(final Context context) { - BluetoothManager manager = getManager(context); - BluetoothAdapter bluetoothAdapter = manager.getAdapter(); - - if (!isBLEPermission(context)) { - return false; - } - return bluetoothAdapter.isEnabled(); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/HitoeScheduler.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/HitoeScheduler.java deleted file mode 100644 index 9a1f52a90c..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/HitoeScheduler.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.deviceconnect.android.deviceplugin.hitoe.util; - -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -/** - * Hitoe Scheduler. - * - * @author NTT DOCOMO, INC. - */ - -public class HitoeScheduler { - - /** - * Instance of ScheduledExecutorService. - */ - private ScheduledExecutorService mExecutor = Executors.newSingleThreadScheduledExecutor(); - - /** - * ScheduledFuture of scan timer. - */ - private ScheduledFuture mScanTimerFuture; - - /** - * Defines a delay 1 second at first execution. - */ - private static final long SCAN_FIRST_WAIT_PERIOD = 1000; - - /** - * Defines a period 10 seconds between successive executions. - */ - private static final long SCAN_WAIT_PERIOD = 10 * 1000; - /** - * Scanning flag. - */ - private boolean mScanning; - /** Notify listener. */ - private OnRegularNotify mNotify; - /** Default wait period. */ - private long mWaitPeriod = SCAN_WAIT_PERIOD; - /** Default first wait period. */ - private long mFirstWaitPeriod = SCAN_FIRST_WAIT_PERIOD; - - /** - * Constructor. - * @param notify listener - * @param first first wait period - * @param period wait period - */ - public HitoeScheduler(final OnRegularNotify notify, final long first, final long period) { - mNotify = notify; - if (first > 0) { - mFirstWaitPeriod = first; - } - if (period > 0) { - mWaitPeriod = period; - } - } - /** - * Scan Hitoe device. - * @param enable scan flag - */ - public synchronized void scanHitoeDevice(final boolean enable) { - if (enable) { - if (mScanning || mScanTimerFuture != null) { - // scan have already started. - return; - } - mScanning = true; - mScanTimerFuture = mExecutor.scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - if (mNotify != null) { - mNotify.onRegularNotify(); - } - } - }, mFirstWaitPeriod, mWaitPeriod, TimeUnit.MILLISECONDS); - } else { - mScanning = false; - cancelScanTimer(); - } - } - - /** - * Stopped the scan timer. - */ - private synchronized void cancelScanTimer() { - if (mScanTimerFuture != null) { - mScanTimerFuture.cancel(true); - mScanTimerFuture = null; - } - } - - public interface OnRegularNotify { - void onRegularNotify(); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/MDERFloatConvreterUtils.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/MDERFloatConvreterUtils.java deleted file mode 100644 index baa6e211da..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/MDERFloatConvreterUtils.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - MDERFloatConvreterUtils - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.util; - -import java.math.BigDecimal; -import java.text.DecimalFormat; - -/** - * A class containing utility methods convert MDER Float. - * @author NTT DOCOMO, INC. - */ -public final class MDERFloatConvreterUtils { - - /** - * Private Constructor. - */ - private MDERFloatConvreterUtils() { - } - - /** - * The Plug-Ins and the APIs designed for consumer/ personal use perspective. - * The following requirements specify the guidelines for all Health Device Plug-Ins. - * Values, when reported, are reported as Strings or MDER FLOATs. - * MDER FLOATs are used to report integers or real numbers. - * The reason for using MDER FLOATs is to capture precision as reported by the device. - * An MDER FLOAT is a 32 bit integer interpreted as follows: - * @param target target float value - * @return mder float value - */ - public static String convertMDERFloatToFloat(final float target) { - DecimalFormat df = new DecimalFormat("##########.##########"); - BigDecimal value = new BigDecimal(target); - int exponent = getExponent(df.format(target)); - int mantissa = value.scaleByPowerOfTen(exponent * -1).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); - return String.format("%02X%06X",(exponent & 0xFF), (mantissa & 0xFFFFFF)); - } - - /** - * Get Exponent. - * @param value target value - * @return exponent - */ - private static int getExponent(final String value) { - int index = value.indexOf("."); - if (index != -1) { - return ((value.length() -1) - index) * -1; - } else { - return countZero(value); - } - } - - /** - * Count Zero. - * @param c target - * @return Count - */ - private static int countZero(final String c) { - int count = 0; - if (c.charAt(c.length() - 1) != '0') { - return 0; - } - for (int i = 0; i < c.length(); i++) { - if (c.charAt(i) == '0') { - count++; - } - } - return count; - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/RawDataParseUtils.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/RawDataParseUtils.java deleted file mode 100644 index 6d48770627..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/RawDataParseUtils.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - RawDataParseUtils - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.deviceplugin.hitoe.util; - -import org.deviceconnect.android.deviceplugin.hitoe.data.AccelerationData; -import org.deviceconnect.android.deviceplugin.hitoe.data.HeartData; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeConstants; -import org.deviceconnect.android.deviceplugin.hitoe.data.HitoeDevice; -import org.deviceconnect.android.deviceplugin.hitoe.data.PoseEstimationData; -import org.deviceconnect.android.deviceplugin.hitoe.data.StressEstimationData; -import org.deviceconnect.android.deviceplugin.hitoe.data.TargetDeviceData; -import org.deviceconnect.android.deviceplugin.hitoe.data.WalkStateData; -import org.deviceconnect.profile.PoseEstimationProfileConstants; -import org.deviceconnect.profile.WalkStateProfileConstants; -import org.deviceconnect.utils.RFC3339DateUtils; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; - -/** - * A class containing utility methods parse raw data. - * @author NTT DOCOMO, INC. - */ -public final class RawDataParseUtils { - - /** - * Private Constructor. - */ - private RawDataParseUtils() { - } - - - /** - * Parse HeartRate data. - * @param raw raw data - * @return HeartRate object - */ - public static HeartData parseHeartRate(final String raw) { - return parseHeartRate(raw, HeartData.HeartRateType.Rate, "heart rate", - 147842, "beat per min", 264864); - } - - /** - * Parse RRI data. - * @param raw raw data - * @return RRI object - */ - public static HeartData parseRRI(final String raw) { - return parseHeartRate(raw, HeartData.HeartRateType.RRI, "RR interval", - 147240, "ms", 264338); - } - - /** - * Parse EnergyExpended data. - * @param raw raw data - * @return EnergyExpended object - */ - public static HeartData parseEnergyExpended(final String raw) { - return parseHeartRate(raw, HeartData.HeartRateType.EnergyExpended, "energy expended", - 119, "Calories", 6784); - } - - - /** - * Parse Hitoe Device info data. - * @param hitoe hitoe device - * @param batteryLevel battery level - * @return Hitoe device info object - */ - public static TargetDeviceData parseDeviceData(final HitoeDevice hitoe, final float batteryLevel) { - TargetDeviceData device = new TargetDeviceData(); - device.setProductName(hitoe.getName()); - if (batteryLevel > -1.0) { - device.setBatteryLevel((batteryLevel + 1) / 4.0f); - } - return device; - } - - - /** - * Parse Acceleration Data. - * @param data Accleration data - * @param raw raw data - * @return Acceleration object - */ - public static AccelerationData parseAccelerationData(final AccelerationData data, final String raw) { - if (raw == null) { - return data; - } - String[] lineList = raw.split(HitoeConstants.BR); - String[] list = lineList[0].split(HitoeConstants.COMMA, -1); - String[] accList = list[1].split(HitoeConstants.COLON, -1); - double[] accelList = new double[3]; - for (int i = 0; i < accList.length; i++) { - accelList[i] = Double.valueOf(accList[i]); - } - data.setAccelX(accelList[0]); - data.setAccelY(accelList[1]); - data.setAccelZ(accelList[2]); - return data; - } - - - - /** - * Parse ECG Data. - * @param raw raw data - * @return ECG data object - */ - public static HeartData parseECG(final String raw) { - String[] lineList = raw.split(HitoeConstants.BR); - HeartData heart = new HeartData(); - for (int i = 0; i < lineList.length; i++) { - String val = lineList[i]; - if (val == null) { - continue; - } - String[] list = val.split(HitoeConstants.COMMA, -1); - long timestamp = Long.parseLong(list[0]); - String[] ecgList = list[1].split(HitoeConstants.COLON, -1); - String date = RFC3339DateUtils.toString(timestamp); - heart.setValue(Float.parseFloat(ecgList[0])); - heart.setTimeStamp(timestamp); - heart.setTimeStampString(date); - } - heart.setHeartRateType(HeartData.HeartRateType.ECG); - heart.setMderFloat(MDERFloatConvreterUtils.convertMDERFloatToFloat(heart.getValue())); - heart.setType("ecg beat"); - heart.setTypeCode(663568); - heart.setUnit("mVolt * miliSecond"); - heart.setUnitCode(3328); - - return heart; - - } - - /** - * Parse Stress Estimation data. - * @param raw raw data - * @return Stress Estimation object - */ - public static StressEstimationData parseStressEstimation(final String raw) { - StressEstimationData stress = new StressEstimationData(); - if (raw == null) { - return stress; - } - String[] lineList = raw.split(HitoeConstants.BR); - String[] stressList = lineList[0].split(HitoeConstants.COMMA, -1); - if (stressList[0].isEmpty() || stressList[1].isEmpty()) { - return stress; - } - long timestamp = Long.parseLong(stressList[0]); - double lfhf = Double.parseDouble(stressList[1]); - stress.setLFHFValue(lfhf); - stress.setTimeStamp(timestamp); - stress.setTimeStampString(RFC3339DateUtils.toString(timestamp)); - return stress; - } - - - /** - * Parse Pose Estimation data. - * @param raw raw data - * @return Pose Estimation object - */ - public static PoseEstimationData parsePoseEstimation(final String raw) { - PoseEstimationData pose = new PoseEstimationData(); - if (raw == null) { - return pose; - } - String[] lineList = raw.split(HitoeConstants.BR); - String[] poseList = lineList[0].split(HitoeConstants.COMMA, -1); - long timestamp = 0; - try { - timestamp = Long.parseLong(poseList[0]); - } catch (NumberFormatException e) { - return pose; - } - pose.setTimeStamp(timestamp); - pose.setTimeStampString(RFC3339DateUtils.toString(timestamp)); - - String type = poseList[1]; - - int backForward = Integer.parseInt(poseList[2]); - int leftRight = Integer.parseInt(poseList[3]); - - if (type.equals("LyingLeft")) { - pose.setPoseState(PoseEstimationProfileConstants.PoseState.FaceLeft); - } else if (type.equals("LyingRight")) { - pose.setPoseState(PoseEstimationProfileConstants.PoseState.FaceRight); - } else if (type.equals("LyingFaceUp")) { - pose.setPoseState(PoseEstimationProfileConstants.PoseState.FaceUp); - } else if (type.equals("LyingFaceDown")) { - pose.setPoseState(PoseEstimationProfileConstants.PoseState.FaceDown); - } else { - if (backForward > HitoeConstants.BACK_FORWARD_THRESHOLD) { - pose.setPoseState(PoseEstimationProfileConstants.PoseState.Forward); - } else if (backForward < -1 * HitoeConstants.BACK_FORWARD_THRESHOLD) { - pose.setPoseState(PoseEstimationProfileConstants.PoseState.Backward); - } else if (leftRight > HitoeConstants.LEFT_RIGHT_THRESHOLD) { - pose.setPoseState(PoseEstimationProfileConstants.PoseState.Leftside); - } else if (leftRight < -1 * HitoeConstants.LEFT_RIGHT_THRESHOLD) { - pose.setPoseState(PoseEstimationProfileConstants.PoseState.Rightside); - } else { - pose.setPoseState(PoseEstimationProfileConstants.PoseState.Standing); - } - } - - return pose; - } - - /** - * Parse Walk State data. - * @param data exist walk state data - * @param raw raw data - * @return walk state object - */ - public static WalkStateData parseWalkState(final WalkStateData data, final String raw) { - String[] lineList = raw.split(HitoeConstants.BR); - String[] walkList = lineList[0].split(HitoeConstants.COMMA, -1); - long timestamp = 0; - try { - timestamp = Long.parseLong(walkList[0]); - } catch (NumberFormatException e) { - return data; - } - data.setTimeStamp(timestamp); - data.setTimeStampString(RFC3339DateUtils.toString(timestamp)); - data.setStep(Integer.parseInt(walkList[1])); - if (walkList[4].equals("Walking")) { - data.setState(WalkStateProfileConstants.WalkState.Walking); - } else if (walkList[4].equals("Running")) { - data.setState(WalkStateProfileConstants.WalkState.Running); - } else { - data.setState(WalkStateProfileConstants.WalkState.Stop); - } - data.setSpeed(Double.parseDouble(walkList[6])); - data.setDistance(Double.parseDouble(walkList[7])); - return data; - } - - /** - * Parse Walk State data for balance. - * @param data walk state data - * @param raw raw data - * @return walk state object - */ - public static WalkStateData parseWalkStateForBalance(final WalkStateData data, final String raw) { - String[] lineList = raw.split(HitoeConstants.BR); - String[] walkList = lineList[0].split(HitoeConstants.COMMA, -1); - if (walkList.length <= 1) { - return data; - } - data.setBalance(Double.parseDouble(walkList[1])); - return data; - } - - /** - * Parse HeartRate data. - * @param raw raw data - * @param heartRateType HeartRate type - * @param type type - * @param typeCode type code - * @param unit unit - * @param unitCode unit Code - * @return HeartRate data - */ - private static HeartData parseHeartRate(final String raw, final HeartData.HeartRateType heartRateType, - final String type, final int typeCode, - final String unit, final int unitCode) { - HeartData heart = new HeartData(); - String[] lineList = raw.split(HitoeConstants.BR); - String rateString = lineList[lineList.length - 1]; - heart.setHeartRateType(heartRateType); - if (rateString == null) { - return null; - } - String[] hrValue = splitComma(rateString); - float rate = Float.parseFloat(hrValue[1]); - heart.setValue(rate); - heart.setMderFloat(MDERFloatConvreterUtils.convertMDERFloatToFloat(rate)); - heart.setType(type); - heart.setTypeCode(typeCode); - heart.setUnit(unit); - heart.setUnitCode(unitCode); - heart.setTimeStamp(Long.parseLong(hrValue[0])); - heart.setTimeStampString(RFC3339DateUtils.toString(Long.parseLong(hrValue[0]))); - return heart; - - } - - - - /** - * Split Comma. - * @param val split value - * @return string array - */ - private static String[] splitComma(final String val) { - return val.split(",", -1); - } - - } diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/UserSettings.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/UserSettings.java deleted file mode 100755 index 39f573c69c..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/UserSettings.java +++ /dev/null @@ -1,75 +0,0 @@ -/* -UserSettings -Copyright (c) 2014 NTT DOCOMO,INC. -Released under the MIT license -http://opensource.org/licenses/mit-license.php -*/ - -package org.deviceconnect.android.deviceplugin.hitoe.util; - -import android.app.Activity; -import android.content.Context; -import android.content.SharedPreferences; - -/** - * UserSettings. - * @author NTT DOCOMO, INC. - */ -public class UserSettings { - /** Preference name. */ - private static final String PREF_NAME = "hitoe_setting_pref"; - /** Key of next on. */ - private static final String KEY_HITOE_ON_NEXT = "next_on"; - /** Key of warning message. */ - private static final String KEY_WARNING_MESSAGE = "warning_message"; - - /** SharedPreferences' instance. */ - private SharedPreferences mPref; - /** SharedPreferences.Editor's instance. */ - private SharedPreferences.Editor mEditor; - - /** - * Constructor. - * @param context Context in which this class belongs - */ - public UserSettings(final Context context) { - mPref = context.getSharedPreferences(PREF_NAME, Activity.MODE_PRIVATE); - } - - /** - * Get the Next state registered. - * Returns null if the Next state is not registered. - * @return true:next show false:next not show - */ - public boolean isNextState() { - return mPref.getBoolean(KEY_HITOE_ON_NEXT, false); - } - - /** - * Get the Warning message flag. - * @return true:next show false:next not show - */ - public boolean isWarningMessage() { - return mPref.getBoolean(KEY_WARNING_MESSAGE, false); - } - - /** - * Register the Next state. - * @param state true:next show false:next not show - */ - public void setNextState(final boolean state) { - mEditor = mPref.edit(); - mEditor.putBoolean(KEY_HITOE_ON_NEXT, state); - mEditor.commit(); - } - - /** - * Register the Warning Message flag. - * @param state true:next show false:next not show - */ - public void setWarningMessage(final boolean state) { - mEditor = mPref.edit(); - mEditor.putBoolean(KEY_WARNING_MESSAGE, state); - mEditor.commit(); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/package-info.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/package-info.java deleted file mode 100755 index 8b5066be35..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/deviceplugin/hitoe/util/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/* -org.deviceconnect.android.deviceplugin.hitoe.util -Copyright (c) 2016 NTT DOCOMO,INC. -Released under the MIT license -http://opensource.org/licenses/mit-license.php - */ - -/** - * Utils for hitoe device. - */ -package org.deviceconnect.android.deviceplugin.hitoe.util; - diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/EventDispatcher.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/EventDispatcher.java deleted file mode 100644 index 1de05d4415..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/EventDispatcher.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.deviceconnect.android.event; - -import android.content.Intent; - -import org.deviceconnect.android.message.DConnectMessageService; - -public abstract class EventDispatcher { - - private DConnectMessageService mMessageService; - - public EventDispatcher(final DConnectMessageService service) { - if (service == null) { - throw new NullPointerException("service is null."); - } - mMessageService = service; - } - - public abstract void sendEvent(final Event event, final Intent message); - public abstract void start(); - public abstract void stop(); - - protected void sendEventInternal(final Event event, final Intent message) { - mMessageService.sendEvent(message, event.getAccessToken()); - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/EventDispatcherFactory.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/EventDispatcherFactory.java deleted file mode 100644 index 98184bf766..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/EventDispatcherFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.deviceconnect.android.event; - -import android.content.Intent; - -import org.deviceconnect.android.message.DConnectMessageService; - -public final class EventDispatcherFactory { - - private EventDispatcherFactory() { - } - - public static EventDispatcher createEventDispatcher(final DConnectMessageService service, final Intent request) { - if (request.getExtras().containsKey("interval")) { - int interval = getInterval(request); - if (interval > 0) { - return createIntervalEventDispatcher(service, interval); - } - } - return createImmediateEventDispatcher(service); - } - - public static EventDispatcher createIntervalEventDispatcher(final DConnectMessageService service, final int periodTime) { - return new IntervalEventDispatcher(service, periodTime, periodTime); - } - - public static EventDispatcher createImmediateEventDispatcher(final DConnectMessageService service) { - return new ImmediateEventDispatcher(service); - } - - private static int getInterval(final Intent request) { - try { - String interval = request.getStringExtra("interval"); - return Integer.parseInt(interval); - } catch (NumberFormatException e) { - return -1; - } - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/EventDispatcherManager.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/EventDispatcherManager.java deleted file mode 100644 index 2c3b77f3f8..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/EventDispatcherManager.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.deviceconnect.android.event; - -import android.content.Intent; - -import java.util.HashMap; -import java.util.Map; - -public class EventDispatcherManager { - - private Map mEventMap = new HashMap<>(); - - public void addEventDispatcher(final Event event, final org.deviceconnect.android.event.EventDispatcher dispatcher) { - if (containsEventDispatcher(event)) { - return; - } - mEventMap.put(event, dispatcher); - dispatcher.start(); - } - - public void removeEventDispatcher(final Event event) { - org.deviceconnect.android.event.EventDispatcher dispatcher = mEventMap.remove(event); - if (dispatcher != null) { - dispatcher.stop(); - } - } - - public void removeAllEventDispatcher() { - for (Map.Entry e : mEventMap.entrySet()) { - e.getValue().stop(); - } - mEventMap.clear(); - } - - public boolean containsEventDispatcher(final Event event) { - return mEventMap.containsKey(event); - } - - public void sendEvent(final Event event, final Intent message) { - org.deviceconnect.android.event.EventDispatcher dispatcher = mEventMap.get(event); - if (dispatcher != null) { - dispatcher.sendEvent(event, message); - } - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/ImmediateEventDispatcher.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/ImmediateEventDispatcher.java deleted file mode 100644 index b41d8b57e5..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/ImmediateEventDispatcher.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.deviceconnect.android.event; - -import android.content.Intent; - -import org.deviceconnect.android.message.DConnectMessageService; - -public class ImmediateEventDispatcher extends EventDispatcher { - - public ImmediateEventDispatcher(final DConnectMessageService service) { - super(service); - } - - @Override - public void sendEvent(final Event event, final Intent message) { - sendEventInternal(event, message); - } - - @Override - public void start() { - // do nothing. - } - - @Override - public void stop() { - // do nothing. - } -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/IntervalEventDispatcher.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/IntervalEventDispatcher.java deleted file mode 100644 index 14ac5c054d..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/event/IntervalEventDispatcher.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.deviceconnect.android.event; - -import android.content.Intent; - -import org.deviceconnect.android.message.DConnectMessageService; - -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -public class IntervalEventDispatcher extends EventDispatcher { - - private ScheduledExecutorService mExecutorService = Executors.newSingleThreadScheduledExecutor(); - private ScheduledFuture mScheduledFuture; - - private int mFirstPeriodTime; - private int mPeriodTime; - - private Event mEvent; - private Intent mMessage; - - private final Object mLockObject = new Object(); - - public IntervalEventDispatcher(final DConnectMessageService service, final int firstPeriodTime, final int periodTime) { - super(service); - - if (firstPeriodTime < 0) { - throw new IllegalArgumentException("firstPeriodTime is negative."); - } - - if (periodTime <= 0) { - throw new IllegalArgumentException("periodTime is zero or negative."); - } - - mFirstPeriodTime = firstPeriodTime; - mPeriodTime = periodTime; - } - - @Override - public void sendEvent(final Event event, final Intent message) { - synchronized (mLockObject) { - mEvent = event; - mMessage = message; - } - } - - @Override - public void start() { - if (mScheduledFuture != null) { - throw new IllegalStateException("This IntervalEventDispatcher already started."); - } - mScheduledFuture = mExecutorService.scheduleAtFixedRate(mRunnable, mFirstPeriodTime, mPeriodTime,TimeUnit.MILLISECONDS); - } - - @Override - public void stop() { - if (mScheduledFuture != null) { - mScheduledFuture.cancel(true); - mExecutorService.shutdown(); - } - } - - private Runnable mRunnable = () -> { - synchronized (mLockObject) { - if (mEvent != null && mMessage != null) { - sendEventInternal(mEvent, mMessage); - } - mEvent = null; - mMessage = null; - } - }; -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/ECGProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/ECGProfile.java deleted file mode 100644 index 891f5216c3..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/ECGProfile.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - ECGProfile.java - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.profile; - -import android.content.Intent; -import android.os.Bundle; - -import org.deviceconnect.profile.ECGProfileConstants; - -/** - * ECG プロファイル. - * - *

- * スマートデバイスに対しての心電図計測機能を提供するAPI.
- * スマートデバイスに対しての心電図計測機能を提供するデバイスプラグインは当クラスを継承し、対応APIを実装すること。
- *

- * - *

各API提供メソッド

- *

- * ECG Profile の各APIへのリクエストに対し、以下のコールバックメソッド群が自動的に呼び出される。
- * サブクラスは以下のメソッド群からデバイスプラグインが提供するAPI用のメソッドをオーバーライドし、機能を実装すること。
- * オーバーライドされていない機能は自動的に非対応APIとしてレスポンスを返す。 - *

- * @author NTT DOCOMO, INC. - */ -public class ECGProfile extends DConnectProfile implements ECGProfileConstants { - - @Override - public final String getProfileName() { - return PROFILE_NAME; - } - - - // ------------------------------------ - // セッターメソッド群 - // ------------------------------------ - - /** - * レスポンスにECGを設定する. - * - * @param response レスポンス - * @param ecg ECGオブジェクト - */ - public static void setECG(final Intent response, final Bundle ecg) { - response.putExtra(PARAM_ECG, ecg); - } - - /** - * レスポンスに測定値を設定する. - * - * @param response レスポンス - * @param value 測定値 - */ - public static void setValue(final Bundle response, final float value) { - response.putFloat(PARAM_VALUE, value); - } - - /** - * レスポンスにMDER Float値を設定する. - * - * @param response レスポンス - * @param mder MDER Float値 - */ - public static void setMDERFloat(final Bundle response, final String mder) { - response.putString(PARAM_MDER_FLOAT, mder); - } - /** - * レスポンスにtype値を設定する. - * - * @param response レスポンス - * @param type type - */ - public static void setType(final Bundle response, final String type) { - response.putString(PARAM_TYPE, type); - } - /** - * レスポンスにtypeCode値を設定する. - * - * @param response レスポンス - * @param typeCode typeCode - */ - public static void setTypeCode(final Bundle response, final int typeCode) { - response.putInt(PARAM_TYPE_CODE, typeCode); - } - /** - * レスポンスにunit値を設定する. - * - * @param response レスポンス - * @param unit unit - */ - public static void setUnit(final Bundle response, final String unit) { - response.putString(PARAM_UNIT, unit); - } - /** - * レスポンスにUnitCode値を設定する. - * - * @param response レスポンス - * @param unitCode UnitCode - */ - public static void setUnitCode(final Bundle response, final int unitCode) { - response.putInt(PARAM_UNIT_CODE, unitCode); - } - /** - * レスポンスにTimeStamp値を設定する. - * - * @param response レスポンス - * @param timeStamp TimeStamp - */ - public static void setTimestamp(final Bundle response, final long timeStamp) { - response.putLong(PARAM_TIMESTAMP, timeStamp); - } - /** - * レスポンスにTimeStampString値を設定する. - * - * @param response レスポンス - * @param timeStampString TimeStampString - */ - public static void setTimestampString(final Bundle response, final String timeStampString) { - response.putString(PARAM_TIMESTAMP_STRING, timeStampString); - } - - - // ------------------------------------ - // ゲッターメソッド群 - // ------------------------------------ -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/HealthProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/HealthProfile.java deleted file mode 100644 index 78ae540f82..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/HealthProfile.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - HealthProfile.java - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.profile; - -import android.content.Intent; -import android.os.Bundle; - -import org.deviceconnect.profile.HealthProfileConstants; - -/** - * Health プロファイル. - * - *

- * スマートデバイスに対しての健康機器操作機能を提供するAPI.
- * スマートデバイスに対しての健康機器操作機能を提供するデバイスプラグインは当クラスを継承し、対応APIを実装すること。
- *

- * - *

各API提供メソッド

- *

- * Health Profile の各APIへのリクエストに対し、以下のコールバックメソッド群が自動的に呼び出される。
- * サブクラスは以下のメソッド群からデバイスプラグインが提供するAPI用のメソッドをオーバーライドし、機能を実装すること。
- * オーバーライドされていない機能は自動的に非対応APIとしてレスポンスを返す。 - *

- - * @author NTT DOCOMO, INC. - */ -public class HealthProfile extends DConnectProfile implements HealthProfileConstants { - - @Override - public final String getProfileName() { - return PROFILE_NAME; - } - - - // ------------------------------------ - // セッターメソッド群 - // ------------------------------------ - - /** - * レスポンスに心拍数を設定する. - * - * @param response レスポンス - * @param heartRate 心拍数 - */ - public static void setHeartRate(final Intent response, final int heartRate) { - response.putExtra(PARAM_HEART_RATE, heartRate); - } - /** - * レスポンスにHealthを設定する. - * - * @param response レスポンス - * @param heart 心拍数,RRIオブジェクト - */ - public static void setHeart(final Intent response, final Bundle heart) { - response.putExtra(PARAM_HEART, heart); - } - /** - * レスポンスに心拍数を設定する. - * - * @param response レスポンス - * @param rate 心拍数オブジェクト - */ - public static void setRate(final Bundle response, final Bundle rate) { - response.putBundle(PARAM_RATE, rate); - } - /** - * レスポンスにRRIを設定する. - * - * @param response レスポンス - * @param rr RRIオブジェクト - */ - public static void setRRI(final Bundle response, final Bundle rr) { - response.putBundle(PARAM_RR, rr); - } - /** - * レスポンスにEnergyExtendedを設定する. - * - * @param response レスポンス - * @param energy RRIオブジェクト - */ - public static void setEnergyExtended(final Bundle response, final Bundle energy) { - response.putBundle(PARAM_ENERGY, energy); - } - /** - * レスポンスにHealthデバイス情報を設定する. - * - * @param response レスポンス - * @param device Healthデバイスオブジェクト - */ - public static void setDevice(final Bundle response, final Bundle device) { - response.putBundle(PARAM_DEVICE, device); - } - - /** - * レスポンスに測定値を設定する. - * - * @param response レスポンス - * @param value 測定値 - */ - public static void setValue(final Bundle response, final float value) { - response.putFloat(PARAM_VALUE, value); - } - - /** - * レスポンスにMDER Float値を設定する. - * - * @param response レスポンス - * @param mder MDER Float値 - */ - public static void setMDERFloat(final Bundle response, final String mder) { - response.putString(PARAM_MDER_FLOAT, mder); - } - /** - * レスポンスにtype値を設定する. - * - * @param response レスポンス - * @param type type - */ - public static void setType(final Bundle response, final String type) { - response.putString(PARAM_TYPE, type); - } - /** - * レスポンスにtypeCode値を設定する. - * - * @param response レスポンス - * @param typeCode typeCode - */ - public static void setTypeCode(final Bundle response, final int typeCode) { - response.putInt(PARAM_TYPE_CODE, typeCode); - } - /** - * レスポンスにunit値を設定する. - * - * @param response レスポンス - * @param unit unit - */ - public static void setUnit(final Bundle response, final String unit) { - response.putString(PARAM_UNIT, unit); - } - /** - * レスポンスにUnitCode値を設定する. - * - * @param response レスポンス - * @param unitCode UnitCode - */ - public static void setUnitCode(final Bundle response, final int unitCode) { - response.putInt(PARAM_UNIT_CODE, unitCode); - } - /** - * レスポンスにTimeStamp値を設定する. - * - * @param response レスポンス - * @param timeStamp TimeStamp - */ - public static void setTimestamp(final Bundle response, final long timeStamp) { - response.putLong(PARAM_TIMESTAMP, timeStamp); - } - /** - * レスポンスにTimeStampString値を設定する. - * - * @param response レスポンス - * @param timeStampString TimeStampString - */ - public static void setTimestampString(final Bundle response, final String timeStampString) { - response.putString(PARAM_TIMESTAMP_STRING, timeStampString); - } - - /** - * レスポンスにProductName値を設定する. - * - * @param response レスポンス - * @param productName productName - */ - public static void setProductName(final Bundle response, final String productName) { - response.putString(PARAM_PRODUCT_NAME, productName); - } - /** - * レスポンスにManufacturerName値を設定する. - * - * @param response レスポンス - * @param manufacturerName ManufacturerName - */ - public static void setManufacturerName(final Bundle response, final String manufacturerName) { - response.putString(PARAM_MANUFACTURER_NAME, manufacturerName); - } - /** - * レスポンスにModelNumber値を設定する. - * - * @param response レスポンス - * @param modelNumber ModelNumber - */ - public static void setModelNumber(final Bundle response, final String modelNumber) { - response.putString(PARAM_MODEL_NUMBER, modelNumber); - } - /** - * レスポンスにFirmwareRevision値を設定する. - * - * @param response レスポンス - * @param firmwareRevision FirmwareRevision - */ - public static void setFirmwareRevision(final Bundle response, final String firmwareRevision) { - response.putString(PARAM_FIRMWARE_REVISION, firmwareRevision); - } - /** - * レスポンスにSerialNumber値を設定する. - * - * @param response レスポンス - * @param serialNumber SerialNumber - */ - public static void setSerialNumber(final Bundle response, final String serialNumber) { - response.putString(PARAM_SERIAL_NUMBER, serialNumber); - } - /** - * レスポンスにSoftwareRevision値を設定する. - * - * @param response レスポンス - * @param softwareRevision SoftwareRevision - */ - public static void setSoftwareRevision(final Bundle response, final String softwareRevision) { - response.putString(PARAM_SOFTWARE_REVISION, softwareRevision); - } - /** - * レスポンスにHardwareRevision値を設定する. - * - * @param response レスポンス - * @param hardwareRevision HardwareRevision - */ - public static void setHardwareRevision(final Bundle response, final String hardwareRevision) { - response.putString(PARAM_HARDWARE_REVISION, hardwareRevision); - } - /** - * レスポンスにPartNumber値を設定する. - * - * @param response レスポンス - * @param partNumber PartNumber - */ - public static void setPartNumber(final Bundle response, final String partNumber) { - response.putString(PARAM_PART_NUMBER, partNumber); - } - /** - * レスポンスにProtocolRevision値を設定する. - * - * @param response レスポンス - * @param protocolRevision ProtocolRevision - */ - public static void setProtocolRevision(final Bundle response, final String protocolRevision) { - response.putString(PARAM_PROTOCOL_REVISION, protocolRevision); - } - /** - * レスポンスにSystemId値を設定する. - * - * @param response レスポンス - * @param systemId SystemId - */ - public static void setSystemId(final Bundle response, final String systemId) { - response.putString(PARAM_SYSTEM_ID, systemId); - } - /** - * レスポンスにBatteryLevel値を設定する. - * - * @param response レスポンス - * @param batteryLevel BatteryLevel - */ - public static void setBatteryLevel(final Bundle response, final float batteryLevel) { - response.putFloat(PARAM_BATTERY_LEVEL, batteryLevel); - } - // ------------------------------------ - // ゲッターメソッド群 - // ------------------------------------ -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/PoseEstimationProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/PoseEstimationProfile.java deleted file mode 100644 index db4aa8571c..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/PoseEstimationProfile.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - PoseEstimationProfile.java - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.profile; - -import android.content.Intent; -import android.os.Bundle; - -import org.deviceconnect.profile.PoseEstimationProfileConstants; - -/** - * PoseEstimation プロファイル. - * - *

- * スマートデバイスに対しての姿勢推定機能を提供するAPI.
- * スマートデバイスに対しての姿勢推定機能を提供するデバイスプラグインは当クラスを継承し、対応APIを実装すること。
- *

- * - *

各API提供メソッド

- *

- * Pose Estimation Profile の各APIへのリクエストに対し、以下のコールバックメソッド群が自動的に呼び出される。
- * サブクラスは以下のメソッド群からデバイスプラグインが提供するAPI用のメソッドをオーバーライドし、機能を実装すること。
- * オーバーライドされていない機能は自動的に非対応APIとしてレスポンスを返す。 - *

- * @author NTT DOCOMO, INC. - */ -public class PoseEstimationProfile extends DConnectProfile implements PoseEstimationProfileConstants { - - @Override - public final String getProfileName() { - return PROFILE_NAME; - } - - - - // ------------------------------------ - // セッターメソッド群 - // ------------------------------------ - - /** - * レスポンスにPoseを設定する. - * - * @param response レスポンス - * @param stress Poseオブジェクト - */ - public static void setPose(final Intent response, final Bundle stress) { - response.putExtra(PARAM_STRESS, stress); - } - - /** - * レスポンスに姿勢状態を設定する. - * - * @param response レスポンス - * @param state 姿勢 - */ - public static void setState(final Bundle response, final String state) { - response.putString(PARAM_STATE, state); - } - - /** - * レスポンスにTimeStamp値を設定する. - * - * @param response レスポンス - * @param timeStamp TimeStamp - */ - public static void setTimestamp(final Bundle response, final long timeStamp) { - response.putLong(PARAM_TIMESTAMP, timeStamp); - } - /** - * レスポンスにTimeStampString値を設定する. - * - * @param response レスポンス - * @param timeStampString TimeStampString - */ - public static void setTimestampString(final Bundle response, final String timeStampString) { - response.putString(PARAM_TIMESTAMP_STRING, timeStampString); - } - - - // ------------------------------------ - // ゲッターメソッド群 - // ------------------------------------ -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/StressEstimationProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/StressEstimationProfile.java deleted file mode 100644 index fa3ca82a53..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/StressEstimationProfile.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - StressEstimationProfile.java - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.profile; - -import android.content.Intent; -import android.os.Bundle; - -import org.deviceconnect.profile.StressEstimationProfileConstants; - -/** - * StressEstimation プロファイル. - * - *

- * スマートデバイスに対してのストレス推定機能を提供するAPI.
- * スマートデバイスに対してのストレス推定機能を提供するデバイスプラグインは当クラスを継承し、対応APIを実装すること。
- *

- * - *

各API提供メソッド

- *

- * Stress Estimation Profile の各APIへのリクエストに対し、以下のコールバックメソッド群が自動的に呼び出される。
- * サブクラスは以下のメソッド群からデバイスプラグインが提供するAPI用のメソッドをオーバーライドし、機能を実装すること。
- * オーバーライドされていない機能は自動的に非対応APIとしてレスポンスを返す。 - *

- * @author NTT DOCOMO, INC. - */ -public class StressEstimationProfile extends DConnectProfile implements StressEstimationProfileConstants { - - @Override - public final String getProfileName() { - return PROFILE_NAME; - } - - - - - // ------------------------------------ - // セッターメソッド群 - // ------------------------------------ - - /** - * レスポンスにStressを設定する. - * - * @param response レスポンス - * @param stress Stressオブジェクト - */ - public static void setStress(final Intent response, final Bundle stress) { - response.putExtra(PARAM_STRESS, stress); - } - - /** - * レスポンスにLFHFを設定する. - * - * @param response レスポンス - * @param lfhf 測定値 - */ - public static void setLFHF(final Bundle response, final double lfhf) { - response.putDouble(PARAM_LFHF, lfhf); - } - - /** - * レスポンスにTimeStamp値を設定する. - * - * @param response レスポンス - * @param timeStamp TimeStamp - */ - public static void setTimestamp(final Bundle response, final long timeStamp) { - response.putLong(PARAM_TIMESTAMP, timeStamp); - } - /** - * レスポンスにTimeStampString値を設定する. - * - * @param response レスポンス - * @param timeStampString TimeStampString - */ - public static void setTimestampString(final Bundle response, final String timeStampString) { - response.putString(PARAM_TIMESTAMP_STRING, timeStampString); - } - - - // ------------------------------------ - // ゲッターメソッド群 - // ------------------------------------ -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/WalkStateProfile.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/WalkStateProfile.java deleted file mode 100644 index a0194adfe1..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/android/profile/WalkStateProfile.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - WalkStateProfile.java - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.android.profile; - -import android.content.Intent; -import android.os.Bundle; - -import org.deviceconnect.profile.WalkStateProfileConstants; - -/** - * WalkState プロファイル. - * - *

- * スマートデバイスに対しての歩行状態計測機能を提供するAPI.
- * スマートデバイスに対しての歩行状態計測機能を提供するデバイスプラグインは当クラスを継承し、対応APIを実装すること。
- *

- * - *

各API提供メソッド

- *

- * Walk State Profile の各APIへのリクエストに対し、以下のコールバックメソッド群が自動的に呼び出される。
- * サブクラスは以下のメソッド群からデバイスプラグインが提供するAPI用のメソッドをオーバーライドし、機能を実装すること。
- * オーバーライドされていない機能は自動的に非対応APIとしてレスポンスを返す。 - *

- * @author NTT DOCOMO, INC. - */ -public class WalkStateProfile extends DConnectProfile implements WalkStateProfileConstants { - - @Override - public final String getProfileName() { - return PROFILE_NAME; - } - - - - // ------------------------------------ - // セッターメソッド群 - // ------------------------------------ - - /** - * レスポンスにWalkを設定する. - * - * @param response レスポンス - * @param walk Walkオブジェクト - */ - public static void setWalk(final Intent response, final Bundle walk) { - response.putExtra(PARAM_WALK, walk); - } - - /** - * レスポンスに歩数を設定する. - * - * @param response レスポンス - * @param step 歩数 - */ - public static void setStep(final Bundle response, final int step) { - response.putInt(PARAM_STEP, step); - } - /** - * レスポンスに歩行状態を設定する. - * - * @param response レスポンス - * @param state 状態 - */ - public static void setState(final Bundle response, final String state) { - response.putString(PARAM_STATE, state); - } - /** - * レスポンスに速度を設定する. - * - * @param response レスポンス - * @param speed 速度 - */ - public static void setSpeed(final Bundle response, final double speed) { - response.putDouble(PARAM_SPEED, speed); - } - /** - * レスポンスに距離を設定する. - * - * @param response レスポンス - * @param distance 距離 - */ - public static void setDistance(final Bundle response, final double distance) { - response.putDouble(PARAM_DISTANCE, distance); - } - /** - * レスポンスにバランスを設定する. - * - * @param response レスポンス - * @param balance バランス - */ - public static void setBalance(final Bundle response, final double balance) { - response.putDouble(PARAM_BALANCE, balance); - } - /** - * レスポンスにTimeStamp値を設定する. - * - * @param response レスポンス - * @param timeStamp TimeStamp - */ - public static void setTimestamp(final Bundle response, final long timeStamp) { - response.putLong(PARAM_TIMESTAMP, timeStamp); - } - /** - * レスポンスにTimeStampString値を設定する. - * - * @param response レスポンス - * @param timeStampString TimeStampString - */ - public static void setTimestampString(final Bundle response, final String timeStampString) { - response.putString(PARAM_TIMESTAMP_STRING, timeStampString); - } - - - // ------------------------------------ - // ゲッターメソッド群 - // ------------------------------------ -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/ECGProfileConstants.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/ECGProfileConstants.java deleted file mode 100644 index a14056da7c..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/ECGProfileConstants.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - ECGProfileConstants.java - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.profile; - -/** - * ECG Profile API 定数群.
- * ECG Profile API のパラメータ名、インタフェース名、属性名、プロファイル名を定義する。 - * - * @author NTT DOCOMO, INC. - */ -public interface ECGProfileConstants extends DConnectProfileConstants { - /** - * プロファイル名: {@value} . - */ - String PROFILE_NAME = "ecg"; - /** - * 属性: {@value} . - */ - String ATTRIBUTE_ON_ECG = "onECG"; - - /** - * パラメータ: {@value} . - */ - String PARAM_ECG = "ecg"; - /** - * パラメータ: {@value} . - */ - String PARAM_VALUE = "value"; - /** - * パラメータ: {@value} . - */ - String PARAM_MDER_FLOAT = "mderFloat"; - /** - * パラメータ: {@value} . - */ - String PARAM_TYPE = "type"; - /** - * パラメータ: {@value} . - */ - String PARAM_TYPE_CODE = "typeCode"; - /** - * パラメータ: {@value} . - */ - String PARAM_UNIT = "unit"; - /** - * パラメータ: {@value} . - */ - String PARAM_UNIT_CODE = "unitCode"; - /** - * パラメータ: {@value} . - */ - String PARAM_TIMESTAMP = "timeStamp"; - /** - * パラメータ: {@value} . - */ - String PARAM_TIMESTAMP_STRING = "timeStampString"; - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/HealthProfileConstants.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/HealthProfileConstants.java deleted file mode 100644 index 54dc6be8ed..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/HealthProfileConstants.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - HealthProfileConstants.java - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.profile; - -/** - * Health Profile API 定数群.
- * Health Profile API のパラメータ名、インタフェース名、属性名、プロファイル名を定義する。 - * - * @author NTT DOCOMO, INC. - */ -public interface HealthProfileConstants extends DConnectProfileConstants { - /** - * プロファイル名: {@value} . - */ - String PROFILE_NAME = "health"; - - /** - * 属性: {@value} . - */ - String ATTRIBUTE_HEART_RATE = "heartrate"; - - /** - * 属性: {@value} . - */ - String ATTRIBUTE_HEART = "heart"; - /** - * 属性: {@value} . - */ - String ATTRIBUTE_ONHEART = "onHeart"; - - /** - * パラメータ: {@value} . - */ - String PARAM_HEART_RATE = "heartRate"; - /** - * パラメータ: {@value} . - */ - String PARAM_HEART = "heart"; - /** - * パラメータ: {@value} . - */ - String PARAM_RATE = "rate"; - /** - * パラメータ: {@value} . - */ - String PARAM_VALUE = "value"; - /** - * パラメータ: {@value} . - */ - String PARAM_MDER_FLOAT = "mderFloat"; - /** - * パラメータ: {@value} . - */ - String PARAM_TYPE = "type"; - /** - * パラメータ: {@value} . - */ - String PARAM_TYPE_CODE = "typeCode"; - /** - * パラメータ: {@value} . - */ - String PARAM_UNIT = "unit"; - /** - * パラメータ: {@value} . - */ - String PARAM_UNIT_CODE = "unitCode"; - /** - * パラメータ: {@value} . - */ - String PARAM_TIMESTAMP = "timeStamp"; - /** - * パラメータ: {@value} . - */ - String PARAM_TIMESTAMP_STRING = "timeStampString"; - - /** - * パラメータ: {@value} . - */ - String PARAM_RR = "rr"; - /** - * パラメータ: {@value} . - */ - String PARAM_ENERGY = "energy"; - /** - * パラメータ: {@value} . - */ - String PARAM_DEVICE = "device"; - /** - * パラメータ: {@value} . - */ - String PARAM_PRODUCT_NAME = "productName"; - /** - * パラメータ: {@value} . - */ - String PARAM_MANUFACTURER_NAME = "manufacturerName"; - /** - * パラメータ: {@value} . - */ - String PARAM_MODEL_NUMBER = "modelNumber"; - /** - * パラメータ: {@value} . - */ - String PARAM_FIRMWARE_REVISION = "firmwareRevision"; - /** - * パラメータ: {@value} . - */ - String PARAM_SERIAL_NUMBER = "serialNumber"; - /** - * パラメータ: {@value} . - */ - String PARAM_SOFTWARE_REVISION = "softwareRevision"; - /** - * パラメータ: {@value} . - */ - String PARAM_HARDWARE_REVISION = "hardwareRevision"; - /** - * パラメータ: {@value} . - */ - String PARAM_PART_NUMBER = "partNumber"; - /** - * パラメータ: {@value} . - */ - String PARAM_PROTOCOL_REVISION = "protocolRevision"; - /** - * パラメータ: {@value} . - */ - String PARAM_SYSTEM_ID = "systemId"; - /** - * パラメータ: {@value} . - */ - String PARAM_BATTERY_LEVEL = "batteryLevel"; - - /** - * パス: {@value}. - */ - String PATH_HEARTRATE = PROFILE_NAME + SEPARATOR + ATTRIBUTE_HEART_RATE; - - /** - * パス: {@value}. - */ - String PATH_HEART = PROFILE_NAME + SEPARATOR + ATTRIBUTE_HEART; - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/PoseEstimationProfileConstants.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/PoseEstimationProfileConstants.java deleted file mode 100644 index d4ca89a414..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/PoseEstimationProfileConstants.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - PoseEstimationProfileConstants.java - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.profile; - -/** - * PoseEstimation Profile API 定数群.
- * PoseEstimation Profile API のパラメータ名、インタフェース名、属性名、プロファイル名を定義する。 - * - * @author NTT DOCOMO, INC. - */ -public interface PoseEstimationProfileConstants extends DConnectProfileConstants { - /** Pose State enum. */ - public enum PoseState { - /** Forward. */ - Forward("Forward"), - /** Backward. */ - Backward("Backward"), - /** Rightside. */ - Rightside("Rightside"), - /** Leftside. */ - Leftside("Leftside"), - /** FaceUp. */ - FaceUp("FaceUp"), - /** FaceLeft. */ - FaceLeft("FaceLeft"), - /** FaceDown. */ - FaceDown("FaceDown"), - /** FaceRight. */ - FaceRight("FaceRight"), - /** Standing. */ - Standing("Standing"); - - /** - * Text. - */ - private final String mState; - - /** - * Constructor. - * @param state State - */ - private PoseState(final String state) { - mState = state; - } - - /** - * Get Pose State. - * @return Pose state - */ - public String getState() { - return mState; - } - } - /** - * プロファイル名: {@value} . - */ - String PROFILE_NAME = "poseEstimation"; - /** - * 属性: {@value} . - */ - String ATTRIBUTE_ON_POSE_ESTIMATION = "onPoseEstimation"; - - /** - * パラメータ: {@value} . - */ - String PARAM_STRESS = "pose"; - /** - * パラメータ: {@value} . - */ - String PARAM_STATE = "state"; - - /** - * パラメータ: {@value} . - */ - String PARAM_TIMESTAMP = "timeStamp"; - /** - * パラメータ: {@value} . - */ - String PARAM_TIMESTAMP_STRING = "timeStampString"; - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/StressEstimationProfileConstants.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/StressEstimationProfileConstants.java deleted file mode 100644 index 8703728b0f..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/StressEstimationProfileConstants.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - StressEstimationProfileConstants.java - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.profile; - -/** - * StressEstimation Profile API 定数群.
- * StressEstimation Profile API のパラメータ名、インタフェース名、属性名、プロファイル名を定義する。 - * - * @author NTT DOCOMO, INC. - */ -public interface StressEstimationProfileConstants extends DConnectProfileConstants { - /** - * プロファイル名: {@value} . - */ - String PROFILE_NAME = "stressEstimation"; - /** - * 属性: {@value} . - */ - String ATTRIBUTE_ON_STRESS_ESTIMATION = "onStressEstimation"; - /** - * パラメータ: {@value} . - */ - String PARAM_STRESS = "stress"; - /** - * パラメータ: {@value} . - */ - String PARAM_LFHF = "lfhf"; - /** - * パラメータ: {@value} . - */ - String PARAM_TIMESTAMP = "timeStamp"; - /** - * パラメータ: {@value} . - */ - String PARAM_TIMESTAMP_STRING = "timeStampString"; - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/WalkStateProfileConstants.java b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/WalkStateProfileConstants.java deleted file mode 100644 index 370594dbc1..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/java/org/deviceconnect/profile/WalkStateProfileConstants.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - WalkStateProfileConstants.java - Copyright (c) 2016 NTT DOCOMO,INC. - Released under the MIT license - http://opensource.org/licenses/mit-license.php - */ -package org.deviceconnect.profile; - -/** - * WalkState Profile API 定数群.
- * WalkState Profile API のパラメータ名、インタフェース名、属性名、プロファイル名を定義する。 - * - * @author NTT DOCOMO, INC. - */ -public interface WalkStateProfileConstants extends DConnectProfileConstants { - /** Walk State enum. */ - public enum WalkState { - /** Stop. */ - Stop("Stop"), - /** Walking. */ - Walking("Walking"), - /** Running. */ - Running("Running"); - - /** - * Text. - */ - private final String mState; - - /** - * Constructor. - * @param state State - */ - private WalkState(final String state) { - mState = state; - } - - /** - * Get Walk State. - * @return Walk state - */ - public String getState() { - return mState; - } - } - - /** - * プロファイル名: {@value} . - */ - String PROFILE_NAME = "walkState"; - /** - * 属性: {@value} . - */ - String ATTRIBUTE_ON_WALK_STATE = "onWalkState"; - - /** - * パラメータ: {@value} . - */ - String PARAM_WALK = "walk"; - /** - * パラメータ: {@value} . - */ - String PARAM_STEP = "step"; - /** - * パラメータ: {@value} . - */ - String PARAM_STATE = "state"; - /** - * パラメータ: {@value} . - */ - String PARAM_SPEED = "speed"; - /** - * パラメータ: {@value} . - */ - String PARAM_DISTANCE = "distance"; - /** - * パラメータ: {@value} . - */ - String PARAM_BALANCE = "balance"; - - /** - * パラメータ: {@value} . - */ - String PARAM_TIMESTAMP = "timeStamp"; - /** - * パラメータ: {@value} . - */ - String PARAM_TIMESTAMP_STRING = "timeStampString"; - -} diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/bg_orientation_graph.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/bg_orientation_graph.png deleted file mode 100755 index 9c016e5601..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/bg_orientation_graph.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/bg_stress.xml b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/bg_stress.xml deleted file mode 100755 index e3a5f97d6e..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/bg_stress.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/button_blue.xml b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/button_blue.xml deleted file mode 100644 index c3a1c8095e..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/button_blue.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/button_red.xml b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/button_red.xml deleted file mode 100644 index 38d7427112..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/button_red.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/hitoe_explain.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/hitoe_explain.png deleted file mode 100644 index 8160c9b5a7..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/hitoe_explain.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/hitoe_input_pin.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/hitoe_input_pin.png deleted file mode 100644 index a3590a1fa2..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/hitoe_input_pin.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/hitoe_set.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/hitoe_set.png deleted file mode 100644 index bd3e6f4ee0..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/hitoe_set.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery01.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery01.png deleted file mode 100644 index 92972d67bf..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery01.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery02.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery02.png deleted file mode 100644 index 74ebafa15a..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery02.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery03.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery03.png deleted file mode 100644 index 6128562dc8..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery03.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery04.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery04.png deleted file mode 100644 index 9402a050b2..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery04.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery05.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery05.png deleted file mode 100644 index 92f2b45360..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_battery05.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_heartrate.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_heartrate.png deleted file mode 100644 index bc243b741a..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/mark_heartrate.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_backward.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_backward.png deleted file mode 100644 index 1e8817dd76..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_backward.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_default.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_default.png deleted file mode 100644 index b190b01c30..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_default.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_facedown.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_facedown.png deleted file mode 100644 index 55fb324762..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_facedown.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_faceleft.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_faceleft.png deleted file mode 100644 index c5212ce577..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_faceleft.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_faceright.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_faceright.png deleted file mode 100644 index a2b67ede8f..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_faceright.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_faceup.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_faceup.png deleted file mode 100644 index 849df21833..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_faceup.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_forward.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_forward.png deleted file mode 100644 index d6f7cf098b..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_forward.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_leftside.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_leftside.png deleted file mode 100644 index e222bd8223..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_leftside.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_rightside.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_rightside.png deleted file mode 100644 index 652508511b..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_rightside.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_running.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_running.png deleted file mode 100644 index 453a036604..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_running.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_standing.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_standing.png deleted file mode 100644 index e4e1527b9f..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_standing.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_walking.png b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_walking.png deleted file mode 100644 index 41df959888..0000000000 Binary files a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/drawable/pose_walking.png and /dev/null differ diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/layout/activity_control_main.xml b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/layout/activity_control_main.xml deleted file mode 100644 index 803a768212..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/layout/activity_control_main.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - \ No newline at end of file diff --git a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/layout/activity_hitoe_device_list.xml b/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/layout/activity_hitoe_device_list.xml deleted file mode 100644 index 89f605d11d..0000000000 --- a/dConnectDevicePlugin/dConnectDeviceHitoe/app/src/main/res/layout/activity_hitoe_device_list.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - -