Commit Graph

98 Commits

Author SHA1 Message Date
Doug Zongker f44a40cda1 replace Email's private base64 class with one from android-common
Convert all usages of com.android.email.codec.binary.Base64 to use
com.android.common.Base64 instead, except for Base64OutputStream
(which doesn't exist in android-common yet).

Change-Id: I339a1f451245138187080c7444fcabef8d13f8aa
2010-02-08 20:26:02 -08:00
Marc Blank 09b45fdcff Additional work on EAS security
* Add more final plumbing for exchange security
* If policies are supported, we now check to see if they are active;
  if so, we acknowledge this to the server, after which we are given a
  final policy key which can be used for syncing

Change-Id: I5992c790294e35b5ec5343c7665e2e7fd31a75ca
2010-02-07 13:28:18 -08:00
Marc Blank 72a5e7d7c1 Initial implementation of EAS security
* This first implementation integrates with early CLs for
  Email app integration with device security
* Check for policies added to validation process
* If the server has no policy requirements, there is no change
  to the existing process
* We automatically declare a set of policies to be unsupported
  if any are known to the sync adapter to be unsupported
  (e.g. no attachments or password history)
* We call isSupported (PolicySet) to determine whether other
  policies use values that the OS can support (e.g. password length,
  inactivity time, etc.)
* Depending on whether the server's policies are unsupported or
  supported, we throw the proper exception back to the caller

Change-Id: I704cb2151dd87f54c83c2aa23976a8ac8e2c501a
2010-02-05 12:33:07 -08: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
Andrew Stadler a1550678af Integrate policies into account setup process
* Rename SECURITY_POLICIES_REQUIRED to SECURITY_POLICIES_UNSUPPORTED
* Create new pathway for SECURITY_POLICIES_REQUIRED, making it advisory
* Cleaned up strings for account setup error dialogs
* Refactored AccountSetupExchange.onActivityResult() to split up the
  three primary use cases, making them more readable.
* Always finish() in AcccountSetupAccountScreen, because it's usually
  cleaner to return to the previous screen (enter username & password).
2010-02-04 15:04:48 -08:00
Marc Blank 48e20b81e6 Fix #2415185 (Email disappears after a while)
* Exchange account validation tests security policies by sending a
  FolderSync command and determining whether this generates an
  error
* Unfortunately, we use the real deviceId when sending the command
  and this causes the next real sync to fail such that all data is
  wiped and reloaded (the bug)
* The fix is to use a false device id while doing validation

Bug: 2415185
Change-Id: Ibe577e36f770d737ba5952b347aa0d73bda3568a
2010-02-04 12:39:07 -08:00
Makoto Onuki bb9b5163c1 Move non-exchange specific classes to com.android.email.service. 2010-01-29 10:37:39 -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
Marc Blank 5de54008e5 Handle Exchange meeting invitation responses
* Includes some refactoring of internal "request" code in SyncManager
* Adds Message flags to tag meeting invites and cancellations
* Adds meetingResponse method in EmailService
* Hooks into Controller and MessageView UI included

Change-Id: I4c5e10bccc4b41956b94d9dfa55925e5af030939
2010-01-26 09:08:52 -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 89ab89dd83 Make sure protocol version is always set in sync services
* A recent change caused an issue in which protocolVersion could
  be null, resulting in an NPE
* Ensure that protocolVersion is always set to a valid version,
  defaulting to 2.5

Bug: 2353859
Change-Id: I6e07ba3df5362c988658e401bebc1776a6780876
2010-01-07 11:59:57 -08:00
Marc Blank 42e5dca4ef Add sanity checks in SyncManager and EasSyncService
* Prevent possible NPE's

Change-Id: I2b3c747609c6a87ec6060fd59006f2912dfcc591
2009-12-18 13:54:53 -08:00
Marc Blank 4a7a50f6a6 Fix potential NPE in earlier CL
* Noted this problem in reviewing a newer CL
* Fix is to add a check in setupService

Change-Id: Ia4d71365f8036aac8bf531b835b184dabfbc06fa
2009-12-14 17:17:30 -08:00
Marc Blank ec2d0e41b7 Use correct EAS protocol version in Outbox (fixes #2319892)
* We inadvertently failed to set the EAS version in EasOutboxService,
  so the default of 2.5 is used
* This works, but SmartReply/SmartForward were enhanced in 12.0 and we
  aren't taking advantage of those changes
* The fix is to set the version using common code

Change-Id: I3b505448003f340681deeb8fb22e61e9dd8d10a0
2009-12-10 14:11:23 -08:00
Marc Blank d3da948c31 Fix #2300147 (mistakenly reporting connection error)
* When a mailbox sync is stopped intentionally (for example, if account
  settings change), we report a connection error by mistake
* Handle this case properly, reporting "success" (i.e. no error state)
* Remove obsolete comment

Change-Id: I9bec1244267cd2240c369b9b7f905948381a0f91
2009-12-03 09:58:56 -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
Marc Blank ccd29c33ed Allow sync data to arrive via the chunked transfer encoding.
* Fixes #2216885
* The bug is that the sync adapters weren't set up to handle chunked
  encoding, primarily because 1) I hadn't seen any servers use it, and
  2) when we changed from HttpUrlConnection to HttpClient, support for
  chunked wasn't added (HttpUrlConnection didn't support it)
