From 17dd681dc82935e1e588029bff44cdaa1e9aeea0 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Mon, 23 Oct 2017 13:03:32 -0700 Subject: [PATCH] Run all AsyncTasks on thread pool executor Should Fix #7002 --- .../securesms/ApplicationContext.java | 3 +- .../securesms/ConfirmIdentityDialog.java | 2 +- .../securesms/ContactSelectionActivity.java | 2 +- .../securesms/ConversationActivity.java | 40 +++++++++---------- .../securesms/ConversationFragment.java | 6 +-- .../securesms/ConversationItem.java | 2 +- .../securesms/ConversationListActivity.java | 2 +- .../securesms/ConversationListFragment.java | 10 ++--- .../securesms/CreateProfileActivity.java | 4 +- .../securesms/DatabaseUpgradeActivity.java | 4 +- .../securesms/DeviceActivity.java | 3 +- .../securesms/DeviceListFragment.java | 3 +- .../securesms/GroupCreateActivity.java | 11 ++--- .../securesms/GroupMembersDialog.java | 2 +- .../securesms/ImportExportFragment.java | 4 +- .../securesms/InviteActivity.java | 6 ++- .../securesms/MediaPreviewActivity.java | 3 +- .../securesms/MessageDetailsActivity.java | 2 +- .../securesms/MessageRecipientListItem.java | 2 +- .../securesms/PassphraseChangeActivity.java | 2 +- .../securesms/PassphraseCreateActivity.java | 2 +- .../RecipientPreferenceActivity.java | 12 +++--- .../RegistrationProgressActivity.java | 4 +- .../thoughtcrime/securesms/ShareActivity.java | 2 +- .../securesms/VerifyIdentityActivity.java | 4 +- .../components/ZoomingImageView.java | 2 +- .../components/camera/CameraView.java | 2 +- .../emoji/RecentEmojiPageModel.java | 2 +- .../emoji/parsing/EmojiPageBitmap.java | 2 +- .../identity/UntrustedSendDialog.java | 2 +- .../identity/UnverifiedSendDialog.java | 2 +- .../components/reminder/InviteReminder.java | 2 +- .../components/webrtc/WebRtcCallScreen.java | 2 +- .../giph/net/GiphyProxySelector.java | 2 +- .../securesms/giph/ui/GiphyActivity.java | 2 +- .../securesms/giph/ui/GiphyFragment.java | 2 +- .../securesms/mms/AttachmentManager.java | 2 +- .../AndroidAutoHeardReceiver.java | 2 +- .../AndroidAutoReplyReceiver.java | 2 +- .../DeleteNotificationReceiver.java | 2 +- .../notifications/MarkReadReceiver.java | 2 +- .../notifications/MessageNotifier.java | 2 +- .../notifications/RemoteReplyReceiver.java | 2 +- .../AdvancedPreferenceFragment.java | 3 +- .../preferences/MmsPreferencesFragment.java | 2 +- .../NotificationsPreferenceFragment.java | 2 +- .../widgets/ProfilePreference.java | 2 +- ...ingtonePreferenceDialogFragmentCompat.java | 2 +- .../securesms/profiles/SystemProfileUtil.java | 4 +- .../securesms/profiles/UnknownSenderView.java | 4 +- .../securesms/push/AccountManagerFactory.java | 2 +- .../securesms/scribbles/ScribbleActivity.java | 2 +- .../scribbles/widget/ScribbleView.java | 2 +- .../securesms/service/KeyCachingService.java | 4 +- .../securesms/util/IdentityUtil.java | 2 +- .../thoughtcrime/securesms/util/Trimmer.java | 2 +- .../util/task/SnackbarAsyncTask.java | 2 +- 57 files changed, 107 insertions(+), 101 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ApplicationContext.java b/src/org/thoughtcrime/securesms/ApplicationContext.java index 607b638364..9f8921e112 100644 --- a/src/org/thoughtcrime/securesms/ApplicationContext.java +++ b/src/org/thoughtcrime/securesms/ApplicationContext.java @@ -202,8 +202,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc } }; - if (Build.VERSION.SDK_INT >= 11) task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - else task.execute(); + task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } diff --git a/src/org/thoughtcrime/securesms/ConfirmIdentityDialog.java b/src/org/thoughtcrime/securesms/ConfirmIdentityDialog.java index cb99911a0b..1f96051677 100644 --- a/src/org/thoughtcrime/securesms/ConfirmIdentityDialog.java +++ b/src/org/thoughtcrime/securesms/ConfirmIdentityDialog.java @@ -183,7 +183,7 @@ public class ConfirmIdentityDialog extends AlertDialog { } } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); if (callback != null) callback.onClick(null, 0); } diff --git a/src/org/thoughtcrime/securesms/ContactSelectionActivity.java b/src/org/thoughtcrime/securesms/ContactSelectionActivity.java index 8d5a731316..2dde655b42 100644 --- a/src/org/thoughtcrime/securesms/ContactSelectionActivity.java +++ b/src/org/thoughtcrime/securesms/ContactSelectionActivity.java @@ -116,7 +116,7 @@ public abstract class ContactSelectionActivity extends PassphraseRequiredActionB @Override public void onRefresh() { - new RefreshDirectoryTask(this).execute(getApplicationContext()); + new RefreshDirectoryTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, getApplicationContext()); } @Override diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index cd1167bfac..6913cd8601 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -588,7 +588,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity invalidateOptionsMenu(); if (fragment != null) fragment.setLastSeen(0); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); } @@ -607,7 +607,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); } @@ -632,7 +632,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private void handleUnblock() { @@ -655,7 +655,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }).show(); } @@ -714,7 +714,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity protected void onPostExecute(Long result) { sendComplete(result); } - }.execute(endSessionMessage); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, endSessionMessage); } } }); @@ -786,7 +786,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity .setDistributionType(threadId, ThreadDatabase.DistributionTypes.BROADCAST); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } @@ -802,7 +802,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity .setDistributionType(threadId, ThreadDatabase.DistributionTypes.CONVERSATION); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } @@ -1005,7 +1005,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity updateToggleButtonState(); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private ListenableFuture initializeSecurity(final boolean currentSecureText, @@ -1043,7 +1043,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity future.set(true); onSecurityUpdated(); } - }.execute(recipient); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, recipient); return future; } @@ -1091,7 +1091,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity protected void onPostExecute(Boolean isMmsEnabled) { ConversationActivity.this.isMmsEnabled = isMmsEnabled; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private ListenableFuture initializeIdentityRecords() { @@ -1145,7 +1145,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity future.set(true); } - }.execute(recipient); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, recipient); return future; } @@ -1427,7 +1427,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity future.set(result); } - }.execute(thisThreadId); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, thisThreadId); return future; } @@ -1537,7 +1537,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity return null; } - }.execute(threadId); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, threadId); } private void markLastSeen() { @@ -1547,7 +1547,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity DatabaseFactory.getThreadDatabase(ConversationActivity.this).setLastSeen(params[0]); return null; } - }.execute(threadId); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, threadId); } protected void sendComplete(long threadId) { @@ -1655,7 +1655,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity sendComplete(result); future.set(null); } - }.execute(outgoingMessage); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, outgoingMessage); return future; } @@ -1694,7 +1694,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity protected void onPostExecute(Long result) { sendComplete(result); } - }.execute(message); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, message); } private void updateToggleButtonState() { @@ -1715,7 +1715,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity .setDefaultSubscriptionId(recipient, subscriptionId.or(-1)); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } @Override @@ -1789,7 +1789,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity PersistentBlobProvider.getInstance(ConversationActivity.this).delete(result.first); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); } catch (InvalidMessageException e) { @@ -1821,7 +1821,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity PersistentBlobProvider.getInstance(ConversationActivity.this).delete(result.first); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } @Override @@ -1999,7 +1999,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity protected void onPostExecute(Void result) { initializeIdentityRecords(); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } diff --git a/src/org/thoughtcrime/securesms/ConversationFragment.java b/src/org/thoughtcrime/securesms/ConversationFragment.java index 61bd1a5588..9e4e91ee76 100644 --- a/src/org/thoughtcrime/securesms/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationFragment.java @@ -347,7 +347,7 @@ public class ConversationFragment extends Fragment return null; } - }.execute(messageRecords.toArray(new MessageRecord[messageRecords.size()])); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, messageRecords.toArray(new MessageRecord[messageRecords.size()])); } }); @@ -388,7 +388,7 @@ public class ConversationFragment extends Fragment MessageSender.resend(context, masterSecret, messageRecords[0]); return null; } - }.execute(message); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, message); } private void handleSaveAttachment(final MediaMmsMessageRecord message) { @@ -397,7 +397,7 @@ public class ConversationFragment extends Fragment for (Slide slide : message.getSlideDeck().getSlides()) { if ((slide.hasImage() || slide.hasVideo() || slide.hasAudio() || slide.hasDocument()) && slide.getUri() != null) { SaveAttachmentTask saveTask = new SaveAttachmentTask(getActivity(), masterSecret, list); - saveTask.execute(new Attachment(slide.getUri(), slide.getContentType(), message.getDateReceived(), slide.getFileName().orNull())); + saveTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Attachment(slide.getUri(), slide.getContentType(), message.getDateReceived(), slide.getFileName().orNull())); return; } } diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java index d66ff12700..d44ce04f20 100644 --- a/src/org/thoughtcrime/securesms/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/ConversationItem.java @@ -493,7 +493,7 @@ public class ConversationItem extends LinearLayout expirationManager.scheduleDeletion(id, mms, messageRecord.getExpiresIn()); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } else { this.expirationTimer.setVisibility(View.GONE); diff --git a/src/org/thoughtcrime/securesms/ConversationListActivity.java b/src/org/thoughtcrime/securesms/ConversationListActivity.java index 27d0a08a5e..f4dc8214ae 100644 --- a/src/org/thoughtcrime/securesms/ConversationListActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationListActivity.java @@ -215,7 +215,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private void handleInvite() { diff --git a/src/org/thoughtcrime/securesms/ConversationListFragment.java b/src/org/thoughtcrime/securesms/ConversationListFragment.java index 15e0998515..9dcac03d93 100644 --- a/src/org/thoughtcrime/securesms/ConversationListFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationListFragment.java @@ -197,7 +197,7 @@ public class ConversationListFragment extends Fragment reminderView.showReminder(reminder.get()); } } - }.execute(getActivity()); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, getActivity()); } private void initializeListAdapter() { @@ -248,7 +248,7 @@ public class ConversationListFragment extends Fragment else DatabaseFactory.getThreadDatabase(getActivity()).archiveConversation(threadId); } } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private void handleDeleteAllSelected() { @@ -294,7 +294,7 @@ public class ConversationListFragment extends Fragment actionMode = null; } } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } }); @@ -463,7 +463,7 @@ public class ConversationListFragment extends Fragment protected void reverseAction(@Nullable Long parameter) { DatabaseFactory.getThreadDatabase(getActivity()).archiveConversation(threadId); } - }.execute(threadId); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, threadId); } else { new SnackbarAsyncTask(getView(), getResources().getQuantityString(R.plurals.ConversationListFragment_conversations_archived, 1, 1), @@ -491,7 +491,7 @@ public class ConversationListFragment extends Fragment MessageNotifier.updateNotification(getActivity(), masterSecret); } } - }.execute(threadId); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, threadId); } } diff --git a/src/org/thoughtcrime/securesms/CreateProfileActivity.java b/src/org/thoughtcrime/securesms/CreateProfileActivity.java index 20a779097d..002496a555 100644 --- a/src/org/thoughtcrime/securesms/CreateProfileActivity.java +++ b/src/org/thoughtcrime/securesms/CreateProfileActivity.java @@ -270,7 +270,7 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje avatar.setImageDrawable(result.second.asDrawable(CreateProfileActivity.this, 0)); } } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else if (!excludeSystem) { SystemProfileUtil.getSystemProfileAvatar(this, new ProfileMediaConstraints()).addListener(new ListenableFuture.Listener() { @Override @@ -398,7 +398,7 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje Toast.makeText(CreateProfileActivity.this, R.string.CreateProfileActivity_problem_setting_profile, Toast.LENGTH_LONG).show(); } } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private void handleFinishedLegacy() { diff --git a/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java b/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java index bb4436c5ed..b01e753802 100644 --- a/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java +++ b/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java @@ -105,7 +105,7 @@ public class DatabaseUpgradeActivity extends BaseActivity { ProgressBar determinateProgress = (ProgressBar)findViewById(R.id.determinate_progress); new DatabaseUpgradeTask(indeterminateProgress, determinateProgress) - .execute(VersionTracker.getLastSeenVersion(this)); + .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, VersionTracker.getLastSeenVersion(this)); } else { VersionTracker.updateLastSeenVersion(this); updateNotifications(this, masterSecret); @@ -150,7 +150,7 @@ public class DatabaseUpgradeActivity extends BaseActivity { MessageNotifier.updateNotification(context, masterSecret); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } public interface DatabaseUpgradeListener { diff --git a/src/org/thoughtcrime/securesms/DeviceActivity.java b/src/org/thoughtcrime/securesms/DeviceActivity.java index c3be6c03a4..a4afe95056 100644 --- a/src/org/thoughtcrime/securesms/DeviceActivity.java +++ b/src/org/thoughtcrime/securesms/DeviceActivity.java @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms; import android.content.Context; import android.net.Uri; +import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Vibrator; @@ -210,6 +211,6 @@ public class DeviceActivity extends PassphraseRequiredActionBarActivity getSupportFragmentManager().popBackStackImmediate(); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } diff --git a/src/org/thoughtcrime/securesms/DeviceListFragment.java b/src/org/thoughtcrime/securesms/DeviceListFragment.java index c123037066..b504947b84 100644 --- a/src/org/thoughtcrime/securesms/DeviceListFragment.java +++ b/src/org/thoughtcrime/securesms/DeviceListFragment.java @@ -3,6 +3,7 @@ package org.thoughtcrime.securesms; import android.app.Activity; import android.content.Context; import android.content.DialogInterface; +import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.support.v4.app.LoaderManager; @@ -183,7 +184,7 @@ public class DeviceListFragment extends ListFragment super.onPostExecute(result); getLoaderManager().restartLoader(0, null, DeviceListFragment.this); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } @Override diff --git a/src/org/thoughtcrime/securesms/GroupCreateActivity.java b/src/org/thoughtcrime/securesms/GroupCreateActivity.java index 8ae8331f24..8f7c525e3b 100644 --- a/src/org/thoughtcrime/securesms/GroupCreateActivity.java +++ b/src/org/thoughtcrime/securesms/GroupCreateActivity.java @@ -18,6 +18,7 @@ package org.thoughtcrime.securesms; import android.app.Activity; +import android.content.AsyncTaskLoader; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; @@ -171,7 +172,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity } private void addSelectedContacts(@NonNull Recipient... recipients) { - new AddMembersTask(this).execute(recipients); + new AddMembersTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, recipients); } private void addSelectedContacts(@NonNull Collection recipients) { @@ -205,7 +206,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity final Address groupAddress = getIntent().getParcelableExtra(GROUP_ADDRESS_EXTRA); if (groupAddress != null) { - new FillExistingGroupInfoAsyncTask(this).execute(groupAddress.toGroupString()); + new FillExistingGroupInfoAsyncTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, groupAddress.toGroupString()); } } @@ -253,15 +254,15 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity return; } if (isSignalGroup()) { - new CreateSignalGroupTask(this, masterSecret, avatarBmp, getGroupName(), getAdapter().getRecipients()).execute(); + new CreateSignalGroupTask(this, masterSecret, avatarBmp, getGroupName(), getAdapter().getRecipients()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { - new CreateMmsGroupTask(this, masterSecret, getAdapter().getRecipients()).execute(); + new CreateMmsGroupTask(this, masterSecret, getAdapter().getRecipients()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } private void handleGroupUpdate() { new UpdateSignalGroupTask(this, masterSecret, groupToUpdate.get().id, avatarBmp, - getGroupName(), getAdapter().getRecipients()).execute(); + getGroupName(), getAdapter().getRecipients()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private void handleOpenConversation(long threadId, Recipient recipient) { diff --git a/src/org/thoughtcrime/securesms/GroupMembersDialog.java b/src/org/thoughtcrime/securesms/GroupMembersDialog.java index e7a7c5e559..e15b6a4ec9 100644 --- a/src/org/thoughtcrime/securesms/GroupMembersDialog.java +++ b/src/org/thoughtcrime/securesms/GroupMembersDialog.java @@ -49,7 +49,7 @@ public class GroupMembersDialog extends AsyncTask> { } public void display() { - execute(); + executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private static class GroupMembersOnClickListener implements DialogInterface.OnClickListener { diff --git a/src/org/thoughtcrime/securesms/ImportExportFragment.java b/src/org/thoughtcrime/securesms/ImportExportFragment.java index 958be145fc..d1562e1968 100644 --- a/src/org/thoughtcrime/securesms/ImportExportFragment.java +++ b/src/org/thoughtcrime/securesms/ImportExportFragment.java @@ -112,7 +112,7 @@ public class ImportExportFragment extends Fragment { builder.setPositiveButton(getActivity().getString(R.string.ImportFragment_import), new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - new ImportPlaintextBackupTask().execute(); + new ImportPlaintextBackupTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); builder.setNegativeButton(getActivity().getString(R.string.ImportFragment_cancel), null); @@ -127,7 +127,7 @@ public class ImportExportFragment extends Fragment { builder.setPositiveButton(getActivity().getString(R.string.ExportFragment_export), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - new ExportPlaintextTask().execute(); + new ExportPlaintextTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); builder.setNegativeButton(getActivity().getString(R.string.ExportFragment_cancel), null); diff --git a/src/org/thoughtcrime/securesms/InviteActivity.java b/src/org/thoughtcrime/securesms/InviteActivity.java index 9465fea67b..85b8538c8d 100644 --- a/src/org/thoughtcrime/securesms/InviteActivity.java +++ b/src/org/thoughtcrime/securesms/InviteActivity.java @@ -5,6 +5,7 @@ import android.annotation.TargetApi; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.os.AsyncTask; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.os.Bundle; @@ -116,8 +117,9 @@ public class InviteActivity extends PassphraseRequiredActionBarActivity implemen private void sendSmsInvites() { new SendSmsInvitesAsyncTask(this, inviteText.getText().toString()) - .execute(contactsFragment.getSelectedContacts() - .toArray(new String[contactsFragment.getSelectedContacts().size()])); + .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, + contactsFragment.getSelectedContacts() + .toArray(new String[contactsFragment.getSelectedContacts().size()])); } private void updateSmsButtonText() { diff --git a/src/org/thoughtcrime/securesms/MediaPreviewActivity.java b/src/org/thoughtcrime/securesms/MediaPreviewActivity.java index f2205a9c92..0ed3ec45a2 100644 --- a/src/org/thoughtcrime/securesms/MediaPreviewActivity.java +++ b/src/org/thoughtcrime/securesms/MediaPreviewActivity.java @@ -20,6 +20,7 @@ import android.annotation.TargetApi; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; +import android.os.AsyncTask; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.os.Bundle; @@ -214,7 +215,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im public void onClick(DialogInterface dialogInterface, int i) { SaveAttachmentTask saveTask = new SaveAttachmentTask(MediaPreviewActivity.this, masterSecret, image); long saveDate = (date > 0) ? date : System.currentTimeMillis(); - saveTask.execute(new Attachment(mediaUri, mediaType, saveDate, null)); + saveTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Attachment(mediaUri, mediaType, saveDate, null)); } }); } diff --git a/src/org/thoughtcrime/securesms/MessageDetailsActivity.java b/src/org/thoughtcrime/securesms/MessageDetailsActivity.java index 80c5d84291..c27c661f75 100644 --- a/src/org/thoughtcrime/securesms/MessageDetailsActivity.java +++ b/src/org/thoughtcrime/securesms/MessageDetailsActivity.java @@ -296,7 +296,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity if (messageRecord == null) { finish(); } else { - new MessageRecipientAsyncTask(this, messageRecord).execute(); + new MessageRecipientAsyncTask(this, messageRecord).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } diff --git a/src/org/thoughtcrime/securesms/MessageRecipientListItem.java b/src/org/thoughtcrime/securesms/MessageRecipientListItem.java index a90884eba5..82883c38f4 100644 --- a/src/org/thoughtcrime/securesms/MessageRecipientListItem.java +++ b/src/org/thoughtcrime/securesms/MessageRecipientListItem.java @@ -119,7 +119,7 @@ public class MessageRecipientListItem extends RelativeLayout errorDescription.setVisibility(View.GONE); actionDescription.setVisibility(View.VISIBLE); actionDescription.setText(R.string.message_recipients_list_item__resending); - new ResendAsyncTask(masterSecret, record, networkFailure).execute(); + new ResendAsyncTask(masterSecret, record, networkFailure).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }); } else { if (record.isOutgoing()) { diff --git a/src/org/thoughtcrime/securesms/PassphraseChangeActivity.java b/src/org/thoughtcrime/securesms/PassphraseChangeActivity.java index 980baabce6..b77e86c649 100644 --- a/src/org/thoughtcrime/securesms/PassphraseChangeActivity.java +++ b/src/org/thoughtcrime/securesms/PassphraseChangeActivity.java @@ -108,7 +108,7 @@ public class PassphraseChangeActivity extends PassphraseActivity { this.newPassphrase.setError(getString(R.string.PassphraseChangeActivity_enter_new_passphrase_exclamation)); this.newPassphrase.requestFocus(); } else { - new ChangePassphraseTask(this).execute(original, passphrase); + new ChangePassphraseTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, original, passphrase); } } diff --git a/src/org/thoughtcrime/securesms/PassphraseCreateActivity.java b/src/org/thoughtcrime/securesms/PassphraseCreateActivity.java index 1fec151451..8519d81b32 100644 --- a/src/org/thoughtcrime/securesms/PassphraseCreateActivity.java +++ b/src/org/thoughtcrime/securesms/PassphraseCreateActivity.java @@ -47,7 +47,7 @@ public class PassphraseCreateActivity extends PassphraseActivity { } private void initializeResources() { - new SecretGenerator().execute(MasterSecretUtil.UNENCRYPTED_PASSPHRASE); + new SecretGenerator().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, MasterSecretUtil.UNENCRYPTED_PASSPHRASE); } private class SecretGenerator extends AsyncTask { diff --git a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java index 12d584e38d..6201458ecb 100644 --- a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java +++ b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java @@ -240,7 +240,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi toolbarLayout.setTitle(recipient.toShortString()); toolbarLayout.setContentScrimColor(recipient.getColor().toActionBarColor(RecipientPreferenceActivity.this)); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } @Override @@ -443,7 +443,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi .setRingtone(recipient, params[0]); return null; } - }.execute(value); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, value); return false; } @@ -462,7 +462,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi .setVibrate(recipient, vibrateState); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return false; } @@ -492,7 +492,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi } return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } return true; } @@ -532,7 +532,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi .setMuted(recipient, until); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } @@ -608,7 +608,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi .add(new MultiDeviceBlockedUpdateJob(context)); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } } diff --git a/src/org/thoughtcrime/securesms/RegistrationProgressActivity.java b/src/org/thoughtcrime/securesms/RegistrationProgressActivity.java index 482647ddd1..7616473a1f 100644 --- a/src/org/thoughtcrime/securesms/RegistrationProgressActivity.java +++ b/src/org/thoughtcrime/securesms/RegistrationProgressActivity.java @@ -557,7 +557,7 @@ public class RegistrationProgressActivity extends BaseActionBarActivity { return NETWORK_ERROR; } } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } @@ -646,7 +646,7 @@ public class RegistrationProgressActivity extends BaseActionBarActivity { return NETWORK_ERROR; } } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } diff --git a/src/org/thoughtcrime/securesms/ShareActivity.java b/src/org/thoughtcrime/securesms/ShareActivity.java index c740b58e38..4fd25d48bb 100644 --- a/src/org/thoughtcrime/securesms/ShareActivity.java +++ b/src/org/thoughtcrime/securesms/ShareActivity.java @@ -134,7 +134,7 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity } else { fragmentContainer.setVisibility(View.GONE); progressWheel.setVisibility(View.VISIBLE); - new ResolveMediaTask(context).execute(streamExtra); + new ResolveMediaTask(context).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, streamExtra); } } diff --git a/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java b/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java index 7624b20504..d92b325821 100644 --- a/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java +++ b/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java @@ -288,7 +288,7 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity setFingerprintViews(fingerprint, true); getActivity().supportInvalidateOptionsMenu(); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); setHasOptionsMenu(true); } @@ -617,7 +617,7 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity } return null; } - }.execute(recipient); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, recipient); } } diff --git a/src/org/thoughtcrime/securesms/components/ZoomingImageView.java b/src/org/thoughtcrime/securesms/components/ZoomingImageView.java index e205b295b4..e2b12f4d0e 100644 --- a/src/org/thoughtcrime/securesms/components/ZoomingImageView.java +++ b/src/org/thoughtcrime/securesms/components/ZoomingImageView.java @@ -96,7 +96,7 @@ public class ZoomingImageView extends FrameLayout { setSubsamplingImageViewUri(uri); } } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private void setImageViewUri(MasterSecret masterSecret, Uri uri) { diff --git a/src/org/thoughtcrime/securesms/components/camera/CameraView.java b/src/org/thoughtcrime/securesms/components/camera/CameraView.java index ce771fe2c3..f125f7eb62 100644 --- a/src/org/thoughtcrime/securesms/components/camera/CameraView.java +++ b/src/org/thoughtcrime/securesms/components/camera/CameraView.java @@ -450,7 +450,7 @@ public class CameraView extends ViewGroup { Log.w(TAG, "previewFormat: " + camera.getParameters().getPreviewFormat()); Log.w(TAG, "croppingRect: " + croppingRect.toString()); Log.w(TAG, "rotation: " + rotation); - new CaptureTask(previewSize, rotation, croppingRect).execute(data); + new CaptureTask(previewSize, rotation, croppingRect).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, data); } }); } diff --git a/src/org/thoughtcrime/securesms/components/emoji/RecentEmojiPageModel.java b/src/org/thoughtcrime/securesms/components/emoji/RecentEmojiPageModel.java index 9691b33721..48620418e3 100644 --- a/src/org/thoughtcrime/securesms/components/emoji/RecentEmojiPageModel.java +++ b/src/org/thoughtcrime/securesms/components/emoji/RecentEmojiPageModel.java @@ -89,7 +89,7 @@ public class RecentEmojiPageModel implements EmojiPageModel { return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private String[] toReversePrimitiveArray(@NonNull LinkedHashSet emojiSet) { diff --git a/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiPageBitmap.java b/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiPageBitmap.java index da90721eab..59190dc777 100644 --- a/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiPageBitmap.java +++ b/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiPageBitmap.java @@ -62,7 +62,7 @@ public class EmojiPageBitmap { @Override protected void onPostExecute(Void aVoid) { task = null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } return task; } diff --git a/src/org/thoughtcrime/securesms/components/identity/UntrustedSendDialog.java b/src/org/thoughtcrime/securesms/components/identity/UntrustedSendDialog.java index 45ac6472ba..6565963802 100644 --- a/src/org/thoughtcrime/securesms/components/identity/UntrustedSendDialog.java +++ b/src/org/thoughtcrime/securesms/components/identity/UntrustedSendDialog.java @@ -57,7 +57,7 @@ public class UntrustedSendDialog extends AlertDialog.Builder implements DialogIn protected void onPostExecute(Void result) { resendListener.onResendMessage(); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } public interface ResendListener { diff --git a/src/org/thoughtcrime/securesms/components/identity/UnverifiedSendDialog.java b/src/org/thoughtcrime/securesms/components/identity/UnverifiedSendDialog.java index 9bf6e3cc27..ed41a723d8 100644 --- a/src/org/thoughtcrime/securesms/components/identity/UnverifiedSendDialog.java +++ b/src/org/thoughtcrime/securesms/components/identity/UnverifiedSendDialog.java @@ -58,7 +58,7 @@ public class UnverifiedSendDialog extends AlertDialog.Builder implements DialogI protected void onPostExecute(Void result) { resendListener.onResendMessage(); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } public interface ResendListener { diff --git a/src/org/thoughtcrime/securesms/components/reminder/InviteReminder.java b/src/org/thoughtcrime/securesms/components/reminder/InviteReminder.java index 536ce24d40..689c127960 100644 --- a/src/org/thoughtcrime/securesms/components/reminder/InviteReminder.java +++ b/src/org/thoughtcrime/securesms/components/reminder/InviteReminder.java @@ -26,7 +26,7 @@ public class InviteReminder extends Reminder { DatabaseFactory.getRecipientDatabase(context).setSeenInviteReminder(recipient, true); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); } diff --git a/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallScreen.java b/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallScreen.java index 860ca88e76..2a0f1fb1ab 100644 --- a/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallScreen.java +++ b/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallScreen.java @@ -302,7 +302,7 @@ public class WebRtcCallScreen extends FrameLayout implements RecipientModifiedLi protected void onPostExecute(final ContactPhoto contactPhoto) { WebRtcCallScreen.this.photo.setImageDrawable(contactPhoto.asCallCard(context)); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); this.name.setText(recipient.getName()); diff --git a/src/org/thoughtcrime/securesms/giph/net/GiphyProxySelector.java b/src/org/thoughtcrime/securesms/giph/net/GiphyProxySelector.java index e7c64bd487..9487fc3b9e 100644 --- a/src/org/thoughtcrime/securesms/giph/net/GiphyProxySelector.java +++ b/src/org/thoughtcrime/securesms/giph/net/GiphyProxySelector.java @@ -36,7 +36,7 @@ public class GiphyProxySelector extends ProxySelector { } return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { initializeGiphyProxy(); } diff --git a/src/org/thoughtcrime/securesms/giph/ui/GiphyActivity.java b/src/org/thoughtcrime/securesms/giph/ui/GiphyActivity.java index 00c4bacac6..c5438de10b 100644 --- a/src/org/thoughtcrime/securesms/giph/ui/GiphyActivity.java +++ b/src/org/thoughtcrime/securesms/giph/ui/GiphyActivity.java @@ -126,7 +126,7 @@ public class GiphyActivity extends PassphraseRequiredActionBarActivity Log.w(TAG, "Resolved Uri is no longer the selected element..."); } } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private static class GiphyFragmentPagerAdapter extends FragmentPagerAdapter { diff --git a/src/org/thoughtcrime/securesms/giph/ui/GiphyFragment.java b/src/org/thoughtcrime/securesms/giph/ui/GiphyFragment.java index c98b6cd812..071a9641cf 100644 --- a/src/org/thoughtcrime/securesms/giph/ui/GiphyFragment.java +++ b/src/org/thoughtcrime/securesms/giph/ui/GiphyFragment.java @@ -117,7 +117,7 @@ public abstract class GiphyFragment extends Fragment implements LoaderManager.Lo protected void onPostExecute(List images) { giphyAdapter.addImages(images); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } } diff --git a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java index de22754994..1577a3bb7b 100644 --- a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java +++ b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java @@ -303,7 +303,7 @@ public class AttachmentManager { Log.w(TAG, "local slide with size " + mediaSize + " took " + (System.currentTimeMillis() - start) + "ms"); return mediaType.createSlide(context, uri, fileName, mimeType, mediaSize); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } public boolean isAttachmentPresent() { diff --git a/src/org/thoughtcrime/securesms/notifications/AndroidAutoHeardReceiver.java b/src/org/thoughtcrime/securesms/notifications/AndroidAutoHeardReceiver.java index ba0b235435..bebaba132e 100644 --- a/src/org/thoughtcrime/securesms/notifications/AndroidAutoHeardReceiver.java +++ b/src/org/thoughtcrime/securesms/notifications/AndroidAutoHeardReceiver.java @@ -71,7 +71,7 @@ public class AndroidAutoHeardReceiver extends MasterSecretBroadcastReceiver { return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } } diff --git a/src/org/thoughtcrime/securesms/notifications/AndroidAutoReplyReceiver.java b/src/org/thoughtcrime/securesms/notifications/AndroidAutoReplyReceiver.java index 970d5c8248..1ffc6e1e04 100644 --- a/src/org/thoughtcrime/securesms/notifications/AndroidAutoReplyReceiver.java +++ b/src/org/thoughtcrime/securesms/notifications/AndroidAutoReplyReceiver.java @@ -93,7 +93,7 @@ public class AndroidAutoReplyReceiver extends MasterSecretBroadcastReceiver { return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } diff --git a/src/org/thoughtcrime/securesms/notifications/DeleteNotificationReceiver.java b/src/org/thoughtcrime/securesms/notifications/DeleteNotificationReceiver.java index 311f553451..be541f2add 100644 --- a/src/org/thoughtcrime/securesms/notifications/DeleteNotificationReceiver.java +++ b/src/org/thoughtcrime/securesms/notifications/DeleteNotificationReceiver.java @@ -35,7 +35,7 @@ public class DeleteNotificationReceiver extends BroadcastReceiver { return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } } diff --git a/src/org/thoughtcrime/securesms/notifications/MarkReadReceiver.java b/src/org/thoughtcrime/securesms/notifications/MarkReadReceiver.java index bbc3401a12..eb3794503d 100644 --- a/src/org/thoughtcrime/securesms/notifications/MarkReadReceiver.java +++ b/src/org/thoughtcrime/securesms/notifications/MarkReadReceiver.java @@ -61,7 +61,7 @@ public class MarkReadReceiver extends MasterSecretBroadcastReceiver { return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } diff --git a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java index ee8d4df59e..ffa639fd85 100644 --- a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java +++ b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java @@ -518,7 +518,7 @@ public class MessageNotifier { return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } diff --git a/src/org/thoughtcrime/securesms/notifications/RemoteReplyReceiver.java b/src/org/thoughtcrime/securesms/notifications/RemoteReplyReceiver.java index b715dc61f4..89df213019 100644 --- a/src/org/thoughtcrime/securesms/notifications/RemoteReplyReceiver.java +++ b/src/org/thoughtcrime/securesms/notifications/RemoteReplyReceiver.java @@ -86,7 +86,7 @@ public class RemoteReplyReceiver extends MasterSecretBroadcastReceiver { return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } diff --git a/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java index ee6ae9a7a0..ce635489aa 100644 --- a/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java +++ b/src/org/thoughtcrime/securesms/preferences/AdvancedPreferenceFragment.java @@ -6,6 +6,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; +import android.os.AsyncTask; import android.os.Bundle; import android.provider.ContactsContract; import android.support.annotation.NonNull; @@ -218,7 +219,7 @@ public class AdvancedPreferenceFragment extends CorrectedPreferenceFragment { builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - new DisablePushMessagesTask((CheckBoxPreference)preference).execute(); + new DisablePushMessagesTask((CheckBoxPreference)preference).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); builder.show(); diff --git a/src/org/thoughtcrime/securesms/preferences/MmsPreferencesFragment.java b/src/org/thoughtcrime/securesms/preferences/MmsPreferencesFragment.java index a7f86016c6..30169f30c0 100644 --- a/src/org/thoughtcrime/securesms/preferences/MmsPreferencesFragment.java +++ b/src/org/thoughtcrime/securesms/preferences/MmsPreferencesFragment.java @@ -53,7 +53,7 @@ public class MmsPreferencesFragment extends CorrectedPreferenceFragment { @Override public void onResume() { super.onResume(); - new LoadApnDefaultsTask().execute(); + new LoadApnDefaultsTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private class LoadApnDefaultsTask extends AsyncTask { diff --git a/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java index 76b5f3e568..bcaccf4f9c 100644 --- a/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java +++ b/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java @@ -106,7 +106,7 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme MessageNotifier.updateNotification(getActivity(), masterSecret); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return super.onPreferenceChange(preference, value); } diff --git a/src/org/thoughtcrime/securesms/preferences/widgets/ProfilePreference.java b/src/org/thoughtcrime/securesms/preferences/widgets/ProfilePreference.java index 36f14a97b0..1da84a41d6 100644 --- a/src/org/thoughtcrime/securesms/preferences/widgets/ProfilePreference.java +++ b/src/org/thoughtcrime/securesms/preferences/widgets/ProfilePreference.java @@ -87,7 +87,7 @@ public class ProfilePreference extends Preference { protected void onPostExecute(@NonNull Drawable contactPhoto) { avatarView.setImageDrawable(contactPhoto); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); if (!TextUtils.isEmpty(profileName)) { profileNameView.setText(profileName); diff --git a/src/org/thoughtcrime/securesms/preferences/widgets/RingtonePreferenceDialogFragmentCompat.java b/src/org/thoughtcrime/securesms/preferences/widgets/RingtonePreferenceDialogFragmentCompat.java index 2b009597ea..f9d9ef5a70 100644 --- a/src/org/thoughtcrime/securesms/preferences/widgets/RingtonePreferenceDialogFragmentCompat.java +++ b/src/org/thoughtcrime/securesms/preferences/widgets/RingtonePreferenceDialogFragmentCompat.java @@ -314,7 +314,7 @@ public class RingtonePreferenceDialogFragmentCompat extends PreferenceDialogFrag } } }; - installTask.execute(fileUri); + installTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, fileUri); } else { ListView listView = ((AlertDialog) getDialog()).getListView(); listView.setItemChecked(selectedIndex, true); diff --git a/src/org/thoughtcrime/securesms/profiles/SystemProfileUtil.java b/src/org/thoughtcrime/securesms/profiles/SystemProfileUtil.java index b68a3304c0..26b81628c1 100644 --- a/src/org/thoughtcrime/securesms/profiles/SystemProfileUtil.java +++ b/src/org/thoughtcrime/securesms/profiles/SystemProfileUtil.java @@ -56,7 +56,7 @@ public class SystemProfileUtil { future.set(result); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return future; } @@ -101,7 +101,7 @@ public class SystemProfileUtil { protected void onPostExecute(@Nullable String result) { future.set(result); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return future; } diff --git a/src/org/thoughtcrime/securesms/profiles/UnknownSenderView.java b/src/org/thoughtcrime/securesms/profiles/UnknownSenderView.java index fd3be5248c..a9c72b7ab0 100644 --- a/src/org/thoughtcrime/securesms/profiles/UnknownSenderView.java +++ b/src/org/thoughtcrime/securesms/profiles/UnknownSenderView.java @@ -54,7 +54,7 @@ public class UnknownSenderView extends FrameLayout { if (threadId != -1) DatabaseFactory.getThreadDatabase(context).setHasSent(threadId, true); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }) .setNegativeButton(android.R.string.cancel, null) .show(); @@ -95,7 +95,7 @@ public class UnknownSenderView extends FrameLayout { if (threadId != -1) DatabaseFactory.getThreadDatabase(context).setHasSent(threadId, true); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }) .setNegativeButton(android.R.string.cancel, null) .show(); diff --git a/src/org/thoughtcrime/securesms/push/AccountManagerFactory.java b/src/org/thoughtcrime/securesms/push/AccountManagerFactory.java index 544c6015a6..4de17e9bec 100644 --- a/src/org/thoughtcrime/securesms/push/AccountManagerFactory.java +++ b/src/org/thoughtcrime/securesms/push/AccountManagerFactory.java @@ -33,7 +33,7 @@ public class AccountManagerFactory { } return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } return new SignalServiceAccountManager(new SignalServiceNetworkAccess(context).getConfiguration(number), diff --git a/src/org/thoughtcrime/securesms/scribbles/ScribbleActivity.java b/src/org/thoughtcrime/securesms/scribbles/ScribbleActivity.java index dc481f0900..d69fd3cf28 100644 --- a/src/org/thoughtcrime/securesms/scribbles/ScribbleActivity.java +++ b/src/org/thoughtcrime/securesms/scribbles/ScribbleActivity.java @@ -165,7 +165,7 @@ public class ScribbleActivity extends PassphraseRequiredActionBarActivity implem protected void onPostExecute(@Nullable Bitmap bitmap) { addSticker(bitmap); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } } diff --git a/src/org/thoughtcrime/securesms/scribbles/widget/ScribbleView.java b/src/org/thoughtcrime/securesms/scribbles/widget/ScribbleView.java index 4c8fde1970..960f91ac7a 100644 --- a/src/org/thoughtcrime/securesms/scribbles/widget/ScribbleView.java +++ b/src/org/thoughtcrime/securesms/scribbles/widget/ScribbleView.java @@ -135,7 +135,7 @@ public class ScribbleView extends FrameLayout { canvasView.render(canvas); future.set(bitmap); } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return future; } diff --git a/src/org/thoughtcrime/securesms/service/KeyCachingService.java b/src/org/thoughtcrime/securesms/service/KeyCachingService.java index b01ca96cb3..827c791f32 100644 --- a/src/org/thoughtcrime/securesms/service/KeyCachingService.java +++ b/src/org/thoughtcrime/securesms/service/KeyCachingService.java @@ -115,7 +115,7 @@ public class KeyCachingService extends Service { } return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } @@ -204,7 +204,7 @@ public class KeyCachingService extends Service { MessageNotifier.updateNotification(KeyCachingService.this, null); return null; } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private void handleDisableService() { diff --git a/src/org/thoughtcrime/securesms/util/IdentityUtil.java b/src/org/thoughtcrime/securesms/util/IdentityUtil.java index 0a159e2bbf..7775846dbd 100644 --- a/src/org/thoughtcrime/securesms/util/IdentityUtil.java +++ b/src/org/thoughtcrime/securesms/util/IdentityUtil.java @@ -62,7 +62,7 @@ public class IdentityUtil { protected void onPostExecute(Optional result) { future.set(result); } - }.execute(recipient); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, recipient); return future; } diff --git a/src/org/thoughtcrime/securesms/util/Trimmer.java b/src/org/thoughtcrime/securesms/util/Trimmer.java index 9ba3b3166f..eac7575f09 100644 --- a/src/org/thoughtcrime/securesms/util/Trimmer.java +++ b/src/org/thoughtcrime/securesms/util/Trimmer.java @@ -12,7 +12,7 @@ import org.thoughtcrime.securesms.database.ThreadDatabase; public class Trimmer { public static void trimAllThreads(Context context, int threadLengthLimit) { - new TrimmingProgressTask(context).execute(threadLengthLimit); + new TrimmingProgressTask(context).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, threadLengthLimit); } private static class TrimmingProgressTask extends AsyncTask implements ThreadDatabase.ProgressListener { diff --git a/src/org/thoughtcrime/securesms/util/task/SnackbarAsyncTask.java b/src/org/thoughtcrime/securesms/util/task/SnackbarAsyncTask.java index db2fd0fc19..b3522c15fa 100644 --- a/src/org/thoughtcrime/securesms/util/task/SnackbarAsyncTask.java +++ b/src/org/thoughtcrime/securesms/util/task/SnackbarAsyncTask.java @@ -85,7 +85,7 @@ public abstract class SnackbarAsyncTask progressDialog = null; } } - }.execute(); + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } protected abstract void executeAction(@Nullable Params parameter);