Commit Graph

377 Commits

Author SHA1 Message Date
Paul Westbrook bb68c13afa Changes to support smaller email tombstone apk size
This reduces the tombstone down by 100K

A follow-on cl will remove the unused resources from the tombstone build

Bug: 17414014
Change-Id: I5d38811b17a5273ec726e750ab123e10e36cee04
2014-09-16 13:59:07 -07:00
Martin Hibdon 51c653646d Put debug screen back into settings
There is still work to be done here:
* The debug setting is not persisted in Exchange, so if
the exchange service is killed, when it restarts the logging
will not be active.
* Nothing in Exchange actually does any additional logging
if this logging is turned on.

Change-Id: Ic578e6956f70dd47fba9b2895385312f71c47abf
2014-08-28 11:53:51 -07:00
Martin Hibdon 1d8fd9c054 Add communication class for HostAuth
We want a separate class for communicating HostAuth objects
to and from IEmailService. The issue is that the HostAuth object
was being used for both to and from the database, and to and from
IEmailService. This is dangerous because The Email app may change
out of band with the Exchange app, and may need to change the
format of HostAuth. This bit us before when adding OAuth.
Now communication to IEmailService is done using HostAuthCompat.

Change-Id: I2fb8c2bd8158f58a7bb9bc3dc83a7936948c718c
2014-07-07 15:08:52 -07:00
Jay Shrauner 9adf186c5b Catch negative literal sizes in imap responses
Check for negative sizes for literals so that we don't crash attempting
to create a negative sized array.

Bug:15834346
Change-Id: I1fbd9b86c807f1e97100fbfe52ef402a337bf655
2014-06-23 14:55:30 -07:00
Tony Mantler 994c282d80 Fix OAuth when changing credentials from settings
b/15521401

Change-Id: I7909389943c8e3eefbef0699f1c7c9c338282ca5
2014-06-09 15:28:11 -07:00
Martin Hibdon b5713fb731 am 81f9a57a: Fix some STOPSHIP logging
* commit '81f9a57a655fe842ddd86b14afe75bcd575edb81':
  Fix some STOPSHIP logging
2014-05-05 20:19:12 +00:00
Martin Hibdon 81f9a57a65 Fix some STOPSHIP logging
b/14564870

Change-Id: I9365013eacde23178578b45f728713f80417bc7a
2014-05-05 13:04:19 -07:00
Tony Mantler 42a4dbbf93 Refactor addMailbox() a bit and clean up warnings
Change-Id: I8497f74ec61c380ae4e69487121c50933f568965
2014-04-18 14:28:28 -07:00
Martin Hibdon 2a7411b57b Fix an NPE in sendCommandInternal
b/13929234

Change-Id: I362682bde3c24123178e68811604f0180c853598
2014-04-09 11:22:52 -07:00
Martin Hibdon d58b490479 Fix a potential stack overflow error
b/13906567

Change-Id: I21be980d4b4878ada0df6d3af706fee55afb4f2b
2014-04-08 14:35:53 -07:00
Tony Mantler 38f9991634 Fix IMAP message upsync to include attachments.
b/13138456

Change-Id: If16b619a650c640a37cb4563750a6327a5e601e6
(cherry picked from commit 0c8696c2eb)
2014-03-27 21:23:32 +00:00
James Lemieux 0dffe3afd7 Keep on getting a couldn't sign-in notification
b/11551107

This is caused by ImapConnection.doLogin() only throwing
AuthenticationFailedExceptions and not other varieties of exceptions.

While fixing this bug, I discovered that the ConversationListFooterView
that is displayed in response to a authentication failure contains a
button called "Sign In" that didn't actually do anything. I made it
navigate to the incoming account settings fragment where the user is
free to change the relevant account credentials.

Change-Id: I2c772ecab18f3e57059eceeae01de08f1fdab4c2
2014-03-07 16:38:47 -08:00
Tony Mantler 76472ae40c Merge setup fragments under a single activity
Change-Id: I10cf8bb9f6bc1a26ea97ae664f0196ae9e9493b5
2014-02-26 13:47:41 -08:00
Martin Hibdon b94bfc31cd Remove some security violating logging
Change-Id: Icf53b132516be5f1b392fb9bd3a8970634212642
2014-02-14 15:36:38 -08:00
James Lemieux 1fa303478c Eliminate redundant methods in Address class
THIS DOES NOT CHANGE ANY EXISTING FUNCTIONALITY.

Address.pack() has been removed and all calls replaced with its synonym Address.toHeader().
Address.unpack() has been renamed to Address.fromHeader() to follow the new naming convention.

