Commit Graph

72 Commits

Author SHA1 Message Date
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 2193962ca2 Email split, part quatre: Move along, nothing to see here
* No code was harmed, er, changed in the making of this CL
* All that's happened is that code that is needed by both Email and
  Exchange have been moved into emailcommon
* This required import changes to many files, which explains the
  length of the CL

Change-Id: I4e12455ba057a4a8054fdbd0b578c73afa411c8a
2011-02-10 16:28:37 -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
Makoto Onuki 5907d39d2b Add debug setting for one-minute refresh
Bug 3377054

Change-Id: I7843fe82d66ab7896b8293b2fa16ca73f6711595
2011-01-28 14:16:56 -08:00
Makoto Onuki c50b6f685b Use broadcast to detect system account update.
Instead of AccountsUpdatedListener.

Bug 3211657

Change-Id: I1e60092fc06fe80b9914ff7264c24fcbfa950745
2011-01-17 11:03:57 -08:00
Andy Stadler 201a24f51e Harden MailService against half-created accounts
* Add simple sanity checks to scanned accounts, skip over if bad
* Fix existing unit tests and add new unit test for this change
* Also fixed minor bug in EmailContent that was never triggered in
  production code (only discovered it via a unit test).
* Also fixed minor bug in an existing unit test

Bug: 2937595
Change-Id: Id60bbb5d8bd923db043d46891c7f89d7debb0a11
2011-01-06 12:53:40 -08:00
Andy Stadler 6ebaa90847 Reduce/eliminate UI thread access in MailService
* Make most calls to AccountBackupRestore return immediately w/o DB access
* Move most workers in MailService into async runnables
* Remove account restore / null check from ACTION_SEND_PENDING_EMAIL
* Strengthened unit test on Mailbox.findMailboxOfType() because after
  removing the account check (above), sendPendingMessages depends on
  findMailboxOfType() returning -1 on a missing account.
* Clean up a bunch of warnings (no longer use deprecated Config.LOGD)

Bug: 3133763  (and probably others)
Change-Id: Id39707bca7a8ebf5000f84d542013411ff0f422e
2010-12-22 16:34:48 -08:00
Andrew Stadler 34e6205d44 Simplify setupSyncReportsLocked
* Remove three unneeded DB lookups
* Eliminate race condition that could cause NPE
* Remove protocol field from report, it wasn't needed (we already
  set the sync interval to -1 which has the same effect.)

Note, the problems were introduced unintentionally, due to the merged
result of three different CL's:
 I168b3db49bf422b33d05f25cfff1c7be15150c2b
 I74a3dae21d9ec16f9903bdf2a1c28092ae89cc50
 I53e935f8bf08e0bda6e2cd483229a6377ed39d74

Bug: 3139451
Change-Id: Iadbed267f88808aeace0a2f011e4acf79074af70
2010-10-29 11:38:28 -07:00
Marc Blank d3e4f3ca7e Use notifications for login failures
* For now, clicking on the notification takes the user to the
  Welcome activity, as we don't have final flows for the new
  account setup UI
* Need comment on strings; the problem is that notification
  text must be rather short if we're to use the standard
  notification display.  It looks like newer UI will allow
  3 lines instead of 2, however.
* Tested w/ IMAP, POP3, EAS, and SMTP

Bug: 2322253
Change-Id: I7ed6fa5599179870cbcdb14af062e956eff37ec5
2010-10-27 08:56:37 -07:00
Jean-Baptiste Queru 9a9c725174 Merge a059c4a1 from gingerbread-plus-aosp
Change-Id: I955120aff44d69bcd6fde165ac7ac974acbd3c78
2010-10-22 05:55:38 -07:00
Marc Blank 2a08ef0d28 Don't allow MailService to schedule EAS accounts
Bug: 3120208
Change-Id: I53e935f8bf08e0bda6e2cd483229a6377ed39d74
2010-10-21 16:49:41 -07:00
Marc Blank eb49659423 Prevent MailService from spamming AccountManager during reconcile
* When any Account is modified, MailService gets a content notification and
  runs reconciliation in an AsyncTask.  Reconciliation ends up calling the
  AccountManager, which also runs asynchronously.  The net effect is that,
  especially during unit tests, where we create/destroy accounts rapidly,
  these calls can "back up", ending in a situation in which the worker pool
  for AsyncTask is filled, with a resulting RejectedExecutionException
