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

Commit 79920f0f authored by Alan Wang's avatar Alan Wang Committed by Adnan Begovic
Browse files

Telephony: Don't read records from card if not needed.

Specifically handle the scenario where there is an RUIM card
 inserted but we are in NV mode. In this case, don't read
records from the card.
IccCardProxy tells the IccRecord that it will be requiring records
from the card. RuimRecord waits for this indication before fetching
records from the card
Change-Id: Ifa95dda2958922901e887b386c55556f947a881d
parent 2be66cb5
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.android.internal.telephony.uicc.IccCardApplicationStatus.PersoSubStat
import com.android.internal.telephony.uicc.IccCardStatus.CardState;
import com.android.internal.telephony.uicc.IccCardStatus.PinState;
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.uicc.RuimRecords;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -144,6 +145,32 @@ public class IccCardProxy extends Handler implements IccCard {
                mCurrentAppType = UiccController.APP_FAM_3GPP2;
            }
            updateQuietMode();
            updateActiveRecord();
        }
    }

    /**
     * This method sets the IccRecord, corresponding to the currently active
     * subscription, as the active record.
     */
    private void updateActiveRecord() {
        log("updateActiveRecord app type = " + mCurrentAppType +
                "mIccRecords = " + mIccRecords);

        if (mIccRecords == null) {
            return;
        }

        if (mCurrentAppType == UiccController.APP_FAM_3GPP2) {
            int newSubscriptionSource = mCdmaSSM.getCdmaSubscriptionSource();
            if (newSubscriptionSource == CdmaSubscriptionSourceManager.SUBSCRIPTION_FROM_RUIM) {
                // Set this as the Active record.
                log("Setting Ruim Record as active");
                mIccRecords.recordsRequired();
            }
        } else if (mCurrentAppType == UiccController.APP_FAM_3GPP) {
            log("Setting SIM Record as active");
            mIccRecords.recordsRequired();
        }
    }

@@ -237,6 +264,7 @@ public class IccCardProxy extends Handler implements IccCard {
                break;
            case EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED:
                updateQuietMode();
                updateActiveRecord();
                break;
            default:
                loge("Unhandled message with number: " + msg.what);
@@ -265,6 +293,7 @@ public class IccCardProxy extends Handler implements IccCard {
                mUiccApplication = newApp;
                mIccRecords = newRecords;
                registerUiccCardEvents();
                updateActiveRecord();
            }

            updateExternalState();
+14 −0
Original line number Diff line number Diff line
@@ -164,6 +164,20 @@ public abstract class IccRecords extends Handler implements IccConstants {
    public abstract void onReady();

    //***** Public Methods

    /*
     * Called to indicate that anyone could request records
     * in the future after this call, once records are loaded and registrants
     * have been notified. This indication could be used
     * to optimize when to actually fetch records from the card. We
     * don't need to fetch records from the card if it is of no use
     * to anyone
     *
     */
    void recordsRequired() {
        return;
    }

    public AdnRecordCache getAdnCache() {
        return mAdnCache;
    }
+30 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.internal.telephony.MccTable;

import com.android.internal.telephony.cdma.sms.UserData;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;


/**
@@ -57,6 +58,7 @@ public final class RuimRecords extends IccRecords {
    private String mMin2Min1;

    private String mPrlVersion;
    private boolean mRecordsRequired = false;
    // From CSIM application
    private byte[] mEFpl = null;
    private byte[] mEFli = null;
@@ -659,8 +661,36 @@ public final class RuimRecords extends IccRecords {
        mCi.getCDMASubscription(obtainMessage(EVENT_GET_CDMA_SUBSCRIPTION_DONE));
    }

    /**
     * Called by IccCardProxy before it requests records.
     * We use this as a trigger to read records from the card.
     */
    void recordsRequired() {
        if (DBG) log("recordsRequired");
        mRecordsRequired = true;

        // trigger to retrieve all records
        fetchRuimRecords();
    }

    private void fetchRuimRecords() {
        /* Don't read records if we don't expect
         * anyone to ask for them
         *
         * If we have already requested records OR
         * records are not required by anyone OR
         * the app is not ready
         * then bail
         */
        if (mRecordsRequested || !mRecordsRequired
            || AppState.APPSTATE_READY != mParentApp.getState()) {
            if (DBG) log("fetchRuimRecords: Abort fetching records rRecordsRequested = "
                            + mRecordsRequested
                            + " state = " + mParentApp.getState()
                            + " required = " + mRecordsRequired);
            return;
        }

        mRecordsRequested = true;

        if (DBG) log("fetchRuimRecords " + mRecordsToLoad);