diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2015-03-20 03:13:35 +0100 |
---|---|---|
committer | Michael Bestas <mikeioannina@gmail.com> | 2016-12-30 20:15:16 +0200 |
commit | c1f42968dc1b15f81bb2adab2c6a2862813f594f (patch) | |
tree | 611e739ab7bea2a6d83ea9f1c1a285ca4e14197b /emailcommon | |
parent | b25395d0908c1c967f2958fb8f4bfb227265732b (diff) | |
download | android_packages_apps_Email-c1f42968dc1b15f81bb2adab2c6a2862813f594f.tar.gz android_packages_apps_Email-c1f42968dc1b15f81bb2adab2c6a2862813f594f.tar.bz2 android_packages_apps_Email-c1f42968dc1b15f81bb2adab2c6a2862813f594f.zip |
email: add an option for delete the account
Change-Id: I0f0f2b7ea950d5154f90cd60261c6918b7ad36b7
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'emailcommon')
-rw-r--r-- | emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java | 7 | ||||
-rw-r--r-- | emailcommon/src/com/android/emailcommon/service/ServiceProxy.java | 21 |
2 files changed, 23 insertions, 5 deletions
diff --git a/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java b/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java index 2ba5ec1cb..0cfd32e42 100644 --- a/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java +++ b/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java @@ -18,6 +18,7 @@ package com.android.emailcommon.service; import android.content.Context; import android.content.Intent; +import android.os.AsyncTask; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; @@ -30,6 +31,7 @@ import com.android.emailcommon.provider.Policy; import com.android.mail.utils.LogUtils; import java.io.IOException; +import java.util.concurrent.Executor; /** * The EmailServiceProxy class provides a simple interface for the UI to call into the various @@ -275,6 +277,11 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { public void deleteExternalAccountPIMData(final String emailAddress) throws RemoteException { setTask(new ProxyTask() { @Override + public Executor runInExecutor() { + return AsyncTask.THREAD_POOL_EXECUTOR; + } + + @Override public void run() throws RemoteException { mService.deleteExternalAccountPIMData(emailAddress); } diff --git a/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java b/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java index b59c4d57c..0e723c28c 100644 --- a/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java +++ b/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java @@ -39,6 +39,9 @@ import android.widget.Toast; import com.android.emailcommon.R; import com.android.emailcommon.provider.EmailContent; import com.android.mail.utils.LogUtils; + +import java.util.concurrent.Executor; + /** * ServiceProxy is a superclass for proxy objects which make a single call to a service. It handles * connecting to the service, running a task supplied by the subclass when the connection is ready, @@ -181,8 +184,8 @@ public abstract class ServiceProxy { "RuntimeException when trying to unbind from service"); } } - mTaskCompleted = true; synchronized(mConnection) { + mTaskCompleted = true; if (DEBUG_PROXY) { LogUtils.v(mTag, "Task " + mName + " completed; disconnecting"); } @@ -190,7 +193,7 @@ public abstract class ServiceProxy { } return null; } - }.execute(); + }.executeOnExecutor(mTask.runInExecutor()); } @Override @@ -202,8 +205,11 @@ public abstract class ServiceProxy { } } - protected interface ProxyTask { - public void run() throws RemoteException; + protected abstract class ProxyTask { + public Executor runInExecutor() { + return AsyncTask.SERIAL_EXECUTOR; + }; + public abstract void run() throws RemoteException; } public ServiceProxy setTimeout(int secs) { @@ -226,6 +232,9 @@ public abstract class ServiceProxy { if (DEBUG_PROXY) { LogUtils.v(mTag, "Bind requested for task " + mName); } + synchronized (mConnection) { + mTaskCompleted = false; + } return mContext.bindService(mIntent, mConnection, Context.BIND_AUTO_CREATE); } @@ -251,7 +260,9 @@ public abstract class ServiceProxy { if (DEBUG_PROXY) { LogUtils.v(mTag, "Waiting for task " + mName + " to complete..."); } - mConnection.wait(mTimeout * 1000L); + if (!mTaskCompleted) { + mConnection.wait(mTimeout * 1000L); + } } catch (InterruptedException e) { // Can be ignored safely } |