forked from jens/Automation
PhoneStatusListener
This commit is contained in:
parent
3fc1dd1a26
commit
170dbbc7e8
@ -69,6 +69,7 @@
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.READ_CALL_LOG" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.telephony"
|
||||
|
@ -67,6 +67,7 @@
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.READ_CALL_LOG" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.telephony"
|
||||
|
@ -65,6 +65,7 @@
|
||||
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.READ_CALL_LOG" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
@ -485,6 +485,7 @@ public class ActivityPermissions extends Activity
|
||||
case phoneCall:
|
||||
addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
|
||||
addToArrayListUnique(Manifest.permission.PROCESS_OUTGOING_CALLS, requiredPermissions);
|
||||
addToArrayListUnique(Manifest.permission.READ_CALL_LOG, requiredPermissions);
|
||||
break;
|
||||
case pointOfInterest:
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
||||
@ -877,6 +878,7 @@ public class ActivityPermissions extends Activity
|
||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||
break;
|
||||
case Manifest.permission.PROCESS_OUTGOING_CALLS:
|
||||
case Manifest.permission.READ_CALL_LOG:
|
||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.phoneCall))
|
||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||
break;
|
||||
|
@ -254,9 +254,9 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
||||
|
||||
if(incomingCallsReceiverInstance == null)
|
||||
{
|
||||
if(Build.VERSION.SDK_INT >= 31)
|
||||
incomingCallsReceiverInstance = new IncomingCallsReceiverNew();
|
||||
else
|
||||
// if(Build.VERSION.SDK_INT >= 31)
|
||||
// incomingCallsReceiverInstance = new IncomingCallsReceiverNew();
|
||||
// else
|
||||
incomingCallsReceiverInstance = new IncomingCallsReceiverOld();
|
||||
}
|
||||
|
||||
@ -268,17 +268,17 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
||||
if(!incomingCallsReceiverActive)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "PhoneStatusListener", "Starting PhoneStatusListener->incomingCallsReceiver", 4);
|
||||
if(Build.VERSION.SDK_INT >= problematicAndroidLevel)
|
||||
{
|
||||
IntentFilter callsFilter = new IntentFilter();
|
||||
callsFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
||||
automationService.registerReceiver((IncomingCallsReceiverNew)incomingCallsReceiverInstance, callsFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if(Build.VERSION.SDK_INT >= problematicAndroidLevel)
|
||||
// {
|
||||
// IntentFilter callsFilter = new IntentFilter();
|
||||
// callsFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
||||
// automationService.registerReceiver((IncomingCallsReceiverNew)incomingCallsReceiverInstance, callsFilter);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
TelephonyManager tm = (TelephonyManager) automationService.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
tm.listen((IncomingCallsReceiverOld)incomingCallsReceiverInstance, PhoneStateListener.LISTEN_CALL_STATE);
|
||||
}
|
||||
// }
|
||||
incomingCallsReceiverActive = true;
|
||||
}
|
||||
|
||||
@ -302,15 +302,15 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
||||
if(incomingCallsReceiverActive)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "PhoneStatusListener", "Stopping phoneStatusListener", 4);
|
||||
if(Build.VERSION.SDK_INT >= 31)
|
||||
{
|
||||
automationService.unregisterReceiver((IncomingCallsReceiverNew)incomingCallsReceiverInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if(Build.VERSION.SDK_INT >= 31)
|
||||
// {
|
||||
// automationService.unregisterReceiver((IncomingCallsReceiverNew)incomingCallsReceiverInstance);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
TelephonyManager tm = (TelephonyManager) automationService.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
tm.listen((IncomingCallsReceiverOld)incomingCallsReceiverInstance, PhoneStateListener.LISTEN_NONE);
|
||||
}
|
||||
// }
|
||||
incomingCallsReceiverActive = false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user