Commit Graph

71 Commits

Author SHA1 Message Date
Tony Mantler 3dd85723a1 Cleanup in EmailContent
Change-Id: Ifa251eb206779f59ea003f99395d454c7e407bc2
2014-04-14 12:54:39 -07:00
Anthony Lee b6125ae385 b/13659368. Ensure properly download status for attachments on failures.
The reason why the UI is wedged is becasue it doesn't
see a state transition in the status. So now we detect the situation
where the user is trying to download an ineligible file and force
the status to indicate that it was a failure to dismiss the UI and
to show the correct error message.

Change-Id: I9264966830a317724bf2fe469ae570860ba7c2a9
2014-03-31 13:21:28 -07:00
Anthony Lee 70cb2878d7 Changed the IEmailService interface to accept and accountId in
the loadAttachment() call. This work was necessary to support
the new EasService & EasOperation infrastructure.

Change-Id: Idd507aec999596ccd4afa5f03ff2b3c2e38a9029
(cherry picked from commit efac8255ed75d22e60036e19e7a95f8407d18ad3)
2014-03-19 23:53:28 +00:00
Tony Mantler 426de73380 Fix unbounded async task creation in ADS
Queue operations through a single ConcurrentLinkedQueue and
service the updates on a single async task to avoid spamming the
async thread task queue.

b/11336926

Change-Id: I8e5c526d61f70fbad0ccef80afd08fc26bb5acf0
2014-02-19 09:48:58 -08:00
Martin Hibdon 272b317f3d Fix an infinitely retrying download problem
b/11436795
If an attachment download fails due to a timeout, or
an exception being thrown from startDownload(), we'd call
cancelDownload() on it. But this didn't actually cancel,
it would remove it from the inProgres list, but leave it
in the list of all downloads, so we'd immediately retry it.
This is bad for two reasons:
1. It can starve out other attachment downloads that could
have been successful.
2. It will keep attempting to do network work, even if it's
hopeless, forever, draining battery.
Now, if an attachment download fails in this way, for the first
few times, we'll move it to the tail end of the list of
downloads we'd like to perform. If it fails more than 10 times,
we'll give up completely. Giving up is not permanent, if we
have a reason to attempt a download again (such as the user
tapping on it), then it will get added back to the download
service and retried.

Change-Id: I5364a7d8b4b25ce299b8dcf061db6e9ce12daf75
2013-11-08 14:05:46 -08:00
Martin Hibdon 1ad443612d Correct some logging in ADS
b/11436795
Some of the logging I enabled here actually causes an
exception to be thrown because the format didn't match
the args in the log command.

Change-Id: If86942e64927c0e8df7573ef099824899e20c289
2013-11-06 15:47:16 -08:00
Martin Hibdon 5ed194434f Add logging to see why attachments fail to load
b/11436795
Now, if we ever insert or update an attachment to have
a blank location, we'll log a warning with stack trace.
Also, logging from ADS now uses the same log tag as everything
else, so we'll be able to see it without needing to turn
on some funny log tag.

Change-Id: Ic566cd87e8893128d074b897d7594a01ae12bc8c
2013-10-31 14:11:41 -07:00
Tony Mantler efd835acea Fix threading issues in EmailDownloadService
b/7257927

Change-Id: I390ced0eee18ff324032481ae55c31f5d4b26ffd
2013-10-14 12:25:04 -07:00
Martin Hibdon 9e608aa5a1 Update logging in AttachmentDownloadService
This is related to b/11081672.
The logging needed to track this down was tied to
MailActivityEmail.DEBUG, which is tied to a setting that
no longer exists.

Change-Id: I0a23508832ead6ab3cc613a82e0831986b0af49b
2013-10-10 12:41:23 -07:00
Martin Hibdon 7c03217316 Add a retry backoff/limit policy to attachment download
b/11081672

Prior to this, any time the AttachmentDownloadService
got a CONNECTION_ERROR, it would just instantly retry,
without any limit on the number of tries. This is bad
if the server is in a funny state, we'll just keep spamming
it with multiple connection attempts per second. Also,
this kills the client device's battery and responsiveness.

Now, it will retry instantly five times, and then retry on a
10 second delay 5 more times. After that it will give up.

Even if it gives up, if the user visits an email with an
attachment, or taps on an attachment to expand it, we'll
start the process over. So we shouldn't have permanent
apparently data loss, even if we fail on the first 10 tries.

I'm not certain that this is the best backoff/limit policy,
maybe we should add a delay after even the first connection
error. But I'm hesitant to change this at this point, it's
possible that something is relying on this behavior and
we don't have a lot of soak time left.

