fix playstore flavor
This commit is contained in:
parent
e89378ceae
commit
5e32b4ab17
|
@ -22,9 +22,7 @@ public class MaintenanceReceiver extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renewInstanceToken(final Context context) {
|
private void renewInstanceToken(final Context context) {
|
||||||
new Thread(new Runnable() {
|
new Thread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
InstanceID instanceID = InstanceID.getInstance(context);
|
InstanceID instanceID = InstanceID.getInstance(context);
|
||||||
try {
|
try {
|
||||||
instanceID.deleteInstanceID();
|
instanceID.deleteInstanceID();
|
||||||
|
@ -34,7 +32,6 @@ public class MaintenanceReceiver extends BroadcastReceiver {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.d(Config.LOGTAG, "unable to renew instance token", e);
|
Log.d(Config.LOGTAG, "unable to renew instance token", e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,26 +15,24 @@ 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;
|
||||||
import eu.siacs.conversations.xmpp.forms.Data;
|
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 eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
||||||
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class PushManagementService {
|
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;
|
protected final XmppConnectionService mXmppConnectionService;
|
||||||
|
|
||||||
public PushManagementService(XmppConnectionService service) {
|
PushManagementService(XmppConnectionService service) {
|
||||||
this.mXmppConnectionService = service;
|
this.mXmppConnectionService = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerPushTokenOnServer(final Account account) {
|
void registerPushTokenOnServer(final Account account) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": has push support");
|
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": has push support");
|
||||||
retrieveGcmInstanceToken(token -> {
|
retrieveGcmInstanceToken(token -> {
|
||||||
try {
|
|
||||||
final String deviceId = Settings.Secure.getString(mXmppConnectionService.getContentResolver(), Settings.Secure.ANDROID_ID);
|
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) -> {
|
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) {
|
||||||
|
@ -44,21 +42,18 @@ public class PushManagementService {
|
||||||
try {
|
try {
|
||||||
String node = data.getValue("node");
|
String node = data.getValue("node");
|
||||||
String secret = data.getValue("secret");
|
String secret = data.getValue("secret");
|
||||||
Jid jid = Jid.fromString(data.getValue("jid"));
|
Jid jid = Jid.of(data.getValue("jid"));
|
||||||
if (node != null && secret != null) {
|
if (node != null && secret != null) {
|
||||||
enablePushOnServer(a, jid, node, secret);
|
enablePushOnServer(a, jid, node, secret);
|
||||||
}
|
}
|
||||||
} catch (InvalidJidException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
IqPacket enable = mXmppConnectionService.getIqGenerator().enablePush(jid, node, secret);
|
||||||
mXmppConnectionService.sendIqPacket(account, enable, (a, p) -> {
|
mXmppConnectionService.sendIqPacket(account, enable, (a, p) -> {
|
||||||
if (p.getType() == IqPacket.TYPE.RESULT) {
|
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) {
|
} 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");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue