Commit Graph

76 Commits

Author SHA1 Message Date
Makoto Onuki 91237e9dcb Adding script for building Email app without exchange.
remove-exchange-support.sh makes it possible to build the email app without
exchange support.

This script:
- removes all packages under com.android.exchange.
- removes all lines surrounded by EXCHANGE-REMOVE-SECTION-START and
  EXCHANGE-REMOVE-SECTION-END

And the resulting source should still build and run fine.

Bug: 2369784
2010-02-03 11:39:46 -08:00
Andrew Stadler 8bb0ee3b92 Fix auto-discover / account verification logic
New behavior:
 * There are two primary paths through this activity:
 *   Edit existing:
 *     Load existing values from account into fields
 *     When user clicks 'next':
 *       Confirm not a duplicate account
 *       Try new values (check settings)
 *       If new values are OK:
 *         Write new values (save to provider)
 *         finish() (pop to previous)
 *
 *   Creating New:
 *     Try Auto-discover to get details from server
 *     If Auto-discover reports an authentication failure:
 *       finish() (pop to previous, to re-enter username & password)
 *     If Auto-discover succeeds:
 *       write server's account details into account
 *     Load values from account into fields
 *     Confirm not a duplicate account
 *     Try new values (check settings)
 *     If new values are OK:
 *       Write new values (save to provider)
 *       Proceed to options screen
 *       finish() (removes self from back stack)
* Added unit test for new loadFields method

Bug: 2412300
2010-02-03 10:38:27 -08:00
Makoto Onuki 9fe51f6329 Gather common exchange related methods into one place
So that it'll be easier to remove exchange dependency.
2010-02-02 13:36:45 -08:00
Makoto Onuki 049509d10e Merge "Move Eas.ACCOUNT_MANAGER_TYPE out of the package." 2010-02-02 13:34:04 -08:00
Andrew Stadler ecb1af8041 Finish up IMAP ID implementation
* scrub all external strings to keep them compliant for IMAP protocol
* move Build.MODEL to x-android-device-model
* send x-android-mobile-net-operator
* send AGUID
* unit tests for above
* retrieve providers from VendorPolicyLoader

Bug: 2332183
2010-02-01 15:53:46 -08:00
Makoto Onuki faed6178b1 Move Eas.ACCOUNT_MANAGER_TYPE out of the package.
Moved Eas.ACCOUNT_MANAGER_TYPE to Email.EXCHANGE_ACCOUNT_MANAGER_TYPE.

This constant is not related to the exchange protocol, and referred in
a lot of different places.  Moving it out of the package will make it a lot
simpler when removing exchange dependency.
2010-02-01 15:38:15 -08:00
Makoto Onuki e5c3c98e9a Fix confusing setup screen title.
Change the title of the screen for adding an exchange account from "Set up email" to "Add an Exchange account".

Bug: 2159019
2010-02-01 14:24:38 -08:00
Marc Blank f3fcb8929e Implement Exchange calendar sync support
What should be working:
* Events sync down from server and appear in calendar
* Recurrences and exceptions appear in calendar
* Changed events on server should be reflected in calendar
* Deletions on server should be reflected in calendar
* Push of new/changed/deleted events should work
* Changes on device are NOT synced back to server
* New, single events on device are synced back to server
  (no time zone, attendee, or recurrence support)
* Checkbox for syncing calendar added to setup flow
* System sync glue in manifest, etc.
* Bugs are to be expected
* A few unit tests; needs more

Change-Id: I7ca262eaba562ccb9d1af5b0cd948c6bac30e5dd
2010-01-28 09:18:48 -08:00
Makoto Onuki f613489663 Add "vendor policy" loader, and alternate exchange descriptive text.
- Dynamically switch to the alternate exchange strings to substitute overlays.
- Added the mechanism to load the "vendor policy", which tells you when the
  alternate strings should be used.

Bug: 2382710
2010-01-27 17:40:56 -08:00
Marc Blank 46199c65a3 Fix #2382368 (NPE in AccountSetupExchangeTests)
* AccountSetupExchange defaultly tries using EAS AutoDiscover, which isn't
  appropriate in the unit test setting
* Add an Intent extra to disable AutoDiscover and use it in unit tests

