add immutable flag to pending alarm intents
This commit is contained in:
parent
2c5601ccf1
commit
508e1ac1bd
|
@ -144,6 +144,7 @@ public class HttpUploadConnection implements Transferable, AbstractConnectionMan
|
|||
@Override
|
||||
public void onFailure(@NotNull final Throwable throwable) {
|
||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to request slot", throwable);
|
||||
// TODO consider fall back to jingle in 1-on-1 chats with exactly one online presence
|
||||
fail(throwable.getMessage());
|
||||
}
|
||||
}, MoreExecutors.directExecutor());
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package eu.siacs.conversations.services;
|
||||
|
||||
import static eu.siacs.conversations.utils.Compatibility.s;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
|
@ -1384,8 +1386,9 @@ public class XmppConnectionService extends Service {
|
|||
final Intent intent = new Intent(this, EventReceiver.class);
|
||||
intent.setAction(ACTION_POST_CONNECTIVITY_CHANGE);
|
||||
try {
|
||||
//TODO add immutable flag
|
||||
final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1, intent, 0);
|
||||
final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1, intent, s()
|
||||
? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
|
||||
: PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtMillis, pendingIntent);
|
||||
} else {
|
||||
|
@ -1397,7 +1400,7 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
|
||||
public void scheduleWakeUpCall(int seconds, int requestCode) {
|
||||
final long timeToWake = SystemClock.elapsedRealtime() + (seconds < 0 ? 1 : seconds + 1) * 1000;
|
||||
final long timeToWake = SystemClock.elapsedRealtime() + (seconds < 0 ? 1 : seconds + 1) * 1000L;
|
||||
final AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
if (alarmManager == null) {
|
||||
return;
|
||||
|
@ -1431,8 +1434,9 @@ public class XmppConnectionService extends Service {
|
|||
final Intent intent = new Intent(this, EventReceiver.class);
|
||||
intent.setAction(ACTION_IDLE_PING);
|
||||
try {
|
||||
//TODO add immutable flag
|
||||
final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
|
||||
final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, s()
|
||||
? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
|
||||
: PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, timeToWake, pendingIntent);
|
||||
} catch (RuntimeException e) {
|
||||
Log.d(Config.LOGTAG, "unable to schedule alarm for idle ping", e);
|
||||
|
|
Loading…
Reference in a new issue