Skip RAT type listener registration if IMSI is not available
Currently, if SIM is inserted but IMSI is not available, such as SIM PIN locked state. Information of such SIM will still be available but IMSI is not. Which makes NetworkStatsSubscriptionMonitor failed to store IMSI locally for later RAT type query. Hence, NETWORK_TYPE_UNKNOWN is always returned for such SIM. Skip the registration until the IMSI is available. This is safe since there will be another onSubscriptionsChanged event when that happens. Test: enable SIM PIN and manually test Test: atest NetworkStatsSubscriptionsMonitorTest#testSubscriberIdUnavailable Test: ./out/host/linux-x86/bin/statsd_testdrive 10082 Bug: 160941101 Merged-In: I408379b3c432d9e62e0837d6b4f6551cc7838e29 Change-Id: I408379b3c432d9e62e0837d6b4f6551cc7838e29 (cherry-picked from ag/12400327)
This commit is contained in:
@@ -100,11 +100,16 @@ public class NetworkStatsSubscriptionsMonitor extends
|
|||||||
if (match != null) continue;
|
if (match != null) continue;
|
||||||
|
|
||||||
// Create listener for every newly added sub. Also store subscriberId into it to
|
// Create listener for every newly added sub. Also store subscriberId into it to
|
||||||
// prevent binder call to telephony when querying RAT.
|
// prevent binder call to telephony when querying RAT. If the subscriberId is empty
|
||||||
|
// for any reason, such as SIM PIN locked, skip registration.
|
||||||
|
// SubscriberId will be unavailable again if 1. modem crashed 2. reboot
|
||||||
|
// 3. re-insert SIM. If that happens, the listeners will be eventually synchronized
|
||||||
|
// with active sub list once all subscriberIds are ready.
|
||||||
final String subscriberId = mTeleManager.getSubscriberId(subId);
|
final String subscriberId = mTeleManager.getSubscriberId(subId);
|
||||||
if (TextUtils.isEmpty(subscriberId)) {
|
if (TextUtils.isEmpty(subscriberId)) {
|
||||||
Log.wtf(NetworkStatsService.TAG,
|
Log.d(NetworkStatsService.TAG, "Empty subscriberId for newly added sub "
|
||||||
"Empty subscriberId for newly added sub: " + subId);
|
+ subId + ", skip listener registration");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
final RatTypeListener listener =
|
final RatTypeListener listener =
|
||||||
new RatTypeListener(mExecutor, this, subId, subscriberId);
|
new RatTypeListener(mExecutor, this, subId, subscriberId);
|
||||||
@@ -113,6 +118,7 @@ public class NetworkStatsSubscriptionsMonitor extends
|
|||||||
// Register listener to the telephony manager that associated with specific sub.
|
// Register listener to the telephony manager that associated with specific sub.
|
||||||
mTeleManager.createForSubscriptionId(subId)
|
mTeleManager.createForSubscriptionId(subId)
|
||||||
.listen(listener, PhoneStateListener.LISTEN_SERVICE_STATE);
|
.listen(listener, PhoneStateListener.LISTEN_SERVICE_STATE);
|
||||||
|
Log.d(NetworkStatsService.TAG, "RAT type listener registered for sub " + subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final RatTypeListener listener : new ArrayList<>(mRatListeners)) {
|
for (final RatTypeListener listener : new ArrayList<>(mRatListeners)) {
|
||||||
@@ -165,6 +171,7 @@ public class NetworkStatsSubscriptionsMonitor extends
|
|||||||
private void handleRemoveRatTypeListener(@NonNull RatTypeListener listener) {
|
private void handleRemoveRatTypeListener(@NonNull RatTypeListener listener) {
|
||||||
mTeleManager.createForSubscriptionId(listener.mSubId)
|
mTeleManager.createForSubscriptionId(listener.mSubId)
|
||||||
.listen(listener, PhoneStateListener.LISTEN_NONE);
|
.listen(listener, PhoneStateListener.LISTEN_NONE);
|
||||||
|
Log.d(NetworkStatsService.TAG, "RAT type listener unregistered for sub " + listener.mSubId);
|
||||||
mRatListeners.remove(listener);
|
mRatListeners.remove(listener);
|
||||||
|
|
||||||
// Removal of subscriptions doesn't generate RAT changed event, fire it for every
|
// Removal of subscriptions doesn't generate RAT changed event, fire it for every
|
||||||
|
|||||||
Reference in New Issue
Block a user