mirror of
https://github.com/danog/termux-api.git
synced 2024-12-03 09:47:52 +01:00
Fix possible crash in NotificationAPI from invalid LED color value (#164)
This commit is contained in:
parent
19acd1d54a
commit
fa9373ab1e
@ -10,6 +10,7 @@ import android.provider.Settings;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.termux.api.util.ResultReturner;
|
import com.termux.api.util.ResultReturner;
|
||||||
|
import com.termux.api.util.TermuxApiLogger;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -51,7 +52,17 @@ public class NotificationAPI {
|
|||||||
String title = intent.getStringExtra("title");
|
String title = intent.getStringExtra("title");
|
||||||
|
|
||||||
String lightsArgbExtra = intent.getStringExtra("led-color");
|
String lightsArgbExtra = intent.getStringExtra("led-color");
|
||||||
int ledColor = (lightsArgbExtra == null) ? 0 : (Integer.parseInt(lightsArgbExtra, 16) | 0xff000000);
|
|
||||||
|
int ledColor = 0;
|
||||||
|
|
||||||
|
if (lightsArgbExtra != null) {
|
||||||
|
try {
|
||||||
|
ledColor = Integer.parseInt(lightsArgbExtra, 16) | 0xff000000;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
TermuxApiLogger.error("Invalid LED color format! Ignoring!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int ledOnMs = intent.getIntExtra("led-on", 800);
|
int ledOnMs = intent.getIntExtra("led-on", 800);
|
||||||
int ledOffMs = intent.getIntExtra("led-off", 800);
|
int ledOffMs = intent.getIntExtra("led-off", 800);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user