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

Commit 979e2e57 authored by Amit Mahajan's avatar Amit Mahajan Committed by android-build-merger
Browse files

Merge "Return MDN if available from RUIM." am: 67a9c7e9

am: fbba4e6c

Change-Id: I08b581870692a5d84dfea394de30d40cdea5ce4a
parents 6529537b fbba4e6c
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -190,8 +190,8 @@ public class ServiceStateTracker extends Handler {
    private int mPendingRadioPowerOffAfterDataOffTag = 0;

    // This is a flag for debug purposes only. It it set once the RUIM_RECORDS_LOADED event is
    // received while the phone type is CDMA-LTE, and is never reset after that.
    private boolean mRuimRecordsLoaded = false;
    // received and RUIM is provisioned while the phone type is CDMA-LTE.
    private boolean mRuimProvisionedRecordsLoaded = false;

    /** Signal strength poll rate. */
    private static final int POLL_PERIOD_MILLIS = 20 * 1000;
@@ -632,7 +632,7 @@ public class ServiceStateTracker extends Handler {
        mNitzState.handleNetworkCountryCodeUnavailable();
        mCellIdentity = null;
        mNewCellIdentity = null;
        mRuimRecordsLoaded = false;
        mRuimProvisionedRecordsLoaded = false;

        //cancel any pending pollstate request on voice tech switching
        cancelPollState();
@@ -1000,6 +1000,7 @@ public class ServiceStateTracker extends Handler {
                    cancelAllNotifications();
                    // clear cached values on SIM removal
                    mMdn = null;
                    mRuimProvisionedRecordsLoaded = false;
                    logMdnChange("EVENT_ICC_CHANGED: setting mMdn to null");
                    mMin = null;
                    mIsMinInfoReady = false;
@@ -1393,9 +1394,9 @@ public class ServiceStateTracker extends Handler {
                        updateSpnDisplay();
                    } else {
                        RuimRecords ruim = (RuimRecords) mIccRecords;
                        mRuimRecordsLoaded = true;
                        if (ruim != null) {
                            if (ruim.isProvisioned()) {
                                mRuimProvisionedRecordsLoaded = true;
                                mMdn = ruim.getMdn();
                                logMdnChange("EVENT_RUIM_RECORDS_LOADED: setting mMdn to " + mMdn);
                                mMin = ruim.getMin();
@@ -1551,16 +1552,17 @@ public class ServiceStateTracker extends Handler {
    }

    public String getMdnNumber() {
        // if for CDMA-LTE phone MDN is null, and it has already been updated from RUIM, in some
        // unknown error scenario mMdn may still have been updated to null. Detect and fix that case
        if (mMdn == null && mRuimRecordsLoaded && mPhone.isPhoneTypeCdmaLte()) {
            // query RuimRecords to see if it's not null and the value from there can be used. This
            // should never be the case except in certain error scenarios/race conditions.
        String mdn = mMdn;
        // if for CDMA-LTE phone MDN is null, return the value from RuimRecords
        if (mMdn == null && mPhone.isPhoneTypeCdmaLte()) {
            RuimRecords ruim = (RuimRecords) mIccRecords;
            if (ruim != null) {
                if (ruim.isProvisioned() && ruim.getMdn() != null) {
            if (ruim != null && ruim.getMdn() != null) {
                logeMdnChange("getMdnNumber: mMdn is null when RuimRecords.getMdn() is not");
                mdn = ruim.getMdn();

                // if mRuimProvisionedRecordsLoaded is true, then mMdn should not have been null and
                // we should not have reached here. Update mMdn and catch the error scenario.
                if (mRuimProvisionedRecordsLoaded) {
                    // broadcast intent to indicate an error related to Line1Number has been
                    // detected
                    Intent intent = new Intent(TelephonyIntents.ACTION_LINE1_NUMBER_ERROR_DETECTED);
@@ -1568,12 +1570,11 @@ public class ServiceStateTracker extends Handler {
                    mPhone.getContext().sendBroadcast(intent,
                            permission.READ_PRIVILEGED_PHONE_STATE);

                    // update mdn
                    mMdn = ruim.getMdn();
                    mMdn = mdn;
                }
            }
        }
        return mMdn;
        return mdn;
    }

    public String getCdmaMin() {
+2 −5
Original line number Diff line number Diff line
@@ -1811,14 +1811,11 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        doReturn(true).when(mRuimRecords).isProvisioned();
        assertEquals(null, sst.getMdnNumber());

        // if ruim is not provisioned, and mdn is non null, sst should still return null
        // if ruim is not provisioned, and mdn is non null, sst should still return the correct
        // value
        doReturn(false).when(mRuimRecords).isProvisioned();
        String mockMdn = "mockMdn";
        doReturn(mockMdn).when(mRuimRecords).getMdn();
        assertEquals(null, sst.getMdnNumber());

        // if ruim is provisioned, and mdn is non null, sst should also return the correct value
        doReturn(true).when(mRuimRecords).isProvisioned();
        assertEquals(mockMdn, sst.getMdnNumber());
    }