summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/phone/SubscriptionInfoHelper.java3
-rw-r--r--src/com/android/services/telephony/TelephonyConnectionService.java16
-rw-r--r--tests/src/com/android/phone/SubscriptionInfoHelperTest.java59
3 files changed, 69 insertions, 9 deletions
diff --git a/src/com/android/phone/SubscriptionInfoHelper.java b/src/com/android/phone/SubscriptionInfoHelper.java
index 7c373e041..14faebc1e 100644
--- a/src/com/android/phone/SubscriptionInfoHelper.java
+++ b/src/com/android/phone/SubscriptionInfoHelper.java
@@ -91,7 +91,8 @@ public class SubscriptionInfoHelper {
intent.putExtra(SubscriptionInfoHelper.SUB_ID_EXTRA, subscription.getSubscriptionId());
intent.putExtra(
- SubscriptionInfoHelper.SUB_LABEL_EXTRA, subscription.getDisplayName().toString());
+ SubscriptionInfoHelper.SUB_LABEL_EXTRA, subscription.getDisplayName() == null ? null
+ : subscription.getDisplayName().toString());
}
/**
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 766a75e6c..4f6acc8f2 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -2084,8 +2084,7 @@ public class TelephonyConnectionService extends ConnectionService {
if (phone.getEmergencyNumberTracker() != null) {
if (phone.getEmergencyNumberTracker().isEmergencyNumber(
emergencyNumberAddress, true)) {
- if (phone.getHalVersion().greaterOrEqual(RIL.RADIO_HAL_VERSION_1_4)
- || isAvailableForEmergencyCalls(phone)) {
+ if (isAvailableForEmergencyCalls(phone)) {
// a)
if (phone.getPhoneId() == defaultVoicePhoneId) {
Log.i(this, "getPhoneForEmergencyCall, Phone Id that supports"
@@ -2208,12 +2207,6 @@ public class TelephonyConnectionService extends ConnectionService {
// Only sort if there are enough elements to do so.
if (phoneSlotStatus.size() > 1) {
Collections.sort(phoneSlotStatus, (o1, o2) -> {
- if (!o1.hasDialedEmergencyNumber && o2.hasDialedEmergencyNumber) {
- return -1;
- }
- if (o1.hasDialedEmergencyNumber && !o2.hasDialedEmergencyNumber) {
- return 1;
- }
// Sort by non-absent SIM.
if (o1.simState == TelephonyManager.SIM_STATE_ABSENT
&& o2.simState != TelephonyManager.SIM_STATE_ABSENT) {
@@ -2232,6 +2225,13 @@ public class TelephonyConnectionService extends ConnectionService {
if (o2.isLocked && !o1.isLocked) {
return 1;
}
+ // Prefer slots where the number is considered emergency.
+ if (!o1.hasDialedEmergencyNumber && o2.hasDialedEmergencyNumber) {
+ return -1;
+ }
+ if (o1.hasDialedEmergencyNumber && !o2.hasDialedEmergencyNumber) {
+ return 1;
+ }
// sort by number of RadioAccessFamily Capabilities.
int compare = RadioAccessFamily.compare(o1.capabilities, o2.capabilities);
if (compare == 0) {
diff --git a/tests/src/com/android/phone/SubscriptionInfoHelperTest.java b/tests/src/com/android/phone/SubscriptionInfoHelperTest.java
new file mode 100644
index 000000000..90f682ffd
--- /dev/null
+++ b/tests/src/com/android/phone/SubscriptionInfoHelperTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2021 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 static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import android.content.Intent;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+
+import org.junit.Test;
+
+public class SubscriptionInfoHelperTest {
+ private static final String EXTRA_SUBSCRIPTION_LABEL =
+ "com.android.phone.settings.SubscriptionInfoHelper.SubscriptionLabel";
+
+ /**
+ * Ensures {@link SubscriptionInfoHelper#addExtrasToIntent(Intent, SubscriptionInfo)} can
+ * properly handle a null display name without crashing.
+ */
+ @Test
+ public void testAddExtrasToIntentWithNullDisplayName() {
+ Intent intent = new Intent();
+ SubscriptionInfo info = new SubscriptionInfo(1, // id
+ "90210", // iccId
+ 1, // simSlotIndex
+ null, // displayName
+ null, // carrierName
+ SubscriptionManager.NAME_SOURCE_CARRIER_ID, // nameSource
+ 0, //iconTint
+ "555-1212", // number
+ 0, // roaming
+ null, // icon
+ "401", // mcc
+ "384", // mnc
+ "us", // countryIso
+ false, // isEmbedded
+ null, // nativeAccessRules
+ ""); // cardString
+ SubscriptionInfoHelper.addExtrasToIntent(intent, info);
+ assertNull(intent.getStringExtra(EXTRA_SUBSCRIPTION_LABEL));
+ assertTrue(intent.hasExtra(EXTRA_SUBSCRIPTION_LABEL));
+ }
+}