Commit Graph

384 Commits

Author SHA1 Message Date
Makoto Onuki
bcf32320e2 Move isSecurityHold/clearAccountHoldFlags to Account
- Added unit tests
- I see the "open a cursor, move to the first row, read a column" pattern over
  and over.  Added a utility method for this.  (Let's try not to bloat the
  binary by copying code around!)
- Added helper classes for database related tests
- Removed code dup

Change-Id: I380959215cc1661b252158f0f6e35369b499cdf8
2010-07-28 11:12:38 -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
Makoto Onuki
a0b88dc1c8 Merge "Adding more test to MessageOrderManager" 2010-07-15 11:07:12 -07:00
Makoto Onuki
638c67f4db Adding more test to MessageOrderManager
Added a case where all the message in the message list is removed.

Change-Id: Iedc2dbdf391978bd67d3bcdc260590d98cc9ef7d
2010-07-15 11:06:19 -07:00
Marc Blank
cd0f12fda8 resolved conflicts for merge of 84f7d07d to master
Change-Id: I62abe3b8aa31a1b551d0396e184b648c305033ec
2010-07-14 23:12:20 -07:00
Marc Blank
7a1a203786 am e43b11ba: Handle correction of rejected Ping heartbeat
Merge commit 'e43b11ba3e9be9380b7c43cde3117c6de28f28bd' into gingerbread

* commit 'e43b11ba3e9be9380b7c43cde3117c6de28f28bd':
  Handle correction of rejected Ping heartbeat
2010-07-14 22:33:34 -07:00
Marc Blank
ec29471c73 Make sure signature is added to reply/forward
* Add this to processSourceMessage in the reply/forward cases
* Add unit tests for reply and forward case

Bug: 2734321
Change-Id: I6be8383fe5f217a4bda8e669cb69f439bc8e96b6
2010-07-14 12:43:37 -07:00
Marc Blank
e43b11ba3e Handle correction of rejected Ping heartbeat
* Handle status 5 for Ping command (heartbeat of out range)
* Write unit test for heartbeat reset

Bug: 2834195
Change-Id: Ic7952a4b296cf15c6ba895d6579fe7956b171e5b
2010-07-13 18:06:24 -07:00
Makoto Onuki
de0a1c33c9 Extract MessageListTask and make it self-contained.
Introducing MessageOrderManager which maintains a message list for
MessageView.  It's used to tell if there is newer/older messages
in a mailbox, and the id of them.

Also, slightly related to this, moved mWaitForLoadMessageId to
ControllerResults where it should belong.

Change-Id: I84e32180c7e84a317f2204bb10ad7245ec022dca
2010-07-13 11:26:01 -07:00
Makoto Onuki
e60d3648fd Extract presence check logic into its own class.
Change-Id: I12e449ce7f1d10ed4737581e35367eae84a7f29e
2010-07-13 11:19:04 -07:00
Makoto Onuki
7f247d1cd3 Disable MessageViewTests
- These tests will probably not make sense with the upcoming UI change.
- Moved testAttachmentWritePermissions to UtilityUnitTests.
  It's a test for createUniqueFile, which is now owned by Utility.
- Removed Long.MIN_VALUE hack from MessageView.
  New tests should have something better.

Change-Id: I9a09e5e8080a165b010607d1fa3112bcaaab4f90
2010-07-12 16:14:29 -07:00
Marc Blank
6fe5199154 Merge "New calendar sync adapter tests" 2010-07-10 15:38:58 -07:00
Marc Blank
f115d31ae8 New calendar sync adapter tests
* Created MockProvider that can be used for testing the results of
  ContentProviderOperation's for Calendar/Contacts (we can't use these
  within our mock contexts because we can't instantiate the provider
  classes within the Email package)
* Wrote some unit tests for MockProvider
* Use MockProvider to test addEvent, in particular how a user's attendee
  status is stored, depending on whether the event is new or updated

Change-Id: I97f02d125eb7347726261e12ce70aadc539be1d4
2010-07-09 10:24:58 -07:00
Marc Blank
5fcbdcf59f Merge "Send intro text with SmartForward" 2010-07-09 09:40:46 -07:00
Marc Blank
80ee607a7c Send intro text with SmartForward
* We need to include the intro text (--Original Message--, etc.) to
  SmartForwards, and somehow this got in a past updat
* Add unit test for forwarding
* Fix unit test for reply so that it works localized

