summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFang Yunong <yunong@codeaurora.org>2015-10-22 10:31:56 +0800
committerLinux Build Service Account <lnxbuild@localhost>2016-08-24 08:18:47 -0600
commite84bdfd20e6977254ce2686275427cdd9c526d2b (patch)
treed53550040b91c1494c469cad7024b9f0e09abc2f
parent4298a8556f3a3825cddee86a7cbe852682316b81 (diff)
downloadpackages_apps_ContactsCommon-e84bdfd20e6977254ce2686275427cdd9c526d2b.tar.gz
packages_apps_ContactsCommon-e84bdfd20e6977254ce2686275427cdd9c526d2b.tar.bz2
packages_apps_ContactsCommon-e84bdfd20e6977254ce2686275427cdd9c526d2b.zip
ContactsProvider: Add support for operator name
Add operator name in dialer screen Add operator name in calllog Change-Id: I6edb5bda95cfa36a2949c8226865543303b8cfab CRs-Fixed: 1037633
-rw-r--r--res/values/donottranslate_config.xml2
-rwxr-xr-xsrc/com/android/contacts/common/MoreContactUtils.java45
2 files changed, 47 insertions, 0 deletions
diff --git a/res/values/donottranslate_config.xml b/res/values/donottranslate_config.xml
index 7d3c074c..c48169d7 100644
--- a/res/values/donottranslate_config.xml
+++ b/res/values/donottranslate_config.xml
@@ -91,4 +91,6 @@
<string name="pref_privacy_policy_key">pref_privacy_policy</string>
<string name="pref_terms_of_service_key">pref_terms_of_service</string>
+ <!-- configuration for set operator show in dialpad or calllog -->
+ <bool name="config_show_operator">false</bool>
</resources>
diff --git a/src/com/android/contacts/common/MoreContactUtils.java b/src/com/android/contacts/common/MoreContactUtils.java
index b4851996..db40fa71 100755
--- a/src/com/android/contacts/common/MoreContactUtils.java
+++ b/src/com/android/contacts/common/MoreContactUtils.java
@@ -39,6 +39,8 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.RawContacts;
import android.provider.Settings;
+import android.telecom.PhoneAccountHandle;
+import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.SubscriptionInfo;
@@ -237,6 +239,49 @@ public class MoreContactUtils {
return rect;
}
+ public static boolean shouldShowOperator(Context context) {
+ return context.getResources().getBoolean(R.bool.config_show_operator);
+ }
+
+ /**
+ * Get Network SPN name, e.g. China Unicom
+ */
+ public static String getNetworkSpnName(Context context, int subscription) {
+ TelephonyManager tm = (TelephonyManager)
+ context.getSystemService(Context.TELEPHONY_SERVICE);
+ String netSpnName = "";
+ if (tm != null) {
+ // Get active operator name.
+ netSpnName = tm.getNetworkOperatorName();
+ if (TextUtils.isEmpty(netSpnName)) {
+ // if could not get the operator name, use sim name instead of
+ List<SubscriptionInfo> subInfoList =
+ SubscriptionManager.from(context).getActiveSubscriptionInfoList();
+ if (subInfoList != null) {
+ for (int i = 0; i < subInfoList.size(); ++i) {
+ final SubscriptionInfo sir = subInfoList.get(i);
+ if (sir.getSubscriptionId() == subscription) {
+ netSpnName = (String)sir.getDisplayName();
+ break;
+ }
+ }
+ }
+ }
+ }
+ return toUpperCaseFirstOne(netSpnName);
+ }
+
+ private static String toUpperCaseFirstOne(String s) {
+ if (TextUtils.isEmpty(s)) {
+ return s;
+ }
+ if (Character.isUpperCase(s.charAt(0))) {
+ return s;
+ } else {
+ return (new StringBuilder()).append(Character.toUpperCase(s.charAt(0)))
+ .append(s.substring(1)).toString();
+ }
+ }
/**
* Returns a header view based on the R.layout.list_separator, where the
* containing {@link android.widget.TextView} is set using the given textResourceId.