Wifi trigger fix attempt
This commit is contained in:
parent
6b23bd6733
commit
8c0cee9589
@ -705,7 +705,6 @@ public class ActivityPermissions extends Activity
|
||||
break;
|
||||
case startPhoneCall:
|
||||
addToArrayListUnique(Manifest.permission.CALL_PHONE, requiredPermissions);
|
||||
// addToArrayListUnique(Manifest.permission.SYSTEM_ALERT_WINDOW, requiredPermissions);
|
||||
addToArrayListUnique(Manifest.permission.SYSTEM_ALERT_WINDOW, requiredPermissions);
|
||||
break;
|
||||
case stopPhoneCall:
|
||||
|
@ -803,13 +803,26 @@ public class Trigger
|
||||
{
|
||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("Wifi name specified, checking that.", this.getParentRule().getName()), 4);
|
||||
|
||||
if(!WifiBroadcastReceiver.getLastWifiSsid().equals(this.getTriggerParameter2()) && !(Miscellaneous.isRegularExpression(this.getTriggerParameter2()) && WifiBroadcastReceiver.getLastWifiSsid().matches(this.getTriggerParameter2())))
|
||||
if(WifiBroadcastReceiver.lastConnectedState) //when connected
|
||||
{
|
||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyNotTheCorrectSsid), getParentRule().getName(), this.getTriggerParameter2(), WifiBroadcastReceiver.getLastWifiSsid()),this.getParentRule().getName()), 3);
|
||||
return false;
|
||||
if (!WifiBroadcastReceiver.getLastWifiSsid().equals(this.getTriggerParameter2()) && !(Miscellaneous.isRegularExpression(this.getTriggerParameter2()) && WifiBroadcastReceiver.getLastWifiSsid().matches(this.getTriggerParameter2())))
|
||||
{
|
||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyNotTheCorrectSsid), getParentRule().getName(), this.getTriggerParameter2(), WifiBroadcastReceiver.getLastWifiSsid()), this.getParentRule().getName()), 3);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("Wifi name matches. Rule will apply.", this.getParentRule().getName()), 4);
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("Wifi name matches. Rule will apply.", this.getParentRule().getName()), 4);
|
||||
{
|
||||
if (!WifiBroadcastReceiver.getLastWifiSsidReal().equals(this.getTriggerParameter2()) && !(Miscellaneous.isRegularExpression(this.getTriggerParameter2()) && WifiBroadcastReceiver.getLastWifiSsidReal().matches(this.getTriggerParameter2())))
|
||||
{
|
||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyNotTheCorrectSsid), getParentRule().getName(), this.getTriggerParameter2(), WifiBroadcastReceiver.getLastWifiSsidReal()), this.getParentRule().getName()), 3);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("Wifi name matches. Rule will apply.", this.getParentRule().getName()), 4);
|
||||
}
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("No wifi name specified, any will do.", this.getParentRule().getName()), 4);
|
||||
|
@ -400,12 +400,12 @@ public class LocationProvider
|
||||
Miscellaneous.logEvent("i", "LocationProvider", this.getParentService().getResources().getString(R.string.applyingSettingsAndRules), 3);
|
||||
|
||||
// *********** SETTING CHANGES ***********
|
||||
if(Settings.useWifiForPositioning && !WifiBroadcastReceiver.isWifiListenerActive())
|
||||
if(Settings.useWifiForPositioning && !WifiBroadcastReceiver.isWifiListenerActive() || Rule.isAnyRuleUsing(Trigger_Enum.wifiConnection))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Starting WifiReceiver because settings now allow to.", 4);
|
||||
WifiBroadcastReceiver.startWifiReceiver(this);
|
||||
}
|
||||
else if(!Settings.useWifiForPositioning && WifiBroadcastReceiver.isWifiListenerActive())
|
||||
else if(!Settings.useWifiForPositioning && WifiBroadcastReceiver.isWifiListenerActive() && !Rule.isAnyRuleUsing(Trigger_Enum.wifiConnection))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Shutting down WifiReceiver because settings forbid to.", 4);
|
||||
WifiBroadcastReceiver.stopWifiReceiver();
|
||||
|
@ -25,12 +25,20 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
||||
public static LocationProvider parentLocationProvider;
|
||||
public static Boolean wasConnected = false;
|
||||
protected static String lastWifiSsid = "";
|
||||
protected static String lastWifiSsidReal = "";
|
||||
public static boolean lastConnectedState = false;
|
||||
protected static boolean mayCellLocationChangedReceiverBeActivatedFromWifiPointOfView = true;
|
||||
protected static WifiBroadcastReceiver wifiBrInstance;
|
||||
protected static IntentFilter wifiListenerIntentFilter;
|
||||
protected static boolean wifiListenerActive=false;
|
||||
|
||||
final static String unknownSsidName = "<unknown ssid>";
|
||||
|
||||
public static String getLastWifiSsidReal()
|
||||
{
|
||||
return lastWifiSsidReal;
|
||||
}
|
||||
|
||||
public static String getLastWifiSsid()
|
||||
{
|
||||
return lastWifiSsid;
|
||||
@ -42,7 +50,11 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
||||
newWifiSsid = newWifiSsid.substring(1, newWifiSsid.length()-1);
|
||||
|
||||
if(newWifiSsid.length() > 0)
|
||||
{
|
||||
if(newWifiSsid.equals(unknownSsidName))
|
||||
WifiBroadcastReceiver.lastWifiSsidReal = lastWifiSsid;
|
||||
WifiBroadcastReceiver.lastWifiSsid = newWifiSsid;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWifiListenerActive()
|
||||
|
Loading…
Reference in New Issue
Block a user