capacitor-plugin-ihealth 1.1.5 → 1.1.6
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
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,57 @@ 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
|
+
bluetoothAdapter.enable();
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
}
|
163
|
+
|
112
164
|
@PluginMethod
|
113
165
|
public void authoriseiHealthSdk(PluginCall call) {
|
114
166
|
|
115
|
-
|
167
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
168
|
+
checkMultiplePermissions();
|
169
|
+
}
|
116
170
|
|
117
171
|
showLog("authorizeSDK() CALLED");
|
118
172
|
try {
|
@@ -259,7 +313,15 @@ public class ihealthPlugin extends Plugin {
|
|
259
313
|
mScanClientCallbackId = iHealthDevicesManager.getInstance().registerClientCallback(miHealthDevicesCallback);
|
260
314
|
DiscoveryTypeEnum discoveryTypeEnum = getDiscoveryTypeEnum(deviceModel);
|
261
315
|
if (discoveryTypeEnum!= null) {
|
262
|
-
|
316
|
+
try {
|
317
|
+
showLog("inside selectPT3SBTAndScan");
|
318
|
+
iHealthDevicesManager.getInstance().startDiscovery(discoveryTypeEnum);
|
319
|
+
showLog("after inside selectPT3SBTAndScan");
|
320
|
+
|
321
|
+
}catch (Exception e ){
|
322
|
+
showLog("wriiefegef");
|
323
|
+
showLog(e.toString());
|
324
|
+
}
|
263
325
|
}
|
264
326
|
}
|
265
327
|
public void selectHS4SAndScan(){
|
@@ -332,24 +394,29 @@ public class ihealthPlugin extends Plugin {
|
|
332
394
|
deviceDiscover=true;
|
333
395
|
}
|
334
396
|
isDevicePairingReq=true;
|
335
|
-
|
336
|
-
|
337
|
-
|
397
|
+
try{
|
398
|
+
boolean request = iHealthDevicesManager.getInstance().connectDevice("", mac, deviceType);
|
399
|
+
showLog(String.valueOf(request));
|
400
|
+
mConnectDeviceClientCallbackId = iHealthDevicesManager.getInstance().registerClientCallback(miHealthDevicesCallback);
|
338
401
|
|
339
402
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
403
|
+
if (request) {
|
404
|
+
eventData.put("deviceConnect", "success");
|
405
|
+
if (!deviceConnect) {
|
406
|
+
notifyListeners("deviceConnect", eventData);
|
407
|
+
deviceConnect = true;
|
408
|
+
}
|
409
|
+
iHealthDevicesManager.getInstance().stopDiscovery();
|
410
|
+
} else {
|
411
|
+
eventData.put("deviceConnectFail", "failed");
|
412
|
+
if (!deviceConnectFail) {
|
413
|
+
notifyListeners("deviceConnectFail", eventData);
|
414
|
+
deviceConnectFail = true;
|
415
|
+
}
|
352
416
|
}
|
417
|
+
}catch (Exception e){
|
418
|
+
showLog("Ecccc----------");
|
419
|
+
showLog(e.toString());
|
353
420
|
}
|
354
421
|
}
|
355
422
|
else {
|
@@ -408,7 +475,16 @@ public class ihealthPlugin extends Plugin {
|
|
408
475
|
iHealthDevicesManager.getInstance().addCallbackFilterForDeviceType(mClientCallbackId, deviceType);
|
409
476
|
|
410
477
|
mPt3sbtControl = iHealthDevicesManager.getInstance().getPt3sbtDevice(deviceMac);
|
411
|
-
|
478
|
+
// long delayMillis = 2000; // 2 seconds
|
479
|
+
// Handler handler2 = new Handler();
|
480
|
+
// handler2.postDelayed(new Runnable() {
|
481
|
+
// @Override
|
482
|
+
// public void run() {
|
483
|
+
|
484
|
+
|
485
|
+
// }
|
486
|
+
// }, delayMillis);
|
487
|
+
// mPt3sbtControl.setTime();
|
412
488
|
mPt3sbtControl.getHistoryData();
|
413
489
|
showLog(" mPt3sbtControl.getHistoryData();");
|
414
490
|
break;
|
@@ -871,19 +947,16 @@ public class ihealthPlugin extends Plugin {
|
|
871
947
|
showLog("message: " + message);
|
872
948
|
break;
|
873
949
|
case Pt3sbtProfile.ACTION_GET_HISTORY_DATA:
|
950
|
+
|
874
951
|
try {
|
875
952
|
JSONObject object = new JSONObject(message);
|
876
953
|
JSObject result = new JSObject();
|
877
954
|
result.put("deviceDataArr", object);
|
878
955
|
result.put("deviceModel", "PT3SBT");
|
879
|
-
//result.put("time", formattedDate);
|
880
956
|
if(!offlineDataFound){
|
881
957
|
notifyListeners("deviceDatafound", result);
|
882
958
|
offlineDataFound= true;
|
883
|
-
|
884
|
-
|
885
|
-
// mPt3sbtControl.
|
886
|
-
|
959
|
+
mPt3sbtControl.deleteHistory();
|
887
960
|
}
|
888
961
|
} catch (JSONException e) {
|
889
962
|
JSObject pt3sbterror1 = new JSObject();
|