diff options
| author | 2020-06-09 12:09:45 -0700 | |
|---|---|---|
| committer | 2020-06-10 22:08:04 +0000 | |
| commit | 2387cdee2cfa5a73c45f11f3451d8e7468d19250 (patch) | |
| tree | 554fe32d74c349a4d2f3b1efc7e25c03d404fc66 | |
| parent | 4181d96ab7dfa94cddb90f88291fcad3b8ca9d44 (diff) | |
Fix bug that notifyDisplayInfoChanged is notified on wrong record
In dual SIM mode, if a SIM is unplugged, there's a chance that
notifyDisplayInfoChanged is notified to registered client incorrectly.
Bug: 157039855
Test: manual - in dual SIM mode, when data is on eSIM, pull off pSIM.
Verify the rat icon of eSIM does NOT disappear.
Change-Id: I305ff855f0d5595be13b6ee4e4480abd89ed258f
| -rw-r--r-- | services/core/java/com/android/server/TelephonyRegistry.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 9080bdb44eaf..a3c164d63605 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -1606,7 +1606,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { for (Record r : mRecords) { if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED) - && idMatch(r.subId, subId, phoneId)) { + && idMatchWithoutDefaultPhoneCheck(r.subId, subId)) { try { r.callback.onDisplayInfoChanged(telephonyDisplayInfo); } catch (RemoteException ex) { @@ -2726,6 +2726,24 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { Rlog.e(TAG, s); } + /** + * If the registrant specified a subId, then we should only notify it if subIds match. + * If the registrant registered with DEFAULT subId, we should notify only when the related subId + * is default subId (which could be INVALID if there's no default subId). + * + * This should be the correct way to check record ID match. in idMatch the record's phoneId is + * speculated based on subId passed by the registrant so it's not a good reference. + * But to avoid triggering potential regression only replace idMatch with it when an issue with + * idMatch is reported. Eventually this should replace all instances of idMatch. + */ + private boolean idMatchWithoutDefaultPhoneCheck(int subIdInRecord, int subIdToNotify) { + if (subIdInRecord == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { + return (subIdToNotify == mDefaultSubId); + } else { + return (subIdInRecord == subIdToNotify); + } + } + boolean idMatch(int rSubId, int subId, int phoneId) { if(subId < 0) { |