fix grabbing SSID info
This commit is contained in:
parent
3a2790acc3
commit
6e88d127e5
7 changed files with 16 additions and 11 deletions
|
@ -138,8 +138,8 @@ class MainActivity : NoSplashAppCompatActivity() {
|
|||
}
|
||||
androidPermission.notifyForStoragePermission(this)
|
||||
androidPermission.notifyForBatteryOptimizationPermission(this)
|
||||
if (config.PUMPDRIVERS) {
|
||||
androidPermission.notifyForLocationPermissions(this)
|
||||
if (config.PUMPDRIVERS) {
|
||||
androidPermission.notifyForSMSPermissions(this, smsCommunicatorPlugin)
|
||||
androidPermission.notifyForSystemWindowPermissions(this)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -949,7 +949,7 @@
|
|||
<string name="permission">Permission</string>
|
||||
<string name="askforpermission">Ask for permission</string>
|
||||
<string name="needsystemwindowpermission">Application needs system window permission for notifications</string>
|
||||
<string name="needlocationpermission">Application needs location permission for BT scan</string>
|
||||
<string name="needlocationpermission">Application needs location permission for BT scan and WiFi identification</string>
|
||||
<string name="needstoragepermission">Application needs storage permission to be able store log files</string>
|
||||
<string name="request">Request</string>
|
||||
<string name="insulinsourcesetup">Configure Insulin plugin</string>
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="info.nightscout.androidaps.core">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
|
||||
<application>
|
||||
|
|
|
@ -11,8 +11,4 @@ class EventNetworkChange : Event() {
|
|||
var ssid = ""
|
||||
var roaming = false
|
||||
var metered = false
|
||||
|
||||
fun connectedSsid(): String {
|
||||
return StringUtils.removeSurroundingQuotes(ssid)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()}")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue