capacitor-plugin-ihealth 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +12 -10
- package/android/src/main/AndroidManifest.xml +11 -1
- package/android/src/main/java/com/managemyhealth/plugins/ihealth/ihealthPlugin.java +102 -25
- package/package.json +1 -1
- package/android/src/assets/libiHealth.so +0 -0
- package/android/src/assets/libs/arm64-v8a/libBodyfat_SDK.so +0 -0
- package/android/src/assets/libs/arm64-v8a/libECGOffline.so +0 -0
- package/android/src/assets/libs/arm64-v8a/libECGOnline.so +0 -0
- package/android/src/assets/libs/arm64-v8a/libVeryFitMulti.so +0 -0
- package/android/src/assets/libs/arm64-v8a/libiHealth.so +0 -0
- package/android/src/main/assets/libiHealth.so +0 -0
- package/android/src/main/assets/libs/arm64-v8a/libBodyfat_SDK.so +0 -0
- package/android/src/main/assets/libs/arm64-v8a/libECGOffline.so +0 -0
- package/android/src/main/assets/libs/arm64-v8a/libECGOnline.so +0 -0
- package/android/src/main/assets/libs/arm64-v8a/libVeryFitMulti.so +0 -0
- package/android/src/main/assets/libs/arm64-v8a/libiHealth.so +0 -0
- package/android/src/main/libiHealth.so +0 -0
package/android/build.gradle
CHANGED
@@ -39,13 +39,11 @@ android {
|
|
39
39
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
40
40
|
}
|
41
41
|
}
|
42
|
-
sourceSets {
|
43
|
-
main {
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
48
|
-
}
|
42
|
+
// sourceSets {
|
43
|
+
// main {
|
44
|
+
// jniLibs.srcDirs = ['libs']
|
45
|
+
// }
|
46
|
+
// }
|
49
47
|
lintOptions {
|
50
48
|
abortOnError false
|
51
49
|
}
|
@@ -71,11 +69,15 @@ dependencies {
|
|
71
69
|
implementation files('src/iHealthSDK_2.9.10.jar')
|
72
70
|
//
|
73
71
|
implementation 'com.alibaba:fastjson:1.2.48'
|
74
|
-
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
|
75
|
-
implementation 'com.squareup.okio:okio:3.2.0'
|
72
|
+
// implementation 'com.squareup.okhttp3:okhttp:4.11.0'
|
73
|
+
// implementation 'com.squareup.okio:okio:3.2.0'
|
76
74
|
implementation 'com.google.code.gson:gson:2.8.9'
|
77
75
|
implementation 'org.greenrobot:greendao:3.2.2'
|
78
|
-
implementation 'no.nordicsemi.android:dfu:1.
|
76
|
+
// implementation 'no.nordicsemi.android:dfu:1.6.0'
|
79
77
|
implementation 'com.android.support:multidex:1.0.3'
|
78
|
+
//old version
|
79
|
+
implementation 'no.nordicsemi.android:dfu:1.9.2'
|
80
|
+
implementation 'com.squareup.okhttp3:okhttp:4.8.0'
|
81
|
+
implementation 'com.squareup.okio:okio:2.7.0'
|
80
82
|
|
81
83
|
}
|
@@ -1,5 +1,15 @@
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
2
|
+
|
3
|
+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
4
|
+
<uses-permission android:name="android.permission.BLUETOOTH" />
|
5
|
+
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
6
|
+
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
2
7
|
<application
|
3
8
|
android:name="com.managemyhealth.plugins.ihealth.BaseApplication"
|
4
|
-
|
9
|
+
>
|
10
|
+
<service
|
11
|
+
android:name="com.ido.ble.bluetooth.DeviceConnectService" android:exported="false" />
|
12
|
+
<service
|
13
|
+
android:name="com.ido.ble.dfu.DFUService" android:enabled="true" android:exported="false" />
|
14
|
+
</application>
|
5
15
|
</manifest>
|
@@ -1,7 +1,10 @@
|
|
1
1
|
package com.managemyhealth.plugins.ihealth;
|
2
2
|
|
3
|
+
import android.Manifest;
|
3
4
|
import android.annotation.SuppressLint;
|
4
5
|
import android.bluetooth.BluetoothAdapter;
|
6
|
+
import android.content.pm.PackageManager;
|
7
|
+
import android.os.Build;
|
5
8
|
import android.os.Bundle;
|
6
9
|
import android.os.Handler;
|
7
10
|
import android.os.Looper;
|
@@ -9,6 +12,9 @@ import android.os.Message;
|
|
9
12
|
import android.util.Log;
|
10
13
|
|
11
14
|
import androidx.annotation.NonNull;
|
15
|
+
import androidx.annotation.RequiresApi;
|
16
|
+
import androidx.core.app.ActivityCompat;
|
17
|
+
import androidx.core.content.ContextCompat;
|
12
18
|
|
13
19
|
import com.getcapacitor.JSObject;
|
14
20
|
import com.getcapacitor.Plugin;
|
@@ -45,6 +51,7 @@ import org.json.JSONTokener;
|
|
45
51
|
|
46
52
|
import java.util.Calendar;
|
47
53
|
|
54
|
+
import java.util.List;
|
48
55
|
import java.util.Map;
|
49
56
|
|
50
57
|
|
@@ -109,10 +116,61 @@ public class ihealthPlugin extends Plugin {
|
|
109
116
|
|
110
117
|
ihealthPlugin context = this;
|
111
118
|
|
119
|
+
@RequiresApi(api = Build.VERSION_CODES.S)
|
120
|
+
private void checkMultiplePermissions() {
|
121
|
+
String[] permissions = {
|
122
|
+
Manifest.permission.BLUETOOTH_SCAN,
|
123
|
+
Manifest.permission.BLUETOOTH,
|
124
|
+
Manifest.permission.BLUETOOTH_ADMIN,
|
125
|
+
Manifest.permission.BLUETOOTH_CONNECT,
|
126
|
+
Manifest.permission.BLUETOOTH_ADVERTISE,
|
127
|
+
|
128
|
+
// Add more permissions as needed
|
129
|
+
};
|
130
|
+
|
131
|
+
List<String> permissionsToRequest = new ArrayList<>();
|
132
|
+
|
133
|
+
|
134
|
+
// Check each permission
|
135
|
+
for (String permission : permissions) {
|
136
|
+
permissionsToRequest.add(permission);
|
137
|
+
}
|
138
|
+
for (String permission : permissions) {
|
139
|
+
if (ContextCompat.checkSelfPermission(this.getActivity(), permission) != PackageManager.PERMISSION_GRANTED) {
|
140
|
+
// Permission not granted
|
141
|
+
permissionsToRequest.add(permission);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
// If there are permissions to request, request them
|
146
|
+
if (!permissionsToRequest.isEmpty()) {
|
147
|
+
showLog("asking permissions---------------");
|
148
|
+
ActivityCompat.requestPermissions(this.getActivity(), permissionsToRequest.toArray(new String[0]), 111);
|
149
|
+
} else {
|
150
|
+
// All permissions are already granted
|
151
|
+
// Do your work here
|
152
|
+
}
|
153
|
+
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
154
|
+
if (bluetoothAdapter == null || !bluetoothAdapter.isEnabled()) {
|
155
|
+
}
|
156
|
+
if (bluetoothAdapter.isEnabled()) {
|
157
|
+
}else{
|
158
|
+
try{
|
159
|
+
bluetoothAdapter.enable();
|
160
|
+
}catch(Exception e){
|
161
|
+
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
}
|
167
|
+
|
112
168
|
@PluginMethod
|
113
169
|
public void authoriseiHealthSdk(PluginCall call) {
|
114
170
|
|
115
|
-
|
171
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
172
|
+
checkMultiplePermissions();
|
173
|
+
}
|
116
174
|
|
117
175
|
showLog("authorizeSDK() CALLED");
|
118
176
|
try {
|
@@ -259,7 +317,15 @@ public class ihealthPlugin extends Plugin {
|
|
259
317
|
mScanClientCallbackId = iHealthDevicesManager.getInstance().registerClientCallback(miHealthDevicesCallback);
|
260
318
|
DiscoveryTypeEnum discoveryTypeEnum = getDiscoveryTypeEnum(deviceModel);
|
261
319
|
if (discoveryTypeEnum!= null) {
|
262
|
-
|
320
|
+
try {
|
321
|
+
showLog("inside selectPT3SBTAndScan");
|
322
|
+
iHealthDevicesManager.getInstance().startDiscovery(discoveryTypeEnum);
|
323
|
+
showLog("after inside selectPT3SBTAndScan");
|
324
|
+
|
325
|
+
}catch (Exception e ){
|
326
|
+
showLog("wriiefegef");
|
327
|
+
showLog(e.toString());
|
328
|
+
}
|
263
329
|
}
|
264
330
|
}
|
265
331
|
public void selectHS4SAndScan(){
|
@@ -332,24 +398,29 @@ public class ihealthPlugin extends Plugin {
|
|
332
398
|
deviceDiscover=true;
|
333
399
|
}
|
334
400
|
isDevicePairingReq=true;
|
335
|
-
|
336
|
-
|
337
|
-
|
401
|
+
try{
|
402
|
+
boolean request = iHealthDevicesManager.getInstance().connectDevice("", mac, deviceType);
|
403
|
+
showLog(String.valueOf(request));
|
404
|
+
mConnectDeviceClientCallbackId = iHealthDevicesManager.getInstance().registerClientCallback(miHealthDevicesCallback);
|
338
405
|
|
339
406
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
407
|
+
if (request) {
|
408
|
+
eventData.put("deviceConnect", "success");
|
409
|
+
if (!deviceConnect) {
|
410
|
+
notifyListeners("deviceConnect", eventData);
|
411
|
+
deviceConnect = true;
|
412
|
+
}
|
413
|
+
iHealthDevicesManager.getInstance().stopDiscovery();
|
414
|
+
} else {
|
415
|
+
eventData.put("deviceConnectFail", "failed");
|
416
|
+
if (!deviceConnectFail) {
|
417
|
+
notifyListeners("deviceConnectFail", eventData);
|
418
|
+
deviceConnectFail = true;
|
419
|
+
}
|
352
420
|
}
|
421
|
+
}catch (Exception e){
|
422
|
+
showLog("Ecccc----------");
|
423
|
+
showLog(e.toString());
|
353
424
|
}
|
354
425
|
}
|
355
426
|
else {
|
@@ -408,7 +479,16 @@ public class ihealthPlugin extends Plugin {
|
|
408
479
|
iHealthDevicesManager.getInstance().addCallbackFilterForDeviceType(mClientCallbackId, deviceType);
|
409
480
|
|
410
481
|
mPt3sbtControl = iHealthDevicesManager.getInstance().getPt3sbtDevice(deviceMac);
|
411
|
-
|
482
|
+
// long delayMillis = 2000; // 2 seconds
|
483
|
+
// Handler handler2 = new Handler();
|
484
|
+
// handler2.postDelayed(new Runnable() {
|
485
|
+
// @Override
|
486
|
+
// public void run() {
|
487
|
+
|
488
|
+
|
489
|
+
// }
|
490
|
+
// }, delayMillis);
|
491
|
+
// mPt3sbtControl.setTime();
|
412
492
|
mPt3sbtControl.getHistoryData();
|
413
493
|
showLog(" mPt3sbtControl.getHistoryData();");
|
414
494
|
break;
|
@@ -871,19 +951,16 @@ public class ihealthPlugin extends Plugin {
|
|
871
951
|
showLog("message: " + message);
|
872
952
|
break;
|
873
953
|
case Pt3sbtProfile.ACTION_GET_HISTORY_DATA:
|
954
|
+
|
874
955
|
try {
|
875
956
|
JSONObject object = new JSONObject(message);
|
876
957
|
JSObject result = new JSObject();
|
877
958
|
result.put("deviceDataArr", object);
|
878
959
|
result.put("deviceModel", "PT3SBT");
|
879
|
-
//result.put("time", formattedDate);
|
880
960
|
if(!offlineDataFound){
|
881
961
|
notifyListeners("deviceDatafound", result);
|
882
962
|
offlineDataFound= true;
|
883
|
-
|
884
|
-
|
885
|
-
// mPt3sbtControl.
|
886
|
-
|
963
|
+
mPt3sbtControl.deleteHistory();
|
887
964
|
}
|
888
965
|
} catch (JSONException e) {
|
889
966
|
JSObject pt3sbterror1 = new JSObject();
|
@@ -1642,7 +1719,7 @@ public class ihealthPlugin extends Plugin {
|
|
1642
1719
|
if(!offlineDataFound){
|
1643
1720
|
notifyListeners("deviceDatafound", result);
|
1644
1721
|
offlineDataFound =true;
|
1645
|
-
mHs4SControl.measureOnline(
|
1722
|
+
mHs4SControl.measureOnline(01,0);
|
1646
1723
|
|
1647
1724
|
}
|
1648
1725
|
} catch (JSONException e) {
|
@@ -1723,7 +1800,7 @@ public class ihealthPlugin extends Plugin {
|
|
1723
1800
|
}
|
1724
1801
|
break;
|
1725
1802
|
case HsProfile.ACTION_NO_HISTORICALDATA:
|
1726
|
-
mHs4SControl.measureOnline(
|
1803
|
+
mHs4SControl.measureOnline(01,0);
|
1727
1804
|
|
1728
1805
|
JSObject wsNoDataResult = new JSObject();
|
1729
1806
|
wsNoDataResult.put("message", "Data not found");
|
package/package.json
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|