Use parallel executor

We should eventually replace all with EmailAsyncTask, but it's the safest thing
we can do now to avoid regression.

Change-Id: I78bfc4fb2be1dcfadeb7f90092ec7adb35c1d393
This commit is contained in:
Makoto Onuki 2011-06-30 16:10:06 -07:00
parent 09e7fffb2a
commit bc2eaadde9
8 changed files with 24 additions and 20 deletions

View File

@ -21,6 +21,7 @@ import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.utility.Utility;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Handler;
import android.util.Log;
@ -283,7 +284,8 @@ public class RefreshManager {
if (LOG_ENABLED) {
Log.d(Logging.LOG_TAG, "sendPendingMessagesForAllAccounts");
}
new SendPendingMessagesForAllAccountsImpl().execute();
new SendPendingMessagesForAllAccountsImpl()
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
private class SendPendingMessagesForAllAccountsImpl extends Utility.ForEachAccount {

View File

@ -158,7 +158,7 @@ public class AccountCheckSettingsFragment extends Fragment {
Account checkAccount = SetupData.getAccount();
mAccountCheckTask = (AccountCheckTask)
new AccountCheckTask(checkMode, checkAccount)
.execute();
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}

View File

@ -160,7 +160,7 @@ public class AccountSecurity extends Activity {
}
finish();
}
}.execute();
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
/**

View File

@ -218,7 +218,8 @@ public abstract class AccountServerBaseFragment extends Fragment
*/
protected void startDuplicateTaskCheck(long accountId, String checkHost, String checkLogin,
int checkSettingsMode) {
new DuplicateCheckTask(accountId, checkHost, checkLogin, checkSettingsMode).execute();
new DuplicateCheckTask(accountId, checkHost, checkLogin, checkSettingsMode)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
/**
@ -329,7 +330,7 @@ public abstract class AccountServerBaseFragment extends Fragment
// Signal to owning activity that a settings check completed
mCallback.onCheckSettingsComplete(settingsResult, SetupData.getFlowMode());
}
}.execute();
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
/**

View File

@ -166,7 +166,8 @@ public class AccountSettings extends PreferenceActivity {
if (ACTION_ACCOUNT_MANAGER_ENTRY.equals(i.getAction())) {
// This case occurs if we're changing account settings from Settings -> Accounts
mGetAccountIdFromAccountTask =
(GetAccountIdFromAccountTask) new GetAccountIdFromAccountTask().execute(i);
(GetAccountIdFromAccountTask) new GetAccountIdFromAccountTask()
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, i);
} else {
// Otherwise, we're called from within the Email app and look for our extras
mRequestedAccountId = IntentUtilities.getAccountIdFromIntent(i);
@ -348,7 +349,8 @@ public class AccountSettings extends PreferenceActivity {
if (hasHeaders()) {
Utility.cancelTaskInterrupt(mLoadAccountListTask);
mLoadAccountListTask = (LoadAccountListTask)
new LoadAccountListTask().execute(mDeletingAccountId);
new LoadAccountListTask().executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR, mDeletingAccountId);
}
}

View File

@ -308,7 +308,8 @@ public class AccountSettingsFragment extends PreferenceFragment {
*/
public void startLoadingAccount(long accountId) {
Utility.cancelTaskInterrupt(mLoadAccountTask);
mLoadAccountTask = new LoadAccountTask().execute(accountId);
mLoadAccountTask = new LoadAccountTask().executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR, accountId);
}
/**

View File

@ -208,7 +208,7 @@ public class AccountSetupBasics extends AccountSetupActivity
// If there are one or more accounts already in existence, then display
// the "use as default" checkbox (it defaults to hidden).
new DisplayCheckboxTask().execute();
new DisplayCheckboxTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
boolean manualButtonDisplayed = true;
boolean alternateStrings = false;
@ -436,7 +436,8 @@ public class AccountSetupBasics extends AccountSetupActivity
// Stop here if the login credentials duplicate an existing account
// Launch an Async task to do the work
new DuplicateCheckTask(this, recvAuth.mAddress, mProvider.incomingUsername).execute();
new DuplicateCheckTask(this, recvAuth.mAddress, mProvider.incomingUsername)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (URISyntaxException e) {
/*
* If there is some problem with the URI we give up and go on to manual setup.

View File

@ -50,7 +50,6 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi
private EditText mName;
private View mAccountNameLabel;
private Button mNextButton;
private boolean mNextPressed = false;
private boolean mEasAccount = false;
public static void actionSetNames(Activity fromActivity) {
@ -122,13 +121,7 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi
public void onClick(View v) {
switch (v.getId()) {
case R.id.next:
// Don't allow this more than once (we do some work in an async thread before
// finish()'ing the Activity, which allows this code to potentially be
// executed multiple times.
if (!mNextPressed) {
onNext();
}
mNextPressed = true;
onNext();
break;
}
}
@ -154,7 +147,7 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi
*/
@Override
public void onBackPressed() {
if (!mNextPressed) {
if (mNextButton.isEnabled()) {
finishActivity();
}
}
@ -180,6 +173,8 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi
* and other steps to finish the creation of the account.
*/
private void onNext() {
mNextButton.setEnabled(false); // Protect against double-tap.
// Update account object from UI
Account account = SetupData.getAccount();
String description = mDescription.getText().toString().trim();
@ -189,7 +184,9 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi
account.setSenderName(mName.getText().toString().trim());
// Launch async task for final commit work
new FinalSetupTask(account).execute();
// Sicne it's a write task, use the serial executor so even if we ran the task twice
// with different values the result would be consistent.
new FinalSetupTask(account).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
}
/**