changed jid of push server

This commit is contained in:
Daniel Gultsch 2018-05-12 17:23:37 +02:00
parent d5a187bafb
commit 9ef2d32a3e
5 changed files with 16 additions and 8 deletions

View File

@ -387,7 +387,7 @@ public class IqGenerator extends AbstractGenerator {
command.setAttribute("action","execute"); command.setAttribute("action","execute");
Data data = new Data(); Data data = new Data();
data.put("token", token); data.put("token", token);
data.put("device-id", deviceId); data.put("android-id", deviceId);
data.submit(); data.submit();
command.addChild(data); command.addChild(data);
return packet; return packet;

View File

@ -667,7 +667,7 @@ public class XmppConnectionService extends Service {
pingNow |= processAccountState(account, pingNow |= processAccountState(account,
interactive, interactive,
"ui".equals(action), "ui".equals(action),
CryptoHelper.getAccountFingerprint(account).equals(pushedAccountHash), CryptoHelper.getAccountFingerprint(account,PhoneHelper.getAndroidId(this)).equals(pushedAccountHash),
pingCandidates); pingCandidates);
} }
if (pingNow) { if (pingNow) {

View File

@ -222,13 +222,13 @@ public final class CryptoHelper {
return prettifyFingerprintCert(bytesToHex(fingerprint)); return prettifyFingerprintCert(bytesToHex(fingerprint));
} }
public static String getAccountFingerprint(Account account) { public static String getAccountFingerprint(Account account, String androidId) {
return getFingerprint(account.getJid().asBareJid().toString()); return getFingerprint(account.getJid().asBareJid().toEscapedString()+"\00"+androidId);
} }
public static String getFingerprint(String value) { public static String getFingerprint(String value) {
try { try {
MessageDigest md = MessageDigest.getInstance("SHA-256"); MessageDigest md = MessageDigest.getInstance("SHA-1");
return bytesToHex(md.digest(value.getBytes("UTF-8"))); return bytesToHex(md.digest(value.getBytes("UTF-8")));
} catch (Exception e) { } catch (Exception e) {
return ""; return "";

View File

@ -1,6 +1,7 @@
package eu.siacs.conversations.utils; package eu.siacs.conversations.utils;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.CursorLoader; import android.content.CursorLoader;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -10,6 +11,7 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.provider.ContactsContract.Profile; import android.provider.ContactsContract.Profile;
import android.provider.Settings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -17,6 +19,11 @@ import java.util.concurrent.RejectedExecutionException;
public class PhoneHelper { 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) { public static void loadPhoneContacts(Context context, final OnPhoneContactsLoadedListener listener) {
final List<Bundle> phoneContacts = new ArrayList<>(); final List<Bundle> phoneContacts = new ArrayList<>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M

View File

@ -11,6 +11,7 @@ import com.google.android.gms.iid.InstanceID;
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.Account;
import eu.siacs.conversations.utils.PhoneHelper;
import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xml.Namespace; import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.XmppConnection;
@ -20,7 +21,7 @@ import rocks.xmpp.addr.Jid;
public class PushManagementService { 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; protected final XmppConnectionService mXmppConnectionService;
@ -31,8 +32,8 @@ public class PushManagementService {
void registerPushTokenOnServer(final Account account) { void registerPushTokenOnServer(final Account account) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": has push support"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": has push support");
retrieveGcmInstanceToken(token -> { retrieveGcmInstanceToken(token -> {
final String deviceId = Settings.Secure.getString(mXmppConnectionService.getContentResolver(), Settings.Secure.ANDROID_ID); final String androidId = PhoneHelper.getAndroidId(mXmppConnectionService);
IqPacket packet = mXmppConnectionService.getIqGenerator().pushTokenToAppServer(APP_SERVER, token, deviceId); IqPacket packet = mXmppConnectionService.getIqGenerator().pushTokenToAppServer(APP_SERVER, token, androidId);
mXmppConnectionService.sendIqPacket(account, packet, (a, p) -> { mXmppConnectionService.sendIqPacket(account, packet, (a, p) -> {
Element command = p.findChild("command", "http://jabber.org/protocol/commands"); Element command = p.findChild("command", "http://jabber.org/protocol/commands");
if (p.getType() == IqPacket.TYPE.RESULT && command != null) { if (p.getType() == IqPacket.TYPE.RESULT && command != null) {