Refactor IccRecords and IccCard

IccRecords is now full base class for RuimRecords and SIMRecords
so we can use the IccRecords to represent both Ruim and SIM records
class.

Rename mSIMRecords to mIccRecords in PhoneBase.

Remove mRuimRecords.

Change-Id: If6afff3f99d41830c947de13c26586deff923c6f
This commit is contained in:
Wink Saville
2011-05-10 11:33:10 -07:00
parent 5de8226cc7
commit 1f3278e111
17 changed files with 226 additions and 169 deletions

View File

@@ -28,6 +28,8 @@ import android.util.Log;
import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.CommandsInterface.RadioState;
import com.android.internal.telephony.gsm.SIMRecords;
import android.os.SystemProperties;
/**
@@ -430,8 +432,14 @@ public abstract class IccCard {
broadcastIccStateChangedIntent(INTENT_VALUE_ICC_LOCKED,
INTENT_VALUE_LOCKED_NETWORK);
}
/*
* TODO: We need to try to remove this, maybe if the RIL sends up a RIL_UNSOL_SIM_REFRESH?
*/
if (oldState != State.READY && newState == State.READY && LTE_AVAILABLE_ON_CDMA) {
mPhone.mSIMRecords.onSimReady();
if (mPhone.mIccRecords instanceof SIMRecords) {
((SIMRecords)mPhone.mIccRecords).onSimReady();
}
}
}

View File

@@ -21,9 +21,6 @@ import android.os.Handler;
import android.os.Message;
import android.os.Registrant;
import android.os.RegistrantList;
import android.util.Log;
import java.util.ArrayList;
/**
* {@hide}
@@ -79,6 +76,11 @@ public abstract class IccRecords extends Handler implements IccConstants {
this.phone = p;
}
/**
* Call when the IccRecords object is no longer going to be used.
*/
public abstract void dispose();
protected abstract void onRadioOffOrNotAvailable();
//***** Public Methods
@@ -99,6 +101,17 @@ public abstract class IccRecords extends Handler implements IccConstants {
recordsLoadedRegistrants.remove(h);
}
/**
* Get the International Mobile Subscriber ID (IMSI) on a SIM
* for GSM, UMTS and like networks. Default is null if IMSI is
* not supported or unavailable.
*
* @return null if SIM is not yet ready or unavailable
*/
public String getIMSI() {
return null;
}
public String getMsisdnNumber() {
return msisdn;
}
@@ -220,6 +233,7 @@ public abstract class IccRecords extends Handler implements IccConstants {
}
//***** Overridden from Handler
@Override
public abstract void handleMessage(Message msg);
protected abstract void onRecordLoaded();
@@ -232,8 +246,51 @@ public abstract class IccRecords extends Handler implements IccConstants {
* and TS 51.011 10.3.11 for details.
*
* If the SPN is not found on the SIM, the rule is always PLMN_ONLY.
* Generally used for GSM/UMTS and the like SIMs.
*/
protected abstract int getDisplayRule(String plmn);
public abstract int getDisplayRule(String plmn);
/**
* Return true if "Restriction of menu options for manual PLMN selection"
* bit is set or EF_CSP data is unavailable, return false otherwise.
* Generally used for GSM/UMTS and the like SIMs.
*/
public boolean isCspPlmnEnabled() {
return false;
}
/**
* Returns the 5 or 6 digit MCC/MNC of the operator that
* provided the SIM card. Returns null of SIM is not yet ready
* or is not valid for the type of IccCard. Generally used for
* GSM/UMTS and the like SIMS
*/
public String getOperatorNumeric() {
return null;
}
/**
* Get the current Voice call forwarding flag for GSM/UMTS and the like SIMs
*
* @return true if enabled
*/
public boolean getVoiceCallForwardingFlag() {
return false;
}
/**
* Set the voice call forwarding flag for GSM/UMTS and the like SIMs
*
* @param line to enable/disable
* @param enable
*/
public void setVoiceCallForwardingFlag(int line, boolean enable) {
}
/**
* Write string to log file
*
* @param s is the string to write
*/
protected abstract void log(String s);
}

View File

