Compare commits

..

No commits in common. "49d272be1e5674ca78813eef5535b5a3437f9fbd" and "b6015a3f2ef02fd6325cf5a3e2f0ae936c69af90" have entirely different histories.

15 changed files with 62 additions and 195 deletions

View File

@ -11,8 +11,8 @@ android {
compileSdkVersion 31
buildToolsVersion '29.0.2'
useLibrary 'org.apache.http.legacy'
versionCode 129
versionName "1.7.13"
versionCode 127
versionName "1.7.12"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -68,8 +68,6 @@
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
<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"

View File

@ -66,8 +66,6 @@
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
<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"

View File

@ -64,8 +64,6 @@
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
<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"

View File

@ -25,8 +25,6 @@ import android.widget.TextView;
import com.jens.automation2.receivers.NotificationListener;
import org.w3c.dom.DOMImplementationSource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -50,7 +48,6 @@ public class ActivityPermissions extends Activity
private static final int requestCodeForPermissionsDeviceAdmin = 12047;
private static final int requestCodeForPermissionsBatteryOptimization = 12048;
private static final int requestCodeForPermissionNotificationAccessAndroid13 = 12049;
private static final int requestCodeForPermissionsManageOverlay = 12050;
protected String[] specificPermissionsToRequest = null;
public static String intentExtraName = "permissionsToBeRequested";
@ -300,10 +297,6 @@ public class ActivityPermissions extends Activity
String packageName = context.getApplicationContext().getPackageName();
return pm.isIgnoringBatteryOptimizations(packageName);
}
else if (s.equals(Manifest.permission.SYSTEM_ALERT_WINDOW))
{
return android.provider.Settings.canDrawOverlays(Miscellaneous.getAnyContext());
}
else
{
int res = context.checkCallingOrSelfPermission(s);
@ -322,11 +315,6 @@ public class ActivityPermissions extends Activity
return active;
}
public static void requestOverlay()
{
Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
ActivityPermissions.getInstance().startActivityForResult(intent, requestCodeForPermissionsManageOverlay);
}
public static void requestDeviceAdmin()
{
if(!haveDeviceAdmin())
@ -485,7 +473,6 @@ 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)
@ -647,8 +634,6 @@ public class ActivityPermissions extends Activity
// action.getParameter2().contains("eu.faircode.netguard.STOP_PORT_FORWARD")
// )
// addToArrayListUnique("net.kollnig.missioncontrol.permission.ADMIN", requiredPermissions);
if(Build.VERSION.SDK_INT >= 29)
addToArrayListUnique(Manifest.permission.SYSTEM_ALERT_WINDOW, requiredPermissions);
break;
case triggerUrl:
addToArrayListUnique(Manifest.permission.INTERNET, requiredPermissions);
@ -878,7 +863,6 @@ 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;
@ -906,10 +890,6 @@ public class ActivityPermissions extends Activity
for(String ruleName : getRulesUsing(Action.Action_Enum.startPhoneCall))
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
break;
case Manifest.permission.SYSTEM_ALERT_WINDOW:
for(String ruleName : getRulesUsing(Action.Action_Enum.startOtherActivity))
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
break;
case Manifest.permission.ANSWER_PHONE_CALLS:
for(String ruleName : getRulesUsing(Action.Action_Enum.stopPhoneCall))
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
@ -1008,10 +988,6 @@ public class ActivityPermissions extends Activity
if (requestCode == requestCodeForPermissionsBatteryOptimization)
if(havePermission(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, ActivityPermissions.this))
requestPermissions(cachedPermissionsToRequest, true);
if (requestCode == requestCodeForPermissionsManageOverlay)
if(havePermission(Manifest.permission.SYSTEM_ALERT_WINDOW, ActivityPermissions.this))
requestPermissions(cachedPermissionsToRequest, true);
}
}
@ -1075,22 +1051,7 @@ public class ActivityPermissions extends Activity
cachedPermissionsToRequest = requiredPermissions;
Intent intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
startActivityForResult(intent, requestCodeForPermissionsNotificationPolicy);
return;
}
else if (s.equalsIgnoreCase(Manifest.permission.SYSTEM_ALERT_WINDOW))
{
AlertDialog diag = Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.overlayPermissionHint), ActivityPermissions.this);
diag.setOnDismissListener(new DialogInterface.OnDismissListener()
{
@Override
public void onDismiss(DialogInterface dialogInterface)
{
requiredPermissions.remove(s);
cachedPermissionsToRequest = requiredPermissions;
requestOverlay();
}
});
diag.show();
return;
}
else if (s.equalsIgnoreCase(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE))

View File

@ -3,9 +3,11 @@ package com.jens.automation2.receivers;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.PendingIntent;
import android.bluetooth.BluetoothDevice;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.util.Log;

