Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e88587b13 | ||
|
|
41cfeb43fc | ||
|
|
72040b54ae | ||
|
|
ab2b0ce34c |
No files matched your search
+3
-1
@@ -61,7 +61,7 @@ android {
|
||||
lint {
|
||||
abortOnError false
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
dependencies }
|
||||
namespace 'com.jens.automation2'
|
||||
buildToolsVersion '36.0.0'
|
||||
}
|
||||
@@ -77,6 +77,8 @@ dependencies {
|
||||
implementation 'com.linkedin.dexmaker:dexmaker:2.28.6'
|
||||
implementation 'org.apache.commons:commons-lang3:3.20.0'
|
||||
|
||||
implementation 'com.sun.mail:android-mail:1.6.4'
|
||||
|
||||
//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'
|
||||
|
||||
@@ -60,7 +60,9 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||
<!--
|
||||
Removed due to latest threat mail from Google:
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>-->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
|
||||
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
|
||||
|
||||
@@ -2675,4 +2675,32 @@ public class Actions
|
||||
android.provider.Settings.Secure.putString(context.getContentResolver(), android.provider.Settings.Secure.LOCATION_MODE, String.valueOf(desiredState));
|
||||
}
|
||||
|
||||
/*public static sendEmail()
|
||||
{
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.host", smtpHost);
|
||||
props.put("mail.smtp.port", "587");
|
||||
props.put("mail.smtp.auth", "true");
|
||||
props.put("mail.smtp.starttls.enable", "true");
|
||||
props.put("mail.smtp.connectiontimeout", "10000");
|
||||
props.put("mail.smtp.timeout", "10000");
|
||||
|
||||
Session session = Session.getInstance(props, new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
});
|
||||
|
||||
Message message = new MimeMessage(session);
|
||||
message.setFrom(new InternetAddress(fromAddress));
|
||||
message.setRecipients(
|
||||
Message.RecipientType.TO,
|
||||
InternetAddress.parse(recipientAddress)
|
||||
);
|
||||
message.setSubject(subject);
|
||||
message.setText(body);
|
||||
|
||||
Transport.send(message);
|
||||
}*/
|
||||
}
|
||||
@@ -102,6 +102,12 @@ public class ActivityManageTriggerPhoneCall extends Activity
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay))
|
||||
{
|
||||
Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.featureNotInGooglePlayVersion), ActivityManageTriggerPhoneCall.this).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !ActivityPermissions.havePermission("android.permission.READ_CONTACTS", ActivityManageTriggerPhoneCall.this))
|
||||
{
|
||||
requestPermissions("android.permission.READ_CONTACTS");
|
||||
|
||||
@@ -7,20 +7,19 @@ import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.RunningServiceInfo;
|
||||
import android.app.Notification;
|
||||
import android.app.Notification.Builder;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.IBinder;
|
||||
import android.os.StrictMode;
|
||||
import android.speech.tts.TextToSpeech;
|
||||
import android.speech.tts.TextToSpeech.OnInitListener;
|
||||
import android.util.Log;
|
||||
@@ -36,11 +35,17 @@ import com.jens.automation2.receivers.DateTimeListener;
|
||||
import com.jens.automation2.receivers.PackageReplacedReceiver;
|
||||
import com.jens.automation2.receivers.PhoneStatusListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class AutomationService extends Service implements OnInitListener
|
||||
{
|
||||
@@ -429,6 +434,33 @@ public class AutomationService extends Service implements OnInitListener
|
||||
Settings.writeSettings(Miscellaneous.getAnyContext());
|
||||
}
|
||||
|
||||
// try
|
||||
// {
|
||||
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());
|
||||
EmailService es = new EmailService(Settings.smtpServerHostname, Integer.parseInt(Settings.smtpServerPort));
|
||||
|
||||
List addresses = new ArrayList();
|
||||
addresses.add(Settings.smtpFromAddress);
|
||||
try
|
||||
{
|
||||
EmailService.Email em = new EmailService.Email(new EmailService.UserPassAuthenticator(Settings.smtpUsername, Settings.smtpPassword), addresses, new InternetAddress(String.valueOf(addresses.get(0))), "test", "testbody");
|
||||
es.send(em);
|
||||
Miscellaneous.logEvent("i", "sendEmail()", "Email sent.", 1);
|
||||
}
|
||||
catch (AddressException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (MessagingException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// }
|
||||
// catch(Exception e)
|
||||
// {
|
||||
// Miscellaneous.logEvent("e", "sendMail()", Log.getStackTraceString(e), 1);
|
||||
// }
|
||||
|
||||
Settings.serviceStartDone = true;
|
||||
Settings.deviceStartDone = true;
|
||||
}
|
||||
@@ -469,7 +501,7 @@ public class AutomationService extends Service implements OnInitListener
|
||||
if(displayNotification)
|
||||
{
|
||||
Intent intent = new Intent(AutomationService.this, ActivityPermissions.class);
|
||||
PendingIntent pi = PendingIntent.getActivity(AutomationService.this, 0, intent, 0);
|
||||
PendingIntent pi = PendingIntent.getActivity(AutomationService.this, 0, intent, FLAG_IMMUTABLE);
|
||||
|
||||
Miscellaneous.logEvent("w", "Features disabled", "Features disabled because of rule " + rule, 5);
|
||||
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.jens.automation2;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.mail.Address;
|
||||
import javax.mail.Authenticator;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.PasswordAuthentication;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
|
||||
public class EmailService
|
||||
{
|
||||
private final String server;
|
||||
private final int port;
|
||||
|
||||
public static final String CLIENT_NAME = "Android StackOverflow programmatic email";
|
||||
|
||||
public EmailService(String server, int port)
|
||||
{
|
||||
this.server = server;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public static class Email
|
||||
{
|
||||
private final Authenticator auth;
|
||||
private final List<InternetAddress> toList;
|
||||
private final Address from;
|
||||
private final String subject;
|
||||
private final String body;
|
||||
|
||||
public Email(Authenticator auth, List<InternetAddress> toList, Address from, String subject, String body)
|
||||
{
|
||||
this.auth = auth;
|
||||
this.toList = toList;
|
||||
this.from = from;
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public Authenticator getAuth()
|
||||
{
|
||||
return auth;
|
||||
}
|
||||
|
||||
public List<InternetAddress> getToList()
|
||||
{
|
||||
return toList;
|
||||
}
|
||||
|
||||
public Address getFrom()
|
||||
{
|
||||
return from;
|
||||
}
|
||||
|
||||
public String getSubject()
|
||||
{
|
||||
return subject;
|
||||
}
|
||||
|
||||
public String getBody()
|
||||
{
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
||||
public static class UserPassAuthenticator extends Authenticator
|
||||
{
|
||||
private final String username;
|
||||
private final String password;
|
||||
|
||||
public UserPassAuthenticator(String username, String password)
|
||||
{
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication()
|
||||
{
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
}
|
||||
|
||||
public void send(Email email) throws MessagingException
|
||||
{
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.auth", "true");
|
||||
props.put("mail.user", email.getFrom().toString());
|
||||
props.put("mail.smtp.host", server);
|
||||
props.put("mail.smtp.port", String.valueOf(port));
|
||||
props.put("mail.smtp.starttls.enable", "true");
|
||||
props.put("mail.smtp.ssl.trust", server);
|
||||
props.put("mail.mime.charset", "UTF-8");
|
||||
|
||||
Session session = Session.getDefaultInstance(props, email.getAuth());
|
||||
MimeMessage msg = new MimeMessage(session);
|
||||
|
||||
msg.setFrom(email.getFrom());
|
||||
msg.setSentDate(Calendar.getInstance().getTime());
|
||||
Address[] toarray = new Address[]{email.getFrom()};
|
||||
msg.setRecipients(Message.RecipientType.TO, toarray);
|
||||
// msg.setRecipients(Message.RecipientType.TO, email.getToList().toArray(new InternetAddress[0]));
|
||||
|
||||
msg.setReplyTo(new Address[]{email.getFrom()});
|
||||
|
||||
msg.addHeader("X-Mailer", CLIENT_NAME);
|
||||
msg.addHeader("Precedence", "bulk");
|
||||
msg.setSubject(email.getSubject());
|
||||
|
||||
MimeMultipart multipart = new MimeMultipart();
|
||||
MimeBodyPart bodyPart = new MimeBodyPart();
|
||||
bodyPart.setText(email.getBody(), "iso-8859-1");
|
||||
multipart.addBodyPart(bodyPart);
|
||||
|
||||
msg.setContent(multipart);
|
||||
Transport.send(msg);
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,14 @@ public class Settings implements SharedPreferences
|
||||
public static long musicCheckFrequency;
|
||||
public static String displayLanguage;
|
||||
|
||||
public static String smtpServerHostname;
|
||||
public static String smtpServerPort;
|
||||
public static boolean smtpServerUseTls;
|
||||
public static String smtpFromAddress;
|
||||
public static String smtpToAddress;
|
||||
public static String smtpUsername;
|
||||
public static String smtpPassword;
|
||||
|
||||
public static boolean lockSoundChanges;
|
||||
public static boolean noticeAndroid9MicrophoneShown;
|
||||
public static boolean noticeAndroid10WifiShown;
|
||||
@@ -146,6 +154,14 @@ public class Settings implements SharedPreferences
|
||||
public static final long default_musicCheckFrequency = 2500;
|
||||
public static final String default_displayLanguage = "systemDefaultLanguage";
|
||||
|
||||
public static final String default_smtpServerHostname = "";
|
||||
public static final String default_smtpServerPort = "587";
|
||||
public static final boolean default_smtpServerUseTls = false;
|
||||
public static final String default_smtpFromAddress = "";
|
||||
public static final String default_smtpToAddress = "";
|
||||
public static final String default_smtpUsername = "";
|
||||
public static final String default_smtpPassword = "";
|
||||
|
||||
@Override
|
||||
public boolean contains(String arg0)
|
||||
{
|
||||
@@ -273,6 +289,14 @@ public class Settings implements SharedPreferences
|
||||
musicCheckFrequency = Long.parseLong(prefs.getString("musicCheckFrequency", String.valueOf(default_musicCheckFrequency)));
|
||||
displayLanguage = prefs.getString("displayLanguage", default_displayLanguage);
|
||||
|
||||
smtpServerHostname = prefs.getString("smtpServerHostname", default_smtpServerHostname);
|
||||
smtpServerPort = prefs.getString("smtpServerPort", default_smtpServerPort);
|
||||
smtpServerUseTls = prefs.getBoolean("smtpServerUseTls", default_smtpServerUseTls);
|
||||
smtpFromAddress = prefs.getString("smtpFromAddress", default_smtpFromAddress);
|
||||
smtpToAddress = prefs.getString("smtpToAddress", default_smtpToAddress);
|
||||
smtpUsername = prefs.getString("smtpUsername", default_smtpUsername);
|
||||
smtpPassword = prefs.getString("smtpPassword", default_smtpPassword);
|
||||
|
||||
if(Settings.musicCheckFrequency == 0)
|
||||
Settings.musicCheckFrequency = Settings.default_musicCheckFrequency;
|
||||
|
||||
@@ -490,6 +514,27 @@ public class Settings implements SharedPreferences
|
||||
if(!prefs.contains("displayLanguage") || force)
|
||||
editor.putString("displayLanguage", default_displayLanguage);
|
||||
|
||||
if(!prefs.contains("smtpServerHostname") || force)
|
||||
editor.putString("smtpServerHostname", default_smtpServerHostname);
|
||||
|
||||
if(!prefs.contains("smtpServerPort") || force)
|
||||
editor.putString("smtpServerPort", default_smtpServerPort);
|
||||
|
||||
if(!prefs.contains("smtpServerUseTls") || force)
|
||||
editor.putBoolean("smtpServerUseTls", default_smtpServerUseTls);
|
||||
|
||||
if(!prefs.contains("smtpFromAddress") || force)
|
||||
editor.putString("smtpFromAddress", default_smtpFromAddress);
|
||||
|
||||
if(!prefs.contains("smtpToAddress") || force)
|
||||
editor.putString("smtpToAddress", default_smtpToAddress);
|
||||
|
||||
if(!prefs.contains("smtpUsername") || force)
|
||||
editor.putString("smtpUsername", default_smtpUsername);
|
||||
|
||||
if(!prefs.contains("smtpPassword") || force)
|
||||
editor.putString("smtpPassword", default_smtpPassword);
|
||||
|
||||
if(!prefs.contains("lockSoundChanges") || force)
|
||||
editor.putBoolean("lockSoundChanges", default_lockSoundChanges);
|
||||
|
||||
@@ -580,6 +625,14 @@ public class Settings implements SharedPreferences
|
||||
|
||||
editor.putString("displayLanguage", displayLanguage);
|
||||
|
||||
editor.putString("smtpServerHostname", smtpServerHostname);
|
||||
editor.putString("smtpServerPort", smtpServerPort);
|
||||
editor.putBoolean("smtpServerUseTls", smtpServerUseTls);
|
||||
editor.putString("smtpFromAddress", smtpFromAddress);
|
||||
editor.putString("smtpToAddress", smtpToAddress);
|
||||
editor.putString("smtpUsername", smtpUsername);
|
||||
editor.putString("smtpPassword", smtpPassword);
|
||||
|
||||
editor.putBoolean("lockSoundChanges", lockSoundChanges);
|
||||
editor.putBoolean("noticeAndroid9MicrophoneShown", noticeAndroid9MicrophoneShown);
|
||||
editor.putBoolean("noticeAndroid10WifiShown", noticeAndroid10WifiShown);
|
||||
|
||||
@@ -307,5 +307,52 @@
|
||||
android:inputType="number" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:summary="@string/settingsCategorySendEmails"
|
||||
android:title="@string/settingsCategorySendEmails">
|
||||
|
||||
<EditTextPreference
|
||||
android:key="smtpServerHostname"
|
||||
android:summary="@string/smtpServerHostnameSummary"
|
||||
android:title="@string/smtpServerHostnameTitle"
|
||||
android:inputType="text" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="smtpServerPort"
|
||||
android:summary="@string/smtpServerPortSummary"
|
||||
android:title="@string/smtpServerPortTitle"
|
||||
android:inputType="number" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="smtpServerUseTls"
|
||||
android:summary="@string/smtpServerUseTlsSummary"
|
||||
android:title="@string/smtpServerUseTlsTitle" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="smtpFromAddress"
|
||||
android:summary="@string/smtpFromAddressSummary"
|
||||
android:title="@string/smtpFromAddressTitle"
|
||||
android:inputType="textEmailAddress" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="smtpToAddress"
|
||||
android:summary="@string/smtpToAddressSummary"
|
||||
android:title="@string/smtpToAddressTitle"
|
||||
android:inputType="textEmailAddress" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="smtpUsername"
|
||||
android:summary="@string/smtpUsernameSummary"
|
||||
android:title="@string/smtpUsernameTitle"
|
||||
android:inputType="text" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="smtpPassword"
|
||||
android:summary="@string/smtpPasswordSummary"
|
||||
android:title="@string/smtpPasswordTitle"
|
||||
android:inputType="textPassword" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -698,7 +698,7 @@
|
||||
<string name="bottom">Bottom</string>
|
||||
<string name="tabsPlacement">Position of tab bar</string>
|
||||
<string name="tabsPlacementSummary">Choose where the tabs bar should be placed.</string>
|
||||
<string name="wifiApi30">Because Google screwed up yet another part of Android, starting with API 30 only the currently visible wifis can be displayed, not all the ones your device has connected to anymore.</string>
|
||||
<string name="wifiApi30">Because Google screwed up yet another part of Android, starting with API 30 only the currently visible Wi-Fi can be displayed, not all the ones your device has connected to anymore.</string>
|
||||
<string name="silentTriggersDnd">REMARK: The silent mode often triggers Do-Not-Disturb on newer devices. If that happens on your device, I recommend using the normal mode instead and lowering all volumes to zero.</string>
|
||||
<string name="tones">Tones</string>
|
||||
<string name="miscellaneous">Miscellaneous</string>
|
||||
@@ -980,4 +980,19 @@
|
||||
<string name="httpParametersExplanation">If any parameter name starts with %1$s while method is POST, it will not be transmitted like the other parameters (with key=value), but transferred as main data. If the parameter ends with %2$s, no encoding will be performed.</string>
|
||||
<string name="target">Target</string>
|
||||
<string name="enter_valid_url">Enter a valid URL.</string>
|
||||
<string name="settingsCategorySendEmails">Email server settings</string>
|
||||
<string name="smtpServerHostnameTitle">Hostname</string>
|
||||
<string name="smtpServerHostnameSummary">SMTP server hostname</string>
|
||||
<string name="smtpServerPortTitle">Port</string>
|
||||
<string name="smtpServerPortSummary">SMTP server port</string>
|
||||
<string name="smtpServerUseTlsTitle">Use TLS</string>
|
||||
<string name="smtpServerUseTlsSummary">Use TLS for connection to SMTP server</string>
|
||||
<string name="smtpFromAddressTitle">From address</string>
|
||||
<string name="smtpFromAddressSummary">Sender address emails (from)</string>
|
||||
<string name="smtpToAddressTitle">Recipient address</string>
|
||||
<string name="smtpToAddressSummary">Recipient address for emails (to)</string>
|
||||
<string name="smtpUsernameTitle">Username</string>
|
||||
<string name="smtpUsernameSummary">Leave empty for no authentication</string>
|
||||
<string name="smtpPasswordTitle">Password</string>
|
||||
<string name="smtpPasswordSummary">If username is empty, no authentication is used.</string>
|
||||
</resources>
|
||||
@@ -1,3 +1,4 @@
|
||||
* Added: Triggers and actions can now be cloned
|
||||
* Added: URL checker for triggerUrl action
|
||||
* Fixed: Crash when starting to add/edit a triggerURL action while the app or the system are set to the German language
|
||||
* Fixed: Crash when starting to add/edit a triggerURL action while the app or the system are set to the German language
|
||||
* Fixed: Crash when starting service in Google Play version
|
||||
Reference in new issue
Block a user