Bug: 2382368
Change-Id: I3d4e8d7194b02da44ad583da0cf2fe60ffb19311
2010-01-27 13:57:20 -08:00
Andrew Stadler d612717340 Backup/Restore accounts - bugfix
* Followup to 5e91cccd
* Workaround for (HTC bug: 2275383) & (Moto bug: 2226582)
* Restores mSyncKey as null instead of empty string, which is how
  a new account is initialized.  Bug: 2385980
* Cleanup synchronized logic in backup & restore
* Minor cleanups & improved comments
2010-01-20 16:52:12 -08: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 0b8b68cbeb Fix account creation race condition
* Due to the order in which account creation occurs in the Provider
  and in AccountManager, and the fact that there are data observers
  on each that initiate account reconciliation, a race condition exists
  that can cause either of these accounts to appear to be orphaned,
  and thereby get deleted
* We add an "incomplete" flag to the Account in EmailProvider and
  set/clear it during account creation.  The various reconciliation
  methods will ignore accounts marked as incomplete.

Bug: 2353755
Change-Id: I13fb144dd857f839eb3471b01f271f3a0d4d8159
2010-01-19 13:07:49 -08:00
Marc Blank 74724af62c Fix autodiscover when attempted with Exchange 2003 server
* Make sure 403 error in autodiscover isn't treated as an auth error
  (401 is used for that)
* Make non-auth errors in autodiscover fail silently (and move user
  to manual setup)

Bug: 2374302
Change-Id: I4699bff70cf5ec4a513e6443e4817543c2ab2cef
2010-01-15 15:36:34 -08:00
Marc Blank 17da1767e3 Implement Autodiscover for Exchange servers
* Autodiscover allows complete configuration using only email address
  and password
* Code handles the two standard autodiscover addresses and redirect
* Autodiscover process starts when the user chooses "Exchange" as the
  account type.  If the account is created via the AccountManager,
  autodiscover begins upon tapping "Next" for the first time
* If autodiscover fails due to anything other than auth failure for
  autodiscover-capable servers, the user is placed into the standard manual
  configuration screen

Bug: 2366019
Change-Id: I936712b924833d9a133e8da04e11c3ba45d92f92
2010-01-13 17:11:49 -08:00
Marc Blank f1efd65a5e Fix "back key" flow for Email account setup
* The existing flow is badly broken; every "back" causes the user
  to leave the setup flow and therefore have to start from scratch.
  This is a very bad user experience, as previously entered data is
  lost and must be re-entered.
* The fix corrects these problems, allowing the user to back up
  through screens UNTIL the account is successfully created.
* After account creation, the user is returned to the proper screen,
  depending on whether we're in "eas flow mode" or not

Bug: 2337511
Change-Id: Ie25ac73dfcd8a1dca36e1b31c75ffb22359840d1
2009-12-21 11:28:53 -08:00
Marc Blank 29935abb1c Fix #2251837; better response when provisioning is required.
* Currently, we validate EAS accounts using a command that will
  succeed even if we do not support required security policies.
* This causes a confusing "invalid username or password" error
  when trying to sync with a validated account in the case that
  there are, in fact, required policies
* The fix is to send a sync command after validating the user name
  and password; a 403 error indicates the requirement for
  security policies.
* When we see the 403 error, we put up a message that is appropriate
  to the situation.

Change-Id: Ic40820253dca1f357297b2355ad987bc39d0775f
2009-11-10 16:29:10 -08:00
Andrew Stadler f16a3f2f6a Cleanup delete handling issues in POP3
* Removed obsolete "delete after 7 days" option from pop-up prefs
* Mark deleted message sentinels as "read" so they don't contribute
    to unread counts.

Bug # 2157487 and Bug # 2159278

Change-Id: Ic3cbc51d6f5ede2eb923e2d0e5c0dfee377764f5
2009-10-01 01:45:10 -07:00
Andrew Stadler e4a7cc440f Re-enable modernized version of "optional" SSL/TLS
* Add "Accept all certificates" modes to incoming/outgoing secure choices
* Change URI scheme slightly to make "trust" a flag, not part of the
    protocol.
* Change Stores to know about new URI scheme
* Slightly rework Transport API to make "trust" an independent flag
* Adapt HostAuth to handle new Uri scheme
* Remove the old ambiguous "optional" code, which was allowing
    some unsigned certificates, but was *also* allowing TLS to
    optionally start (though not SSL, despite the UI strings.)