In days of yore, pack() and toHeader() used to do different things. Now they are identical and
thus one is superfluous. We have standardized on toHeader() and fromHeader().

Change-Id: Iac91c966eb6c1477f8dba0dd2ae01c84b359e539
2014-01-22 16:15:57 -08:00
Martin Hibdon 4e952d9cf4 Fix a privacy violating log
Change-Id: I0c49fde90e4c14e6751a927d0963533092fbef52
2014-01-08 09:30:16 -08:00
Martin Hibdon e8eb6e659b Make OAuth work
Now you can authenticate your account using oauth
for google hosted accounts (e.g. google.com, gmail.com)
The setup ui is still not up to spec.

Change-Id: Ib2826653550a823b4d1b8739c1e483746cccbc22
2014-01-03 14:05:46 -08:00
Martin Hibdon ff1ee36cb5 Close Imap connections when we are done using them
Also, clean up when we create and lose track of ImapStores.
Prior to this we were creating them often, and losing track of them,
which renders useless a lot of the complex logic in ImapStore devoted
to reusing connections.

Change-Id: I771d4e46d0c1cb9b605c43d9cbae6e52f5894745
2014-01-03 14:01:04 -08:00
Martin Hibdon 5de5354918 Update some error logging
Now it logs stack traces of exceptions, and does not use
exception.toString() as the format specifier, which can be
dangerous.

Change-Id: If841426067017c574c4aff88b8d8ae6b49ee867a
2014-01-03 08:54:34 -08:00
Tony Mantler 1644749d1b Merge "Clean up dead/weird code." into ub-mail-master 2013-12-09 18:22:08 +00:00
Jerry Xie 17d3a29c9d Get Email units to compile
Change-Id: I171a0e2421c5006d9862ad94f886932146547020
2013-12-05 11:11:21 -08:00
Tony Mantler 5ec2108cf0 Clean up dead/weird code.
Change-Id: I27da217fc919bee6804b12ee8ec5f5a78b1ee410
2013-11-22 10:36:09 -08:00
Martin Hibdon d482cbd54b Fix attachments in search results
b/11294681
We had some really broken logic about handling search
results.
In IMAP search, we would request, in a single pass,
FLAGS, ENVELOPE, STRUCTURE, and BODY_SANE. BODY_SANE means
the first N bytes of message content, whether it be from
the message text or attachments. This is different from how
sync works: In sync, we get FLAGS and ENVELOPE in one pass,
and in a later pass get STRUCTURE and first body part text
for each message.
If the total size of the message exceeded the maximum limit
for BODY_SANE, then we'd mark the message as partial, which
would cause us to create a dummy attachment in copyMessageToProvider().
This is a weird solution to the problem of POP messages not
being completely loaded, because in POP message body and
attachments can't be requested separately, so the dummy attachment
just signified that we needed to fetch more data.
This system fails completely on IMAP, because just fetching the
rest of the body will not get you the attachments.

But even if that code is disabled, attachments in search results
still didn't work properly. For reasons I don't yet understand,
if we requet both STRUCTURE and BODY_SANE at the same time, either
we don't received the full attachment metadata, or we ignore it, and
only use the attachments whose contents could actually fit in the
limit imposed by BODY_SANE. So attachments that didn't fit,
or didn't completely fit, would either be missing or corrupt
and unretriveable.

So, end result: It's not clear why we were trying to load
BODY_SANE all in one pass, unlike how it works for sync.
In fact, the way sync does it now makes a lot of sense: We
load FLAGS and ENVELOPE data (small) and put the in the DB
immediately so they can be displayed. In the second pass we
load the (potentially large) structure and message body. If this
is the right solution for sync, it's probably the right solution
for search. So now, that's what we do.

There is cleanup I'd like to do post MR1: Some code is duplicated
between sync and search that could be consolidated, but we're in
low risk mode now so I only changed search code.

Change-Id: I11475e290cda04b91f76d38ba952679e8e8964d5
2013-11-06 10:53:07 -08:00
Tony Mantler e3cf91af61 Set parentServerId for IMAP folders to prevent fixup code from resetting parentKey
b/11355523

Change-Id: Idbef28cdbbc0eac50552fabeb24e2ec49a6cd042
2013-10-23 14:14:21 -07:00
Tony Mantler 4aaf3f2e33 Don't bail out of downloading an attachment if the size is delcared as zero
b/11225306