View File

@ -6,15 +6,10 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.os.Build;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.util.Log;
import androidx.annotation.RequiresApi;
import com.jens.automation2.ActivityPermissions;
import com.jens.automation2.AutomationService;
import com.jens.automation2.Miscellaneous;
@ -27,7 +22,6 @@ import java.util.ArrayList;
public class PhoneStatusListener implements AutomationListenerInterface
{
static int problematicAndroidLevel = 29;
protected static String lastPhoneNumber="";
protected static int lastPhoneDirection = -1; //0=incoming, 1=outgoing
protected static int currentState = -1;
@ -76,13 +70,22 @@ public class PhoneStatusListener implements AutomationListenerInterface
return currentState;
}
public static interface IncomingCallsReceiver
public static class IncomingCallsReceiver extends PhoneStateListener
{
}
protected static void workWithIncomingCallData(int state, String incomingNumber)
@Override
public void onCallStateChanged(int state, String incomingNumber)
{
// Miscellaneous.logEvent("i", "Call state", "New call state: " + String.valueOf(state), 4);
/*
Unfortunately receivers for incoming and outgoing calls behave pretty differently:
The Outgoing-Receiver is called when starting a call (ringing)
It is not called when that outgoing call ends however, only the incoming receiver.
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)
{
// This status update is actually for an outgoing call
@ -144,61 +147,6 @@ public class PhoneStatusListener implements AutomationListenerInterface
}
}
}
public static class IncomingCallsReceiverOld extends PhoneStateListener implements IncomingCallsReceiver
{
@Override
public void onCallStateChanged(int state, String incomingNumber)
{
// Miscellaneous.logEvent("i", "Call state", "New call state: " + String.valueOf(state), 4);
/*
Unfortunately receivers for incoming and outgoing calls behave pretty differently:
The Outgoing-Receiver is called when starting a call (ringing)
It is not called when that outgoing call ends however, only the incoming receiver.
If the last call was outgoing the state has not changed to idle this is kind of a fake alert.
*/
workWithIncomingCallData(state, incomingNumber);
}
}
@RequiresApi(api = Build.VERSION_CODES.S)
public static class IncomingCallsReceiverNew extends BroadcastReceiver implements IncomingCallsReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
/*
this code detects both incoming and outgoing,
if the state changes idle => ringing you know it's an incoming call,
if the state changes idle => offhook, you know it's an outgoing call
*/
if (!intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL))
{
String stateStr = intent.getExtras().getString(TelephonyManager.EXTRA_STATE);
int state = 99;
switch(stateStr)
{
case "RINGING":
state = TelephonyManager.CALL_STATE_RINGING;
break;
case "IDLE":
state = TelephonyManager.CALL_STATE_IDLE;
break;
case "OFFHOOK":
state = TelephonyManager.CALL_STATE_OFFHOOK;
break;
}
String number = intent.getExtras().getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
Log.i("test", "test");
}
}
}
static void setLastPhoneDirection(int i)
@ -253,12 +201,7 @@ public class PhoneStatusListener implements AutomationListenerInterface
}
if(incomingCallsReceiverInstance == null)
{
// if(Build.VERSION.SDK_INT >= 31)
// incomingCallsReceiverInstance = new IncomingCallsReceiverNew();
// else
incomingCallsReceiverInstance = new IncomingCallsReceiverOld();
}
incomingCallsReceiverInstance = new IncomingCallsReceiver();
if(outgoingCallsReceiverInstance == null)
outgoingCallsReceiverInstance = new OutgoingCallsReceiver();
@ -268,17 +211,8 @@ 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
// {
TelephonyManager tm = (TelephonyManager)automationService.getSystemService(Context.TELEPHONY_SERVICE);
tm.listen((IncomingCallsReceiverOld)incomingCallsReceiverInstance, PhoneStateListener.LISTEN_CALL_STATE);
// }
tm.listen(incomingCallsReceiverInstance, PhoneStateListener.LISTEN_CALL_STATE);
incomingCallsReceiverActive = true;
}
@ -302,15 +236,8 @@ 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
// {
TelephonyManager tm = (TelephonyManager)automationService.getSystemService(Context.TELEPHONY_SERVICE);
tm.listen((IncomingCallsReceiverOld)incomingCallsReceiverInstance, PhoneStateListener.LISTEN_NONE);
// }
tm.listen(incomingCallsReceiverInstance, PhoneStateListener.LISTEN_NONE);
incomingCallsReceiverActive = false;
}

View File

