am dc1160e4
: Merge "Explicitly pass a callback when loading attachments." into jb-ub-mail-ur10
* commit 'dc1160e4c3b16f215a5e09a7807ee9dd22b6bfad': Explicitly pass a callback when loading attachments.
This commit is contained in:
commit
4ef8d93637
@ -125,19 +125,21 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService {
|
||||
* loading has started and stopped and SHOULD send callbacks with progress information if
|
||||
* possible.
|
||||
*
|
||||
* @param cb The {@link IEmailServiceCallback} to use for this operation.
|
||||
* @param attachmentId the id of the attachment record
|
||||
* @param background whether or not this request corresponds to a background action (i.e.
|
||||
* prefetch) vs a foreground action (user request)
|
||||
*/
|
||||
@Override
|
||||
public void loadAttachment(final long attachmentId, final boolean background)
|
||||
public void loadAttachment(final IEmailServiceCallback cb, final long attachmentId,
|
||||
final boolean background)
|
||||
throws RemoteException {
|
||||
setTask(new ProxyTask() {
|
||||
@Override
|
||||
public void run() throws RemoteException {
|
||||
try {
|
||||
if (mCallback != null) mService.setCallback(mCallback);
|
||||
mService.loadAttachment(attachmentId, background);
|
||||
mService.loadAttachment(mCallback, attachmentId, background);
|
||||
} catch (RemoteException e) {
|
||||
try {
|
||||
// Try to send a callback (if set)
|
||||
@ -181,7 +183,6 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService {
|
||||
* the sync was started via the startSync service call.
|
||||
*
|
||||
* @param mailboxId the id of the mailbox record
|
||||
* @param userRequest whether or not the user specifically asked for the sync
|
||||
*/
|
||||
@Override
|
||||
public void stopSync(final long mailboxId) throws RemoteException {
|
||||
@ -262,7 +263,7 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService {
|
||||
* Request that the service reload the folder list for the specified account. The service
|
||||
* MUST use the syncMailboxListStatus callback to indicate "starting" and "finished"
|
||||
*
|
||||
* @param accoundId the id of the account whose folder list is to be updated
|
||||
* @param accountId the id of the account whose folder list is to be updated
|
||||
*/
|
||||
@Override
|
||||
public void updateFolderList(final long accountId) throws RemoteException {
|
||||
@ -479,7 +480,7 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService {
|
||||
/**
|
||||
* Request that the account be updated for this service; this call is synchronous
|
||||
*
|
||||
* @param the email address of the account to be updated
|
||||
* @param emailAddress the email address of the account to be updated
|
||||
*/
|
||||
@Override
|
||||
public void serviceUpdated(final String emailAddress) throws RemoteException {
|
||||
|
@ -31,7 +31,7 @@ interface IEmailService {
|
||||
|
||||
// TODO: loadMore appears to be unused; if so, delete it.
|
||||
oneway void loadMore(long messageId);
|
||||
oneway void loadAttachment(long attachmentId, boolean background);
|
||||
oneway void loadAttachment(IEmailServiceCallback cb, long attachmentId, boolean background);
|
||||
|
||||
oneway void updateFolderList(long accountId);
|
||||
|
||||
|
@ -492,7 +492,7 @@ public class AttachmentDownloadService extends Service implements Runnable {
|
||||
* Do the work of starting an attachment download using the EmailService interface, and
|
||||
* set our watchdog alarm
|
||||
*
|
||||
* @param serviceClass the service handling the download
|
||||
* @param service the service handling the download
|
||||
* @param req the DownloadRequest
|
||||
* @throws RemoteException
|
||||
*/
|
||||
@ -501,7 +501,8 @@ public class AttachmentDownloadService extends Service implements Runnable {
|
||||
req.startTime = System.currentTimeMillis();
|
||||
req.inProgress = true;
|
||||
mDownloadsInProgress.put(req.attachmentId, req);
|
||||
service.loadAttachment(req.attachmentId, req.priority != PRIORITY_FOREGROUND);
|
||||
service.loadAttachment(mServiceCallback, req.attachmentId,
|
||||
req.priority != PRIORITY_FOREGROUND);
|
||||
setWatchdogAlarm();
|
||||
}
|
||||
|
||||
|
@ -206,8 +206,10 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Switch from using setCallback to the explicitly passed callback.
|
||||
@Override
|
||||
public void loadAttachment(long attachmentId, boolean background) throws RemoteException {
|
||||
public void loadAttachment(final IEmailServiceCallback cb, final long attachmentId,
|
||||
final boolean background) throws RemoteException {
|
||||
try {
|
||||
//1. Check if the attachment is already here and return early in that case
|
||||
Attachment attachment =
|
||||
|
@ -612,7 +612,8 @@ public class EmailServiceUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAttachment(long attachmentId, boolean background) throws RemoteException {
|
||||
public void loadAttachment(final IEmailServiceCallback cb, final long attachmentId,
|
||||
final boolean background) throws RemoteException {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,8 +95,10 @@ public class Pop3Service extends Service {
|
||||
return AccountCapabilities.UNDO;
|
||||
}
|
||||
|
||||
// TODO: Switch from using the callback from setCallback to using the one passed here.
|
||||
@Override
|
||||
public void loadAttachment(long attachmentId, boolean background) throws RemoteException {
|
||||
public void loadAttachment(final IEmailServiceCallback callback, final long attachmentId,
|
||||
final boolean background) throws RemoteException {
|
||||
Attachment att = Attachment.restoreAttachmentWithId(mContext, attachmentId);
|
||||
if (att == null || att.mUiState != AttachmentState.DOWNLOADING) return;
|
||||
long inboxId = Mailbox.findMailboxOfType(mContext, att.mAccountKey, Mailbox.TYPE_INBOX);
|
||||
|
Loading…
Reference in New Issue
Block a user