import com.android.internal.R;
import com.android.internal.telephony.DataConnection.FailCause;
-import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.util.AsyncChannel;
import com.android.internal.util.Protocol;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
/**
* {@hide}
public static final int EVENT_CLEAN_UP_ALL_CONNECTIONS = BASE + 30;
public static final int CMD_SET_DEPENDENCY_MET = BASE + 31;
public static final int CMD_SET_POLICY_DATA_ENABLE = BASE + 32;
- protected static final int EVENT_ICC_CHANGED = BASE + 33;
/***** Constants *****/
// member variables
protected PhoneBase mPhone;
- protected UiccController mUiccController;
- protected AtomicReference<IccRecords> mIccRecords = new AtomicReference<IccRecords>();
protected Activity mActivity = Activity.NONE;
protected State mState = State.IDLE;
protected Handler mDataConnectionTracker = null;
protected DataConnectionTracker(PhoneBase phone) {
super();
mPhone = phone;
- mUiccController = UiccController.getInstance();
- mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
IntentFilter filter = new IntentFilter();
filter.addAction(getActionIntentReconnectAlarm());
mIsDisposed = true;
mPhone.getContext().unregisterReceiver(this.mIntentReceiver);
mDataRoamingSettingObserver.unregister(mPhone.getContext());
- mUiccController.unregisterForIccChanged(this);
}
protected void broadcastMessenger() {
protected abstract void onCleanUpConnection(boolean tearDown, int apnId, String reason);
protected abstract void onCleanUpAllConnections(String cause);
protected abstract boolean isDataPossible(String apnType);
- protected abstract void onUpdateIcc();
protected void onDataStallAlarm(int tag) {
loge("onDataStallAlarm: not impleted tag=" + tag);
onSetPolicyDataEnabled(enabled);
break;
}
- case EVENT_ICC_CHANGED:
- onUpdateIcc();
- break;
-
default:
Log.e("DATA", "Unidentified event msg=" + msg);
break;
import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.CommandsInterface.RadioState;
-import com.android.internal.telephony.gsm.GSMPhone;
import com.android.internal.telephony.gsm.SIMFileHandler;
import com.android.internal.telephony.gsm.SIMRecords;
import com.android.internal.telephony.cat.CatService;
import com.android.internal.telephony.cdma.CDMALTEPhone;
-import com.android.internal.telephony.cdma.CDMAPhone;
import com.android.internal.telephony.cdma.CdmaLteUiccFileHandler;
import com.android.internal.telephony.cdma.CdmaLteUiccRecords;
import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
protected static final int EVENT_ICC_LOCKED = 1;
private static final int EVENT_GET_ICC_STATUS_DONE = 2;
protected static final int EVENT_RADIO_OFF_OR_NOT_AVAILABLE = 3;
+ private static final int EVENT_PINPUK_DONE = 4;
+ private static final int EVENT_REPOLL_STATUS_DONE = 5;
protected static final int EVENT_ICC_READY = 6;
private static final int EVENT_QUERY_FACILITY_LOCK_DONE = 7;
private static final int EVENT_CHANGE_FACILITY_LOCK_DONE = 8;
return State.UNKNOWN;
}
- public IccCard(PhoneBase phone, IccCardStatus ics, String logTag, boolean dbg) {
+ public IccCard(PhoneBase phone, String logTag, Boolean is3gpp, Boolean dbg) {
mLogTag = logTag;
mDbg = dbg;
- if (mDbg) log("Creating");
- update(phone, ics);
+ 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) {
+ mIccFileHandler = new CdmaLteUiccFileHandler(this, "", mPhone.mCM);
+ mIccRecords = new CdmaLteUiccRecords(this, mPhone.mContext, mPhone.mCM);
+ } else {
+ // Correct aid will be set later (when GET_SIM_STATUS returns)
+ mIccFileHandler = is3gpp ? new SIMFileHandler(this, "", mPhone.mCM) :
+ new RuimFileHandler(this, "", mPhone.mCM);
+ mIccRecords = is3gpp ? new SIMRecords(this, mPhone.mContext, mPhone.mCM) :
+ new RuimRecords(this, mPhone.mContext, mPhone.mCM);
+ }
+ mCatService = CatService.getInstance(mPhone.mCM, mIccRecords,
+ mPhone.mContext, mIccFileHandler, this);
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);
}
public void dispose() {
- if (mDbg) log("Disposing card type " + (is3gpp ? "3gpp" : "3gpp2"));
+ if (mDbg) log("[IccCard] Disposing card type " + (is3gpp ? "3gpp" : "3gpp2"));
mPhone.mCM.unregisterForIccStatusChanged(mHandler);
mPhone.mCM.unregisterForOffOrNotAvailable(mHandler);
mPhone.mCM.unregisterForOn(mHandler);
mIccFileHandler.dispose();
}
- public void update(PhoneBase phone, IccCardStatus ics) {
- if (phone != mPhone) {
- PhoneBase oldPhone = mPhone;
- mPhone = phone;
- log("Update");
- if (phone instanceof GSMPhone) {
- is3gpp = true;
- } else if (phone instanceof CDMALTEPhone){
- is3gpp = true;
- } else if (phone instanceof CDMAPhone){
- is3gpp = false;
- } else {
- throw new RuntimeException("Update: Unhandled phone type. Critical error!" +
- phone.getPhoneName());
- }
-
-
- if (phone.mCM.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE
- && phone instanceof CDMALTEPhone) {
- mIccFileHandler = new CdmaLteUiccFileHandler(this, "", mPhone.mCM);
- mIccRecords = new CdmaLteUiccRecords(this, mPhone.mContext, mPhone.mCM);
- } else {
- // Correct aid will be set later (when GET_SIM_STATUS returns)
- mIccFileHandler = is3gpp ? new SIMFileHandler(this, "", mPhone.mCM) :
- new RuimFileHandler(this, "", mPhone.mCM);
- mIccRecords = is3gpp ? new SIMRecords(this, mPhone.mContext, mPhone.mCM) :
- new RuimRecords(this, mPhone.mContext, mPhone.mCM);
- }
- mCatService = CatService.getInstance(mPhone.mCM, mIccRecords, mPhone.mContext,
- mIccFileHandler, this);
- }
- mHandler.sendMessage(mHandler.obtainMessage(EVENT_GET_ICC_STATUS_DONE, ics));
- }
-
protected void finalize() {
if (mDbg) log("[IccCard] Finalized card type " + (is3gpp ? "3gpp" : "3gpp2"));
}
*/
public void supplyPin (String pin, Message onComplete) {
- mPhone.mCM.supplyIccPin(pin, onComplete);
+ mPhone.mCM.supplyIccPin(pin, mHandler.obtainMessage(EVENT_PINPUK_DONE, onComplete));
}
public void supplyPuk (String puk, String newPin, Message onComplete) {
- mPhone.mCM.supplyIccPuk(puk, newPin, onComplete);
+ mPhone.mCM.supplyIccPuk(puk, newPin,
+ mHandler.obtainMessage(EVENT_PINPUK_DONE, onComplete));
}
public void supplyPin2 (String pin2, Message onComplete) {
- mPhone.mCM.supplyIccPin2(pin2, onComplete);
+ mPhone.mCM.supplyIccPin2(pin2,
+ mHandler.obtainMessage(EVENT_PINPUK_DONE, onComplete));
}
public void supplyPuk2 (String puk2, String newPin2, Message onComplete) {
- mPhone.mCM.supplyIccPuk2(puk2, newPin2, onComplete);
+ mPhone.mCM.supplyIccPuk2(puk2, newPin2,
+ mHandler.obtainMessage(EVENT_PINPUK_DONE, onComplete));
}
public void supplyNetworkDepersonalization (String pin, Message onComplete) {
- mPhone.mCM.supplyNetworkDepersonalization(pin, onComplete);
+ mPhone.mCM.supplyNetworkDepersonalization(pin,
+ mHandler.obtainMessage(EVENT_PINPUK_DONE, onComplete));
}
/**
*
*/
public String getServiceProviderName () {
- return mIccRecords.getServiceProviderName();
+ return mPhone.mIccRecords.getServiceProviderName();
}
protected void updateStateProperty() {
mPhone.setSystemProperty(TelephonyProperties.PROPERTY_SIM_STATE, getState().toString());
}
- private void getIccCardStatusDone(IccCardStatus ics) {
- handleIccCardStatus(ics);
+ private void getIccCardStatusDone(AsyncResult ar) {
+ if (ar.exception != null) {
+ Log.e(mLogTag,"Error getting ICC status. "
+ + "RIL_REQUEST_GET_ICC_STATUS should "
+ + "never return an error", ar.exception);
+ return;
+ }
+ handleIccCardStatus((IccCardStatus) ar.result);
}
private void handleIccCardStatus(IccCardStatus newCardStatus) {
if (oldState != State.READY && newState == State.READY &&
(is3gpp || isSubscriptionFromIccCard)) {
mIccFileHandler.setAid(getAid());
- broadcastIccStateChangedIntent(INTENT_VALUE_ICC_READY, null);
mIccRecords.onReady();
}
}
if (!is3gpp) {
handleCdmaSubscriptionSource();
}
+ mPhone.mCM.getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE));
break;
case EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED:
handleCdmaSubscriptionSource();
obtainMessage(EVENT_QUERY_FACILITY_LOCK_DONE));
break;
case EVENT_GET_ICC_STATUS_DONE:
- IccCardStatus cs = (IccCardStatus)msg.obj;
+ ar = (AsyncResult)msg.obj;
+
+ getIccCardStatusDone(ar);
+ break;
+ case EVENT_PINPUK_DONE:
+ // a PIN/PUK/PIN2/PUK2/Network Personalization
+ // request has completed. ar.userObj is the response Message
+ // Repoll before returning
+ ar = (AsyncResult)msg.obj;
+ // TODO should abstract these exceptions
+ AsyncResult.forMessage(((Message)ar.userObj)).exception
+ = ar.exception;
+ mPhone.mCM.getIccCardStatus(
+ obtainMessage(EVENT_REPOLL_STATUS_DONE, ar.userObj));
+ break;
+ case EVENT_REPOLL_STATUS_DONE:
+ // Finished repolling status after PIN operation
+ // ar.userObj is the response messaeg
+ // ar.userObj.obj is already an AsyncResult with an
+ // appropriate exception filled in if applicable
- getIccCardStatusDone(cs);
+ ar = (AsyncResult)msg.obj;
+ getIccCardStatusDone(ar);
+ ((Message)ar.userObj).sendToTarget();
break;
case EVENT_QUERY_FACILITY_LOCK_DONE:
ar = (AsyncResult)msg.obj;
= ar.exception;
((Message)ar.userObj).sendToTarget();
break;
+ case EVENT_ICC_STATUS_CHANGED:
+ Log.d(mLogTag, "Received Event EVENT_ICC_STATUS_CHANGED");
+ mPhone.mCM.getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE));
+ break;
case EVENT_CARD_REMOVED:
onIccSwap(false);
break;
Log.d(mLogTag, "[IccCard] " + msg);
}
- private void loge(String msg) {
- Log.e(mLogTag, "[IccCard] " + msg);
- }
-
protected int getCurrentApplicationIndex() {
if (is3gpp) {
return mIccCardStatus.getGsmUmtsSubscriptionAppIndex();
public IccPhoneBookInterfaceManager(PhoneBase phone) {
this.phone = phone;
- IccRecords r = phone.mIccRecords.get();
- if (r != null) {
- adnCache = r.getAdnCache();
- }
}
public void dispose() {
}
- public void updateIccRecords(IccRecords iccRecords) {
- if (iccRecords != null) {
- adnCache = iccRecords.getAdnCache();
- } else {
- adnCache = null;
- }
- }
-
protected void publish() {
//NOTE service "simphonebook" added by IccSmsInterfaceManagerProxy
ServiceManager.addService("simphonebook", this);
import com.android.internal.telephony.gsm.UsimServiceTable;
import com.android.internal.telephony.ims.IsimRecords;
-import java.util.concurrent.atomic.AtomicBoolean;
-
/**
* {@hide}
*/
protected static final boolean DBG = true;
// ***** Instance Variables
- protected AtomicBoolean mDestroyed = new AtomicBoolean(false);
+ protected boolean mDestroyed = false; // set to true once this object needs to be disposed of
protected Context mContext;
protected CommandsInterface mCi;
protected IccFileHandler mFh;
// ***** Event Constants
protected static final int EVENT_SET_MSISDN_DONE = 30;
- public static final int EVENT_MWI = 0; // Message Waiting indication
- public static final int EVENT_CFI = 1; // Call Forwarding indication
- public static final int EVENT_SPN = 2; // Service Provider Name
+ public static final int EVENT_MWI = 0;
+ public static final int EVENT_CFI = 1;
+ public static final int EVENT_SPN = 2;
public static final int EVENT_GET_ICC_RECORD_DONE = 100;
* Call when the IccRecords object is no longer going to be used.
*/
public void dispose() {
- mDestroyed.set(true);
+ mDestroyed = true;
mParentCard = null;
mFh = null;
mCi = null;
return adnCache;
}
+ public IccCard getIccCard() {
+ return mParentCard;
+ }
+
public void registerForRecordsLoaded(Handler h, int what, Object obj) {
- if (mDestroyed.get()) {
+ if (mDestroyed) {
return;
}
import com.android.internal.telephony.gsm.UsimServiceTable;
import com.android.internal.telephony.ims.IsimRecords;
import com.android.internal.telephony.test.SimulatedRadioControl;
-import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.gsm.SIMRecords;
import java.io.FileDescriptor;
protected static final int EVENT_SET_NETWORK_AUTOMATIC = 28;
protected static final int EVENT_NEW_ICC_SMS = 29;
protected static final int EVENT_ICC_RECORD_EVENTS = 30;
- protected static final int EVENT_ICC_CHANGED = 31;
// Key used to read/write current CLIR setting
public static final String CLIR_KEY = "clir_key";
int mCallRingDelay;
public boolean mIsTheCurrentActivePhone = true;
boolean mIsVoiceCapable = true;
- protected UiccController mUiccController = null;
- public AtomicReference<IccRecords> mIccRecords = new AtomicReference<IccRecords>();
+ public IccRecords mIccRecords;
protected AtomicReference<IccCard> mIccCard = new AtomicReference<IccCard>();
public SmsStorageMonitor mSmsStorageMonitor;
public SmsUsageMonitor mSmsUsageMonitor;
// Initialize device storage and outgoing SMS usage monitors for SMSDispatchers.
mSmsStorageMonitor = new SmsStorageMonitor(this);
mSmsUsageMonitor = new SmsUsageMonitor(context);
- mUiccController = UiccController.getInstance(this);
- mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
}
public void dispose() {
// Dispose the SMS usage and storage monitors
mSmsStorageMonitor.dispose();
mSmsUsageMonitor.dispose();
- mUiccController.unregisterForIccChanged(this);
}
}
mSmsStorageMonitor = null;
mSmsUsageMonitor = null;
mSMS = null;
- mIccRecords.set(null);
+ mIccRecords = null;
mIccCard.set(null);
mDataConnectionTracker = null;
- mUiccController = null;
}
/**
}
break;
- case EVENT_ICC_CHANGED:
- onUpdateIccAvailability();
- break;
-
default:
throw new RuntimeException("unexpected event not handled");
}
return mContext;
}
- // Will be called when icc changed
- protected abstract void onUpdateIccAvailability();
-
/**
* Disables the DNS check (i.e., allows "0.0.0.0").
* Useful for lab testing environment.
@Override
public String getIccSerialNumber() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.iccid : "";
+ return mIccRecords.iccid;
}
@Override
public boolean getIccRecordsLoaded() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.getRecordsLoaded() : false;
+ return mIccRecords.getRecordsLoaded();
}
@Override
public boolean getMessageWaitingIndicator() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.getVoiceMessageWaiting() : false;
+ return mIccRecords.getVoiceMessageWaiting();
}
@Override
public boolean getCallForwardingIndicator() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.getVoiceCallForwardingFlag() : false;
+ return mIccRecords.getVoiceCallForwardingFlag();
}
/**
*/
@Override
public void setVoiceMessageWaiting(int line, int countWaiting) {
- IccRecords r = mIccRecords.get();
- if (r != null) {
- r.setVoiceMessageWaiting(line, countWaiting);
- }
+ mIccRecords.setVoiceMessageWaiting(line, countWaiting);
}
/**
*/
@Override
public UsimServiceTable getUsimServiceTable() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.getUsimServiceTable() : null;
+ return mIccRecords.getUsimServiceTable();
}
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
import android.os.AsyncResult;
import android.os.Handler;
-import android.os.Looper;
import android.os.Message;
import android.os.Registrant;
import android.os.RegistrantList;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
-import com.android.internal.telephony.uicc.UiccController;
-
import java.io.FileDescriptor;
import java.io.PrintWriter;
public abstract class ServiceStateTracker extends Handler {
protected CommandsInterface cm;
- protected UiccController mUiccController = null;
- protected IccCard mIccCard = null;
- protected IccRecords mIccRecords = null;
public ServiceState ss;
protected ServiceState newSS;
protected static final int EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED = 39;
protected static final int EVENT_CDMA_PRL_VERSION_CHANGED = 40;
protected static final int EVENT_RADIO_ON = 41;
- protected static final int EVENT_ICC_CHANGED = 42;
+
protected static final String TIMEZONE_PROPERTY = "persist.sys.timezone";
protected static final String REGISTRATION_DENIED_GEN = "General";
protected static final String REGISTRATION_DENIED_AUTH = "Authentication Failure";
- public ServiceStateTracker(PhoneBase p, CommandsInterface ci) {
- cm = ci;
- mUiccController = UiccController.getInstance();
- mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
+ public ServiceStateTracker() {
}
public boolean getDesiredPowerState() {
}
break;
- case EVENT_ICC_CHANGED:
- onUpdateIccAvailability();
- break;
-
default:
log("Unhandled message with number: " + msg.what);
break;
protected abstract void handlePollStateResult(int what, AsyncResult ar);
protected abstract void updateSpnDisplay();
protected abstract void setPowerStateToDesired();
- protected abstract void onUpdateIccAvailability();
protected abstract void log(String s);
protected abstract void loge(String s);
pollingContext = new int[1];
}
- /**
- * Verifies the current thread is the same as the thread originally
- * used in the initialization of this instance. Throws RuntimeException
- * if not.
- *
- * @exception RuntimeException if the current thread is not
- * the thread that originally obtained this PhoneBase instance.
- */
- protected void checkCorrectThread() {
- if (Thread.currentThread() != getLooper().getThread()) {
- throw new RuntimeException(
- "ServiceStateTracker must be used from within one thread");
- }
- }
-
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("ServiceStateTracker:");
pw.println(" ss=" + ss);
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.IccCard;
-import com.android.internal.telephony.IccRecords;
import com.android.internal.telephony.OperatorInfo;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneNotifier;
public CDMALTEPhone(Context context, CommandsInterface ci, PhoneNotifier notifier) {
super(context, ci, notifier, false);
m3gppSMS = new GsmSMSDispatcher(this, mSmsStorageMonitor, mSmsUsageMonitor);
+ mIccRecords.registerForNewSms(this, EVENT_NEW_ICC_SMS, null);
}
@Override
@Override
protected void initSstIcc() {
+ mIccCard.set(UiccController.getInstance(this).getIccCard());
+ mIccRecords = mIccCard.get().getIccRecords();
+ // CdmaLteServiceStateTracker registers with IccCard to know
+ // when the card is ready. So create mIccCard before the ServiceStateTracker
mSST = new CdmaLteServiceStateTracker(this);
}
synchronized(PhoneProxy.lockForRadioTechnologyChange) {
super.dispose();
m3gppSMS.dispose();
+ mIccRecords.unregisterForNewSms(this);
}
}
@Override
public boolean updateCurrentCarrierInProvider() {
- IccRecords r = mIccRecords.get();
- if (r != null) {
+ if (mIccRecords != null) {
try {
Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
ContentValues map = new ContentValues();
- String operatorNumeric = r.getOperatorNumeric();
+ String operatorNumeric = mIccRecords.getOperatorNumeric();
map.put(Telephony.Carriers.NUMERIC, operatorNumeric);
if (DBG) log("updateCurrentCarrierInProvider from UICC: numeric=" +
operatorNumeric);
// return IMSI from USIM as subscriber ID.
@Override
public String getSubscriberId() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.getIMSI() : "";
+ return mIccRecords.getIMSI();
}
@Override
@Override
public IsimRecords getIsimRecords() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.getIsimRecords() : null;
+ return mIccRecords.getIsimRecords();
}
@Override
public String getMsisdn() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.getMsisdnNumber() : null;
+ return mIccRecords.getMsisdnNumber();
}
@Override
}
@Override
- protected void registerForRuimRecordEvents() {
- IccRecords r = mIccRecords.get();
- if (r == null) {
- return;
- }
- r.registerForNewSms(this, EVENT_NEW_ICC_SMS, null);
- super.registerForRuimRecordEvents();
- }
-
- @Override
- protected void unregisterForRuimRecordEvents() {
- IccRecords r = mIccRecords.get();
- if (r == null) {
- return;
- }
- r.unregisterForNewSms(this);
- super.unregisterForRuimRecordEvents();
- }
-
- @Override
protected void log(String s) {
Log.d(LOG_TAG, "[CDMALTEPhone] " + s);
}
import com.android.internal.telephony.IccException;
import com.android.internal.telephony.IccFileHandler;
import com.android.internal.telephony.IccPhoneBookInterfaceManager;
-import com.android.internal.telephony.IccRecords;
import com.android.internal.telephony.IccSmsInterfaceManager;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.MmiCode;
}
protected void initSstIcc() {
+ mIccCard.set(UiccController.getInstance(this).getIccCard());
+ mIccRecords = mIccCard.get().getIccRecords();
+ // CdmaServiceStateTracker registers with IccCard to know
+ // when the Ruim card is ready. So create mIccCard before the ServiceStateTracker
mSST = new CdmaServiceStateTracker(this);
}
mEriManager = new EriManager(this, context, EriManager.ERI_FROM_XML);
mCM.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
+ registerForRuimRecordEvents();
mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
mCM.registerForOn(this, EVENT_RADIO_ON, null);
mCM.setOnSuppServiceNotification(this, EVENT_SSN, null);
Message resp;
mVmNumber = voiceMailNumber;
resp = obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete);
- IccRecords r = mIccRecords.get();
- if (r != null) {
- r.setVoiceMailNumber(alphaTag, mVmNumber, resp);
- }
+ mIccRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp);
}
public String getVoiceMailNumber() {
* @hide
*/
public int getVoiceMessageCount() {
- IccRecords r = mIccRecords.get();
- int voicemailCount = (r != null) ? r.getVoiceMessageCount() : 0;
+ 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.
}
}
- @Override
- protected void onUpdateIccAvailability() {
- if (mUiccController == null ) {
- return;
- }
-
- IccCard newIccCard = mUiccController.getIccCard();
-
- IccCard c = mIccCard.get();
- if (c != newIccCard) {
- if (c != null) {
- log("Removing stale icc objects.");
- if (mIccRecords.get() != null) {
- unregisterForRuimRecordEvents();
- if (mRuimPhoneBookInterfaceManager != null) {
- mRuimPhoneBookInterfaceManager.updateIccRecords(null);
- }
- }
- mIccRecords.set(null);
- mIccCard.set(null);
- }
- if (newIccCard != null) {
- log("New card found");
- mIccCard.set(newIccCard);
- mIccRecords.set(newIccCard.getIccRecords());
- registerForRuimRecordEvents();
- if (mRuimPhoneBookInterfaceManager != null) {
- mRuimPhoneBookInterfaceManager.updateIccRecords(mIccRecords.get());
- }
- }
- }
- }
-
private void processIccRecordEvents(int eventCode) {
switch (eventCode) {
case RuimRecords.EVENT_MWI:
return mEriManager.isEriFileLoaded();
}
- protected void registerForRuimRecordEvents() {
- IccRecords r = mIccRecords.get();
- if (r == null) {
- return;
- }
- r.registerForRecordsEvents(this, EVENT_ICC_RECORD_EVENTS, null);
- r.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null);
+ private void registerForRuimRecordEvents() {
+ mIccRecords.registerForRecordsEvents(this, EVENT_ICC_RECORD_EVENTS, null);
+ mIccRecords.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null);
}
- protected void unregisterForRuimRecordEvents() {
- IccRecords r = mIccRecords.get();
- if (r == null) {
- return;
- }
- r.unregisterForRecordsEvents(this);
- r.unregisterForRecordsLoaded(this);
+ private void unregisterForRuimRecordEvents() {
+ mIccRecords.unregisterForRecordsEvents(this);
+ mIccRecords.unregisterForRecordsLoaded(this);
}
protected void log(String s) {
import com.android.internal.telephony.DataConnectionAc;
import com.android.internal.telephony.DataConnectionTracker;
import com.android.internal.telephony.EventLogTags;
-import com.android.internal.telephony.IccCard;
-import com.android.internal.telephony.IccRecords;
import com.android.internal.telephony.RetryManager;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.Phone;
p.mCM.registerForAvailable (this, EVENT_RADIO_AVAILABLE, null);
p.mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
+ p.mIccRecords.registerForRecordsLoaded(this, EVENT_RECORDS_LOADED, null);
p.mCM.registerForDataNetworkStateChanged (this, EVENT_DATA_STATE_CHANGED, null);
p.mCT.registerForVoiceCallEnded (this, EVENT_VOICE_CALL_ENDED, null);
p.mCT.registerForVoiceCallStarted (this, EVENT_VOICE_CALL_STARTED, null);
// Unregister from all events
mPhone.mCM.unregisterForAvailable(this);
mPhone.mCM.unregisterForOffOrNotAvailable(this);
- IccRecords r = mIccRecords.get();
- if (r != null) { r.unregisterForRecordsLoaded(this);}
+ mCdmaPhone.mIccRecords.unregisterForRecordsLoaded(this);
mPhone.mCM.unregisterForDataNetworkStateChanged(this);
mCdmaPhone.mCT.unregisterForVoiceCallEnded(this);
mCdmaPhone.mCT.unregisterForVoiceCallStarted(this);
boolean subscriptionFromNv = (mCdmaSSM.getCdmaSubscriptionSource()
== CdmaSubscriptionSourceManager.SUBSCRIPTION_FROM_NV);
- IccRecords r = mIccRecords.get();
boolean allowed =
(psState == ServiceState.STATE_IN_SERVICE ||
mAutoAttachOnCreation) &&
(subscriptionFromNv ||
- (r != null && r.getRecordsLoaded())) &&
+ mCdmaPhone.mIccRecords.getRecordsLoaded()) &&
(mCdmaPhone.mSST.isConcurrentVoiceAndDataAllowed() ||
mPhone.getState() == Phone.State.IDLE) &&
!roaming &&
reason += " - psState= " + psState;
}
if (!subscriptionFromNv &&
- !(r != null && r.getRecordsLoaded())) {
+ !mCdmaPhone.mIccRecords.getRecordsLoaded()) {
reason += " - RUIM not loaded";
}
if (!(mCdmaPhone.mSST.isConcurrentVoiceAndDataAllowed() ||
}
@Override
- protected void onUpdateIcc() {
- if (mUiccController == null ) {
- return;
- }
-
- IccCard newIccCard = mUiccController.getIccCard();
- IccRecords newIccRecords = null;
- if (newIccCard != null) {
- newIccRecords = newIccCard.getIccRecords();
- }
-
- IccRecords r = mIccRecords.get();
- if (r != newIccRecords) {
- if (r != null) {
- log("Removing stale icc objects.");
- r.unregisterForRecordsLoaded(this);
- mIccRecords.set(null);
- }
- if (newIccCard != null) {
- log("New card found");
- mIccRecords.set(newIccRecords);
- newIccRecords.registerForRecordsLoaded(this, EVENT_RECORDS_LOADED, null);
- }
- }
- }
-
- @Override
public boolean isDisconnected() {
return ((mState == State.IDLE) || (mState == State.FAILED));
}
handlePollStateResult(msg.what, ar);
break;
case EVENT_RUIM_RECORDS_LOADED:
- CdmaLteUiccRecords sim = (CdmaLteUiccRecords)mIccRecords;
+ CdmaLteUiccRecords sim = (CdmaLteUiccRecords)phone.mIccRecords;
if ((sim != null) && sim.isProvisioned()) {
mMdn = sim.getMdn();
mMin = sim.getMin();
ss.setOperatorAlphaLong(eriText);
}
- if (mIccCard != null && mIccCard.getState() == IccCard.State.READY &&
- mIccRecords != null) {
+ if (phone.getIccCard().getState() == IccCard.State.READY) {
// SIM is found on the device. If ERI roaming is OFF, and SID/NID matches
// one configfured in SIM, use operator name from CSIM record.
boolean showSpn =
- ((CdmaLteUiccRecords)mIccRecords).getCsimSpnDisplayCondition();
+ ((CdmaLteUiccRecords)phone.mIccRecords).getCsimSpnDisplayCondition();
int iconIndex = ss.getCdmaEriIconIndex();
if (showSpn && (iconIndex == EriInfo.ROAMING_INDICATOR_OFF) &&
- isInHomeSidNid(ss.getSystemId(), ss.getNetworkId()) &&
- mIccRecords != null) {
- ss.setOperatorAlphaLong(mIccRecords.getServiceProviderName());
+ isInHomeSidNid(ss.getSystemId(), ss.getNetworkId())) {
+ ss.setOperatorAlphaLong(phone.mIccRecords.getServiceProviderName());
}
}
long mSavedTime;
long mSavedAtTime;
+ /**
+ * We can't register for SIM_RECORDS_LOADED immediately because the
+ * SIMRecords object may not be instantiated yet.
+ */
+ private boolean mNeedToRegForRuimLoaded = false;
+
/** Wake lock used while setting time of day. */
private PowerManager.WakeLock mWakeLock;
private static final String WAKELOCK_TAG = "ServiceStateTracker";
};
public CdmaServiceStateTracker(CDMAPhone phone) {
- super(phone, phone.mCM);
+ super();
this.phone = phone;
cr = phone.getContext().getContentResolver();
+ cm = phone.mCM;
ss = new ServiceState();
newSS = new ServiceState();
cellLoc = new CdmaCellLocation();
Settings.System.getUriFor(Settings.System.AUTO_TIME_ZONE), true,
mAutoTimeZoneObserver);
setSignalStrengthDefaultValues();
+
+ mNeedToRegForRuimLoaded = true;
}
public void dispose() {
- checkCorrectThread();
// Unregister for all events.
cm.unregisterForRadioStateChanged(this);
cm.unregisterForVoiceNetworkStateChanged(this);
+ phone.getIccCard().unregisterForReady(this);
cm.unregisterForCdmaOtaProvision(this);
phone.unregisterForEriFileLoaded(this);
- if (mIccCard != null) {mIccCard.unregisterForReady(this);}
- if (mIccRecords != null) {mIccRecords.unregisterForRecordsLoaded(this);}
+ phone.mIccRecords.unregisterForRecordsLoaded(this);
cm.unSetOnSignalStrengthUpdate(this);
cm.unSetOnNITZTime(this);
cr.unregisterContentObserver(mAutoTimeObserver);
case EVENT_RUIM_READY:
// TODO: Consider calling setCurrentPreferredNetworkType as we do in GsmSST.
// cm.setCurrentPreferredNetworkType();
+
+ // The RUIM is now ready i.e if it was locked it has been
+ // unlocked. At this stage, the radio is already powered on.
+ if (mNeedToRegForRuimLoaded) {
+ phone.mIccRecords.registerForRecordsLoaded(this,
+ EVENT_RUIM_RECORDS_LOADED, null);
+ mNeedToRegForRuimLoaded = false;
+ }
if (DBG) log("Receive EVENT_RUIM_READY and Send Request getCDMASubscription.");
getSubscriptionInfoAndStartPollingThreads();
phone.prepareEri();
mIsMinInfoReady = true;
updateOtaspState();
- if (mIccCard != null) {
- if (DBG) log("GET_CDMA_SUBSCRIPTION broadcast Icc state changed");
- mIccCard.broadcastIccStateChangedIntent(IccCard.INTENT_VALUE_ICC_IMSI,
- null);
- } else {
- if (DBG) {
- log("GET_CDMA_SUBSCRIPTION mIccCard is null (probably NV type device)" +
- " can't broadcast Icc state changed");
- }
- }
+ phone.getIccCard().broadcastIccStateChangedIntent(IccCard.INTENT_VALUE_ICC_IMSI,
+ null);
} else {
if (DBG) {
log("GET_CDMA_SUBSCRIPTION: error parsing cdmaSubscription params num="
if (!isSubscriptionFromRuim) {
// NV is ready when subscription source is NV
sendMessage(obtainMessage(EVENT_NV_READY));
+ } else {
+ phone.getIccCard().registerForReady(this, EVENT_RUIM_READY, null);
}
}
}
@Override
- protected void onUpdateIccAvailability() {
- if (mUiccController == null ) {
- return;
- }
-
- IccCard newIccCard = mUiccController.getIccCard();
-
- if (mIccCard != newIccCard) {
- if (mIccCard != null) {
- log("Removing stale icc objects.");
- mIccCard.unregisterForReady(this);
- if (mIccRecords != null) {
- mIccRecords.unregisterForRecordsLoaded(this);
- }
- mIccRecords = null;
- mIccCard = null;
- }
- if (newIccCard != null) {
- log("New card found");
- mIccCard = newIccCard;
- mIccRecords = mIccCard.getIccRecords();
- if (isSubscriptionFromRuim) {
- mIccCard.registerForReady(this, EVENT_RUIM_READY, null);
- if (mIccRecords != null) {
- mIccRecords.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null);
- }
- }
- }
- }
- }
-
- @Override
protected void log(String s) {
Log.d(LOG_TAG, "[CdmaSST] " + s);
}
pw.println(" mSavedTimeZone=" + mSavedTimeZone);
pw.println(" mSavedTime=" + mSavedTime);
pw.println(" mSavedAtTime=" + mSavedAtTime);
+ pw.println(" mNeedToRegForRuimLoaded=" + mNeedToRegForRuimLoaded);
pw.println(" mWakeLock=" + mWakeLock);
pw.println(" mCurPlmn=" + mCurPlmn);
pw.println(" mMdn=" + mMdn);
import android.os.Message;
import android.util.Log;
-import com.android.internal.telephony.IccFileHandler;
import com.android.internal.telephony.IccPhoneBookInterfaceManager;
/**
public RuimPhoneBookInterfaceManager(CDMAPhone phone) {
super(phone);
+ adnCache = phone.mIccRecords.getAdnCache();
//NOTE service "simphonebook" added by IccSmsInterfaceManagerProxy
}
AtomicBoolean status = new AtomicBoolean(false);
Message response = mBaseHandler.obtainMessage(EVENT_GET_SIZE_DONE, status);
- IccFileHandler fh = phone.getIccFileHandler();
- //IccFileHandler can be null if there is no icc card present.
- if (fh != null) {
- fh.getEFLinearRecordSize(efid, response);
- waitForResult(status);
- }
+ phone.getIccFileHandler().getEFLinearRecordSize(efid, response);
+ waitForResult(status);
}
return recordSize;
boolean isRecordLoadResponse = false;
- if (mDestroyed.get()) {
+ if (mDestroyed) {
loge("Received message " + msg +
"[" + msg.what + "] while being destroyed. Ignoring.");
return;
// One record loaded successfully or failed, In either case
// we need to update the recordsToLoad count
recordsToLoad -= 1;
- if (DBG) log("onRecordLoaded " + recordsToLoad + " requested: " + recordsRequested);
+ if (DBG) log("RuimRecords:onRecordLoaded " + recordsToLoad + " requested: " + recordsRequested);
if (recordsToLoad == 0 && recordsRequested == true) {
onAllRecordsLoaded();
} else if (recordsToLoad < 0) {
- loge("recordsToLoad <0, programmer error suspected");
+ loge("RuimRecords: recordsToLoad <0, programmer error suspected");
recordsToLoad = 0;
}
}
@Override
protected void onAllRecordsLoaded() {
- if (DBG) log("record load complete");
-
// Further records that can be inserted are Operator/OEM dependent
String operator = getRUIMOperatorNumeric();
@Override
public void onReady() {
+ /* broadcast intent ICC_READY here so that we can make sure
+ READY is sent before IMSI ready
+ */
+
+ mParentCard.broadcastIccStateChangedIntent(
+ IccCard.INTENT_VALUE_ICC_READY, null);
+
fetchRuimRecords();
mCi.getCDMASubscription(obtainMessage(EVENT_GET_CDMA_SUBSCRIPTION_DONE));
private void fetchRuimRecords() {
recordsRequested = true;
- if (DBG) log("fetchRuimRecords " + recordsToLoad);
+ Log.v(LOG_TAG, "RuimRecords:fetchRuimRecords " + recordsToLoad);
mCi.getIMSI(obtainMessage(EVENT_GET_IMSI_DONE));
recordsToLoad++;
obtainMessage(EVENT_GET_ICCID_DONE));
recordsToLoad++;
- if (DBG) log("fetchRuimRecords " + recordsToLoad + " requested: " + recordsRequested);
+ log("RuimRecords:fetchRuimRecords " + recordsToLoad + " requested: " + recordsRequested);
// Further records that can be inserted are Operator/OEM dependent
}
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.IccFileHandler;
import com.android.internal.telephony.IccPhoneBookInterfaceManager;
-import com.android.internal.telephony.IccRecords;
import com.android.internal.telephony.IccSmsInterfaceManager;
import com.android.internal.telephony.MmiCode;
import com.android.internal.telephony.OperatorInfo;
if (ci instanceof SimulatedRadioControl) {
mSimulatedRadioControl = (SimulatedRadioControl) ci;
}
+
mCM.setPhoneType(Phone.PHONE_TYPE_GSM);
+ mIccCard.set(UiccController.getInstance(this).getIccCard());
+ mIccRecords = mIccCard.get().getIccRecords();
mCT = new GsmCallTracker(this);
mSST = new GsmServiceStateTracker (this);
mSMS = new GsmSMSDispatcher(this, mSmsStorageMonitor, mSmsUsageMonitor);
-
mDataConnectionTracker = new GsmDataConnectionTracker (this);
if (!unitTestMode) {
mSimPhoneBookIntManager = new SimPhoneBookInterfaceManager(this);
}
mCM.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
+ registerForSimRecordEvents();
mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
mCM.registerForOn(this, EVENT_RADIO_ON, null);
mCM.setOnUSSD(this, EVENT_USSD, null);
public String getVoiceMailNumber() {
// Read from the SIM. If its null, try reading from the shared preference area.
- IccRecords r = mIccRecords.get();
- String number = (r != null) ? r.getVoiceMailNumber() : "";
+ String number = mIccRecords.getVoiceMailNumber();
if (TextUtils.isEmpty(number)) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
number = sp.getString(VM_NUMBER, null);
public String getVoiceMailAlphaTag() {
String ret;
- IccRecords r = mIccRecords.get();
- ret = (r != null) ? r.getVoiceMailAlphaTag() : "";
+ ret = mIccRecords.getVoiceMailAlphaTag();
if (ret == null || ret.length() == 0) {
return mContext.getText(
}
public String getSubscriberId() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.getIMSI() : "";
+ return mIccRecords.getIMSI();
}
public String getLine1Number() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.getMsisdnNumber() : "";
+ return mIccRecords.getMsisdnNumber();
}
@Override
public String getMsisdn() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.getMsisdnNumber() : "";
+ return mIccRecords.getMsisdnNumber();
}
public String getLine1AlphaTag() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.getMsisdnAlphaTag() : "";
+ return mIccRecords.getMsisdnAlphaTag();
}
public void setLine1Number(String alphaTag, String number, Message onComplete) {
- IccRecords r = mIccRecords.get();
- if (r != null) {
- r.setMsisdnNumber(alphaTag, number, onComplete);
- }
+ mIccRecords.setMsisdnNumber(alphaTag, number, onComplete);
}
public void setVoiceMailNumber(String alphaTag,
Message resp;
mVmNumber = voiceMailNumber;
resp = obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete);
- IccRecords r = mIccRecords.get();
- if (r != null) {
- r.setVoiceMailNumber(alphaTag, mVmNumber, resp);
- }
+ mIccRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp);
}
private boolean isValidCommandInterfaceCFReason (int commandInterfaceCFReason) {
case EVENT_SET_CALL_FORWARD_DONE:
ar = (AsyncResult)msg.obj;
- IccRecords r = mIccRecords.get();
- if (ar.exception == null && r != null) {
- r.setVoiceCallForwardingFlag(1, msg.arg1 == 1);
+ if (ar.exception == null) {
+ mIccRecords.setVoiceCallForwardingFlag(1, msg.arg1 == 1);
}
onComplete = (Message) ar.userObj;
if (onComplete != null) {
}
}
- @Override
- protected void onUpdateIccAvailability() {
- if (mUiccController == null ) {
- return;
- }
-
- IccCard newIccCard = mUiccController.getIccCard();
-
- IccCard c = mIccCard.get();
- if (c != newIccCard) {
- if (c != null) {
- if (LOCAL_DEBUG) log("Removing stale icc objects.");
- if (mIccRecords.get() != null) {
- unregisterForSimRecordEvents();
- mSimPhoneBookIntManager.updateIccRecords(null);
- }
- mIccRecords.set(null);
- mIccCard.set(null);
- }
- if (newIccCard != null) {
- if (LOCAL_DEBUG) log("New card found");
- mIccCard.set(newIccCard);
- mIccRecords.set(newIccCard.getIccRecords());
- registerForSimRecordEvents();
- mSimPhoneBookIntManager.updateIccRecords(mIccRecords.get());
- }
- }
- }
-
private void processIccRecordEvents(int eventCode) {
switch (eventCode) {
- case IccRecords.EVENT_CFI:
+ case SIMRecords.EVENT_CFI:
notifyCallForwardingIndicator();
break;
- case IccRecords.EVENT_MWI:
+ case SIMRecords.EVENT_MWI:
notifyMessageWaitingIndicator();
break;
}
* @return true for success; false otherwise.
*/
boolean updateCurrentCarrierInProvider() {
- IccRecords r = mIccRecords.get();
- if (r != null) {
+ if (mIccRecords != null) {
try {
Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
ContentValues map = new ContentValues();
- map.put(Telephony.Carriers.NUMERIC, r.getOperatorNumeric());
+ map.put(Telephony.Carriers.NUMERIC, mIccRecords.getOperatorNumeric());
mContext.getContentResolver().insert(uri, map);
return true;
} catch (SQLException e) {
}
private void handleCfuQueryResult(CallForwardInfo[] infos) {
- IccRecords r = mIccRecords.get();
- if (r != null) {
- if (infos == null || infos.length == 0) {
- // Assume the default is not active
- // Set unconditional CFF in SIM to false
- r.setVoiceCallForwardingFlag(1, false);
- } else {
- for (int i = 0, s = infos.length; i < s; i++) {
- if ((infos[i].serviceClass & SERVICE_CLASS_VOICE) != 0) {
- r.setVoiceCallForwardingFlag(1, (infos[i].status == 1));
- // should only have the one
- break;
- }
+ if (infos == null || infos.length == 0) {
+ // Assume the default is not active
+ // Set unconditional CFF in SIM to false
+ mIccRecords.setVoiceCallForwardingFlag(1, false);
+ } else {
+ for (int i = 0, s = infos.length; i < s; i++) {
+ if ((infos[i].serviceClass & SERVICE_CLASS_VOICE) != 0) {
+ mIccRecords.setVoiceCallForwardingFlag(1, (infos[i].status == 1));
+ // should only have the one
+ break;
}
}
}
}
public boolean isCspPlmnEnabled() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.isCspPlmnEnabled() : false;
+ return mIccRecords.isCspPlmnEnabled();
}
private void registerForSimRecordEvents() {
- IccRecords r = mIccRecords.get();
- if (r == null) {
- return;
- }
- r.registerForNetworkSelectionModeAutomatic(
+ mIccRecords.registerForNetworkSelectionModeAutomatic(
this, EVENT_SET_NETWORK_AUTOMATIC, null);
- r.registerForNewSms(this, EVENT_NEW_ICC_SMS, null);
- r.registerForRecordsEvents(this, EVENT_ICC_RECORD_EVENTS, null);
- r.registerForRecordsLoaded(this, EVENT_SIM_RECORDS_LOADED, null);
+ mIccRecords.registerForNewSms(this, EVENT_NEW_ICC_SMS, null);
+ mIccRecords.registerForRecordsEvents(this, EVENT_ICC_RECORD_EVENTS, null);
+ mIccRecords.registerForRecordsLoaded(this, EVENT_SIM_RECORDS_LOADED, null);
}
private void unregisterForSimRecordEvents() {
- IccRecords r = mIccRecords.get();
- if (r == null) {
- return;
- }
- r.unregisterForNetworkSelectionModeAutomatic(this);
- r.unregisterForNewSms(this);
- r.unregisterForRecordsEvents(this);
- r.unregisterForRecordsLoaded(this);
- }
-
- protected void log(String s) {
- Log.d(LOG_TAG, "[GSMPhone] " + s);
+ mIccRecords.unregisterForNetworkSelectionModeAutomatic(this);
+ mIccRecords.unregisterForNewSms(this);
+ mIccRecords.unregisterForRecordsEvents(this);
+ mIccRecords.unregisterForRecordsLoaded(this);
}
@Override
import com.android.internal.telephony.DataConnectionAc;
import com.android.internal.telephony.DataConnectionTracker;
import com.android.internal.telephony.EventLogTags;
-import com.android.internal.telephony.IccCard;
-import com.android.internal.telephony.IccRecords;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.RILConstants;
p.mCM.registerForAvailable (this, EVENT_RADIO_AVAILABLE, null);
p.mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, 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);
//Unregister for all events
mPhone.mCM.unregisterForAvailable(this);
mPhone.mCM.unregisterForOffOrNotAvailable(this);
- IccRecords r = mIccRecords.get();
- if (r != null) { r.unregisterForRecordsLoaded(this);}
+ mPhone.mIccRecords.unregisterForRecordsLoaded(this);
mPhone.mCM.unregisterForDataNetworkStateChanged(this);
mPhone.getCallTracker().unregisterForVoiceCallEnded(this);
mPhone.getCallTracker().unregisterForVoiceCallStarted(this);
int gprsState = mPhone.getServiceStateTracker().getCurrentDataConnectionState();
boolean desiredPowerState = mPhone.getServiceStateTracker().getDesiredPowerState();
- IccRecords r = mIccRecords.get();
- boolean recordsLoaded = (r != null) ? r.getRecordsLoaded() : false;
boolean allowed =
(gprsState == ServiceState.STATE_IN_SERVICE || mAutoAttachOnCreation) &&
- recordsLoaded &&
+ mPhone.mIccRecords.getRecordsLoaded() &&
(mPhone.getState() == Phone.State.IDLE ||
mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) &&
internalDataEnabled &&
if (!((gprsState == ServiceState.STATE_IN_SERVICE) || mAutoAttachOnCreation)) {
reason += " - gprs= " + gprsState;
}
- if (!recordsLoaded) reason += " - SIM not loaded";
+ if (!mPhone.mIccRecords.getRecordsLoaded()) reason += " - SIM not loaded";
if (mPhone.getState() != Phone.State.IDLE &&
!mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()) {
reason += " - PhoneState= " + mPhone.getState();
log("onRadioAvailable: We're on the simulator; assuming data is connected");
}
- IccRecords r = mIccRecords.get();
- if (r != null && r.getRecordsLoaded()) {
+ if (mPhone.mIccRecords.getRecordsLoaded()) {
notifyOffApnsOfAvailability(null);
}
*/
private void createAllApnList() {
mAllApns = new ArrayList<ApnSetting>();
- IccRecords r = mIccRecords.get();
- String operator = (r != null) ? r.getOperatorNumeric() : "";
+ String operator = mPhone.mIccRecords.getOperatorNumeric();
if (operator != null) {
String selection = "numeric = '" + operator + "'";
// query only enabled apn.
}
}
- IccRecords r = mIccRecords.get();
- String operator = (r != null) ? r.getOperatorNumeric() : "";
- int radioTech = mPhone.getServiceState().getRadioTechnology();
+ String operator = mPhone.mIccRecords.getOperatorNumeric();
+ int networkType = mPhone.getServiceState().getNetworkType();
if (requestedApnType.equals(Phone.APN_TYPE_DEFAULT)) {
if (canSetPreferApn && mPreferredApn != null) {
+ mPreferredApn.numeric + ":" + mPreferredApn);
}
if (mPreferredApn.numeric.equals(operator)) {
- if (mPreferredApn.bearer == 0 || mPreferredApn.bearer == radioTech) {
+ if (mPreferredApn.bearer == 0 || mPreferredApn.bearer == networkType) {
apnList.add(mPreferredApn);
if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList);
return apnList;
if (mAllApns != null) {
for (ApnSetting apn : mAllApns) {
if (apn.canHandleType(requestedApnType)) {
- if (apn.bearer == 0 || apn.bearer == radioTech) {
+ if (apn.bearer == 0 || apn.bearer == networkType) {
if (DBG) log("apn info : " +apn.toString());
apnList.add(apn);
}
}
@Override
- protected void onUpdateIcc() {
- if (mUiccController == null ) {
- return;
- }
-
- IccCard newIccCard = mUiccController.getIccCard();
- IccRecords newIccRecords = null;
- if (newIccCard != null) {
- newIccRecords = newIccCard.getIccRecords();
- }
-
- IccRecords r = mIccRecords.get();
- if (r != newIccRecords) {
- if (r != null) {
- log("Removing stale icc objects.");
- r.unregisterForRecordsLoaded(this);
- mIccRecords.set(null);
- }
- if (newIccCard != null) {
- log("New card found");
- mIccRecords.set(newIccRecords);
- newIccRecords.registerForRecordsLoaded(this, EVENT_RECORDS_LOADED, null);
- }
- }
- }
-
- @Override
protected void log(String s) {
Log.d(LOG_TAG, "[GsmDCT] "+ s);
}
*/
if ((ar.exception == null) && (msg.arg1 == 1)) {
boolean cffEnabled = (msg.arg2 == 1);
- IccRecords r = phone.mIccRecords.get();
- if (r != null) {
- r.setVoiceCallForwardingFlag(1, cffEnabled);
- }
+ phone.mIccRecords.setVoiceCallForwardingFlag(1, cffEnabled);
}
onSetComplete(ar);
(info.serviceClass & serviceClassMask)
== CommandsInterface.SERVICE_CLASS_VOICE) {
boolean cffEnabled = (info.status == 1);
- IccRecords r = phone.mIccRecords.get();
- if (r != null) {
- r.setVoiceCallForwardingFlag(1, cffEnabled);
- }
+ phone.mIccRecords.setVoiceCallForwardingFlag(1, cffEnabled);
}
return TextUtils.replace(template, sources, destinations);
sb.append(context.getText(com.android.internal.R.string.serviceDisabled));
// Set unconditional CFF in SIM to false
- IccRecords r = phone.mIccRecords.get();
- if (r != null) {
- r.setVoiceCallForwardingFlag(1, false);
- }
+ phone.mIccRecords.setVoiceCallForwardingFlag(1, false);
} else {
SpannableStringBuilder tb = new SpannableStringBuilder();
long mSavedTime;
long mSavedAtTime;
+ /**
+ * We can't register for SIM_RECORDS_LOADED immediately because the
+ * SIMRecords object may not be instantiated yet.
+ */
+ private boolean mNeedToRegForSimLoaded;
+
/** Started the recheck process after finding gprs should registered but not. */
private boolean mStartedGprsRegCheck = false;
};
public GsmServiceStateTracker(GSMPhone phone) {
- super(phone, phone.mCM);
+ super();
this.phone = phone;
+ cm = phone.mCM;
ss = new ServiceState();
newSS = new ServiceState();
cellLoc = new GsmCellLocation();
cm.setOnNITZTime(this, EVENT_NITZ_TIME, null);
cm.setOnSignalStrengthUpdate(this, EVENT_SIGNAL_STRENGTH_UPDATE, null);
cm.setOnRestrictedStateChanged(this, EVENT_RESTRICTED_STATE_CHANGED, null);
+ phone.getIccCard().registerForReady(this, EVENT_SIM_READY, null);
// system setting property AIRPLANE_MODE_ON is set in Settings.
int airplaneMode = Settings.System.getInt(
mAutoTimeZoneObserver);
setSignalStrengthDefaultValues();
+ mNeedToRegForSimLoaded = true;
// Monitor locale change
IntentFilter filter = new IntentFilter();
}
public void dispose() {
- checkCorrectThread();
// Unregister for all events.
cm.unregisterForAvailable(this);
cm.unregisterForRadioStateChanged(this);
cm.unregisterForVoiceNetworkStateChanged(this);
- if (mIccCard != null) {mIccCard.unregisterForReady(this);}
- if (mIccRecords != null) {mIccRecords.unregisterForRecordsLoaded(this);}
+ phone.getIccCard().unregisterForReady(this);
+ phone.mIccRecords.unregisterForRecordsLoaded(this);
cm.unSetOnSignalStrengthUpdate(this);
cm.unSetOnRestrictedStateChanged(this);
cm.unSetOnNITZTime(this);
// Set the network type, in case the radio does not restore it.
cm.setCurrentPreferredNetworkType();
+ // The SIM is now ready i.e if it was locked
+ // it has been unlocked. At this stage, the radio is already
+ // powered on.
+ if (mNeedToRegForSimLoaded) {
+ phone.mIccRecords.registerForRecordsLoaded(this,
+ EVENT_SIM_RECORDS_LOADED, null);
+ mNeedToRegForSimLoaded = false;
+ }
+
boolean skipRestoringSelection = phone.getContext().getResources().getBoolean(
com.android.internal.R.bool.skip_restoring_network_selection);
}
protected void updateSpnDisplay() {
- if (mIccRecords == null) {
- return;
- }
- int rule = mIccRecords.getDisplayRule(ss.getOperatorNumeric());
- String spn = mIccRecords.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
((state & RILConstants.RIL_RESTRICTED_STATE_CS_EMERGENCY) != 0) ||
((state & RILConstants.RIL_RESTRICTED_STATE_CS_ALL) != 0) );
//ignore the normal call and data restricted state before SIM READY
- if (mIccCard.getState() == IccCard.State.READY) {
+ if (phone.getIccCard().getState() == IccCard.State.READY) {
newRs.setCsNormalRestricted(
((state & RILConstants.RIL_RESTRICTED_STATE_CS_NORMAL) != 0) ||
((state & RILConstants.RIL_RESTRICTED_STATE_CS_ALL) != 0) );
}
@Override
- protected void onUpdateIccAvailability() {
- if (mUiccController == null ) {
- return;
- }
-
- IccCard newIccCard = mUiccController.getIccCard();
-
- if (mIccCard != newIccCard) {
- if (mIccCard != null) {
- log("Removing stale icc objects.");
- mIccCard.unregisterForReady(this);
- if (mIccRecords != null) {
- mIccRecords.unregisterForRecordsLoaded(this);
- }
- mIccRecords = null;
- mIccCard = null;
- }
- if (newIccCard != null) {
- log("New card found");
- mIccCard = newIccCard;
- mIccRecords = mIccCard.getIccRecords();
- mIccCard.registerForReady(this, EVENT_SIM_READY, null);
- if (mIccRecords != null) {
- mIccRecords.registerForRecordsLoaded(this, EVENT_SIM_RECORDS_LOADED, null);
- }
- }
- }
- }
- @Override
protected void log(String s) {
Log.d(LOG_TAG, "[GsmSST] " + s);
}
pw.println(" mSavedTimeZone=" + mSavedTimeZone);
pw.println(" mSavedTime=" + mSavedTime);
pw.println(" mSavedAtTime=" + mSavedAtTime);
+ pw.println(" mNeedToRegForSimLoaded=" + mNeedToRegForSimLoaded);
pw.println(" mStartedGprsRegCheck=" + mStartedGprsRegCheck);
pw.println(" mReportedGprsNoReg=" + mReportedGprsNoReg);
pw.println(" mNotification=" + mNotification);
boolean isRecordLoadResponse = false;
- if (mDestroyed.get()) {
+ if (mDestroyed) {
loge("Received message " + msg + "[" + msg.what + "] " +
" while being destroyed. Ignoring.");
return;
@Override
public void onReady() {
+ /* broadcast intent SIM_READY here so that we can make sure
+ READY is sent before IMSI ready
+ */
+ mParentCard.broadcastIccStateChangedIntent(
+ IccCard.INTENT_VALUE_ICC_READY, null);
+
fetchSimRecords();
}
import android.os.Message;
import android.util.Log;
-import com.android.internal.telephony.IccFileHandler;
import com.android.internal.telephony.IccPhoneBookInterfaceManager;
/**
public SimPhoneBookInterfaceManager(GSMPhone phone) {
super(phone);
+ adnCache = phone.mIccRecords.getAdnCache();
//NOTE service "simphonebook" added by IccSmsInterfaceManagerProxy
}
AtomicBoolean status = new AtomicBoolean(false);
Message response = mBaseHandler.obtainMessage(EVENT_GET_SIZE_DONE, status);
- IccFileHandler fh = phone.getIccFileHandler();
- if (fh != null) {
- fh.getEFLinearRecordSize(efid, response);
- waitForResult(status);
- }
+ phone.getIccFileHandler().getEFLinearRecordSize(efid, response);
+ waitForResult(status);
}
return recordSize;
notifyPhoneStateChanged();
}
}
-
- @Override
- protected void onUpdateIccAvailability() {
- }
}
package com.android.internal.telephony.uicc;
-import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.IccCard;
-import com.android.internal.telephony.IccCardStatus;
-import com.android.internal.telephony.IccCardStatus.CardState;
import com.android.internal.telephony.PhoneBase;
+import com.android.internal.telephony.cdma.CDMALTEPhone;
+import com.android.internal.telephony.cdma.CDMAPhone;
+import com.android.internal.telephony.gsm.GSMPhone;
-import android.os.AsyncResult;
-import android.os.Handler;
-import android.os.Message;
-import android.os.Registrant;
-import android.os.RegistrantList;
import android.util.Log;
/* This class is responsible for keeping all knowledge about
* ICCs in the system. It is also used as API to get appropriate
* applications to pass them to phone and service trackers.
*/
-public class UiccController extends Handler {
+public class UiccController {
private static final boolean DBG = true;
private static final String LOG_TAG = "RIL_UiccController";
- private static final int EVENT_ICC_STATUS_CHANGED = 1;
- private static final int EVENT_GET_ICC_STATUS_DONE = 2;
-
private static UiccController mInstance;
private PhoneBase mCurrentPhone;
- private CommandsInterface mCi;
+ private boolean mIsCurrentCard3gpp;
private IccCard mIccCard;
- private boolean mRegisteredWithCi = false;
-
- private RegistrantList mIccChangedRegistrants = new RegistrantList();
public static synchronized UiccController getInstance(PhoneBase phone) {
if (mInstance == null) {
mInstance = new UiccController(phone);
- } else if (phone != null) {
+ } else {
mInstance.setNewPhone(phone);
}
return mInstance;
}
- // This method is not synchronized as getInstance(PhoneBase) is.
- public static UiccController getInstance() {
- return getInstance(null);
- }
-
- public synchronized IccCard getIccCard() {
+ public IccCard getIccCard() {
return mIccCard;
}
- //Notifies when card status changes
- public void registerForIccChanged(Handler h, int what, Object obj) {
- Registrant r = new Registrant (h, what, obj);
- mIccChangedRegistrants.add(r);
- //Notify registrant right after registering, so that it will get the latest ICC status,
- //otherwise which may not happen until there is an actual change in ICC status.
- r.notifyRegistrant();
- }
- public void unregisterForIccChanged(Handler h) {
- mIccChangedRegistrants.remove(h);
- }
-
- @Override
- public void handleMessage (Message msg) {
- switch (msg.what) {
- case EVENT_ICC_STATUS_CHANGED:
- if (DBG) log("Received EVENT_ICC_STATUS_CHANGED, calling getIccCardStatus");
- mCi.getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE));
- break;
- case EVENT_GET_ICC_STATUS_DONE:
- if (DBG) log("Received EVENT_GET_ICC_STATUS_DONE");
- AsyncResult ar = (AsyncResult)msg.obj;
- onGetIccCardStatusDone(ar);
- break;
- default:
- Log.e(LOG_TAG, " Unknown Event " + msg.what);
- }
- }
-
private UiccController(PhoneBase phone) {
if (DBG) log("Creating UiccController");
setNewPhone(phone);
}
- private synchronized void onGetIccCardStatusDone(AsyncResult ar) {
- if (ar.exception != null) {
- Log.e(LOG_TAG,"Error getting ICC status. "
- + "RIL_REQUEST_GET_ICC_STATUS should "
- + "never return an error", ar.exception);
- return;
+ private void setNewPhone(PhoneBase phone) {
+ mCurrentPhone = phone;
+ if (phone instanceof GSMPhone) {
+ if (DBG) log("New phone is GSMPhone");
+ updateCurrentCard(IccCard.CARD_IS_3GPP);
+ } else if (phone instanceof CDMALTEPhone){
+ if (DBG) log("New phone type is CDMALTEPhone");
+ updateCurrentCard(IccCard.CARD_IS_3GPP);
+ } else if (phone instanceof CDMAPhone){
+ if (DBG) log("New phone type is CDMAPhone");
+ updateCurrentCard(IccCard.CARD_IS_NOT_3GPP);
+ } else {
+ Log.e(LOG_TAG, "Unhandled phone type. Critical error!");
}
+ }
- IccCardStatus status = (IccCardStatus)ar.result;
-
- //Update already existing card
- if (mIccCard != null && status.getCardState() == CardState.CARDSTATE_PRESENT) {
- mIccCard.update(mCurrentPhone, status);
+ private void updateCurrentCard(boolean isNewCard3gpp) {
+ if (mIsCurrentCard3gpp == isNewCard3gpp && mIccCard != null) {
+ return;
}
- //Dispose of removed card
- if (mIccCard != null && status.getCardState() != CardState.CARDSTATE_PRESENT) {
+ if (mIccCard != null) {
mIccCard.dispose();
mIccCard = null;
}
- //Create new card
- if (mIccCard == null && status.getCardState() == CardState.CARDSTATE_PRESENT) {
- mIccCard = new IccCard(mCurrentPhone, status, mCurrentPhone.getPhoneName(), true);
- }
-
- if (DBG) log("Notifying IccChangedRegistrants");
- mIccChangedRegistrants.notifyRegistrants();
- }
-
- private void setNewPhone(PhoneBase phone) {
- if (phone == null) {
- throw new RuntimeException("Phone can't be null in UiccController");
- }
-
- if (DBG) log("setNewPhone");
- if (mCurrentPhone != phone) {
- if (mIccCard != null) {
- // Refresh card if phone changed
- // TODO: Remove once card is simplified
- if (DBG) log("Disposing card since phone object changed");
- mIccCard.dispose();
- mIccCard = null;
- }
- sendMessage(obtainMessage(EVENT_ICC_STATUS_CHANGED));
- mCurrentPhone = phone;
-
- if (!mRegisteredWithCi) {
- // This needs to be done only once after we have valid phone object
- mCi = mCurrentPhone.mCM;
- mCi.registerForIccStatusChanged(this, EVENT_ICC_STATUS_CHANGED, null);
- // TODO remove this once modem correctly notifies the unsols
- mCi.registerForOn(this, EVENT_ICC_STATUS_CHANGED, null);
- mRegisteredWithCi = true;
- }
- }
+ mIsCurrentCard3gpp = isNewCard3gpp;
+ mIccCard = new IccCard(mCurrentPhone, mCurrentPhone.getPhoneName(),
+ isNewCard3gpp, DBG);
}
private void log(String string) {
Log.d(LOG_TAG, string);
}
-}
+}
\ No newline at end of file