Bug: 2477988
Bug: 2685784
Change-Id: I8d92f00d37a434840ec3eb237f3901cd5dc7ad09
2010-07-09 09:39:58 -07:00
Marc Blank
5b02ecf87c Fix SmartReply/SmartForward in EAS 2.5
* We inadvertently broke this with a recent update that uses Uri
  encoding for ItemId and CollectionId in SmartForward/Reply commands.
  We need to allow colon (:) however for EAS 2.5; otherwise, sends
  fail with HTTP 500
* Update unit test

Bug: 2821684
Change-Id: Ia6bdd2169513d1c13a8174dd599477a35df950f2
2010-07-07 14:42:31 -07:00
Makoto Onuki
57f4d0222b Adding 2 utility methods for testing
expectThrowable() and waitUntil().

Change-Id: I8e3af97ed02254ef2fdc72afadea1911ed23e4ab
2010-07-02 15:30:23 -07:00
Makoto Onuki
a0f1dd0a5c Merge "Cleaning up MessageView" 2010-07-02 13:31:26 -07:00
Makoto Onuki
44b5242edd Cleaning up MessageView
- Removed dead code/dead comment.
- Moved static utility methods to Utility.
- Renamed some methods.
- Changed the timing to call super methods.

Also:
- Internationalized formatSize()
- Added unit tests for createUniqueFile() and formatSize()
- createUniqueFile now uses File.createNewFile() instead of exists().

Change-Id: Ibc30e15b029ed5088954bd6fc9032e25dddf176e
2010-07-02 13:26:05 -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
4e366b9995 Merge "Always use the mime-type "message/rfc822" for eml files." 2010-06-29 12:37:27 -07:00
Marc Blank
5bd2faee5e Preliminary GAL/Contacts integration for EAS
Change-Id: I9997ac96f83f427c71caf12d591ba6069bedf935
2010-06-29 11:49:04 -07:00
Makoto Onuki
1d0be30871 Always use the mime-type "message/rfc822" for eml files.
Bug 2795919

Change-Id: Ie20fccdad34d7d17d7444af25d3e57033a45de5a
2010-06-29 10:40:31 -07:00
Marc Blank
51f5b2f3fa Fix problem with unencoded data in URI sent to EAS
* We need to encode the itemId and collectionId for SmartForward and
  SmartReply
* Add unit test for the fix
* Small change + test to EasSyncService usage of URI encoding to use
  a non-deprecated method

Bug: 2787725
Change-Id: I428b308b56cc359b8cdd9e42bc3f42c65b6797dc
2010-06-28 21:25:53 -07:00
Marc Blank
8d8f86e899 Cleanup and speed up isMessagingController
* Use the new Account.getProtocol() method to determine whether an
  Account "isMessagingController" (i.e. uses the legacy controller)
* Cache the result of this test, so that it's only done once per
  Account
* Add unit test

Change-Id: I6a0ec789a84bdf30b55156e6337a627fb4e81a08
2010-06-28 10:21:45 -07:00
Marc Blank
663b57daa7 Fix GAL search in EAS 12.1
* We weren't sending the proper protocol version to GAL search, which
  causes errors when using 12.1
* The simple fix is to send the agreed upon protocol version, instead
  of the default (which is 2.5)
* Replace parsing of protocol version with lookup

Bug: 2793588
Change-Id: Ib2a255d8467004ce985d2d688b37066e1e09d78a
2010-06-23 16:48:46 -07:00
Marc Blank
9b4988de43 Implement support for new security policies
* Minimum complex characters
* Password history (i.e. disallow re-use of past n passwords)
* Password expiration
* Password expiration is NOT yet supported in the framework; there
  is a TODO in this CL and a trivial change will be needed when
  support arrives; for now, we report this as unsupported
* The two implemented policies are testable

Change-Id: I477adbc000577c57d1ab1788378c97a60018c10c
2010-06-23 14:51:59 -07:00
Marc Blank
391ae25c43 Handle viewing of attachments that are, themselves, emails
* Add intent filter for application/eml and message/rfc822 mime types,
  launching MessageView with a Uri
* Modify loadMessageTask to handle the Uri by parsing the attachment's
  input stream with Pop3Message.parse(), and then creating an
  EmailProvider message in a special Mailbox created to hold
  "attachment" messages
* Delete all "attachment" messages after the parent message is closed
* Add unit tests

Change-Id: I20276ee006b9f05b889f3c808d3dc407cde26d49
2010-06-22 18:39:18 -07:00
Andrew Stadler
e4ecb50091 Convert AccountFolderList to use a Fragment
* Introduce AccountFolderListFragment and its layout
* Extract all list-related UI into it
* Fix leaking cursor in AccountsAdapter and add unit test

