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
This commit is contained in:
junyulai
2022-03-18 11:18:55 +08:00
parent e2b00d3a7d
commit 37ffc3a20f

View File

@@ -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)