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

Commit 6542c6ec authored by Jordan Liu's avatar Jordan Liu Committed by Android (Google) Code Review
Browse files

Merge "Send placeholder OOS ServiceState when subId goes invalid" into rvc-qpr-dev

parents 50fcf366 8a7a2464
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -72,11 +72,14 @@ public class DefaultPhoneNotifier implements PhoneNotifier {


    @Override
    @Override
    public void notifyServiceState(Phone sender) {
    public void notifyServiceState(Phone sender) {
        ServiceState ss = sender.getServiceState();
        notifyServiceStateForSubId(sender, sender.getServiceState(), sender.getSubId());
    }

    @Override
    public void notifyServiceStateForSubId(Phone sender, ServiceState ss, int subId) {
        int phoneId = sender.getPhoneId();
        int phoneId = sender.getPhoneId();
        int subId = sender.getSubId();


        Rlog.d(LOG_TAG, "notifyServiceState: mRegistryMgr=" + mTelephonyRegistryMgr + " ss="
        Rlog.d(LOG_TAG, "notifyServiceStateForSubId: mRegistryMgr=" + mTelephonyRegistryMgr + " ss="
                + ss + " sender=" + sender + " phondId=" + phoneId + " subId=" + subId);
                + ss + " sender=" + sender + " phondId=" + phoneId + " subId=" + subId);
        if (ss == null) {
        if (ss == null) {
            ss = new ServiceState();
            ss = new ServiceState();
+4 −0
Original line number Original line Diff line number Diff line
@@ -848,6 +848,10 @@ public class GsmCdmaPhone extends Phone {
        super.notifyServiceStateChangedP(ss);
        super.notifyServiceStateChangedP(ss);
    }
    }


    void notifyServiceStateChangedForSubId(ServiceState ss, int subId) {
        super.notifyServiceStateChangedPForSubId(ss, subId);
    }

    /**
    /**
     * Notify that the cell location has changed.
     * Notify that the cell location has changed.
     *
     *
+11 −0
Original line number Original line Diff line number Diff line
@@ -1695,6 +1695,17 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        mNotifier.notifyServiceState(this);
        mNotifier.notifyServiceState(this);
    }
    }


    /**
     * Version of notifyServiceStateChangedP which allows us to specify the subId. This is used when
     * we send out a final ServiceState update when a phone's subId becomes invalid.
     */
    protected void notifyServiceStateChangedPForSubId(ServiceState ss, int subId) {
        AsyncResult ar = new AsyncResult(null, ss, null);
        mServiceStateRegistrants.notifyRegistrants(ar);

        mNotifier.notifyServiceStateForSubId(this, ss, subId);
    }

    /**
    /**
     * If this is a simulated phone interface, returns a SimulatedRadioControl.
     * If this is a simulated phone interface, returns a SimulatedRadioControl.
     * @return SimulatedRadioControl if this is a simulated interface;
     * @return SimulatedRadioControl if this is a simulated interface;
+12 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import android.telephony.CellIdentity;
import android.telephony.CellInfo;
import android.telephony.CellInfo;
import android.telephony.PhoneCapability;
import android.telephony.PhoneCapability;
import android.telephony.PreciseDataConnectionState;
import android.telephony.PreciseDataConnectionState;
import android.telephony.ServiceState;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsReasonInfo;
@@ -40,8 +41,19 @@ public interface PhoneNotifier {


    void notifyPhoneState(Phone sender);
    void notifyPhoneState(Phone sender);


    /**
     * Notify registrants of the given phone's current ServiceState.
     */
    void notifyServiceState(Phone sender);
    void notifyServiceState(Phone sender);


    /**
     * Notify registrants with a given ServiceState. Passing in the subId allows us to
     * send a final ServiceState update when the subId for the sender phone becomes invalid
     * @param sender
     * @param subId
     */
    void notifyServiceStateForSubId(Phone sender, ServiceState ss, int subId);

    /**
    /**
     * Notify registrants of the current CellLocation.
     * Notify registrants of the current CellLocation.
     *
     *
+15 −0
Original line number Original line Diff line number Diff line
@@ -160,6 +160,10 @@ public class ServiceStateTracker extends Handler {
    public ServiceState mSS;
    public ServiceState mSS;
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    private ServiceState mNewSS;
    private ServiceState mNewSS;
    // A placeholder service state which will always be out of service. This is broadcast to
    // listeners when the subscription ID for a phone becomes invalid so that they get a final
    // state update.
    private final ServiceState mOutOfServiceSS;


    // This is the minimum interval at which CellInfo requests will be serviced by the modem.
    // This is the minimum interval at which CellInfo requests will be serviced by the modem.
    // Any requests that arrive within MinInterval of the previous reuqest will simply receive the
    // Any requests that arrive within MinInterval of the previous reuqest will simply receive the
@@ -439,6 +443,14 @@ public class ServiceStateTracker extends Handler {
                    // displayed on the UI again. The old SPN update intents sent to
                    // displayed on the UI again. The old SPN update intents sent to
                    // MobileSignalController earlier were actually ignored due to invalid sub id.
                    // MobileSignalController earlier were actually ignored due to invalid sub id.
                    updateSpnDisplay();
                    updateSpnDisplay();
                } else {
                    if (SubscriptionManager.isValidSubscriptionId(
                            ServiceStateTracker.this.mPrevSubId)) {
                        // just went from valid to invalid subId, so notify phone state listeners
                        // with final broadcast
                        mPhone.notifyServiceStateChangedForSubId(mOutOfServiceSS,
                                ServiceStateTracker.this.mPrevSubId);
                    }
                }
                }
                // update voicemail count and notify message waiting changed
                // update voicemail count and notify message waiting changed
                mPhone.updateVoiceMail();
                mPhone.updateVoiceMail();
@@ -631,6 +643,9 @@ public class ServiceStateTracker extends Handler {
                .isVoiceCapable();
                .isVoiceCapable();
        mUiccController = UiccController.getInstance();
        mUiccController = UiccController.getInstance();


        mOutOfServiceSS = new ServiceState();
        mOutOfServiceSS.setStateOutOfService();

        mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
        mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
        mCi.setOnSignalStrengthUpdate(this, EVENT_SIGNAL_STRENGTH_UPDATE, null);
        mCi.setOnSignalStrengthUpdate(this, EVENT_SIGNAL_STRENGTH_UPDATE, null);
        mCi.registerForCellInfoList(this, EVENT_UNSOL_CELL_INFO_LIST, null);
        mCi.registerForCellInfoList(this, EVENT_UNSOL_CELL_INFO_LIST, null);