From 8f0cd860905618ec0e15bd58587905962106be8b Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 28 Oct 2017 17:49:51 +0200 Subject: [PATCH] Resync has_enabled_account setting after delete and on start --- .../services/XmppConnectionService.java | 290 +++++++++--------- 1 file changed, 147 insertions(+), 143 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 69ac9070..9792cd3a 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -282,7 +282,7 @@ public class XmppConnectionService extends Service { private int keyStatusUpdatedListenerCount = 0; private AtomicLong mLastExpiryRun = new AtomicLong(0); private SecureRandom mRandom; - private LruCache,ServiceDiscoveryResult> discoCache = new LruCache<>(20); + private LruCache, ServiceDiscoveryResult> discoCache = new LruCache<>(20); private final OnBindListener mOnBindListener = new OnBindListener() { @Override @@ -295,7 +295,7 @@ public class XmppConnectionService extends Service { } } } - if (account.setOption(Account.OPTION_LOGGED_IN_SUCCESSFULLY,true)) { + if (account.setOption(Account.OPTION_LOGGED_IN_SUCCESSFULLY, true)) { databaseBackend.updateAccount(account); } account.getRoster().clearPresences(); @@ -342,7 +342,7 @@ public class XmppConnectionService extends Service { if (conversation.getAccount() == account && !account.pendingConferenceJoins.contains(conversation)) { if (!conversation.startOtrIfNeeded()) { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": couldn't start OTR with "+conversation.getContact().getJid()+" when needed"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": couldn't start OTR with " + conversation.getContact().getJid() + " when needed"); } sendUnsentMessages(conversation); } @@ -374,11 +374,11 @@ public class XmppConnectionService extends Service { final int next = connection.getTimeToNextAttempt(); final boolean lowPingTimeoutMode = isInLowPingTimeoutMode(account); if (next <= 0) { - Log.d(Config.LOGTAG, account.getJid().toBareJid()+": error connecting account. reconnecting now. lowPingTimeout="+Boolean.toString(lowPingTimeoutMode)); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": error connecting account. reconnecting now. lowPingTimeout=" + Boolean.toString(lowPingTimeoutMode)); reconnectAccount(account, true, false); } else { final int attempt = connection.getAttempt() + 1; - Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": error connecting account. try again in " + next + "s for the " + attempt+ " time. lowPingTimeout="+Boolean.toString(lowPingTimeoutMode)); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": error connecting account. try again in " + next + "s for the " + attempt + " time. lowPingTimeout=" + Boolean.toString(lowPingTimeoutMode)); scheduleWakeUpCall(next, account.getUuid().hashCode()); } } @@ -455,8 +455,8 @@ public class XmppConnectionService extends Service { } public void attachLocationToConversation(final Conversation conversation, - final Uri uri, - final UiCallback callback) { + final Uri uri, + final UiCallback callback) { int encryption = conversation.getNextEncryption(); if (encryption == Message.ENCRYPTION_PGP) { encryption = Message.ENCRYPTION_DECRYPTED; @@ -473,10 +473,10 @@ public class XmppConnectionService extends Service { } public void attachFileToConversation(final Conversation conversation, - final Uri uri, - final UiCallback callback) { + final Uri uri, + final UiCallback callback) { if (FileBackend.weOwnFile(this, uri)) { - Log.d(Config.LOGTAG,"trying to attach file that belonged to us"); + Log.d(Config.LOGTAG, "trying to attach file that belonged to us"); callback.error(R.string.security_error_invalid_file_access, null); return; } @@ -488,7 +488,7 @@ public class XmppConnectionService extends Service { } message.setCounterpart(conversation.getNextCounterpart()); message.setType(Message.TYPE_FILE); - final AttachFileToConversationRunnable runnable = new AttachFileToConversationRunnable(this,uri,message,callback); + final AttachFileToConversationRunnable runnable = new AttachFileToConversationRunnable(this, uri, message, callback); if (runnable.isVideoMessage()) { mVideoCompressionExecutor.execute(runnable); } else { @@ -498,7 +498,7 @@ public class XmppConnectionService extends Service { public void attachImageToConversation(final Conversation conversation, final Uri uri, final UiCallback callback) { if (FileBackend.weOwnFile(this, uri)) { - Log.d(Config.LOGTAG,"trying to attach file that belonged to us"); + Log.d(Config.LOGTAG, "trying to attach file that belonged to us"); callback.error(R.string.security_error_invalid_file_access, null); return; } @@ -509,7 +509,7 @@ public class XmppConnectionService extends Service { if ("never".equals(compressPictures) || ("auto".equals(compressPictures) && getFileBackend().useImageAsIs(uri)) || (mimeType != null && mimeType.endsWith("/gif"))) { - Log.d(Config.LOGTAG,conversation.getAccount().getJid().toBareJid()+ ": not compressing picture. sending as file"); + Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": not compressing picture. sending as file"); attachFileToConversation(conversation, uri, callback); return; } @@ -531,7 +531,7 @@ public class XmppConnectionService extends Service { final PgpEngine pgpEngine = getPgpEngine(); if (pgpEngine != null) { pgpEngine.encrypt(message, callback); - } else if (callback != null){ + } else if (callback != null) { callback.error(R.string.unable_to_connect_to_keychain, null); } } else { @@ -593,7 +593,7 @@ public class XmppConnectionService extends Service { if (remoteInput != null && c != null) { final CharSequence body = remoteInput.getCharSequence("text_reply"); if (body != null && body.length() > 0) { - directReply(c, body.toString(),intent.getBooleanExtra("dismiss_notification",false)); + directReply(c, body.toString(), intent.getBooleanExtra("dismiss_notification", false)); } } break; @@ -601,7 +601,7 @@ public class XmppConnectionService extends Service { if (c != null) { sendReadMarker(c); } else { - Log.d(Config.LOGTAG,"received mark read intent for unknown conversation ("+uuid+")"); + Log.d(Config.LOGTAG, "received mark read intent for unknown conversation (" + uuid + ")"); } break; case AudioManager.RINGER_MODE_CHANGED_ACTION: @@ -625,7 +625,7 @@ public class XmppConnectionService extends Service { } break; case ACTION_GCM_MESSAGE_RECEIVED: - Log.d(Config.LOGTAG,"gcm push message arrived in service. extras="+intent.getExtras()); + Log.d(Config.LOGTAG, "gcm push message arrived in service. extras=" + intent.getExtras()); pushedAccountHash = intent.getStringExtra("account"); break; } @@ -718,14 +718,14 @@ public class XmppConnectionService extends Service { long discoTimeout = Config.CONNECT_DISCO_TIMEOUT - secondsSinceLastDisco; long timeout = Config.CONNECT_TIMEOUT - secondsSinceLastConnect; if (timeout < 0) { - Log.d(Config.LOGTAG, account.getJid() + ": time out during connect reconnecting (secondsSinceLast="+secondsSinceLastConnect+")"); + Log.d(Config.LOGTAG, account.getJid() + ": time out during connect reconnecting (secondsSinceLast=" + secondsSinceLastConnect + ")"); account.getXmppConnection().resetAttemptCount(false); reconnectAccount(account, true, interactive); } else if (discoTimeout < 0) { account.getXmppConnection().sendDiscoTimeout(); - scheduleWakeUpCall((int) Math.min(timeout,discoTimeout), account.getUuid().hashCode()); + scheduleWakeUpCall((int) Math.min(timeout, discoTimeout), account.getUuid().hashCode()); } else { - scheduleWakeUpCall((int) Math.min(timeout,discoTimeout), account.getUuid().hashCode()); + scheduleWakeUpCall((int) Math.min(timeout, discoTimeout), account.getUuid().hashCode()); } } else { if (account.getXmppConnection().getTimeToNextAttempt() <= 0) { @@ -748,7 +748,7 @@ public class XmppConnectionService extends Service { } private void directReply(Conversation conversation, String body, final boolean dismissAfterReply) { - Message message = new Message(conversation,body,conversation.getNextEncryption()); + Message message = new Message(conversation, body, conversation.getNextEncryption()); message.markUnread(); if (message.getEncryption() == Message.ENCRYPTION_PGP) { getPgpEngine().encrypt(message, new UiCallback() { @@ -757,7 +757,7 @@ public class XmppConnectionService extends Service { message.setEncryption(Message.ENCRYPTION_DECRYPTED); sendMessage(message); if (dismissAfterReply) { - markRead(message.getConversation(),true); + markRead(message.getConversation(), true); } else { mNotificationService.pushFromDirectReply(message); } @@ -776,7 +776,7 @@ public class XmppConnectionService extends Service { } else { sendMessage(message); if (dismissAfterReply) { - markRead(conversation,true); + markRead(conversation, true); } else { mNotificationService.pushFromDirectReply(message); } @@ -796,7 +796,7 @@ public class XmppConnectionService extends Service { } private boolean awayWhenScreenOff() { - return getBooleanPreference(SettingsActivity.AWAY_WHEN_SCREEN_IS_OFF,R.bool.away_when_screen_off); + return getBooleanPreference(SettingsActivity.AWAY_WHEN_SCREEN_IS_OFF, R.bool.away_when_screen_off); } private String getCompressPicturesPreference() { @@ -836,7 +836,7 @@ public class XmppConnectionService extends Service { return audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT; } } catch (Throwable throwable) { - Log.d(Config.LOGTAG,"platform bug in isPhoneSilenced ("+ throwable.getMessage()+")"); + Log.d(Config.LOGTAG, "platform bug in isPhoneSilenced (" + throwable.getMessage() + ")"); return false; } } @@ -860,7 +860,7 @@ public class XmppConnectionService extends Service { private void dismissErrorNotifications() { for (final Account account : this.accounts) { if (account.hasErrorStatus()) { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": dismissing error notification"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": dismissing error notification"); if (account.setShowErrorNotification(false)) { databaseBackend.updateAccount(account); } @@ -919,15 +919,17 @@ public class XmppConnectionService extends Service { } }; - Log.d(Config.LOGTAG,"initializing database..."); + Log.d(Config.LOGTAG, "initializing database..."); this.databaseBackend = DatabaseBackend.getInstance(getApplicationContext()); - Log.d(Config.LOGTAG,"restoring accounts..."); + Log.d(Config.LOGTAG, "restoring accounts..."); this.accounts = databaseBackend.getAccounts(); - - if (this.accounts.size() == 0 && Arrays.asList("Sony","Sony Ericsson").contains(Build.MANUFACTURER)) { - getPreferences().edit().putBoolean(SettingsActivity.KEEP_FOREGROUND_SERVICE,true).commit(); - Log.d(Config.LOGTAG,Build.MANUFACTURER+" is on blacklist. enabling foreground service"); + final SharedPreferences.Editor editor = getPreferences().edit(); + if (this.accounts.size() == 0 && Arrays.asList("Sony", "Sony Ericsson").contains(Build.MANUFACTURER)) { + editor.putBoolean(SettingsActivity.KEEP_FOREGROUND_SERVICE, true); + Log.d(Config.LOGTAG, Build.MANUFACTURER + " is on blacklist. enabling foreground service"); } + editor.putBoolean(EventReceiver.SETTING_ENABLED_ACCOUNTS, hasEnabledAccounts()).apply(); + editor.apply(); restoreFromDatabase(); @@ -939,12 +941,12 @@ public class XmppConnectionService extends Service { } }).start(); if (Config.supportOpenPgp()) { - this.pgpServiceConnection = new OpenPgpServiceConnection(getApplicationContext(), "org.sufficientlysecure.keychain", new OpenPgpServiceConnection.OnBound() { + this.pgpServiceConnection = new OpenPgpServiceConnection(this, "org.sufficientlysecure.keychain", new OpenPgpServiceConnection.OnBound() { @Override public void onBound(IOpenPgpService2 service) { for (Account account : accounts) { final PgpDecryptionService pgp = account.getPgpDecryptionService(); - if(pgp != null) { + if (pgp != null) { pgp.continueDecryption(true); } } @@ -967,7 +969,7 @@ public class XmppConnectionService extends Service { scheduleNextIdlePing(); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - registerReceiver(this.mEventReceiver,new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); + registerReceiver(this.mEventReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); } } @@ -1008,22 +1010,22 @@ public class XmppConnectionService extends Service { public void toggleForegroundService() { if (mForceForegroundService.get() || (keepForegroundService() && hasEnabledAccounts())) { startForeground(NotificationService.FOREGROUND_NOTIFICATION_ID, this.mNotificationService.createForegroundNotification()); - Log.d(Config.LOGTAG,"started foreground service"); + Log.d(Config.LOGTAG, "started foreground service"); } else { stopForeground(true); - Log.d(Config.LOGTAG,"stopped foreground service"); + Log.d(Config.LOGTAG, "stopped foreground service"); } } public boolean keepForegroundService() { - return getBooleanPreference(SettingsActivity.KEEP_FOREGROUND_SERVICE,R.bool.enable_foreground_service); + return getBooleanPreference(SettingsActivity.KEEP_FOREGROUND_SERVICE, R.bool.enable_foreground_service); } @Override public void onTaskRemoved(final Intent rootIntent) { super.onTaskRemoved(rootIntent); if (keepForegroundService() || mForceForegroundService.get()) { - Log.d(Config.LOGTAG,"ignoring onTaskRemoved because foreground service is activated"); + Log.d(Config.LOGTAG, "ignoring onTaskRemoved because foreground service is activated"); } else { this.logoutAndSave(false); } @@ -1062,14 +1064,14 @@ public class XmppConnectionService extends Service { @TargetApi(Build.VERSION_CODES.M) private void scheduleNextIdlePing() { - Log.d(Config.LOGTAG,"schedule next idle ping"); + Log.d(Config.LOGTAG, "schedule next idle ping"); AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(this, EventReceiver.class); intent.setAction(ACTION_IDLE_PING); alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, - SystemClock.elapsedRealtime()+(Config.IDLE_PING_INTERVAL * 1000), - PendingIntent.getBroadcast(this,0,intent,0) - ); + SystemClock.elapsedRealtime() + (Config.IDLE_PING_INTERVAL * 1000), + PendingIntent.getBroadcast(this, 0, intent, 0) + ); } public XmppConnection createConnection(final Account account) { @@ -1111,7 +1113,7 @@ public class XmppConnectionService extends Service { private void sendFileMessage(final Message message, final boolean delay) { Log.d(Config.LOGTAG, "send file message"); final Account account = message.getConversation().getAccount(); - if (account.httpUploadAvailable(fileBackend.getFile(message,false).getSize()) + if (account.httpUploadAvailable(fileBackend.getFile(message, false).getSize()) || message.getConversation().getMode() == Conversation.MODE_MULTI) { mHttpConnectionManager.createNewUploadConnection(message, delay); } else { @@ -1153,7 +1155,7 @@ public class XmppConnectionService extends Service { switch (message.getEncryption()) { case Message.ENCRYPTION_NONE: if (message.needsUploading()) { - if (account.httpUploadAvailable(fileBackend.getFile(message,false).getSize()) + if (account.httpUploadAvailable(fileBackend.getFile(message, false).getSize()) || conversation.getMode() == Conversation.MODE_MULTI || message.fixCounterpart()) { this.sendFileMessage(message, delay); @@ -1167,7 +1169,7 @@ public class XmppConnectionService extends Service { case Message.ENCRYPTION_PGP: case Message.ENCRYPTION_DECRYPTED: if (message.needsUploading()) { - if (account.httpUploadAvailable(fileBackend.getFile(message,false).getSize()) + if (account.httpUploadAvailable(fileBackend.getFile(message, false).getSize()) || conversation.getMode() == Conversation.MODE_MULTI || message.fixCounterpart()) { this.sendFileMessage(message, delay); @@ -1195,17 +1197,17 @@ public class XmppConnectionService extends Service { if (message.fixCounterpart()) { conversation.startOtrSession(message.getCounterpart().getResourcepart(), true); } else { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not fix counterpart for OTR message to contact "+message.getCounterpart()); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not fix counterpart for OTR message to contact " + message.getCounterpart()); break; } } else { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+" OTR session with "+message.getContact()+" is in wrong state: "+otrSession.getSessionStatus().toString()); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + " OTR session with " + message.getContact() + " is in wrong state: " + otrSession.getSessionStatus().toString()); } break; case Message.ENCRYPTION_AXOLOTL: message.setFingerprint(account.getAxolotlService().getOwnFingerprint()); if (message.needsUploading()) { - if (account.httpUploadAvailable(fileBackend.getFile(message,false).getSize()) + if (account.httpUploadAvailable(fileBackend.getFile(message, false).getSize()) || conversation.getMode() == Conversation.MODE_MULTI || message.fixCounterpart()) { this.sendFileMessage(message, delay); @@ -1255,7 +1257,7 @@ public class XmppConnectionService extends Service { break; case Message.ENCRYPTION_OTR: if (!conversation.hasValidOtrSession() && message.getCounterpart() != null) { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": create otr session without starting for "+message.getContact().getJid()); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": create otr session without starting for " + message.getContact().getJid()); conversation.startOtrSession(message.getCounterpart().getResourcepart(), false); } break; @@ -1365,7 +1367,7 @@ public class XmppConnectionService extends Service { } public void pushBookmarks(Account account) { - Log.d(Config.LOGTAG, account.getJid().toBareJid()+": pushing bookmarks"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": pushing bookmarks"); IqPacket iqPacket = new IqPacket(IqPacket.TYPE.SET); Element query = iqPacket.query("jabber:iq:private"); Element storage = query.addChild("storage", "storage:bookmarks"); @@ -1381,31 +1383,31 @@ public class XmppConnectionService extends Service { for (Account account : this.accounts) { accountLookupTable.put(account.getUuid(), account); } - Log.d(Config.LOGTAG,"restoring conversations..."); + Log.d(Config.LOGTAG, "restoring conversations..."); final long startTimeConversationsRestore = SystemClock.elapsedRealtime(); this.conversations.addAll(databaseBackend.getConversations(Conversation.STATUS_AVAILABLE)); - for(Iterator iterator = conversations.listIterator(); iterator.hasNext();) { + for (Iterator iterator = conversations.listIterator(); iterator.hasNext(); ) { Conversation conversation = iterator.next(); Account account = accountLookupTable.get(conversation.getAccountUuid()); if (account != null) { conversation.setAccount(account); } else { - Log.e(Config.LOGTAG,"unable to restore Conversations with "+conversation.getJid()); + Log.e(Config.LOGTAG, "unable to restore Conversations with " + conversation.getJid()); iterator.remove(); } } long diffConversationsRestore = SystemClock.elapsedRealtime() - startTimeConversationsRestore; - Log.d(Config.LOGTAG,"finished restoring conversations in "+diffConversationsRestore+"ms"); + Log.d(Config.LOGTAG, "finished restoring conversations in " + diffConversationsRestore + "ms"); Runnable runnable = new Runnable() { @Override public void run() { long deletionDate = getAutomaticMessageDeletionDate(); mLastExpiryRun.set(SystemClock.elapsedRealtime()); if (deletionDate > 0) { - Log.d(Config.LOGTAG, "deleting messages that are older than "+AbstractGenerator.getTimestamp(deletionDate)); + Log.d(Config.LOGTAG, "deleting messages that are older than " + AbstractGenerator.getTimestamp(deletionDate)); databaseBackend.expireOldMessages(deletionDate); } - Log.d(Config.LOGTAG,"restoring roster..."); + Log.d(Config.LOGTAG, "restoring roster..."); for (Account account : accounts) { databaseBackend.readRoster(account.getRoster()); account.initAccountServices(XmppConnectionService.this); //roster needs to be loaded at this stage @@ -1434,7 +1436,7 @@ public class XmppConnectionService extends Service { mNotificationService.finishBacklog(false); mRestoredFromDatabase = true; final long diffMessageRestore = SystemClock.elapsedRealtime() - startMessageRestore; - Log.d(Config.LOGTAG, "finished restoring messages in "+diffMessageRestore+"ms"); + Log.d(Config.LOGTAG, "finished restoring messages in " + diffMessageRestore + "ms"); updateConversationUi(); } }; @@ -1481,7 +1483,7 @@ public class XmppConnectionService extends Service { } } Log.d(Config.LOGTAG, "finished merging phone contacts"); - mShortcutService.refresh(mInitialAddressbookSyncCompleted.compareAndSet(false,true)); + mShortcutService.refresh(mInitialAddressbookSyncCompleted.compareAndSet(false, true)); updateAccountUi(); } }); @@ -1510,7 +1512,7 @@ public class XmppConnectionService extends Service { } private void markFileDeleted(final String path) { - Log.d(Config.LOGTAG,"deleted file "+path); + Log.d(Config.LOGTAG, "deleted file " + path); for (Conversation conversation : getConversations()) { conversation.findMessagesWithFiles(new Conversation.OnMessageFound() { @Override @@ -1526,7 +1528,7 @@ public class XmppConnectionService extends Service { updateConversationUi(); } } else { - Log.d(Config.LOGTAG,"found matching message for file "+path+" but file still exists"); + Log.d(Config.LOGTAG, "found matching message for file " + path + " but file still exists"); } } } @@ -1599,7 +1601,7 @@ public class XmppConnectionService extends Service { public List findAllConferencesWith(Contact contact) { ArrayList results = new ArrayList<>(); - for(Conversation conversation : conversations) { + for (Conversation conversation : conversations) { if (conversation.getMode() == Conversation.MODE_MULTI && conversation.getMucOptions().isContactInRoom(contact)) { results.add(conversation); @@ -1631,7 +1633,7 @@ public class XmppConnectionService extends Service { } public Conversation findOrCreateConversation(Account account, Jid jid, boolean muc, final boolean async) { - return this.findOrCreateConversation(account,jid,muc,false, async); + return this.findOrCreateConversation(account, jid, muc, false, async); } public Conversation findOrCreateConversation(final Account account, final Jid jid, final boolean muc, final boolean joinAfterCreate, final boolean async) { @@ -1657,7 +1659,7 @@ public class XmppConnectionService extends Service { conversation.setContactJid(jid.toBareJid()); } databaseBackend.updateConversation(conversation); - loadMessagesFromDb = conversation.messagesLoaded.compareAndSet(true,false); + loadMessagesFromDb = conversation.messagesLoaded.compareAndSet(true, false); } else { String conversationName; Contact contact = account.getRoster().getContact(jid); @@ -1692,7 +1694,7 @@ public class XmppConnectionService extends Service { mMessageArchiveService.query(c); } else { if (query.getConversation() == null) { - mMessageArchiveService.query(c, query.getStart(),query.isCatchup()); + mMessageArchiveService.query(c, query.getStart(), query.isCatchup()); } } } @@ -1753,7 +1755,7 @@ public class XmppConnectionService extends Service { } private void syncEnabledAccountSetting() { - getPreferences().edit().putBoolean(EventReceiver.SETTING_ENABLED_ACCOUNTS,hasEnabledAccounts()).apply(); + getPreferences().edit().putBoolean(EventReceiver.SETTING_ENABLED_ACCOUNTS, hasEnabledAccounts()).apply(); } public void createAccountFromKey(final String alias, final OnAccountCreated callback) { @@ -1794,10 +1796,10 @@ public class XmppConnectionService extends Service { } public void updateKeyInAccount(final Account account, final String alias) { - Log.d(Config.LOGTAG, account.getJid().toBareJid()+": update key in account " + alias); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": update key in account " + alias); try { X509Certificate[] chain = KeyChain.getCertificateChain(XmppConnectionService.this, alias); - Log.d(Config.LOGTAG,account.getJid().toBareJid()+" loaded certificate chain"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + " loaded certificate chain"); Pair info = CryptoHelper.extractJidAndName(chain[0]); if (account.getJid().toBareJid().equals(info.first)) { account.setPrivateKeyAlias(alias); @@ -1876,7 +1878,7 @@ public class XmppConnectionService extends Service { @Override public void run() { if (!databaseBackend.deleteAccount(account)) { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": unable to delete account"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": unable to delete account"); } } }; @@ -1884,6 +1886,7 @@ public class XmppConnectionService extends Service { this.accounts.remove(account); updateAccountUi(); getNotificationService().updateErrorNotification(); + syncEnabledAccountSetting(); } } @@ -2114,7 +2117,7 @@ public class XmppConnectionService extends Service { if (account.getStatus() == Account.State.ONLINE) { account.deactivateGracePeriod(); final XmppConnection connection = account.getXmppConnection(); - if (connection != null ) { + if (connection != null) { if (connection.getFeatures().csi()) { connection.sendActive(); } @@ -2156,7 +2159,7 @@ public class XmppConnectionService extends Service { } public void joinMuc(Conversation conversation) { - joinMuc(conversation,null, false); + joinMuc(conversation, null, false); } public void joinMuc(Conversation conversation, boolean followedInvite) { @@ -2164,7 +2167,7 @@ public class XmppConnectionService extends Service { } private void joinMuc(Conversation conversation, final OnConferenceJoined onConferenceJoined) { - joinMuc(conversation,onConferenceJoined,false); + joinMuc(conversation, onConferenceJoined, false); } private void joinMuc(Conversation conversation, final OnConferenceJoined onConferenceJoined, final boolean followedInvite) { @@ -2214,7 +2217,7 @@ public class XmppConnectionService extends Service { if (mucOptions.membersOnly() && mucOptions.nonanonymous()) { fetchConferenceMembers(conversation); if (followedInvite && conversation.getBookmark() == null) { - saveConversationAsBookmark(conversation,null); + saveConversationAsBookmark(conversation, null); } } sendUnsentMessages(conversation); @@ -2248,7 +2251,7 @@ public class XmppConnectionService extends Service { private void fetchConferenceMembers(final Conversation conversation) { final Account account = conversation.getAccount(); final AxolotlService axolotlService = account.getAxolotlService(); - final String[] affiliations = {"member","admin","owner"}; + final String[] affiliations = {"member", "admin", "owner"}; OnIqPacketReceived callback = new OnIqPacketReceived() { private int i = 0; @@ -2259,9 +2262,9 @@ public class XmppConnectionService extends Service { Element query = packet.query("http://jabber.org/protocol/muc#admin"); if (packet.getType() == IqPacket.TYPE.RESULT && query != null) { - for(Element child : query.getChildren()) { + for (Element child : query.getChildren()) { if ("item".equals(child.getName())) { - MucOptions.User user = AbstractParser.parseItem(conversation,child); + MucOptions.User user = AbstractParser.parseItem(conversation, child); if (!user.realJidMatchesAccount()) { boolean isNew = conversation.getMucOptions().updateUser(user); if (isNew && user.getRealJid() != null && axolotlService.hasEmptyDeviceList(user.getRealJid())) { @@ -2272,7 +2275,7 @@ public class XmppConnectionService extends Service { } } else { success = false; - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not request affiliation "+affiliations[i]+" in "+conversation.getJid().toBareJid()); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not request affiliation " + affiliations[i] + " in " + conversation.getJid().toBareJid()); } ++i; if (i >= affiliations.length) { @@ -2280,11 +2283,11 @@ public class XmppConnectionService extends Service { if (success) { List cryptoTargets = conversation.getAcceptedCryptoTargets(); boolean changed = false; - for(ListIterator iterator = cryptoTargets.listIterator(); iterator.hasNext();) { + for (ListIterator iterator = cryptoTargets.listIterator(); iterator.hasNext(); ) { Jid jid = iterator.next(); if (!members.contains(jid)) { iterator.remove(); - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": removed "+jid+" from crypto targets of "+conversation.getName()); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": removed " + jid + " from crypto targets of " + conversation.getName()); changed = true; } } @@ -2293,17 +2296,17 @@ public class XmppConnectionService extends Service { updateConversation(conversation); } } - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": retrieved members for "+conversation.getJid().toBareJid()+": "+conversation.getMucOptions().getMembers()); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": retrieved members for " + conversation.getJid().toBareJid() + ": " + conversation.getMucOptions().getMembers()); getAvatarService().clear(conversation); updateMucRosterUi(); updateConversationUi(); } } }; - for(String affiliation : affiliations) { + for (String affiliation : affiliations) { sendIqPacket(account, mIqGenerator.queryAffiliation(conversation, affiliation), callback); } - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": fetching members for "+conversation.getName()); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": fetching members for " + conversation.getName()); } public void providePasswordForMuc(Conversation conversation, String password) { @@ -2321,7 +2324,7 @@ public class XmppConnectionService extends Service { } private boolean hasEnabledAccounts() { - for(Account account : this.accounts) { + for (Account account : this.accounts) { if (!account.isOptionSet(Account.OPTION_DISABLED)) { return true; } @@ -2416,9 +2419,9 @@ public class XmppConnectionService extends Service { } public boolean createAdhocConference(final Account account, - final String subject, - final Iterable jids, - final UiCallback callback) { + final String subject, + final Iterable jids, + final UiCallback callback) { Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": creating adhoc conference with " + jids.toString()); if (account.getStatus() == Account.State.ONLINE) { try { @@ -2488,7 +2491,7 @@ public class XmppConnectionService extends Service { sendIqPacket(conversation.getAccount(), request, new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket packet) { - Element query = packet.findChild("query","http://jabber.org/protocol/disco#info"); + Element query = packet.findChild("query", "http://jabber.org/protocol/disco#info"); if (packet.getType() == IqPacket.TYPE.RESULT && query != null) { ArrayList features = new ArrayList<>(); for (Element child : query.getChildren()) { @@ -2507,7 +2510,7 @@ public class XmppConnectionService extends Service { if (callback != null) { callback.onConferenceConfigurationFetched(conversation); } - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": fetched muc configuration for "+conversation.getJid().toBareJid()+" - "+features.toString()); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": fetched muc configuration for " + conversation.getJid().toBareJid() + " - " + features.toString()); updateConversationUi(); } else if (packet.getType() == IqPacket.TYPE.ERROR) { if (callback != null) { @@ -2519,17 +2522,17 @@ public class XmppConnectionService extends Service { } public void pushNodeConfiguration(Account account, final String node, final Bundle options, final OnConfigurationPushed callback) { - pushNodeConfiguration(account,account.getJid().toBareJid(),node,options,callback); + pushNodeConfiguration(account, account.getJid().toBareJid(), node, options, callback); } public void pushNodeConfiguration(Account account, final Jid jid, final String node, final Bundle options, final OnConfigurationPushed callback) { - sendIqPacket(account, mIqGenerator.requestPubsubConfiguration(jid,node), new OnIqPacketReceived() { + sendIqPacket(account, mIqGenerator.requestPubsubConfiguration(jid, node), new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket packet) { if (packet.getType() == IqPacket.TYPE.RESULT) { - Element pubsub = packet.findChild("pubsub","http://jabber.org/protocol/pubsub#owner"); + Element pubsub = packet.findChild("pubsub", "http://jabber.org/protocol/pubsub#owner"); Element configuration = pubsub == null ? null : pubsub.findChild("configure"); - Element x = configuration == null ? null : configuration.findChild("x","jabber:x:data"); + Element x = configuration == null ? null : configuration.findChild("x", "jabber:x:data"); if (x != null) { Data data = Data.parse(x); data.submit(options); @@ -2539,14 +2542,14 @@ public class XmppConnectionService extends Service { if (packet.getType() == IqPacket.TYPE.RESULT && callback != null) { callback.onPushSucceeded(); } else { - Log.d(Config.LOGTAG,packet.toString()); + Log.d(Config.LOGTAG, packet.toString()); } } }); - } else if (callback !=null) { + } else if (callback != null) { callback.onPushFailed(); } - } else if (callback != null){ + } else if (callback != null) { callback.onPushFailed(); } } @@ -2825,20 +2828,20 @@ public class XmppConnectionService extends Service { getAvatarService().clear(account); databaseBackend.updateAccount(account); } - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": published avatar "+(avatar.size/1024)+"KiB"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": published avatar " + (avatar.size / 1024) + "KiB"); if (callback != null) { callback.success(avatar); } } else { if (callback != null) { - callback.error(R.string.error_publish_avatar_server_reject,avatar); + callback.error(R.string.error_publish_avatar_server_reject, avatar); } } } }); } else { Element error = result.findChild("error"); - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": server rejected avatar "+(avatar.size/1024)+"KiB "+(error!=null?error.toString():"")); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": server rejected avatar " + (avatar.size / 1024) + "KiB " + (error != null ? error.toString() : "")); if (callback != null) { callback.error(R.string.error_publish_avatar_server_reject, avatar); } @@ -2849,7 +2852,7 @@ public class XmppConnectionService extends Service { public void republishAvatarIfNeeded(Account account) { if (account.getAxolotlService().isPepBroken()) { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": skipping republication of avatar because pep is broken"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": skipping republication of avatar because pep is broken"); return; } IqPacket packet = this.mIqGenerator.retrieveAvatarMetaData(null); @@ -2880,10 +2883,10 @@ public class XmppConnectionService extends Service { if (serverAvatar == null && account.getAvatar() != null) { Avatar avatar = fileBackend.getStoredPepAvatar(account.getAvatar()); if (avatar != null) { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": avatar on server was null. republishing"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": avatar on server was null. republishing"); publishAvatar(account, fileBackend.getStoredPepAvatar(account.getAvatar()), null); } else { - Log.e(Config.LOGTAG, account.getJid().toBareJid()+": error rereading avatar"); + Log.e(Config.LOGTAG, account.getJid().toBareJid() + ": error rereading avatar"); } } } @@ -2989,7 +2992,7 @@ public class XmppConnectionService extends Service { + ": successfully fetched vCard avatar for " + avatar.owner); if (avatar.owner.isBareJid()) { if (account.getJid().toBareJid().equals(avatar.owner) && account.getAvatar() == null) { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": had no avatar. replacing with vcard"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": had no avatar. replacing with vcard"); account.setAvatar(avatar.getFilename()); databaseBackend.updateAccount(account); getAvatarService().clear(account); @@ -3028,7 +3031,7 @@ public class XmppConnectionService extends Service { @Override public void onIqPacketReceived(Account account, IqPacket packet) { if (packet.getType() == IqPacket.TYPE.RESULT) { - Element pubsub = packet.findChild("pubsub","http://jabber.org/protocol/pubsub"); + Element pubsub = packet.findChild("pubsub", "http://jabber.org/protocol/pubsub"); if (pubsub != null) { Element items = pubsub.findChild("items"); if (items != null) { @@ -3203,21 +3206,21 @@ public class XmppConnectionService extends Service { } public long getAutomaticMessageDeletionDate() { - final long timeout = getLongPreference(SettingsActivity.AUTOMATIC_MESSAGE_DELETION,R.integer.automatic_message_deletion); + final long timeout = getLongPreference(SettingsActivity.AUTOMATIC_MESSAGE_DELETION, R.integer.automatic_message_deletion); return timeout == 0 ? timeout : (System.currentTimeMillis() - (timeout * 1000)); } public long getLongPreference(String name, @IntegerRes int res) { long defaultValue = getResources().getInteger(res); try { - return Long.parseLong(getPreferences().getString(name,String.valueOf(defaultValue))); + return Long.parseLong(getPreferences().getString(name, String.valueOf(defaultValue))); } catch (NumberFormatException e) { return defaultValue; } } public boolean getBooleanPreference(String name, @BoolRes int res) { - return getPreferences().getBoolean(name,getResources().getBoolean(res)); + return getPreferences().getBoolean(name, getResources().getBoolean(res)); } public boolean confirmMessages() { @@ -3334,7 +3337,7 @@ public class XmppConnectionService extends Service { } public boolean markRead(final Conversation conversation) { - return markRead(conversation,true); + return markRead(conversation, true); } public boolean markRead(final Conversation conversation, boolean clear) { @@ -3447,10 +3450,10 @@ public class XmppConnectionService extends Service { } } } - if(Config.DOMAIN_LOCK != null && !hosts.contains(Config.DOMAIN_LOCK)) { + if (Config.DOMAIN_LOCK != null && !hosts.contains(Config.DOMAIN_LOCK)) { hosts.add(Config.DOMAIN_LOCK); } - if(Config.MAGIC_CREATE_DOMAIN != null && !hosts.contains(Config.MAGIC_CREATE_DOMAIN)) { + if (Config.MAGIC_CREATE_DOMAIN != null && !hosts.contains(Config.MAGIC_CREATE_DOMAIN)) { hosts.add(Config.MAGIC_CREATE_DOMAIN); } return hosts; @@ -3464,7 +3467,7 @@ public class XmppConnectionService extends Service { if (server != null && !mucServers.contains(server)) { mucServers.add(server); } - for(Bookmark bookmark : account.getBookmarks()) { + for (Bookmark bookmark : account.getBookmarks()) { final Jid jid = bookmark.getJid(); final String s = jid == null ? null : jid.getDomainpart(); if (s != null && !mucServers.contains(s)) { @@ -3512,7 +3515,7 @@ public class XmppConnectionService extends Service { private void sendPresence(final Account account, final boolean includeIdleTimestamp) { PresencePacket packet; if (manuallyChangePresence()) { - packet = mPresenceGenerator.selfPresence(account, account.getPresenceStatus()); + packet = mPresenceGenerator.selfPresence(account, account.getPresenceStatus()); String message = account.getPresenceStatusMessage(); if (message != null && !message.isEmpty()) { packet.addChild(new Element("status").setContent(message)); @@ -3522,13 +3525,13 @@ public class XmppConnectionService extends Service { } if (mLastActivity > 0 && includeIdleTimestamp) { long since = Math.min(mLastActivity, System.currentTimeMillis()); //don't send future dates - packet.addChild("idle",Namespace.IDLE).setAttribute("since", AbstractGenerator.getTimestamp(since)); + packet.addChild("idle", Namespace.IDLE).setAttribute("since", AbstractGenerator.getTimestamp(since)); } sendPresencePacket(account, packet); } private void deactivateGracePeriod() { - for(Account account : getAccounts()) { + for (Account account : getAccounts()) { account.deactivateGracePeriod(); } } @@ -3543,7 +3546,7 @@ public class XmppConnectionService extends Service { } private void refreshAllGcmTokens() { - for(Account account : getAccounts()) { + for (Account account : getAccounts()) { if (account.isOnlineAndConnected() && mPushManagementService.available(account)) { mPushManagementService.registerPushTokenOnServer(account); } @@ -3551,7 +3554,7 @@ public class XmppConnectionService extends Service { } private void sendOfflinePresence(final Account account) { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": sending offline presence"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": sending offline presence"); sendPresencePacket(account, mPresenceGenerator.sendOfflinePresence(account)); } @@ -3594,7 +3597,7 @@ public class XmppConnectionService extends Service { } public Conversation findFirstMuc(Jid jid) { - for(Conversation conversation : getConversations()) { + for (Conversation conversation : getConversations()) { if (conversation.getJid().toBareJid().equals(jid.toBareJid()) && conversation.getMode() == Conversation.MODE_MULTI) { return conversation; @@ -3642,7 +3645,7 @@ public class XmppConnectionService extends Service { } conversation.clearMessages(); conversation.setHasMessagesLeftOnServer(false); //avoid messages getting loaded through mam - conversation.setLastClearHistory(clearDate,reference); + conversation.setLastClearHistory(clearDate, reference); Runnable runnable = new Runnable() { @Override public void run() { @@ -3666,7 +3669,7 @@ public class XmppConnectionService extends Service { } } }); - if (removeBlockedConversations(blockable.getAccount(),jid)) { + if (removeBlockedConversations(blockable.getAccount(), jid)) { updateConversationUi(); return true; } else { @@ -3681,7 +3684,7 @@ public class XmppConnectionService extends Service { boolean removed = false; synchronized (this.conversations) { boolean domainJid = blockedJid.isDomainJid(); - for(Conversation conversation : this.conversations) { + for (Conversation conversation : this.conversations) { boolean jidMatches = (domainJid && blockedJid.getDomainpart().equals(conversation.getJid().getDomainpart())) || blockedJid.equals(conversation.getJid().toBareJid()); if (conversation.getAccount() == account @@ -3690,7 +3693,7 @@ public class XmppConnectionService extends Service { this.conversations.remove(conversation); markRead(conversation); conversation.setStatus(Conversation.STATUS_ARCHIVED); - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": archiving conversation "+conversation.getJid().toBareJid()+" because jid was blocked"); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": archiving conversation " + conversation.getJid().toBareJid() + " because jid was blocked"); updateConversation(conversation); removed = true; } @@ -3743,7 +3746,7 @@ public class XmppConnectionService extends Service { } public void fetchCaps(Account account, final Jid jid, final Presence presence) { - final Pair key = new Pair<>(presence.getHash(), presence.getVer()); + final Pair key = new Pair<>(presence.getHash(), presence.getVer()); ServiceDiscoveryResult disco = getCachedServiceDiscoveryResult(key); if (disco != null) { presence.setServiceDiscoveryResult(disco); @@ -3753,7 +3756,7 @@ public class XmppConnectionService extends Service { IqPacket request = new IqPacket(IqPacket.TYPE.GET); request.setTo(jid); request.query("http://jabber.org/protocol/disco#info"); - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": making disco request for "+key.second+" to "+jid); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": making disco request for " + key.second + " to " + jid); sendIqPacket(account, request, new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket discoPacket) { @@ -3774,8 +3777,8 @@ public class XmppConnectionService extends Service { } private void injectServiceDiscorveryResult(Roster roster, String hash, String ver, ServiceDiscoveryResult disco) { - for(Contact contact : roster.getContacts()) { - for(Presence presence : contact.getPresences().getPresences().values()) { + for (Contact contact : roster.getContacts()) { + for (Presence presence : contact.getPresences().getPresences().values()) { if (hash.equals(presence.getHash()) && ver.equals(presence.getVer())) { presence.setServiceDiscoveryResult(disco); } @@ -3786,11 +3789,11 @@ public class XmppConnectionService extends Service { public void fetchMamPreferences(Account account, final OnMamPreferencesFetched callback) { final boolean legacy = account.getXmppConnection().getFeatures().mamLegacy(); IqPacket request = new IqPacket(IqPacket.TYPE.GET); - request.addChild("prefs",legacy ? Namespace.MAM_LEGACY : Namespace.MAM); + request.addChild("prefs", legacy ? Namespace.MAM_LEGACY : Namespace.MAM); sendIqPacket(account, request, new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket packet) { - Element prefs = packet.findChild("prefs",legacy ? Namespace.MAM_LEGACY : Namespace.MAM); + Element prefs = packet.findChild("prefs", legacy ? Namespace.MAM_LEGACY : Namespace.MAM); if (packet.getType() == IqPacket.TYPE.RESULT && prefs != null) { callback.onPreferencesFetched(prefs); } else { @@ -3806,7 +3809,7 @@ public class XmppConnectionService extends Service { public Account getPendingAccount() { Account pending = null; - for(Account account : getAccounts()) { + for (Account account : getAccounts()) { if (account.isOptionSet(Account.OPTION_REGISTER)) { pending = account; } else { @@ -3836,14 +3839,14 @@ public class XmppConnectionService extends Service { if (!statusMessage.isEmpty()) { databaseBackend.insertPresenceTemplate(new PresenceTemplate(status, statusMessage)); } - for(Account account : getAccounts()) { + for (Account account : getAccounts()) { changeStatusReal(account, status, statusMessage, true); } } public List getPresenceTemplates(Account account) { List templates = databaseBackend.getPresenceTemplates(); - for(PresenceTemplate template : account.getSelfContact().getPresences().asTemplates()) { + for (PresenceTemplate template : account.getSelfContact().getPresences().asTemplates()) { if (!templates.contains(template)) { templates.add(0, template); } @@ -3860,7 +3863,7 @@ public class XmppConnectionService extends Service { if (name != null && !name.trim().isEmpty()) { bookmark.setBookmarkName(name.trim()); } - bookmark.setAutojoin(getPreferences().getBoolean("autojoin",getResources().getBoolean(R.bool.autojoin))); + bookmark.setAutojoin(getPreferences().getBoolean("autojoin", getResources().getBoolean(R.bool.autojoin))); account.getBookmarks().add(bookmark); pushBookmarks(account); conversation.setBookmark(bookmark); @@ -3870,20 +3873,20 @@ public class XmppConnectionService extends Service { boolean needsRosterWrite = false; boolean performedVerification = false; final AxolotlService axolotlService = contact.getAccount().getAxolotlService(); - for(XmppUri.Fingerprint fp : fingerprints) { + for (XmppUri.Fingerprint fp : fingerprints) { if (fp.type == XmppUri.FingerprintType.OTR) { performedVerification |= contact.addOtrFingerprint(fp.fingerprint); needsRosterWrite |= performedVerification; } else if (fp.type == XmppUri.FingerprintType.OMEMO) { - String fingerprint = "05"+fp.fingerprint.replaceAll("\\s",""); + String fingerprint = "05" + fp.fingerprint.replaceAll("\\s", ""); FingerprintStatus fingerprintStatus = axolotlService.getFingerprintTrust(fingerprint); if (fingerprintStatus != null) { if (!fingerprintStatus.isVerified()) { performedVerification = true; - axolotlService.setFingerprintTrust(fingerprint,fingerprintStatus.toVerified()); + axolotlService.setFingerprintTrust(fingerprint, fingerprintStatus.toVerified()); } } else { - axolotlService.preVerifyFingerprint(contact,fingerprint); + axolotlService.preVerifyFingerprint(contact, fingerprint); } } } @@ -3896,18 +3899,18 @@ public class XmppConnectionService extends Service { public boolean verifyFingerprints(Account account, List fingerprints) { final AxolotlService axolotlService = account.getAxolotlService(); boolean verifiedSomething = false; - for(XmppUri.Fingerprint fp : fingerprints) { + for (XmppUri.Fingerprint fp : fingerprints) { if (fp.type == XmppUri.FingerprintType.OMEMO) { - String fingerprint = "05"+fp.fingerprint.replaceAll("\\s",""); - Log.d(Config.LOGTAG,"trying to verify own fp="+fingerprint); + String fingerprint = "05" + fp.fingerprint.replaceAll("\\s", ""); + Log.d(Config.LOGTAG, "trying to verify own fp=" + fingerprint); FingerprintStatus fingerprintStatus = axolotlService.getFingerprintTrust(fingerprint); if (fingerprintStatus != null) { if (!fingerprintStatus.isVerified()) { - axolotlService.setFingerprintTrust(fingerprint,fingerprintStatus.toVerified()); + axolotlService.setFingerprintTrust(fingerprint, fingerprintStatus.toVerified()); verifiedSomething = true; } } else { - axolotlService.preVerifyFingerprint(account,fingerprint); + axolotlService.preVerifyFingerprint(account, fingerprint); verifiedSomething = true; } } @@ -3916,7 +3919,7 @@ public class XmppConnectionService extends Service { } public boolean blindTrustBeforeVerification() { - return getBooleanPreference(SettingsActivity.BLIND_TRUST_BEFORE_VERIFICATION,R.bool.btbv); + return getBooleanPreference(SettingsActivity.BLIND_TRUST_BEFORE_VERIFICATION, R.bool.btbv); } public ShortcutService getShortcutService() { @@ -3925,6 +3928,7 @@ public class XmppConnectionService extends Service { public interface OnMamPreferencesFetched { void onPreferencesFetched(Element prefs); + void onPreferencesFetchFailed(); } @@ -3974,9 +3978,9 @@ public class XmppConnectionService extends Service { public interface OnCaptchaRequested { void onCaptchaRequested(Account account, - String id, - Data data, - Bitmap captcha); + String id, + Data data, + Bitmap captcha); } public interface OnRosterUpdate {