summaryrefslogtreecommitdiffstats
path: root/java/com/android/dialer/oem
diff options
context:
space:
mode:
authorTobias Thierer <tobiast@google.com>2017-06-09 14:16:05 +0000
committerTobias Thierer <tobiast@google.com>2017-06-09 14:16:05 +0000
commitcded3beaf28a703e1ef8f71bbc6836e6806c3736 (patch)
treec1b5e8199b5996fc848e7455d04126b9cdbb3c39 /java/com/android/dialer/oem
parentc67d658e7daa453fe9ad9fd1a37f81eaf2048c44 (diff)
downloadandroid_packages_apps_Dialer-cded3beaf28a703e1ef8f71bbc6836e6806c3736.tar.gz
android_packages_apps_Dialer-cded3beaf28a703e1ef8f71bbc6836e6806c3736.tar.bz2
android_packages_apps_Dialer-cded3beaf28a703e1ef8f71bbc6836e6806c3736.zip
Revert "Update AOSP Dialer source from internal google3 repository at cl/158012278. am: 91ce7d2a47"
This reverts commit c67d658e7daa453fe9ad9fd1a37f81eaf2048c44. Reason for revert: This CL broke the sailfish-userdebug_javac-all target on master. Change-Id: I9b54333a654c00154ca84f4ece84bea4f07cc19b
Diffstat (limited to 'java/com/android/dialer/oem')
-rw-r--r--java/com/android/dialer/oem/CequintCallerIdManager.java98
-rw-r--r--java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java4
-rw-r--r--java/com/android/dialer/oem/MotorolaUtils.java25
-rw-r--r--java/com/android/dialer/oem/res/values-mcc310-mnc000/motorola_config.xml17
-rw-r--r--java/com/android/dialer/oem/res/values-mcc310-mnc120/motorola_config.xml17
-rw-r--r--java/com/android/dialer/oem/res/values-mcc311-mnc490/motorola_config.xml17
-rw-r--r--java/com/android/dialer/oem/res/values-mcc311-mnc870/motorola_config.xml17
-rw-r--r--java/com/android/dialer/oem/res/values-mcc312-mnc530/motorola_config.xml17
-rw-r--r--java/com/android/dialer/oem/res/values-mcc316-mnc010/motorola_config.xml17
-rw-r--r--java/com/android/dialer/oem/res/values/motorola_config.xml19
10 files changed, 83 insertions, 165 deletions
diff --git a/java/com/android/dialer/oem/CequintCallerIdManager.java b/java/com/android/dialer/oem/CequintCallerIdManager.java
index 806d553eb..095ee4e66 100644
--- a/java/com/android/dialer/oem/CequintCallerIdManager.java
+++ b/java/com/android/dialer/oem/CequintCallerIdManager.java
@@ -18,6 +18,7 @@ package com.android.dialer.oem;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build.VERSION_CODES;
@@ -30,6 +31,7 @@ import android.text.TextUtils;
import com.android.dialer.common.Assert;
import com.android.dialer.common.ConfigProviderBindings;
import com.android.dialer.common.LogUtil;
+import com.android.dialer.util.PermissionsUtil;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -71,12 +73,17 @@ public class CequintCallerIdManager {
private static final String IMAGE = "cid_pLogo";
private static final String DISPLAY_NAME = "cid_pDisplayName";
+ // TODO: Revisit it and maybe remove it if it's not necessary.
+ private static final ConcurrentHashMap<String, CequintCallerIdContact> callLogCache =
+ new ConcurrentHashMap<>();
+ private static final ConcurrentHashMap<String, CequintCallerIdContact> incallIncomingCallCache =
+ new ConcurrentHashMap<>();
+ private static final ConcurrentHashMap<String, CequintCallerIdContact> incallOutgoingCallCache =
+ new ConcurrentHashMap<>();
+ private static boolean hasRegisteredContentObserver;
private static boolean hasAlreadyCheckedCequintCallerIdPackage;
private static boolean isCequintCallerIdEnabled;
- // TODO: Revisit it and maybe remove it if it's not necessary.
- private final ConcurrentHashMap<String, CequintCallerIdContact> callLogCache;
-
/** Cequint caller id contact information. */
public static class CequintCallerIdContact {
public final String name;
@@ -110,8 +117,27 @@ public class CequintCallerIdManager {
return isCequintCallerIdEnabled;
}
- public static CequintCallerIdManager createInstanceForCallLog() {
- return new CequintCallerIdManager();
+ @WorkerThread
+ @Nullable
+ public static CequintCallerIdContact getCequintCallerIdContact(Context context, String number) {
+ Assert.isWorkerThread();
+ LogUtil.d(
+ "CequintCallerIdManager.getCequintCallerIdContact",
+ "number: %s",
+ LogUtil.sanitizePhoneNumber(number));
+ if (callLogCache.containsKey(number)) {
+ return callLogCache.get(number);
+ }
+ CequintCallerIdContact cequintCallerIdContact =
+ lookup(
+ context,
+ CONTENT_URI,
+ PhoneNumberUtils.stripSeparators(number),
+ new String[] {"system"});
+ if (cequintCallerIdContact != null) {
+ callLogCache.put(number, cequintCallerIdContact);
+ }
+ return cequintCallerIdContact;
}
@WorkerThread
@@ -125,6 +151,12 @@ public class CequintCallerIdManager {
LogUtil.sanitizePhoneNumber(number),
LogUtil.sanitizePii(cnapName),
isIncoming);
+ registerContentObserver(context);
+ if (isIncoming && incallIncomingCallCache.containsKey(number)) {
+ return incallIncomingCallCache.get(number);
+ } else if (!isIncoming && incallOutgoingCallCache.containsKey(number)) {
+ return incallOutgoingCallCache.get(number);
+ }
int flag = 0;
if (isIncoming) {
flag |= CALLER_ID_LOOKUP_INCOMING_CALL;
@@ -133,28 +165,14 @@ public class CequintCallerIdManager {
flag |= CALLER_ID_LOOKUP_USER_PROVIDED_CID;
}
String[] flags = {cnapName, String.valueOf(flag)};
- return lookup(context, CONTENT_URI_FOR_INCALL, number, flags);
- }
-
- @WorkerThread
- @Nullable
- public CequintCallerIdContact getCequintCallerIdContact(Context context, String number) {
- Assert.isWorkerThread();
- LogUtil.d(
- "CequintCallerIdManager.getCequintCallerIdContact",
- "number: %s",
- LogUtil.sanitizePhoneNumber(number));
- if (callLogCache.containsKey(number)) {
- return callLogCache.get(number);
- }
CequintCallerIdContact cequintCallerIdContact =
- lookup(
- context,
- CONTENT_URI,
- PhoneNumberUtils.stripSeparators(number),
- new String[] {"system"});
+ lookup(context, CONTENT_URI_FOR_INCALL, number, flags);
if (cequintCallerIdContact != null) {
- callLogCache.put(number, cequintCallerIdContact);
+ if (isIncoming) {
+ incallIncomingCallCache.put(number, cequintCallerIdContact);
+ } else {
+ incallOutgoingCallCache.put(number, cequintCallerIdContact);
+ }
}
return cequintCallerIdContact;
}
@@ -267,7 +285,33 @@ public class CequintCallerIdManager {
return geoDescription;
}
- private CequintCallerIdManager() {
- callLogCache = new ConcurrentHashMap<>();
+ private static synchronized void registerContentObserver(Context context) {
+ if (!PermissionsUtil.hasCequintPermissions(context)) {
+ LogUtil.i("CequintCallerIdManager.registerContentObserver", "no cequint permissions");
+ return;
+ }
+
+ if (hasRegisteredContentObserver) {
+ return;
+ }
+ ContentObserver contentObserver =
+ new ContentObserver(null) {
+ @Override
+ public void onChange(boolean selfChange) {
+ invalidateCache();
+ }
+ };
+
+ context
+ .getContentResolver()
+ .registerContentObserver(CONTENT_URI_FOR_INCALL, true, contentObserver);
+ hasRegisteredContentObserver = true;
+ }
+
+ private static void invalidateCache() {
+ incallIncomingCallCache.clear();
+ incallOutgoingCallCache.clear();
}
+
+ private CequintCallerIdManager() {}
}
diff --git a/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java b/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java
index 79abff08e..9cf145b7a 100644
--- a/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java
+++ b/java/com/android/dialer/oem/MotorolaHiddenMenuKeySequence.java
@@ -67,7 +67,9 @@ public class MotorolaHiddenMenuKeySequence {
}
private MotorolaHiddenMenuKeySequence(Context context) {
- featureHiddenMenuEnabled = MotorolaUtils.isSupportingHiddenMenu(context);
+ featureHiddenMenuEnabled =
+ MotorolaUtils.isSpnMatched(context)
+ && context.getResources().getBoolean(R.bool.motorola_feature_hidden_menu);
// In case we do have a SPN from resource we need to match from service; otherwise we are
// free to go
if (featureHiddenMenuEnabled) {
diff --git a/java/com/android/dialer/oem/MotorolaUtils.java b/java/com/android/dialer/oem/MotorolaUtils.java
index 2c91e60ab..db2b8909a 100644
--- a/java/com/android/dialer/oem/MotorolaUtils.java
+++ b/java/com/android/dialer/oem/MotorolaUtils.java
@@ -19,10 +19,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.telephony.TelephonyManager;
import com.android.dialer.common.ConfigProviderBindings;
-import com.android.dialer.common.LogUtil;
import com.android.dialer.common.PackageUtils;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
/** Util class for Motorola OEM devices. */
public class MotorolaUtils {
@@ -42,8 +39,6 @@ public class MotorolaUtils {
// This is used to check if a Motorola device supports WiFi call feature, by checking if a certain
// package is enabled.
private static final String WIFI_CALL_PACKAGE_NAME = "com.motorola.sprintwfc";
- // Thi is used to check if a Motorola device supports hidden menu feature.
- private static final String HIDDEN_MENU_FEATURE = "com.motorola.software.sprint.hidden_menu";
// Feature flag indicates it's a HD call, currently this is only used by Motorola system build.
// TODO(b/35359461): Use reference to android.provider.CallLog once it's in new SDK.
@@ -69,10 +64,6 @@ public class MotorolaUtils {
}
}
- static boolean isSupportingHiddenMenu(Context context) {
- return context.getPackageManager().hasSystemFeature(HIDDEN_MENU_FEATURE);
- }
-
public static boolean shouldBlinkHdIconWhenConnectingCall(Context context) {
return ConfigProviderBindings.get(context)
.getBoolean(CONFIG_HD_CODEC_BLINKING_ICON_WHEN_CONNECTING_CALL_ENABLED, true)
@@ -111,22 +102,6 @@ public class MotorolaUtils {
return MotorolaHiddenMenuKeySequence.handleCharSequence(context, input);
}
- public static boolean isWifiCallingAvailable(Context context) {
- if (!isSupportingSprintWifiCall(context)) {
- return false;
- }
- TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
- try {
- Method method = TelephonyManager.class.getMethod("isWifiCallingAvailable");
- boolean isWifiCallingAvailable = (boolean) method.invoke(telephonyManager);
- LogUtil.d("MotorolaUtils.isWifiCallingAvailable", "%b", isWifiCallingAvailable);
- return isWifiCallingAvailable;
- } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
- LogUtil.e("MotorolaUtils.isWifiCallingAvailable", "", e);
- }
- return false;
- }
-
private static boolean isSupportingSprintHdCodec(Context context) {
return isSpnMatched(context)
&& context.getResources().getBoolean(R.bool.motorola_sprint_hd_codec)
diff --git a/java/com/android/dialer/oem/res/values-mcc310-mnc000/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc310-mnc000/motorola_config.xml
index ac3397520..7f63bee75 100644
--- a/java/com/android/dialer/oem/res/values-mcc310-mnc000/motorola_config.xml
+++ b/java/com/android/dialer/oem/res/values-mcc310-mnc000/motorola_config.xml
@@ -1,21 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
<resources>
<bool name="motorola_sprint_hd_codec">true</bool>
+ <bool name="motorola_feature_hidden_menu">true</bool>
<string name="motorola_enabled_spn">Sprint</string>
</resources> \ No newline at end of file
diff --git a/java/com/android/dialer/oem/res/values-mcc310-mnc120/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc310-mnc120/motorola_config.xml
index c5cb0d1f7..39b72cdd1 100644
--- a/java/com/android/dialer/oem/res/values-mcc310-mnc120/motorola_config.xml
+++ b/java/com/android/dialer/oem/res/values-mcc310-mnc120/motorola_config.xml
@@ -1,20 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
<resources>
<bool name="motorola_sprint_hd_codec">true</bool>
+ <bool name="motorola_feature_hidden_menu">true</bool>
</resources> \ No newline at end of file
diff --git a/java/com/android/dialer/oem/res/values-mcc311-mnc490/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc311-mnc490/motorola_config.xml
index c5cb0d1f7..39b72cdd1 100644
--- a/java/com/android/dialer/oem/res/values-mcc311-mnc490/motorola_config.xml
+++ b/java/com/android/dialer/oem/res/values-mcc311-mnc490/motorola_config.xml
@@ -1,20 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
<resources>
<bool name="motorola_sprint_hd_codec">true</bool>
+ <bool name="motorola_feature_hidden_menu">true</bool>
</resources> \ No newline at end of file
diff --git a/java/com/android/dialer/oem/res/values-mcc311-mnc870/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc311-mnc870/motorola_config.xml
index c5cb0d1f7..39b72cdd1 100644
--- a/java/com/android/dialer/oem/res/values-mcc311-mnc870/motorola_config.xml
+++ b/java/com/android/dialer/oem/res/values-mcc311-mnc870/motorola_config.xml
@@ -1,20 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
<resources>
<bool name="motorola_sprint_hd_codec">true</bool>
+ <bool name="motorola_feature_hidden_menu">true</bool>
</resources> \ No newline at end of file
diff --git a/java/com/android/dialer/oem/res/values-mcc312-mnc530/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc312-mnc530/motorola_config.xml
index c5cb0d1f7..39b72cdd1 100644
--- a/java/com/android/dialer/oem/res/values-mcc312-mnc530/motorola_config.xml
+++ b/java/com/android/dialer/oem/res/values-mcc312-mnc530/motorola_config.xml
@@ -1,20 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
<resources>
<bool name="motorola_sprint_hd_codec">true</bool>
+ <bool name="motorola_feature_hidden_menu">true</bool>
</resources> \ No newline at end of file
diff --git a/java/com/android/dialer/oem/res/values-mcc316-mnc010/motorola_config.xml b/java/com/android/dialer/oem/res/values-mcc316-mnc010/motorola_config.xml
index c5cb0d1f7..39b72cdd1 100644
--- a/java/com/android/dialer/oem/res/values-mcc316-mnc010/motorola_config.xml
+++ b/java/com/android/dialer/oem/res/values-mcc316-mnc010/motorola_config.xml
@@ -1,20 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
<resources>
<bool name="motorola_sprint_hd_codec">true</bool>
+ <bool name="motorola_feature_hidden_menu">true</bool>
</resources> \ No newline at end of file
diff --git a/java/com/android/dialer/oem/res/values/motorola_config.xml b/java/com/android/dialer/oem/res/values/motorola_config.xml
index 46e7a16b6..f875d573d 100644
--- a/java/com/android/dialer/oem/res/values/motorola_config.xml
+++ b/java/com/android/dialer/oem/res/values/motorola_config.xml
@@ -1,25 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
<resources>
<!-- Flag to control if HD codec is supported by Sprint. -->
<bool name="motorola_sprint_hd_codec">false</bool>
<!-- Hidden menu configuration for Motorola. -->
+ <!-- Flag to control if the Hidden Menu sequence will be supported by Sprint. -->
+ <bool name="motorola_feature_hidden_menu">false</bool>
+
<!-- This defines the specific key seuquence that will be catched in the SpecialCharSequenceMgr
such as, ##OMADM# -->
<string-array name="motorola_hidden_menu_key_sequence">