summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-05-07 08:50:41 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-05-07 08:50:41 +0000
commit04bc8e6cc67e8e10d757236be77b6608b66dd72a (patch)
treee8e16984acf0e9052c6d68d21e9a8330f0c70e17 /libs
parent644c45a0db09f711a7f5d333d94ee8543892b1d0 (diff)
parent431a8ab0ac838e332d43d4264b58d97cae3b7732 (diff)
Merge "Show App name when carrier id not set" into rvc-dev am: 431a8ab0ac
Change-Id: I425d20958b71ab51cb6022180bf6e3b4bc38c4db
Diffstat (limited to 'libs')
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java16
-rw-r--r--libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/UtilsTest.java14
2 files changed, 26 insertions, 4 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java
index 934cdf146..ced1d81bd 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java
@@ -618,6 +618,9 @@ class Utils {
* Get the SIM carrier name for target subscription Id.
*/
static @Nullable String getCarrierNameForSubId(@NonNull Context context, int subId) {
+ if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ return null;
+ }
TelephonyManager telephonyManager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager == null) return null;
@@ -641,9 +644,8 @@ class Utils {
* Get the best match subscription Id for target WifiConfiguration.
*/
static int getSubIdForConfig(@NonNull Context context, @NonNull WifiConfiguration config) {
- int dataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
if (config.carrierId == TelephonyManager.UNKNOWN_CARRIER_ID) {
- return dataSubId;
+ return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
}
SubscriptionManager subscriptionManager =
(SubscriptionManager) context.getSystemService(
@@ -657,6 +659,7 @@ class Utils {
}
int matchSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ int dataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
for (SubscriptionInfo subInfo : subInfoList) {
if (subInfo.getCarrierId() == config.carrierId) {
matchSubId = subInfo.getSubscriptionId();
@@ -691,8 +694,13 @@ class Utils {
if (context == null || wifiConfig == null || !isSimCredential(wifiConfig)) {
return "";
}
-
- int subId = getSubIdForConfig(context, wifiConfig);
+ int subId;
+ if (wifiConfig.carrierId == TelephonyManager.UNKNOWN_CARRIER_ID) {
+ // Config without carrierId use default data subscription.
+ subId = SubscriptionManager.getDefaultSubscriptionId();
+ } else {
+ subId = getSubIdForConfig(context, wifiConfig);
+ }
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID
|| isImsiPrivacyProtectionProvided(context, subId)) {
return "";
diff --git a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/UtilsTest.java b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/UtilsTest.java
index aa0df1092..de4b6903c 100644
--- a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/UtilsTest.java
+++ b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/UtilsTest.java
@@ -344,6 +344,13 @@ public class UtilsTest {
}
@Test
+ public void testGetCarrierNameWithInvalidSubId() {
+ when(mSpecifiedTm.getSimCarrierIdName()).thenReturn(TEST_CARRIER_NAME);
+ assertNull(getCarrierNameForSubId(mMockContext,
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID));
+ }
+
+ @Test
public void testCheckRequireImsiPrivacyProtectionWithNoCarrierConfig() {
assertFalse(isImsiPrivacyProtectionProvided(mMockContext, TEST_SUB_ID));
}
@@ -379,6 +386,13 @@ public class UtilsTest {
}
@Test
+ public void testGetSubIdForWifiConfigurationWithoutCarrierId() {
+ WifiConfiguration config = new WifiConfiguration();
+ assertEquals(SubscriptionManager.INVALID_SUBSCRIPTION_ID,
+ getSubIdForConfig(mMockContext, config));
+ }
+
+ @Test
public void testGetImsiProtectionDescription_isSimCredentialFalse_returnEmptyString() {
final WifiConfiguration wificonfig = new WifiConfiguration();