* Add a few unit tests to EmailContent
* Add logging and a bunch of comments to TrustManagerFactory, and a bit
    of simple cleanup to make it more readable.
* Add missing conversion of SSLException->CertificateValidationException
    in TLS so we get the correct certificate errors from TLS too.
* Re-enable TLS for mac.com accounts (which had a certificate problem)

Fixes bug http://b/2119755, http://b/1374780, and probably a raft of
earlier and/or external bugs about certificate problems.

Change-Id: Iaf99a8da3eaadaa4cdeec224737838b5d6813e55
2009-09-29 15:28:43 -07:00
Marc Blank 832e4a02a6 Add hostChanged service call; use it from UI (fixes #2148572)
* After a HostAuth has been changed for an EAS account, the SyncManager needs
  to be alerted so that it can take appropriate action
* Added hostChanged service call
* Send service call from AccountSetupExchange after a HostAuth is edited
* Stop running syncs and clear error states in hostChanged

Change-Id: I2311e2d00be81ea7829f5f4e38b2377f18c63f30
2009-09-28 10:57:27 -07:00
Marc Blank e1145d1739 In EAS flow mode, don't try to use auto-setup (fixes #2143583)
Change-Id: I53a287d909fdde3c6ab75087a4a049c3afe9852c
2009-09-24 11:58:11 -07:00
Marc Blank b19bc4c0b6 Save HostAuth's when returning from editing Incoming/Outgoing settings
* in onActivityResult, we not only need to update the Account, but also
  the relevant HostAuth (both if coming from AccountSetupExchange)

Change-Id: I0657ff257fe949e46e100eb3e6cfec6162514aa9
2009-09-23 18:31:16 -07:00
Marc Blank 4cf3252fb0 Workaround system peculiarity to fix #2134509
* Our AccountManager listener was getting unregistered due to the way
  ApplicationContext caches AccountManager in a static member
* The result was that AccountManager registers its listeners against the
  FIRST context it is instantiated with!  Future calls will all obtain
  this pre-initialized AccountManager.
* In this case, AccountSetupOptions was the first caller (to create the
  AccountManager Account for Exchange)
* The subsequent call to register a listener therefore had its registration
  tied to the context of AccountSetupOptions, and was therefore leaked
  when AccountSetupOptions finished!
* This caused a chain of problems - the leaked receiver, an Exception in
  AccountManager when trying to ping the listener in an expired context,
  and eventually the bug referenced above, which became a P1 issue

Change-Id: I478e28d21ca77419afa8011e4ed8101cdf67ab79
2009-09-22 10:40:46 -07:00
Marc Blank 7b79163aac Show "sync contacts" setting properly in the settings page
Change-Id: I9c198e7795a8f2ea348361092eae22c8ff22a1a0
2009-09-21 10:39:10 -07:00
Andrew Stadler 8067b54294 UI cleanups for new account creation
* Improve appearance of basics screen and use simplified text
* Provide alternate text when in EAS account setup flow (from acct mgr)
* Change "Exchange/ActiveSync" button to "Exchange account"
* Add some spacing to the three buttons, to improve appearance

Bugs addressed:
2128055 Change string in account picker activity to Exchange
2132713 Welcome message for Email app is inappropriate when coming from
          Settings -> Accounts & sync -> New account
2009-09-20 17:26:43 -07:00
Marc Blank 7041dc5d1b Reconnect Settings -> Accounts to Email account settings screen
* This was broken during the AccountManager naming reversion

Change-Id: Ib2ccc9ca187ffdaf4a978c3c8111808be50d1583
2009-09-20 14:56:02 -07:00
Marc Blank a4482e865d Fix service behavior w/r/t onStartCommand, onCreate, onDestroy
* Make sure to null out vars in onDestroy
* Use START_STICKY as return value for onStartCommand
* Start SyncManager from EasAuthenticator callback, rather from the
  authenticator itself (otherwise, the Account might not have been
  created when we start SyncManager)

Change-Id: I54ff8d5586e96f016b365587717710dee3202da8
2009-09-19 13:38:59 -07:00
Andrew Stadler cd1e207200 Fix NPE when entering account settings. 2009-09-18 15:13:12 -07:00
Marc Blank 91f12b8d52 Fix problem with account settings not being saved (#2131153)
Change-Id: I6845604c6f3326e136060cace55fc53fcca867c9
2009-09-18 12:39:42 -07:00
Marc Blank eadb55b04e Implement hooks from Settings->Accounts to Exchange account setu
* Fixes #2106718
* Fixes #2106733
* Remove "Add another account" from the preference screen

Change-Id: I8db1400d2bdb6ed7d3aeb2049cc1a399c47c38c5
2009-09-18 09:19:41 -07:00
Andrew Stadler 8b91975fa5 Clean up transport encryption & port options
* Remove SSL-Optional and TLS-Optional choices from UI
* Remove SSL-Optional and TLS-Optional choices from providers.xml
* Switch over most SMTP connections from 25 to 587
* Clean up the providers list which has a lot of "optional" cases
    that were probably falling back to unencrypted.

Fixes bugs:
2110243	Settings UI shouldn't offer SSL/TLS (if available) options
2089070 Update list of providers

Change-Id: I57be57b349eed33a5284121d904528279a36a91c
2009-09-17 23:47:00 -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
Marc Blank acfd155c12 Don't add backslash if there already is one; fixes #2124974
Change-Id: If5fa8369ee4c52449047d5134f3bf28feb88de1a
2009-09-16 18:55:28 -07:00
Marc Blank e428f94161 Add "Sync Contacts" to Account preferences screen (part of #2106733)
* Also added some checks for null Accounts and HostAuth

Change-Id: Ia4ae68d0e8a62abdaf002519766b6685b6947e9e
2009-09-16 16:07:27 -07:00
Marc Blank ac37c5c15a Change Exchange username validation to exclude bare backslash
* Fixes #2121422

Change-Id: Id55dfa365b83d725926e3e7dcd7b646256863aa1
2009-09-15 18:05:16 -07:00
Andrew Stadler da8836a76c Give warnings if dupe account created:
* Check for existing accounts with matching servername + username
* Show a dialog and block account creation
* Triggers in three cases:
  * After input of an auto-setup account (e.g. Gmail or AOL)
  * After input of manual setup (incoming) parameters
  * After changing incoming parameters of *any* existing account
* Made some notes in EmailContent regarding fields in HostAuth that we
    are not actually using.
* Added HostAuth unit tests

Primarily fixes bug # 1964449
Bonus fix for bug # 1594408

Change-Id: I49310faf6654280582e0ab3d3e40f2701bfcd21d
2009-09-15 16:33:44 -07:00
Marc Blank 60c7502b67 Change exchange setup screen per #2025029
Change-Id: Ib94713857902e336984b847f70c96e04826b9b74
2009-09-13 21:55:10 -07:00
Andrew Stadler 6c21942ec4 Implement move-to-trash for IMAP and POP3.
* Define new message-loaded state "FLAG_LOADED_DELETED" (used only for
   POP3, which needs to write sentinel messages that are not displayed.)
* Also renamed the other flags to make the naming more consistent.
* Tweak MessageList query generation to inhibit display of deleted
    message sentinels, and MessagingController won't try to resync them.
* Clean up implementation of Controller.deleteMessage()
* Add support for move to trash to MessagingController.  This operates
    in three primary modes:
  * POP3 local delete (no server-side interaction)
  * POP3 server delete
  * IMAP server delete (and copy to IMAP trash mailbox)
* Add missing implementation in provider to delete all of the attachments
    for a given message
* Fix progress reporting in activities (the test for error vs. progress
    was inverted, which caused progress indicators to keep spinning
    after errors.)
* Fix broken account settings UI (POP3 delete policy was not persisting)

Addresses bug 2097409

TODO delete from trash / empty trash

Change-Id: I00188e6dc2093823106e009f35b68c760227c9e6
2009-09-10 12:44:05 -07:00
Marc Blank 805562e26f Fix logic for use of "Sync Contacts" button value
Change-Id: I9abed1830a61795542bdf15ee62395a63abc9222
2009-09-09 18:37:42 -07:00
Marc Blank cef2344e70 Rework EAS account creation & ssl operation
* Fixes 2048663, 2025029, and 2100131
* Add "Trust Certificates" checkbox in EAS account creation
* Use custom ClientConnectionManager for HttpClient with registry
  for plain, ssl, and tssl (trusted ssl) connection
* Use a ConnectionPool for HttpClient connections
* Remove "Domain" checkbox in  EAS account creation
* Remove tests related to the "Domain" field
* TODO Write a test for valid usernames (requires a bit of research)
  <name>, <email address>, <domain>/<name, and <domain>\<name> are all
  valid, but there might be others

Change-Id: I4a0338df5960bfd3d679a88aaf22d1c49f49992b
2009-09-09 10:32:06 -07:00
Marc Blank a3c6c6ed29 Handle errors in account creation by AccountManager
* Don't create our EmailProvider Account until we get a confirmation from
  AccountManager that the system Account is created
* Put up an erorr dialog if AccountManager fails for some reason (this is
  what we saw in bug #2072668)
2009-08-26 13:20:23 -07:00
Jeff Hamilton d382107bdc Don't try to load the owner info for now, it's not available. 2009-08-20 22:51:26 -05:00
Andrew Stadler bcff14acf2 Create setup flow for use by Accounts manager.
* Create a new entry point for the exchange setup flow and switch
    EASAuthenticatorService to call it
* Pass "eas flow mode" down through the setup screens
* Slightly modify their behavior as we go (e.g. we skip the
    (account type" screen since we know it's EAS.)
* Add a checkbox to "sync contacts from this account" and pass that
    value into ExchangeStore when we set up the account.
* Change the flow exit to pop back to the account manager instead of
    taking the user to the new inbox.

This CL satisfies cases 1 & 2 of bug # 1974752.
2009-08-20 15:51:36 -07:00
Jeff Hamilton fb67ec958c Handle null cursors when looking up owner info. 2009-08-19 12:26:44 -05:00
Andrew Stadler c640cbbaf3 Update SMTP to send from provider messages, and attachments
* Change Sender definition (remove old Message from API) and update
    any existing calls through that API
* Rewrite SMTPSender to use provider messages
* Add attachments to RFC822Output
* Minor bugfixes in RFC822Output
* Unit tests
2009-08-13 09:31:57 -07:00
Marc Blank cc402e42ab Clear error states on network reconnect; add temporary notifications; see details
* When we get a network connect broadcast, clear error states so sync can
  restart for any boxes in an error state
* Add temporary notification code for the testers
* Add file-based debug logger
* Add Exchange logging to debug screen (adds additional exchange debugging)
* Add Exchange sd card logging to debug screen (logs to sd card)
* Change setLogging service API to send an int rather than a boolean
* Make sure push mailboxes are set up again when account changes to push
* Make sure push mailboxes are set up again when account mailbox starts
* (Fixed contacts sync bug found during debugging these changes)
2009-08-09 21:20:47 -07:00
Mihai Preda a5af05f1a9 MessageCompose: load body.
- load body for edit-draft, replay, forward.
- fix debug secret code for no-keyboard devices.
- fix CR-LF BUG 1911254.
- fix menu invoke compose from folder with mailboxId < 0.
2009-08-06 11:40:42 +02:00
Marc Blank 948c36f47a Reimplement EAS contacts sync to work w/ new system facilities
* Modify to work with ContactsProvider2
* Modify to work with system AccountManager
* Modify to work with system SyncManager (for triggering user-change syncs)
* Sync server->client for adds/deletes implemented (CP2 doesn't handle delete yet)
* Sync server->client changes handled efficiently (only write changes)
* Some fields still not handled
* Rewrote most of the CPO code to handle server->client changes
* Sync client->server works for supported fields
2009-07-30 09:22:40 -07:00
Mihai Preda 180d69e085 Fix UnsupportedOperationException in AccountSetupBasic caused by Account.update() when !isSaved().
Bug 2001896.
Introduced by CL 8158.
2009-07-27 20:56:43 +02:00
Andrew Stadler 9e2c6bd5f2 Remove saveOrUpdate from EmailContent to prevent stale writes
* Numerous classes modified to deal with this change
  * Fixes bugs 1993292 and 1994671
  * Renamed various setter and getter methods to reflect the underlying
    field names
  * Renamed syncFrequency to syncInterval in Account and Mailbox
  * Convenience method added to AccountSettings to save only user settings
  * Calls to content.update(context, content.toContentValues()), which save
    all fields, should be double-checked for correctness, making sure that
    content has current data and will not conflict with other threads that
    might modify that data
  * Ran all unit tests to confirm proper function

NOTE:  The logic to enforce single default account no longer works,
because that logic is in Account.save() and does not run via
Account.update().  I have patched out a small section of the relevant unit
test and will file a bug to come back for this fix.
2009-07-22 15:13:30 -07:00