@@ -118,8 +118,8 @@ public abstract class PhoneBase extends Handler implements Phone {
int mCallRingDelay;
public boolean mIsTheCurrentActivePhone = true;
boolean mIsVoiceCapable = true;
public SIMRecords mSIMRecords;
public SimCard mSimCard;
public IccRecords mIccRecords;
public IccCard mIccCard;
public SMSDispatcher mSMS;
/**
@@ -681,6 +681,31 @@ public abstract class PhoneBase extends Handler implements Phone {
return null;
}
@Override
public IccCard getIccCard() {
return mIccCard;
}
@Override
public String getIccSerialNumber() {
return mIccRecords.iccid;
}
@Override
public boolean getIccRecordsLoaded() {
return mIccRecords.getRecordsLoaded();
}
@Override
public boolean getMessageWaitingIndicator() {
return mIccRecords.getVoiceMessageWaiting();
}
@Override
public boolean getCallForwardingIndicator() {
return mIccRecords.getVoiceCallForwardingFlag();
}
/**
* Query the status of the CDMA roaming preference
*/

View File

@@ -48,58 +48,30 @@ public class CDMALTEPhone extends CDMAPhone {
// Constructors
public CDMALTEPhone(Context context, CommandsInterface ci, PhoneNotifier notifier) {
this(context, ci, notifier, false);
log("CDMALTEPhone Constructors");
}
public CDMALTEPhone(Context context, CommandsInterface ci, PhoneNotifier notifier,
boolean unitTestMode) {
super(context, ci, notifier, false);
mSIMRecords = new SIMRecords(this);
mSimCard = new SimCard(this, LOG_TAG, DBG);
}
@Override
protected void initSST() {
protected void initSstIcc() {
mSST = new CdmaLteServiceStateTracker(this);
}
public void dispose() {
synchronized (PhoneProxy.lockForRadioTechnologyChange) {
super.dispose();
mSIMRecords.dispose();
mSimCard.dispose();
}
}
@Override
public void removeReferences() {
super.removeReferences();
this.mSIMRecords = null;
this.mSimCard = null;
}
@Override
public ServiceStateTracker getServiceStateTracker() {
return mSST;
}
public IccCard getIccCard() {
return mSimCard;
}
@Override
public String getIccSerialNumber() {
return mSIMRecords.iccid;
mIccRecords = new SIMRecords(this);
mIccCard = new SimCard(this, LOG_TAG, DBG);
}
@Override
public DataState getDataConnectionState(String apnType) {
// TODO: Remove instanceof if possible.
boolean isCdmaDataConnectionTracker = false;
if (mDataConnectionTracker instanceof CdmaDataConnectionTracker) {
log("getDataConnectionState isCdmaDataConnectionTracker");
isCdmaDataConnectionTracker = true;
} else {
log("getDataConnectionState NOT CdmaDataConnectionTracker");
}
log("getDataConnectionState");
DataState ret = DataState.DISCONNECTED;
if (!isCdmaDataConnectionTracker && (SystemProperties.get("adb.connected", "").length()
@@ -145,28 +117,29 @@ public class CDMALTEPhone extends CDMAPhone {
}
}
log("getDataConnectionState apnType=" + apnType + " ret=" + ret);
return ret;
}
public boolean updateCurrentCarrierInProvider() {
if (mSIMRecords != null) {
if (mIccRecords != null) {
try {
Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
ContentValues map = new ContentValues();
map.put(Telephony.Carriers.NUMERIC, mSIMRecords.getSIMOperatorNumeric());
map.put(Telephony.Carriers.NUMERIC, mIccRecords.getOperatorNumeric());
log("updateCurrentCarrierInProvider insert uri=" + uri);
mContext.getContentResolver().insert(uri, map);
return true;
} catch (SQLException e) {
Log.e(LOG_TAG, "[CDMALTEPhone] Can't store current operator", e);
Log.e(LOG_TAG, "[CDMALTEPhone] Can't store current operator ret false", e);
}
} else {
log("updateCurrentCarrierInProvider mIccRecords == null ret false");
}
return false;
}
public String getActiveApn(String apnType) {
return mDataConnectionTracker.getActiveApnString(apnType);
}
@Override
protected void log(String s) {
if (DBG)
Log.d(LOG_TAG, "[CDMALTEPhone] " + s);

View File

@@ -49,6 +49,7 @@ import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.DataConnection;
import com.android.internal.telephony.IccRecords;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.IccException;
@@ -99,8 +100,6 @@ public class CDMAPhone extends PhoneBase {
// Instance Variables
CdmaCallTracker mCT;
CdmaServiceStateTracker mSST;
RuimRecords mRuimRecords;
RuimCard mRuimCard;
ArrayList <CdmaMmiCode> mPendingMmis = new ArrayList<CdmaMmiCode>();
RuimPhoneBookInterfaceManager mRuimPhoneBookInterfaceManager;
RuimSmsInterfaceManager mRuimSmsInterfaceManager;
@@ -142,19 +141,21 @@ public class CDMAPhone extends PhoneBase {
// Constructors
public CDMAPhone(Context context, CommandsInterface ci, PhoneNotifier notifier) {
super(notifier, context, ci, false);
initSST();
initSstIcc();
init(context, notifier);
}
public CDMAPhone(Context context, CommandsInterface ci, PhoneNotifier notifier,
boolean unitTestMode) {
super(notifier, context, ci, unitTestMode);
initSST();
initSstIcc();
init(context, notifier);
}
protected void initSST() {
protected void initSstIcc() {
mSST = new CdmaServiceStateTracker(this);
mIccRecords = new RuimRecords(this);
mIccCard = new RuimCard(this, LOG_TAG, DBG);
}
protected void init(Context context, PhoneNotifier notifier) {
@@ -162,18 +163,16 @@ public class CDMAPhone extends PhoneBase {
mCT = new CdmaCallTracker(this);
mSMS = new CdmaSMSDispatcher(this);
mIccFileHandler = new RuimFileHandler(this);
mRuimRecords = new RuimRecords(this);
mDataConnectionTracker = new CdmaDataConnectionTracker (this);
mRuimCard = new RuimCard(this);
mRuimPhoneBookInterfaceManager = new RuimPhoneBookInterfaceManager(this);
mRuimSmsInterfaceManager = new RuimSmsInterfaceManager(this, mSMS);
mSubInfo = new PhoneSubInfo(this);
mEriManager = new EriManager(this, context, EriManager.ERI_FROM_XML);
mCcatService = CatService.getInstance(mCM, mRuimRecords, mContext,
mIccFileHandler, mRuimCard);
mCcatService = CatService.getInstance(mCM, mIccRecords, mContext,
mIccFileHandler, mIccCard);
mCM.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
mRuimRecords.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null);
mIccRecords.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null);
mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
mCM.registerForOn(this, EVENT_RADIO_ON, null);
mCM.setOnSuppServiceNotification(this, EVENT_SSN, null);
@@ -222,9 +221,10 @@ public class CDMAPhone extends PhoneBase {
public void dispose() {
synchronized(PhoneProxy.lockForRadioTechnologyChange) {
super.dispose();
log("dispose");
//Unregister from all former registered events
mRuimRecords.unregisterForRecordsLoaded(this); //EVENT_RUIM_RECORDS_LOADED
mIccRecords.unregisterForRecordsLoaded(this); //EVENT_RUIM_RECORDS_LOADED
mCM.unregisterForAvailable(this); //EVENT_RADIO_AVAILABLE
mCM.unregisterForOffOrNotAvailable(this); //EVENT_RADIO_OFF_OR_NOT_AVAILABLE
mCM.unregisterForOn(this); //EVENT_RADIO_ON
@@ -241,8 +241,8 @@ public class CDMAPhone extends PhoneBase {
mSST.dispose();
mSMS.dispose();
mIccFileHandler.dispose(); // instance of RuimFileHandler
mRuimRecords.dispose();
mRuimCard.dispose();
mIccRecords.dispose();
mIccCard.dispose();
mRuimPhoneBookInterfaceManager.dispose();
mRuimSmsInterfaceManager.dispose();
mSubInfo.dispose();
@@ -252,13 +252,14 @@ public class CDMAPhone extends PhoneBase {
}
public void removeReferences() {
log("removeReferences");
this.mRuimPhoneBookInterfaceManager = null;
this.mRuimSmsInterfaceManager = null;
this.mSMS = null;
this.mSubInfo = null;
this.mRuimRecords = null;
this.mIccRecords = null;
this.mIccFileHandler = null;
this.mRuimCard = null;
this.mIccCard = null;
this.mDataConnectionTracker = null;
this.mCT = null;
this.mSST = null;
@@ -547,14 +548,6 @@ public class CDMAPhone extends PhoneBase {
Log.e(LOG_TAG, "setLine1Number: not possible in CDMA");
}
public IccCard getIccCard() {
return mRuimCard;
}
public String getIccSerialNumber() {
return mRuimRecords.iccid;
}
public void setCallWaiting(boolean enable, Message onComplete) {
Log.e(LOG_TAG, "method setCallWaiting is NOT supported in CDMA!");
}
@@ -657,6 +650,7 @@ public class CDMAPhone extends PhoneBase {
}
}
log("getDataConnectionState apnType=" + apnType + " ret=" + ret);
return ret;
}
@@ -733,7 +727,7 @@ public class CDMAPhone extends PhoneBase {
Message resp;
mVmNumber = voiceMailNumber;
resp = obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete);
mRuimRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp);
mIccRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp);
}
public String getVoiceMailNumber() {
@@ -755,7 +749,7 @@ public class CDMAPhone extends PhoneBase {
* @hide
*/
public int getVoiceMessageCount() {
int voicemailCount = mRuimRecords.getVoiceMessageCount();
int voicemailCount = mIccRecords.getVoiceMessageCount();
// If mRuimRecords.getVoiceMessageCount returns zero, then there is possibility
// that phone was power cycled and would have lost the voicemail count.
// So get the count from preferences.
@@ -780,10 +774,6 @@ public class CDMAPhone extends PhoneBase {
return ret;
}
public boolean getIccRecordsLoaded() {
return mRuimRecords.getRecordsLoaded();
}
public void getCallForwardingOption(int commandInterfaceCFReason, Message onComplete) {
Log.e(LOG_TAG, "getCallForwardingOption: not possible in CDMA");
}
@@ -864,13 +854,13 @@ public class CDMAPhone extends PhoneBase {
/*package*/ void
updateMessageWaitingIndicator(boolean mwi) {
// this also calls notifyMessageWaitingIndicator()
mRuimRecords.setVoiceMessageWaiting(1, mwi ? -1 : 0);
mIccRecords.setVoiceMessageWaiting(1, mwi ? -1 : 0);
}
/* This function is overloaded to send number of voicemails instead of sending true/false */
/*package*/ void
updateMessageWaitingIndicator(int mwi) {
mRuimRecords.setVoiceMessageWaiting(1, mwi);
mIccRecords.setVoiceMessageWaiting(1, mwi);
}
@Override
@@ -1417,6 +1407,7 @@ public class CDMAPhone extends PhoneBase {
Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
ContentValues map = new ContentValues();
map.put(Telephony.Carriers.NUMERIC, operatorNumeric);
log("updateCurrentCarrierInProvider insert uri=" + uri);
getContext().getContentResolver().insert(uri, map);
// Updates MCC MNC device configuration information
@@ -1429,4 +1420,9 @@ public class CDMAPhone extends PhoneBase {
}
return false;
}
protected void log(String s) {
if (DBG)
Log.d(LOG_TAG, "[CDMAPhone] " + s);
}
}

View File

@@ -98,7 +98,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
p.mCM.registerForAvailable (this, EVENT_RADIO_AVAILABLE, null);
p.mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
p.mRuimRecords.registerForRecordsLoaded(this, EVENT_RECORDS_LOADED, null);
p.mIccRecords.registerForRecordsLoaded(this, EVENT_RECORDS_LOADED, null);
p.mCM.registerForNVReady(this, EVENT_NV_READY, null);
p.mCM.registerForDataNetworkStateChanged (this, EVENT_DATA_STATE_CHANGED, null);
p.mCT.registerForVoiceCallEnded (this, EVENT_VOICE_CALL_ENDED, null);
@@ -124,7 +124,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
// Unregister from all events
mPhone.mCM.unregisterForAvailable(this);
mPhone.mCM.unregisterForOffOrNotAvailable(this);
mCdmaPhone.mRuimRecords.unregisterForRecordsLoaded(this);
mCdmaPhone.mIccRecords.unregisterForRecordsLoaded(this);
mPhone.mCM.unregisterForNVReady(this);
mPhone.mCM.unregisterForDataNetworkStateChanged(this);
mCdmaPhone.mCT.unregisterForVoiceCallEnded(this);
@@ -183,7 +183,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
(psState == ServiceState.STATE_IN_SERVICE ||
mAutoAttachOnCreation) &&
(mPhone.mCM.getNvState() == CommandsInterface.RadioState.NV_READY ||
mCdmaPhone.mRuimRecords.getRecordsLoaded()) &&
mCdmaPhone.mIccRecords.getRecordsLoaded()) &&
(mCdmaPhone.mSST.isConcurrentVoiceAndDataAllowed() ||
mPhone.getState() == Phone.State.IDLE) &&
!roaming &&
@@ -197,7 +197,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
reason += " - psState= " + psState;
}
if (!(mPhone.mCM.getNvState() == CommandsInterface.RadioState.NV_READY ||
mCdmaPhone.mRuimRecords.getRecordsLoaded())) {
mCdmaPhone.mIccRecords.getRecordsLoaded())) {
reason += " - radioState= " + mPhone.mCM.getNvState() + " - RUIM not loaded";
}
if (!(mCdmaPhone.mSST.isConcurrentVoiceAndDataAllowed() ||

View File

@@ -214,7 +214,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
cm.unregisterForNVReady(this);
cm.unregisterForCdmaOtaProvision(this);
phone.unregisterForEriFileLoaded(this);
phone.mRuimRecords.unregisterForRecordsLoaded(this);
phone.mIccRecords.unregisterForRecordsLoaded(this);
cm.unSetOnSignalStrengthUpdate(this);
cm.unSetOnNITZTime(this);
cr.unregisterContentObserver(mAutoTimeObserver);
@@ -260,7 +260,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
// unlocked. At this stage, the radio is already powered on.
isSubscriptionFromRuim = true;
if (mNeedToRegForRuimLoaded) {
phone.mRuimRecords.registerForRecordsLoaded(this,
phone.mIccRecords.registerForRecordsLoaded(this,
EVENT_RUIM_RECORDS_LOADED, null);
mNeedToRegForRuimLoaded = false;
}

View File

@@ -25,8 +25,8 @@ import com.android.internal.telephony.IccCard;
*/
public final class RuimCard extends IccCard {
RuimCard(CDMAPhone phone) {
super(phone, "CDMA", true);
RuimCard(CDMAPhone phone, String LOG_TAG, boolean dbg) {
super(phone, LOG_TAG, dbg);
mPhone.mCM.registerForRUIMLockedOrAbsent(mHandler, EVENT_ICC_LOCKED_OR_ABSENT, null);
mPhone.mCM.registerForOffOrNotAvailable(mHandler, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
mPhone.mCM.registerForRUIMReady(mHandler, EVENT_ICC_READY, null);
@@ -43,7 +43,7 @@ public final class RuimCard extends IccCard {
@Override
public String getServiceProviderName () {
return ((CDMAPhone)mPhone).mRuimRecords.getServiceProviderName();
return mPhone.mIccRecords.getServiceProviderName();
}
}

View File

@@ -32,7 +32,7 @@ public class RuimPhoneBookInterfaceManager extends IccPhoneBookInterfaceManager
public RuimPhoneBookInterfaceManager(CDMAPhone phone) {
super(phone);
adnCache = phone.mRuimRecords.getAdnCache();
adnCache = phone.mIccRecords.getAdnCache();
//NOTE service "simphonebook" added by IccSmsInterfaceManagerProxy
}

View File

@@ -94,6 +94,7 @@ public final class RuimRecords extends IccRecords {
}
@Override
public void dispose() {
//Unregister for all events
phone.mCM.unregisterForRUIMReady(this);
@@ -293,7 +294,7 @@ public final class RuimRecords extends IccRecords {
recordsLoadedRegistrants.notifyRegistrants(
new AsyncResult(null, null, null));
((CDMAPhone) phone).mRuimCard.broadcastIccStateChangedIntent(
phone.mIccCard.broadcastIccStateChangedIntent(
RuimCard.INTENT_VALUE_ICC_LOADED, null);
}
@@ -302,7 +303,7 @@ public final class RuimRecords extends IccRecords {
READY is sent before IMSI ready
*/
((CDMAPhone) phone).mRuimCard.broadcastIccStateChangedIntent(
phone.mIccCard.broadcastIccStateChangedIntent(
RuimCard.INTENT_VALUE_ICC_READY, null);
fetchRuimRecords();
@@ -324,8 +325,13 @@ public final class RuimRecords extends IccRecords {
// Further records that can be inserted are Operator/OEM dependent
}
/**
* {@inheritDoc}
*
* No Display rule for RUIMs yet.
*/
@Override
protected int getDisplayRule(String plmn) {
public int getDisplayRule(String plmn) {
// TODO together with spn
return 0;
}

View File

@@ -142,19 +142,18 @@ public class GSMPhone extends PhoneBase {
mSST = new GsmServiceStateTracker (this);
mSMS = new GsmSMSDispatcher(this);
mIccFileHandler = new SIMFileHandler(this);
mSIMRecords = new SIMRecords(this);
mIccRecords = new SIMRecords(this);
mDataConnectionTracker = new GsmDataConnectionTracker (this);
mSimCard = new SimCard(this);
mIccCard = new SimCard(this);
if (!unitTestMode) {
mSimPhoneBookIntManager = new SimPhoneBookInterfaceManager(this);
mSimSmsIntManager = new SimSmsInterfaceManager(this, mSMS);
mSubInfo = new PhoneSubInfo(this);
}
mStkService = CatService.getInstance(mCM, mSIMRecords, mContext,
(SIMFileHandler)mIccFileHandler, mSimCard);
mStkService = CatService.getInstance(mCM, mIccRecords, mContext, mIccFileHandler, mIccCard);
mCM.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
mSIMRecords.registerForRecordsLoaded(this, EVENT_SIM_RECORDS_LOADED, null);
mIccRecords.registerForRecordsLoaded(this, EVENT_SIM_RECORDS_LOADED, null);
mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
mCM.registerForOn(this, EVENT_RADIO_ON, null);
mCM.setOnUSSD(this, EVENT_USSD, null);
@@ -206,7 +205,7 @@ public class GSMPhone extends PhoneBase {
//Unregister from all former registered events
mCM.unregisterForAvailable(this); //EVENT_RADIO_AVAILABLE
mSIMRecords.unregisterForRecordsLoaded(this); //EVENT_SIM_RECORDS_LOADED
mIccRecords.unregisterForRecordsLoaded(this); //EVENT_SIM_RECORDS_LOADED
mCM.unregisterForOffOrNotAvailable(this); //EVENT_RADIO_OFF_OR_NOT_AVAILABLE
mCM.unregisterForOn(this); //EVENT_RADIO_ON
mSST.unregisterForNetworkAttached(this); //EVENT_REGISTERED_TO_NETWORK
@@ -221,8 +220,8 @@ public class GSMPhone extends PhoneBase {
mDataConnectionTracker.dispose();
mSST.dispose();
mIccFileHandler.dispose(); // instance of SimFileHandler
mSIMRecords.dispose();
mSimCard.dispose();
mIccRecords.dispose();
mIccCard.dispose();
mSimPhoneBookIntManager.dispose();
mSimSmsIntManager.dispose();
mSubInfo.dispose();
@@ -236,9 +235,9 @@ public class GSMPhone extends PhoneBase {
this.mSimSmsIntManager = null;
this.mSMS = null;
this.mSubInfo = null;
this.mSIMRecords = null;
this.mIccRecords = null;
this.mIccFileHandler = null;
this.mSimCard = null;
this.mIccCard = null;
this.mDataConnectionTracker = null;
this.mCT = null;
this.mSST = null;
@@ -274,14 +273,6 @@ public class GSMPhone extends PhoneBase {
return mSST.mSignalStrength;
}
public boolean getMessageWaitingIndicator() {
return mSIMRecords.getVoiceMessageWaiting();
}
public boolean getCallForwardingIndicator() {
return mSIMRecords.getVoiceCallForwardingFlag();
}
public CallTracker getCallTracker() {
return mCT;
}
@@ -419,7 +410,7 @@ public class GSMPhone extends PhoneBase {
/*package*/ void
updateMessageWaitingIndicator(boolean mwi) {
// this also calls notifyMessageWaitingIndicator()
mSIMRecords.setVoiceMessageWaiting(1, mwi ? -1 : 0);
mIccRecords.setVoiceMessageWaiting(1, mwi ? -1 : 0);
}
public void
@@ -820,7 +811,7 @@ public class GSMPhone extends PhoneBase {
public String getVoiceMailNumber() {
// Read from the SIM. If its null, try reading from the shared preference area.
String number = mSIMRecords.getVoiceMailNumber();
String number = mIccRecords.getVoiceMailNumber();
if (TextUtils.isEmpty(number)) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
number = sp.getString(VM_NUMBER, null);
@@ -843,7 +834,7 @@ public class GSMPhone extends PhoneBase {
public String getVoiceMailAlphaTag() {
String ret;
ret = mSIMRecords.getVoiceMailAlphaTag();
ret = mIccRecords.getVoiceMailAlphaTag();
if (ret == null || ret.length() == 0) {
return mContext.getText(
@@ -872,23 +863,19 @@ public class GSMPhone extends PhoneBase {
}
public String getSubscriberId() {
return mSIMRecords.imsi;
}
public String getIccSerialNumber() {
return mSIMRecords.iccid;
return mIccRecords.getIMSI();
}
public String getLine1Number() {
return mSIMRecords.getMsisdnNumber();
return mIccRecords.getMsisdnNumber();
}
public String getLine1AlphaTag() {
return mSIMRecords.getMsisdnAlphaTag();
return mIccRecords.getMsisdnAlphaTag();
}
public void setLine1Number(String alphaTag, String number, Message onComplete) {
mSIMRecords.setMsisdnNumber(alphaTag, number, onComplete);
mIccRecords.setMsisdnNumber(alphaTag, number, onComplete);
}
public void setVoiceMailNumber(String alphaTag,
@@ -898,7 +885,7 @@ public class GSMPhone extends PhoneBase {
Message resp;
mVmNumber = voiceMailNumber;
resp = obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete);
mSIMRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp);
mIccRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp);
}
private boolean isValidCommandInterfaceCFReason (int commandInterfaceCFReason) {
@@ -988,15 +975,6 @@ public class GSMPhone extends PhoneBase {
mCM.setCallWaiting(enable, CommandsInterface.SERVICE_CLASS_VOICE, onComplete);
}
public boolean
getIccRecordsLoaded() {
return mSIMRecords.getRecordsLoaded();
}
public IccCard getIccCard() {
return mSimCard;
}
public void
getAvailableNetworks(Message response) {
mCM.getAvailableNetworks(response);
@@ -1276,7 +1254,7 @@ public class GSMPhone extends PhoneBase {
case EVENT_SET_CALL_FORWARD_DONE:
ar = (AsyncResult)msg.obj;
if (ar.exception == null) {
mSIMRecords.setVoiceCallForwardingFlag(1, msg.arg1 == 1);
mIccRecords.setVoiceCallForwardingFlag(1, msg.arg1 == 1);
}
onComplete = (Message) ar.userObj;
if (onComplete != null) {
@@ -1340,11 +1318,11 @@ public class GSMPhone extends PhoneBase {
* @return true for success; false otherwise.
*/
boolean updateCurrentCarrierInProvider() {
if (mSIMRecords != null) {
if (mIccRecords != null) {
try {
Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
ContentValues map = new ContentValues();
map.put(Telephony.Carriers.NUMERIC, mSIMRecords.getSIMOperatorNumeric());
map.put(Telephony.Carriers.NUMERIC, mIccRecords.getOperatorNumeric());
mContext.getContentResolver().insert(uri, map);
return true;
} catch (SQLException e) {
@@ -1409,11 +1387,11 @@ public class GSMPhone extends PhoneBase {
if (infos == null || infos.length == 0) {
// Assume the default is not active
// Set unconditional CFF in SIM to false
mSIMRecords.setVoiceCallForwardingFlag(1, false);
mIccRecords.setVoiceCallForwardingFlag(1, false);
} else {
for (int i = 0, s = infos.length; i < s; i++) {
if ((infos[i].serviceClass & SERVICE_CLASS_VOICE) != 0) {
mSIMRecords.setVoiceCallForwardingFlag(1, (infos[i].status == 1));
mIccRecords.setVoiceCallForwardingFlag(1, (infos[i].status == 1));
// should only have the one
break;
}
@@ -1462,6 +1440,6 @@ public class GSMPhone extends PhoneBase {
}
public boolean isCspPlmnEnabled() {
return mSIMRecords.isCspPlmnEnabled();
return mIccRecords.isCspPlmnEnabled();
}
}

View File

@@ -143,7 +143,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
p.mCM.registerForAvailable (this, EVENT_RADIO_AVAILABLE, null);
p.mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
p.mSIMRecords.registerForRecordsLoaded(this, EVENT_RECORDS_LOADED, null);
p.mIccRecords.registerForRecordsLoaded(this, EVENT_RECORDS_LOADED, null);
p.mCM.registerForDataNetworkStateChanged (this, EVENT_DATA_STATE_CHANGED, null);
p.getCallTracker().registerForVoiceCallEnded (this, EVENT_VOICE_CALL_ENDED, null);
p.getCallTracker().registerForVoiceCallStarted (this, EVENT_VOICE_CALL_STARTED, null);
@@ -179,7 +179,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
//Unregister for all events
mPhone.mCM.unregisterForAvailable(this);
mPhone.mCM.unregisterForOffOrNotAvailable(this);
mPhone.mSIMRecords.unregisterForRecordsLoaded(this);
mPhone.mIccRecords.unregisterForRecordsLoaded(this);
mPhone.mCM.unregisterForDataNetworkStateChanged(this);
mPhone.getCallTracker().unregisterForVoiceCallEnded(this);
mPhone.getCallTracker().unregisterForVoiceCallStarted(this);
@@ -582,7 +582,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
boolean allowed =
gprsState == ServiceState.STATE_IN_SERVICE &&
mPhone.mSIMRecords.getRecordsLoaded() &&
mPhone.mIccRecords.getRecordsLoaded() &&
mPhone.getState() == Phone.State.IDLE &&
mInternalDataEnabled &&
(!mPhone.getServiceState().getRoaming() || getDataOnRoamingEnabled()) &&
@@ -593,7 +593,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
if (!(gprsState == ServiceState.STATE_IN_SERVICE)) {
reason += " - gprs= " + gprsState;
}
if (!mPhone.mSIMRecords.getRecordsLoaded()) reason += " - SIM not loaded";
if (!mPhone.mIccRecords.getRecordsLoaded()) reason += " - SIM not loaded";
if (mPhone.getState() != Phone.State.IDLE) {
reason += " - PhoneState= " + mPhone.getState();
}
@@ -1505,7 +1505,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
log("onRadioAvailable: We're on the simulator; assuming data is connected");
}
if (mPhone.mSIMRecords.getRecordsLoaded()) {
if (mPhone.mIccRecords.getRecordsLoaded()) {
notifyDataAvailability(null);
}
@@ -1752,7 +1752,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
*/
private void createAllApnList() {
mAllApns = new ArrayList<ApnSetting>();
String operator = mPhone.mSIMRecords.getSIMOperatorNumeric();
String operator = mPhone.mIccRecords.getOperatorNumeric();
if (operator != null) {
String selection = "numeric = '" + operator + "'";
if (DBG) log("createAllApnList: selection=" + selection);
@@ -1852,7 +1852,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
return apnList;
}
String operator = mPhone.mSIMRecords.getSIMOperatorNumeric();
String operator = mPhone.mIccRecords.getOperatorNumeric();
if (requestedApnType.equals(Phone.APN_TYPE_DEFAULT)) {
if (canSetPreferApn && mPreferredApn != null) {
if (DBG) {

View File

@@ -765,7 +765,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
// invalid length
handlePasswordError(com.android.internal.R.string.invalidPin);
} else if (sc.equals(SC_PIN) &&
phone.mSimCard.getState() == SimCard.State.PUK_REQUIRED ) {
phone.mIccCard.getState() == SimCard.State.PUK_REQUIRED ) {
// Sim is puk-locked
handlePasswordError(com.android.internal.R.string.needPuk);
} else {
@@ -885,7 +885,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
*/
if ((ar.exception == null) && (msg.arg1 == 1)) {
boolean cffEnabled = (msg.arg2 == 1);
phone.mSIMRecords.setVoiceCallForwardingFlag(1, cffEnabled);
phone.mIccRecords.setVoiceCallForwardingFlag(1, cffEnabled);
}
onSetComplete(ar);
@@ -1203,7 +1203,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
(info.serviceClass & serviceClassMask)
== CommandsInterface.SERVICE_CLASS_VOICE) {
boolean cffEnabled = (info.status == 1);
phone.mSIMRecords.setVoiceCallForwardingFlag(1, cffEnabled);
phone.mIccRecords.setVoiceCallForwardingFlag(1, cffEnabled);
}
return TextUtils.replace(template, sources, destinations);
@@ -1228,7 +1228,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
sb.append(context.getText(com.android.internal.R.string.serviceDisabled));
// Set unconditional CFF in SIM to false
phone.mSIMRecords.setVoiceCallForwardingFlag(1, false);
phone.mIccRecords.setVoiceCallForwardingFlag(1, false);
} else {
SpannableStringBuilder tb = new SpannableStringBuilder();

View File

@@ -247,7 +247,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
cm.unregisterForVoiceNetworkStateChanged(this);
cm.unregisterForSIMReady(this);
phone.mSIMRecords.unregisterForRecordsLoaded(this);
phone.mIccRecords.unregisterForRecordsLoaded(this);
cm.unSetOnSignalStrengthUpdate(this);
cm.unSetOnRestrictedStateChanged(this);
cm.unSetOnNITZTime(this);
@@ -281,7 +281,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
// it has been unlocked. At this stage, the radio is already
// powered on.
if (mNeedToRegForSimLoaded) {
phone.mSIMRecords.registerForRecordsLoaded(this,
phone.mIccRecords.registerForRecordsLoaded(this,
EVENT_SIM_RECORDS_LOADED, null);
mNeedToRegForSimLoaded = false;
}
@@ -487,8 +487,8 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
}
protected void updateSpnDisplay() {
int rule = phone.mSIMRecords.getDisplayRule(ss.getOperatorNumeric());
String spn = phone.mSIMRecords.getServiceProviderName();
int rule = phone.mIccRecords.getDisplayRule(ss.getOperatorNumeric());
String spn = phone.mIccRecords.getServiceProviderName();
String plmn = ss.getOperatorAlphaLong();
// For emergency calls only, pass the EmergencyCallsOnly string via EXTRA_PLMN

View File

@@ -59,8 +59,8 @@ public final class SIMRecords extends IccRecords {
// ***** Cached SIM State; cleared on channel close
String imsi;
boolean callForwardingEnabled;
private String imsi;
private boolean callForwardingEnabled;
/**
@@ -191,6 +191,7 @@ public final class SIMRecords extends IccRecords {
}
@Override
public void dispose() {
//Unregister for all events
phone.mCM.unregisterForSIMReady(this);
@@ -231,7 +232,10 @@ public final class SIMRecords extends IccRecords {
//***** Public Methods
/** Returns null if SIM is not yet ready */
/**
* {@inheritDoc}
*/
@Override
public String getIMSI() {
return imsi;
}
@@ -404,10 +408,18 @@ public final class SIMRecords extends IccRecords {
}
}
/**
* {@inheritDoc}
*/
@Override
public boolean getVoiceCallForwardingFlag() {
return callForwardingEnabled;
}
/**
* {@inheritDoc}
*/
@Override
public void setVoiceCallForwardingFlag(int line, boolean enable) {
if (line != 1) return; // only line 1 is supported
@@ -468,12 +480,13 @@ public final class SIMRecords extends IccRecords {
}
}
/** Returns the 5 or 6 digit MCC/MNC of the operator that
* provided the SIM card. Returns null of SIM is not yet ready
/**
* {@inheritDoc}
*/
public String getSIMOperatorNumeric() {
@Override
public String getOperatorNumeric() {
if (imsi == null) {
Log.d(LOG_TAG, "getSIMOperatorNumeric: IMSI == null");
Log.d(LOG_TAG, "getOperatorNumeric: IMSI == null");
return null;
}
if (mncLength == UNINITIALIZED || mncLength == UNKNOWN) {
@@ -484,7 +497,7 @@ public final class SIMRecords extends IccRecords {
// STOPSHIP: to be removed
if (SystemProperties.getInt(com.android.internal.telephony.TelephonyProperties
.PROPERTY_NETWORK_LTE_ON_CDMA, 0) == 1) {
Log.e(LOG_TAG, "getSIMOperatorNumeric: STOPSHIP bad numeric operators in lte");
Log.e(LOG_TAG, "getOperatorNumeric: STOPSHIP bad numeric operators in lte");
return SystemProperties.get("ro.cdma.home.operator.numeric", "310004");
}
// Length = length of MCC + length of MNC
@@ -559,7 +572,7 @@ public final class SIMRecords extends IccRecords {
// finally have both the imsi and the mncLength and can parse the imsi properly
MccTable.updateMccMncConfiguration(phone, imsi.substring(0, 3 + mncLength));
}
phone.mSimCard.broadcastIccStateChangedIntent(
phone.mIccCard.broadcastIccStateChangedIntent(
SimCard.INTENT_VALUE_ICC_IMSI, null);
break;
@@ -1221,7 +1234,7 @@ public final class SIMRecords extends IccRecords {
protected void onAllRecordsLoaded() {
Log.d(LOG_TAG, "SIMRecords: record load complete");
String operator = getSIMOperatorNumeric();
String operator = getOperatorNumeric();
// Some fields require more than one SIM record to set
@@ -1240,7 +1253,7 @@ public final class SIMRecords extends IccRecords {
recordsLoadedRegistrants.notifyRegistrants(
new AsyncResult(null, null, null));
phone.mSimCard.broadcastIccStateChangedIntent(
phone.mIccCard.broadcastIccStateChangedIntent(
SimCard.INTENT_VALUE_ICC_LOADED, null);
}
@@ -1265,7 +1278,7 @@ public final class SIMRecords extends IccRecords {
/* broadcast intent SIM_READY here so that we can make sure
READY is sent before IMSI ready
*/
phone.mSimCard.broadcastIccStateChangedIntent(
phone.mIccCard.broadcastIccStateChangedIntent(
SimCard.INTENT_VALUE_ICC_READY, null);
fetchSimRecords();
@@ -1362,7 +1375,8 @@ public final class SIMRecords extends IccRecords {
*
* If the SPN is not found on the SIM, the rule is always PLMN_ONLY.
*/
protected int getDisplayRule(String plmn) {
@Override
public int getDisplayRule(String plmn) {
int rule;
if (spn == null || spnDisplayCondition == -1) {
// EF_SPN was not found on the SIM, or not yet loaded. Just show ONS.
@@ -1389,7 +1403,7 @@ public final class SIMRecords extends IccRecords {
private boolean isOnMatchingPlmn(String plmn) {
if (plmn == null) return false;
if (plmn.equals(getSIMOperatorNumeric())) {
if (plmn.equals(getOperatorNumeric())) {
return true;
}

View File

@@ -62,7 +62,7 @@ public final class SimCard extends IccCard {
@Override
public String getServiceProviderName () {
return ((GSMPhone)mPhone).mSIMRecords.getServiceProviderName();
return mPhone.mIccRecords.getServiceProviderName();
}
}

View File

@@ -32,7 +32,7 @@ public class SimPhoneBookInterfaceManager extends IccPhoneBookInterfaceManager {
public SimPhoneBookInterfaceManager(GSMPhone phone) {
super(phone);
adnCache = phone.mSIMRecords.getAdnCache();
adnCache = phone.mIccRecords.getAdnCache();
//NOTE service "simphonebook" added by IccSmsInterfaceManagerProxy
}