首先在MesssageViewFragmentBase.java
下载附件走如下流程:首先在MesssageViewFragmentBase.java的onLoadAttachment方法中调用loadAttachment,会通过附件下载任务EmailAsyncTask,将其添加到下载队列mDownloadSet里
1096899728,com.android.email/.Controller$Controllerservice,,4675]
com.android.email.service.AttachmentDownloadService$DownloadSet.startDownload(AttachmentDownloadService.java:509)
com.android.email.service.AttachmentDownloadService$DownloadSet.tryStartDownload(AttachmentDownloadService.java:465)
com.android.email.service.AttachmentDownloadService$DownloadSet.processQueue(AttachmentDownloadService.java:341)
com.android.email.service.AttachmentDownloadService.run(AttachmentDownloadService.java:929)
启动EmailAsyncTask
添加到mDownloadSet的队列中
然后在AttachmentDownloadService.java中通过
processQueue处理下载队列中的附件,执行:mDownloadSet.tryStartDownload(req);——>j
进一步在tryStartDownload中调用startDownload执行proxy.loadAttachment(req.attachmentId, req.priority != PRIORITY_FOREGROUND);其中proxy为EmailServiceProxy对象,EmailServiceProxy为Email邮件下载同步的执行类——>
而在EmailServiceProxy中,通过IEmailService.aidl去执行loadAttachment进行附件下载。
EmailServiceProxy类中
public void onConnected(IBinder binder) {
mService = IEmailService.Stub.asInterface(binder);
}
loadAttachment
ControllerService类中
private final IEmailService.Stub mBinder = new IEmailService.Stub() 绑定
其中loadAttachment这个方法进行处理
MessagingController legacyController = sInstance.mLegacyController;
LegacyListener legacyListener = sInstance.mLegacyListener;
legacyController.loadAttachment(msg.mAccountKey, msg.mId, msg.mMailboxKey,
attachmentId, legacyListener, background);
之后执行MessagingController中的loadAttachment
com.android.email.MessagingController.run(MessagingController.java:207)
com.android.email.MessagingController$11.run(MessagingController.java:2029)
com.android.email.mail.store.ImapFolder.open(ImapFolder.java:129)
com.android.email.mail.store.ImapFolder.doSelect(ImapFolder.java:1106)
com.android.email.mail.store.ImapConnection.executeSimpleCommand(ImapConnection.java:287)
com.android.email.mail.store.ImapConnection.executeSimpleCommand(ImapConnection.java:325)
com.android.email.mail.store.ImapConnection.sendCommand(ImapConnection.java:243)
com.android.email.mail.store.ImapConnection.open(ImapConnection.java:109)
com.android.email.mail.transport.MailTransport.open(MailTransport.java:182)
com.android.email.MessagingController.run(MessagingController.java:207)
transport.MailTransport.close()