issue ping after push was received
This commit is contained in:
parent
9f060f477f
commit
40e5090bdd
|
@ -529,6 +529,7 @@ public class XmppConnectionService extends Service {
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
final String action = intent == null ? null : intent.getAction();
|
final String action = intent == null ? null : intent.getAction();
|
||||||
|
String pushedAccountHash = null;
|
||||||
boolean interactive = false;
|
boolean interactive = false;
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
final Conversation c = findConversationByUuid(intent.getStringExtra("uuid"));
|
final Conversation c = findConversationByUuid(intent.getStringExtra("uuid"));
|
||||||
|
@ -596,6 +597,7 @@ public class XmppConnectionService extends Service {
|
||||||
break;
|
break;
|
||||||
case ACTION_GCM_MESSAGE_RECEIVED:
|
case ACTION_GCM_MESSAGE_RECEIVED:
|
||||||
Log.d(Config.LOGTAG,"gcm push message arrived in service. extras="+intent.getExtras());
|
Log.d(Config.LOGTAG,"gcm push message arrived in service. extras="+intent.getExtras());
|
||||||
|
pushedAccountHash = intent.getStringExtra("account");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -634,7 +636,7 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pingCandidates.add(account);
|
pingCandidates.add(account);
|
||||||
if (msToNextPing <= 0) {
|
if (msToNextPing <= 0 || CryptoHelper.getAccountFingerprint(account).equals(pushedAccountHash)) {
|
||||||
pingNow = true;
|
pingNow = true;
|
||||||
} else {
|
} else {
|
||||||
this.scheduleWakeUpCall((int) (msToNextPing / 1000), account.getUuid().hashCode());
|
this.scheduleWakeUpCall((int) (msToNextPing / 1000), account.getUuid().hashCode());
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Message;
|
import eu.siacs.conversations.entities.Message;
|
||||||
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
@ -204,6 +205,15 @@ public final class CryptoHelper {
|
||||||
return prettifyFingerprintCert(bytesToHex(fingerprint));
|
return prettifyFingerprintCert(bytesToHex(fingerprint));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getAccountFingerprint(Account account) {
|
||||||
|
try {
|
||||||
|
MessageDigest md = MessageDigest.getInstance("SHA256");
|
||||||
|
return bytesToHex(md.digest(account.getJid().toBareJid().toString().getBytes("UTF-8")));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int encryptionTypeToText(int encryption) {
|
public static int encryptionTypeToText(int encryption) {
|
||||||
switch (encryption) {
|
switch (encryption) {
|
||||||
case Message.ENCRYPTION_OTR:
|
case Message.ENCRYPTION_OTR:
|
||||||
|
|
Loading…
Reference in New Issue