* We fix this by preventing more than one request for reconciliation to
  be queued at a time
* Added a unit test that thrashes the notification handler

Bug: 2937628
Change-Id: Iaf25806efb46831f31704604360df091752d9525
2010-10-18 14:07:47 -07:00
Makoto Onuki 241f18f237 Fix when to clear notification
I was assuming MailService.resetNewMessageCount cleared notification,
but it didn't.

Doing it in Activity.onResume is clearly wrong because we don't always
have an account ID there.  If we don't, we're passing -1, which clears
all notifications for all accounts.

We're now calling resetNewMessageCount() in MessageListFragment,
when we refresh the list, so we can remove it from onResume() for the Phone
UI as well.

Bug 3074056

Change-Id: Ib0bb2fbb0309a0784fb3a525927102f423e930df
2010-10-08 13:51:23 -07:00
Makoto Onuki 4b0d4f9f4d Fix "+ -1 more" in notification.
Need to reset lastUnseenMessageCount with unseenMessageCount.

Bug 3069406

Change-Id: I867dfaeb2d39cfd3511f956d60d2187031291780
2010-10-07 15:14:40 -07:00
Marc Blank fe6e3eae2a Fix MailService unit test
Bug: 2844726
Change-Id: I168b3db49bf422b33d05f25cfff1c7be15150c2b
2010-10-07 14:34:50 -07:00
Makoto Onuki 899c5b8661 Switch to tablet style notification
- Now we show separate notification for each account
- New notification has sender photo, sender name, and subject
  of the latest email
- Added the NotificationController class, which is intended to manage
  all notifications besides "new message" eventually.

The framework doesn't seem to be 100% ready, and it's not clear how to
add the 3rd line in the expanded notification at this point.  Need to
revisit it later to verify UI details.

Change-Id: I40193ee372cb6b2b7245c1588890f238b2469699
2010-09-29 18:35:17 -07:00
Makoto Onuki 08346b67b8 Refactor for new notification UI
- Move the notifiaction code into a bg thread.
  We need to access db to fetch the latest message
- Extracted ContactStatusLoader.load to synchronously load contact
  pictures.

Change-Id: I282ffb706ea8e14558bf29880a0fb952868b27e5
2010-09-24 16:22:47 -07:00
Makoto Onuki 550aa6163f DO NOT MERGE: Clean up member variables.
- Fix misnomered fields.  (e.g. static mMember -> static sMember)
- Reduce visibility.  (e.g. mark as private)
- Mark final / static if possible.

Note it's on master.

There's a lot more cleanup oppotunities in the activities, but they're going
to go through a major overhaul, so I didn't bother.

Backport of b3f7dd0169

Change-Id: Ic33f9518f23805716e2aec0ab42edb92107e066c
2010-09-20 14:03:29 -07:00
Makoto Onuki 261d6c3f0c Notify only account cursors when resetting new msg count
- Resetting the new message count is now correctly done on a BG thread.
- Added special content provider URI to reset the count.
  (/resetNewMessageCount)
- This URI only supports update, which will notify only account
  cursors.
- Fixed a problem that an insert with MAILBOX_ID/MESSAGE_ID/ACCOUNT_ID
  triggers two notifications.

- This CL changes how we use notification URIs, but unfortunately
  no tests for this part.  It turned out MockContentResolver doesn't
  support the notification mechanism, which made it very hard
  to write tests.

Bug 2911646

Change-Id: I35b30a7e6bf2d57510486c7ed19b9f263d8c9b58
2010-09-15 10:53:17 -07:00
Makoto Onuki 0be2d85bb8 Make notification open XL activity on tablet
* Now notification kicks Welcome, which knows which
  activity to use.
* Extracted cancelNewMessageNotification
* Also fixed 2909215.  There'll be only one XL activity on the app stack.

Bug 2945369
Bug 2909215

Change-Id: I2a7fec0d48a7618375cae55138ca51fefc70ff6e
2010-08-26 13:17:41 -07:00
Marc Blank c184f36c2d Revert "Convert Controller to a full service"
This reverts commit 0e6d972641.

Change-Id: I005fc34152396806468edef919a3620961ddb4fe
2010-08-24 10:27:58 -07:00
Marc Blank 0e6d972641 Convert Controller to a full service
Change-Id: I2078fd047ff46f85936c8bf798a5edd3678bb5b4
2010-08-20 13:34:09 -07:00
Marc Blank 09fd4d0a18 New asynchronous attachment loading code
* Create AttachmentDownloadService to manage all attachment downloads
  1) User requested
  2) Required for email forwarding
  3) Opportunistic downloads to enhance offline use
