Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6d1814c authored by Xiangyu/Malcolm Chen's avatar Xiangyu/Malcolm Chen Committed by Automerger Merge Worker
Browse files

Merge "Fix bug that notifyDisplayInfoChanged is notified on wrong record" am: 5821bbc6

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1331803

Change-Id: I27caffd81ca9c1a9579831e35d5bf971ee69e7e9
parents 15b0dc5e 5821bbc6
Loading
Loading
Loading
Loading
+19 −1
Original line number Original line Diff line number Diff line
@@ -1605,7 +1605,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                for (Record r : mRecords) {
                for (Record r : mRecords) {
                    if (r.matchPhoneStateListenerEvent(
                    if (r.matchPhoneStateListenerEvent(
                            PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED)
                            PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED)
                            && idMatch(r.subId, subId, phoneId)) {
                            && idMatchWithoutDefaultPhoneCheck(r.subId, subId)) {
                        try {
                        try {
                            r.callback.onDisplayInfoChanged(telephonyDisplayInfo);
                            r.callback.onDisplayInfoChanged(telephonyDisplayInfo);
                        } catch (RemoteException ex) {
                        } catch (RemoteException ex) {
@@ -2703,6 +2703,24 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
        Rlog.e(TAG, s);
        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) {
    boolean idMatch(int rSubId, int subId, int phoneId) {


        if(subId < 0) {
        if(subId < 0) {