From 1317e27e91b9eb08f9769cb5dae0526235d3000d Mon Sep 17 00:00:00 2001 From: paulhu Date: Thu, 16 Apr 2020 14:35:49 +0800 Subject: [PATCH] [TNU05.1] Address aosp/1237036 leftover comments Bug: 147818698 Test: atest TetheringTests Change-Id: Ife738339aeae00d2063fea6918b50204daef24fc --- .../TetheringNotificationUpdater.java | 18 ++++++++---------- .../TetheringNotificationUpdaterTest.kt | 3 ++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Tethering/src/com/android/networkstack/tethering/TetheringNotificationUpdater.java b/Tethering/src/com/android/networkstack/tethering/TetheringNotificationUpdater.java index ff83fd1e4f..de2f90e50e 100644 --- a/Tethering/src/com/android/networkstack/tethering/TetheringNotificationUpdater.java +++ b/Tethering/src/com/android/networkstack/tethering/TetheringNotificationUpdater.java @@ -50,9 +50,6 @@ import androidx.annotation.Nullable; import com.android.internal.annotations.VisibleForTesting; -import java.util.Arrays; -import java.util.List; - /** * A class to display tethering-related notifications. * @@ -89,6 +86,9 @@ public class TetheringNotificationUpdater { static final int NO_ICON_ID = 0; @VisibleForTesting static final int DOWNSTREAM_NONE = 0; + // Refer to TelephonyManager#getSimCarrierId for more details about carrier id. + @VisibleForTesting + static final int VERIZON_CARRIER_ID = 1839; private final Context mContext; private final NotificationManager mNotificationManager; private final NotificationChannel mChannel; @@ -114,11 +114,11 @@ public class TetheringNotificationUpdater { @interface NotificationId {} private static final class MccMncOverrideInfo { - public final List visitedMccMncs; + public final String visitedMccMnc; public final int homeMcc; public final int homeMnc; - MccMncOverrideInfo(List visitedMccMncs, int mcc, int mnc) { - this.visitedMccMncs = visitedMccMncs; + MccMncOverrideInfo(String visitedMccMnc, int mcc, int mnc) { + this.visitedMccMnc = visitedMccMnc; this.homeMcc = mcc; this.homeMnc = mnc; } @@ -127,9 +127,7 @@ public class TetheringNotificationUpdater { private static final SparseArray sCarrierIdToMccMnc = new SparseArray<>(); static { - // VZW - sCarrierIdToMccMnc.put( - 1839, new MccMncOverrideInfo(Arrays.asList(new String[] {"20404"}), 311, 480)); + sCarrierIdToMccMnc.put(VERIZON_CARRIER_ID, new MccMncOverrideInfo("20404", 311, 480)); } public TetheringNotificationUpdater(@NonNull final Context context, @@ -200,7 +198,7 @@ public class TetheringNotificationUpdater { final int carrierId = tm.getSimCarrierId(); final String mccmnc = tm.getSimOperator(); final MccMncOverrideInfo overrideInfo = sCarrierIdToMccMnc.get(carrierId); - if (overrideInfo != null && overrideInfo.visitedMccMncs.contains(mccmnc)) { + if (overrideInfo != null && overrideInfo.visitedMccMnc.equals(mccmnc)) { // Re-configure MCC/MNC value to specific carrier to get right resources. final Configuration config = res.getConfiguration(); config.mcc = overrideInfo.homeMcc; diff --git a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringNotificationUpdaterTest.kt b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringNotificationUpdaterTest.kt index 5f8858857c..294bf1b7e1 100644 --- a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringNotificationUpdaterTest.kt +++ b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringNotificationUpdaterTest.kt @@ -39,6 +39,7 @@ import com.android.networkstack.tethering.TetheringNotificationUpdater.ENABLE_NO import com.android.networkstack.tethering.TetheringNotificationUpdater.EVENT_SHOW_NO_UPSTREAM import com.android.networkstack.tethering.TetheringNotificationUpdater.NO_UPSTREAM_NOTIFICATION_ID import com.android.networkstack.tethering.TetheringNotificationUpdater.RESTRICTED_NOTIFICATION_ID +import com.android.networkstack.tethering.TetheringNotificationUpdater.VERIZON_CARRIER_ID import com.android.testutils.waitForIdle import org.junit.After import org.junit.Assert.assertEquals @@ -417,7 +418,7 @@ class TetheringNotificationUpdaterTest { assertEquals(config.mcc, res.configuration.mcc) assertEquals(config.mnc, res.configuration.mnc) - doReturn(1839).`when`(telephonyManager).getSimCarrierId() + doReturn(VERIZON_CARRIER_ID).`when`(telephonyManager).getSimCarrierId() res = notificationUpdater.getResourcesForSubId(context, subId) assertEquals(config.mcc, res.configuration.mcc) assertEquals(config.mnc, res.configuration.mnc)