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

Commit 22c17003 authored by Wink Saville's avatar Wink Saville
Browse files

Telephony: Create and use UiccController

UiccController creates and disposes IccCard
IccRecords and IccFileHandler is part of IccCard

Change-Id: I3dfb476c76162bbe8443271927a06743bb5e39c4
parent d1f0023d
Loading
Loading
Loading
Loading
+40 −3
Original line number Diff line number Diff line
@@ -35,8 +35,15 @@ import android.view.WindowManager;

import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.CommandsInterface.RadioState;
import com.android.internal.telephony.gsm.SIMFileHandler;
import com.android.internal.telephony.gsm.SIMRecords;
import com.android.internal.telephony.cdma.CDMALTEPhone;
import com.android.internal.telephony.cdma.CdmaLteUiccFileHandler;
import com.android.internal.telephony.cdma.CdmaLteUiccRecords;
import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
import com.android.internal.telephony.cdma.RuimFileHandler;
import com.android.internal.telephony.cdma.RuimRecords;

import android.os.SystemProperties;

import com.android.internal.R;
@@ -56,6 +63,8 @@ public class IccCard {
    protected boolean isSubscriptionFromIccCard = true;
    protected CdmaSubscriptionSourceManager mCdmaSSM = null;
    protected PhoneBase mPhone;
    private IccRecords mIccRecords;
    private IccFileHandler mIccFileHandler;
    private RegistrantList mAbsentRegistrants = new RegistrantList();
    private RegistrantList mPinLockedRegistrants = new RegistrantList();
    private RegistrantList mNetworkLockedRegistrants = new RegistrantList();
@@ -167,26 +176,46 @@ public class IccCard {
    }

    public IccCard(PhoneBase phone, String logTag, Boolean is3gpp, Boolean dbg) {
        mLogTag = logTag;
        mDbg = dbg;
        if (mDbg) log("[IccCard] Creating card type " + (is3gpp ? "3gpp" : "3gpp2"));
        mPhone = phone;
        this.is3gpp = is3gpp;
        mCdmaSSM = CdmaSubscriptionSourceManager.getInstance(mPhone.getContext(),
                mPhone.mCM, mHandler, EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED, null);
        if (phone.mCM.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE
                && phone instanceof CDMALTEPhone) {
            mIccRecords = new CdmaLteUiccRecords(phone);
            mIccFileHandler = new CdmaLteUiccFileHandler((CDMALTEPhone)phone);
        } else {
            mIccRecords = is3gpp ? new SIMRecords(phone) : new RuimRecords(phone);
            mIccFileHandler = is3gpp ? new SIMFileHandler(phone) : new RuimFileHandler(phone);
        }
        mPhone.mCM.registerForOffOrNotAvailable(mHandler, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
        mPhone.mCM.registerForOn(mHandler, EVENT_RADIO_ON, null);
        mPhone.mCM.registerForIccStatusChanged(mHandler, EVENT_ICC_STATUS_CHANGED, null);
        mLogTag = logTag;
        mDbg = dbg;
    }

    public void dispose() {
        if (mDbg) log("[IccCard] Disposing card type " + (is3gpp ? "3gpp" : "3gpp2"));
        mPhone.mCM.unregisterForIccStatusChanged(mHandler);
        mPhone.mCM.unregisterForOffOrNotAvailable(mHandler);
        mPhone.mCM.unregisterForOn(mHandler);
        mCdmaSSM.dispose(mHandler);
        mIccRecords.dispose();
        mIccFileHandler.dispose();
    }

    protected void finalize() {
        if(mDbg) Log.d(mLogTag, "IccCard finalized");
        if (mDbg) log("[IccCard] Finalized card type " + (is3gpp ? "3gpp" : "3gpp2"));
    }

    public IccRecords getIccRecords() {
        return mIccRecords;
    }

    public IccFileHandler getIccFileHandler() {
        return mIccFileHandler;
    }

    /**
@@ -541,6 +570,10 @@ public class IccCard {
        } else if (isIccCardAdded) {
            mHandler.sendMessage(mHandler.obtainMessage(EVENT_CARD_ADDED, null));
        }

        if (oldState != State.READY && newState == State.READY) {
            mIccRecords.onReady();
        }
    }

    private void onIccSwap(boolean isAdded) {
@@ -932,6 +965,10 @@ public class IccCard {

    public String getAid() {
        String aid = "";
        if (mIccCardStatus == null) {
            return aid;
        }

        int appIndex = getCurrentApplicationIndex();

        if (appIndex >= 0 && appIndex < IccCardStatus.CARD_MAX_APPS) {
+1 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ public abstract class IccRecords extends Handler implements IccConstants {
    public abstract void dispose();

    protected abstract void onRadioOffOrNotAvailable();
    public abstract void onReady();

    //***** Public Methods
    public AdnRecordCache getAdnCache() {
+9 −8
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.internal.telephony.PhoneProxy;
import com.android.internal.telephony.SMSDispatcher;
import com.android.internal.telephony.gsm.GsmSMSDispatcher;
import com.android.internal.telephony.ims.IsimRecords;
import com.android.internal.telephony.uicc.UiccController;

public class CDMALTEPhone extends CDMAPhone {
    static final String LOG_TAG = "CDMA";
@@ -79,9 +80,9 @@ public class CDMALTEPhone extends CDMAPhone {

    @Override
    protected void initSstIcc() {
        mIccCard = new IccCard(this, LOG_TAG, IccCard.CARD_IS_3GPP, DBG);
        mIccRecords = new CdmaLteUiccRecords(this);
        mIccFileHandler = new CdmaLteUiccFileHandler(this);
        mIccCard = UiccController.getInstance(this).getIccCard();
        mIccRecords = mIccCard.getIccRecords();
        mIccFileHandler = mIccCard.getIccFileHandler();
        // CdmaLteServiceStateTracker registers with IccCard to know
        // when the card is ready. So create mIccCard before the ServiceStateTracker
        mSST = new CdmaLteServiceStateTracker(this);
@@ -164,7 +165,7 @@ public class CDMALTEPhone extends CDMAPhone {
        // look for our wrapper within the asyncresult, skip the rest if it
        // is null.
        if (!(ar.userObj instanceof NetworkSelectMessage)) {
            if (DBG) Log.d(LOG_TAG, "unexpected result from user object.");
            Log.e(LOG_TAG, "unexpected result from user object.");
            return;
        }

@@ -173,7 +174,7 @@ public class CDMALTEPhone extends CDMAPhone {
        // found the object, now we send off the message we had originally
        // attached to the request.
        if (nsm.message != null) {
            if (DBG) Log.d(LOG_TAG, "sending original message to recipient");
            if (DBG) log("sending original message to recipient");
            AsyncResult.forMessage(nsm.message, ar.result, ar.exception);
            nsm.message.sendToTarget();
        }
@@ -200,14 +201,15 @@ public class CDMALTEPhone extends CDMAPhone {
                ContentValues map = new ContentValues();
                String operatorNumeric = mIccRecords.getOperatorNumeric();
                map.put(Telephony.Carriers.NUMERIC, operatorNumeric);
                log("updateCurrentCarrierInProvider from UICC: numeric=" + operatorNumeric);
                if (DBG) log("updateCurrentCarrierInProvider from UICC: numeric=" +
                        operatorNumeric);
                mContext.getContentResolver().insert(uri, map);
                return true;
            } catch (SQLException e) {
                Log.e(LOG_TAG, "[CDMALTEPhone] Can't store current operator ret false", e);
            }
        } else {
            log("updateCurrentCarrierInProvider mIccRecords == null ret false");
            if (DBG) log("updateCurrentCarrierInProvider mIccRecords == null ret false");
        }
        return false;
    }
@@ -259,7 +261,6 @@ public class CDMALTEPhone extends CDMAPhone {

    @Override
    protected void log(String s) {
        if (DBG)
            Log.d(LOG_TAG, "[CDMALTEPhone] " + s);
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.UUSInfo;
import com.android.internal.telephony.cat.CatService;
import com.android.internal.telephony.uicc.UiccController;

import java.util.ArrayList;
import java.util.List;
@@ -149,9 +150,9 @@ public class CDMAPhone extends PhoneBase {
    }

    protected void initSstIcc() {
        mIccCard = new IccCard(this, LOG_TAG, IccCard.CARD_IS_NOT_3GPP, DBG);
        mIccRecords = new RuimRecords(this);
        mIccFileHandler = new RuimFileHandler(this);
        mIccCard = UiccController.getInstance(this).getIccCard();
        mIccRecords = mIccCard.getIccRecords();
        mIccFileHandler = mIccCard.getIccFileHandler();
        // CdmaServiceStateTracker registers with IccCard to know
        // when the Ruim card is ready. So create mIccCard before the ServiceStateTracker
        mSST = new CdmaServiceStateTracker(this);
@@ -242,7 +243,6 @@ public class CDMAPhone extends PhoneBase {
            mSMS.dispose();
            mIccFileHandler.dispose(); // instance of RuimFileHandler
            mIccRecords.dispose();
            mIccCard.dispose();
            mRuimPhoneBookInterfaceManager.dispose();
            mRuimSmsInterfaceManager.dispose();
            mSubInfo.dispose();
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ import android.os.Message;
public final class CdmaLteUiccFileHandler extends IccFileHandler {
    static final String LOG_TAG = "CDMA";

    CdmaLteUiccFileHandler(CDMALTEPhone phone) {
    public CdmaLteUiccFileHandler(CDMALTEPhone phone) {
        super(phone);
    }

Loading