Add an adapter to bridge ECC data and emergency dialer UI
- EccInfoHelper is not instanciated in EmergencyDialer yet, it's
waiting for a proper IsoToEccRepository to supply EccInfo.
- After get current country's EccInfo list from EccInfoHelper, apply
the EccInfo list to EccShortcutAdapter.
- With EccShortcutAdapter, each EccInfo will show as a shortcut button
in EmergencyDialer. The types of an EccInfo will be combined together
to generate the description string for the shortcut button.
- Add strings for ECC types.
- Add police and fire icon resources.
Test: Manually
Bug: 112168722
Bug: 111622312
Bug: 80406570
Change-Id: I1f15bb81598f21364309f2a19ad8d2f14a195d42
Merged-In: I1f15bb81598f21364309f2a19ad8d2f14a195d42
diff --git a/res/drawable-hdpi/ic_fire_white_24.png b/res/drawable-hdpi/ic_fire_white_24.png
new file mode 100644
index 0000000..0c0c6ed
--- /dev/null
+++ b/res/drawable-hdpi/ic_fire_white_24.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_shield_white_24.png b/res/drawable-hdpi/ic_shield_white_24.png
new file mode 100644
index 0000000..bf23794
--- /dev/null
+++ b/res/drawable-hdpi/ic_shield_white_24.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_fire_white_24.png b/res/drawable-mdpi/ic_fire_white_24.png
new file mode 100644
index 0000000..de8fda9
--- /dev/null
+++ b/res/drawable-mdpi/ic_fire_white_24.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_shield_white_24.png b/res/drawable-mdpi/ic_shield_white_24.png
new file mode 100644
index 0000000..9a5d958
--- /dev/null
+++ b/res/drawable-mdpi/ic_shield_white_24.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_fire_white_24.png b/res/drawable-xhdpi/ic_fire_white_24.png
new file mode 100644
index 0000000..750072e
--- /dev/null
+++ b/res/drawable-xhdpi/ic_fire_white_24.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_shield_white_24.png b/res/drawable-xhdpi/ic_shield_white_24.png
new file mode 100644
index 0000000..e886233
--- /dev/null
+++ b/res/drawable-xhdpi/ic_shield_white_24.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_fire_white_24.png b/res/drawable-xxhdpi/ic_fire_white_24.png
new file mode 100644
index 0000000..37c6ecd
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_fire_white_24.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_shield_white_24.png b/res/drawable-xxhdpi/ic_shield_white_24.png
new file mode 100644
index 0000000..1621836
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_shield_white_24.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_fire_white_24.png b/res/drawable-xxxhdpi/ic_fire_white_24.png
new file mode 100644
index 0000000..fb1d630
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_fire_white_24.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_shield_white_24.png b/res/drawable-xxxhdpi/ic_shield_white_24.png
new file mode 100644
index 0000000..8b9f129
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_shield_white_24.png
Binary files differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 399fd5e..88873b3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1157,6 +1157,19 @@
emergency calling is not currently available. -->
<string name="dial_emergency_calling_not_available">Emergency calling not available</string>
+ <!-- Text for description of police calling type -->
+ <string name="police_type_description">Police</string>
+ <!-- Text for description of ambulance calling type -->
+ <string name="ambulance_type_description">Ambulance</string>
+ <!-- Text for description of fire calling type -->
+ <string name="fire_type_description">Fire</string>
+
+ <!-- Format for concatenating multiple emergency type descriptions. The separator may differ in
+ different locales, for example arabic comma "،" is used in some countries. Some languages
+ may use full-width separator without leading or trailing spaces, eg. Ideographic comma "、"
+ in Chinese and Japanese. -->
+ <string name="description_concat_format">%1$s, %2$s</string>
+
<!-- Displayed in the text entry box in the dialer when in landscape mode to guide the user
to dial using the physical keyboard -->
<string name="dialerKeyboardHintText">Use keyboard to dial</string>
diff --git a/src/com/android/phone/EccShortcutAdapter.java b/src/com/android/phone/EccShortcutAdapter.java
new file mode 100644
index 0000000..bd7252c
--- /dev/null
+++ b/src/com/android/phone/EccShortcutAdapter.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+package com.android.phone;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.content.Context;
+import android.text.TextUtils;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+
+import com.android.phone.ecc.CountryEccInfo;
+import com.android.phone.ecc.EccInfo;
+
+import com.google.common.collect.LinkedListMultimap;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An abstract adapter between ECC data and the view contains ECC shortcuts.
+ * This adapter will convert given {@link CountryEccInfo} to number string, description string and
+ * icon resource id for each {@link EccInfo}.
+ * The subclass should implements {@link #inflateView} to provide the view for an ECC data, when the
+ * view container calls {@link #getView}.
+ */
+public abstract class EccShortcutAdapter extends BaseAdapter {
+ // GSM default emergency number, used when country's fallback ECC(112 or 911) not available.
+ private static final String FALLBACK_EMERGENCY_NUMBER = "112";
+
+ private List<EccDisplayMaterial> mEccDisplayMaterialList;
+
+ private CharSequence mPoliceDescription;
+ private CharSequence mAmbulanceDescription;
+ private CharSequence mFireDescription;
+
+ private static class EccDisplayMaterial {
+ public CharSequence number = null;
+ public int iconRes = 0;
+ public CharSequence description = null;
+ }
+
+ public EccShortcutAdapter(@NonNull Context context) {
+ mPoliceDescription = context.getText(R.string.police_type_description);
+ mAmbulanceDescription = context.getText(R.string.ambulance_type_description);
+ mFireDescription = context.getText(R.string.fire_type_description);
+
+ mEccDisplayMaterialList = new ArrayList<>();
+ }
+
+ @Override
+ public int getCount() {
+ return mEccDisplayMaterialList.size();
+ }
+
+ @Override
+ public EccDisplayMaterial getItem(int position) {
+ return mEccDisplayMaterialList.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ EccDisplayMaterial material = getItem(position);
+ return inflateView(convertView, parent, material.number, material.description,
+ material.iconRes);
+ }
+
+ /**
+ * Get a View that display the given ECC data: number, description and iconRes.
+ *
+ * @param convertView The old view to reuse, if possible. Note: You should check that this view
+ * is non-null and of an appropriate type before using. If it is not possible
+ * to convert this view to display the correct data, this method can create a
+ * new view. Heterogeneous lists can specify their number of view types, so
+ * that this View is always of the right type (see {@link
+ * BaseAdapter#getViewTypeCount()} and {@link
+ * BaseAdapter#getItemViewType(int)}).
+ * @param parent The parent that this view will eventually be attached to.
+ * @param number The number of the ECC shortcut to display in the view.
+ * @param description The description of the ECC shortcut to display in the view.
+ * @param iconRes The icon resource ID represent for the ECC shortcut.
+ * @return A View corresponding to the data at the specified position.
+ */
+ public abstract View inflateView(View convertView, ViewGroup parent, CharSequence number,
+ CharSequence description, int iconRes);
+
+ /**
+ * Update country ECC info. This method converts given country ECC info to ECC data that could
+ * be display by the short container View.
+ *
+ * @param context The context used to access resources.
+ * @param countryEccInfo Updated country ECC info.
+ */
+ public void updateCountryEccInfo(@NonNull Context context, CountryEccInfo countryEccInfo) {
+ List<EccDisplayMaterial> displayMaterials = new ArrayList<>();
+
+ final EccInfo.Type[] orderedMustHaveTypes =
+ { EccInfo.Type.POLICE, EccInfo.Type.AMBULANCE, EccInfo.Type.FIRE };
+
+ String fallback = null;
+ EccInfo[] eccInfoList = null;
+ if (countryEccInfo != null) {
+ fallback = countryEccInfo.getFallbackEcc();
+ eccInfoList = countryEccInfo.getEccInfoList();
+ }
+ if (TextUtils.isEmpty(fallback)) {
+ fallback = FALLBACK_EMERGENCY_NUMBER;
+ }
+
+ // Finding matched ECC for each must have types.
+ // Using LinkedListMultimap to prevent duplicated keys.
+ // LinkedListMultimap also preserve the insertion order of keys (ECC number) and values
+ // (matched types of the ECC number), which follows the order in orderedMustHaveTypes.
+ LinkedListMultimap<String, EccInfo.Type> eccList = LinkedListMultimap.create();
+ for (EccInfo.Type type : orderedMustHaveTypes) {
+ String number = null;
+ if (eccInfoList != null) {
+ number = pickEccNumberForType(type, eccInfoList);
+ }
+ if (number == null) {
+ number = fallback;
+ }
+ // append type for exist number, otherwise insert a new entry.
+ eccList.put(number, type);
+ }
+
+ // prepare display material for picked ECC
+ for (String number : eccList.keySet()) {
+ EccDisplayMaterial material = prepareDisplayMaterialForEccInfo(context,
+ new EccInfo(number, eccList.asMap().get(number)));
+ if (material != null) {
+ displayMaterials.add(material);
+ }
+ }
+
+ mEccDisplayMaterialList = displayMaterials;
+ notifyDataSetChanged();
+ }
+
+ private @Nullable String pickEccNumberForType(@NonNull EccInfo.Type targetType,
+ @NonNull EccInfo[] eccInfoList) {
+ EccInfo pickedEccInfo = null;
+ for (EccInfo eccInfo : eccInfoList) {
+ if (eccInfo.containsType(targetType)) {
+ // An ECC is more suitable for a type if the ECC has fewer other types.
+ if (pickedEccInfo == null
+ || eccInfo.getTypesCount() < pickedEccInfo.getTypesCount()) {
+ pickedEccInfo = eccInfo;
+ }
+ }
+ }
+ if (pickedEccInfo != null) {
+ return pickedEccInfo.getNumber();
+ }
+ return null;
+ }
+
+ private @Nullable EccDisplayMaterial prepareDisplayMaterialForEccInfo(@NonNull Context context,
+ @NonNull EccInfo eccInfo) {
+ EccDisplayMaterial material = new EccDisplayMaterial();
+ material.number = eccInfo.getNumber();
+ EccInfo.Type[] types = eccInfo.getTypes();
+ for (EccInfo.Type type : types) {
+ CharSequence description;
+ switch (type) {
+ case POLICE:
+ description = mPoliceDescription;
+ material.iconRes = R.drawable.ic_shield_white_24;
+ break;
+ case AMBULANCE:
+ description = mAmbulanceDescription;
+ material.iconRes = R.drawable.ic_emergency_number_24;
+ break;
+ case FIRE:
+ description = mFireDescription;
+ material.iconRes = R.drawable.ic_fire_white_24;
+ break;
+ default:
+ // ignore unknown types
+ continue;
+ }
+ if (TextUtils.isEmpty(material.description)) {
+ material.description = description;
+ } else {
+ // concatenate multiple types
+ material.iconRes = R.drawable.ic_emergency_number_24;
+ material.description = context.getString(R.string.description_concat_format,
+ material.description, description);
+ }
+ }
+ if (TextUtils.isEmpty(material.description) || material.iconRes == 0) {
+ return null;
+ }
+ return material;
+ }
+
+}
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index 951fae9..c57615d 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -28,6 +28,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.database.DataSetObserver;
import android.graphics.Color;
import android.graphics.Point;
import android.media.AudioManager;
@@ -70,9 +71,12 @@
import com.android.phone.common.dialpad.DialpadKeyButton;
import com.android.phone.common.util.ViewUtil;
import com.android.phone.common.widget.ResizingTextEditText;
+import com.android.phone.ecc.CountryEccInfo;
+import com.android.phone.ecc.EccInfoHelper;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
/**
* EmergencyDialer is a special dialer that is used ONLY for dialing emergency calls.
@@ -135,13 +139,20 @@
/** 85% opacity for black background **/
private static final int BLACK_BACKGROUND_GRADIENT_ALPHA = 217;
+ /** Size limit of emergency shortcut buttons container. **/
+ private static final int SHORTCUT_SIZE_LIMIT = 3;
+
ResizingTextEditText mDigits;
private View mDialButton;
private View mDelete;
private View mEmergencyShortcutView;
private View mDialpadView;
+ private EccInfoHelper mEccInfoHelper;
+
private List<EmergencyShortcutButton> mEmergencyShortcutButtonList;
+ private EccShortcutAdapter mShortcutAdapter;
+ private DataSetObserver mShortcutDataSetObserver = null;
private ToneGenerator mToneGenerator;
private Object mToneGeneratorLock = new Object();
@@ -219,6 +230,8 @@
mAreEmergencyDialerShortcutsEnabled = Settings.Global.getInt(getContentResolver(),
Settings.Global.FASTER_EMERGENCY_PHONE_CALL_ENABLED, 0) != 0;
+ Log.d(LOG_TAG, "Enable emergency dialer shortcut: "
+ + mAreEmergencyDialerShortcutsEnabled);
mColorExtractor = new ColorExtractor(this);
@@ -330,6 +343,10 @@
}
}
unregisterReceiver(mBroadcastReceiver);
+ if (mShortcutAdapter != null && mShortcutDataSetObserver != null) {
+ mShortcutAdapter.unregisterDataSetObserver(mShortcutDataSetObserver);
+ mShortcutDataSetObserver = null;
+ }
}
@Override
@@ -592,6 +609,32 @@
mBackgroundGradient.setColors(lockScreenColors, false);
updateTheme(lockScreenColors.supportsDarkText());
}
+
+ if (mAreEmergencyDialerShortcutsEnabled && mEccInfoHelper != null) {
+ final Context context = this;
+ mEccInfoHelper.getCountryEccInfoAsync(context,
+ new EccInfoHelper.CountryEccInfoResultCallback() {
+ @Override
+ public void onSuccess(String iso, CountryEccInfo countryEccInfo) {
+ Log.d(LOG_TAG, "Retrieve ECC info success, country ISO: "
+ + Rlog.pii(LOG_TAG, iso));
+ updateLocationAndEccInfo(iso, countryEccInfo);
+ }
+
+ @Override
+ public void onDetectCountryFailed() {
+ Log.w(LOG_TAG, "Cannot detect current country.");
+ updateLocationAndEccInfo(null, null);
+ }
+
+ @Override
+ public void onRetrieveCountryEccInfoFailed(String iso) {
+ Log.w(LOG_TAG, "Retrieve ECC info failed, country ISO: "
+ + Rlog.pii(LOG_TAG, iso));
+ updateLocationAndEccInfo(iso, null);
+ }
+ });
+ }
}
@Override
@@ -900,53 +943,94 @@
final View emergencyDialpadTitle = findViewById(R.id.emergency_dialpad_title_container);
emergencyDialpadTitle.setVisibility(View.VISIBLE);
- // TODO: Integrating emergency phone number table will get location information.
- // Using null to present no location status.
- setLocationInfo(null);
-
mEmergencyShortcutButtonList = new ArrayList<>();
setupEmergencyCallShortcutButton();
+ updateLocationAndEccInfo(null, null);
+
switchView(mEmergencyShortcutView, mDialpadView, false);
}
- private void setLocationInfo(String country) {
+ private void setLocationInfo(String countryIso) {
final View locationInfo = findViewById(R.id.location_info);
- if (TextUtils.isEmpty(country)) {
+ String countryName = null;
+ if (!TextUtils.isEmpty(countryIso)) {
+ Locale locale = Locale.getDefault();
+ countryName = new Locale(locale.getLanguage(), countryIso, locale.getVariant())
+ .getDisplayCountry();
+ }
+ if (TextUtils.isEmpty(countryName)) {
locationInfo.setVisibility(View.INVISIBLE);
} else {
final TextView location = (TextView) locationInfo.findViewById(R.id.location_text);
- location.setText(country);
+ location.setText(countryName);
locationInfo.setVisibility(View.VISIBLE);
}
}
- // TODO: Integrate emergency phone number table.
- // Using default layout(no location, phone number is 112, description is Emergency,
- // and icon is cross shape) until integrating emergency phone number table.
private void setupEmergencyCallShortcutButton() {
final ViewGroup shortcutButtonContainer = findViewById(
R.id.emergency_shortcut_buttons_container);
shortcutButtonContainer.setClipToOutline(true);
+ final TextView emergencyNumberTitle = findViewById(R.id.emergency_number_title);
- final EmergencyShortcutButton button =
- (EmergencyShortcutButton) getLayoutInflater().inflate(
- R.layout.emergency_shortcut_button,
- shortcutButtonContainer, false);
+ mShortcutAdapter = new EccShortcutAdapter(this) {
+ @Override
+ public View inflateView(View convertView, ViewGroup parent, CharSequence number,
+ CharSequence description, int iconRes) {
+ EmergencyShortcutButton button = (EmergencyShortcutButton) getLayoutInflater()
+ .inflate(R.layout.emergency_shortcut_button, parent, false);
+ button.setPhoneNumber(number);
+ button.setPhoneDescription(description);
+ button.setPhoneTypeIcon(iconRes);
+ button.setOnConfirmClickListener(EmergencyDialer.this);
+ return button;
+ }
+ };
+ mShortcutDataSetObserver = new DataSetObserver() {
+ @Override
+ public void onChanged() {
+ super.onChanged();
+ updateLayout();
+ }
- button.setPhoneNumber("112");
- button.setPhoneDescription("Emergency");
- button.setPhoneTypeIcon(R.drawable.ic_emergency_number_24);
- button.setOnConfirmClickListener(this);
+ @Override
+ public void onInvalidated() {
+ super.onInvalidated();
+ updateLayout();
+ }
- shortcutButtonContainer.addView(button);
- mEmergencyShortcutButtonList.add(button);
+ private void updateLayout() {
+ // clear previous added buttons
+ shortcutButtonContainer.removeAllViews();
+ mEmergencyShortcutButtonList.clear();
- //Set emergency number title for numerous buttons.
- if (shortcutButtonContainer.getChildCount() > 1) {
- final TextView emergencyNumberTitle = findViewById(R.id.emergency_number_title);
- emergencyNumberTitle.setText(getString(R.string.numerous_emergency_numbers_title));
+ for (int i = 0; i < mShortcutAdapter.getCount() && i < SHORTCUT_SIZE_LIMIT; ++i) {
+ EmergencyShortcutButton button = (EmergencyShortcutButton)
+ mShortcutAdapter.getView(i, null, shortcutButtonContainer);
+ mEmergencyShortcutButtonList.add(button);
+ shortcutButtonContainer.addView(button);
+ }
+
+ // update emergency numbers title for numerous buttons.
+ if (mEmergencyShortcutButtonList.size() > 1) {
+ emergencyNumberTitle.setText(getString(
+ R.string.numerous_emergency_numbers_title));
+ } else {
+ emergencyNumberTitle.setText(getText(R.string.single_emergency_number_title));
+ }
+ }
+ };
+ mShortcutAdapter.registerDataSetObserver(mShortcutDataSetObserver);
+ }
+
+ private void updateLocationAndEccInfo(String iso, CountryEccInfo countryEccInfo) {
+ if (!isFinishing() && !isDestroyed()) {
+ setLocationInfo(iso);
+ if (mShortcutAdapter != null) {
+ mShortcutAdapter.updateCountryEccInfo(this, countryEccInfo);
+ }
}
}
diff --git a/src/com/android/phone/EmergencyShortcutButton.java b/src/com/android/phone/EmergencyShortcutButton.java
index f2582cc..9b6caa4 100644
--- a/src/com/android/phone/EmergencyShortcutButton.java
+++ b/src/com/android/phone/EmergencyShortcutButton.java
@@ -102,14 +102,14 @@
/**
* Set emergency phone number description.
*/
- public void setPhoneDescription(@NonNull String description) {
+ public void setPhoneDescription(@NonNull CharSequence description) {
mPhoneTypeDescription.setText(description);
}
/**
* Set emergency phone number.
*/
- public void setPhoneNumber(@NonNull String number) {
+ public void setPhoneNumber(@NonNull CharSequence number) {
mPhoneNumber.setText(number);
mPhoneCallHint.setText(
getContext().getString(R.string.emergency_call_shortcut_hint, number));
@@ -117,7 +117,7 @@
// Set content description for phone number.
if (number.length() > 1) {
StringBuilder stringBuilder = new StringBuilder();
- for (char c : number.toCharArray()) {
+ for (char c : number.toString().toCharArray()) {
stringBuilder.append(c).append(" ");
}
mPhoneNumber.setContentDescription(stringBuilder.toString().trim());
diff --git a/src/com/android/phone/ecc/CountryEccInfo.java b/src/com/android/phone/ecc/CountryEccInfo.java
index 41f06eb..bc7ec84 100644
--- a/src/com/android/phone/ecc/CountryEccInfo.java
+++ b/src/com/android/phone/ecc/CountryEccInfo.java
@@ -19,7 +19,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
-import java.util.List;
+import java.util.Collection;
/**
* ECC info of a country.
@@ -28,7 +28,7 @@
private final String mFallbackEcc;
private final EccInfo[] mEccInfoList;
- public CountryEccInfo(String eccFallback, @NonNull List<EccInfo> eccInfoList) {
+ public CountryEccInfo(String eccFallback, @NonNull Collection<EccInfo> eccInfoList) {
mFallbackEcc = eccFallback;
mEccInfoList = eccInfoList.toArray(new EccInfo[eccInfoList.size()]);
}
diff --git a/src/com/android/phone/ecc/EccInfo.java b/src/com/android/phone/ecc/EccInfo.java
index c4bf119..a219bae 100644
--- a/src/com/android/phone/ecc/EccInfo.java
+++ b/src/com/android/phone/ecc/EccInfo.java
@@ -18,7 +18,7 @@
import android.annotation.NonNull;
-import java.util.List;
+import java.util.Collection;
/**
* Emergency call code info.
@@ -41,7 +41,7 @@
mTypes = new Type[]{ type };
}
- public EccInfo(@NonNull String number, @NonNull List<Type> types) {
+ public EccInfo(@NonNull String number, @NonNull Collection<Type> types) {
mNumber = number;
mTypes = types.toArray(new Type[types.size()]);
}
diff --git a/src/com/android/phone/ecc/EccInfoHelper.java b/src/com/android/phone/ecc/EccInfoHelper.java
index 7035881..875442a 100644
--- a/src/com/android/phone/ecc/EccInfoHelper.java
+++ b/src/com/android/phone/ecc/EccInfoHelper.java
@@ -29,6 +29,7 @@
import android.telephony.CellInfoLte;
import android.telephony.CellInfoWcdma;
import android.telephony.PhoneNumberUtils;
+import android.telephony.Rlog;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -44,6 +45,8 @@
* Helper for retrieve ECC info for current country.
*/
public class EccInfoHelper {
+ // Debug constants.
+ private static final boolean DBG = false;
private static final String LOG_TAG = "EccInfoHelper";
// country ISO to ECC list data source
@@ -163,14 +166,17 @@
TelephonyManager tm = (TelephonyManager) context.getSystemService(
Context.TELEPHONY_SERVICE);
String iso = tm.getNetworkCountryIso();
- Log.d(LOG_TAG, "Current country ISO is " + iso);
+ if (DBG) Log.d(LOG_TAG, "Current country ISO is " + Rlog.pii(LOG_TAG, iso));
if (TextUtils.isEmpty(iso)) {
// XXX: according to ServiceStateTracker's implementation, retrieve cell info in a
// thread other than TelephonyManager's main thread.
String mcc = getCurrentMccFromCellInfo(context);
iso = countryCodeForMcc(mcc);
- Log.d(LOG_TAG, "Current mcc is " + mcc + ", mapping to ISO: " + iso);
+ if (DBG) {
+ Log.d(LOG_TAG, "Current mcc is " + Rlog.pii(LOG_TAG, mcc) + ", mapping to ISO: "
+ + Rlog.pii(LOG_TAG, iso));
+ }
}
return iso;
}
@@ -211,7 +217,7 @@
break;
}
}
- Log.d(LOG_TAG, "Retrieve MCC from cell info list: " + mcc);
+ if (DBG) Log.d(LOG_TAG, "Retrieve MCC from cell info list: " + Rlog.pii(LOG_TAG, mcc));
} else {
Log.w(LOG_TAG, "Cannot get cell info list.");
}