Alpha addresses get put in the same thread

For alpha addresses that weren't email addresses, the DB query would
use a native phone number comparison function. It would match any alpha
to any alpha. The first incoming alpha address would get added to the
canonical_addresses table and any and all subsequent alpha addresses
would match that first address. With this change, alpha addresses are
compared the same way email addresses are compared. Bug 3332079

Change-Id: Ib48ed1869e83c28f6e0723611b6d251ab7dd86b7
diff --git a/src/com/android/providers/telephony/MmsSmsProvider.java b/src/com/android/providers/telephony/MmsSmsProvider.java
index 31f5062..313b92e 100644
--- a/src/com/android/providers/telephony/MmsSmsProvider.java
+++ b/src/com/android/providers/telephony/MmsSmsProvider.java
@@ -453,12 +453,18 @@
      */
     private long getSingleAddressId(String address) {
         boolean isEmail = Mms.isEmailAddress(address);
+        boolean isPhoneNumber = Mms.isPhoneNumber(address);
+
+        // We lowercase all email addresses, but not addresses that aren't numbers, because
+        // that would incorrectly turn an address such as "My Vodafone" into "my vodafone"
+        // and the thread title would be incorrect when displayed in the UI.
         String refinedAddress = isEmail ? address.toLowerCase() : address;
+
         String selection = "address=?";
         String[] selectionArgs;
         long retVal = -1L;
 
-        if (isEmail) {
+        if (!isPhoneNumber) {
             selectionArgs = new String[] { refinedAddress };
         } else {
             selection += " OR " + String.format("PHONE_NUMBERS_EQUAL(address, ?, %d)",