Change-Id: Ica566847d97927b736f515d434c6691c82343290
2010-06-18 15:32:10 -07:00
Marc Blank
1d6dab2956 Handle "Allow non-provisionable devices" properly
* Send policy key of "0" when validating; this gets us the policies
  even if "Allow..." is enabled (currently, we simply don't see the
  policies)
* If we don't support all of the policies, send back the response
  code indicating support for partial support.  If we get a positive
  response back, then we're good to go - the server allows devices
  with partial support.  Otherwise, we fail as we always have - with
  the toast indicating that the device doesn't support required
  policies
* Remove PolicySet.isSupported() and ensure proper field ranges
  within the constructor
* Update tests as appropriate

Bug: 2759782
Change-Id: I5f354a0e2d81844aff75d8a8a6de3b97f0020c1f
2010-06-16 13:14:36 -07:00
Marc Blank
ca6647a679 Merge "Add tests for CalendarSyncAdapter" 2010-06-16 10:53:43 -07:00
Makoto Onuki
34f29c8a74 Test for interaction between ImapStore and vendor policy.
Change-Id: I092b3a0f2f40d9aa19f2f61066362099c8b3f50b
2010-06-15 13:44:31 -07:00
Makoto Onuki
601187db42 Introducing MessageListFragment.
- Extracted MessageListFragment out of the MessageList activity.
- This is basically pure extraction, with the following conceptual change.
  - Now the MessageList activity doesn't know the mailbox id or
    the account id.  If it needs these ids, it needs to ask the fragment.
  - MessageListFragment.LoadMessagesTask tries to determine the account ID
    if it's unknown.

Most code in MessageListFragment is directly copied from MessageList
with minimal changes (e.g. pass mActivity instead of 'this' as a Context).
There's a few cleaning up oppotunities.  I'll work on them later in a separate
CL.

Change-Id: Ie004cc49b429f2cd8f9de73df5abb94f3054ea0a
2010-06-14 10:20:29 -07:00
Marc Blank
1a3b2f7de2 Add tests for CalendarSyncAdapter
* Test for creation of a typical event
* Test for creation of an event with redacted attendees
* More to come

Change-Id: Ica117cd20a9e270ffe49efed75607e92b4d8ac90
2010-06-11 16:31:15 -07:00
Makoto Onuki
36d3dfaeac Extract MockVendorPolicy, add standard mechanism to inject it.
One thing that bothers me regarding the new ImapStore is that there is no
tests to verify if the way how getImapId() uses a vendor policy hasn't changed.
This part is hard to test with a real vendor policy, and it can easily be
overlooked even if it's broken.

This CL offers ImapStoreUnitTests a way to test the interaction between
getImapId() and a vendor policy.

Also fixed a bug in VendorPolicyLoaderTest where it assumed the test apk
package name is "com.android.email.tests", but it may actually be
"com.google.android.email.tests" now.  (Broken since the test makefile
used inherit-package.)

Change-Id: I8feb616ea28cb5cae5b4fba57e363771014ac599
2010-06-11 15:11:15 -07:00
Makoto Onuki
851f3219e2 Renaming MessageListAdapter to MessagesAdapter
in line with MailboxesAdapter.

Change-Id: I4ed387db2f5ce1f9bad282521c62eeec0c697db4
2010-06-09 14:43:43 -07:00
Makoto Onuki
0fb092b389 Fix for failing SecurityPolicyTests.
This fixes the following exception.

java.lang.UnsupportedOperationException
        at android.test.mock.MockContext.getApplicationContext(MockContext.java:82)

Bug 2725552

Change-Id: Iaca177defe5f5e836211c58270379da056fa64e0
2010-06-07 16:14:53 -07:00
Makoto Onuki
0a892ae04f Extract MessageListAdapter.
Change-Id: I0e441b7fff925c7703ab88ab54240c5b42d045c4
2010-06-02 16:37:47 -07:00
Makoto Onuki
bf58053406 Follow-up to the new IMAP parser.
- Replace string literals in ImapStore with constants.
- Simplifies ImapStore.en/decodeFolderName
- Mix cases in the test data to test for case-insensitivity

