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

Commit bb80a8a2 authored by Nathan Harold's avatar Nathan Harold Committed by Automerger Merge Worker
Browse files

Merge "SST - Remove Double-Cached Previous SubId" am: 5e7dddba am:...

Merge "SST - Remove Double-Cached Previous SubId" am: 5e7dddba am: b54dfad7 am: 688b9e54 am: 2723af90 am: 5781596b

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1357704

Change-Id: I8de7323ede96ac47881bb8e05101a829947f519b
parents d22aba74 5781596b
Loading
Loading
Loading
Loading
+73 −65
Original line number Original line Diff line number Diff line
@@ -126,7 +126,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.List;
import java.util.Set;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.regex.PatternSyntaxException;
@@ -369,8 +368,6 @@ public class ServiceStateTracker extends Handler {
    private Pattern mOperatorNameStringPattern;
    private Pattern mOperatorNameStringPattern;


    private class SstSubscriptionsChangedListener extends OnSubscriptionsChangedListener {
    private class SstSubscriptionsChangedListener extends OnSubscriptionsChangedListener {
        public final AtomicInteger mPreviousSubId =
                new AtomicInteger(SubscriptionManager.INVALID_SUBSCRIPTION_ID);


        /**
        /**
         * Callback invoked when there is any change to any SubscriptionInfo. Typically
         * Callback invoked when there is any change to any SubscriptionInfo. Typically
@@ -379,19 +376,36 @@ public class ServiceStateTracker extends Handler {
        @Override
        @Override
        public void onSubscriptionsChanged() {
        public void onSubscriptionsChanged() {
            if (DBG) log("SubscriptionListener.onSubscriptionInfoChanged");
            if (DBG) log("SubscriptionListener.onSubscriptionInfoChanged");
            // Set the network type, in case the radio does not restore it.

            int subId = mPhone.getSubId();
            final int curSubId = mPhone.getSubId();
            ServiceStateTracker.this.mPrevSubId = mPreviousSubId.get();

            if (mPreviousSubId.getAndSet(subId) != subId) {
            // If the sub info changed, but the subId is the same, then we're done.
                if (SubscriptionManager.isValidSubscriptionId(subId)) {
            if (mSubId == curSubId) return;

            // If not, then the subId has changed, so we need to remember the old subId,
            // even if the new subId is invalid (likely).
            mPrevSubId = mSubId;
            mSubId = curSubId;

            // Update voicemail count and notify message waiting changed regardless of
            // whether the new subId is valid. This is an exception to the general logic
            // of only updating things if the new subscription is valid. The result is that
            // VoiceMail counts (and UI indicators) are cleared when the SIM is removed,
            // which seems desirable.
            mPhone.updateVoiceMail();

            // If the new subscription ID isn't valid, then we don't need to do all the
            // UI updating, so we're done.
            if (!SubscriptionManager.isValidSubscriptionId(mSubId)) return;

            Context context = mPhone.getContext();
            Context context = mPhone.getContext();


            mPhone.notifyPhoneStateChanged();
            mPhone.notifyPhoneStateChanged();
            mPhone.notifyCallForwardingIndicator();
            mPhone.notifyCallForwardingIndicator();
                    if (!SubscriptionManager.isValidSubscriptionId(

                            ServiceStateTracker.this.mPrevSubId)) {
            if (!SubscriptionManager.isValidSubscriptionId(mPrevSubId)) {
                // just went from invalid to valid subId, so notify with current service
                // just went from invalid to valid subId, so notify with current service
                        // state in case our service stat was never broadcasted (we don't notify
                // state in case our service state was never broadcasted (we don't notify
                // service states when the subId is invalid)
                // service states when the subId is invalid)
                mPhone.notifyServiceStateChanged(mSS);
                mPhone.notifyServiceStateChanged(mSS);
            }
            }
@@ -419,15 +433,15 @@ public class ServiceStateTracker extends Handler {
                    Phone.NETWORK_SELECTION_NAME_KEY, "");
                    Phone.NETWORK_SELECTION_NAME_KEY, "");
            String oldNetworkSelectionShort = sp.getString(
            String oldNetworkSelectionShort = sp.getString(
                    Phone.NETWORK_SELECTION_SHORT_KEY, "");
                    Phone.NETWORK_SELECTION_SHORT_KEY, "");
                    if (!TextUtils.isEmpty(oldNetworkSelection) ||
            if (!TextUtils.isEmpty(oldNetworkSelection)
                            !TextUtils.isEmpty(oldNetworkSelectionName) ||
                    || !TextUtils.isEmpty(oldNetworkSelectionName)
                            !TextUtils.isEmpty(oldNetworkSelectionShort)) {
                    || !TextUtils.isEmpty(oldNetworkSelectionShort)) {
                SharedPreferences.Editor editor = sp.edit();
                SharedPreferences.Editor editor = sp.edit();
                        editor.putString(Phone.NETWORK_SELECTION_KEY + subId,
                editor.putString(Phone.NETWORK_SELECTION_KEY + mSubId,
                        oldNetworkSelection);
                        oldNetworkSelection);
                        editor.putString(Phone.NETWORK_SELECTION_NAME_KEY + subId,
                editor.putString(Phone.NETWORK_SELECTION_NAME_KEY + mSubId,
                        oldNetworkSelectionName);
                        oldNetworkSelectionName);
                        editor.putString(Phone.NETWORK_SELECTION_SHORT_KEY + subId,
                editor.putString(Phone.NETWORK_SELECTION_SHORT_KEY + mSubId,
                        oldNetworkSelectionShort);
                        oldNetworkSelectionShort);
                editor.remove(Phone.NETWORK_SELECTION_KEY);
                editor.remove(Phone.NETWORK_SELECTION_KEY);
                editor.remove(Phone.NETWORK_SELECTION_NAME_KEY);
                editor.remove(Phone.NETWORK_SELECTION_NAME_KEY);
@@ -440,10 +454,6 @@ public class ServiceStateTracker extends Handler {
            // MobileSignalController earlier were actually ignored due to invalid sub id.
            // MobileSignalController earlier were actually ignored due to invalid sub id.
            updateSpnDisplay();
            updateSpnDisplay();
        }
        }
                // update voicemail count and notify message waiting changed
                mPhone.updateVoiceMail();
            }
        }
    };
    };


    //Common
    //Common
@@ -630,8 +640,8 @@ public class ServiceStateTracker extends Handler {


        mSubscriptionController = SubscriptionController.getInstance();
        mSubscriptionController = SubscriptionController.getInstance();
        mSubscriptionManager = SubscriptionManager.from(phone.getContext());
        mSubscriptionManager = SubscriptionManager.from(phone.getContext());
        mSubscriptionManager
        mSubscriptionManager.addOnSubscriptionsChangedListener(
                .addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
                new android.os.HandlerExecutor(this), mOnSubscriptionsChangedListener);
        mRestrictedState = new RestrictedState();
        mRestrictedState = new RestrictedState();


        mTransportManager = mPhone.getTransportManager();
        mTransportManager = mPhone.getTransportManager();
@@ -1251,10 +1261,8 @@ public class ServiceStateTracker extends Handler {


            // GSM
            // GSM
            case EVENT_SIM_READY:
            case EVENT_SIM_READY:
                // Reset the mPreviousSubId so we treat a SIM power bounce
                // Reset the mPrevSubId so we treat a SIM power bounce
                // as a first boot.  See b/19194287
                // as a first boot.  See b/19194287
                mOnSubscriptionsChangedListener.mPreviousSubId.set(
                        SubscriptionManager.INVALID_SUBSCRIPTION_ID);
                mPrevSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
                mPrevSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
                mIsSimReady = true;
                mIsSimReady = true;
                pollStateInternal(false);
                pollStateInternal(false);