diff --git a/app/build.gradle b/app/build.gradle
index a1bb434984..dac7419d0e 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -261,6 +261,9 @@ dependencies {
exclude group: 'androidx.core', module: 'core' // fix INotificationSideChannel // android.support.v4.app
}
+ api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1"
+ implementation(name: 'ns-sdk-full-release', ext: 'aar')
+
//implementation 'androidx.core:core-ktx:1.9.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.7.21'
@@ -344,7 +347,9 @@ dependencies {
testImplementation "org.robolectric:robolectric:4.4.1"
testImplementation "com.google.truth:truth:1.1.3"
- testImplementation 'org.mockito:mockito-core:2.4.0'
+ testImplementation 'org.mockito:mockito-inline:2.13.0'
+ testImplementation 'org.mockito:mockito-core:4.11.0'
+
testImplementation 'org.powermock:powermock-core:1.7.1'
testImplementation 'org.powermock:powermock-module-junit4:1.7.1'
testImplementation 'org.powermock:powermock-module-junit4-rule:1.7.1'
diff --git a/app/libs/ns-sdk-full-release.aar b/app/libs/ns-sdk-full-release.aar
new file mode 100644
index 0000000000..b1eb2082fd
Binary files /dev/null and b/app/libs/ns-sdk-full-release.aar differ
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9a9ef12cf8..df95d0f403 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -5,7 +5,7 @@
android:installLocation="internalOnly"
tools:ignore="InnerclassSeparator">
-
+
@@ -498,6 +498,9 @@
+
+
+
diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/NSClientReceiver.java b/app/src/main/java/com/eveningoutpost/dexdrip/NSClientReceiver.java
index c6761e6e09..bc80e6c398 100644
--- a/app/src/main/java/com/eveningoutpost/dexdrip/NSClientReceiver.java
+++ b/app/src/main/java/com/eveningoutpost/dexdrip/NSClientReceiver.java
@@ -1,5 +1,6 @@
package com.eveningoutpost.dexdrip;
+import static com.eveningoutpost.dexdrip.Models.JoH.emptyString;
import static com.eveningoutpost.dexdrip.xdrip.gs;
import android.content.BroadcastReceiver;
@@ -18,6 +19,7 @@
import com.eveningoutpost.dexdrip.UtilityModels.Intents;
import com.eveningoutpost.dexdrip.UtilityModels.Pref;
import com.eveningoutpost.dexdrip.profileeditor.ImportAapsProfile;
+import com.google.gson.GsonBuilder;
import org.json.JSONArray;
import org.json.JSONException;
@@ -26,6 +28,7 @@
import java.util.HashMap;
import java.util.UUID;
+import info.nightscout.sdk.localmodel.devicestatus.NSDeviceStatus;
import lombok.val;
@@ -57,6 +60,27 @@ public void onReceive(Context context, Intent intent) {
if (action == null) return;
switch (action) {
+ case Intents.ACTION_NS_BRIDGE:
+ if (bundle == null) break;
+ if (prefs.getBoolean("accept_nsclient_treatments", true)) {
+
+ final String device_status_json = bundle.getString("devicestatus", "");
+ if (!emptyString(device_status_json)) {
+ try {
+ val gson = new GsonBuilder().create(); // TODO optimize
+ val ds = gson.fromJson(device_status_json, NSDeviceStatus.class);
+ Log.e(TAG, "DEBUG: got device status: " + ds.toString());
+ } catch (Exception e) {
+ Log.e(TAG, "Exception processing device status in NS_BRIDGE action: " + e);
+ }
+ } else {
+ Log.e(TAG, "Empty device status received via NS_BRIDGE action");
+ }
+ } else {
+ Log.e(TAG, "Cannot accept device status as preference setting prevents it");
+ }
+ break;
+
case Intents.ACTION_NEW_SGV:
if (Home.get_follower() && prefs.getBoolean("accept_nsclient_sgv", true)) {
if (bundle == null) break;
diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/UtilityModels/Intents.java b/app/src/main/java/com/eveningoutpost/dexdrip/UtilityModels/Intents.java
index 4189f52ba5..9c5ff3b490 100644
--- a/app/src/main/java/com/eveningoutpost/dexdrip/UtilityModels/Intents.java
+++ b/app/src/main/java/com/eveningoutpost/dexdrip/UtilityModels/Intents.java
@@ -41,6 +41,7 @@ public interface Intents {
String ACTION_REMOVED_TREATMENT = "info.nightscout.client.REMOVED_TREATMENT";
String ACTION_NEW_PROFILE = "info.nightscout.client.NEW_PROFILE";
String ACTION_NEW_SGV = "info.nightscout.client.NEW_SGV";
+ String ACTION_NS_BRIDGE = "info.nightscout.client.NS_BRIDGE";