From d8046e520a866b9948ee9ba47cf642b441ca8e23 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Thu, 6 Apr 2017 09:41:50 -0700 Subject: Update AOSP Dialer source from internal google3 repository at cl/152373142. Test: make, treehugger This CL updates the AOSP Dialer source with all the changes that have gone into the private google3 repository. This includes all the changes from cl/151342913 (3/27/2017) to cl/152373142 (4/06/2017). This goal of these drops is to keep the AOSP source in sync with the internal google3 repository. Currently these sync are done by hand with very minor modifications to the internal source code. See the Android.mk file for list of modifications. Our current goal is to do frequent drops (daily if possible) and eventually switched to an automated process. Change-Id: I2fbc88cf6867b90ac8b65f75e5e34468988c7217 --- java/com/android/dialer/oem/AndroidManifest.xml | 5 ++- .../android/dialer/oem/CequintCallerIdManager.java | 42 ++++++++++++++-------- java/com/android/dialer/oem/MotorolaUtils.java | 6 ++-- 3 files changed, 35 insertions(+), 18 deletions(-) (limited to 'java/com/android/dialer/oem') diff --git a/java/com/android/dialer/oem/AndroidManifest.xml b/java/com/android/dialer/oem/AndroidManifest.xml index 685bc3d20..9e0373ab4 100644 --- a/java/com/android/dialer/oem/AndroidManifest.xml +++ b/java/com/android/dialer/oem/AndroidManifest.xml @@ -13,6 +13,9 @@ limitations under the License. --> - + + + \ No newline at end of file diff --git a/java/com/android/dialer/oem/CequintCallerIdManager.java b/java/com/android/dialer/oem/CequintCallerIdManager.java index 094cc842d..c8e6010a3 100644 --- a/java/com/android/dialer/oem/CequintCallerIdManager.java +++ b/java/com/android/dialer/oem/CequintCallerIdManager.java @@ -22,6 +22,7 @@ import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; import android.os.Build.VERSION_CODES; +import android.support.annotation.AnyThread; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; @@ -57,6 +58,8 @@ public class CequintCallerIdManager { private static final Uri CONTENT_URI_FOR_INCALL = Uri.parse("content://" + PROVIDER_NAME + "/incalllookup"); + private static final String[] EMPTY_PROJECTION = new String[] {}; + // Column names in Cequint provider. private static final String CITY_NAME = "cid_pCityName"; private static final String STATE_NAME = "cid_pStateName"; @@ -72,9 +75,9 @@ public class CequintCallerIdManager { // TODO: Revisit it and maybe remove it if it's not necessary. private static final ConcurrentHashMap callLogCache = new ConcurrentHashMap<>(); - // Cache for incall lookup. Key is phone number + "i" for incoming call or "o" for outgoing call. - // TODO: Revisit it and maybe remove it if it's not necessary. - private static final ConcurrentHashMap incallCache = + private static final ConcurrentHashMap incallIncomingCallCache = + new ConcurrentHashMap<>(); + private static final ConcurrentHashMap incallOutgoingCallCache = new ConcurrentHashMap<>(); private static boolean hasRegisteredContentObserver; private static boolean hasAlreadyCheckedCequintCallerIdPackage; @@ -94,6 +97,7 @@ public class CequintCallerIdManager { } /** Check whether Cequint Caller Id provider package is available and enabled. */ + @AnyThread public static synchronized boolean isCequintCallerIdEnabled(@NonNull Context context) { if (!ConfigProviderBindings.get(context).getBoolean(CONFIG_CALLER_ID_ENABLED, true)) { return false; @@ -113,13 +117,13 @@ public class CequintCallerIdManager { } @WorkerThread + @Nullable public static CequintCallerIdContact getCequintCallerIdContact(Context context, String number) { Assert.isWorkerThread(); LogUtil.d( "CequintCallerIdManager.getCequintCallerIdContact", "number: %s", LogUtil.sanitizePhoneNumber(number)); - registerContentObserver(context); if (callLogCache.containsKey(number)) { return callLogCache.get(number); } @@ -136,6 +140,7 @@ public class CequintCallerIdManager { } @WorkerThread + @Nullable public static CequintCallerIdContact getCequintCallerIdContactForInCall( Context context, String number, String cnapName, boolean isIncoming) { Assert.isWorkerThread(); @@ -146,9 +151,10 @@ public class CequintCallerIdManager { LogUtil.sanitizePii(cnapName), isIncoming); registerContentObserver(context); - String key = number + (isIncoming ? "i" : "o"); - if (incallCache.containsKey(key)) { - return incallCache.get(key); + if (isIncoming && incallIncomingCallCache.containsKey(number)) { + return incallIncomingCallCache.get(number); + } else if (!isIncoming && incallOutgoingCallCache.containsKey(number)) { + return incallOutgoingCallCache.get(number); } int flag = 0; if (isIncoming) { @@ -161,7 +167,11 @@ public class CequintCallerIdManager { CequintCallerIdContact cequintCallerIdContact = lookup(context, CONTENT_URI_FOR_INCALL, number, flags); if (cequintCallerIdContact != null) { - incallCache.put(key, cequintCallerIdContact); + if (isIncoming) { + incallIncomingCallCache.put(number, cequintCallerIdContact); + } else { + incallOutgoingCallCache.put(number, cequintCallerIdContact); + } } return cequintCallerIdContact; } @@ -169,11 +179,13 @@ public class CequintCallerIdManager { @WorkerThread @Nullable private static CequintCallerIdContact lookup( - Context context, Uri uri, String number, String[] flags) { + Context context, Uri uri, @NonNull String number, String[] flags) { Assert.isWorkerThread(); + Assert.isNotNull(number); // Cequint is using custom arguments for content provider. See more details in b/35766080. - try (Cursor cursor = context.getContentResolver().query(uri, null, number, flags, null)) { + try (Cursor cursor = + context.getContentResolver().query(uri, EMPTY_PROJECTION, number, flags, null)) { if (cursor != null && cursor.moveToFirst()) { String city = getString(cursor, cursor.getColumnIndex(CITY_NAME)); String state = getString(cursor, cursor.getColumnIndex(STATE_NAME)); @@ -203,6 +215,9 @@ public class CequintCallerIdManager { LogUtil.d("CequintCallerIdManager.lookup", "No CequintCallerIdContact found"); return null; } + } catch (Exception e) { + LogUtil.e("CequintCallerIdManager.lookup", "exception on query", e); + return null; } } @@ -269,7 +284,7 @@ public class CequintCallerIdManager { return geoDescription; } - private static void registerContentObserver(Context context) { + private static synchronized void registerContentObserver(Context context) { if (hasRegisteredContentObserver) { return; } @@ -281,7 +296,6 @@ public class CequintCallerIdManager { } }; - context.getContentResolver().registerContentObserver(CONTENT_URI, true, contentObserver); context .getContentResolver() .registerContentObserver(CONTENT_URI_FOR_INCALL, true, contentObserver); @@ -289,8 +303,8 @@ public class CequintCallerIdManager { } private static void invalidateCache() { - callLogCache.clear(); - incallCache.clear(); + incallIncomingCallCache.clear(); + incallOutgoingCallCache.clear(); } private CequintCallerIdManager() {} diff --git a/java/com/android/dialer/oem/MotorolaUtils.java b/java/com/android/dialer/oem/MotorolaUtils.java index d0589103d..db2b8909a 100644 --- a/java/com/android/dialer/oem/MotorolaUtils.java +++ b/java/com/android/dialer/oem/MotorolaUtils.java @@ -41,10 +41,10 @@ public class MotorolaUtils { private static final String WIFI_CALL_PACKAGE_NAME = "com.motorola.sprintwfc"; // Feature flag indicates it's a HD call, currently this is only used by Motorola system build. - // TODO(b/35359461): Upstream and move it to android.provider.CallLog. - private static final int FEATURES_HD_CALL = 0x10000000; + // TODO(b/35359461): Use reference to android.provider.CallLog once it's in new SDK. + private static final int FEATURES_HD_CALL = 0x4; // Feature flag indicates it's a WiFi call, currently this is only used by Motorola system build. - private static final int FEATURES_WIFI = 0x80000000; + private static final int FEATURES_WIFI = 0x8; private static boolean hasCheckedSprintWifiCall; private static boolean supportSprintWifiCall; -- cgit v1.2.3