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

Commit 7cb0c75c authored by Ashit Sood's avatar Ashit Sood Committed by Mengjun Leng
Browse files

Fix to load CarrierConfig after SUB is generated

- Currently CarrierConfig does not wait SUB READY
  to broadcast ACTION_CARRIER_CONFIG_CHANGED

- ImsPhoneCallTracker might get dummy SUB id that
  skips updating the cache

- Fix by waiting for SUB id to be generated before
  loading CarrierConfig

Bug: 112870294
Test: Manual test and Telephony unit sanity test

Change-Id: I62a30abed37d7b64c97111b84ab11e1cc531ae90
parent 3321d72b
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import android.telephony.ims.feature.ImsFeature;
import android.telephony.ims.feature.MmTelFeature;
import android.telephony.ims.stub.ImsConfigImplBase;
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
@@ -264,6 +265,21 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                }
            };

    private final OnSubscriptionsChangedListener mOnSubscriptionsChangedListener =
            new OnSubscriptionsChangedListener() {
                final AtomicInteger mPreviousSubId =
                        new AtomicInteger(SubscriptionManager.INVALID_SUBSCRIPTION_ID);

                @Override
                public void onSubscriptionsChanged() {
                    int subId = mPhone.getSubId();
                    if (mPreviousSubId.getAndSet(subId) != subId
                            && SubscriptionController.getInstance().isActiveSubId(subId)) {
                        cacheCarrierConfiguration(subId);
                    }
                }
            };

    //***** Constants

    static final int MAX_CONNECTIONS = 7;
@@ -713,6 +729,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        intentfilter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
        intentfilter.addAction(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
        mPhone.getContext().registerReceiver(mReceiver, intentfilter);
        SubscriptionManager.from(mPhone.getContext())
            .addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
        cacheCarrierConfiguration(mPhone.getSubId());

        mPhone.getDefaultPhone().registerForDataEnabledChanged(
@@ -854,6 +872,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        mPhone.getContext().unregisterReceiver(mReceiver);
        mPhone.getDefaultPhone().unregisterForDataEnabledChanged(this);
        mImsManagerConnector.disconnect();
        SubscriptionManager.from(mPhone.getContext())
            .removeOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
    }

    @Override