From 37ffc3a20fe4adcb54e0d9e7daca5bedf1b0d0df Mon Sep 17 00:00:00 2001 From: junyulai Date: Fri, 18 Mar 2022 11:18:55 +0800 Subject: [PATCH] Fix crash when MultipathPolicyTracker cannot get IMSI Catch the exception when cannot get IMSI to fix races that network establish/tear down is not in-sync with SIM. If this happens, this will be automatically recovered when the next onCapabilitiesChanged event fires. Test: FrameworksNetTests Fix: 212399727 Change-Id: I3877806c0f98d8e7e3a77df75738b1799e4b68d3 --- .../server/connectivity/MultipathPolicyTracker.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/MultipathPolicyTracker.java b/services/core/java/com/android/server/connectivity/MultipathPolicyTracker.java index 108e7bcb23bb5..b9efdf5516464 100644 --- a/services/core/java/com/android/server/connectivity/MultipathPolicyTracker.java +++ b/services/core/java/com/android/server/connectivity/MultipathPolicyTracker.java @@ -71,7 +71,6 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; -import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -222,8 +221,10 @@ public class MultipathPolicyTracker { "Can't get TelephonyManager for subId %d", mSubId)); } - subscriberId = Objects.requireNonNull(tele.getSubscriberId(), - "Null subscriber Id for subId " + mSubId); + subscriberId = tele.getSubscriberId(); + if (subscriberId == null) { + throw new IllegalStateException("Null subscriber Id for subId " + mSubId); + } mNetworkTemplate = new NetworkTemplate.Builder(NetworkTemplate.MATCH_MOBILE) .setSubscriberIds(Set.of(subscriberId)) .setMeteredness(NetworkStats.METERED_YES)