Change-Id: I53d75d5d214ccca887a89cf65b799fe640cc9bc5
2013-10-09 16:32:08 -07:00
Yu Ping Hu 2075c97f60 Delete most of IEmailServiceCallback.
The old callback mechanism is deprecated, in favor of making
calls on the ContentProvider.

Bug: 9842867

Change-Id: I65f559e593cda24456c4ffb96f785e054626dd0b
2013-07-29 20:04:42 -07:00
Yu Ping Hu d5acf0bbc0 Explicitly pass a callback when loading attachments.
This is part of moving away from the explicit setCallback,
which either has race conditions or is very noisy, or both.
(Each IEmailService call that wants callbacks should just
pass the callback explicitly.)

I'm not yet changing how the services actually handle the
call. Each protocol will need to fix this on their own.

Bug: 9735207
Bug: 9842867
Change-Id: If8cf69ffe82f3544ace9e58b1db5a183f38d038a
2013-07-15 21:54:02 +00:00
Mark Wei 8f474dc02f Fix IMAP attachments REDOWNLOADING.
Previously, if you clicked Download again, you will never be able to view that
attachment again.

Change-Id: Ie944becaf8c89a1a27b8625af4795550e9213f5e
2013-06-19 17:35:37 -07:00
Scott Kennedy 560bfadc31 Unify LogTag
There is now only one LogTag class. The static initializer of
GmailApplication (existing) and EmailApplication (new) will now set
the log tag to "Gmail" and "Email", respectively. Up until that code
is run, it will be "UnifiedEmail".

"setprop log.tag.Gmail VERBOSE" (or .Email) will trigger all logs to
be printed as long as they go through LogUtils, regardless of what tag
is used by that individual log. This lets us still turn on logging
everywhere in one command, but also lets us use more descriptive tags
(like the class name).

And since we no longer have three com.android.mail.utils.LogTag
classes, builds will be much easier.

Also, we now use LogUtils everywhere.

Change-Id: I55f1c7a66ce50ead54877a13e40256422a56dc39
2013-06-05 20:06:15 -07:00
Marc Blank 6e5bccf2c9 Use correct attachment provider authority
* Make sure new code works with old Attachment rows

Bug: 7130972
Change-Id: Ia5d258930f39266517eead535a92bb4380fdb594
2012-09-09 09:32:14 -07:00
Marc Blank f419287f22 DO NOT MERGE: Move emailcommon2 sources to emailcommon
Change-Id: I06df7e467cd2e0117df8b8db3ddc6ff9da13f1c7
2012-06-28 11:15:06 -07:00
Marc Blank 03cd72805d Revert to old Email app
* These are the last sources in the ICS-MR1 tree

Change-Id: Ida4651bddd92a06a518d00f3e1f275ab3a80c8ae
2012-04-25 13:58:23 -07:00
Marc Blank 3408ad1113 Use proper column in loadAttachmentCallback
Bug: 6138389

Change-Id: Icd9b3454670d29e1fbd1dfc309700eb1643cc9ee
2012-03-08 21:18:04 -08:00
Marc Blank 97e4651c45 Repair brain damage
Change-Id: I1f2367476f78c5cd78d8a59e099debabceb95e3a
2012-03-08 19:48:11 -08:00
Marc Blank 420e97f0f8 Support attachment commands from UIProvider
Change-Id: Ib457808bdb424275c0abe6e1d86e3b9d33406780
2012-03-07 14:57:19 -08:00
Marc Blank 4f813fb129 Convert POP3 to service
* Remove MessagingController and (almost all of) MailService

Change-Id: I8953b58b237de6a71fda770f1727bd94081fec55
2012-02-16 10:27:00 -08:00
Marc Blank c84467afe1 Start of IMAP conversion to Service architecture
* Handle startSync and loadMore
* Use SyncManager rather than MailService for periodic sync
  and upload sync
* First of many CL's to disentangle sync from UI
* Note that the large majority of this CL is a refactoring
  of IMAP specific code out of MessagingController and into
  ImapService; MessagingController will eventually be
  removed entirely from the app, as will much of Controller

Change-Id: I13546d0694479b33cf93c25920dedc1d38227f6c
2012-02-13 11:04:56 -08:00
Marc Blank ecaa977413 If we're stopped, make sure watchdog alarm is also stopped
Bug: 5647625
Change-Id: I33e94107f2d6e4a38a5a221df72ed83596ca7c54
2012-01-25 14:59:54 -08:00
Marc Blank faf9ecc992 Enforce "auto-sync app data" setting for POP3/IMAP
* We were using the deprecated ConnectivityManager for this; we should now be
  using the setting in ContentResolver
* Also, remove broadcast receiver code that is no longer relevant

