Fix Boolean thingy

This commit is contained in:
Markus M. May 2018-05-01 22:15:22 +02:00
parent 02e9ce105c
commit 306d45bb3e
2 changed files with 18 additions and 4 deletions

View file

@ -121,10 +121,16 @@ class NsClientReceiverDelegate {
boolean newAllowedState = true;
if (!ev.wifiConnected && wifiOnly) newAllowedState = false;
if (ev.wifiConnected && !allowedSSIDs.trim().isEmpty() && !allowedSSIDs.contains(ev.ssid))
if (ev.wifiConnected) {
if (!allowedSSIDs.trim().isEmpty() && !allowedSSIDs.contains(ev.ssid)) {
newAllowedState = false;
if (!ev.wifiConnected && !allowRoaming && ev.roaming) newAllowedState = false;
}
} else {
if ((!allowRoaming && ev.roaming) || wifiOnly) {
newAllowedState = false;
}
}
return newAllowedState;
}

View file

@ -111,5 +111,13 @@ public class NsClientReceiverDelegateTest {
ev.wifiConnected = true;
ev.roaming = true;
assertTrue(sut.calculateStatus(ev));
// wifiOnly = false
// allowRoaming = false
when(SP.getBoolean(R.string.key_ns_wifionly, false)).thenReturn(false);
when(SP.getBoolean(R.string.key_ns_allowroaming, true)).thenReturn(false);
ev.wifiConnected = true;
ev.roaming = true;
assertTrue(sut.calculateStatus(ev));
}
}