* New attachment related UI (pending UX approval, of course)
  1) MessageView (attachment actions, progress bar, etc.)
  2) MessageCompose (attachments for forwarded messages)
  3) Associated toasts, notifications, etc.

TODO:
* Unit tests
* Cache Management (separate CL)

Change-Id: I7864a5fb1c3f4f2be68d98341a971edc6cbacfe1
2010-08-19 14:01:08 -07:00
Marc Blank d14229872a Fix NPE in MailService
Bug: 2873538
Change-Id: Ida9135d3c8090abb63424cc2b2cb1b848785d571
2010-08-18 13:17:21 -07:00
Makoto Onuki 21efedb67f Rework/cleanup of "refresh".
Added RefreshManager, which is responsible for getting refresh requests
from UI and keeping track of what is being refreshed.

Conceptually it's a part of Controller, but extracted for easier testing.

- Now sendPendingMessagesForAllAccounts() is owned by RefreshManager
  rather than Controller.
- Also updateMailboxRefreshTime/mailboxRequiresRefresh have been moved
  in from the Email class.
- Now MessagingException implements a method to return an error message
  for the UI.

The refresh button on 2-pane doesn't work as intended yet, because the
spec is a bit too complicated (as described in the TODO in
MessageListXLFragmentManager.onRefhres()).

This change touches many file mostly because it cleans up a lot
of code duplication.

Change-Id: I058ab745ccff10f6e574f6ec4569c84ac4a3e10e
2010-08-18 11:06:45 -07:00
Marc Blank a09459f6f4 Run AccountsUpdatedListener work in worker thread
Bug: 2922224
Change-Id: If7b61c4f41d901fd71d571450fa5fa7f3ff11535
2010-08-16 09:44:54 -07:00
Makoto Onuki c435d7ad24 Workaround for bug 2873538
Prevent NPE.

Change-Id: I6d80e6f574d6c37adb9d7a402850c39e2a79f04a
2010-07-27 12:54:28 -07:00
Marc Blank e6cc662abc Use AccountManager for POP/IMAP; refactor setup classes
There are two major, interrelated parts to this CL:

1) Clean up the activities to reduce the use of Intents to pass
   information between activities; instead, we use a common
   SetupData structure that automatically saved/restored as necessary
   during the setup flow.  A fair amount of code and inconsistent
   use of Bundle extras has been eliminated in the process.

   * Create SetupData structure, setters/getters, and initialization
     methods to simplify the preservation of state during setup flow
   * Remove all state/flow extras from Intents; Intents now only
     specify the Activity to be started, which should greatly simplify
     the transition to Fragments.
   * Remove all state/flow fields from Activities
   * Modify existing setup activity unit tests and confirm tests pass

2) Create AccountManager accounts for POP/IMAP email accounts to
   provide consistency in user experience.  Also, internal flows are
   now identical as between account types.

   * Move account reconciliation from SyncManager to MailService, so
     that reconciliation is consistent between email and exchange
     accounts; move unit tests as appropriate
   * Add a "Sync Email" setting for POP/IMAP/EAS
   * Change MailService to respect the "Sync Email" setting in
     Settings -> Accounts & sync
   * Create PopImapSyncAdapterService to handle manual POP/IMAP sync as
     requested by SyncManager; add EmailSyncAdapterService to perform
     the same function for EAS
   * Use new PopImapAuthenticatorService to add AccountManager accounts
     for POP/IMAP accounts; setup appropriate stanzas in AndroidManifest
     and add related xml files
   * Update AccountSettings to use SetupData

Miscellaneous other changes:

   * Only allow valid port numbers in incoming/outgoing setup

Bug: 1712475

Change-Id: Ibdac52fb2c5578b86bf3992ddb1acd10f162391a
2010-07-21 19:01:41 -07:00
Marc Blank 42ff939e3a Prevent MailService from potential looping due to EAS accounts
* The code assumed that all accounts used the scheduler in MailService
  whereas only those using MessagingController do so (i.e. EAS does
  not)
* Change setupSyncReportsLocked to set the syncInterval for accounts
  that don't use MessagingController to Account.CHECK_INTERVAL_NEVER
* Add unit test for the changed code