Bug: 5405352
Change-Id: I985a95071aea92d235a2708925f775b817ba2328
2011-10-03 13:05:24 -07:00
Ben Komalo 32bed4bb8e Fix unit tests.
- make attachment download service injectable
- fix assertions for account manager account checks
- update message compose ID's so they're consistent on tablet/phone

Bug: 5198343
Change-Id: I9976f5b9e5590dd61fb0a62937d3f9203fefe236
2011-08-24 10:24:42 -07:00
Marc Blank a9f1631fb8 Remove STOPSHIPs in Email/Emailcommon
Bug: 5142183
Change-Id: I1f6e31bfd2e7c32bdd7886e54b02fd4640a96e6f
2011-08-10 16:43:20 -07:00
Marc Blank 433b0ed9fe More whack-a-mole in AttachmentDownloadService
Bug: 5115008
Change-Id: I6e5236e08331cfd6a9a11868d97bf5caaf68f6fe
2011-08-03 13:28:01 -07:00
Marc Blank 41c63a05eb Catch NPE in AttachmentDownloadService
%$!@#*&%

Bug: 5055519
Change-Id: Ie155c8d0f9931b51613f7d77e4545531bc148964
2011-07-27 15:53:51 -07:00
Marc Blank cb2f0a8bb9 Ignore watchdog alarms for stopped service
Bug: 5055519
Change-Id: I35352364f3f2842932ad40e47d70646bb6d42349
2011-07-26 09:59:10 -07:00
Marc Blank 90a4811551 Fix NPE in onStartCommand
Bug: 5041436
Change-Id: Ib7462e5c8cb040b7526d9a655c5ab3f41cd159b8
2011-07-18 09:49:52 -07:00
Marc Blank b2a8c2ce4c Start/stop AttachmentDownloadService as needed
Bug: 5033646
Change-Id: Ic0e75b28d0d8d5665c3f3ca864a9532fee05df8c
2011-07-17 18:06:20 -07:00
Marc Blank f5418f1f93 Move Account into its own top-level class
Change-Id: Ide7c991b7d4d418dbe17164421425bf898ba64ee
2011-06-13 15:37:22 -07:00
Marc Blank 2f6cbb021c Fix a race condition in which an Attachment might be wrongly deleted
* This is a serious bug dating back to the first Honeycomb release
* It was possible that a newly created Message could not yet be
  committed to the database when the AttachmentDownloadService
  tries to download one of that message's attachments.
* ADS, when it sees that the message (apparently) doesn't
  exist, deletes the Attachment (it appears to be orphaned)
* The effect is that the user never sees one of the attachments
  in a message.
* This bug has been reported externally
* The fix is simply to check for the message's existence before
  deciding to delete it (this check will always work properly)

Bug: 4409692

Change-Id: I106ed2fe88d2435ad7a462fced5cb307c2559fd6
2011-05-11 17:27:37 -07:00
Marc Blank 973702b30e Only allow prefetch when on a WiFi network
Bug: 3515125

Change-Id: I0814ea20b1fc73807667e7f9531c1ea065bfa803
2011-03-07 22:01:34 -08:00
Marc Blank 81273dfcee Fix deadlock issue in AttachmentDownloadService
* When a connectivity wait was added to processQueue, I neglected
  to consider that a lock was held during this time
* The fix is to move the check for connectivity out of processQueue

Bug: 3500702

Change-Id: I646cf899ff895d9838612e89b15b66f1084840b1
2011-03-01 13:43:44 -08:00
Marc Blank dc78a769fc Email split, part dix
* The coup de grĂ¢ce for Exchange in Email
* Remove Exchange bits from AndroidManifest
* Update Android.mk to create static jar for emailcommon
* Delete all com.android.exchange files
* Delete all exchange-only strings
* Change loadAttachment service method to take only attachment id and
  background flag
* Add code to AttachmentProvider.openFile() that opens an output file
  for attachment writes
* Make sure deviceId is determined in Email app (not Exchange)

Bug: 3442973
Change-Id: I775600252fd121f474d51cb26fefbfcc50e387af
2011-02-25 10:46:16 -08:00
Todd Kennedy ffe6ef342a fix UnsupportedOperationException in tests
We're using the mock context to prevent modifying the real databases. However,
we need the real context to create intents. Use the real context in the few
places we must use it.

Change-Id: Icb8d289239218921c0b4b5c93ac7983830d90394
2011-02-23 14:51:45 -08:00
Marc Blank 3a5c1fb274 Email split, part neuf: Setup, logging, attachment glue
* Make "Exchange" option in account setup depend upon availability of the
  Exchange EmailService
* Make presence of Exchange logging depend upon availability of the
  Exchange EmailService
* Make AttachmentDownloadService use service rather than ExchangeService
  class