Change-Id: If67401dd3e6b652b03fba2e71cfc82fdae80ccb2
2013-10-17 09:46:03 -07:00
Martin Hibdon 35cdca3fb4 Correct syntax for IMAP date range search
b/11183568
We were surrounding the data parameters with
double quotes. Apparently some servers do not
accept this, and they aren't present in the
imap spec.
However, we've been running with the quotes
for several months now, and it seems to work
on most servers. I'm afraid of changing this
right now, it might cause other servers to fail.
So now we'll try the query without quotes, and
if we get an exception, fall back to the old
style query with the quotes.

Change-Id: Ifb7b1a6dd4a9f7bb6b38bd1611c64e2bddb2e188
2013-10-13 21:44:52 -07:00
Martin Hibdon 529bdeaec1 Always close the connection after trying to load attachments
b/11081672

Change-Id: Ibe804713492b37f5579fb20a0da7292e82cb5341
2013-10-08 16:48:52 -07:00
Martin Hibdon 312aa85609 Handle it if an fetchPart has no content-encoding
b/10855399

Change-Id: Ic2a8b51d095fe44f180ba2f2171dc70a9df10a1d
2013-09-26 13:10:48 -07:00
Martin Hibdon 35957ffcf6 Correctly fix an outOfBounds error
b/10380970

Change-Id: I58a57c7a659bb92ba6b6dbf0cbb099d0d252cc37
2013-08-28 16:22:09 -07:00
Martin Hibdon b940ed8adf Fix an OutOfBoundsException
b/10380970
This could happen if the response to the POP3
RETR request did not contain a content length.

Change-Id: I99ad93ec71ba917e0f36bee204d7f8d05c79c5ff
2013-08-19 17:07:05 -07:00
Paul Westbrook ae29fb76f0 Fix problem in IMAP with non-roman locales
This is a partial cherry-pick of:
https://android-review.googlesource.com/#/c/57514/1

Change-Id: I1dea4d5bf0bd02fec2baf5763f5864c3eb32f744
2013-08-12 11:43:44 -07:00
Martin Hibdon fda9d945e7 Fix a couple of bugs in imap synching
b/10111339
b/10125810
The first problem was that the imap BEFORE clause
is exclusive, so messages on the date given in
BEFORE will not be sent. Now, on the sync for the
most recent messages, we will just not specify a
BEFORE clause, so we can always get the most recent
messages even if our clock drifts from the server.

The second is that some imap servers do not accept
time information on the query dates, and that causes
errors. The imap spec defines the BEFORE and SINCE
clauses to come with a <date> only, not a time,
and although it seems that at least some imap servers
handle that, it can't be expected to always work.

Change-Id: Ibf41c6f7600b9f9537bc6d13b59873ee36798e1e
2013-08-05 12:27:13 -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
Martin Hibdon 2503179606 Update IMAP sync method
Now it syncs using a date range query.

Change-Id: Ia520fbbe39521b1356acaf0fe764f9bdcc1aeb82
2013-07-24 17:57:07 -07:00
Scott Kennedy 1b8e0fa23f Clean up a bunch of warnings
Bug: 9565838
Change-Id: I5e95562bbf463f057cbcc4a9884427a774473b45
2013-06-25 15:34:32 -07:00
Paul Westbrook 5a3fe57f4e Fix logging crash
If the string contains a character that is intrepreted by the
string formatter, this would throw an exception

Change-Id: I60cccb539bf197fa555d8d1f0fa1bdca3e07114e
2013-06-06 17:20:52 -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
Andrew Sapperstein bc7cd75e9a Prevent duplicate inboxes after upgrade.
Previously, we were not properly handling the
case-insensitive INBOX mailbox type. We are now
upgrading properly. Fixes b/8701883.

Change-Id: I61be5159e23dc3e9578e577e33bc00a63f56b525
2013-05-29 18:10:59 -07:00
Yu Ping Hu 7c3f85885c Changes to support cleaving sync out of ExchangeService.
Change-Id: Idbfff4ddc8fca4829228d04816d40a4ab9639382
2013-05-15 15:04:59 -07:00
Yu Ping Hu 9a2686afa2 Improve POP sync.
- Set socket timeout as soon as you open it. This was how
  IMAP worked, so I just moved the call up one level. This
  should help one of the sync forever scenarios.
- Simplify the SQL query for getting a Mailbox.
- Try to load messages that failed to load last time.
- Always close the connection to the remote folder.
- Don't try to be too clever in fetching the body.
  This needs to be fixed later for attachements, but for
  now seems to work better and will let me get more testing.