* The fix for xml data is trivial, since the Content-Length returned in
  the chunked case (-1) was being disallowed, but works perfectly well
  with HttpClient.
* The fix for attachments is less trivial, but still straightforward.
* With this change, we are no longer dependent on receiving content-length,
  which is highly desirable

Change-Id: Ie3bd6af0cf68f3afa190711d96b1dbd2e6341f79
2009-11-01 13:48:31 -08:00
Marc Blank e7965e975f am 1e1d7cb1: Merge change Ie2804ddc into eclair
Merge commit '1e1d7cb189e7ea7164d1335539d68d3d3ca8c0e5' into eclair-mr2

* commit '1e1d7cb189e7ea7164d1335539d68d3d3ca8c0e5':
  Fix #2225869 (Regression in attachment loading / Exchange 2003)
2009-10-30 14:33:58 -07:00
Marc Blank 05dfc20853 Fix #2225869 (Regression in attachment loading / Exchange 2003)
* The fix to bug #2191778 inadvertently broke attachment loading for
  Exchange 2003 servers; the server responds with a 403 error (indicating
  an authentication issue)
* All other communications with the server work properly
* We use a slightly different set of calls in the case of attachments (we
  wanted to change as little as possible in the fix to #2191778) than we
  do in the other cases
* The fix here is to use the same calling sequence for attachments that we
  use elsewhere
* This fix has been observed to work on multiple servers, and in various
  SSL scenarios (on/off, trusted/untrusted)

Change-Id: Ie2804ddcbfa2b10edff42f7a3811734c325e933d
2009-10-29 20:10:46 -07:00
Marc Blank e53de6985a Server validates even though server address is wrong DO NOT MERGE
* Fixes #2173664
* Make sure that not only is the OPTIONS command accepted, but that
  the server reports EAS versions and commands

Change-Id: Ic29d3eacfdc54d107600afc443964a1e8b3d5e59
2009-10-28 08:53:57 -07:00
Marc Blank 38203a3fde Fix timing-dependent crash in Medium tests (#2202726)
Change-Id: I218079f24f1ce08d770624d1272e1d9a46c1be26
2009-10-21 12:41:57 -07:00
Marc Blank 3a88e2c35c am 55a97fc3: Fix attachment loading with "accept certificates" checked
Merge commit '55a97fc360ac549631af3aa3aad9833812674562' into eclair-mr2

* commit '55a97fc360ac549631af3aa3aad9833812674562':
  Fix attachment loading with "accept certificates" checked
2009-10-19 10:40:15 -07:00
Marc Blank 55a97fc360 Fix attachment loading with "accept certificates" checked
* Fixes #2191778 (P1/S1)
* Attachment retrieval wasn't using newer code to create its
  HttpClient.
* Fix is simple, extremely safe

Change-Id: I65be27decae8719bbad8ac7dce1c1164de4371a5
2009-10-19 10:34:10 -07:00
Andrew Stadler e3e02adac6 am dee4e253: Do not trust server-provided content type for attachments
Merge commit 'dee4e25320c5154a5626446e1aa37f63ae97c48c' into eclair-mr2

* commit 'dee4e25320c5154a5626446e1aa37f63ae97c48c':
  Do not trust server-provided content type for attachments
2009-10-14 07:37:12 -07:00
Andrew Stadler dee4e25320 Do not trust server-provided content type for attachments
* Fixes a bug that caused some attachments to be labeled with the
  wrong content type and thus unable to be opened by local apps.
* When the attachment code was written, MimeTypeMap had very few
  entries, so we tried to get the mime type of Exchange attachments
  from the stream when the file was read off the server.  It turns
  out that the server's idea of mime type is unpredictable
* In the meantime, MimeTypeMap has been fleshed out, so we really
  do know the type in the vast majority of cases (and including all
  common document types)
* The fix is to remove the lines related to reading the mime
  type from the attachment stream
* Content type is set (properly) when attachment record is created.  See
  EasEmailSyncParser.getMimeTypeFromFileName() for details.

Fixes bug http://b/2182955

Change-Id: Iebb3de529df4548327d7112e1dedb3bd448462a4
2009-10-13 21:09:40 -07:00
Marc Blank 7cfda60b2b am 4e424a33: Merge change Ie093215f into eclair
Merge commit '4e424a33c29446d750790e360e43fb7c83ec0c6f' into eclair-mr2

* commit '4e424a33c29446d750790e360e43fb7c83ec0c6f':
  Add truncation at 100k (EAS 2.5) and 200k (EAS 12) (#2184807)
2009-10-13 14:46:04 -07:00
Marc Blank 5fd81cad4c Add truncation at 100k (EAS 2.5) and 200k (EAS 12) (#2184807)
* Prevents OOM errors with huge message bodies

Change-Id: Ie093215f96a514b3a1bcd31aa1f5957d1ada7719
2009-10-13 12:06:47 -07:00
Marc Blank 8be9b8937b am ea878be1: Make sure we hold WakeLock during mail sending (fixes #2180551)
Merge commit 'ea878be11729cd793d9183fc264118241cd5a5b6' into eclair-mr2

* commit 'ea878be11729cd793d9183fc264118241cd5a5b6':
  Make sure we hold WakeLock during mail sending (fixes #2180551)
2009-10-10 22:59:05 -07:00
Marc Blank ea878be117 Make sure we hold WakeLock during mail sending (fixes #2180551)
* Don't runAsleep unless this is a Ping
* Relates to #2178288 in that it's possible that the system could
  sleep while we're trying to send (not sure if this is possible;
  will check), so we prevent it by holding a WakeLock in this case

Change-Id: Ib3f8786501b942e1cfcb7a0bbb07b8e3084e2a86
2009-10-10 22:54:24 -07:00
Marc Blank 7a8bbfe0b0 am 4b59cfc8: Fix problem with timeouts and sending attachments (#2178288)
Merge commit '4b59cfc8ed4054ffb5ad85cea8aba94a430cc2cb' into eclair-mr2

* commit '4b59cfc8ed4054ffb5ad85cea8aba94a430cc2cb':
  Fix problem with timeouts and sending attachments (#2178288)
2009-10-09 12:43:01 -07:00
Marc Blank 4b59cfc8ed Fix problem with timeouts and sending attachments (#2178288)
* Standard Exchange command timeouts are 20 seconds
* For sending, however, these need to be significantly longer to
  handle the case of sending large attachments, as sending (of any
  length) happens in a single HTTP Post command
* Having an infinite timeout leads to the (small) possibility of the
  Outbox hanging for a long time, holding up the sending of other
  mail, so we set a long, but not infinite timeout for this case
* Timeout now set for 15 minutes
* Prevent sync of Outbox and Drafts (the UI triggers these by changing
  the contents of these boxes, but we need to ignore the pings that
  are generated this way)

Change-Id: I5b830d6b4e94525d95138b2112be12898a37882e
2009-10-09 11:20:52 -07:00
Marc Blank 8063528202 Server validates even though server address is wrong
* Fixes #2173664
* Make sure that not only is the OPTIONS command accepted, but that
  the server reports EAS versions and commands

Change-Id: I15dccd1fbd06aa3cf2ba8fbbf72d20918ec44617
2009-10-07 17:10:46 -07:00
Marc Blank ffef9d9fe8 Help with another push inconsistency edge case (#2131432)
* If we are forced to abort a "ping" due to a watchdog alarm, we should
  handle this as a ping failure (which potentially changes the heartbeat)
  rather than a garden variety IOException.
* This prevents the additional overhead of connection error backoffs,
  which would only tend to increase the time needed to recover from the
  error.
* In one case reported by Moto, this appears to be the behavior of a WiFi
  router with NAT timeout.  This fix will cause maximum delay for pushed
  mail to be reduced in most cases.

Change-Id: I2b0e3b10d82762d20f63cac3ac4638a03f13f842
2009-10-06 13:46:09 -07:00
Marc Blank 36842abe9f Fix push failure edge case (#2161999)
* Unsafe (potentially stale) data was being written to the Mailbox table near
  the end of each sync.  It would effectively undo changes made to the
  Mailbox in other threads that occurred while the Mailbox was syncing.
* In this particular case, changes to sync interval (push/ping/timed)
  were being overwritten, which could cause push to get lost for as
  long as 30 minutes (the pingLoop timeout when there aren't any
  pingable mailboxes)
* Watchdog alarm was being set to wrong time (typo)
* Add extra user logging in case there are additional cases of push
* Only set sync status and time on successful sync
* Move ping error check into pingParser to avoid unnecessary sync

Change-Id: Icb4494078480ada39b7494b3abf380fb08858406
2009-10-02 11:09:08 -07:00
Marc Blank 3fef6f4a47 Fix an issue related to ping loop errors and ping state; add logging
Change-Id: Ie6d16a8914205ddf63ae1929961279f66360eb89
2009-09-30 12:23:23 -07:00
Marc Blank 0797b4e351 Near-final tweaks to sync timeouts and logging
* Tighten up user logging
* Send all HttpClient commands w/ watchdog to prevent
  holding wakelocks too long
* Fix case in which no ping boxes are ready in which
  ping loop would hang on to WakeLock indefinitely
* Release WakeLock for waits < 10 seconds, rather than
  30s in SyncManager
* Improve logging of IOExceptions
* Log network status (at least until #2150976 is fixed)

Change-Id: I020b8a21c2c4f536d5b6df871f6b5c03fdc66ab8
2009-09-29 11:37:01 -07:00
Marc Blank a4258ed487 Fix sendPing to set proper ping timeouts
* We were setting the timeout and heartbeat to the same time,
  which could cause mistaken timeouts
* Set timeout ten seconds after the heartbeat for now, and set
  an alarm a few seconds after that

Change-Id: Ic2f7b44c9626ebbdd7a8821f53f7aaf6169f62c3
2009-09-28 20:06:54 -07:00
Marc Blank f60bf5f351 Reduce the sync window from 20 items to 5 (partial fix #2149029)
* This change trades off network time / overhead with time keeping
  ContactsProvider2 busy
* The net effect will probably be to reduce some UI slowdowns while
  syncing Exchange contacts, while increasing the time it takes to
  sync those contacts

Change-Id: I56e2358698aa4c901cda4559f7a8f9117681f627
2009-09-28 14:49:35 -07:00
Marc Blank 7822aec383 Run sync threads in background priority (helps with #2126515)
* Seems to improve UI responsiveness while doing large syncs,
  but it can still slow down quite a bit

Change-Id: I539b8a9a96a922d810fba02ff4093759489a8153
2009-09-24 17:22:51 -07:00
Marc Blank cf19af4c74 Add more ping logging to detect odd looping behavior in Moto log
Change-Id: I66f9789cf9ded590ec96b502c2f74f5d0ae5d17d
2009-09-23 17:49:47 -07:00
Marc Blank 1d4d1b8d90 Make sure we don't start account sync without push/ping active
* Wait for mailboxes to finish the initial sync while waiting in pingLoop

Change-Id: Ie1606e225261e071981cef0aab3bd623a360fc86
2009-09-20 22:18:19 -07:00
Marc Blank 657de3bfd6 Revert change to AccountManager naming; use email address again
* Forces wipe of existing accounts

Change-Id: I65d08e07a2d74f94f9142e85791d9bf49c100241
2009-09-18 20:48:43 -07:00
Marc Blank 7e89834cfd Fix problem w/ SmartReply & SmartForward in Exchange 2003
* It doesn't like URLEncoded commands; go figure!
* Fixes #2127892

Change-Id: Ibae8cad990ed45accb6699716fda56f45c850939
2009-09-17 15:50:52 -07:00
Marc Blank e7e1ca432e Change AccountManager username for Exchange to the user's login credential
* This is not a backward-compatible change (sorry)
* Existing AccountManager EAS accounts and contacts are deleted
* Existing EmailProvider data is deleted
* Change works with new code (stadler) to avoid account duplication

Change-Id: Ife09c51fa714d91054d017b497bce603add5375a
2009-09-17 10:06:27 -07:00
Marc Blank a84a0e9a0d Fix EAS sending (#2122221)
Change-Id: I92ea4b1a77d96bf7992ea34026a2c5d30f33c317
2009-09-15 16:20:34 -07:00
Marc Blank 1d98989222 Implement SmartReply/SmartForward for EAS; fixes #2098779
* SmartForward and SmartReply are EAS commands that automatically
  include the original message and, if a forward, all original
  attachments, regardless of whether they've been downloaded to
  the device
* Both commands improve battery life by sending less data; greatly
  so for SmartForward if there are attachments

Change-Id: I12432cd5275a3b54e9a80d5cd59da437c4a086cc
2009-09-14 15:47:38 -07:00
Marc Blank 4f9d5cf8f8 Don't wait longer than 10s for ping boxes to be ready
* Do a short ping in this case, which at least will allow the device
  to sleep while waiting
* Addresses #2116749

Change-Id: I9e70feaeef1361e1d66652dc66b92f6ee14751bf
2009-09-13 22:52:36 -07:00
Marc Blank 9679d4cf64 Don't sync if the "Sync Contacts" checkbox isn't set
Change-Id: I606f6c384fa34283ccee1eeaac90123347846f28
2009-09-11 18:34:06 -07:00
Marc Blank a918672f4c Fix connection failure retry behavior; don't try syncing w/o connectivity
* Also remove some logging and correct some erroneous logging
* Fix the backoff behavior on IOException

Change-Id: I5fb5a0bf73eaa681eb7b9c305c838e78e7ba88ab
2009-09-11 12:59:35 -07:00