@ -793,7 +793,4 @@
<string name="wifiMonitoringAlsoRequiresThis">Diese Berechtigung wird auch benötigt, wenn man die aktuelle WLAN Verbindung auslesen möchte.</string>
<string name="copyTextToClipboard">Text in die Zwischenablage kopieren</string>
<string name="textToCopy">Text, der kopiert werden soll</string>
<string name="android.permission.SYSTEM_ALERT_WINDOW">Über anderen Anwendungen anzeigen</string>
<string name="overlayPermissionHint">Nachdem Sie auf OK geklickt haben, werden Sie zu einem Systemdialog weitergeleitet. Bitte wählen Sie dort Automation aus und erlauben Sie die Anzeige über anderen Apps.</string>
<string name="overlayPermissionHint">Nachdem Sie auf OK geklickt haben, werden Sie zu einem Systemdialog weitergeleitet. Bitte wählen Sie dort Automatisierung aus und lassen Sie das Zeichnen über andere Apps zu.</string>
</resources>

View File

@ -792,6 +792,4 @@
<string name="wifiMonitoringAlsoRequiresThis">Este permiso también es necesario si el disparador está utilizando la conexión wifi actual.</string>
<string name="copyTextToClipboard">Copiar texto al portapapeles</string>
<string name="textToCopy">Texto para copiar</string>
<string name="android.permission.SYSTEM_ALERT_WINDOW">Dibujar encima otras aplicaciones</string>
<string name="overlayPermissionHint">Después de hacer cliquear en Aceptar, se le enviará a un cuadro de diálogo del sistema. Seleccione Automation allí y permita dibujar encima otras aplicaciones.</string>
</resources>

View File

@ -792,6 +792,4 @@
<string name="wifiMonitoringAlsoRequiresThis">Cette autorisation est également requise si le déclencheur utilise la connexion wifi actuelle.</string>
<string name="copyTextToClipboard">Copier du texte dans le presse-papiers</string>
<string name="textToCopy">Texte à copier</string>
<string name="android.permission.SYSTEM_ALERT_WINDOW">Dessiner sur d\'autres applications</string>
<string name="overlayPermissionHint">Après avoir cliqué sur OK, vous serez redirigé vers une boîte de dialogue système. Veuillez sélectionner Automatisation et autoriser le tirage sur d\'autres applications.</string>
</resources>

View File

@ -793,6 +793,4 @@
<string name="wifiMonitoringAlsoRequiresThis">Questa autorizzazione è necessaria anche se il trigger utilizza la connessione wifi corrente.</string>
<string name="copyTextToClipboard">Copiare testo negli appunti</string>
<string name="textToCopy">Testo da copiare</string>
<string name="android.permission.SYSTEM_ALERT_WINDOW">Disegna su altre app</string>
<string name="overlayPermissionHint">Dopo aver fatto clic su OK, verrai indirizzato a una finestra di dialogo di sistema. Seleziona Automazione lì e consenti il disegno su altre app.</string>
</resources>

View File

@ -791,7 +791,5 @@
<string name="wifiMonitoringAlsoRequiresThis">Deze toestemming is ook vereist als de trigger de huidige wifi-verbinding gebruikt.</string>
<string name="copyTextToClipboard">Tekst naar klembord kopiëren</string>
<string name="textToCopy">Tekst om te kopiëren</string>
<string name="android.permission.SYSTEM_ALERT_WINDOW">Tekenen over andere apps</string>
<string name="overlayPermissionHint">Nadat u op OK hebt geklikt, wordt u naar een systeemdialoogvenster gestuurd. Selecteer daar Automatisering en sta tekenen toe over andere apps.</string>
</resources>

View File

@ -850,6 +850,4 @@
<string name="wifiMonitoringAlsoRequiresThis">Это разрешение также требуется, если триггер использует текущее соединение Wi-Fi.</string>
<string name="copyTextToClipboard">Копирование текста в буфер обмена</string>
<string name="textToCopy">Текст для копирования</string>
<string name="android.permission.SYSTEM_ALERT_WINDOW">Рисование поверх других приложений</string>
<string name="overlayPermissionHint">После нажатия кнопки «ОК» вы попадете в системный диалог. Пожалуйста, выберите там «Автоматизация» и разрешите рисовать поверх других приложений.</string>
</resources>

View File

@ -882,6 +882,4 @@
<string name="wifiMonitoringAlsoRequiresThis">This permission is also required if the trigger is using the current wifi connection.</string>
<string name="copyTextToClipboard">Copy text to clipboard</string>
<string name="textToCopy">Text to copy</string>
<string name="android.permission.SYSTEM_ALERT_WINDOW">Draw over other apps</string>
<string name="overlayPermissionHint">After clicking OK you\'ll be sent to a system dialog. Please select Automation there and allow "draw over other apps".</string>
</resources>

View File

@ -1,2 +0,0 @@
* Fixed: Introduced overlay permission to enable startActivity() to work from the background
* Fixed: Phone number available as variable again (permission READ_CALL_LOGS required)