forked from jens/Automation
screen state trigger
This commit is contained in:
parent
94f6418076
commit
d64ea8454e
@ -556,7 +556,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
innerloop:
|
innerloop:
|
||||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||||
{
|
{
|
||||||
if(oneTrigger.getTriggerType() == triggerType)
|
if(oneTrigger.getTriggerType().equals(triggerType))
|
||||||
{
|
{
|
||||||
ruleCandidates.add(oneRule);
|
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
|
||||||
@ -567,6 +567,26 @@ public class Rule implements Comparable<Rule>
|
|||||||
return ruleCandidates;
|
return ruleCandidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ArrayList<Rule> findRuleCandidates(Action.Action_Enum actionType)
|
||||||
|
{
|
||||||
|
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||||
|
|
||||||
|
for(Rule oneRule : ruleCollection)
|
||||||
|
{
|
||||||
|
innerloop:
|
||||||
|
for(Action oneAction : oneRule.getActionSet())
|
||||||
|
{
|
||||||
|
if(oneAction.getAction().equals(actionType))
|
||||||
|
{
|
||||||
|
ruleCandidates.add(oneRule);
|
||||||
|
break innerloop; // we don't need to check the other actions in the same rule
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ruleCandidates;
|
||||||
|
}
|
||||||
|
|
||||||
public static ArrayList<Rule> findRuleCandidatesByPoi(PointOfInterest searchPoi, boolean triggerParameter)
|
public static ArrayList<Rule> findRuleCandidatesByPoi(PointOfInterest searchPoi, boolean triggerParameter)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "RuleSearch", "Searching for rules referencing POI " + searchPoi.getName() + ". Total size of ruleset: " + String.valueOf(ruleCollection.size()), 4);
|
Miscellaneous.logEvent("i", "RuleSearch", "Searching for rules referencing POI " + searchPoi.getName() + ". Total size of ruleset: " + String.valueOf(ruleCollection.size()), 4);
|
||||||
@ -608,186 +628,6 @@ public class Rule implements Comparable<Rule>
|
|||||||
return ruleCandidates;
|
return ruleCandidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static ArrayList<Rule> findRuleCandidatesByTimeFrame(TimeFrame searchTimeFrame, boolean triggerParameter)
|
|
||||||
{
|
|
||||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
|
||||||
|
|
||||||
for(int i=0; i<ruleCollection.size(); i++)
|
|
||||||
{
|
|
||||||
innerloop:
|
|
||||||
for(int j=0; j<ruleCollection.get(i).getTriggerSet().size(); j++)
|
|
||||||
{
|
|
||||||
if(ruleCollection.get(i).getTriggerSet().get(j).getTriggerType() == Trigger.Trigger_Enum.timeFrame)
|
|
||||||
{
|
|
||||||
if(ruleCollection.get(i).getTriggerSet().get(j).getTimeFrame().equals(searchTimeFrame) && ruleCollection.get(i).getTriggerSet().get(j).getTriggerParameter() == triggerParameter)
|
|
||||||
{
|
|
||||||
ruleCandidates.add(ruleCollection.get(i));
|
|
||||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ruleCandidates;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*public static ArrayList<Rule> findRuleCandidatesByTime(Time searchTime)
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "RuleSearch", "Searching for rules with TimeFrame with time " + searchTime.toString() + ". RuleCollection-Size: " + String.valueOf(ruleCollection.size()), 3);;
|
|
||||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
|
||||||
|
|
||||||
for(Rule oneRule : ruleCollection)
|
|
||||||
{
|
|
||||||
innerloop:
|
|
||||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
|
||||||
{
|
|
||||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.timeFrame)
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "RuleSearch", "Searching interval: " + oneTrigger.getTimeFrame().getTriggerTimeStart().toString() + " to " + oneTrigger.getTimeFrame().getTriggerTimeStop().toString(), 5);
|
|
||||||
Miscellaneous.logEvent("i", "RuleSearch", "interval start: " + String.valueOf(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime()), 5);
|
|
||||||
Miscellaneous.logEvent("i", "RuleSearch", "search time: " + String.valueOf(searchTime.getTime()), 5);
|
|
||||||
Miscellaneous.logEvent("i", "RuleSearch", "interval stop: " + String.valueOf(oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()), 5);
|
|
||||||
|
|
||||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() > oneTrigger.getTimeFrame().getTriggerTimeStop().getTime())
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "Timeframe search", "Rule (" + oneRule.getName() + ") stretches over midnight.", 5);
|
|
||||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() || searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
|
||||||
{
|
|
||||||
ruleCandidates.add(oneRule);
|
|
||||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() && searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "RuleSearch", "Rule found (" + oneRule.getName() + ") with TimeFrame with time " + searchTime.toString(), 3);
|
|
||||||
ruleCandidates.add(oneRule);
|
|
||||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Miscellaneous.logEvent("i", "RuleSearch", String.valueOf(ruleCandidates.size()) + " Rule(s) found with TimeFrame with time " + searchTime.toString(), 3);
|
|
||||||
|
|
||||||
return ruleCandidates;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*public static ArrayList<Rule> findRuleCandidatesByCharging(boolean triggerParameter)
|
|
||||||
{
|
|
||||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
|
||||||
|
|
||||||
for(Rule oneRule : ruleCollection)
|
|
||||||
{
|
|
||||||
innerloop:
|
|
||||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
|
||||||
{
|
|
||||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.charging)
|
|
||||||
{
|
|
||||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
|
||||||
{
|
|
||||||
ruleCandidates.add(oneRule);
|
|
||||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ruleCandidates;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*public static ArrayList<Rule> findRuleCandidatesByUsbHost(boolean triggerParameter)
|
|
||||||
{
|
|
||||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
|
||||||
|
|
||||||
for(Rule oneRule : ruleCollection)
|
|
||||||
{
|
|
||||||
innerloop:
|
|
||||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
|
||||||
{
|
|
||||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.usb_host_connection)
|
|
||||||
{
|
|
||||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
|
||||||
{
|
|
||||||
ruleCandidates.add(oneRule);
|
|
||||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ruleCandidates;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*public static ArrayList<Rule> findRuleCandidatesByAirplaneMode(boolean triggerParameter)
|
|
||||||
{
|
|
||||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
|
||||||
|
|
||||||
for(Rule oneRule : ruleCollection)
|
|
||||||
{
|
|
||||||
innerloop:
|
|
||||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
|
||||||
{
|
|
||||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.airplaneMode)
|
|
||||||
{
|
|
||||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
|
||||||
{
|
|
||||||
ruleCandidates.add(oneRule);
|
|
||||||
break innerloop; //we don't need to search the other triggers in the same rule
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ruleCandidates;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*public static ArrayList<Rule> findRuleCandidatesByRoaming(boolean triggerParameter)
|
|
||||||
{
|
|
||||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
|
||||||
|
|
||||||
for(Rule oneRule : ruleCollection)
|
|
||||||
{
|
|
||||||
innerloop:
|
|
||||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
|
||||||
{
|
|
||||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.roaming)
|
|
||||||
{
|
|
||||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
|
||||||
{
|
|
||||||
ruleCandidates.add(oneRule);
|
|
||||||
break innerloop; //we don't need to search the other triggers in the same rule
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ruleCandidates;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*public static ArrayList<Rule> findRuleCandidatesByPhoneCall(String direction)
|
|
||||||
{
|
|
||||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
|
||||||
|
|
||||||
for(Rule oneRule : ruleCollection)
|
|
||||||
{
|
|
||||||
innerloop:
|
|
||||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
|
||||||
{
|
|
||||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.phoneCall)
|
|
||||||
{
|
|
||||||
String[] elements = oneTrigger.getTriggerParameter2().split(triggerParameter2Split);
|
|
||||||
if(elements[1].equals(Trigger.triggerPhoneCallDirectionAny) || elements[1].equals(direction))
|
|
||||||
{
|
|
||||||
ruleCandidates.add(oneRule);
|
|
||||||
break innerloop; //we don't need to search the other triggers in the same rule
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ruleCandidates;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public static ArrayList<Rule> findRuleCandidatesByPoi(PointOfInterest searchPoi)
|
public static ArrayList<Rule> findRuleCandidatesByPoi(PointOfInterest searchPoi)
|
||||||
{
|
{
|
||||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||||
@ -811,29 +651,6 @@ public class Rule implements Comparable<Rule>
|
|||||||
return ruleCandidates;
|
return ruleCandidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static ArrayList<Rule> findRuleCandidatesByHeadphoneJack(boolean triggerParameter)
|
|
||||||
{
|
|
||||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
|
||||||
|
|
||||||
for(Rule oneRule : ruleCollection)
|
|
||||||
{
|
|
||||||
innerloop:
|
|
||||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
|
||||||
{
|
|
||||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.headsetPlugged)
|
|
||||||
{
|
|
||||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
|
||||||
{
|
|
||||||
ruleCandidates.add(oneRule);
|
|
||||||
break innerloop; //we don't need to search the other triggers in the same rule
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ruleCandidates;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public static ArrayList<Rule> findRuleCandidatesByTriggerProfile(Profile profile)
|
public static ArrayList<Rule> findRuleCandidatesByTriggerProfile(Profile profile)
|
||||||
{
|
{
|
||||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||||
|
@ -1137,9 +1137,6 @@ public class ActivityManageRule extends Activity
|
|||||||
});
|
});
|
||||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||||
|
|
||||||
// Log.i("Amount of Applications", String.valueOf(applicationArray.length));
|
|
||||||
// Log.i("Amount of Packages", String.valueOf(ActivityManageStartActivity.getPackageListString(myContext).length));
|
|
||||||
|
|
||||||
return alertDialog;
|
return alertDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1176,6 +1173,7 @@ public class ActivityManageRule extends Activity
|
|||||||
triggerProcess = activityArray[which];
|
triggerProcess = activityArray[which];
|
||||||
newTrigger.setTriggerType(Trigger_Enum.process_started_stopped);
|
newTrigger.setTriggerType(Trigger_Enum.process_started_stopped);
|
||||||
newTrigger.setProcessName(triggerProcess);
|
newTrigger.setProcessName(triggerProcess);
|
||||||
|
newTrigger.setTriggerParameter2(packageName + Trigger.triggerParameter2Split + triggerProcess);
|
||||||
ruleToEdit.getTriggerSet().add(newTrigger);
|
ruleToEdit.getTriggerSet().add(newTrigger);
|
||||||
refreshTriggerList();
|
refreshTriggerList();
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import com.jens.automation2.receivers.HeadphoneJackListener;
|
|||||||
import com.jens.automation2.receivers.NoiseListener;
|
import com.jens.automation2.receivers.NoiseListener;
|
||||||
import com.jens.automation2.receivers.PhoneStatusListener;
|
import com.jens.automation2.receivers.PhoneStatusListener;
|
||||||
import com.jens.automation2.receivers.ProcessListener;
|
import com.jens.automation2.receivers.ProcessListener;
|
||||||
|
import com.jens.automation2.receivers.ScreenStateReceiver;
|
||||||
import com.jens.automation2.receivers.TimeZoneListener;
|
import com.jens.automation2.receivers.TimeZoneListener;
|
||||||
|
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
@ -54,6 +55,7 @@ public class ReceiverCoordinator
|
|||||||
//NotificationListener.class,
|
//NotificationListener.class,
|
||||||
PhoneStatusListener.class,
|
PhoneStatusListener.class,
|
||||||
ProcessListener.class,
|
ProcessListener.class,
|
||||||
|
ScreenStateReceiver.class,
|
||||||
TimeZoneListener.class
|
TimeZoneListener.class
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -70,6 +72,7 @@ public class ReceiverCoordinator
|
|||||||
NoiseListener.class,
|
NoiseListener.class,
|
||||||
PhoneStatusListener.class,
|
PhoneStatusListener.class,
|
||||||
ProcessListener.class,
|
ProcessListener.class,
|
||||||
|
ScreenStateReceiver.class,
|
||||||
TimeZoneListener.class
|
TimeZoneListener.class
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -177,13 +180,14 @@ public class ReceiverCoordinator
|
|||||||
// Nothing to do, just not starting this one.
|
// Nothing to do, just not starting this one.
|
||||||
}
|
}
|
||||||
|
|
||||||
//startBluetoothReceiver
|
|
||||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.bluetoothConnection))
|
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.bluetoothConnection))
|
||||||
BluetoothReceiver.startBluetoothReceiver();
|
BluetoothReceiver.startBluetoothReceiver();
|
||||||
|
|
||||||
//startHeadsetJackListener
|
|
||||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.headsetPlugged))
|
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.headsetPlugged))
|
||||||
HeadphoneJackListener.getInstance().startListener(AutomationService.getInstance());
|
HeadphoneJackListener.getInstance().startListener(AutomationService.getInstance());
|
||||||
|
|
||||||
|
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.screenState))
|
||||||
|
ScreenStateReceiver.startScreenStateReceiver(AutomationService.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stopAllReceivers()
|
public static void stopAllReceivers()
|
||||||
@ -268,6 +272,17 @@ public class ReceiverCoordinator
|
|||||||
ProcessListener.stopProcessListener(AutomationService.getInstance());
|
ProcessListener.stopProcessListener(AutomationService.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.screenState))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "LocationProvider", "Starting ScreenStateListener because used in a new/changed rule.", 4);
|
||||||
|
ScreenStateReceiver.startScreenStateReceiver(AutomationService.getInstance());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "LocationProvider", "Shutting down ScreenStateListener because not used in any rule.", 4);
|
||||||
|
ScreenStateReceiver.stopScreenStateReceiver();
|
||||||
|
}
|
||||||
|
|
||||||
if(!BuildConfig.FLAVOR.equalsIgnoreCase("fdroidFlavor"))
|
if(!BuildConfig.FLAVOR.equalsIgnoreCase("fdroidFlavor"))
|
||||||
{
|
{
|
||||||
if (Rule.isAnyRuleUsing(Trigger.Trigger_Enum.activityDetection))
|
if (Rule.isAnyRuleUsing(Trigger.Trigger_Enum.activityDetection))
|
||||||
|
@ -24,6 +24,7 @@ import com.jens.automation2.receivers.PhoneStatusListener;
|
|||||||
import com.jens.automation2.receivers.ProcessListener;
|
import com.jens.automation2.receivers.ProcessListener;
|
||||||
import com.jens.automation2.receivers.ScreenStateReceiver;
|
import com.jens.automation2.receivers.ScreenStateReceiver;
|
||||||
|
|
||||||
|
import static com.jens.automation2.Trigger.triggerParameter2Split;
|
||||||
import static com.jens.automation2.receivers.NotificationListener.EXTRA_TEXT;
|
import static com.jens.automation2.receivers.NotificationListener.EXTRA_TEXT;
|
||||||
import static com.jens.automation2.receivers.NotificationListener.EXTRA_TITLE;
|
import static com.jens.automation2.receivers.NotificationListener.EXTRA_TITLE;
|
||||||
|
|
||||||
@ -555,7 +556,19 @@ public class Trigger
|
|||||||
|
|
||||||
boolean checkProcess()
|
boolean checkProcess()
|
||||||
{
|
{
|
||||||
boolean running = ProcessListener.getRunningApps().contains(this.getProcessName());
|
boolean running = false;
|
||||||
|
|
||||||
|
if(getTriggerParameter2().contains(triggerParameter2Split))
|
||||||
|
{
|
||||||
|
String parts[] = triggerParameter2.split(triggerParameter2Split);
|
||||||
|
for(String appName : ProcessListener.getRunningApps())
|
||||||
|
{
|
||||||
|
if(appName.startsWith(parts[0]))
|
||||||
|
running = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
running = ProcessListener.getRunningApps().contains(this.getProcessName());
|
||||||
|
|
||||||
if(running)
|
if(running)
|
||||||
Miscellaneous.logEvent("i", "ProcessMonitoring", "App " + this.getProcessName() + " is currently running.", 4);
|
Miscellaneous.logEvent("i", "ProcessMonitoring", "App " + this.getProcessName() + " is currently running.", 4);
|
||||||
|
@ -263,11 +263,9 @@ public class XmlFileInterface
|
|||||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.wifiConnection)
|
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.wifiConnection)
|
||||||
serializer.text(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerParameter2());
|
serializer.text(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerParameter2());
|
||||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.process_started_stopped)
|
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.process_started_stopped)
|
||||||
serializer.text(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getProcessName());
|
serializer.text(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerParameter2());
|
||||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.batteryLevel)
|
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.batteryLevel)
|
||||||
serializer.text(String.valueOf(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getBatteryLevel()));
|
serializer.text(String.valueOf(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getBatteryLevel()));
|
||||||
// else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.phoneCall)
|
|
||||||
// serializer.text(String.valueOf(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getPhoneDirection()) + "," + String.valueOf(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getPhoneNumber()));
|
|
||||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.nfcTag)
|
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.nfcTag)
|
||||||
serializer.text(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getNfcTagId());
|
serializer.text(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getNfcTagId());
|
||||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.activityDetection)
|
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.activityDetection)
|
||||||
@ -943,8 +941,16 @@ public class XmlFileInterface
|
|||||||
}
|
}
|
||||||
else if(newTrigger.getTriggerType() == Trigger_Enum.process_started_stopped)
|
else if(newTrigger.getTriggerType() == Trigger_Enum.process_started_stopped)
|
||||||
{
|
{
|
||||||
newTrigger.setProcessName(triggerParameter2);
|
|
||||||
newTrigger.setTriggerParameter2(triggerParameter2);
|
newTrigger.setTriggerParameter2(triggerParameter2);
|
||||||
|
|
||||||
|
if(triggerParameter2.contains(triggerParameter2Split))
|
||||||
|
{
|
||||||
|
String[] parts = triggerParameter2.split(triggerParameter2Split);
|
||||||
|
newTrigger.setProcessName(parts[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
newTrigger.setProcessName(triggerParameter2);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(newTrigger.getTriggerType() == Trigger_Enum.phoneCall)
|
else if(newTrigger.getTriggerType() == Trigger_Enum.phoneCall)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.jens.automation2.receivers;
|
package com.jens.automation2.receivers;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityManager.RunningAppProcessInfo;
|
import android.app.ActivityManager.RunningAppProcessInfo;
|
||||||
import android.app.ActivityManager.RunningServiceInfo;
|
import android.app.ActivityManager.RunningServiceInfo;
|
||||||
@ -8,6 +9,7 @@ import android.content.Context;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
|
||||||
|
import com.jens.automation2.Action;
|
||||||
import com.jens.automation2.ActivityPermissions;
|
import com.jens.automation2.ActivityPermissions;
|
||||||
import com.jens.automation2.AutomationService;
|
import com.jens.automation2.AutomationService;
|
||||||
import com.jens.automation2.Miscellaneous;
|
import com.jens.automation2.Miscellaneous;
|
||||||
@ -208,12 +210,12 @@ public class ProcessListener implements AutomationListenerInterface
|
|||||||
workHandler.sendMessage(answer);
|
workHandler.sendMessage(answer);
|
||||||
|
|
||||||
//activate rule(s)
|
//activate rule(s)
|
||||||
/*ArrayList<Rule> ruleCandidates = Rule.findRuleCandidatesByProcess();
|
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.process_started_stopped);
|
||||||
for(int i=0; i<ruleCandidates.size(); i++)
|
for(int i=0; i<ruleCandidates.size(); i++)
|
||||||
{
|
{
|
||||||
if(ruleCandidates.get(i).applies(automationService))
|
if(ruleCandidates.get(i).getsGreenLight(automationService))
|
||||||
ruleCandidates.get(i).activate(automationService);
|
ruleCandidates.get(i).activate(automationService, false);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
isMonitoringActive = false;
|
isMonitoringActive = false;
|
||||||
|
|
||||||
@ -255,24 +257,6 @@ public class ProcessListener implements AutomationListenerInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for(String runningApp : runningAppsListReference)
|
|
||||||
// {
|
|
||||||
// Miscellaneous.logEvent("i", "Running app", runningApp, 5);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// List<RunningAppProcessInfo> procInfos = activityManager.getRunningAppProcesses();
|
|
||||||
// for(int i = 0; i < procInfos.size(); i++)
|
|
||||||
// {
|
|
||||||
// ArrayList<String> runningPkgs = new ArrayList<String>(Arrays.asList(procInfos.get(i).pkgList));
|
|
||||||
//
|
|
||||||
// Collection diff = subtractSets(runningPkgs, stalkList);
|
|
||||||
//
|
|
||||||
// if(diff != null)
|
|
||||||
// {
|
|
||||||
// stalkList.removeAll(diff);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Set marker to the one to be written next.
|
// Set marker to the one to be written next.
|
||||||
if(lastWritten == 1)
|
if(lastWritten == 1)
|
||||||
lastWritten = 2;
|
lastWritten = 2;
|
||||||
@ -351,7 +335,7 @@ public class ProcessListener implements AutomationListenerInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkifThisIsActive(RunningAppProcessInfo target)
|
private boolean checkIfThisIsActive(RunningAppProcessInfo target)
|
||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
RunningTaskInfo info;
|
RunningTaskInfo info;
|
||||||
@ -397,7 +381,6 @@ public class ProcessListener implements AutomationListenerInterface
|
|||||||
|
|
||||||
Message message = new Message();
|
Message message = new Message();
|
||||||
message.arg1 = 1;
|
message.arg1 = 1;
|
||||||
// schedulingHandler.sendMessageDelayed(message, Settings.timeBetweenNoiseLevelMeasurements * 1000);
|
|
||||||
schedulingHandler.sendMessageDelayed(message, 10000);
|
schedulingHandler.sendMessageDelayed(message, 10000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -444,7 +427,7 @@ public class ProcessListener implements AutomationListenerInterface
|
|||||||
|
|
||||||
public static boolean haveAllPermission()
|
public static boolean haveAllPermission()
|
||||||
{
|
{
|
||||||
return ActivityPermissions.havePermission("android.permission.GET_TASKS", Miscellaneous.getAnyContext());
|
return ActivityPermissions.havePermission(Manifest.permission.GET_TASKS, Miscellaneous.getAnyContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -458,6 +441,4 @@ public class ProcessListener implements AutomationListenerInterface
|
|||||||
{
|
{
|
||||||
return new Trigger_Enum[] { Trigger_Enum.process_started_stopped };
|
return new Trigger_Enum[] { Trigger_Enum.process_started_stopped };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -27,6 +27,14 @@ public class ScreenStateReceiver extends BroadcastReceiver implements Automation
|
|||||||
private static Intent screenStatusIntent = null;
|
private static Intent screenStatusIntent = null;
|
||||||
private static BroadcastReceiver screenStateReceiverInstance = null;
|
private static BroadcastReceiver screenStateReceiverInstance = null;
|
||||||
|
|
||||||
|
public static BroadcastReceiver getScreenStateReceiverInstance()
|
||||||
|
{
|
||||||
|
if(screenStateReceiverInstance == null)
|
||||||
|
screenStateReceiverInstance = new ScreenStateReceiver();
|
||||||
|
|
||||||
|
return screenStateReceiverInstance;
|
||||||
|
}
|
||||||
|
|
||||||
public static void startScreenStateReceiver(final AutomationService automationServiceRef)
|
public static void startScreenStateReceiver(final AutomationService automationServiceRef)
|
||||||
{
|
{
|
||||||
if(!screenStateReceiverActive)
|
if(!screenStateReceiverActive)
|
||||||
@ -93,14 +101,14 @@ public class ScreenStateReceiver extends BroadcastReceiver implements Automation
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(intent.getAction().equals(Intent.ACTION_SCREEN_ON))
|
if(intent.getAction().equals(Intent.ACTION_SCREEN_OFF))
|
||||||
{
|
|
||||||
ScreenStateReceiver.screenState = 1;
|
|
||||||
}
|
|
||||||
else if(intent.getAction().equals(Intent.ACTION_SCREEN_OFF))
|
|
||||||
{
|
{
|
||||||
ScreenStateReceiver.screenState = 0;
|
ScreenStateReceiver.screenState = 0;
|
||||||
}
|
}
|
||||||
|
else if(intent.getAction().equals(Intent.ACTION_SCREEN_ON))
|
||||||
|
{
|
||||||
|
ScreenStateReceiver.screenState = 1;
|
||||||
|
}
|
||||||
else if(intent.getAction().equals(Intent.ACTION_USER_PRESENT))
|
else if(intent.getAction().equals(Intent.ACTION_USER_PRESENT))
|
||||||
{
|
{
|
||||||
ScreenStateReceiver.screenState = 2;
|
ScreenStateReceiver.screenState = 2;
|
||||||
@ -114,10 +122,6 @@ public class ScreenStateReceiver extends BroadcastReceiver implements Automation
|
|||||||
{
|
{
|
||||||
Miscellaneous.logEvent("e", "ScreenStateReceiver", "Error receiving screen state: " + e.getMessage(), 3);
|
Miscellaneous.logEvent("e", "ScreenStateReceiver", "Error receiving screen state: " + e.getMessage(), 3);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void actionCharging(Context context, int state)
|
|
||||||
{
|
|
||||||
|
|
||||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.screenState);
|
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.screenState);
|
||||||
for(int i=0; i<ruleCandidates.size(); i++)
|
for(int i=0; i<ruleCandidates.size(); i++)
|
||||||
|
@ -17,7 +17,7 @@ public class StartupIntentReceiver extends BroadcastReceiver
|
|||||||
{
|
{
|
||||||
Settings.readFromPersistentStorage(context);
|
Settings.readFromPersistentStorage(context);
|
||||||
|
|
||||||
Miscellaneous.logEvent("i", "Boot event", "Received event: " + intent.getAction(), 5);
|
// Miscellaneous.logEvent("i", "Boot event", "Received event: " + intent.getAction(), 5);
|
||||||
|
|
||||||
if(Settings.startServiceAtSystemBoot)
|
if(Settings.startServiceAtSystemBoot)
|
||||||
{
|
{
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
* New trigger: screen state (on/off)
|
||||||
* New action: Create notification
|
* New action: Create notification
|
||||||
* New action: Close notification(s)
|
* New action: Close notification(s)
|
||||||
* Fixed: Translation bug in dutch variables text
|
* Fixed: Translation bug in dutch variables text
|
||||||
|
* Fixed: Variables were not replaced when sending text messages
|
||||||
|
* Fixed: Service wouldn't always start after device is powered on
|
Loading…
Reference in New Issue
Block a user