From 0bd64e4a535c102837671a8feb7b4ba9e093d3e0 Mon Sep 17 00:00:00 2001 From: Jens Date: Tue, 22 Feb 2022 23:08:25 +0100 Subject: [PATCH 1/3] operator change --- .../com/jens/automation2/location/LocationProvider.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/jens/automation2/location/LocationProvider.java b/app/src/main/java/com/jens/automation2/location/LocationProvider.java index 7740b9ae..020f79ff 100644 --- a/app/src/main/java/com/jens/automation2/location/LocationProvider.java +++ b/app/src/main/java/com/jens/automation2/location/LocationProvider.java @@ -189,7 +189,7 @@ public class LocationProvider /* Due to strange factors the time difference might be 0 resulting in mathematical error. */ - if (Double.isInfinite(currentSpeed) | Double.isNaN(currentSpeed)) + if (Double.isInfinite(currentSpeed) || Double.isNaN(currentSpeed)) Miscellaneous.logEvent("i", "Speed", "Error while calculating speed.", 4); else { @@ -240,7 +240,7 @@ public class LocationProvider if(Settings.positioningEngine == 0) { - if(Rule.isAnyRuleUsing(Trigger_Enum.pointOfInterest) | Rule.isAnyRuleUsing(Trigger_Enum.speed)) + if(Rule.isAnyRuleUsing(Trigger_Enum.pointOfInterest) || Rule.isAnyRuleUsing(Trigger_Enum.speed)) { // startCellLocationChangedReceiver if (CellLocationChangedReceiver.isCellLocationChangedReceiverPossible()) @@ -424,7 +424,7 @@ public class LocationProvider } // *********** RULE CHANGES *********** - if(!CellLocationChangedReceiver.isCellLocationListenerActive() && (Rule.isAnyRuleUsing(Trigger_Enum.pointOfInterest) | Rule.isAnyRuleUsing(Trigger_Enum.speed))) + if(!CellLocationChangedReceiver.isCellLocationListenerActive() && (Rule.isAnyRuleUsing(Trigger_Enum.pointOfInterest) || Rule.isAnyRuleUsing(Trigger_Enum.speed))) { Miscellaneous.logEvent("i", "LocationProvider", "Starting NoiseListener CellLocationChangedReceiver because used in a new/changed rule.", 4); if(CellLocationChangedReceiver.haveAllPermission()) From e7191141662cc574560da117140b5fe861449554 Mon Sep 17 00:00:00 2001 From: jens Date: Sun, 27 Feb 2022 18:01:54 +0100 Subject: [PATCH 2/3] parallel rule execution --- .../apkFlavor/java/com/jens/automation2/Rule.java | 13 ++++++++----- .../java/com/jens/automation2/Rule.java | 15 +++++++++------ .../java/com/jens/automation2/Rule.java | 13 ++++++++----- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/app/src/apkFlavor/java/com/jens/automation2/Rule.java b/app/src/apkFlavor/java/com/jens/automation2/Rule.java index daffe934..ec437b66 100644 --- a/app/src/apkFlavor/java/com/jens/automation2/Rule.java +++ b/app/src/apkFlavor/java/com/jens/automation2/Rule.java @@ -5,6 +5,7 @@ import static com.jens.automation2.Trigger.triggerParameter2Split; import android.annotation.SuppressLint; import android.content.Context; import android.os.AsyncTask; +import android.os.Build; import android.os.Looper; import android.util.Log; import android.widget.Toast; @@ -21,8 +22,7 @@ import java.util.List; public class Rule implements Comparable { private static ArrayList ruleCollection = new ArrayList(); - public static boolean isAnyRuleActive = false; - + private static List ruleRunHistory = new ArrayList(); public static List getRuleRunHistory() @@ -538,7 +538,10 @@ public class Rule implements Comparable public void activate(AutomationService automationService, boolean force) { ActivateRuleTask task = new ActivateRuleTask(); - task.execute(automationService, force); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) + task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, automationService, force); + else + task.execute(automationService, force); } public static ArrayList findRuleCandidates(Trigger.Trigger_Enum triggerType) @@ -547,13 +550,13 @@ public class Rule implements Comparable for(Rule oneRule : ruleCollection) { - innerloop: + innerLoop: for(Trigger oneTrigger : oneRule.getTriggerSet()) { if(oneTrigger.getTriggerType().equals(triggerType)) { ruleCandidates.add(oneRule); - break innerloop; // we don't need to check the other triggers in the same rule + break innerLoop; // we don't need to check the other triggers in the same rule } } } diff --git a/app/src/fdroidFlavor/java/com/jens/automation2/Rule.java b/app/src/fdroidFlavor/java/com/jens/automation2/Rule.java index 2642dad8..8074f94e 100644 --- a/app/src/fdroidFlavor/java/com/jens/automation2/Rule.java +++ b/app/src/fdroidFlavor/java/com/jens/automation2/Rule.java @@ -5,6 +5,7 @@ import static com.jens.automation2.Trigger.triggerParameter2Split; import android.annotation.SuppressLint; import android.content.Context; import android.os.AsyncTask; +import android.os.Build; import android.os.Looper; import android.util.Log; import android.widget.Toast; @@ -18,8 +19,7 @@ import java.util.List; public class Rule implements Comparable { private static ArrayList ruleCollection = new ArrayList(); - public static boolean isAnyRuleActive = false; - + private static List ruleRunHistory = new ArrayList(); public static List getRuleRunHistory() @@ -409,7 +409,7 @@ public class Rule implements Comparable Thread.setDefaultUncaughtExceptionHandler(Miscellaneous.uncaughtExceptionHandler); - // without this line debugger will - for some reason - skip all breakpoints in this class + // without this line the debugger will - for some reason - skip all breakpoints in this class if(android.os.Debug.isDebuggerConnected()) android.os.Debug.waitForDebugger(); @@ -511,7 +511,10 @@ public class Rule implements Comparable public void activate(AutomationService automationService, boolean force) { ActivateRuleTask task = new ActivateRuleTask(); - task.execute(automationService, force); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) + task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, automationService, force); + else + task.execute(automationService, force); } public static ArrayList findRuleCandidates(Trigger.Trigger_Enum triggerType) @@ -520,13 +523,13 @@ public class Rule implements Comparable for(Rule oneRule : ruleCollection) { - innerloop: + innerLoop: for(Trigger oneTrigger : oneRule.getTriggerSet()) { if(oneTrigger.getTriggerType().equals(triggerType)) { ruleCandidates.add(oneRule); - break innerloop; // we don't need to check the other triggers in the same rule + break innerLoop; // we don't need to check the other triggers in the same rule } } } diff --git a/app/src/googlePlayFlavor/java/com/jens/automation2/Rule.java b/app/src/googlePlayFlavor/java/com/jens/automation2/Rule.java index 4810f013..63e15801 100644 --- a/app/src/googlePlayFlavor/java/com/jens/automation2/Rule.java +++ b/app/src/googlePlayFlavor/java/com/jens/automation2/Rule.java @@ -5,6 +5,7 @@ import static com.jens.automation2.Trigger.triggerParameter2Split; import android.annotation.SuppressLint; import android.content.Context; import android.os.AsyncTask; +import android.os.Build; import android.os.Looper; import android.util.Log; import android.widget.Toast; @@ -21,8 +22,7 @@ import java.util.List; public class Rule implements Comparable { private static ArrayList ruleCollection = new ArrayList(); - public static boolean isAnyRuleActive = false; - + private static List ruleRunHistory = new ArrayList(); public static List getRuleRunHistory() @@ -538,7 +538,10 @@ public class Rule implements Comparable public void activate(AutomationService automationService, boolean force) { ActivateRuleTask task = new ActivateRuleTask(); - task.execute(automationService, force); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) + task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, automationService, force); + else + task.execute(automationService, force); } public static ArrayList findRuleCandidates(Trigger.Trigger_Enum triggerType) @@ -547,13 +550,13 @@ public class Rule implements Comparable for(Rule oneRule : ruleCollection) { - innerloop: + innerLoop: for(Trigger oneTrigger : oneRule.getTriggerSet()) { if(oneTrigger.getTriggerType().equals(triggerType)) { ruleCandidates.add(oneRule); - break innerloop; // we don't need to check the other triggers in the same rule + break innerLoop; // we don't need to check the other triggers in the same rule } } } From 4c9e61618b7ee5cda09eef45441fcdfabf1f0a31 Mon Sep 17 00:00:00 2001 From: jens Date: Mon, 28 Feb 2022 13:46:18 +0100 Subject: [PATCH 3/3] profile delete bug fixed --- .../java/com/jens/automation2/Profile.java | 20 ++++--------------- .../metadata/android/en-US/changelogs/118.txt | 3 ++- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/jens/automation2/Profile.java b/app/src/main/java/com/jens/automation2/Profile.java index ac29817f..5f40373e 100644 --- a/app/src/main/java/com/jens/automation2/Profile.java +++ b/app/src/main/java/com/jens/automation2/Profile.java @@ -458,29 +458,17 @@ public class Profile implements Comparable public boolean delete(Context context) { - if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.profileActive)) + Rule usingRule = this.isInUseByRules(); + if(usingRule != null) { - for (Rule rule : Rule.findRuleCandidatesByTriggerProfile(this)) - { - Toast.makeText(context, String.format(context.getResources().getString(R.string.ruleXIsUsingProfileY), rule.getName(), this.getName()), Toast.LENGTH_LONG).show(); - return false; - } - } - else if(Rule.isAnyRuleUsing(Action_Enum.changeSoundProfile)) - { - for (Rule rule : Rule.findRuleCandidatesByActionProfile(this)) - { - Toast.makeText(context, String.format(context.getResources().getString(R.string.ruleXIsUsingProfileY), rule.getName(), this.getName()), Toast.LENGTH_LONG).show(); - return false; - } + Toast.makeText(context, String.format(context.getResources().getString(R.string.ruleXIsUsingProfileY), usingRule.getName(), this.getName()), Toast.LENGTH_LONG).show(); + return false; } else { profileCollection.remove(this); return XmlFileInterface.writeFile(); } - - return false; } private boolean plausibilityCheck() diff --git a/fastlane/metadata/android/en-US/changelogs/118.txt b/fastlane/metadata/android/en-US/changelogs/118.txt index 68341d1c..a0f3dc18 100644 --- a/fastlane/metadata/android/en-US/changelogs/118.txt +++ b/fastlane/metadata/android/en-US/changelogs/118.txt @@ -6,4 +6,5 @@ * Fixed: Variables were not replaced when sending text messages * Fixed: Service wouldn't always start after device has been powered on * Fixed: Set ringtones on Android 11 and above -* Fixed: Permission read storage required for changing ringtones \ No newline at end of file +* Fixed: Permission read storage required for changing ringtones +* Fixed: Profile that were not in use, could not be deleted. \ No newline at end of file