Compare commits
No commits in common. "master" and "development" have entirely different histories.
master
...
developmen
|
@ -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 133
|
||||
versionName "1.7.17"
|
||||
versionCode 120
|
||||
versionName "1.7.6"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
@ -36,15 +36,9 @@ android {
|
|||
{
|
||||
dimension "version"
|
||||
versionNameSuffix "-googlePlay"
|
||||
targetSdkVersion 31
|
||||
targetSdkVersion 30
|
||||
}
|
||||
|
||||
/*
|
||||
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"
|
||||
|
@ -78,9 +72,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.2'
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
testImplementation 'junit:junit:4'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"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,10 +66,6 @@
|
|||
<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"
|
||||
|
@ -173,13 +169,6 @@
|
|||
<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.trim();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static void readFromFile()
|
||||
|
@ -347,16 +347,7 @@ public class Rule implements Comparable<Rule>
|
|||
if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.timeFrame))
|
||||
{
|
||||
if(oneTrigger.getTimeFrame().repetition > 0)
|
||||
{
|
||||
if(this.getLastExecution() != null)
|
||||
{
|
||||
Calendar now = Calendar.getInstance();
|
||||
if (this.getLastExecution().getTimeInMillis() + oneTrigger.getTimeFrame().getRepetition() * 1000 <= now.getTimeInMillis())
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.broadcastReceived))
|
||||
{
|
||||
|
@ -405,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()), 4);
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -476,9 +467,7 @@ public class Rule implements Comparable<Rule>
|
|||
{
|
||||
AutomationService service = AutomationService.getInstance();
|
||||
service.speak(messages[0], false);
|
||||
|
||||
if(Settings.showToasts)
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
super.onProgressUpdate(messages);
|
||||
}
|
||||
|
|
|
@ -64,10 +64,6 @@
|
|||
<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"
|
||||
|
@ -171,12 +167,6 @@
|
|||
<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.trim();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
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()), 4);
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -440,9 +440,7 @@ public class Rule implements Comparable<Rule>
|
|||
{
|
||||
AutomationService service = AutomationService.getInstance();
|
||||
service.speak(messages[0], false);
|
||||
|
||||
if(Settings.showToasts)
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
super.onProgressUpdate(messages);
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
@ -113,7 +111,6 @@
|
|||
</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" />
|
||||
|
@ -125,7 +122,6 @@
|
|||
|
||||
<receiver
|
||||
android:name=".DeviceAdmin"
|
||||
android:exported="true"
|
||||
android:description="@string/app_name"
|
||||
android:label="@string/app_name"
|
||||
android:permission= "android.permission.BIND_DEVICE_ADMIN" >
|
||||
|
@ -158,14 +154,8 @@
|
|||
<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" />
|
||||
|
@ -214,7 +204,6 @@
|
|||
|
||||
<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.trim();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
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()), 4);
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -467,9 +467,7 @@ public class Rule implements Comparable<Rule>
|
|||
{
|
||||
AutomationService service = AutomationService.getInstance();
|
||||
service.speak(messages[0], false);
|
||||
|
||||
if(Settings.showToasts)
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
super.onProgressUpdate(messages);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
|
||||
|
||||
</manifest>
|
|
@ -6,6 +6,8 @@ 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;
|
||||
|
||||
|
@ -51,11 +53,6 @@ public class Action
|
|||
closeNotification,
|
||||
sendBroadcast,
|
||||
runExecutable,
|
||||
wakelock,
|
||||
setVariable,
|
||||
startPhoneCall,
|
||||
stopPhoneCall,
|
||||
copyToClipboard,
|
||||
sendTextMessage;
|
||||
|
||||
public String getFullName(Context context)
|
||||
|
@ -130,16 +127,6 @@ 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";
|
||||
}
|
||||
|
@ -286,27 +273,6 @@ 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());
|
||||
}
|
||||
|
@ -364,25 +330,17 @@ 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(": ");
|
||||
|
||||
|
@ -410,12 +368,6 @@ 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, "; "));
|
||||
}
|
||||
|
@ -529,7 +481,7 @@ public class Action
|
|||
Actions.setUsbTethering(context, getParameter1(), toggleActionIfPossible);
|
||||
break;
|
||||
case setWifi:
|
||||
Actions.WifiStuff.setWifi(context, getParameter1(), getParameter2(), toggleActionIfPossible);
|
||||
Actions.WifiStuff.setWifi(context, getParameter1(), toggleActionIfPossible);
|
||||
break;
|
||||
case setWifiTethering:
|
||||
Actions.setWifiTethering(context, getParameter1(), toggleActionIfPossible);
|
||||
|
@ -614,24 +566,6 @@ 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;
|
||||
|
@ -658,7 +592,7 @@ public class Action
|
|||
password = components[1];
|
||||
url = components[2];
|
||||
}
|
||||
else // compatibility for very old versions which haven't upgraded, yet.
|
||||
else
|
||||
url = components[0];
|
||||
|
||||
try
|
||||
|
|
|
@ -10,10 +10,13 @@ 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;
|
||||
|
@ -23,8 +26,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;
|
||||
|
@ -67,7 +70,6 @@ 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;
|
||||
|
||||
|
@ -80,6 +82,10 @@ 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";
|
||||
|
||||
|
@ -93,7 +99,6 @@ 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
|
||||
|
@ -112,8 +117,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);
|
||||
|
@ -122,14 +127,11 @@ public class Actions
|
|||
String myTitleDir = params[1];
|
||||
String requiredTitle = params[2];
|
||||
String myTextDir = params[3];
|
||||
String requiredText = "";
|
||||
String method = ActivityManageActionCloseNotification.dismissRegularString;
|
||||
|
||||
if(params.length >= 5)
|
||||
String requiredText;
|
||||
if (params.length >= 5)
|
||||
requiredText = params[4];
|
||||
|
||||
if(params.length >= 6 && !params[5].equals(ActivityManageActionCloseNotification.dismissRegularString))
|
||||
method = params[5];
|
||||
else
|
||||
requiredText = "";
|
||||
|
||||
for (StatusBarNotification sbn : NotificationListener.getInstance().getActiveNotifications())
|
||||
{
|
||||
|
@ -183,17 +185,12 @@ public class Actions
|
|||
|
||||
Miscellaneous.logEvent("i", "NotificationCloseCheck", "All criteria matches. Closing notification: " + sbn.getNotification().toString(), 3);
|
||||
if(NotificationListener.getInstance() != null)
|
||||
{
|
||||
if(method == ActivityManageActionCloseNotification.dismissRegularString)
|
||||
NotificationListener.getInstance().dismissNotification(sbn);
|
||||
else
|
||||
NotificationListener.getInstance().clickNotificationButton(sbn, method);
|
||||
}
|
||||
NotificationListener.getInstance().dismissNotification(sbn);
|
||||
else
|
||||
Miscellaneous.logEvent("i", "NotificationCloseCheck", "NotificationListener instance is null. Can\'t close notification.", 3);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendBroadcast(Context context, String action)
|
||||
|
@ -205,9 +202,7 @@ public class Actions
|
|||
{
|
||||
String[] parts = action.split(Action.actionParameter2Split);
|
||||
broadcastIntent.setAction(parts[0]);
|
||||
|
||||
String[] intentparts = parts[1].split(";");
|
||||
broadcastIntent = packParametersIntoIntent(broadcastIntent, intentparts, 0);
|
||||
add params
|
||||
}
|
||||
else
|
||||
broadcastIntent.setAction(action);
|
||||
|
@ -215,50 +210,11 @@ public class Actions
|
|||
context.sendBroadcast(broadcastIntent);
|
||||
}
|
||||
|
||||
public static void setVariable(String parameter2)
|
||||
public static class WifiStuff
|
||||
{
|
||||
String[] parts = parameter2.split(Action.actionParameter2Split);
|
||||
|
||||
if(AutomationService.isMyServiceRunning(Miscellaneous.getAnyContext()))
|
||||
public static Boolean setWifi(Context context, Boolean desiredState, boolean toggleActionIfPossible)
|
||||
{
|
||||
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)
|
||||
if(context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q)
|
||||
return setWifiWithRoot(context, desiredState, toggleActionIfPossible);
|
||||
else
|
||||
return setWifiOldFashioned(context, desiredState, toggleActionIfPossible);
|
||||
|
@ -294,15 +250,8 @@ public class Actions
|
|||
{
|
||||
Miscellaneous.logEvent("i", "Wifi", "Changing wifi to " + String.valueOf(desiredState), 4);
|
||||
|
||||
try
|
||||
{
|
||||
if (desiredState && Settings.useWifiForPositioning)
|
||||
WifiBroadcastReceiver.startWifiReceiver(automationServerRef.getLocationProvider());
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("w", "setWifiOldFashioned()", Log.getStackTraceString(e), 4);
|
||||
}
|
||||
if (desiredState && Settings.useWifiForPositioning)
|
||||
WifiBroadcastReceiver.startWifiReceiver(automationServerRef.getLocationProvider());
|
||||
|
||||
WifiManager myWifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
|
||||
|
@ -830,21 +779,29 @@ public class Actions
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void setDoNotDisturb(Context context, int desiredDndMode)
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
public static void setDoNotDisturb(Context context, int desiredSetting)
|
||||
{
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
{
|
||||
/*
|
||||
if (!notificationManager.isNotificationPolicyAccessGranted())
|
||||
--> done externally
|
||||
*/
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
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);
|
||||
// Check if the notification policy access has been granted for the app.
|
||||
/* if (!notificationManager.isNotificationPolicyAccessGranted())
|
||||
{
|
||||
Intent intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
|
||||
startActivity(intent);
|
||||
return;
|
||||
}*/
|
||||
|
||||
notificationManager.setInterruptionFilter(desiredSetting);
|
||||
|
||||
/*if (notificationManager.getCurrentInterruptionFilter() == NotificationManager.INTERRUPTION_FILTER_ALL)
|
||||
{
|
||||
notificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_NONE);
|
||||
}
|
||||
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);
|
||||
{
|
||||
notificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALL);
|
||||
}*/
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
|
@ -981,6 +938,18 @@ 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();
|
||||
|
@ -1048,6 +1017,8 @@ public class Actions
|
|||
{
|
||||
Intent externalActivityIntent;
|
||||
|
||||
int paramsStartIndex;
|
||||
|
||||
if (!startByAction)
|
||||
{
|
||||
// selected by activity
|
||||
|
@ -1059,6 +1030,8 @@ 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);
|
||||
|
||||
|
@ -1086,27 +1059,9 @@ public class Actions
|
|||
externalActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
// Pack intents
|
||||
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);
|
||||
for (int i = 3; i < params.length; i++)
|
||||
{
|
||||
String[] singleParam = params[i].split(Action.intentPairSeparator);
|
||||
|
||||
/*Class c = Class.forName(singleParam[0]);
|
||||
for(Method m : c.getMethods())
|
||||
|
@ -1118,89 +1073,83 @@ 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);
|
||||
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[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[1].equalsIgnoreCase("IntentData"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with value " + singleParam[2] + " as standard data parameter.", 3);
|
||||
intent.setData(Uri.parse(Miscellaneous.replaceVariablesInText(singleParam[2], context)));
|
||||
|
||||
externalActivityIntent.setData(Uri.parse(singleParam[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
intent.putExtra(singleParam[1], Uri.parse(Miscellaneous.replaceVariablesInText(singleParam[2], context)));
|
||||
externalActivityIntent.putExtra(singleParam[1], Uri.parse(singleParam[2]));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
else if (singleParam[0].equals("String"))
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
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]);
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("w", "StartOtherApp", "Unknown type of parameter " + singleParam[0] + " found. Name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
}
|
||||
else if (singleParam[0].equals("String"))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
try
|
||||
{
|
||||
intent.putExtra(singleParam[1], Miscellaneous.replaceVariablesInText(singleParam[2], context));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
intent.putExtra(singleParam[1], singleParam[2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("w", "StartOtherApp", "Unknown type of parameter " + singleParam[0] + " found. Name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
}
|
||||
|
||||
return intent;
|
||||
if (params[2].equals(ActivityManageActionStartActivity.startByActivityString))
|
||||
automationServerRef.startActivity(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 void waitBeforeNextAction(Long waitTime)
|
||||
|
@ -1239,37 +1188,21 @@ public class Actions
|
|||
|
||||
public static void sendTextMessage(Context context, String[] parametersArray)
|
||||
{
|
||||
String phoneNumber, message, messageType = ActivityManageActionSendTextMessage.messageTypeSms, filePath = null;
|
||||
String phoneNumber, message;
|
||||
|
||||
phoneNumber = parametersArray[0];
|
||||
message = parametersArray[1];
|
||||
|
||||
if(parametersArray.length > 2)
|
||||
{
|
||||
messageType = parametersArray[2];
|
||||
|
||||
if(parametersArray.length > 3)
|
||||
filePath = parametersArray[3];
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
String textToSend = Miscellaneous.replaceVariablesInText(message, context);
|
||||
if(messageType.equals("sms"))
|
||||
sendSmsMessage(phoneNumber, textToSend);
|
||||
else
|
||||
sendMmsMessage(phoneNumber, textToSend, filePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", Miscellaneous.getAnyContext().getString(R.string.sendTextMessage), "Error in sendTextMessage: " + Log.getStackTraceString(e), 3);
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendSmsMessage(String phoneNumber, String textToSend)
|
||||
{
|
||||
try
|
||||
{
|
||||
/*
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + phoneNumber));
|
||||
intent.putExtra("sms_body", message);
|
||||
AutomationService.getInstance().startActivity(intent);
|
||||
*/
|
||||
|
||||
PendingIntent pi = PendingIntent.getActivity(context, 0, new Intent(context, Actions.class), 0);
|
||||
SmsManager sms = SmsManager.getDefault();
|
||||
sms.sendTextMessage(phoneNumber, null, textToSend, pi, null);
|
||||
|
@ -1280,26 +1213,6 @@ public class Actions
|
|||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private static void sendMmsMessage(String phoneNumber, String textToSend, String fileToBeAttached)
|
||||
{
|
||||
try
|
||||
{
|
||||
Miscellaneous.logEvent("i", "sendMmsMessage()", "Sending MMS message...", 2);
|
||||
// Uri contentUri = Uri.fromFile(new File(fileToBeAttached));
|
||||
String str2 = "send." + String.valueOf(Math.abs(new Random().nextLong())) + ".dat";
|
||||
Uri contentUri = new Uri.Builder().authority(context.getPackageName() + ".MmsFileProvider").path(str2).scheme("content").build();
|
||||
|
||||
// Bundle a3 = C3326a.m16196a(new C8792q("enableGroupMms", true), new C8792q("maxMessageSize", Integer.valueOf(C3664a.m17428d())));
|
||||
|
||||
SmsManager.getDefault().sendMultimediaMessage(context, contentUri, phoneNumber, null, null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "sendMmsMessage()", "Error in sendMmsMessage(): " + Log.getStackTraceString(e), 3);
|
||||
}
|
||||
}
|
||||
|
||||
private static class WakeUpDeviceClass implements Runnable
|
||||
{
|
||||
private long awakeTime;
|
||||
|
@ -1966,12 +1879,6 @@ public class Actions
|
|||
|
||||
protected static boolean executeCommandViaSu(String[] commands)
|
||||
{
|
||||
boolean suAvailable = false;
|
||||
String suVersion = null;
|
||||
String suVersionInternal = null;
|
||||
// List<String> suResult = null;
|
||||
int suResult;
|
||||
|
||||
boolean success = false;
|
||||
|
||||
try
|
||||
|
@ -1981,30 +1888,17 @@ public class Actions
|
|||
{
|
||||
suVersion = Shell.SU.version(false);
|
||||
suVersionInternal = Shell.SU.version(true);
|
||||
suResult = Shell.SU.run(commands);
|
||||
|
||||
Miscellaneous.logEvent("i", "executeCommandViaSu()", "suVersion: " + suVersion + ", suVersionInternal: " + suVersionInternal, 5);
|
||||
|
||||
// suResult = Shell.SU.run(commands);
|
||||
suResult = Shell.Pool.SU.run(commands);
|
||||
|
||||
// if (suResult != null)
|
||||
// success = true;
|
||||
|
||||
Miscellaneous.logEvent("i", "executeCommandViaSu()", "RC=" + String.valueOf(suResult), 3);
|
||||
|
||||
if(suResult == 0)
|
||||
if (suResult != null)
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("w", "executeCommandViaSu()", "su not available.", 4);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "executeCommandViaSu()", "Returning " + String.valueOf(success), 4);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -2213,117 +2107,4 @@ public class Actions
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public final static int wakeLockTimeoutDisabled = -1;
|
||||
static boolean wakeLockStopRequested = false;
|
||||
public static void wakeLockStart(Context context, long duration)
|
||||
{
|
||||
Thread lockThread = new Thread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
wakeLockStopRequested = false;
|
||||
|
||||
long waited = 0;
|
||||
int step = 2000;
|
||||
|
||||
try
|
||||
{
|
||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager.WakeLock fullWakeLock = powerManager.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "Loneworker - FULL WAKE LOCK");
|
||||
fullWakeLock.acquire(); // turn on
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
Thread.sleep(step); // turn on duration
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(duration > 0)
|
||||
waited += step;
|
||||
|
||||
if(wakeLockStopRequested) //stop requested
|
||||
Miscellaneous.logEvent("i", "WakeLockStart", "Stop requested.", 4);
|
||||
}
|
||||
while(!wakeLockStopRequested && (duration < 0 || waited <= duration));
|
||||
|
||||
fullWakeLock.release();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
lockThread.start();
|
||||
}
|
||||
|
||||
public static void wakeLockStop()
|
||||
{
|
||||
Miscellaneous.logEvent("i", "WakeLockStart", "Requesting stop.", 4);
|
||||
wakeLockStopRequested = true;
|
||||
}
|
||||
|
||||
public static void startPhoneCall(Context context, String phoneNumber)
|
||||
{
|
||||
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Uri.encode(phoneNumber)));
|
||||
// intent.setClassName("com.android.phone","com.android.phone.OutgoingCallBroadcaster");
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.addFlags(Intent.FLAG_FROM_BACKGROUND);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void endPhoneCall(Context context)
|
||||
{
|
||||
if(Build.VERSION.SDK_INT < 21)
|
||||
{
|
||||
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
try
|
||||
{
|
||||
Class c = Class.forName(tm.getClass().getName());
|
||||
Method m = c.getDeclaredMethod("getITelephony");
|
||||
m.setAccessible(true);
|
||||
Object telephonyService = m.invoke(tm);
|
||||
|
||||
c = Class.forName(telephonyService.getClass().getName());
|
||||
m = c.getDeclaredMethod("endCall");
|
||||
m.setAccessible(true);
|
||||
m.invoke(telephonyService);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TelecomManager mgr = (TelecomManager) context.getSystemService(context.TELECOM_SERVICE);
|
||||
mgr.endCall();
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyToClipboard(Context context, String text)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Clipboard", "Copying data to clipboard: " + text, 4);
|
||||
|
||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB)
|
||||
{
|
||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
clipboard.setText(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
android.content.ClipData clip = android.content.ClipData.newPlainText("Data-from-Automation", text);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,10 +39,8 @@ public class ActivityControlCenter extends Activity
|
|||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
Miscellaneous.setDisplayLanguage(this);
|
||||
setContentView(R.layout.activity_control_center);
|
||||
|
||||
|
||||
bVolumeTest = (Button) findViewById(R.id.bVolumeTest);
|
||||
bVolumeTest.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
|
@ -386,7 +384,6 @@ public class ActivityControlCenter extends Activity
|
|||
protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
Miscellaneous.setDisplayLanguage(this);
|
||||
|
||||
String folder = Miscellaneous.getWriteableFolder();
|
||||
if (folder != null && folder.length() > 0)
|
||||
|
|
|
@ -21,7 +21,6 @@ public class ActivityDisplayLongMessage extends Activity
|
|||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
Miscellaneous.setDisplayLanguage(this);
|
||||
setContentView(R.layout.activity_display_long_message);
|
||||
|
||||
tvMessageTitle = (TextView)findViewById(R.id.tvMessageTitle);
|
||||
|
|
|
@ -13,8 +13,7 @@ public class ActivityHelp extends Activity
|
|||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
Miscellaneous.setDisplayLanguage(this);
|
||||
setContentView(layout.activity_help_text);
|
||||
setContentView(layout.help_text);
|
||||
|
||||
TextView tvHelpTextEnergySaving = (TextView) findViewById(R.id.tvHelpTextEnergySaving);
|
||||
tvHelpTextEnergySaving.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
|
|
@ -44,7 +44,6 @@ public class ActivityMainPoi extends ActivityGeneric
|
|||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
Miscellaneous.setDisplayLanguage(this);
|
||||
setContentView(R.layout.main_poi_layout);
|
||||