diff options
| author | Yu Ping Hu <yph@google.com> | 2013-07-29 19:11:41 -0700 |
|---|---|---|
| committer | Yu Ping Hu <yph@google.com> | 2013-07-29 20:04:42 -0700 |
| commit | 2075c97f608a853923980865b72147a5c8ef71f0 (patch) | |
| tree | 43c5d92264ec0f0292bb2b484068d0596dd2c8f8 /emailcommon | |
| parent | c362f66ee1d47b2bb84170d5e2fc15a550753761 (diff) | |
| download | android_packages_apps_Email-2075c97f608a853923980865b72147a5c8ef71f0.tar.gz android_packages_apps_Email-2075c97f608a853923980865b72147a5c8ef71f0.tar.bz2 android_packages_apps_Email-2075c97f608a853923980865b72147a5c8ef71f0.zip | |
Delete most of IEmailServiceCallback.
The old callback mechanism is deprecated, in favor of making
calls on the ContentProvider.
Bug: 9842867
Change-Id: I65f559e593cda24456c4ffb96f785e054626dd0b
Diffstat (limited to 'emailcommon')
5 files changed, 6 insertions, 227 deletions
diff --git a/emailcommon/src/com/android/emailcommon/service/EmailServiceCallback.java b/emailcommon/src/com/android/emailcommon/service/EmailServiceCallback.java deleted file mode 100644 index 97c1e49c8..000000000 --- a/emailcommon/src/com/android/emailcommon/service/EmailServiceCallback.java +++ /dev/null @@ -1,118 +0,0 @@ -/* Copyright (C) 2012 The Android Open Source Project. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.emailcommon.service; - -import android.os.RemoteCallbackList; -import android.os.RemoteException; - -import com.android.emailcommon.service.IEmailServiceCallback.Stub; -import com.android.mail.utils.LogUtils; - -public class EmailServiceCallback extends Stub { - - private final RemoteCallbackList<IEmailServiceCallback> mCallbackList; - - public EmailServiceCallback(RemoteCallbackList<IEmailServiceCallback> callbackList) { - mCallbackList = callbackList; - } - /** - * Broadcast a callback to the everyone that's registered - * - * @param wrapper the ServiceCallbackWrapper used in the broadcast - */ - private synchronized void broadcastCallback(ServiceCallbackWrapper wrapper) { - RemoteCallbackList<IEmailServiceCallback> callbackList = mCallbackList; - if (callbackList != null) { - // Call everyone on our callback list - int count = callbackList.beginBroadcast(); - try { - for (int i = 0; i < count; i++) { - try { - wrapper.call(callbackList.getBroadcastItem(i)); - } catch (RemoteException e) { - // Safe to ignore - } catch (RuntimeException e) { - // We don't want an exception in one call to prevent other calls, so - // we'll just log this and continue - LogUtils.e("EmailServiceCallback", "Caught RuntimeException in broadcast", - e); - } - } - } finally { - // No matter what, we need to finish the broadcast - callbackList.finishBroadcast(); - } - } - } - - @Override - public void loadAttachmentStatus(final long messageId, final long attachmentId, - final int status, final int progress) { - broadcastCallback(new ServiceCallbackWrapper() { - @Override - public void call(IEmailServiceCallback cb) throws RemoteException { - cb.loadAttachmentStatus(messageId, attachmentId, status, progress); - } - }); - } - - @Override - public void loadMessageStatus(final long messageId, final int status, final int progress) { - broadcastCallback(new ServiceCallbackWrapper() { - @Override - public void call(IEmailServiceCallback cb) throws RemoteException { - cb.loadMessageStatus(messageId, status, progress); - } - }); - } - - @Override - public void sendMessageStatus(final long messageId, final String subject, final int status, - final int progress) { - broadcastCallback(new ServiceCallbackWrapper() { - @Override - public void call(IEmailServiceCallback cb) throws RemoteException { - cb.sendMessageStatus(messageId, subject, status, progress); - } - }); - } - - @Override - public void syncMailboxListStatus(final long accountId, final int status, - final int progress) { - broadcastCallback(new ServiceCallbackWrapper() { - @Override - public void call(IEmailServiceCallback cb) throws RemoteException { - cb.syncMailboxListStatus(accountId, status, progress); - } - }); - } - - @Override - public void syncMailboxStatus(final long mailboxId, final int status, - final int progress) { - broadcastCallback(new ServiceCallbackWrapper() { - @Override - public void call(IEmailServiceCallback cb) throws RemoteException { - cb.syncMailboxStatus(mailboxId, status, progress); - } - }); - } - - private interface ServiceCallbackWrapper { - public void call(IEmailServiceCallback cb) throws RemoteException; - } -} diff --git a/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java b/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java index 129818bf4..e97e7401e 100644 --- a/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java +++ b/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java @@ -62,7 +62,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { public static final String VALIDATE_BUNDLE_PROTOCOL_VERSION = "validate_protocol_version"; public static final String VALIDATE_BUNDLE_REDIRECT_ADDRESS = "validate_redirect_address"; - private final IEmailServiceCallback mCallback; private Object mReturn = null; private IEmailService mService; private final boolean isRemote; @@ -78,31 +77,25 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { // The first two constructors are used with local services that can be referenced by class public EmailServiceProxy(Context _context, Class<?> _class) { - this(_context, _class, null); - } - - public EmailServiceProxy(Context _context, Class<?> _class, IEmailServiceCallback _callback) { super(_context, new Intent(_context, _class)); TempDirectory.setTempDirectory(_context); - mCallback = _callback; isRemote = false; } // The following two constructors are used with remote services that must be referenced by // a known action or by a prebuilt intent - public EmailServiceProxy(Context _context, Intent _intent, IEmailServiceCallback _callback) { + public EmailServiceProxy(Context _context, Intent _intent) { super(_context, _intent); try { Device.getDeviceId(_context); } catch (IOException e) { } TempDirectory.setTempDirectory(_context); - mCallback = _callback; isRemote = true; } - public EmailServiceProxy(Context _context, String _action, IEmailServiceCallback _callback) { - this(_context, new Intent(_action), _callback); + public EmailServiceProxy(Context _context, String _action) { + this(_context, new Intent(_action)); } @Override @@ -138,13 +131,12 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { @Override public void run() throws RemoteException { try { - if (mCallback != null) mService.setCallback(mCallback); - mService.loadAttachment(mCallback, attachmentId, background); + mService.loadAttachment(cb, attachmentId, background); } catch (RemoteException e) { try { // Try to send a callback (if set) - if (mCallback != null) { - mCallback.loadAttachmentStatus(-1, attachmentId, + if (cb != null) { + cb.loadAttachmentStatus(-1, attachmentId, EmailServiceStatus.REMOTE_EXCEPTION, 0); } } catch (RemoteException e1) { @@ -171,7 +163,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { setTask(new ProxyTask() { @Override public void run() throws RemoteException { - if (mCallback != null) mService.setCallback(mCallback); mService.startSync(mailboxId, userRequest, deltaMessageCount); } }, "startSync"); @@ -189,7 +180,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { setTask(new ProxyTask() { @Override public void run() throws RemoteException { - if (mCallback != null) mService.setCallback(mCallback); mService.stopSync(mailboxId); } }, "stopSync"); @@ -210,7 +200,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { setTask(new ProxyTask() { @Override public void run() throws RemoteException{ - if (mCallback != null) mService.setCallback(mCallback); mReturn = mService.validate(hostAuth); } }, "validate"); @@ -243,7 +232,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { setTask(new ProxyTask() { @Override public void run() throws RemoteException{ - if (mCallback != null) mService.setCallback(mCallback); mReturn = mService.autoDiscover(userName, password); } }, "autoDiscover"); @@ -270,7 +258,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { setTask(new ProxyTask() { @Override public void run() throws RemoteException { - if (mCallback != null) mService.setCallback(mCallback); mService.updateFolderList(accountId); } }, "updateFolderList"); @@ -287,29 +274,12 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { setTask(new ProxyTask() { @Override public void run() throws RemoteException { - if (mCallback != null) mService.setCallback(mCallback); mService.setLogging(flags); } }, "setLogging"); } /** - * Set the global callback object to be used by the service; the service MUST always use the - * most recently set callback object - * - * @param cb a callback object through which all service callbacks are executed - */ - @Override - public void setCallback(final IEmailServiceCallback cb) throws RemoteException { - setTask(new ProxyTask() { - @Override - public void run() throws RemoteException { - mService.setCallback(cb); - } - }, "setCallback"); - } - - /** * Alert the sync adapter that the account's host information has (or may have) changed; the * service MUST stop all in-process or pending syncs, clear error states related to the * account and its mailboxes, and restart necessary sync adapters (e.g. pushed mailboxes) @@ -338,7 +308,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { setTask(new ProxyTask() { @Override public void run() throws RemoteException { - if (mCallback != null) mService.setCallback(mCallback); mService.sendMeetingResponse(messageId, response); } }, "sendMeetingResponse"); @@ -354,7 +323,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { setTask(new ProxyTask() { @Override public void run() throws RemoteException { - if (mCallback != null) mService.setCallback(mCallback); mService.loadMore(messageId); } }, "startSync"); @@ -433,7 +401,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { setTask(new ProxyTask() { @Override public void run() throws RemoteException{ - if (mCallback != null) mService.setCallback(mCallback); mReturn = mService.searchMessages(accountId, searchParams, destMailboxId); } }, "searchMessages"); @@ -455,7 +422,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { setTask(new ProxyTask() { @Override public void run() throws RemoteException{ - if (mCallback != null) mService.setCallback(mCallback); mService.sendMail(accountId); } }, "sendMail"); @@ -466,7 +432,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { setTask(new ProxyTask() { @Override public void run() throws RemoteException{ - if (mCallback != null) mService.setCallback(mCallback); mReturn = mService.getCapabilities(acct); } }, "getCapabilities"); @@ -487,7 +452,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { setTask(new ProxyTask() { @Override public void run() throws RemoteException{ - if (mCallback != null) mService.setCallback(mCallback); mService.serviceUpdated(emailAddress); } }, "settingsUpdate"); diff --git a/emailcommon/src/com/android/emailcommon/service/EmailServiceStatus.java b/emailcommon/src/com/android/emailcommon/service/EmailServiceStatus.java index 969d989dd..b4f14b38a 100644 --- a/emailcommon/src/com/android/emailcommon/service/EmailServiceStatus.java +++ b/emailcommon/src/com/android/emailcommon/service/EmailServiceStatus.java @@ -64,11 +64,6 @@ public abstract class EmailServiceStatus { // Values for the SYNC_STATUS_TYPE to specify what kind of sync status we're returning. public static final int SYNC_STATUS_TYPE_MAILBOX = 0; - public static final int SYNC_STATUS_TYPE_SEND_MESSAGE = 1; - public static final int SYNC_STATUS_TYPE_MAILBOX_LIST = 2; - - // Additional status Bundle keys, used for specific status types. - public static final String SYNC_STATUS_SUBJECT = "subject"; /** * Some status updates need to provide values in addition to the core id, code, and progress. @@ -125,30 +120,4 @@ public abstract class EmailServiceStatus { syncStatus(cr, syncExtras, SYNC_STATUS_TYPE_MAILBOX, mailboxId, statusCode, progress, null); } - /** - * If the sync extras specify a callback, then notify the sync requester of the outbound - * message status. This function is for use by the - * {@link android.content.AbstractThreadedSyncAdapter}. - * @param cr A ContentResolver. - * @param syncExtras The extras provided to the sync request. - * @param messageId The message that is being sent. - * @param subject The subject line of that message, or null if the subject is unavailable. - * @param statusCode The status code for this sync operation. - * @param progress The progress of this sync operation. - */ - public static void sendMessageStatus(final ContentResolver cr, final Bundle syncExtras, - final long messageId, final String subject, final int statusCode, final int progress) { - syncStatus(cr, syncExtras, SYNC_STATUS_TYPE_SEND_MESSAGE, messageId, statusCode, progress, - new StatusWriter() { - @Override - public void addToStatus(final Bundle statusExtras) { - statusExtras.putString(SYNC_STATUS_SUBJECT, subject); - }}); - } - - public static void syncMailboxListStatus(final ContentResolver cr, final Bundle syncExtras, - final long accountId, final int statusCode, final int progress) { - syncStatus(cr, syncExtras, SYNC_STATUS_TYPE_MAILBOX_LIST, accountId, statusCode, progress, - null); - } } diff --git a/emailcommon/src/com/android/emailcommon/service/IEmailService.aidl b/emailcommon/src/com/android/emailcommon/service/IEmailService.aidl index 87affc9cb..74a55e58e 100644 --- a/emailcommon/src/com/android/emailcommon/service/IEmailService.aidl +++ b/emailcommon/src/com/android/emailcommon/service/IEmailService.aidl @@ -39,10 +39,6 @@ interface IEmailService { boolean deleteFolder(long accountId, String name); boolean renameFolder(long accountId, String oldName, String newName); - // Must not be oneway; unless an exception is thrown, the caller is guaranteed that the callback - // has been registered - void setCallback(IEmailServiceCallback cb); - oneway void setLogging(int on); oneway void hostChanged(long accountId); diff --git a/emailcommon/src/com/android/emailcommon/service/IEmailServiceCallback.aidl b/emailcommon/src/com/android/emailcommon/service/IEmailServiceCallback.aidl index c713f5211..5dd9f275c 100644 --- a/emailcommon/src/com/android/emailcommon/service/IEmailServiceCallback.aidl +++ b/emailcommon/src/com/android/emailcommon/service/IEmailServiceCallback.aidl @@ -34,22 +34,6 @@ oneway interface IEmailServiceCallback { */ /** - * Callback to indicate that an account is being synced (updating folder list) - * accountId = the account being synced - * statusCode = 0 for OK, 1 for progress, other codes for error - * progress = 0 for "start", 1..100 for optional progress reports - */ - void syncMailboxListStatus(long accountId, int statusCode, int progress); - - /** - * Callback to indicate that a mailbox is being synced - * mailboxId = the mailbox being synced - * statusCode = 0 for OK, 1 for progress, other codes for error - * progress = 0 for "start", 1..100 for optional progress reports - */ - void syncMailboxStatus(long mailboxId, int statusCode, int progress); - - /** * Callback to indicate that a particular attachment is being synced * messageId = the message that owns the attachment * attachmentId = the attachment being synced @@ -57,20 +41,4 @@ oneway interface IEmailServiceCallback { * progress = 0 for "start", 1..100 for optional progress reports */ void loadAttachmentStatus(long messageId, long attachmentId, int statusCode, int progress); - - /** - * Callback to indicate that a particular message is being sent - * messageId = the message being sent - * statusCode = 0 for OK, 1 for progress, other codes for error - * progress = 0 for "start", 1..100 for optional progress reports - */ - void sendMessageStatus(long messageId, String subject, int statusCode, int progress); - - /** - * Callback to indicate that a particular message is being loaded - * messageId = the message being sent - * statusCode = 0 for OK, 1 for progress, other codes for error - * progress = 0 for "start", 1..100 for optional progress reports - */ - void loadMessageStatus(long messageId, int statusCode, int progress); } |
