mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Set pending intents to be immutable
This commit is contained in:
@@ -41,6 +41,7 @@ import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.system.AlarmConstants.EXTRA_PID;
|
||||
import static org.briarproject.bramble.system.AlarmConstants.REQUEST_ALARM;
|
||||
import static org.briarproject.bramble.util.AndroidUtils.getImmutableFlags;
|
||||
|
||||
@ThreadSafe
|
||||
@NotNullByDefault
|
||||
@@ -199,7 +200,7 @@ class AndroidTaskScheduler implements TaskScheduler, Service, AlarmListener {
|
||||
Intent i = new Intent(app, AlarmReceiver.class);
|
||||
i.putExtra(EXTRA_PID, android.os.Process.myPid());
|
||||
return PendingIntent.getBroadcast(app, REQUEST_ALARM, i,
|
||||
FLAG_CANCEL_CURRENT);
|
||||
getImmutableFlags(FLAG_CANCEL_CURRENT));
|
||||
}
|
||||
|
||||
private class ScheduledTask
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Scanner;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static android.app.PendingIntent.FLAG_IMMUTABLE;
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static java.lang.Runtime.getRuntime;
|
||||
@@ -139,4 +140,11 @@ public class AndroidUtils {
|
||||
public static boolean isUiThread() {
|
||||
return Looper.myLooper() == Looper.getMainLooper();
|
||||
}
|
||||
|
||||
public static int getImmutableFlags(int flags) {
|
||||
if (SDK_INT >= 23) {
|
||||
return FLAG_IMMUTABLE | flags;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user