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

Commit f2fbd2ed authored by Wink Saville's avatar Wink Saville Committed by Android (Google) Code Review
Browse files

Merge "Telephony: Make IccFileHandler use ci instead of phone"

parents 2e76c992 2b75d12a
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -186,10 +186,12 @@ public class IccCard {
        if (phone.mCM.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE
                && phone instanceof CDMALTEPhone) {
            mIccRecords = new CdmaLteUiccRecords(phone);
            mIccFileHandler = new CdmaLteUiccFileHandler((CDMALTEPhone)phone);
            mIccFileHandler = new CdmaLteUiccFileHandler(this, "", mPhone.mCM);
        } else {
            mIccRecords = is3gpp ? new SIMRecords(phone) : new RuimRecords(phone);
            mIccFileHandler = is3gpp ? new SIMFileHandler(phone) : new RuimFileHandler(phone);
            // Correct aid will be set later (when GET_SIM_STATUS returns)
            mIccFileHandler = is3gpp ? new SIMFileHandler(this, "", mPhone.mCM) :
                                       new RuimFileHandler(this, "", mPhone.mCM);
        }
        mPhone.mCM.registerForOffOrNotAvailable(mHandler, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
        mPhone.mCM.registerForOn(mHandler, EVENT_RADIO_ON, null);
@@ -572,6 +574,7 @@ public class IccCard {
        }

        if (oldState != State.READY && newState == State.READY) {
            mIccFileHandler.setAid(getAid());
            mIccRecords.onReady();
        }
    }
+32 −36
Original line number Diff line number Diff line
@@ -90,7 +90,9 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
    static protected final int EVENT_READ_ICON_DONE = 10;

     // member variables
    protected PhoneBase phone;
    protected final CommandsInterface mCi;
    protected final IccCard mParentCard;
    protected String mAid;

    static class LoadLinearFixedContext {

@@ -120,9 +122,10 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
    /**
     * Default constructor
     */
    protected IccFileHandler(PhoneBase phone) {
        super();
        this.phone = phone;
    protected IccFileHandler(IccCard card, String aid, CommandsInterface ci) {
        mParentCard = card;
        mAid = aid;
        mCi = ci;
    }

    public void dispose() {
@@ -145,9 +148,8 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
            = obtainMessage(EVENT_GET_RECORD_SIZE_DONE,
                        new LoadLinearFixedContext(fileid, recordNum, onLoaded));

        phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null,
                        phone.getIccCard().getAid(), response);
        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
    }

    /**
@@ -165,10 +167,9 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                        onLoaded));

        // TODO(): Verify when path changes are done.
        phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, IccConstants.EF_IMG, "img",
        mCi.iccIOForApp(COMMAND_GET_RESPONSE, IccConstants.EF_IMG, "img",
                recordNum, READ_RECORD_MODE_ABSOLUTE,
                GET_RESPONSE_EF_IMG_SIZE_BYTES, null, null,
                phone.getIccCard().getAid(), response);
                GET_RESPONSE_EF_IMG_SIZE_BYTES, null, null, mAid, response);
    }

    /**
@@ -184,9 +185,8 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
        Message response
                = obtainMessage(EVENT_GET_EF_LINEAR_RECORD_SIZE_DONE,
                        new LoadLinearFixedContext(fileid, onLoaded));
        phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                    0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, phone.getIccCard().getAid(),
                    response);
        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                    0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
    }

    /**
@@ -202,9 +202,8 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
        Message response = obtainMessage(EVENT_GET_RECORD_SIZE_DONE,
                        new LoadLinearFixedContext(fileid,onLoaded));

        phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null,
                        phone.getIccCard().getAid(), response);
        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
    }

    /**
@@ -221,9 +220,8 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
        Message response = obtainMessage(EVENT_GET_BINARY_SIZE_DONE,
                        fileid, 0, onLoaded);

        phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null,
                        phone.getIccCard().getAid(), response);
        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
    }

    /**
@@ -241,8 +239,8 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
        Message response = obtainMessage(EVENT_READ_ICON_DONE, fileid, 0,
                onLoaded);

        phone.mCM.iccIOForApp(COMMAND_READ_BINARY, fileid, "img", highOffset, lowOffset,
                length, null, null, phone.getIccCard().getAid(), response);
        mCi.iccIOForApp(COMMAND_READ_BINARY, fileid, "img", highOffset, lowOffset,
                length, null, null, mAid, response);
    }

    /**
@@ -256,10 +254,9 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
     */
    public void updateEFLinearFixed(int fileid, int recordNum, byte[] data,
            String pin2, Message onComplete) {
        phone.mCM.iccIOForApp(COMMAND_UPDATE_RECORD, fileid, getEFPath(fileid),
        mCi.iccIOForApp(COMMAND_UPDATE_RECORD, fileid, getEFPath(fileid),
                        recordNum, READ_RECORD_MODE_ABSOLUTE, data.length,
                        IccUtils.bytesToHexString(data), pin2,
                        phone.getIccCard().getAid(), onComplete);
                        IccUtils.bytesToHexString(data), pin2, mAid, onComplete);
    }

    /**
@@ -268,10 +265,9 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
     * @param data must be exactly as long as the EF
     */
    public void updateEFTransparent(int fileid, byte[] data, Message onComplete) {
        phone.mCM.iccIOForApp(COMMAND_UPDATE_BINARY, fileid, getEFPath(fileid),
        mCi.iccIOForApp(COMMAND_UPDATE_BINARY, fileid, getEFPath(fileid),
                        0, 0, data.length,
                        IccUtils.bytesToHexString(data), null,
                        phone.getIccCard().getAid(), onComplete);
                        IccUtils.bytesToHexString(data), null, mAid, onComplete);
    }


@@ -402,11 +398,10 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                     lc.results = new ArrayList<byte[]>(lc.countRecords);
                 }

                 phone.mCM.iccIOForApp(COMMAND_READ_RECORD, lc.efid, getEFPath(lc.efid),
                 mCi.iccIOForApp(COMMAND_READ_RECORD, lc.efid, getEFPath(lc.efid),
                         lc.recordNum,
                         READ_RECORD_MODE_ABSOLUTE,
                         lc.recordSize, null, null,
                         phone.getIccCard().getAid(),
                         lc.recordSize, null, null, mAid,
                         obtainMessage(EVENT_READ_RECORD_DONE, lc));
                 break;
            case EVENT_GET_BINARY_SIZE_DONE:
@@ -441,9 +436,8 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                size = ((data[RESPONSE_DATA_FILE_SIZE_1] & 0xff) << 8)
                       + (data[RESPONSE_DATA_FILE_SIZE_2] & 0xff);

                phone.mCM.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
                                0, 0, size, null, null,
                                phone.getIccCard().getAid(),
                mCi.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
                                0, 0, size, null, null, mAid,
                                obtainMessage(EVENT_READ_BINARY_DONE,
                                              fileid, 0, response));
            break;
@@ -477,11 +471,10 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                    if (lc.recordNum > lc.countRecords) {
                        sendResult(response, lc.results, null);
                    } else {
                        phone.mCM.iccIOForApp(COMMAND_READ_RECORD, lc.efid, getEFPath(lc.efid),
                        mCi.iccIOForApp(COMMAND_READ_RECORD, lc.efid, getEFPath(lc.efid),
                                    lc.recordNum,
                                    READ_RECORD_MODE_ABSOLUTE,
                                    lc.recordSize, null, null,
                                    phone.getIccCard().getAid(),
                                    lc.recordSize, null, null, mAid,
                                    obtainMessage(EVENT_READ_RECORD_DONE, lc));
                    }
                }
@@ -551,5 +544,8 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
    protected abstract void logd(String s);

    protected abstract void loge(String s);
    protected void setAid(String aid) {
        mAid = aid;
    }

}
+7 −4
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@
package com.android.internal.telephony.cdma;

