changed jid of push server
This commit is contained in:
parent
d5a187bafb
commit
9ef2d32a3e
|
@ -387,7 +387,7 @@ public class IqGenerator extends AbstractGenerator {
|
|||
command.setAttribute("action","execute");
|
||||
Data data = new Data();
|
||||
data.put("token", token);
|
||||
data.put("device-id", deviceId);
|
||||
data.put("android-id", deviceId);
|
||||
data.submit();
|
||||
command.addChild(data);
|
||||
return packet;
|
||||
|
|
|
@ -667,7 +667,7 @@ public class XmppConnectionService extends Service {
|
|||
pingNow |= processAccountState(account,
|
||||
interactive,
|
||||
"ui".equals(action),
|
||||
CryptoHelper.getAccountFingerprint(account).equals(pushedAccountHash),
|
||||
CryptoHelper.getAccountFingerprint(account,PhoneHelper.getAndroidId(this)).equals(pushedAccountHash),
|
||||
pingCandidates);
|
||||
}
|
||||
if (pingNow) {
|
||||
|
|
|
@ -222,13 +222,13 @@ public final class CryptoHelper {
|
|||
return prettifyFingerprintCert(bytesToHex(fingerprint));
|
||||
}
|
||||
|
||||
public static String getAccountFingerprint(Account account) {
|
||||
return getFingerprint(account.getJid().asBareJid().toString());
|
||||
public static String getAccountFingerprint(Account account, String androidId) {
|
||||
return getFingerprint(account.getJid().asBareJid().toEscapedString()+"\00"+androidId);
|
||||
}
|
||||
|
||||
public static String getFingerprint(String value) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||
return bytesToHex(md.digest(value.getBytes("UTF-8")));
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.siacs.conversations.utils;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.CursorLoader;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -10,6 +11,7 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.provider.ContactsContract.Profile;
|
||||
import android.provider.Settings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -17,6 +19,11 @@ import java.util.concurrent.RejectedExecutionException;
|
|||
|
||||
public class PhoneHelper {
|
||||
|
||||
@SuppressLint("HardwareIds")
|
||||
public static String getAndroidId(Context context) {
|
||||
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
}
|
||||
|
||||
public static void loadPhoneContacts(Context context, final OnPhoneContactsLoadedListener listener) {
|
||||
final List<Bundle> phoneContacts = new ArrayList<>();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.google.android.gms.iid.InstanceID;
|
|||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.utils.PhoneHelper;
|
||||
import eu.siacs.conversations.xml.Element;
|
||||
import eu.siacs.conversations.xml.Namespace;
|
||||
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||
|
@ -20,7 +21,7 @@ import rocks.xmpp.addr.Jid;
|
|||
|
||||
public class PushManagementService {
|
||||
|
||||
private static final Jid APP_SERVER = Jid.of("push.siacs.eu");
|
||||
private static final Jid APP_SERVER = Jid.of("p2.siacs.eu");
|
||||
|
||||
protected final XmppConnectionService mXmppConnectionService;
|
||||
|
||||
|
@ -31,8 +32,8 @@ public class PushManagementService {
|
|||
void registerPushTokenOnServer(final Account account) {
|
||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": has push support");
|
||||
retrieveGcmInstanceToken(token -> {
|
||||
final String deviceId = Settings.Secure.getString(mXmppConnectionService.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
IqPacket packet = mXmppConnectionService.getIqGenerator().pushTokenToAppServer(APP_SERVER, token, deviceId);
|
||||
final String androidId = PhoneHelper.getAndroidId(mXmppConnectionService);
|
||||
IqPacket packet = mXmppConnectionService.getIqGenerator().pushTokenToAppServer(APP_SERVER, token, androidId);
|
||||
mXmppConnectionService.sendIqPacket(account, packet, (a, p) -> {
|
||||
Element command = p.findChild("command", "http://jabber.org/protocol/commands");
|
||||
if (p.getType() == IqPacket.TYPE.RESULT && command != null) {
|
||||
|
|
Loading…
Reference in New Issue