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

Commit f82ada69 authored by Shareef Ali's avatar Shareef Ali Committed by Gerrit Code Review
Browse files

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

This reverts commit 2bda0907.

Change-Id: If7782e6efdab19552e7891cc51e29880ffc778e8
parent 2bda0907
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;
@@ -150,6 +151,32 @@ public class IccCardProxy extends Handler implements IccCard {
                }
            }
            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();
        }
    }

@@ -247,6 +274,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);
@@ -275,6 +303,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);