forked from jens/Automation
Compare commits
139 Commits
developmen
...
master
Author | SHA1 | Date |
---|---|---|
|
4c66fe906e | |
|
60cfa150b5 | |
|
bd2231b075 | |
|
158f5f2e04 | |
|
f1315dc742 | |
|
28aa0c3e4b | |
|
6b9dbca7ab | |
|
291e0c41af | |
|
c9eedd5d87 | |
|
2470321e15 | |
|
d85a199117 | |
|
b047cde4ea | |
|
9a1796f2eb | |
|
7e8a6b121e | |
|
810c7488c4 | |
|
8af24695fd | |
|
533a9bf54d | |
|
8653e4853b | |
|
c464a9d71f | |
|
26e4851c0d | |
|
11f0ee25bf | |
|
a76cafc6e2 | |
|
bd2920e6d9 | |
|
5caf33b45d | |
|
6a74d070eb | |
|
eba02ade08 | |
|
394effea36 | |
|
4d51f1890a | |
|
a8b2c3bf7d | |
|
d1c6abaa91 | |
|
587ed5803e | |
|
49d272be1e | |
|
d9e54c7780 | |
|
170dbbc7e8 | |
|
3fc1dd1a26 | |
|
0acb52099c | |
|
b6015a3f2e | |
|
ae1e767fa6 | |
|
6e12e71133 | |
|
e4e3faea06 | |
|
7c42250e13 | |
|
ebb0724b28 | |
|
a7ae0c6588 | |
|
e5433bf2ec | |
|
fd8ffd4f7d | |
|
f49455712a | |
|
132f64114e | |
|
27e9b3e0d1 | |
|
a6c6dfc6ba | |
|
6a7875cc61 | |
|
6f80caa1c6 | |
|
a9646cbf28 | |
|
52edfa32df | |
|
ca81e6a7bd | |
|
49e4c20ab6 | |
|
ab98b4d1db | |
|
6b32301894 | |
|
d9cdfab828 | |
|
62a8723344 | |
|
2b69938ad5 | |
|
c42f65bd3a | |
|
ad0d9962b5 | |
|
58f24953f3 | |
|
3d212456e6 | |
|
fff0a28310 | |
|
48da91cb40 | |
|
98df050f42 | |
|
93cb72ac2f | |
|
713228c06e | |
|
c868d45896 | |
|
4abce042eb | |
|
62034e1b10 | |
|
135f4594be | |
|
900aaf3c8c | |
|
5baa40ed59 | |
|
759e8076c3 | |
|
17b9f19dc2 | |
|
374a5c4263 | |
|
2fd79140cb | |
|
a0910e620f | |
|
475c1719d7 | |
|
baa39c7a77 | |
|
e11cc09da2 | |
|
eff04037a1 | |
|
b73a45f4cd | |
|
fad6050c7a | |
|
8a00529991 | |
|
1d7cf00b94 | |
|
d74e2eae68 | |
|
4f7c36c4f7 | |
|
b0df3efa27 | |
|
f99418fda3 | |
|
e05a42f5d6 | |
|
83a27dcfdb | |
|
bdc89a855b | |
|
7ce203a679 | |
|
57bc666453 | |
|
c966981eae | |
|
7a05b9a95b | |
|
7fdbf74906 | |
|
d17e8b70fe | |
|
f97bfbb732 | |
|
937c6ffe1d | |
|
1ecc61452f | |
|
19fd2d098b | |
|
d07c1a05e4 | |
|
f9f9b30116 | |
|
d154a3d64f | |
|
eeb4f4a39e | |
|
53e62068a5 | |
|
922807d903 | |
|
a7d294c115 | |
|
2d2fd901a1 | |
|
536a5e22f9 | |
|
99faa2f7ef | |
|
f3fac2f4e8 | |
|
b3b713e454 | |
|
b0d509aafe | |
|
efb4919a1e | |
|
7bc858fee3 | |
|
647d5bd511 | |
|
f1f3be56cb | |
|
5856c93fc8 | |
|
8201b1d4e4 | |
|
ce9480d188 | |
|
a69bbb1e05 | |
|
16817e6f53 | |
|
26ed906521 | |
|
d1ca9ab56b | |
|
9c76340f24 | |
|
aca5572f40 | |
|
944e165dd0 | |
|
7f2fc4b5de | |
|
cd163afc47 | |
|
6179f0e9ae | |
|
581cdafb87 | |
|
9162bcb451 | |
|
5272b56032 | |
|
92e58149a7 |
|
@ -145,7 +145,7 @@ fabric.properties
|
|||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/androidstudio
|
||||
|
||||
|
||||
output-metadata.json
|
||||
/app/app-release.apk
|
||||
Automation_settings.xml
|
||||
/app/googlePlayFlavor/
|
||||
|
|
|
@ -11,8 +11,8 @@ android {
|
|||
compileSdkVersion 31
|
||||
buildToolsVersion '29.0.2'
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
versionCode 120
|
||||
versionName "1.7.6"
|
||||
versionCode 133
|
||||
versionName "1.7.17"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
@ -36,9 +36,15 @@ android {
|
|||
{
|
||||
dimension "version"
|
||||
versionNameSuffix "-googlePlay"
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 31
|
||||
}
|
||||
|
||||
/*
|
||||
targetSdkVersion is kept at 28 for as long as possible.
|
||||
If raised wifi cannot be switched on or off anymore without root permissions.
|
||||
In the Google version I'm forced to raise the value regularly.
|
||||
*/
|
||||
|
||||
fdroidFlavor
|
||||
{
|
||||
dimension "version"
|
||||
|
@ -72,9 +78,9 @@ dependencies {
|
|||
|
||||
//implementation "androidx.security:security-crypto:1.0.0"
|
||||
//implementation "androidx.security:security-identity-credential:1.0.0-alpha02"
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.2'
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
testImplementation 'junit:junit:4'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.jens.automation2",
|
||||
"variantName": "googlePlayFlavorRelease",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 119,
|
||||
"versionName": "1.7.5-googlePlay",
|
||||
"outputFile": "app-googlePlayFlavor-release.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
|
@ -66,6 +66,10 @@
|
|||
<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.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"
|
||||
|
@ -169,6 +173,13 @@
|
|||
<activity android:name=".ActivityManageActionRunExecutable" />
|
||||
<activity android:name=".ActivityManageActionWifi" />
|
||||
<activity android:name=".ActivityManageTriggerTethering" />
|
||||
<activity android:name=".ActivityManageActionWakeLock" />
|
||||
<activity android:name=".ActivityManageTriggerSubSystemState" />
|
||||
<activity android:name=".ActivityManageActionMakePhoneCall" />
|
||||
<activity android:name=".ActivityManageActionSetVariable" />
|
||||
<activity android:name=".ActivityManageTriggerCheckVariable" />
|
||||
<activity android:name=".ActivityManageActionCopyToClipboard" />
|
||||
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:launchMode="singleTask">
|
||||
|
|
|
@ -107,7 +107,7 @@ public class Rule implements Comparable<Rule>
|
|||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
this.name = name.trim();
|
||||
}
|
||||
|
||||
public static void readFromFile()
|
||||
|
@ -347,7 +347,16 @@ public class Rule implements Comparable<Rule>
|
|||
if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.timeFrame))
|
||||
{
|
||||
if(oneTrigger.getTimeFrame().repetition > 0)
|
||||
return true;
|
||||
{
|
||||
if(this.getLastExecution() != null)
|
||||
{
|
||||
Calendar now = Calendar.getInstance();
|
||||
if (this.getLastExecution().getTimeInMillis() + oneTrigger.getTimeFrame().getRepetition() * 1000 <= now.getTimeInMillis())
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.broadcastReceived))
|
||||
{
|
||||
|
@ -396,7 +405,7 @@ public class Rule implements Comparable<Rule>
|
|||
return true;
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -467,7 +476,9 @@ public class Rule implements Comparable<Rule>
|
|||
{
|
||||
AutomationService service = AutomationService.getInstance();
|
||||
service.speak(messages[0], false);
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
if(Settings.showToasts)
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
super.onProgressUpdate(messages);
|
||||
}
|
||||
|
|
|
@ -64,6 +64,10 @@
|
|||
<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.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"
|
||||
|
@ -167,6 +171,12 @@
|
|||
<activity android:name=".ActivityManageActionRunExecutable" />
|
||||
<activity android:name=".ActivityManageActionWifi" />
|
||||
<activity android:name=".ActivityManageTriggerTethering" />
|
||||
<activity android:name=".ActivityManageActionWakeLock" />
|
||||
<activity android:name=".ActivityManageTriggerSubSystemState" />
|
||||
<activity android:name=".ActivityManageActionMakePhoneCall" />
|
||||
<activity android:name=".ActivityManageActionSetVariable" />
|
||||
<activity android:name=".ActivityManageTriggerCheckVariable" />
|
||||
<activity android:name=".ActivityManageActionCopyToClipboard" />
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:launchMode="singleTask">
|
||||
|
|
|
@ -104,7 +104,7 @@ public class Rule implements Comparable<Rule>
|
|||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
this.name = name.trim();
|
||||
}
|
||||
|
||||
public static void readFromFile()
|
||||
|
@ -393,7 +393,7 @@ public class Rule implements Comparable<Rule>
|
|||
return true;
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -440,7 +440,9 @@ public class Rule implements Comparable<Rule>
|
|||
{
|
||||
AutomationService service = AutomationService.getInstance();
|
||||
service.speak(messages[0], false);
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
if(Settings.showToasts)
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
super.onProgressUpdate(messages);
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
<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"
|
||||
|
@ -111,6 +113,7 @@
|
|||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".receivers.PackageReplacedReceiver"
|
||||
android:exported="true"
|
||||
android:enabled="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
|
@ -122,6 +125,7 @@
|
|||
|
||||
<receiver
|
||||
android:name=".DeviceAdmin"
|
||||
android:exported="true"
|
||||
android:description="@string/app_name"
|
||||
android:label="@string/app_name"
|
||||
android:permission= "android.permission.BIND_DEVICE_ADMIN" >
|
||||
|
@ -154,8 +158,14 @@
|
|||
<activity android:name=".ActivityManageActionRunExecutable" />
|
||||
<activity android:name=".ActivityManageActionWifi" />
|
||||
<activity android:name=".ActivityManageTriggerTethering" />
|
||||
<activity android:name=".ActivityManageActionWakeLock" />
|
||||
<activity android:name=".ActivityManageTriggerSubSystemState" />
|
||||
<activity android:name=".ActivityManageActionSetVariable" />
|
||||
<activity android:name=".ActivityManageTriggerCheckVariable" />
|
||||
<activity android:name=".ActivityManageActionCopyToClipboard" />
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -204,6 +214,7 @@
|
|||
|
||||
<service
|
||||
android:name=".receivers.NotificationListener"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
|
||||
<intent-filter>
|
||||
|
|
|
@ -107,7 +107,7 @@ public class Rule implements Comparable<Rule>
|
|||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
this.name = name.trim();
|
||||
}
|
||||
|
||||
public static void readFromFile()
|
||||
|
@ -396,7 +396,7 @@ public class Rule implements Comparable<Rule>
|
|||
return true;
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,9 @@ public class Rule implements Comparable<Rule>
|
|||
{
|
||||
AutomationService service = AutomationService.getInstance();
|
||||
service.speak(messages[0], false);
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
if(Settings.showToasts)
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
super.onProgressUpdate(messages);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
|
||||
|
||||
</manifest>
|
|
@ -6,8 +6,6 @@ import android.os.Build;
|
|||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
|
||||
|
@ -53,6 +51,11 @@ public class Action
|
|||
closeNotification,
|
||||
sendBroadcast,
|
||||
runExecutable,
|
||||
wakelock,
|
||||
setVariable,
|
||||
startPhoneCall,
|
||||
stopPhoneCall,
|
||||
copyToClipboard,
|
||||
sendTextMessage;
|
||||
|
||||
public String getFullName(Context context)
|
||||
|
@ -127,6 +130,16 @@ public class Action
|
|||
return context.getResources().getString(R.string.sendBroadcast);
|
||||
case runExecutable:
|
||||
return context.getResources().getString(R.string.runExecutable);
|
||||
case wakelock:
|
||||
return context.getResources().getString(R.string.keepDeviceAwake);
|
||||
case setVariable:
|
||||
return context.getResources().getString(R.string.setVariable);
|
||||
case startPhoneCall:
|
||||
return context.getResources().getString(R.string.startPhoneCall);
|
||||
case stopPhoneCall:
|
||||
return context.getResources().getString(R.string.endPhoneCall);
|
||||
case copyToClipboard:
|
||||
return context.getResources().getString(R.string.copyTextToClipboard);
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
@ -273,6 +286,27 @@ public class Action
|
|||
case runExecutable:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.runExecutable));
|
||||
break;
|
||||
case wakelock:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.keepDeviceAwake) + " (" + String.valueOf(getParameter1()) + ")");
|
||||
break;
|
||||
case setVariable:
|
||||
String[] variableParams = getParameter2().split(actionParameter2Split);
|
||||
String addition;
|
||||
if (variableParams.length >= 2)
|
||||
addition = " (key: " + variableParams[0] + ", value: " + variableParams[1] + ")";
|
||||
else
|
||||
addition = " (delete key: " + variableParams[0] + ")";
|
||||
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.setVariable) + addition);
|
||||
break;
|
||||
case startPhoneCall:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.startPhoneCall));
|
||||
break;
|
||||
case stopPhoneCall:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.endPhoneCall));
|
||||
break;
|
||||
case copyToClipboard:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.copyTextToClipboard));
|
||||
default:
|
||||
returnString.append(action.toString());
|
||||
}
|
||||
|
@ -330,17 +364,25 @@ public class Action
|
|||
|
||||
if (parts.length > 4 && !StringUtils.isBlank(parts[4]))
|
||||
returnString.append(", " + Miscellaneous.getAnyContext().getResources().getString(R.string.ifString) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.text) + " " + Trigger.getMatchString(parts[3]) + " " + parts[4]);
|
||||
|
||||
if (parts.length >= 6)
|
||||
{
|
||||
if (!parts[5].equals(ActivityManageActionCloseNotification.dismissRegularString))
|
||||
{
|
||||
returnString.append(" " + String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.withButton), parts[5]));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(this.getAction().equals(Action_Enum.setWifi))
|
||||
else if (this.getAction().equals(Action_Enum.setWifi))
|
||||
{
|
||||
if(!StringUtils.isEmpty(this.parameter2))
|
||||
if (!StringUtils.isEmpty(this.parameter2))
|
||||
{
|
||||
boolean useRoot = Boolean.parseBoolean(this.parameter2);
|
||||
if(useRoot)
|
||||
if (useRoot)
|
||||
returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.usingRoot));
|
||||
}
|
||||
}
|
||||
else if(this.getAction().equals(Action_Enum.controlMediaPlayback))
|
||||
else if (this.getAction().equals(Action_Enum.controlMediaPlayback))
|
||||
{
|
||||
returnString.append(": ");
|
||||
|
||||
|
@ -368,6 +410,12 @@ public class Action
|
|||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.unknown));
|
||||
}
|
||||
}
|
||||
else if (this.getAction().equals(Action_Enum.sendBroadcast))
|
||||
{
|
||||
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; ").replace(Action.intentPairSeparator, "/"));
|
||||
}
|
||||
else if(this.getAction().equals(Action_Enum.setVariable) || this.getAction().equals(Action_Enum.copyToClipboard))
|
||||
; // it's completed further above already
|
||||
else if (parameter2 != null && parameter2.length() > 0)
|
||||
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; "));
|
||||
}
|
||||
|
@ -481,7 +529,7 @@ public class Action
|
|||
Actions.setUsbTethering(context, getParameter1(), toggleActionIfPossible);
|
||||
break;
|
||||
case setWifi:
|
||||
Actions.WifiStuff.setWifi(context, getParameter1(), toggleActionIfPossible);
|
||||
Actions.WifiStuff.setWifi(context, getParameter1(), getParameter2(), toggleActionIfPossible);
|
||||
break;
|
||||
case setWifiTethering:
|
||||
Actions.setWifiTethering(context, getParameter1(), toggleActionIfPossible);
|
||||
|
@ -566,6 +614,24 @@ public class Action
|
|||
else if(execParts.length == 2)
|
||||
Actions.runExecutable(context, this.getParameter1(), execParts[0], execParts[1]);
|
||||
break;
|
||||
case wakelock:
|
||||
if(this.getParameter1())
|
||||
Actions.wakeLockStart(context, Long.parseLong(this.getParameter2()));
|
||||
else
|
||||
Actions.wakeLockStop();
|
||||
break;
|
||||
case setVariable:
|
||||
Actions.setVariable(this.getParameter2());
|
||||
break;
|
||||
case startPhoneCall:
|
||||
Actions.startPhoneCall(context, this.getParameter2());
|
||||
break;
|
||||
case stopPhoneCall:
|
||||
Actions.endPhoneCall(context);
|
||||
break;
|
||||
case copyToClipboard:
|
||||
Actions.copyToClipboard(context, Miscellaneous.replaceVariablesInText(this.getParameter2(), context));
|
||||
break;
|
||||
default:
|
||||
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
|
||||
break;
|
||||
|
@ -592,7 +658,7 @@ public class Action
|
|||
password = components[1];
|
||||
url = components[2];
|
||||
}
|
||||
else
|
||||
else // compatibility for very old versions which haven't upgraded, yet.
|
||||
url = components[0];
|
||||
|
||||
try
|
||||
|
|
|
@ -10,13 +10,10 @@ import android.bluetooth.BluetoothAdapter;
|
|||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer;
|
||||
import android.media.session.MediaController;
|
||||
import android.media.session.MediaSessionManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
@ -26,8 +23,8 @@ import android.os.PowerManager.WakeLock;
|
|||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.MediaStore;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.telecom.TelecomManager;
|
||||
import android.telephony.SmsManager;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
@ -70,6 +67,7 @@ import java.util.Collections;
|
|||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -82,10 +80,6 @@ public class Actions
|
|||
public static AutomationService automationServerRef;
|
||||
public static Context context;
|
||||
private static Intent playMusicIntent;
|
||||
private static boolean suAvailable = false;
|
||||
private static String suVersion = null;
|
||||
private static String suVersionInternal = null;
|
||||
private static List<String> suResult = null;
|
||||
public final static String smsSeparator = "&sms&";
|
||||
public final static String dummyPackageString = "dummyPkg239asd";
|
||||
|
||||
|
@ -99,6 +93,7 @@ public class Actions
|
|||
|
||||
Miscellaneous.logEvent("w", "createNotification", "Creating notification with title " + elements[0] + " and text " + elements[1], 3);
|
||||
|
||||
// Create a new notification ID each time
|
||||
int notificationId = Math.round(Calendar.getInstance().getTimeInMillis()/1000);
|
||||
|
||||
try
|
||||
|
@ -117,8 +112,8 @@ public class Actions
|
|||
public static void closeNotification(Action action)
|
||||
{
|
||||
NotificationManager nm = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
for(StatusBarNotification n : nm.getActiveNotifications())
|
||||
{
|
||||
// for(StatusBarNotification n : nm.getActiveNotifications())
|
||||
// {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
||||
{
|
||||
String[] params = action.getParameter2().split(Action.actionParameter2Split);
|
||||
|
@ -127,11 +122,14 @@ public class Actions
|
|||
String myTitleDir = params[1];
|
||||
String requiredTitle = params[2];
|
||||
String myTextDir = params[3];
|
||||
String requiredText;
|
||||
if (params.length >= 5)
|
||||
String requiredText = "";
|
||||
String method = ActivityManageActionCloseNotification.dismissRegularString;
|
||||
|
||||
if(params.length >= 5)
|
||||
requiredText = params[4];
|
||||
else
|
||||
requiredText = "";
|
||||
|
||||
if(params.length >= 6 && !params[5].equals(ActivityManageActionCloseNotification.dismissRegularString))
|
||||
method = params[5];
|
||||
|
||||
for (StatusBarNotification sbn : NotificationListener.getInstance().getActiveNotifications())
|
||||
{
|
||||
|
@ -185,12 +183,17 @@ public class Actions
|
|||
|
||||
Miscellaneous.logEvent("i", "NotificationCloseCheck", "All criteria matches. Closing notification: " + sbn.getNotification().toString(), 3);
|
||||
if(NotificationListener.getInstance() != null)
|
||||
NotificationListener.getInstance().dismissNotification(sbn);
|
||||
{
|
||||
if(method == ActivityManageActionCloseNotification.dismissRegularString)
|
||||
NotificationListener.getInstance().dismissNotification(sbn);
|
||||
else
|
||||
NotificationListener.getInstance().clickNotificationButton(sbn, method);
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("i", "NotificationCloseCheck", "NotificationListener instance is null. Can\'t close notification.", 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
public static void sendBroadcast(Context context, String action)
|
||||
|
@ -202,7 +205,9 @@ public class Actions
|
|||
{
|
||||
String[] parts = action.split(Action.actionParameter2Split);
|
||||
broadcastIntent.setAction(parts[0]);
|
||||
add params
|
||||
|
||||
String[] intentparts = parts[1].split(";");
|
||||
broadcastIntent = packParametersIntoIntent(broadcastIntent, intentparts, 0);
|
||||
}
|
||||
else
|
||||
broadcastIntent.setAction(action);
|
||||
|
@ -210,11 +215,50 @@ public class Actions
|
|||
context.sendBroadcast(broadcastIntent);
|
||||
}
|
||||
|
||||
public static class WifiStuff
|
||||
public static void setVariable(String parameter2)
|
||||
{
|
||||
public static Boolean setWifi(Context context, Boolean desiredState, boolean toggleActionIfPossible)
|
||||
String[] parts = parameter2.split(Action.actionParameter2Split);
|
||||
|
||||
if(AutomationService.isMyServiceRunning(Miscellaneous.getAnyContext()))
|
||||
{
|
||||
if(context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q)
|
||||
Map<String,String> map = AutomationService.getInstance().getVariableMap();
|
||||
|
||||
if(parts.length > 1)
|
||||
map.put(parts[0], parts[1]);
|
||||
else
|
||||
map.remove(parts[0]);
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "Variable", "Checking for applicable rules after variable has been set or deleted.", 2);
|
||||
List<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.checkVariable);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
if(ruleCandidates.get(i).haveEnoughPermissions() && ruleCandidates.get(i).getsGreenLight(AutomationService.getInstance()))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Variable", "Rule " + ruleCandidates.get(i).getName() + " applies after variable has been set or deleted.", 2);
|
||||
ruleCandidates.get(i).activate(AutomationService.getInstance(), false);
|
||||
}
|
||||
}
|
||||
Miscellaneous.logEvent("i", "Variable", "Done checking for applicable rules after variable has been set or deleted.", 2);
|
||||
|
||||
}
|
||||
|
||||
public static class WifiStuff
|
||||
{
|
||||
public static Boolean setWifi(Context context, Boolean desiredState, String parameter2, boolean toggleActionIfPossible)
|
||||
{
|
||||
boolean forceUseRoot = false;
|
||||
|
||||
try
|
||||
{
|
||||
forceUseRoot = Boolean.parseBoolean(parameter2);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if(context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q || forceUseRoot)
|
||||
return setWifiWithRoot(context, desiredState, toggleActionIfPossible);
|
||||
else
|
||||
return setWifiOldFashioned(context, desiredState, toggleActionIfPossible);
|
||||
|
@ -250,8 +294,15 @@ public class Actions
|
|||
{
|
||||
Miscellaneous.logEvent("i", "Wifi", "Changing wifi to " + String.valueOf(desiredState), 4);
|
||||
|
||||
if (desiredState && Settings.useWifiForPositioning)
|
||||
WifiBroadcastReceiver.startWifiReceiver(automationServerRef.getLocationProvider());
|
||||
try
|
||||
{
|
||||
if (desiredState && Settings.useWifiForPositioning)
|
||||
WifiBroadcastReceiver.startWifiReceiver(automationServerRef.getLocationProvider());
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("w", "setWifiOldFashioned()", Log.getStackTraceString(e), 4);
|
||||
}
|
||||
|
||||
WifiManager myWifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
|
||||
|
@ -779,29 +830,21 @@ public class Actions
|
|||
return false;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
public static void setDoNotDisturb(Context context, int desiredSetting)
|
||||
public static void setDoNotDisturb(Context context, int desiredDndMode)
|
||||
{
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
// Check if the notification policy access has been granted for the app.
|
||||
/* if (!notificationManager.isNotificationPolicyAccessGranted())
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
{
|
||||
Intent intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
|
||||
startActivity(intent);
|
||||
return;
|
||||
}*/
|
||||
/*
|
||||
if (!notificationManager.isNotificationPolicyAccessGranted())
|
||||
--> done externally
|
||||
*/
|
||||
|
||||
notificationManager.setInterruptionFilter(desiredSetting);
|
||||
|
||||
/*if (notificationManager.getCurrentInterruptionFilter() == NotificationManager.INTERRUPTION_FILTER_ALL)
|
||||
{
|
||||
notificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_NONE);
|
||||
Miscellaneous.logEvent("i", context.getResources().getString(R.string.soundSettings), "Changing DND to " + String.valueOf(desiredDndMode), 4);
|
||||
NotificationManager mNotificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.setInterruptionFilter(desiredDndMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
notificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALL);
|
||||
}*/
|
||||
Miscellaneous.logEvent("w", context.getResources().getString(R.string.soundSettings), "Cannot change DND to " + String.valueOf(desiredDndMode) + ". This Android version is too and doesn\'t have that feature, yet.", 4);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
|
@ -938,18 +981,6 @@ public class Actions
|
|||
}
|
||||
}
|
||||
|
||||
public static void setDND(Context context, int desiredDndMode)
|
||||
{
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
{
|
||||
Miscellaneous.logEvent("i", context.getResources().getString(R.string.soundSettings), "Changing DND to " + String.valueOf(desiredDndMode), 4);
|
||||
NotificationManager mNotificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.setInterruptionFilter(desiredDndMode);
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("w", context.getResources().getString(R.string.soundSettings), "Cannot change DND to " + String.valueOf(desiredDndMode) + ". This Android version is too and doesn\'t have that feature, yet.", 4);
|
||||
}
|
||||
|
||||
public void useDownloadedWebpage(String result)
|
||||
{
|
||||
// Toast.makeText(context, "Result: " + result, Toast.LENGTH_LONG).show();
|
||||
|
@ -1017,8 +1048,6 @@ public class Actions
|
|||
{
|
||||
Intent externalActivityIntent;
|
||||
|
||||
int paramsStartIndex;
|
||||
|
||||
if (!startByAction)
|
||||
{
|
||||
// selected by activity
|
||||
|
@ -1030,8 +1059,6 @@ public class Actions
|
|||
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by activity: " + packageName + " " + className, 3);
|
||||
|
||||
paramsStartIndex = 2;
|
||||
|
||||
externalActivityIntent = new Intent(Intent.ACTION_MAIN);
|
||||
externalActivityIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
|
||||
|
@ -1059,9 +1086,27 @@ public class Actions
|
|||
externalActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
// Pack intents
|
||||
for (int i = 3; i < params.length; i++)
|
||||
{
|
||||
String[] singleParam = params[i].split(Action.intentPairSeparator);
|
||||
externalActivityIntent = packParametersIntoIntent(externalActivityIntent, params, 3);
|
||||
|
||||
if (params[2].equals(ActivityManageActionStartActivity.startByActivityString))
|
||||
automationServerRef.startActivity(externalActivityIntent);
|
||||
if (params[2].equals(ActivityManageActionStartActivity.startByServiceString))
|
||||
automationServerRef.startService(externalActivityIntent);
|
||||
else
|
||||
automationServerRef.sendBroadcast(externalActivityIntent);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "StartOtherApp", automationServerRef.getResources().getString(R.string.errorStartingOtherActivity) + ": " + Log.getStackTraceString(e), 2);
|
||||
Toast.makeText(automationServerRef, automationServerRef.getResources().getString(R.string.errorStartingOtherActivity) + ": " + e.getMessage(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
public static Intent packParametersIntoIntent(Intent intent, String[] params, int startIndex)
|
||||
{
|
||||
for (int i = startIndex; i < params.length; i++)
|
||||
{
|
||||
String[] singleParam = params[i].split(Action.intentPairSeparator);
|
||||
|
||||
/*Class c = Class.forName(singleParam[0]);
|
||||
for(Method m : c.getMethods())
|
||||
|
@ -1073,83 +1118,89 @@ public class Actions
|
|||
}
|
||||
}*/
|
||||
|
||||
if (singleParam[0].equals("boolean"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
externalActivityIntent.putExtra(singleParam[1], Boolean.parseBoolean(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("byte"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
externalActivityIntent.putExtra(singleParam[1], Byte.parseByte(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("char"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
externalActivityIntent.putExtra(singleParam[1], singleParam[2].charAt(0));
|
||||
}
|
||||
else if (singleParam[0].equals("CharSequence"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
externalActivityIntent.putExtra(singleParam[1], (CharSequence) singleParam[2]);
|
||||
}
|
||||
else if (singleParam[0].equals("double"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
externalActivityIntent.putExtra(singleParam[1], Double.parseDouble(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("float"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
externalActivityIntent.putExtra(singleParam[1], Float.parseFloat(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("int"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
externalActivityIntent.putExtra(singleParam[1], Integer.parseInt(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("long"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
externalActivityIntent.putExtra(singleParam[1], Long.parseLong(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("short"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
externalActivityIntent.putExtra(singleParam[1], Short.parseShort(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("Uri"))
|
||||
if (singleParam[0].equals("boolean"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
intent.putExtra(singleParam[1], Boolean.parseBoolean(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("byte"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
intent.putExtra(singleParam[1], Byte.parseByte(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("char"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
intent.putExtra(singleParam[1], singleParam[2].charAt(0));
|
||||
}
|
||||
else if (singleParam[0].equals("CharSequence"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
intent.putExtra(singleParam[1], (CharSequence) singleParam[2]);
|
||||
}
|
||||
else if (singleParam[0].equals("double"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
intent.putExtra(singleParam[1], Double.parseDouble(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("float"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
intent.putExtra(singleParam[1], Float.parseFloat(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("int"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
intent.putExtra(singleParam[1], Integer.parseInt(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("long"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
intent.putExtra(singleParam[1], Long.parseLong(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("short"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
intent.putExtra(singleParam[1], Short.parseShort(singleParam[2]));
|
||||
}
|
||||
else if (singleParam[0].equals("Uri"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (singleParam[1].equalsIgnoreCase("IntentData"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with value " + singleParam[2] + " as standard data parameter.", 3);
|
||||
externalActivityIntent.setData(Uri.parse(singleParam[2]));
|
||||
intent.setData(Uri.parse(Miscellaneous.replaceVariablesInText(singleParam[2], context)));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
externalActivityIntent.putExtra(singleParam[1], Uri.parse(singleParam[2]));
|
||||
intent.putExtra(singleParam[1], Uri.parse(Miscellaneous.replaceVariablesInText(singleParam[2] |