[automerger skipped] Import translations. DO NOT MERGE ANYWHERE am: af35ba7978 -s ours am: 0da42aa206 -s ours am: 6cca98b9d8 -s ours
am skip reason: subject contains skip directive
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telephony/+/19382830
Change-Id: Ie914b23c5047ea8417f5f3ed5e0b4a05c0275cc3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/res/values-te/strings.xml b/res/values-te/strings.xml
index b09fea7..edc71b3 100644
--- a/res/values-te/strings.xml
+++ b/res/values-te/strings.xml
@@ -52,7 +52,7 @@
<string name="label_ndp" msgid="7617392683877410341">"SIM నెట్వర్క్ అన్లాక్ పిన్"</string>
<string name="label_phoneid" msgid="8775611434123577808">"ఈ ఆపరేటర్కు సంబంధించి SIM లాక్ చేయబడింది"</string>
<string name="sim_ndp_unlock_text" msgid="7737338355451978338">"అన్లాక్ చేయి"</string>
- <string name="sim_ndp_dismiss_text" msgid="89667342248929777">"తీసివేయి"</string>
+ <string name="sim_ndp_dismiss_text" msgid="89667342248929777">"తీసివేయండి"</string>
<string name="requesting_unlock" msgid="930512210309437741">"నెట్వర్క్ అన్లాక్ను అభ్యర్థిస్తోంది…"</string>
<string name="unlock_failed" msgid="7103543844840661366">"నెట్వర్క్ అన్లాక్ రిక్వెస్ట్ విఫలమైంది."</string>
<string name="unlock_success" msgid="32681089371067565">"నెట్వర్క్ అన్లాక్ విజయవంతమైంది."</string>
@@ -279,7 +279,7 @@
<!-- no translation found for enhanced_4g_lte_mode_sumary_variant:1 (5262249464504131443) -->
<!-- no translation found for enhanced_4g_lte_mode_sumary_variant:2 (6356974241850241718) -->
<string name="data_enabled" msgid="22525832097434368">"డేటా ప్రారంభించబడింది"</string>
- <string name="data_enable_summary" msgid="696860063456536557">"డేటా వినియోగాన్ని అనుమతించు"</string>
+ <string name="data_enable_summary" msgid="696860063456536557">"డేటా వినియోగాన్ని అనుమతించండి"</string>
<string name="dialog_alert_title" msgid="5260471806940268478">"హెచ్చరిక"</string>
<string name="roaming" msgid="1576180772877858949">"రోమింగ్"</string>
<string name="roaming_enable" msgid="6853685214521494819">"రోమింగ్లో ఉన్నప్పుడు డేటా సర్వీసులకు కనెక్ట్ చేయండి"</string>
@@ -305,7 +305,7 @@
<string name="carrier_settings_euicc_summary" msgid="2027941166597330117">"<xliff:g id="CARRIER_NAME">%1$s</xliff:g> — <xliff:g id="PHONE_NUMBER">%2$s</xliff:g>"</string>
<string name="mobile_data_settings_title" msgid="7228249980933944101">"మొబైల్ డేటా"</string>
<string name="mobile_data_settings_summary" msgid="5012570152029118471">"మొబైల్ నెట్వర్క్ను ఉపయోగించి డేటాను యాక్సెస్ చేయండి"</string>
- <string name="data_usage_disable_mobile" msgid="5669109209055988308">"మొబైల్ డేటాని ఆఫ్ చేయాలా?"</string>
+ <string name="data_usage_disable_mobile" msgid="5669109209055988308">"మొబైల్ డేటాను ఆఫ్ చేయాలా?"</string>
<string name="sim_selection_required_pref" msgid="6985901872978341314">"ఎంపిక అవసరం"</string>
<string name="sim_change_data_title" msgid="9142726786345906606">"డేటా SIMని మార్చాలా?"</string>
<string name="sim_change_data_message" msgid="3567358694255933280">"మొబైల్ డేటా కోసం <xliff:g id="OLD_SIM">%2$s</xliff:g>కి బదులుగా <xliff:g id="NEW_SIM">%1$s</xliff:g>ని ఉపయోగించాలా?"</string>
@@ -586,10 +586,10 @@
<string name="onscreenManageConferenceText" msgid="4700574060601755137">"కాన్ఫరెన్స్ను నిర్వహించు"</string>
<string name="onscreenAudioText" msgid="7224226735052019986">"ఆడియో"</string>
<string name="onscreenVideoCallText" msgid="1743992456126258698">"వీడియో కాల్"</string>
- <string name="importSimEntry" msgid="3892354284082689894">"దిగుమతి చేయి"</string>
- <string name="importAllSimEntries" msgid="2628391505643564007">"అన్నింటినీ దిగుమతి చేయి"</string>
+ <string name="importSimEntry" msgid="3892354284082689894">"దిగుమతి చేయండి"</string>
+ <string name="importAllSimEntries" msgid="2628391505643564007">"అన్నింటినీ దిగుమతి చేయండి"</string>
<string name="importingSimContacts" msgid="4995457122107888932">"SIM కాంటాక్ట్లను దిగుమతి చేస్తోంది"</string>
- <string name="importToFDNfromContacts" msgid="5068664870738407341">"కాంటాక్ట్ల నుండి దిగుమతి చేయి"</string>
+ <string name="importToFDNfromContacts" msgid="5068664870738407341">"కాంటాక్ట్ల నుండి దిగుమతి చేయండి"</string>
<string name="singleContactImportedMsg" msgid="3619804066300998934">"కాంటాక్ట్ దిగుమతి చేయబడింది"</string>
<string name="failedToImportSingleContactMsg" msgid="228095510489830266">"కాంటాక్ట్ను దిగుమతి చేయడంలో విఫలమైంది"</string>
<string name="hac_mode_title" msgid="4127986689621125468">"వినికిడి సహాయక సాధనాలు"</string>
@@ -643,7 +643,7 @@
<string name="progress_dialog_exiting_ecm" msgid="9159080081676927217">"అత్యవసర కాల్బ్యాక్ మోడ్ నుండి నిష్క్రమిస్తోంది"</string>
<string name="alert_dialog_yes" msgid="3532525979632841417">"అవును"</string>
<string name="alert_dialog_no" msgid="1075632654085988420">"కాదు"</string>
- <string name="alert_dialog_dismiss" msgid="1336356286354517054">"తీసివేయి"</string>
+ <string name="alert_dialog_dismiss" msgid="1336356286354517054">"తీసివేయండి"</string>
<string name="phone_in_ecm_call_notification_text_without_data_restriction_hint" msgid="3747860785153531225">"ఫోన్ అత్యవసర కాల్బ్యాక్ మోడ్లో ఉంది"</string>
<string name="phone_in_ecm_notification_complete_time_without_data_restriction_hint" msgid="3690292264812050858">"<xliff:g id="COMPLETETIME">%s</xliff:g> వరకు"</string>
<string name="alert_dialog_exit_ecm_without_data_restriction_hint" msgid="7549850847524907932">"{count,plural, =1{ఫోన్ ఒక నిమిషం పాటు ఎమర్జెన్సీ కాల్బ్యాక్ మోడ్లో ఉంటుంది.\nమీరు ఇప్పుడే నిష్క్రమించాలనుకుంటున్నారా?}other{ఫోన్ %s నిమిషాల పాటు ఎమర్జెన్సీ కాల్బ్యాక్ మోడ్లో ఉంటుంది.\nమీరు ఇప్పుడే నిష్క్రమించాలనుకుంటున్నారా?}}"</string>
@@ -822,7 +822,7 @@
<string name="supp_service_over_ut_precautions_roaming" msgid="670342104569972327">"<xliff:g id="SUPP_SERVICE">%s</xliff:g>ని ఉపయోగించడానికి, మొబైల్ డేటా మరియు డేటా రోమింగ్ని తప్పకుండా ఆన్ చేసారని నిర్ధారించుకోండి. మీరు వీటిని మొబైల్ నెట్వర్క్ సెట్టింగ్లలో మార్చవచ్చు."</string>
<string name="supp_service_over_ut_precautions_dual_sim" msgid="5166866975550910474">"<xliff:g id="SUPP_SERVICE">%1$s</xliff:g>ని ఉపయోగించడానికి, SIM <xliff:g id="SIM_NUMBER">%2$d</xliff:g> కోసం మొబైల్ డేటాను తప్పకుండా ఆన్ చేసారని నిర్ధారించుకోండి. మీరు దీనిని మొబైల్ నెట్వర్క్ సెట్టింగ్లలో మార్చవచ్చు."</string>
<string name="supp_service_over_ut_precautions_roaming_dual_sim" msgid="6627654855191817965">"<xliff:g id="SUPP_SERVICE">%1$s</xliff:g>ని ఉపయోగించడానికి, SIM <xliff:g id="SIM_NUMBER">%2$d</xliff:g> కోసం మొబైల్ డేటా మరియు డేటా రోమింగ్ని తప్పకుండా ఆన్ చేసారని నిర్ధారించుకోండి. మీరు వీటిని మొబైల్ నెట్వర్క్ సెట్టింగ్లలో మార్చవచ్చు."</string>
- <string name="supp_service_over_ut_precautions_dialog_dismiss" msgid="5934541487903081652">"తీసివేయి"</string>
+ <string name="supp_service_over_ut_precautions_dialog_dismiss" msgid="5934541487903081652">"తీసివేయండి"</string>
<string name="radio_info_data_connection_enable" msgid="6183729739783252840">"డేటా కనెక్షన్ను ప్రారంభించండి"</string>
<string name="radio_info_data_connection_disable" msgid="6404751291511368706">"డేటా కనెక్షన్ను నిలిపివేయండి"</string>
<string name="volte_provisioned_switch_string" msgid="4812874990480336178">"VoLTE సదుపాయం ఉంది"</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8218a84..d0f427c 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -207,8 +207,6 @@
<style name="DialerAlertDialogTheme"
parent="@android:style/Theme.Material.Light.Dialog">
<item name="android:forceDarkAllowed">true</item>
- <item name="android:colorAccent">@color/dialer_theme_color</item>
- <item name="android:textColor">?android:attr/textColorPrimaryInverseDisableOnly</item>
</style>
<style name="Empty" parent="@android:style/Theme.Material.Light">
diff --git a/src/com/android/phone/PhoneDisplayMessage.java b/src/com/android/phone/PhoneDisplayMessage.java
index be7fc7f..c487cba 100644
--- a/src/com/android/phone/PhoneDisplayMessage.java
+++ b/src/com/android/phone/PhoneDisplayMessage.java
@@ -80,7 +80,8 @@
sDisplayMessageDialog.getWindow().addFlags(
WindowManager.LayoutParams.FLAG_DIM_BEHIND
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
- | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
sDisplayMessageDialog.show();
}
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 695a4a4..d0aad4a 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -469,7 +469,7 @@
// build the dialog
final AlertDialog newDialog =
- FrameworksUtils.makeAlertDialogBuilder(contextThemeWrapper)
+ new AlertDialog.Builder(contextThemeWrapper)
.setMessage(text)
.setView(dialogView)
.setPositiveButton(R.string.send_button, mUSSDDialogListener)
diff --git a/src/com/android/services/telephony/DisconnectCauseUtil.java b/src/com/android/services/telephony/DisconnectCauseUtil.java
index 9321e1e..587ac43 100644
--- a/src/com/android/services/telephony/DisconnectCauseUtil.java
+++ b/src/com/android/services/telephony/DisconnectCauseUtil.java
@@ -25,6 +25,7 @@
import android.telephony.SubscriptionManager;
import android.telephony.ims.ImsReasonInfo;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.CallFailCause;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
@@ -101,14 +102,29 @@
public static DisconnectCause toTelecomDisconnectCause(
int telephonyDisconnectCause, int telephonyPreciseDisconnectCause, String reason,
int phoneId, ImsReasonInfo imsReasonInfo) {
+ return toTelecomDisconnectCause(telephonyDisconnectCause, telephonyPreciseDisconnectCause,
+ reason, phoneId, imsReasonInfo, getCarrierConfigBundle(phoneId));
+ }
+
+ /**
+ * Final pre-processing method in creating a DisconnectCause. This method should NOT be called
+ * from another class directly. It only has private-package visibility for testing.
+ *
+ * @param carrierConfig
+ */
+ @VisibleForTesting
+ static DisconnectCause toTelecomDisconnectCause(
+ int telephonyDisconnectCause, int telephonyPreciseDisconnectCause, String reason,
+ int phoneId, ImsReasonInfo imsReasonInfo, PersistableBundle carrierConfig) {
Context context = PhoneGlobals.getInstance();
+
return new DisconnectCause(
- toTelecomDisconnectCauseCode(telephonyDisconnectCause),
+ toTelecomDisconnectCauseCode(telephonyDisconnectCause, carrierConfig),
toTelecomDisconnectCauseLabel(context, telephonyDisconnectCause,
- telephonyPreciseDisconnectCause),
+ telephonyPreciseDisconnectCause, carrierConfig),
toTelecomDisconnectCauseDescription(context, telephonyDisconnectCause, phoneId),
- toTelecomDisconnectReason(context,telephonyDisconnectCause, reason, phoneId),
- toTelecomDisconnectCauseTone(telephonyDisconnectCause, phoneId),
+ toTelecomDisconnectReason(context, telephonyDisconnectCause, reason, phoneId),
+ toTelecomDisconnectCauseTone(telephonyDisconnectCause, carrierConfig),
telephonyDisconnectCause,
telephonyPreciseDisconnectCause,
imsReasonInfo);
@@ -119,7 +135,16 @@
* {@link android.telecom.DisconnectCause} disconnect code.
* @return The disconnect code as defined in {@link android.telecom.DisconnectCause}.
*/
- private static int toTelecomDisconnectCauseCode(int telephonyDisconnectCause) {
+ private static int toTelecomDisconnectCauseCode(int telephonyDisconnectCause,
+ PersistableBundle carrierConfig) {
+
+ // special case: some carriers determine what disconnect causes play the BUSY tone.
+ // hence, must adjust the disconnectCause CODE to match the tone.
+ if (doesCarrierClassifyDisconnectCauseAsBusyCause(telephonyDisconnectCause,
+ carrierConfig)) {
+ return DisconnectCause.BUSY;
+ }
+
switch (telephonyDisconnectCause) {
case android.telephony.DisconnectCause.LOCAL:
// The call was still disconnected locally, so this is not an error condition.
@@ -237,8 +262,17 @@
* Returns a label for to the disconnect cause to be shown to the user.
*/
private static CharSequence toTelecomDisconnectCauseLabel(
- Context context, int telephonyDisconnectCause, int telephonyPreciseDisconnectCause) {
+ Context context, int telephonyDisconnectCause, int telephonyPreciseDisconnectCause,
+ PersistableBundle carrierConfig) {
CharSequence label;
+
+ // special case: some carriers determine what disconnect causes play the BUSY tone.
+ // hence, must adjust the disconnectCause LABEL to match the tone.
+ if (doesCarrierClassifyDisconnectCauseAsBusyCause(telephonyDisconnectCause,
+ carrierConfig)) {
+ return context.getResources().getString(R.string.callFailed_userBusy);
+ }
+
if (telephonyPreciseDisconnectCause != CallFailCause.NOT_VALID) {
label = getLabelFromPreciseDisconnectCause(context, telephonyPreciseDisconnectCause,
telephonyDisconnectCause);
@@ -695,6 +729,10 @@
resourceId = R.string.incall_error_emergency_only;
break;
+ case android.telephony.DisconnectCause.ICC_ERROR:
+ resourceId = R.string.callFailed_simError;
+ break;
+
case android.telephony.DisconnectCause.OUT_OF_SERVICE:
// No network connection.
if (ImsUtil.shouldPromoteWfc(context, phoneId)) {
@@ -840,21 +878,15 @@
/**
* Returns the tone to play for the disconnect cause, or UNKNOWN if none should be played.
*/
- private static int toTelecomDisconnectCauseTone(int telephonyDisconnectCause, int phoneId) {
- Phone phone = PhoneFactory.getPhone(phoneId);
- PersistableBundle config;
- if (phone != null) {
- config = PhoneGlobals.getInstance().getCarrierConfigForSubId(phone.getSubId());
- } else {
- config = PhoneGlobals.getInstance().getCarrierConfig();
+ private static int toTelecomDisconnectCauseTone(int telephonyDisconnectCause,
+ PersistableBundle carrierConfig) {
+
+ // special case: some carriers determine what disconnect causes play the BUSY tone.
+ if (doesCarrierClassifyDisconnectCauseAsBusyCause(telephonyDisconnectCause,
+ carrierConfig)) {
+ return ToneGenerator.TONE_SUP_BUSY;
}
- int[] busyToneArray = config.getIntArray(
- CarrierConfigManager.KEY_DISCONNECT_CAUSE_PLAY_BUSYTONE_INT_ARRAY);
- for (int busyTone : busyToneArray) {
- if (busyTone == telephonyDisconnectCause) {
- return ToneGenerator.TONE_SUP_BUSY;
- }
- }
+
switch (telephonyDisconnectCause) {
case android.telephony.DisconnectCause.CONGESTION:
return ToneGenerator.TONE_SUP_CONGESTION;
@@ -886,4 +918,37 @@
return ToneGenerator.TONE_PROP_PROMPT;
}
}
+
+ /**
+ * Helper method that examines the carrierConfig KEY_DISCONNECT_CAUSE_PLAY_BUSYTONE_INT_ARRAY
+ * containing the DisconnectCauses that are classified as DisconnectCause.BUSY
+ * @param telephonyDisconnectCause
+ * @param carrierConfig object that holds all the carrier specific settings
+ * @return whether the cause is in the carrier config busy tone array
+ */
+ private static boolean doesCarrierClassifyDisconnectCauseAsBusyCause(
+ int telephonyDisconnectCause, PersistableBundle carrierConfig) {
+ int[] busyToneArray = carrierConfig.getIntArray(
+ CarrierConfigManager.KEY_DISCONNECT_CAUSE_PLAY_BUSYTONE_INT_ARRAY);
+ for (int busyTone : busyToneArray) {
+ if (busyTone == telephonyDisconnectCause) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static PersistableBundle getCarrierConfigBundle(int phoneId) {
+ Phone phone = PhoneFactory.getPhone(phoneId);
+ PersistableBundle config;
+
+ if (phone != null) {
+ config = PhoneGlobals.getInstance().getCarrierConfigForSubId(phone.getSubId());
+ } else {
+ config = PhoneGlobals.getInstance().getCarrierConfig();
+ }
+
+ return config;
+ }
+
}
diff --git a/testapps/GbaTestApp/res/values-te/strings.xml b/testapps/GbaTestApp/res/values-te/strings.xml
index 72bd28b..28b0489 100644
--- a/testapps/GbaTestApp/res/values-te/strings.xml
+++ b/testapps/GbaTestApp/res/values-te/strings.xml
@@ -7,7 +7,7 @@
<string name="label_service" msgid="2668963955237345578">"సర్వీస్ కాన్ఫిగరేషన్"</string>
<string name="label_test" msgid="8425079572898571918">"పరీక్ష కాన్ఫిగరేషన్"</string>
<string name="button_name_running" msgid="4557363091224858010">"రన్ అవుతోంది"</string>
- <string name="button_name_exit" msgid="8025683733431538975">"నిష్క్రమించు"</string>
+ <string name="button_name_exit" msgid="8025683733431538975">"నిష్క్రమించండి"</string>
<string name="label_test_result" msgid="892984695972956196">"పరీక్ష ఫలితం"</string>
<string name="button_name_clear" msgid="436313515327318537">"రీసెట్ చేయండి"</string>
<string name="button_name_done" msgid="6030406534322497491">"పూర్తయింది"</string>
diff --git a/tests/src/com/android/services/telephony/DisconnectCauseUtilTest.java b/tests/src/com/android/services/telephony/DisconnectCauseUtilTest.java
index 7f9efdc..28a7b02 100644
--- a/tests/src/com/android/services/telephony/DisconnectCauseUtilTest.java
+++ b/tests/src/com/android/services/telephony/DisconnectCauseUtilTest.java
@@ -17,19 +17,104 @@
package com.android.services.telephony;
import static android.media.ToneGenerator.TONE_PROP_PROMPT;
+import static android.media.ToneGenerator.TONE_SUP_BUSY;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.TestCase.assertEquals;
+import android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.os.PersistableBundle;
+import android.telephony.CarrierConfigManager;
import android.telephony.DisconnectCause;
+import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
+import com.android.TelephonyTestBase;
+import com.android.internal.telephony.GsmCdmaPhone;
+import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneFactory;
+import com.android.phone.common.R;
+
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Locale;
+
@RunWith(AndroidJUnit4.class)
-public class DisconnectCauseUtilTest {
+public class DisconnectCauseUtilTest extends TelephonyTestBase {
+
+ // constants
+ public static final int PHONE_ID = 123;
+ public static final String EMPTY_STRING = "";
+
+ // dynamic
+ private Context mContext;
+ private HashMap<InstanceKey, Object> mOldInstances = new HashMap<InstanceKey, Object>();
+ private ArrayList<InstanceKey> mInstanceKeys = new ArrayList<InstanceKey>();
+
+ //Mocks
+ @Mock
+ private GsmCdmaPhone mMockPhone;
+
+ // inner classes
+ private static class InstanceKey {
+ public final Class mClass;
+ public final String mInstName;
+ public final Object mObj;
+
+ InstanceKey(final Class c, final String instName, final Object obj) {
+ mClass = c;
+ mInstName = instName;
+ mObj = obj;
+ }
+
+ @Override
+ public int hashCode() {
+ return (mClass.getName().hashCode() * 31 + mInstName.hashCode()) * 31;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null || !(obj instanceof InstanceKey)) {
+ return false;
+ }
+
+ InstanceKey other = (InstanceKey) obj;
+ return (other.mClass == mClass && other.mInstName.equals(mInstName)
+ && other.mObj == mObj);
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ // objects that call static getInstance()
+ mMockPhone = Mockito.mock(GsmCdmaPhone.class);
+ mContext = InstrumentationRegistry.getTargetContext();
+ // set mocks
+ setSinglePhone();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // restoreInstance.
+ // Not doing so will potentially "confuse" other tests with the mocked instance
+ restoreInstance(PhoneFactory.class, "sPhones", null);
+ super.tearDown();
+ }
+
+
/**
* Verifies that a call drop due to loss of WIFI results in a disconnect cause of error and that
* the label, description and tone are all present.
@@ -43,4 +128,109 @@
assertNotNull(tcCause.getDescription());
assertNotNull(tcCause.getReason());
}
+
+ /**
+ * ensure the default behavior was not changed when a disconnect cause comes in as
+ * DisconnectCause.ERROR_UNSPECIFIED
+ */
+ @Test
+ public void testDefaultDisconnectCauseBehaviorForCauseNotInCarrierBusyToneArray() {
+ android.telecom.DisconnectCause tcCause = DisconnectCauseUtil.toTelecomDisconnectCause(
+ DisconnectCause.ERROR_UNSPECIFIED, EMPTY_STRING, PHONE_ID);
+ // CODE
+ assertEquals(android.telecom.DisconnectCause.ERROR, tcCause.getCode());
+ // LABEL
+ safeAssertLabel(null, tcCause);
+ // TONE
+ assertEquals(TONE_PROP_PROMPT, tcCause.getTone());
+ }
+
+ /**
+ * Simulate a Carrier classifying the DisconnectCause.ERROR_UNSPECIFIED as a
+ * DisconnectCause.BUSY. The code, label, and tone should match DisconnectCause.BUSY.
+ */
+ @Test
+ public void testCarrierSetDisconnectCauseInBusyToneArray() {
+ int[] carrierBusyArr = {DisconnectCause.BUSY, DisconnectCause.ERROR_UNSPECIFIED};
+ PersistableBundle config = new PersistableBundle();
+
+ config.putIntArray(
+ CarrierConfigManager.KEY_DISCONNECT_CAUSE_PLAY_BUSYTONE_INT_ARRAY,
+ carrierBusyArr);
+
+ android.telecom.DisconnectCause tcCause =
+ DisconnectCauseUtil.toTelecomDisconnectCause(
+ DisconnectCause.ERROR_UNSPECIFIED, -1,
+ EMPTY_STRING, PHONE_ID, null, config);
+
+ // CODE
+ assertEquals(android.telecom.DisconnectCause.BUSY, tcCause.getCode());
+ // LABEL
+ safeAssertLabel(R.string.callFailed_userBusy, tcCause);
+ // TONE
+ assertEquals(TONE_SUP_BUSY, tcCause.getTone());
+ }
+
+ private void setSinglePhone() throws Exception {
+ Phone[] mPhones = new Phone[]{mMockPhone};
+ replaceInstance(PhoneFactory.class, "sPhones", null, mPhones);
+ }
+
+
+ protected synchronized void replaceInstance(final Class c, final String instanceName,
+ final Object obj, final Object newValue)
+ throws Exception {
+ Field field = c.getDeclaredField(instanceName);
+ field.setAccessible(true);
+
+ InstanceKey key = new InstanceKey(c, instanceName, obj);
+ if (!mOldInstances.containsKey(key)) {
+ mOldInstances.put(key, field.get(obj));
+ mInstanceKeys.add(key);
+ }
+ field.set(obj, newValue);
+ }
+
+ protected synchronized void restoreInstance(final Class c, final String instanceName,
+ final Object obj) throws Exception {
+ InstanceKey key = new InstanceKey(c, instanceName, obj);
+ if (mOldInstances.containsKey(key)) {
+ Field field = c.getDeclaredField(instanceName);
+ field.setAccessible(true);
+ field.set(obj, mOldInstances.get(key));
+ mOldInstances.remove(key);
+ mInstanceKeys.remove(key);
+ }
+ }
+
+ private Resources getResourcesForLocale(Context context, Locale locale) {
+ Configuration config = new Configuration();
+ config.setToDefaults();
+ config.setLocale(locale);
+ Context localeContext = context.createConfigurationContext(config);
+ return localeContext.getResources();
+ }
+
+ private void safeAssertLabel(Integer resourceId,
+ android.telecom.DisconnectCause disconnectCause) {
+ Resources r = getResourcesForLocale(mContext, Locale.US);
+ if (resourceId == null || r == null) {
+ return;
+ }
+ String label = r.getString(resourceId);
+ assertEquals(label, disconnectCause.getLabel());
+ }
+
+ /**
+ * Verifies that an ICC_ERROR disconnect cause generates a message which mentions there is no
+ * SIM.
+ */
+ @Test
+ public void testIccError() {
+ android.telecom.DisconnectCause tcCause = DisconnectCauseUtil.toTelecomDisconnectCause(
+ DisconnectCause.ICC_ERROR);
+ assertEquals(android.telecom.DisconnectCause.ERROR, tcCause.getCode());
+ assertNotNull(tcCause.getLabel());
+ assertNotNull(tcCause.getDescription());
+ }
}