fix playstore flavor

This commit is contained in:
Daniel Gultsch 2018-03-08 16:27:33 +01:00
parent e89378ceae
commit 5e32b4ab17
2 changed files with 38 additions and 46 deletions

View file

@ -22,9 +22,7 @@ public class MaintenanceReceiver extends BroadcastReceiver {
}
private void renewInstanceToken(final Context context) {
new Thread(new Runnable() {
@Override
public void run() {
new Thread(() -> {
InstanceID instanceID = InstanceID.getInstance(context);
try {
instanceID.deleteInstanceID();
@ -34,7 +32,6 @@ public class MaintenanceReceiver extends BroadcastReceiver {
} catch (IOException e) {
Log.d(Config.LOGTAG, "unable to renew instance token", e);
}
}
}).start();
}

View file

@ -15,26 +15,24 @@ import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xmpp.XmppConnection;
import eu.siacs.conversations.xmpp.forms.Data;
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid;
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
import rocks.xmpp.addr.Jid;
public class PushManagementService {
private static final String APP_SERVER = "push.siacs.eu";
private static final Jid APP_SERVER = Jid.of("push.siacs.eu");
protected final XmppConnectionService mXmppConnectionService;
public PushManagementService(XmppConnectionService service) {
PushManagementService(XmppConnectionService service) {
this.mXmppConnectionService = service;
}
public void registerPushTokenOnServer(final Account account) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": has push support");
void registerPushTokenOnServer(final Account account) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": has push support");
retrieveGcmInstanceToken(token -> {
try {
final String deviceId = Settings.Secure.getString(mXmppConnectionService.getContentResolver(), Settings.Secure.ANDROID_ID);
IqPacket packet = mXmppConnectionService.getIqGenerator().pushTokenToAppServer(Jid.fromString(APP_SERVER), token, deviceId);
IqPacket packet = mXmppConnectionService.getIqGenerator().pushTokenToAppServer(APP_SERVER, token, deviceId);
mXmppConnectionService.sendIqPacket(account, packet, (a, p) -> {
Element command = p.findChild("command", "http://jabber.org/protocol/commands");
if (p.getType() == IqPacket.TYPE.RESULT && command != null) {
@ -44,21 +42,18 @@ public class PushManagementService {
try {
String node = data.getValue("node");
String secret = data.getValue("secret");
Jid jid = Jid.fromString(data.getValue("jid"));
Jid jid = Jid.of(data.getValue("jid"));
if (node != null && secret != null) {
enablePushOnServer(a, jid, node, secret);
}
} catch (InvalidJidException e) {
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
} else {
Log.d(Config.LOGTAG, a.getJid().toBareJid()+": invalid response from app server");
Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": invalid response from app server");
}
});
} catch (InvalidJidException ignored) {
}
});
}
@ -66,9 +61,9 @@ public class PushManagementService {
IqPacket enable = mXmppConnectionService.getIqGenerator().enablePush(jid, node, secret);
mXmppConnectionService.sendIqPacket(account, enable, (a, p) -> {
if (p.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG, a.getJid().toBareJid() + ": successfully enabled push on server");
Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": successfully enabled push on server");
} else if (p.getType() == IqPacket.TYPE.ERROR) {
Log.d(Config.LOGTAG, a.getJid().toBareJid() + ": enabling push on server failed");
Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": enabling push on server failed");
}
});
}