diff options
author | Makoto Onuki <omakoto@google.com> | 2014-07-08 17:56:03 -0700 |
---|---|---|
committer | Makoto Onuki <omakoto@google.com> | 2014-07-10 11:22:47 -0700 |
commit | 76855c20de037a38b02716642cd27be674772f2d (patch) | |
tree | 31455880d2abf7a3ea271c468f6f68f9c7f7907e /InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java | |
parent | 05d1440049e389568a9357a8b59bdfff05f26375 (diff) |
Use enterprise caller-id in incall.
- Use PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI for caller-id.
- Removed a bunch of unused code.
- Renamed fields that will have different semantics. e.g. contactId now will be
0 and lookupUri null for corp contacts.
- Simplify the sip caller-id lookup. The regular caller-id lookup can also
do SIP. The original code (http://ag/70555) was written before CP2 supported
it (http://ag/147367). This needs QAing.
- Instead of passing around a contact-id to later load a contact picture,
use the picture URI returned from the API.
Bug 15779911
Change-Id: Ia755b9079d03d9236f824c2f1102a6fa902b2097
Diffstat (limited to 'InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java | 111 |
1 files changed, 24 insertions, 87 deletions
diff --git a/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java b/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java index 4a2b4fbf0..fd95458c8 100644 --- a/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java +++ b/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java @@ -24,8 +24,7 @@ import android.net.Uri; import android.os.Handler; import android.os.Looper; import android.os.Message; -import android.provider.ContactsContract.CommonDataKinds.SipAddress; -import android.provider.ContactsContract.Data; +import android.provider.ContactsContract; import android.provider.ContactsContract.PhoneLookup; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; @@ -33,6 +32,7 @@ import android.text.TextUtils; import com.android.contacts.common.util.PhoneNumberHelper; import com.android.contacts.common.util.TelephonyManagerUtils; +import java.util.Arrays; import java.util.Locale; /** @@ -95,6 +95,20 @@ public class CallerInfoAsyncQuery { */ private class CallerInfoAsyncQueryHandler extends AsyncQueryHandler { + @Override + public void startQuery(int token, Object cookie, Uri uri, String[] projection, + String selection, String[] selectionArgs, String orderBy) { + if (DBG) { + // Show stack trace with the arguments. + android.util.Log.d(LOG_TAG, "InCall: startQuery: url=" + uri + + " projection=[" + Arrays.toString(projection) + "]" + + " selection=" + selection + " " + + " args=[" + Arrays.toString(selectionArgs) + "]", + new RuntimeException("STACKTRACE")); + } + super.startQuery(token, cookie, uri, projection, selection, selectionArgs, orderBy); + } + /** * The information relevant to each CallerInfo query. Each query may have multiple * listeners, so each AsyncCursorInfo is associated with 2 or more CookieWrapper @@ -303,29 +317,6 @@ public class CallerInfoAsyncQuery { private CallerInfoAsyncQuery() { } - - /** - * Factory method to start query with a Uri query spec - */ - public static CallerInfoAsyncQuery startQuery(int token, Context context, Uri contactRef, - OnQueryCompleteListener listener, Object cookie) { - - CallerInfoAsyncQuery c = new CallerInfoAsyncQuery(); - c.allocate(context, contactRef); - - Log.d(LOG_TAG, "starting query for URI: " + contactRef + " handler: " + c.toString()); - - //create cookieWrapper, start query - CookieWrapper cw = new CookieWrapper(); - cw.listener = listener; - cw.cookie = cookie; - cw.event = EVENT_NEW_QUERY; - - c.mHandler.startQuery(token, cw, contactRef, null, null, null, null); - - return c; - } - /** * Factory method to start the query based on a number. * @@ -340,56 +331,19 @@ public class CallerInfoAsyncQuery { public static CallerInfoAsyncQuery startQuery(int token, Context context, String number, OnQueryCompleteListener listener, Object cookie) { Log.d(LOG_TAG, "##### CallerInfoAsyncQuery startQuery()... #####"); - Log.d(LOG_TAG, "- number: " + /* number */"xxxxxxx"); + Log.d(LOG_TAG, "- number: " + number); Log.d(LOG_TAG, "- cookie: " + cookie); // Construct the URI object and query params, and start the query. - Uri contactRef; - String selection; - String[] selectionArgs; - - if (PhoneNumberHelper.isUriNumber(number)) { - // "number" is really a SIP address. - Log.d(LOG_TAG, " - Treating number as a SIP address: " + /* number */"xxxxxxx"); - - // We look up SIP addresses directly in the Data table: - contactRef = Data.CONTENT_URI; - - // Note Data.DATA1 and SipAddress.SIP_ADDRESS are equivalent. - // - // Also note we use "upper(data1)" in the WHERE clause, and - // uppercase the incoming SIP address, in order to do a - // case-insensitive match. - // - // TODO: need to confirm that the use of upper() doesn't - // prevent us from using the index! (Linear scan of the whole - // contacts DB can be very slow.) - // - // TODO: May also need to normalize by adding "sip:" as a - // prefix, if we start storing SIP addresses that way in the - // database. - - selection = "upper(" + Data.DATA1 + ")=?" - + " AND " - + Data.MIMETYPE + "='" + SipAddress.CONTENT_ITEM_TYPE + "'"; - selectionArgs = new String[] { number.toUpperCase() }; - - } else { - // "number" is a regular phone number. Use the PhoneLookup table: - contactRef = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number)); - selection = null; - selectionArgs = null; - } + final Uri contactRef = PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI.buildUpon() + .appendPath(number) + .appendQueryParameter(PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, + String.valueOf(PhoneNumberHelper.isUriNumber(number))) + .build(); if (DBG) { Log.d(LOG_TAG, "==> contactRef: " + sanitizeUriToString(contactRef)); - Log.d(LOG_TAG, "==> selection: " + selection); - if (selectionArgs != null) { - for (int i = 0; i < selectionArgs.length; i++) { - Log.d(LOG_TAG, "==> selectionArgs[" + i + "]: " + selectionArgs[i]); - } - } } CallerInfoAsyncQuery c = new CallerInfoAsyncQuery(); @@ -414,30 +368,13 @@ public class CallerInfoAsyncQuery { cw, // cookie contactRef, // uri null, // projection - selection, // selection - selectionArgs, // selectionArgs + null, // selection + null, // selectionArgs null); // orderBy return c; } /** - * Method to add listeners to a currently running query - */ - public void addQueryListener(int token, OnQueryCompleteListener listener, Object cookie) { - - Log.d(this, "adding listener to query: " + sanitizeUriToString(mHandler.mQueryUri) + - " handler: " + mHandler.toString()); - - //create cookieWrapper, add query request to end of queue. - CookieWrapper cw = new CookieWrapper(); - cw.listener = listener; - cw.cookie = cookie; - cw.event = EVENT_ADD_LISTENER; - - mHandler.startQuery(token, cw, null, null, null, null, null); - } - - /** * Method to create a new CallerInfoAsyncQueryHandler object, ensuring correct * state of context and uri. */ |