Change-Id: I88424357227bcf78528df5e6a1c4ba45d54cc65b
2010-06-01 10:50:15 -07:00
Makoto Onuki
7e5ba0e1ea New IMAP parser to fix long-lasting problems.
- Almost completely re-wrote ImapResponseParser layer
- We no longer use simple ArrayList and String to represent
  imap response.  We have classes for that.  (Type safe!)
  These classes are also NPE-free.
  (which isn't necessarily a good thing, though)
- A lot of clean-ups and fixes in ImapStore.
- More tests for ImapStore.

Now ImapResponseParser moved to com.android.email.mail.store.imap.parser,
but inside, it's 99% new code.

This CL introduces many new classes, but most of them are small classes
to represent the IMAP response.

Problems that this CL fixes includes:
- Special characters in OK response
- Handling BYE response
- Case sensitivity
- ClassCast/ArrayIndexOutOfBound/NumberFormatException
- Handling NIL/literals at any position

Bug 2480227
Bug 2244049
Bug 2138981
Bug 1351896
Bug 2591435
Bug 2173061
Bug 2370627
Bug 2524881
Bug 2525902
Bug 2538076

Change-Id: I7116f57fba079b8a5ef8d5439a9b3d9a9af8e6ed
2010-05-28 15:59:09 -07:00
Marc Blank
637abf9852 Merge "Split UtilityUnitTests into medium and small test classes" 2010-05-28 13:29:36 -07:00
Marc Blank
654cc1f68f Split UtilityUnitTests into medium and small test classes
Change-Id: I382bb2bd94ba4d800e907f9c439b4e03f1f20ea4
2010-05-28 13:29:09 -07:00
Andrew Stadler
50adf5369c Merge "Refactor AccountsAdapter into its own class." 2010-05-28 13:26:46 -07:00
Andrew Stadler
f3c285d4a3 Refactor AccountsAdapter into its own class.
* Extract AccountAdapter from AccountFolderList
* Use callback instead of hardcoded launch of MailboxList
* Unit tests

Change-Id: Icafce1ef73a99fb61985c649620440656f9b51a3
2010-05-28 12:54:56 -07:00
Marc Blank
9d387ff0bb Fix validation use of FolderSync
* To avoid having to use a mock deviceId with FolderSync in validation, we now
  simply use the real deviceId with the correct SyncKey ("0" for a new account,
  or the actual sync key if the account already exists)
* Rework utility code that finds existing accounts
* Write unit test for findExistingAccount

Bug: 2589243
Change-Id: Ia532b2e209aec3aa01ca06617b4da78c3d986b32
2010-05-28 10:48:17 -07:00
Marc Blank
838beeb621 am 719d29bd: am 4c8adbc4: am 027a6ddf: Merge "Fix bugs related to TZ handling for all-day events" into froyo 2010-05-25 13:12:34 -07:00
Marc Blank
719d29bdcd am 4c8adbc4: am 027a6ddf: Merge "Fix bugs related to TZ handling for all-day events" into froyo
Merge commit '4c8adbc4aa81308e57ae129e9587ec50483af6a8' into kraken

* commit '4c8adbc4aa81308e57ae129e9587ec50483af6a8':
  Fix bugs related to TZ handling for all-day events
2010-05-25 13:10:35 -07:00
Marc Blank
4c8adbc4aa am 027a6ddf: Merge "Fix bugs related to TZ handling for all-day events" into froyo
Merge commit '027a6ddfaa7228854cb3c4238434f87fc69078b6' into froyo-plus-aosp

* commit '027a6ddfaa7228854cb3c4238434f87fc69078b6':
  Fix bugs related to TZ handling for all-day events
2010-05-25 13:09:05 -07:00
Marc Blank
3e065170f3 Fix bugs related to TZ handling for all-day events
* In bug 2703075, all-day events from time zones at GMT or later
  appear a day early; this is because the time was calculated from
  the GMT date/time of the event rather than the local date/time of
  the event; this CL correctly changes this to use local date/time
* In bug 2707966, device-edited all-day events disappear in Outlook
  and OWA after upsync; this is due to the fact that we store all-day
  events in UTC on device, whereas we need to upload all-day events
  using the original (local) time zone.  In this CL, we save away
  the original time zone and use it on upsync
* In our decoding of Exchange time zone information, we default to
  local time when we can't find a time zone that matches the bias
  and DST information; we should really default to a time zone with
  the same bias, if one exists; we do that in this CL.
* Add/modify unit tests

Bug: 2703075
Change-Id: Id80c481ecc0eae980b2e91dae7f105f924cfca28
2010-05-25 11:46:44 -07:00
Makoto Onuki
32f8a49e01 Two new tests for the bottom half of ImapFolder.append().
They cover the cases:
- when OK response doesn't have APPENDUID.
- when APPEND fails.

Change-Id: I13a0fb8aaf2e1cbb5a1f055c9ce56e2891373ea0
2010-05-20 18:23:16 -07:00