diff options
Diffstat (limited to '')
10 files changed, 65 insertions, 26 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/PgpEngine.java b/src/main/java/de/pixart/messenger/crypto/PgpEngine.java index 7fb474429..8cd0e2e6f 100644 --- a/src/main/java/de/pixart/messenger/crypto/PgpEngine.java +++ b/src/main/java/de/pixart/messenger/crypto/PgpEngine.java @@ -92,7 +92,7 @@ public class PgpEngine { } break; case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: - callback.userInputRequried(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), message); + callback.userInputRequired(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), message); break; case OpenPgpApi.RESULT_CODE_ERROR: OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR); @@ -131,7 +131,7 @@ public class PgpEngine { callback.success(message); break; case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: - callback.userInputRequried(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), message); + callback.userInputRequired(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), message); break; case OpenPgpApi.RESULT_CODE_ERROR: logError(conversation.getAccount(), result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); @@ -198,7 +198,7 @@ public class PgpEngine { callback.success(account); return; case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: - callback.userInputRequried(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), account); + callback.userInputRequired(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), account); return; case OpenPgpApi.RESULT_CODE_ERROR: logError(account, result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); @@ -247,7 +247,7 @@ public class PgpEngine { callback.success(signatureBuilder.toString()); return; case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: - callback.userInputRequried(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), status); + callback.userInputRequired(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), status); return; case OpenPgpApi.RESULT_CODE_ERROR: OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR); @@ -274,7 +274,7 @@ public class PgpEngine { callback.success(contact); return; case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: - callback.userInputRequried(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), contact); + callback.userInputRequired(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), contact); return; case OpenPgpApi.RESULT_CODE_ERROR: logError(contact.getAccount(), result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); diff --git a/src/main/java/de/pixart/messenger/generator/IqGenerator.java b/src/main/java/de/pixart/messenger/generator/IqGenerator.java index ad977c7b4..52f9f5b01 100644 --- a/src/main/java/de/pixart/messenger/generator/IqGenerator.java +++ b/src/main/java/de/pixart/messenger/generator/IqGenerator.java @@ -453,6 +453,20 @@ public class IqGenerator extends AbstractGenerator { return packet; } + public IqPacket unregisterChannelOnAppServer(Jid appServer, String deviceId, String channel) { + final IqPacket packet = new IqPacket(IqPacket.TYPE.SET); + packet.setTo(appServer); + final Element command = packet.addChild("command", Namespace.COMMANDS); + command.setAttribute("node", "unregister-push-fcm"); + command.setAttribute("action", "execute"); + final Data data = new Data(); + data.put("channel", channel); + data.put("android-id", deviceId); + data.submit(); + command.addChild(data); + return packet; + } + public IqPacket enablePush(final Jid jid, final String node, final String secret) { IqPacket packet = new IqPacket(IqPacket.TYPE.SET); Element enable = packet.addChild("enable", Namespace.PUSH); diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 9d9be2a5b..ff96f255d 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -609,6 +609,7 @@ public class XmppConnectionService extends Service { toggleForegroundService(true); } String pushedAccountHash = null; + String pushedChannelHash = null; boolean interactive = false; if (action != null) { final String uuid = intent.getStringExtra("uuid"); @@ -721,6 +722,7 @@ public class XmppConnectionService extends Service { break; case ACTION_FCM_MESSAGE_RECEIVED: pushedAccountHash = intent.getStringExtra("account"); + pushedChannelHash = intent.getStringExtra("channel"); Log.d(Config.LOGTAG, "push message arrived in service. account=" + pushedAccountHash); break; case Intent.ACTION_SEND: @@ -734,13 +736,18 @@ public class XmppConnectionService extends Service { synchronized (this) { WakeLockHelper.acquire(wakeLock); boolean pingNow = ConnectivityManager.CONNECTIVITY_ACTION.equals(action) || (Config.POST_CONNECTIVITY_CHANGE_PING_INTERVAL > 0 && ACTION_POST_CONNECTIVITY_CHANGE.equals(action)); - HashSet<Account> pingCandidates = new HashSet<>(); + final HashSet<Account> pingCandidates = new HashSet<>(); + final String androidId = PhoneHelper.getAndroidId(this); for (Account account : accounts) { + final boolean pushWasMeantForThisAccount = CryptoHelper.getAccountFingerprint(account, androidId).equals(pushedAccountHash); pingNow |= processAccountState(account, interactive, "ui".equals(action), - CryptoHelper.getAccountFingerprint(account, PhoneHelper.getAndroidId(this)).equals(pushedAccountHash), + pushWasMeantForThisAccount, pingCandidates); + if (pushWasMeantForThisAccount && pushedChannelHash != null) { + checkMucStillJoined(account, pushedAccountHash, androidId); + } } if (pingNow) { for (Account account : pingCandidates) { @@ -876,6 +883,20 @@ public class XmppConnectionService extends Service { editor.apply(); } + private void checkMucStillJoined(final Account account, final String hash, final String androidId) { + for (final Conversation conversation : this.conversations) { + if (conversation.getAccount() == account && conversation.getMode() == Conversational.MODE_MULTI) { + Jid jid = conversation.getJid().asBareJid(); + final String currentHash = CryptoHelper.getFingerprint(jid, androidId); + if (currentHash.equals(hash)) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received cloud push notification for MUC " + jid); + return; + } + } + } + mPushManagementService.unregisterChannel(account, hash); + } + public void reinitializeMuclumbusService() { mChannelDiscoveryService.initializeMuclumbusService(); } @@ -914,7 +935,7 @@ public class XmppConnectionService extends Service { } @Override - public void userInputRequried(PendingIntent pi, Message object) { + public void userInputRequired(PendingIntent pi, Message object) { } }); diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index 27fb7fe90..cdd4a00df 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -103,7 +103,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } @Override - public void userInputRequried(PendingIntent pi, Conversation object) { + public void userInputRequired(PendingIntent pi, Conversation object) { } }; diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index ad5b15894..04b52adc3 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -718,7 +718,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } @Override - public void userInputRequried(PendingIntent pi, Message object) { + public void userInputRequired(PendingIntent pi, Message object) { } }); @@ -752,7 +752,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } @Override - public void userInputRequried(PendingIntent pi, Message message) { + public void userInputRequired(PendingIntent pi, Message message) { hidePrepareFileToast(prepareFileToast); } }); @@ -769,7 +769,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke new UiCallback<Message>() { @Override - public void userInputRequried(PendingIntent pi, Message object) { + public void userInputRequired(PendingIntent pi, Message object) { hidePrepareFileToast(prepareFileToast); } @@ -797,7 +797,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke new UiCallback<Message>() { @Override - public void userInputRequried(PendingIntent pi, Message object) { + public void userInputRequired(PendingIntent pi, Message object) { hidePrepareFileToast(prepareFileToast); } @@ -829,7 +829,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke activity.xmppConnectionService.attachImageToConversation(conversation, uri, new UiCallback<Message>() { @Override - public void userInputRequried(PendingIntent pi, Message object) { + public void userInputRequired(PendingIntent pi, Message object) { hidePrepareFileToast(prepareFileToast); } @@ -1544,7 +1544,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke new UiCallback<Contact>() { @Override - public void userInputRequried(PendingIntent pi, Contact contact) { + public void userInputRequired(PendingIntent pi, Contact contact) { startPendingIntent(pi, attachmentChoice); } @@ -2721,7 +2721,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke new UiCallback<Contact>() { @Override - public void userInputRequried(PendingIntent pi, Contact contact) { + public void userInputRequired(PendingIntent pi, Contact contact) { startPendingIntent(pi, REQUEST_ENCRYPT_MESSAGE); } @@ -2779,7 +2779,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke new UiCallback<Message>() { @Override - public void userInputRequried(PendingIntent pi, Message message) { + public void userInputRequired(PendingIntent pi, Message message) { startPendingIntent(pi, REQUEST_SEND_MESSAGE); } diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index 6f4f00bce..980ce5bce 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -353,7 +353,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat private final UiCallback<Avatar> mAvatarFetchCallback = new UiCallback<Avatar>() { @Override - public void userInputRequried(final PendingIntent pi, final Avatar avatar) { + public void userInputRequired(final PendingIntent pi, final Avatar avatar) { finishInitialSetup(avatar); } @@ -1023,7 +1023,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } @Override - public void userInputRequried(PendingIntent pi, String object) { + public void userInputRequired(PendingIntent pi, String object) { mPendingPresenceTemplate.push(template); try { startIntentSenderForResult(pi.getIntentSender(), REQUEST_CHANGE_STATUS, null, 0, 0, 0); diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 4689add0a..68aa128b6 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -171,7 +171,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } @Override - public void userInputRequried(PendingIntent pi, Conversation object) { + public void userInputRequired(PendingIntent pi, Conversation object) { } }; @@ -1050,7 +1050,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } @Override - public void userInputRequried(PendingIntent pi, Conversation object) { + public void userInputRequired(PendingIntent pi, Conversation object) { } }); diff --git a/src/main/java/de/pixart/messenger/ui/UiCallback.java b/src/main/java/de/pixart/messenger/ui/UiCallback.java index 310a49255..59b12c7e6 100644 --- a/src/main/java/de/pixart/messenger/ui/UiCallback.java +++ b/src/main/java/de/pixart/messenger/ui/UiCallback.java @@ -7,5 +7,5 @@ public interface UiCallback<T> { void error(int errorCode, T object); - void userInputRequried(PendingIntent pi, T object); + void userInputRequired(PendingIntent pi, T object); } diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index bcdcafe37..05d5c4d31 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -164,7 +164,7 @@ public abstract class XmppActivity extends ActionBarActivity { } @Override - public void userInputRequried(PendingIntent pi, Conversation object) { + public void userInputRequired(PendingIntent pi, Conversation object) { } }; @@ -582,7 +582,7 @@ public abstract class XmppActivity extends ActionBarActivity { xmppConnectionService.getPgpEngine().generateSignature(intent, account, status, new UiCallback<String>() { @Override - public void userInputRequried(PendingIntent pi, String signature) { + public void userInputRequired(PendingIntent pi, String signature) { try { startIntentSenderForResult(pi.getIntentSender(), REQUEST_ANNOUNCE_PGP, null, 0, 0, 0); } catch (final SendIntentException ignored) { @@ -642,7 +642,7 @@ public abstract class XmppActivity extends ActionBarActivity { } @Override - public void userInputRequried(PendingIntent pi, Account object) { + public void userInputRequired(PendingIntent pi, Account object) { try { startIntentSenderForResult(pi.getIntentSender(), REQUEST_CHOOSE_PGP_ID, null, 0, 0, 0); diff --git a/src/main/java/de/pixart/messenger/utils/CryptoHelper.java b/src/main/java/de/pixart/messenger/utils/CryptoHelper.java index 5d1e7980c..6d14ccf93 100644 --- a/src/main/java/de/pixart/messenger/utils/CryptoHelper.java +++ b/src/main/java/de/pixart/messenger/utils/CryptoHelper.java @@ -246,8 +246,12 @@ public final class CryptoHelper { return prettifyFingerprintCert(bytesToHex(fingerprint)); } + public static String getFingerprint(Jid jid, String androidId) { + return getFingerprint(jid.toEscapedString() + "\00" + androidId); + } + public static String getAccountFingerprint(Account account, String androidId) { - return getFingerprint(account.getJid().asBareJid().toEscapedString() + "\00" + androidId); + return getFingerprint(account.getJid().asBareJid(), androidId); } public static String getFingerprint(String value) { |