diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt
index 7881fea604..e54addbf71 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt
+++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt
@@ -138,8 +138,8 @@ class MainActivity : NoSplashAppCompatActivity() {
}
androidPermission.notifyForStoragePermission(this)
androidPermission.notifyForBatteryOptimizationPermission(this)
+ androidPermission.notifyForLocationPermissions(this)
if (config.PUMPDRIVERS) {
- androidPermission.notifyForLocationPermissions(this)
androidPermission.notifyForSMSPermissions(this, smsCommunicatorPlugin)
androidPermission.notifyForSystemWindowPermissions(this)
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt
index 49aeec14ed..71839a8fae 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt
@@ -47,7 +47,7 @@ class TriggerWifiSsid(injector: HasAndroidInjector) : Trigger(injector) {
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
return true
}
- if (eventNetworkChange.wifiConnected && comparator.value.check(eventNetworkChange.connectedSsid(), ssid.value)) {
+ if (eventNetworkChange.wifiConnected && comparator.value.check(eventNetworkChange.ssid, ssid.value)) {
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
return true
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NsClientReceiverDelegate.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NsClientReceiverDelegate.java
index 3bc2bde171..d54f48d511 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NsClientReceiverDelegate.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NsClientReceiverDelegate.java
@@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.general.nsclient;
+import java.util.Arrays;
+
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -48,6 +50,7 @@ class NsClientReceiverDelegate {
ev.isChanged(resourceHelper, R.string.key_ns_allowroaming)
) {
receiverStatusStore.updateNetworkStatus();
+ onStatusEvent(receiverStatusStore.getLastNetworkEvent());
} else if (ev.isChanged(resourceHelper, R.string.key_ns_chargingonly)) {
receiverStatusStore.broadcastChargingState();
}
@@ -92,14 +95,15 @@ class NsClientReceiverDelegate {
boolean calculateStatus(final EventNetworkChange ev) {
boolean wifiOnly = sp.getBoolean(R.string.key_ns_wifionly, false);
- String allowedSSIDs = sp.getString(R.string.key_ns_wifi_ssids, "");
+ String allowedSSIDstring = sp.getString(R.string.key_ns_wifi_ssids, "");
+ String[] allowedSSIDs = allowedSSIDstring.split(";");
+ if (allowedSSIDstring.isEmpty()) allowedSSIDs = new String[0];
boolean allowRoaming = sp.getBoolean(R.string.key_ns_allowroaming, true);
boolean newAllowedState = true;
if (ev.getWifiConnected()) {
- if (!allowedSSIDs.trim().isEmpty() &&
- (!allowedSSIDs.contains(ev.connectedSsid()) && !allowedSSIDs.contains(ev.getSsid()))) {
+ if (allowedSSIDs.length != 0 && !Arrays.asList(allowedSSIDs).contains(ev.getSsid())) {
newAllowedState = false;
}
} else {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0e411e05a7..8719ffd7d0 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -949,7 +949,7 @@
Permission
Ask for permission
Application needs system window permission for notifications
- Application needs location permission for BT scan
+ Application needs location permission for BT scan and WiFi identification
Application needs storage permission to be able store log files
Request
Configure Insulin plugin
diff --git a/core/src/main/AndroidManifest.xml b/core/src/main/AndroidManifest.xml
index 6d8a02d4c2..9ef7e793bf 100644
--- a/core/src/main/AndroidManifest.xml
+++ b/core/src/main/AndroidManifest.xml
@@ -1,6 +1,10 @@
+
+
+
+
diff --git a/core/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.kt b/core/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.kt
index 87599a9373..716b2b1810 100644
--- a/core/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.kt
+++ b/core/src/main/java/info/nightscout/androidaps/events/EventNetworkChange.kt
@@ -11,8 +11,4 @@ class EventNetworkChange : Event() {
var ssid = ""
var roaming = false
var metered = false
-
- fun connectedSsid(): String {
- return StringUtils.removeSurroundingQuotes(ssid)
- }
}
diff --git a/core/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.kt b/core/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.kt
index faeb4632cd..9233ee1b1b 100644
--- a/core/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.kt
+++ b/core/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.kt
@@ -12,6 +12,7 @@ import info.nightscout.androidaps.events.EventNetworkChange
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
+import info.nightscout.androidaps.utils.StringUtils
import javax.inject.Inject
class NetworkChangeReceiver : DaggerBroadcastReceiver() {
@@ -39,7 +40,7 @@ class NetworkChangeReceiver : DaggerBroadcastReceiver() {
val wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
val wifiInfo = wifiManager.connectionInfo
if (wifiInfo.supplicantState == SupplicantState.COMPLETED) {
- event.ssid = wifiInfo.ssid
+ event.ssid = StringUtils.removeSurroundingQuotes(wifiInfo.ssid)
// aapsLogger.debug(LTag.CORE, "NETCHANGE: Wifi connected. SSID: ${event.connectedSsid()}")
}
}