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
|
@Override
|
||||||
public void onFailure(@NotNull final Throwable throwable) {
|
public void onFailure(@NotNull final Throwable throwable) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to request slot", 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());
|
fail(throwable.getMessage());
|
||||||
}
|
}
|
||||||
}, MoreExecutors.directExecutor());
|
}, MoreExecutors.directExecutor());
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package eu.siacs.conversations.services;
|
package eu.siacs.conversations.services;
|
||||||
|
|
||||||
|
import static eu.siacs.conversations.utils.Compatibility.s;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
|
@ -1384,8 +1386,9 @@ public class XmppConnectionService extends Service {
|
||||||
final Intent intent = new Intent(this, EventReceiver.class);
|
final Intent intent = new Intent(this, EventReceiver.class);
|
||||||
intent.setAction(ACTION_POST_CONNECTIVITY_CHANGE);
|
intent.setAction(ACTION_POST_CONNECTIVITY_CHANGE);
|
||||||
try {
|
try {
|
||||||
//TODO add immutable flag
|
final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1, intent, s()
|
||||||
final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1, intent, 0);
|
? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
: PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtMillis, pendingIntent);
|
alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtMillis, pendingIntent);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1397,7 +1400,7 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scheduleWakeUpCall(int seconds, int requestCode) {
|
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);
|
final AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||||
if (alarmManager == null) {
|
if (alarmManager == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -1431,8 +1434,9 @@ public class XmppConnectionService extends Service {
|
||||||
final Intent intent = new Intent(this, EventReceiver.class);
|
final Intent intent = new Intent(this, EventReceiver.class);
|
||||||
intent.setAction(ACTION_IDLE_PING);
|
intent.setAction(ACTION_IDLE_PING);
|
||||||
try {
|
try {
|
||||||
//TODO add immutable flag
|
final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, s()
|
||||||
final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
|
? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
: PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, timeToWake, pendingIntent);
|
alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, timeToWake, pendingIntent);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
Log.d(Config.LOGTAG, "unable to schedule alarm for idle ping", e);
|
Log.d(Config.LOGTAG, "unable to schedule alarm for idle ping", e);
|
||||||
|
|
Loading…
Reference in a new issue