Change-Id: I74a3dae21d9ec16f9903bdf2a1c28092ae89cc50
2010-07-02 11:47:03 -07:00
Makoto Onuki 3f545a4060 Controller rework.
- Controller.Result is now a class rather than an interface,
  so subclasses don't have to implement empty methods.

- Replaced Threads with AsyncTasks, which is more light weighted
  because it uses pooled threads.

- Removed the Result argument from Controller's methods.
  These argumetns weren't used, except in serviceCheckMail.

  Regarding serviceCheckMail, the new code behave differenly from the old code.
  If there's already listeners registered when it's colled, they wouldn't get
  called in the old code, but they will in the new code.
  But I think this difference is okay because that's how it works for
  POP/IMAP accounts.

Change-Id: I37a857ce7c089c1a411cb7f1fcfcb72c9f5fd2a6
2010-06-07 16:33:44 -07:00
Makoto Onuki 9580f6175d Don't sync when the background data system setting is off.
Bug 2494703

Change-Id: Ia6f4c9fc86cdcb5ca3276141cb84b4effb6ee87c
2010-05-14 13:59:11 -07:00
Makoto Onuki b3f7dd0169 Clean up member variables.
- Fix misnomered fields.  (e.g. static mMember -> static sMember)
- Reduce visibility.  (e.g. mark as private)
- Mark final / static if possible.

Note it's on master.

There's a lot more cleanup oppotunities in the activities, but they're going
to go through a major overhaul, so I didn't bother.

Change-Id: I3fde73ba5f1f9ff675fff07c510e1e49521dde42
2010-05-11 17:06:37 -07:00
Jim Shuma 9e2ddca59d Add "vibrate when silent" mode to notifications
* Add "vibrate when silent" choice in UI
* Add storage for it in Email's provider.  Existing accounts default to
  their current settings (always vibrate / never vibrate).
* Respect new mode when notifications are posted
* Updated existing unit tests

Bug: 2457183
Change-Id: I5c933ac39dbef8b2028255f330e0b084a445421a
2010-03-18 13:57:25 -07:00
Makoto Onuki e37881aac5 Store UUID instead of _id in desktop shortcuts.
- Because AccountBackupRestore won't preserve _id.
- Now MessageList accepts both Donut(1.6)-style URIs and Eclair(2.0-2.1)-style
  URIs.

Bug 2479609
2010-03-03 15:41:10 -08:00
Makoto Onuki c18f8f615f Enable calendar sync for Exchange accounts when upgrading.
On the first boot after upgrade from Eclair, enable calendar sync for all the
existing Exchange accounts, if any, and show notification.

Note on this version, nothing happens when you click on the "Calendar added"
notification.  We're waiting for an API (action or something) to launch
calendar.

Bug 2428718
2010-02-26 13:28:59 -08:00
Jeff Hamilton 5f32e2d31f Don't use hard coded package names.
Change-Id: Id65967a87afa969f5410f4fdee058d450776a32e
2010-02-13 00:21:46 -06:00
Andrew Stadler 3d2b3b3b35 Logic to move phone into security-admin mode
* Create notification to display when syncs fail due to security
* Create psuedo-activity (no UI) to manage device admin state transitions
* Clean up and flesh out SecurityPolicy APIs'
* Add placeholders in EasSyncService showing how to react when policies
    are not met and sync cannot continue.

Note:  There are some STOPSHIP todo's at the top of SecurityPolicy.java.
These should explain any code that you might think is "missing".
2010-02-05 11:10:39 -08:00
Mike Lockwood 87a520d7b9 Use default values rather than hard coding green for LED notification color.
Change-Id: Id192ea4d34725abf9ce892bc24e5c8562215f3e3
BUG: 2329568

Signed-off-by: Mike Lockwood <lockwood@android.com>
2010-01-21 11:20:23 -05:00
Andrew Stadler 5e91cccd4b Quick backup/restore of accounts
* Workaround for (HTC bug 2275383) & (Moto bug 2226582)
* Adds checkpoints for backing up and restoring accounts
* Uses legacy Account / prefs to back up accounts - this is because
  some of this code will be reused for legacy account migration
* Unit tests of Account & LegacyConversions
* Unit tests of backup & restore
* Not done:  testing of EAS/Account Manager interface (this will require
  deeper dependency injection, to avoid the embedded calls to the Account
  Manager and other system services.)
