Fixed app crashing when saving rules while service is running.

This commit is contained in:
Jens 2021-03-21 22:27:34 +01:00
parent d4288dfc40
commit b7ebf2cdcd
2 changed files with 27 additions and 19 deletions

View File

@ -11,8 +11,8 @@ android {
compileSdkVersion 29 compileSdkVersion 29
buildToolsVersion '29.0.2' buildToolsVersion '29.0.2'
useLibrary 'org.apache.http.legacy' useLibrary 'org.apache.http.legacy'
versionCode 100 versionCode 101
versionName "1.6.24" versionName "1.6.25"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

View File

@ -273,7 +273,10 @@ public class ReceiverCoordinator
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.activityDetection)) if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.activityDetection))
{ {
boolean isRunning = (Boolean)Miscellaneous.runMethodReflective("ActivityDetectionReceiver", "isActivityDetectionReceiverRunning", null); Object runResult = Miscellaneous.runMethodReflective("ActivityDetectionReceiver", "isActivityDetectionReceiverRunning", null);;
if(runResult instanceof Boolean)
{
boolean isRunning = (Boolean) runResult;
if (isRunning) if (isRunning)
{ {
Miscellaneous.logEvent("i", "LocationProvider", "Restarting ActivityDetectionReceiver because used in a new/changed rule.", 4); Miscellaneous.logEvent("i", "LocationProvider", "Restarting ActivityDetectionReceiver because used in a new/changed rule.", 4);
@ -291,9 +294,13 @@ public class ReceiverCoordinator
// ActivityDetectionReceiver.startActivityDetectionReceiver(); // ActivityDetectionReceiver.startActivityDetectionReceiver();
} }
} }
}
else else
{ {
boolean isRunning = (Boolean)Miscellaneous.runMethodReflective("ActivityDetectionReceiver", "isActivityDetectionReceiverRunning", null); Object runResult = Miscellaneous.runMethodReflective(activityDetectionClassPath, "isActivityDetectionReceiverRunning", null);
if(runResult instanceof Boolean)
{
boolean isRunning = (Boolean) runResult;
if (isRunning) if (isRunning)
{ {
Miscellaneous.logEvent("i", "LocationProvider", "Shutting down ActivityDetectionReceiver because not used in any rule.", 4); Miscellaneous.logEvent("i", "LocationProvider", "Shutting down ActivityDetectionReceiver because not used in any rule.", 4);
@ -301,6 +308,7 @@ public class ReceiverCoordinator
// ActivityDetectionReceiver.stopActivityDetectionReceiver(); // ActivityDetectionReceiver.stopActivityDetectionReceiver();
} }
} }
}
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.bluetoothConnection)) if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.bluetoothConnection))
{ {