Escaped variables when triggering
This commit is contained in:
parent
8c0cee9589
commit
8d10bf05af
@ -578,7 +578,12 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
builder.setOnlyAlertOnce(true);
|
builder.setOnlyAlertOnce(true);
|
||||||
|
|
||||||
if(Settings.showIconWhenServiceIsRunning)
|
if(Settings.showIconWhenServiceIsRunning)
|
||||||
|
{
|
||||||
|
if (BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay))
|
||||||
builder.setSmallIcon(R.drawable.crane);
|
builder.setSmallIcon(R.drawable.crane);
|
||||||
|
else
|
||||||
|
builder.setSmallIcon(R.drawable.ic_launcher);
|
||||||
|
}
|
||||||
|
|
||||||
// builder.setContentText(textToDisplay);
|
// builder.setContentText(textToDisplay);
|
||||||
// builder.setSmallIcon(icon);
|
// builder.setSmallIcon(icon);
|
||||||
|
@ -70,6 +70,7 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.Thread.UncaughtExceptionHandler;
|
import java.lang.Thread.UncaughtExceptionHandler;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -77,6 +78,8 @@ import java.math.BigDecimal;
|
|||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.DigestInputStream;
|
import java.security.DigestInputStream;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
@ -708,7 +711,7 @@ public class Miscellaneous extends Service
|
|||||||
String notificationTitle = NotificationListener.getLastNotification().getTitle();
|
String notificationTitle = NotificationListener.getLastNotification().getTitle();
|
||||||
|
|
||||||
if (notificationTitle != null && notificationTitle.length() > 0)
|
if (notificationTitle != null && notificationTitle.length() > 0)
|
||||||
source = source.replace("[notificationTitle]", notificationTitle);
|
source = source.replace("[notificationTitle]", escapeStringForUrl(notificationTitle));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
source = source.replace("[notificationTitle]", "notificationTitle unknown");
|
source = source.replace("[notificationTitle]", "notificationTitle unknown");
|
||||||
@ -729,7 +732,7 @@ public class Miscellaneous extends Service
|
|||||||
String notificationText = NotificationListener.getLastNotification().getText();
|
String notificationText = NotificationListener.getLastNotification().getText();
|
||||||
|
|
||||||
if (notificationText != null && notificationText.length() > 0)
|
if (notificationText != null && notificationText.length() > 0)
|
||||||
source = source.replace("[notificationText]", notificationText);
|
source = source.replace("[notificationText]", escapeStringForUrl(notificationText));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
source = source.replace("[notificationText]", "notificationText unknown");
|
source = source.replace("[notificationText]", "notificationText unknown");
|
||||||
@ -760,7 +763,7 @@ public class Miscellaneous extends Service
|
|||||||
else
|
else
|
||||||
replacement = "unknownVariable";
|
replacement = "unknownVariable";
|
||||||
|
|
||||||
source = source.substring(0, pos1) + replacement + source.substring(pos2 +1);
|
source = source.substring(0, pos1) + escapeStringForUrl(replacement) + source.substring(pos2 +1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Miscellaneous.logEvent("i", "URL after replace", source);
|
// Miscellaneous.logEvent("i", "URL after replace", source);
|
||||||
@ -1164,7 +1167,12 @@ public class Miscellaneous extends Service
|
|||||||
builder.setOnlyAlertOnce(true);
|
builder.setOnlyAlertOnce(true);
|
||||||
|
|
||||||
if(Settings.showIconWhenServiceIsRunning && notificationChannelId.equals(AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE))
|
if(Settings.showIconWhenServiceIsRunning && notificationChannelId.equals(AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE))
|
||||||
|
{
|
||||||
|
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay))
|
||||||
builder.setSmallIcon(R.drawable.crane);
|
builder.setSmallIcon(R.drawable.crane);
|
||||||
|
else
|
||||||
|
builder.setSmallIcon(R.drawable.ic_launcher);
|
||||||
|
}
|
||||||
else if(!notificationChannelId.equals(AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE))
|
else if(!notificationChannelId.equals(AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE))
|
||||||
builder.setSmallIcon(R.drawable.info);
|
builder.setSmallIcon(R.drawable.info);
|
||||||
|
|
||||||
@ -2034,4 +2042,28 @@ public class Miscellaneous extends Service
|
|||||||
//startActivity(refresh);
|
//startActivity(refresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String escapeStringForUrl(String input)
|
||||||
|
{
|
||||||
|
String output;
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
output = URLEncoder.encode(input, String.valueOf(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
catch (UnsupportedEncodingException e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "URLEncoder", "Error encoding string for URL. Leaving as it is. Error details: " + Log.getStackTraceString(e), 3);
|
||||||
|
output = input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output = Uri.encode(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
}
|
}
|
BIN
app/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/drawable-ldpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-ldpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in New Issue
Block a user