Phone Listener changed.
This commit is contained in:
parent
3844079781
commit
0a0399c2b0
@ -1360,28 +1360,29 @@ public class Rule implements Comparable<Rule>
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
// public static ArrayList<Rule> findRuleCandidatesByPhoneCall()
|
||||
// {
|
||||
// ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
//
|
||||
// for(Rule oneRule : ruleCollection)
|
||||
// {
|
||||
// innerloop:
|
||||
// for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
// {
|
||||
// if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.phoneCall)
|
||||
// {
|
||||
// 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> findRuleCandidatesByNfc()
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Looper;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -217,7 +218,7 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
private boolean checkBeforeSaving(Context context, boolean changeExistingRule)
|
||||
{
|
||||
if(this.getName() == null | this.getName().length()==0)
|
||||
if(this.getName() == null || this.getName().length()==0)
|
||||
{
|
||||
Toast.makeText(context, context.getResources().getString(R.string.pleaseEnterValidName), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
@ -412,13 +413,13 @@ public class Rule implements Comparable<Rule>
|
||||
&&
|
||||
Miscellaneous.compareTimes(nowTime, oneTrigger.getTimeFrame().getTriggerTimeStop()) > 0
|
||||
)
|
||||
|
|
||||
||
|
||||
// Other case, start time higher than end time, timeframe goes over midnight
|
||||
(
|
||||
Miscellaneous.compareTimes(oneTrigger.getTimeFrame().getTriggerTimeStart(), oneTrigger.getTimeFrame().getTriggerTimeStop()) < 0
|
||||
&&
|
||||
(Miscellaneous.compareTimes(oneTrigger.getTimeFrame().getTriggerTimeStart(), nowTime) >= 0
|
||||
|
|
||||
||
|
||||
Miscellaneous.compareTimes(nowTime, oneTrigger.getTimeFrame().getTriggerTimeStop()) > 0)
|
||||
)
|
||||
|
||||
@ -598,13 +599,29 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.phoneCall))
|
||||
{
|
||||
if(oneTrigger.getPhoneNumber().equals("any") | oneTrigger.getPhoneNumber().equals(PhoneStatusListener.getLastPhoneNumber()))
|
||||
String[] elements = oneTrigger.getTriggerParameter2().split(triggerParameter2Split);
|
||||
// state dir number
|
||||
|
||||
if(elements[2].equals(Trigger.triggerPhoneCallNumberAny) || PhoneStatusListener.getLastPhoneNumber().matches(elements[2]))
|
||||
{
|
||||
if(PhoneStatusListener.isInACall() == oneTrigger.getTriggerParameter())
|
||||
//if(PhoneStatusListener.isInACall() == oneTrigger.getTriggerParameter())
|
||||
if(
|
||||
(elements[0].equals(Trigger.triggerPhoneCallStateRinging) && PhoneStatusListener.getCurrentState() == TelephonyManager.CALL_STATE_RINGING)
|
||||
||
|
||||
(elements[0].equals(Trigger.triggerPhoneCallStateStarted) && PhoneStatusListener.getCurrentState() == TelephonyManager.CALL_STATE_OFFHOOK)
|
||||
||
|
||||
(elements[0].equals(Trigger.triggerPhoneCallStateStopped) && PhoneStatusListener.getCurrentState() == TelephonyManager.CALL_STATE_IDLE)
|
||||
)
|
||||
{
|
||||
if(oneTrigger.getPhoneDirection() == 0 | (oneTrigger.getPhoneDirection() == PhoneStatusListener.getLastPhoneDirection()))
|
||||
if(
|
||||
elements[1].equals(Trigger.triggerPhoneCallDirectionAny)
|
||||
||
|
||||
(elements[1].equals(Trigger.triggerPhoneCallDirectionIncoming) && PhoneStatusListener.getLastPhoneDirection() == 1)
|
||||
||
|
||||
(elements[1].equals(Trigger.triggerPhoneCallDirectionOutgoing) && PhoneStatusListener.getLastPhoneDirection() == 2)
|
||||
)
|
||||
{
|
||||
// Everything's allright
|
||||
// Trigger conditions are met
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -619,7 +636,10 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Rule", "Rule doesn't apply. Wrong phone number. Demanded: " + oneTrigger.getPhoneNumber() + ", got: " + PhoneStatusListener.getLastPhoneNumber(), 4);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.nfcTag))
|
||||
{
|
||||
@ -772,6 +792,7 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
|
||||
foundMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -840,7 +861,7 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
if (Looper.myLooper() == null)
|
||||
Looper.prepare();
|
||||
|
||||
|
||||
wasActivated = activateInternally((AutomationService)params[0], (Boolean)params[1]);
|
||||
|
||||
return null;
|
||||
@ -870,8 +891,8 @@ public class Rule implements Comparable<Rule>
|
||||
ActivityMainScreen.updateMainScreen();
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Will activate the rule. Should be called by a separate execution thread
|
||||
* @param automationService
|
||||
@ -879,15 +900,15 @@ public class Rule implements Comparable<Rule>
|
||||
protected boolean activateInternally(AutomationService automationService, boolean force)
|
||||
{
|
||||
boolean isActuallyToggable = isActuallyToggable();
|
||||
|
||||
|
||||
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
|
||||
boolean doToggle = ruleToggle && isActuallyToggable;
|
||||
|
||||
if(notLastActive | force | doToggle)
|
||||
|
||||
if(notLastActive || force || doToggle)
|
||||
{
|
||||
String message;
|
||||
if(!doToggle)
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivate), Rule.this.getName());
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivate), Rule.this.getName());
|
||||
else
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivateToggle), Rule.this.getName());
|
||||
Miscellaneous.logEvent("i", "Rule", message, 2);
|
||||
@ -895,7 +916,7 @@ public class Rule implements Comparable<Rule>
|
||||
// Toast.makeText(automationService, message, Toast.LENGTH_LONG).show();
|
||||
if(Settings.startNewThreadForRuleActivation)
|
||||
publishProgress(message);
|
||||
|
||||
|
||||
for(int i = 0; i< Rule.this.getActionSet().size(); i++)
|
||||
{
|
||||
try
|
||||
@ -1036,7 +1057,7 @@ public class Rule implements Comparable<Rule>
|
||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() > oneTrigger.getTimeFrame().getTriggerTimeStop().getTime())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Timeframe search", "Rule goes over midnight.", 5);
|
||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() | searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
||||
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
|
||||
@ -1307,10 +1328,10 @@ public class Rule implements Comparable<Rule>
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidatesByPhoneCall(boolean triggerParameter)
|
||||
public static ArrayList<Rule> findRuleCandidatesByPhoneCall(String direction)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
@ -1318,7 +1339,8 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.phoneCall)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
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
|
||||
@ -1326,7 +1348,7 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
this.lastExecution = lastExecution;
|
||||
}
|
||||
|
||||
|
||||
public boolean isRuleToggle()
|
||||
{
|
||||
return ruleToggle;
|
||||
@ -219,7 +219,7 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
private boolean checkBeforeSaving(Context context, boolean changeExistingRule)
|
||||
{
|
||||
if(this.getName() == null | this.getName().length()==0)
|
||||
if(this.getName() == null || this.getName().length()==0)
|
||||
{
|
||||
Toast.makeText(context, context.getResources().getString(R.string.pleaseEnterValidName), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
@ -414,13 +414,13 @@ public class Rule implements Comparable<Rule>
|
||||
&&
|
||||
Miscellaneous.compareTimes(nowTime, oneTrigger.getTimeFrame().getTriggerTimeStop()) > 0
|
||||
)
|
||||
|
|
||||
||
|
||||
// Other case, start time higher than end time, timeframe goes over midnight
|
||||
(
|
||||
Miscellaneous.compareTimes(oneTrigger.getTimeFrame().getTriggerTimeStart(), oneTrigger.getTimeFrame().getTriggerTimeStop()) < 0
|
||||
&&
|
||||
(Miscellaneous.compareTimes(oneTrigger.getTimeFrame().getTriggerTimeStart(), nowTime) >= 0
|
||||
|
|
||||
||
|
||||
Miscellaneous.compareTimes(nowTime, oneTrigger.getTimeFrame().getTriggerTimeStop()) > 0)
|
||||
)
|
||||
|
||||
@ -600,13 +600,29 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.phoneCall))
|
||||
{
|
||||
if(oneTrigger.getPhoneNumber().equals("any") | oneTrigger.getPhoneNumber().equals(PhoneStatusListener.getLastPhoneNumber()))
|
||||
String[] elements = oneTrigger.getTriggerParameter2().split(triggerParameter2Split);
|
||||
// state dir number
|
||||
|
||||
if(elements[2].equals(Trigger.triggerPhoneCallNumberAny) || PhoneStatusListener.getLastPhoneNumber().matches(elements[2]))
|
||||
{
|
||||
if(PhoneStatusListener.isInACall() == oneTrigger.getTriggerParameter())
|
||||
//if(PhoneStatusListener.isInACall() == oneTrigger.getTriggerParameter())
|
||||
if(
|
||||
(elements[0].equals(Trigger.triggerPhoneCallStateRinging) && PhoneStatusListener.getCurrentState() == TelephonyManager.CALL_STATE_RINGING)
|
||||
||
|
||||
(elements[0].equals(Trigger.triggerPhoneCallStateStarted) && PhoneStatusListener.getCurrentState() == TelephonyManager.CALL_STATE_OFFHOOK)
|
||||
||
|
||||
(elements[0].equals(Trigger.triggerPhoneCallStateStopped) && PhoneStatusListener.getCurrentState() == TelephonyManager.CALL_STATE_IDLE)
|
||||
)
|
||||
{
|
||||
if(oneTrigger.getPhoneDirection() == 0 | (oneTrigger.getPhoneDirection() == PhoneStatusListener.getLastPhoneDirection()))
|
||||
if(
|
||||
elements[1].equals(Trigger.triggerPhoneCallDirectionAny)
|
||||
||
|
||||
(elements[1].equals(Trigger.triggerPhoneCallDirectionIncoming) && PhoneStatusListener.getLastPhoneDirection() == 1)
|
||||
||
|
||||
(elements[1].equals(Trigger.triggerPhoneCallDirectionOutgoing) && PhoneStatusListener.getLastPhoneDirection() == 2)
|
||||
)
|
||||
{
|
||||
// Everything's allright
|
||||
// Trigger conditions are met
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -621,7 +637,10 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Rule", "Rule doesn't apply. Wrong phone number. Demanded: " + oneTrigger.getPhoneNumber() + ", got: " + PhoneStatusListener.getLastPhoneNumber(), 4);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.nfcTag))
|
||||
{
|
||||
@ -872,7 +891,7 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
if (Looper.myLooper() == null)
|
||||
Looper.prepare();
|
||||
|
||||
|
||||
wasActivated = activateInternally((AutomationService)params[0], (Boolean)params[1]);
|
||||
|
||||
return null;
|
||||
@ -915,7 +934,7 @@ public class Rule implements Comparable<Rule>
|
||||
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
|
||||
boolean doToggle = ruleToggle && isActuallyToggable;
|
||||
|
||||
if(notLastActive | force | doToggle)
|
||||
if(notLastActive || force || doToggle)
|
||||
{
|
||||
String message;
|
||||
if(!doToggle)
|
||||
@ -1068,7 +1087,7 @@ public class Rule implements Comparable<Rule>
|
||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() > oneTrigger.getTimeFrame().getTriggerTimeStop().getTime())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Timeframe search", "Rule goes over midnight.", 5);
|
||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() | searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
||||
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
|
||||
@ -1339,10 +1358,10 @@ public class Rule implements Comparable<Rule>
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidatesByPhoneCall(boolean triggerParameter)
|
||||
public static ArrayList<Rule> findRuleCandidatesByPhoneCall(String direction)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
@ -1350,7 +1369,8 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.phoneCall)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
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
|
||||
@ -1358,7 +1378,7 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,8 @@ public class AutomationService extends Service implements OnInitListener
|
||||
|
||||
private void stopRoutine()
|
||||
{
|
||||
Log.i("STOP", "Stopping");
|
||||
Miscellaneous.logEvent("i", "Service", "Stopping service...", 3);
|
||||
// Log.i("STOP", "Stopping");
|
||||
try
|
||||
{
|
||||
myLocationProvider.stopLocationService();
|
||||
|
@ -927,7 +927,7 @@ public class XmlFileInterface
|
||||
else if(newTrigger.getTriggerType() == Trigger_Enum.phoneCall)
|
||||
{
|
||||
String[] elements = triggerParameter2.split(",");
|
||||
if(elements.length > 3 && elements.length < 3) //old format
|
||||
if(elements.length == 2) //old format
|
||||
{
|
||||
// 0/1/2,number
|
||||
int direction = Integer.parseInt(elements[0]);
|
||||
|
@ -14,6 +14,7 @@ import com.jens.automation2.AutomationService;
|
||||
import com.jens.automation2.Miscellaneous;
|
||||
import com.jens.automation2.R;
|
||||
import com.jens.automation2.Rule;
|
||||
import com.jens.automation2.Trigger;
|
||||
import com.jens.automation2.Trigger.Trigger_Enum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -33,7 +34,6 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
||||
protected static IncomingCallsReceiver incomingCallsReceiverInstance;
|
||||
protected static BroadcastReceiver outgoingCallsReceiverInstance;
|
||||
|
||||
|
||||
public static boolean isIncomingCallsReceiverActive()
|
||||
{
|
||||
return incomingCallsReceiverActive;
|
||||
@ -78,63 +78,106 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
||||
{
|
||||
// Miscellaneous.logEvent("i", "Call state", "New call state: " + String.valueOf(state), 4);
|
||||
|
||||
setCurrentState(state);
|
||||
/*
|
||||
Unfortunately receivers for incoming and outgoing calls behave pretty differently:
|
||||
|
||||
if(incomingNumber != null && incomingNumber.length() > 0) // check for null in case call comes in with suppressed number.
|
||||
setLastPhoneNumber(incomingNumber);
|
||||
The Outgoing-Receiver is called when starting a call (ringing)
|
||||
It is not called when that outgoing call ends however, only the incoming receiver.
|
||||
|
||||
lastPhoneDirection = 1;
|
||||
|
||||
switch(state)
|
||||
If the last call was outgoing the state has not changed to idle this is kind of a fake alert.
|
||||
*/
|
||||
|
||||
if(lastPhoneDirection == 2 && currentState != TelephonyManager.CALL_STATE_IDLE)
|
||||
{
|
||||
case TelephonyManager.CALL_STATE_IDLE:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_IDLE", 4);
|
||||
// if(currentStateIncoming == TelephonyManager.CALL_STATE_OFFHOOK)
|
||||
// setCurrentStateIncoming(state);
|
||||
// else if(currentStateOutgoing == TelephonyManager.CALL_STATE_OFFHOOK)
|
||||
// setCurrentStateOutgoing(state);
|
||||
// else
|
||||
// currentStateIncoming = state;
|
||||
// currentStateOutgoing = state;
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_OFFHOOK:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_OFFHOOK", 4);
|
||||
// if(currentStateIncoming == TelephonyManager.CALL_STATE_RINGING)
|
||||
// setCurrentStateIncoming(state);
|
||||
// else if(currentStateOutgoing == TelephonyManager.CALL_STATE_RINGING)
|
||||
// setCurrentStateOutgoing(state);
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_RINGING:
|
||||
Miscellaneous.logEvent("i", "Call state", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.incomingCallFrom), incomingNumber), 4);
|
||||
break;
|
||||
// This status update is actually for an outgoing call
|
||||
setCurrentState(state);
|
||||
|
||||
if(incomingNumber != null && incomingNumber.length() > 0) // check for null in case call comes in with suppressed number.
|
||||
setLastPhoneNumber(incomingNumber);
|
||||
|
||||
switch(state)
|
||||
{
|
||||
case TelephonyManager.CALL_STATE_IDLE:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_IDLE", 4);
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_OFFHOOK:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_OFFHOOK", 4);
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_RINGING:
|
||||
Miscellaneous.logEvent("i", "Call state", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.outgoingCallTo), incomingNumber), 4);
|
||||
break;
|
||||
}
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidatesByPhoneCall(Trigger.triggerPhoneCallDirectionOutgoing);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
AutomationService asInstance = AutomationService.getInstance();
|
||||
if(asInstance != null)
|
||||
if(ruleCandidates.get(i).applies(asInstance))
|
||||
ruleCandidates.get(i).activate(asInstance, false);
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.phoneCall);
|
||||
AutomationService asInstance = AutomationService.getInstance();
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
else
|
||||
{
|
||||
if(asInstance != null)
|
||||
if(ruleCandidates.get(i).applies(asInstance))
|
||||
ruleCandidates.get(i).activate(asInstance, false);
|
||||
// state != TelephonyManager.CALL_STATE_IDLE &&
|
||||
|
||||
setCurrentState(state);
|
||||
setLastPhoneDirection(1);
|
||||
|
||||
if (incomingNumber != null && incomingNumber.length() > 0) // check for null in case call comes in with suppressed number.
|
||||
setLastPhoneNumber(incomingNumber);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case TelephonyManager.CALL_STATE_IDLE:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_IDLE", 4);
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_OFFHOOK:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_OFFHOOK", 4);
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_RINGING:
|
||||
Miscellaneous.logEvent("i", "Call state", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.incomingCallFrom), incomingNumber), 4);
|
||||
break;
|
||||
}
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidatesByPhoneCall(Trigger.triggerPhoneCallDirectionIncoming);
|
||||
for (int i = 0; i < ruleCandidates.size(); i++)
|
||||
{
|
||||
AutomationService asInstance = AutomationService.getInstance();
|
||||
if (asInstance != null)
|
||||
if (ruleCandidates.get(i).applies(asInstance))
|
||||
ruleCandidates.get(i).activate(asInstance, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void setLastPhoneDirection(int i)
|
||||
{
|
||||
lastPhoneDirection = i;
|
||||
}
|
||||
|
||||
public static class OutgoingCallsReceiver extends BroadcastReceiver
|
||||
{
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
lastPhoneDirection = 2;
|
||||
// setCurrentStateOutgoing(2); // das kommt hier auch bei nur klingeln
|
||||
/*
|
||||
This receiver is ONLY triggered when outgoing calls ring, not when that call is established or ends.
|
||||
*/
|
||||
setLastPhoneDirection(2);
|
||||
|
||||
TelephonyManager tm = (TelephonyManager)context.getSystemService(Service.TELEPHONY_SERVICE);
|
||||
setCurrentState(tm.getCallState());
|
||||
// TelephonyManager tm = (TelephonyManager)context.getSystemService(Service.TELEPHONY_SERVICE);
|
||||
// int newState = tm.getCallState();
|
||||
// setCurrentState(newState);
|
||||
|
||||
setLastPhoneNumber(intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER));
|
||||
Miscellaneous.logEvent("i", "Call state", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.outgoingCallFrom), getLastPhoneNumber()), 4);
|
||||
setCurrentState(TelephonyManager.CALL_STATE_RINGING);
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.phoneCall);
|
||||
String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
|
||||
setLastPhoneNumber(phoneNumber);
|
||||
Miscellaneous.logEvent("i", "Call state", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.outgoingCallTo), getLastPhoneNumber()), 4);
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidatesByPhoneCall(Trigger.triggerPhoneCallDirectionOutgoing);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
AutomationService asInstance = AutomationService.getInstance();
|
||||
|
@ -410,7 +410,7 @@
|
||||
<string name="activityDetectionRequiredProbabilityTitle">Wahrscheinlichkeit für Aktivitätserkennungen</string>
|
||||
<string name="activityDetectionRequiredProbabilitySummary">Wahrscheinlichkeit, ab der eine Aktivität als gegeben gilt.</string>
|
||||
<string name="incomingCallFrom">Eingehender Telefonanruf von %1$s.</string>
|
||||
<string name="outgoingCallFrom">Ausgehender Telefonanruf von %1$s.</string>
|
||||
<string name="outgoingCallTo">Ausgehender Telefonanruf von %1$s.</string>
|
||||
<string name="actionSpeakText">Text sprechen</string>
|
||||
<string name="textToSpeak">Zu sprechender Text</string>
|
||||
<string name="toggleNotAllowed">Die Umschaltfunktion ist momentan nur für Regeln erlaubt, die NFC Tags als Auslöser haben. Für weitere Informationen lesen Sie die Hilfe.</string>
|
||||
|
@ -312,7 +312,7 @@ Quindi, se si crea una regola che imposta il profilo su vibrazione nell\'interva
|
||||
<string name="onOff">On/Off</string>
|
||||
<string name="outgoing">effettuata</string>
|
||||
<string name="outgoingAdjective">effettuata</string>
|
||||
<string name="outgoingCallFrom">Ultima chiamata effettuata %1$s fa.</string>
|
||||
<string name="outgoingCallTo">Ultima chiamata effettuata %1$s fa.</string>
|
||||
<string name="overlapBetweenPois">Rilevata sovrapposizione della posizione %1$s. Ridurre il raggio almeno di %2$s metri.</string>
|
||||
<string name="overview">Panoramica</string>
|
||||
<string name="parameterName">Nome parametro</string>
|
||||
|
@ -411,7 +411,7 @@
|
||||
<string name="activityDetectionRequiredProbabilityTitle">Activity detection probability</string>
|
||||
<string name="activityDetectionRequiredProbabilitySummary">Certainty from which activities are accepted as fact.</string>
|
||||
<string name="incomingCallFrom">Incoming telephone call from %1$s.</string>
|
||||
<string name="outgoingCallFrom">Outgoing telephone call to %1$s.</string>
|
||||
<string name="outgoingCallTo">Outgoing telephone call to %1$s.</string>
|
||||
<string name="actionSpeakText">Speak text</string>
|
||||
<string name="textToSpeak">Text to speak</string>
|
||||
<string name="toggleNotAllowed">Toggling is currently only allowed for rules that have NFC tags as trigger. See help for further information.</string>
|
||||
|
Loading…
Reference in New Issue
Block a user