* Move SSLUtils to emailcommon/utility
* Move account manager type defs to emailcommon/AccountManagerTypes
* Update proguard.flags
* This is the penultimate CL for the Email package itself; the next CL
  creates a clean, SDK-compatible Email application

Bug: 3442973
Change-Id: I9162cf5fa6b5a043ded0fdd1e25fd3ce5948ad8f
2011-02-14 16:08:55 -08:00
Marc Blank 31d9acbf06 Email split, part huit: Refactor constants, clean emailcommon
* There are three pieces to this CL (sorry):
  1) Move and/or rename some constants into emailcommon
  2) Move Utility to emailcommon, moving the few UI
     related utilities back into Email (FolderProperties
     and UiUtilities)
  3) Remove all references to resources from emailcommon
* The three pieces relate in that, between them, they allow
  the emailcommon static library to compile cleanly

Bug: 3442973

Change-Id: Ic5e3abaa2a1b36999e0b6653c6c2134ea1bd544f
2011-02-14 12:18:10 -08:00
Marc Blank a7bc0319a7 Email split, part six: EmailContent
* Moved EmailContent to emailcommon

Change-Id: Ib3db1bfcfe74554c0e5afd3cfce6d72f26e9aeb9
2011-02-10 19:44:29 -08:00
Marc Blank 8a57469460 Email split, part trois: AccountService
* Create AccountService.aidl and AccountServiceProxy in emailcommon
* Implement AccountService in email
* Use AccountServiceProxy in Exchange for account reconciliation,
  notifications, etc.
* Move sync window constants into emailcommon
* Split attachment provider utilities and constants into emailcommon

Bug: 3442973
Change-Id: I89dce28b799b193243c07774dab65d830ae62775
2011-02-10 14:32:01 -08:00
Marc Blank 0d4fc55861 Email split, part one: EmailService
* Create emailcommon package
* Move EmailService classes to emailcommon package
* Change references to aidl's to emailcommon package
* Add getApiLevel() command to EmailService

Bug: 3442973

Change-Id: Ic7d2115363cdff6ebb86c46650b0a5b2109b1c72
2011-02-10 13:10:38 -08:00
Makoto Onuki 9c44430690 Fix AttachmentDownloadService for remove-exchange script
Now the source at least compiles fine.

Change-Id: I329ad08f81fd6ab23f28dd30023fe3e781ccc4fc
2011-01-28 11:22:51 -08:00
Marc Blank ed9938cd9c Protect against threading issues in AttachmentDownloadService
Bug: 3391148
Change-Id: I513b5678815db262ea5660661336432f1e203c9e
2011-01-26 16:04:28 -08:00
Makoto Onuki 2d0e44f201 Fix NPE in AttachmentDownloadService
Initialize mConnectivityManager before starting the thread.

Bug 3389701

Change-Id: If616721ad3b3bec81c5d6920f4a5d91b06f937fb
2011-01-25 15:30:15 -08:00
Marc Blank 3ef8f54bae Prefetch respects "background data" setting and waits for connectivity
Bug: 3384997
Bug: 3384994
Change-Id: Id8338650b69666f2996837324e27c2e98c9261fe
2011-01-24 18:39:50 -08:00
Todd Kennedy 751e4b2d95 Prevent auto-download of attachments not in an inbox
When creating the list of attachments to be automatically downloaded in the
background, exclude any attachments that are not in an inbox. Also added unit
tests to ensure the query URIs behave as expected.

NOTE: This is a partial fix for general background attachment downloading issues

bug 3373982

Change-Id: I13ef56cd280c028fa966ab9e655acce28b0b9b91
2011-01-24 13:43:14 -08:00
Todd Kennedy 819db01ead Limit attachment background download attempts
Do not retry downloading attachments infinitely. After some number of failures,
black list the attachment and move on. The black list is not persisted, so,
restarting the app will again try to fetch the attachments. In this way, any
transient network failures will not permanently affect the ability to download
attachments in the background

NOTE: This is a partial fix for general background attachment downloading issues

bug 3373982

Change-Id: I7f3ad9667ebebb95fbba95278b62bf40c5fce67c
2011-01-24 10:19:46 -08:00
Todd Kennedy f92dd2bf3e Don't display toast for background download failures
When downloading attachments in the background, do not display any errors
on the display.

NOTE: This is a partial fix for general background attachment downloading issues

bug 3373982

Change-Id: I874ed902bde293303e10308f38b992b2bb15b6aa
2011-01-21 15:17:29 -08:00
Marc Blank 2ac1833943 Delete attachment if there's no corresponding message
Bug: 3372440
Change-Id: I5c3653c5f27e0aa7bab52ca0d979e14bb6bafc34
2011-01-20 20:32:56 -08:00