import android.util.Log;

import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.IccConstants;
import com.android.internal.telephony.IccFileHandler;
import android.os.Message;
@@ -27,8 +30,8 @@ import android.os.Message;
public final class CdmaLteUiccFileHandler extends IccFileHandler {
    static final String LOG_TAG = "CDMA";

    public CdmaLteUiccFileHandler(CDMALTEPhone phone) {
        super(phone);
    public CdmaLteUiccFileHandler(IccCard card, String aid, CommandsInterface ci) {
        super(card, aid, ci);
    }

    protected String getEFPath(int efid) {
@@ -55,8 +58,8 @@ public final class CdmaLteUiccFileHandler extends IccFileHandler {
        if (fileid == EF_CSIM_EPRL) {
            // Entire PRL could be huge. We are only interested in
            // the first 4 bytes of the record.
            phone.mCM.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
                            0, 0, 4, null, null, phone.getIccCard().getAid(),
            mCi.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
                            0, 0, 4, null, null, mAid,
                            obtainMessage(EVENT_READ_BINARY_DONE,
                                          fileid, 0, onLoaded));
        } else {
+6 −4
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.internal.telephony.cdma;
import android.os.*;
import android.util.Log;

import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.IccConstants;
import com.android.internal.telephony.IccException;
import com.android.internal.telephony.IccFileHandler;
@@ -39,8 +41,8 @@ public final class RuimFileHandler extends IccFileHandler {
    //***** Instance Variables

    //***** Constructor
    public RuimFileHandler(PhoneBase phone) {
        super(phone);
    public RuimFileHandler(IccCard card, String aid, CommandsInterface ci) {
        super(card, aid, ci);
    }

    public void dispose() {
@@ -58,9 +60,9 @@ public final class RuimFileHandler extends IccFileHandler {
        Message response = obtainMessage(EVENT_READ_ICON_DONE, fileid, 0,
                onLoaded);

        phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, "img", 0, 0,
        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, "img", 0, 0,
                GET_RESPONSE_EF_IMG_SIZE_BYTES, null, null,
                phone.getIccCard().getAid(), response);
                mAid, response);
    }

    @Override
+5 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.internal.telephony.gsm;
import android.os.Message;
import android.util.Log;

import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.IccCardApplication;
import com.android.internal.telephony.IccConstants;
@@ -35,8 +36,8 @@ public final class SIMFileHandler extends IccFileHandler implements IccConstants

    //***** Constructor

    public SIMFileHandler(PhoneBase phone) {
        super(phone);
    public SIMFileHandler(IccCard card, String aid, CommandsInterface ci) {
        super(card, aid, ci);
    }

    public void dispose() {
@@ -91,8 +92,8 @@ public final class SIMFileHandler extends IccFileHandler implements IccConstants
            // The EFids in USIM phone book entries are decided by the card manufacturer.
            // So if we don't match any of the cases above and if its a USIM return
            // the phone book path.
            IccCard card = phone.getIccCard();
            if (card != null && card.isApplicationOnIcc(IccCardApplication.AppType.APPTYPE_USIM)) {
            if (mParentCard != null
                    && mParentCard.isApplicationOnIcc(IccCardApplication.AppType.APPTYPE_USIM)) {
                return MF_SIM + DF_TELECOM + DF_PHONEBOOK;
            }
            Log.e(LOG_TAG, "Error: EF Path being returned in null");