2010-01-20 01:36:01 -08:00
Marc Blank d16b4b921f Go to combined inbox from notification for 2+ accounts (#2147265)
* The problem is that PendingIntents aren't updated when a notification
  is updated, so the changed extras when a 2nd account gets a new message
  aren't seen by MessageList when it's started up upon tapping the
  notification (it uses the extras from the 1st account to get a new
  message)
* The fix is to use the newish (cupcake) flag in the PendingIntent that
  causes the extras in the PendingIntent to be updated

Change-Id: Ia4ab14954b2c1413526016975216b2516372f2aa
2009-10-21 13:51:16 -07:00
Andrew Stadler deffba584e Stop forcing email logging for all users
* Don't force Email.Debug == true
* Also, remove some unneeded development logging from MailService
2009-09-28 14:31:56 -07:00
Andrew Stadler 27bc39399e Turn off debugging code that was accidentally left on.
This goes with Change I52e53c4b.

Change-Id: Ife5672af1c0c5cf2b2c279a9a912beb26c64390d
2009-09-17 21:15:17 -07:00
Andrew Stadler 01f61ef912 Fix acct settings -> inbox checks -> notifications
This cleans up a number of bugs that could be generically described as
"MailService and Notifications not being updated when accounts or account
settings are changed."

This also fixes a number of race conditions, one of which was causing
accounts to be refreshed in a nearly-endless loop, and another which
could cause an endless loop of alarms to be posted & fired..

Specific changes:
* Update/reschedule any time an account is edited (this was accidentally
    broken and being handled on EAS only.)
* Make sure we reschedule if an account becomes unavailable
* Clear notifications whenever refreshing accounts
* Reload local copy of account settings whenever refreshing accounts
* When restoring prev sync times (this happens when process is killed),
    be sure to also recalculate next sync times.
* Set flags on the pending intents to make sure old pending intents are
    not being reused.
* Set a watchdog each time we check the mail, so if we are killed during
    the mail check, we will be woken up again to retry.
* Fix a 2nd race condition in which a just-created account fails to sync,
    due to not (yet) having an inbox.
* Clean up handling of Controller callback:
  * Fix a minor bug in which refresh of non-inbox mailboxes would delay
      the next timed sync of the inbox for that account.
  * If the checkmail ended in an error (result != null) the service was
      never rescheduled.

Bugs Fixed:
bug 2078149 - Update service and notifications when account settings
   change or accounts are added/deleted.
bug 2084412 - Fix race condition caused by first intent being refired
bug 2071484 - Make sure we wake up later if killed during mail check

Change-Id: I3ee0d1b389c652351de5eb798c32a2daea244067
2009-09-17 18:35:43 -07:00
satok d2174733b1 Auto-sync of stale mailboxes
BUG: 2050116
- auto sync onResume
- add mNonPushMode
-- mNonPushMode is updated in SetFooterTask
2009-09-15 14:38:13 +09:00
Andrew Stadler 7b03c7936a A bit more debugging to catch the service race condition.
NOTE: This switches on Email.DEBUG for everyone, and should be
removed.


Change-Id: I700099a9aa5e5c64d8c282cb8d07a47c7c408862
2009-09-04 23:13:32 -07:00
Andrew Stadler 9b9a2e69b9 Improve logging in MailService
The goal is to generate better reports to help find the race condition
described in bug 2084412

Change-Id: Idfc453af17edf08e89d2aa656585b83ed48691c8
2009-09-03 15:02:03 -07:00
Marc Blank 68c3c7518e Use LED for notification (same parameters as Gmail and GTalk services)
* Agreed to by Erick and Prasenjit

Change-Id: I1a0f3642c9b10f981b2feed55762407ed853763d
2009-08-25 11:06:17 -07:00
Andrew Stadler df86adf873 Finish the code to demand-load partially loaded messages.
This happens in two primary cases:
1.  When a very large POP message was skipped during initial sync
2.  When any message was interrupted during initial sync, e.g. by
    a dropped connection.

Changes:
* Added loadMessageForView and callbacks to Controller (and touched all
    files with Controller listeners)
* Rewrote loadMessageForView in legacy MessagingController to work with
    provider.
* Update flow in MessageView to use loadMessageForView when needed.
* Restored the use of "loading.html" and "empty.html" assets (although
    I think we should replace them with simple layouts & views.)
* Some random cleanup in MessageView

Satisfies bug # 2065563
2009-08-25 10:13:35 -07:00