summaryrefslogtreecommitdiffstats
path: root/emailcommon
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2015-03-20 03:13:35 +0100
committerSteve Kondik <steve@cyngn.com>2015-10-18 14:03:22 -0700
commit8b1818d4a89912768bd6b1c94ff6eec25b072087 (patch)
tree74fcc2bb7d5844d8f8db94899758ee0d63b02abe /emailcommon
parentf119f904ed4c2d2089df3d9243488cd1de04e405 (diff)
downloadandroid_packages_apps_Email-8b1818d4a89912768bd6b1c94ff6eec25b072087.tar.gz
android_packages_apps_Email-8b1818d4a89912768bd6b1c94ff6eec25b072087.tar.bz2
android_packages_apps_Email-8b1818d4a89912768bd6b1c94ff6eec25b072087.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.java7
-rw-r--r--emailcommon/src/com/android/emailcommon/service/ServiceProxy.java20
2 files changed, 22 insertions, 5 deletions
diff --git a/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java b/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java
index 36a0d336e..4fc08ee11 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
@@ -259,6 +261,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 3669345c1..8adffc43e 100644
--- a/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java
+++ b/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java
@@ -31,6 +31,8 @@ import android.os.RemoteException;
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,
@@ -133,8 +135,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");
}
@@ -142,7 +144,7 @@ public abstract class ServiceProxy {
}
return null;
}
- }.execute();
+ }.executeOnExecutor(mTask.runInExecutor());
}
@Override
@@ -154,8 +156,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) {
@@ -178,6 +183,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);
}
@@ -203,7 +211,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
}