Change-Id: I91b6a6f2a2846b34b1a0c50eb4eb37fc947389ce
2013-04-17 10:54:33 -07:00
Yu Ping Hu 17d5bbf768 Improve mailbox sync and load more.
- Update syncTime for IMAP and POP whenever we sync.
- Change load more to simply include the delta in the RPC
  rather than using the visibleLimit column.
- Add a query to get the message count for a Mailbox.
- Refactor code for updating totalCount and determining
  the new message count when syncing.
- Remove dead code from Mailbox.
- Remove uses of visibleLimit from code.

Note that visibleLimit and messageCount in Mailbox table are
no longer useful and will be removed in a later change.

Bug: 8579767
Bug: 8523146
Change-Id: Ieb67e3b6f1c82c3b21b972c5a1e557cd75dc21db
2013-04-11 21:06:08 +00:00
Paul Westbrook d402c890dc Fixed make POP and Imap more locale safe
Cherry-picks from:
https://android-review.googlesource.com/#/c/42334/
https://android-review.googlesource.com/#/c/42332/

Change-Id: I557c3d8c725cf6dc4f13f227dcec63864ab5db67
2013-04-05 13:57:51 -07:00
Jack Bates 4fd97a3050 Fix SMTP RFC violation for better interoperability
Space after colon violates RFC 5321 (and RFC 821): "Since it has been a common
source of errors, it is worth noting that spaces are not permitted on either
side of the colon following FROM in the MAIL command or TO in the RCPT command"

Change-Id: Ie5330bf2bd01cd8f734134dadd742cf16df70d7a
Signed-off-by: Jack Bates <jack@nottheoilrig.com>

cherry-pick of https://android-review.googlesource.com/#/c/32640/
2013-04-05 13:42:13 -07:00
Yu Ping Hu c5c9c1c69e Restore functionality for uploading new messages.
The code for syncing new messages from client to server
somehow never got moved from Email1 to Email2.

This change also includes minor cleanup on system mailbox
flags.

Bug: 8531552
Change-Id: I1f9396635ba14cb6e641d2bc1b506c6d702f6b2e
2013-04-03 09:32:35 -07:00
Paul Westbrook d1a87bc02d Fix IMAP sync with Arabic language
Email shouldn't rely on the the default locale.
See: http://developer.android.com/reference/java/util/Locale.html#default_locale

Bug: 7138507
Change-Id: Ia2c6eccc6dee011f4e7e7c663a0328d4fd76131b
2013-04-02 11:36:11 -07:00
Yu Ping Hu 2192bf01e0 Always create system folders during sync.
Change-Id: I8ff6eb4f65d4207d7a2768c5fd837fad8cd47269
2013-03-20 15:23:51 -07:00
Yu Ping Hu 9ae81e2af0 Move system folder string resources to emailcommon.
This permits us to move shared code for looking up system
folder names to emailcommon, which is also in this change.

Also renames emailcommon2 to emailcommon.

This is part of a multi-project submit with
I4a071a07c3e33aaa4ea404eb66a8db1eabc9ef0e and
I5746c0353783f9b29d52d6540472588c6542a6a2.

Bug: 8383232

Change-Id: I6c6eec4f1bcf2abd54c1ed05da1add8d894ee403
2013-03-19 19:45:52 -07:00
Yu Ping Hu 3e88d65aa8 Fix inboxes in POP for non-english.
Same as I27b422b4b9a3568c899beda41c96e61eb77c4ad3
but for POP.

Bug: 8393126
Change-Id: Ifa7ef3aa4080ec4c39309f988f041344fc4e8b54
2013-03-14 20:29:10 -07:00
Yu Ping Hu 5187e702d6 "Fix" Inboxes in non-English languages for IMAP.
Without this change, languages where the inbox is not named
"Inbox" will never initialize IMAP accounts correctly.

This change "works" because
LegacyConversions.inferMailboxTypeFromName matches against
server name. Obviously this code's bad and I should feel
bad, but for now this change at least makes the app usable
in other languages and leaves the code in the simplest state
for fixing later.

Bug: 8393126
Change-Id: I27b422b4b9a3568c899beda41c96e61eb77c4ad3
2013-03-15 02:01:22 +00:00
Marc Blank 5c52385838 Restore Imap1
* Restore Imap1 code
* Legacy users will use Imap1
* Existing Imap2 users will continue to use Imap2
* New accounts will be created in Imap1
* More to follow

Bug: 7203993

Change-Id: I8b86fcada59a854fd464d5269c94d00ebae85459
2012-09-21 08:29:09 -07:00