summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/com/android/internal/telephony/DataConnectionTracker.java13
-rw-r--r--telephony/java/com/android/internal/telephony/IccCard.java122
-rw-r--r--telephony/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java12
-rw-r--r--telephony/java/com/android/internal/telephony/IccRecords.java18
-rw-r--r--telephony/java/com/android/internal/telephony/PhoneBase.java38
-rw-r--r--telephony/java/com/android/internal/telephony/ServiceStateTracker.java33
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CDMALTEPhone.java41
-rwxr-xr-xtelephony/java/com/android/internal/telephony/cdma/CDMAPhone.java67
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java38
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java12
-rwxr-xr-xtelephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java71
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/RuimPhoneBookInterfaceManager.java10
-rwxr-xr-xtelephony/java/com/android/internal/telephony/cdma/RuimRecords.java19
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GSMPhone.java131
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java54
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java15
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java64
-rwxr-xr-xtelephony/java/com/android/internal/telephony/gsm/SIMRecords.java8
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/SimPhoneBookInterfaceManager.java9
-rwxr-xr-xtelephony/java/com/android/internal/telephony/sip/SipPhoneBase.java4
-rw-r--r--telephony/java/com/android/internal/telephony/uicc/UiccController.java130
21 files changed, 274 insertions, 635 deletions
diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
index 214627d..55f2ca3 100644
--- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
@@ -46,7 +46,6 @@ import android.util.Log;
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;
@@ -58,7 +57,6 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
/**
* {@hide}
@@ -140,7 +138,6 @@ public abstract class DataConnectionTracker extends Handler {
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 *****/
@@ -253,8 +250,6 @@ public abstract class DataConnectionTracker extends Handler {
// 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;
@@ -505,8 +500,6 @@ public abstract class DataConnectionTracker extends Handler {
protected DataConnectionTracker(PhoneBase phone) {
super();
mPhone = phone;
- mUiccController = UiccController.getInstance();
- mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
IntentFilter filter = new IntentFilter();
filter.addAction(getActionIntentReconnectAlarm());
@@ -548,7 +541,6 @@ public abstract class DataConnectionTracker extends Handler {
mIsDisposed = true;
mPhone.getContext().unregisterReceiver(this.mIntentReceiver);
mDataRoamingSettingObserver.unregister(mPhone.getContext());
- mUiccController.unregisterForIccChanged(this);
}
protected void broadcastMessenger() {
@@ -671,7 +663,6 @@ public abstract class DataConnectionTracker extends Handler {
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);
@@ -782,10 +773,6 @@ public abstract class DataConnectionTracker extends Handler {
onSetPolicyDataEnabled(enabled);
break;
}
- case EVENT_ICC_CHANGED:
- onUpdateIcc();
- break;
-
default:
Log.e("DATA", "Unidentified event msg=" + msg);
break;
diff --git a/telephony/java/com/android/internal/telephony/IccCard.java b/telephony/java/com/android/internal/telephony/IccCard.java
index 140b7c6..92024cd 100644
--- a/telephony/java/com/android/internal/telephony/IccCard.java
+++ b/telephony/java/com/android/internal/telephony/IccCard.java
@@ -35,12 +35,10 @@ import android.view.WindowManager;
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;
@@ -116,6 +114,8 @@ public class IccCard {
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;
@@ -178,19 +178,34 @@ public class IccCard {
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);
@@ -200,40 +215,6 @@ public class IccCard {
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"));
}
@@ -363,23 +344,27 @@ public class IccCard {
*/
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));
}
/**
@@ -509,15 +494,21 @@ public class IccCard {
*
*/
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) {
@@ -593,7 +584,6 @@ public class IccCard {
if (oldState != State.READY && newState == State.READY &&
(is3gpp || isSubscriptionFromIccCard)) {
mIccFileHandler.setAid(getAid());
- broadcastIccStateChangedIntent(INTENT_VALUE_ICC_READY, null);
mIccRecords.onReady();
}
}
@@ -714,6 +704,7 @@ public class IccCard {
if (!is3gpp) {
handleCdmaSubscriptionSource();
}
+ mPhone.mCM.getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE));
break;
case EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED:
handleCdmaSubscriptionSource();
@@ -734,9 +725,30 @@ public class IccCard {
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;
@@ -785,6 +797,10 @@ public class IccCard {
= 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;
@@ -951,10 +967,6 @@ public class IccCard {
Log.d(mLogTag, "[IccCard] " + msg);
}
- private void loge(String msg) {
- Log.e(mLogTag, "[IccCard] " + msg);
- }
-
protected int getCurrentApplicationIndex() {
if (is3gpp) {
return mIccCardStatus.getGsmUmtsSubscriptionAppIndex();
diff --git a/telephony/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java b/telephony/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java
index 0e5f2da..45562ca 100644
--- a/telephony/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java
+++ b/telephony/java/com/android/internal/telephony/IccPhoneBookInterfaceManager.java
@@ -103,23 +103,11 @@ public abstract class IccPhoneBookInterfaceManager extends IIccPhoneBook.Stub {
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);
diff --git a/telephony/java/com/android/internal/telephony/IccRecords.java b/telephony/java/com/android/internal/telephony/IccRecords.java
index 3c906471a..41c9d5a 100644
--- a/telephony/java/com/android/internal/telephony/IccRecords.java
+++ b/telephony/java/com/android/internal/telephony/IccRecords.java
@@ -26,8 +26,6 @@ import android.os.RegistrantList;
import com.android.internal.telephony.gsm.UsimServiceTable;
import com.android.internal.telephony.ims.IsimRecords;
-import java.util.concurrent.atomic.AtomicBoolean;
-
/**
* {@hide}
*/
@@ -35,7 +33,7 @@ public abstract class IccRecords extends Handler implements IccConstants {
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;
@@ -81,9 +79,9 @@ public abstract class IccRecords extends Handler implements IccConstants {
// ***** 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;
@@ -115,7 +113,7 @@ public abstract class IccRecords extends Handler implements IccConstants {
* 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;
@@ -130,8 +128,12 @@ public abstract class IccRecords extends Handler implements IccConstants {
return adnCache;
}
+ public IccCard getIccCard() {
+ return mParentCard;
+ }
+
public void registerForRecordsLoaded(Handler h, int what, Object obj) {
- if (mDestroyed.get()) {
+ if (mDestroyed) {
return;
}
diff --git a/telephony/java/com/android/internal/telephony/PhoneBase.java b/telephony/java/com/android/internal/telephony/PhoneBase.java
index 0c2f234..2ac9365 100644
--- a/telephony/java/com/android/internal/telephony/PhoneBase.java
+++ b/telephony/java/com/android/internal/telephony/PhoneBase.java
@@ -40,7 +40,6 @@ import com.android.internal.R;
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;
@@ -111,7 +110,6 @@ public abstract class PhoneBase extends Handler implements Phone {
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";
@@ -128,8 +126,7 @@ public abstract class PhoneBase extends Handler implements Phone {
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;
@@ -254,8 +251,6 @@ public abstract class PhoneBase extends Handler implements Phone {
// 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() {
@@ -267,7 +262,6 @@ public abstract class PhoneBase extends Handler implements Phone {
// Dispose the SMS usage and storage monitors
mSmsStorageMonitor.dispose();
mSmsUsageMonitor.dispose();
- mUiccController.unregisterForIccChanged(this);
}
}
@@ -275,10 +269,9 @@ public abstract class PhoneBase extends Handler implements Phone {
mSmsStorageMonitor = null;
mSmsUsageMonitor = null;
mSMS = null;
- mIccRecords.set(null);
+ mIccRecords = null;
mIccCard.set(null);
mDataConnectionTracker = null;
- mUiccController = null;
}
/**
@@ -315,10 +308,6 @@ public abstract class PhoneBase extends Handler implements Phone {
}
break;
- case EVENT_ICC_CHANGED:
- onUpdateIccAvailability();
- break;
-
default:
throw new RuntimeException("unexpected event not handled");
}
@@ -329,9 +318,6 @@ public abstract class PhoneBase extends Handler implements Phone {
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.
@@ -680,26 +666,22 @@ public abstract class PhoneBase extends Handler implements Phone {
@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();
}
/**
@@ -1153,10 +1135,7 @@ public abstract class PhoneBase extends Handler implements Phone {
*/
@Override
public void setVoiceMessageWaiting(int line, int countWaiting) {
- IccRecords r = mIccRecords.get();
- if (r != null) {
- r.setVoiceMessageWaiting(line, countWaiting);
- }
+ mIccRecords.setVoiceMessageWaiting(line, countWaiting);
}
/**
@@ -1165,8 +1144,7 @@ public abstract class PhoneBase extends Handler implements Phone {
*/
@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) {
diff --git a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java
index a86b68b..75eb226 100644
--- a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java
@@ -18,15 +18,12 @@ package com.android.internal.telephony;
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;
@@ -36,9 +33,6 @@ 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;
@@ -136,7 +130,7 @@ public abstract class ServiceStateTracker extends Handler {
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";
@@ -173,10 +167,7 @@ public abstract class ServiceStateTracker extends Handler {
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() {
@@ -303,10 +294,6 @@ public abstract class ServiceStateTracker extends Handler {
}
break;
- case EVENT_ICC_CHANGED:
- onUpdateIccAvailability();
- break;
-
default:
log("Unhandled message with number: " + msg.what);
break;
@@ -317,7 +304,6 @@ public abstract class ServiceStateTracker extends Handler {
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);
@@ -477,21 +463,6 @@ public abstract class ServiceStateTracker extends Handler {
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);
diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMALTEPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
index 24bb814..d99a625 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
@@ -29,7 +29,6 @@ import android.util.Log;
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;
@@ -67,6 +66,7 @@ public class CDMALTEPhone extends CDMAPhone {
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
@@ -88,6 +88,10 @@ public class CDMALTEPhone extends CDMAPhone {
@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);
}
@@ -96,6 +100,7 @@ public class CDMALTEPhone extends CDMAPhone {
synchronized(PhoneProxy.lockForRadioTechnologyChange) {
super.dispose();
m3gppSMS.dispose();
+ mIccRecords.unregisterForNewSms(this);
}
}
@@ -198,12 +203,11 @@ public class CDMALTEPhone extends CDMAPhone {
@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);
@@ -221,8 +225,7 @@ public class CDMALTEPhone extends CDMAPhone {
// return IMSI from USIM as subscriber ID.
@Override
public String getSubscriberId() {
- IccRecords r = mIccRecords.get();
- return (r != null) ? r.getIMSI() : "";
+ return mIccRecords.getIMSI();
}
@Override
@@ -237,14 +240,12 @@ public class CDMALTEPhone extends CDMAPhone {
@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
@@ -258,26 +259,6 @@ public class CDMALTEPhone extends CDMAPhone {
}
@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);
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
index 7922b3c..9f6ec71 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
@@ -50,7 +50,6 @@ import com.android.internal.telephony.IccCard;
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;
@@ -153,6 +152,10 @@ public class CDMAPhone extends PhoneBase {
}
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);
}
@@ -169,6 +172,7 @@ public class CDMAPhone extends PhoneBase {
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);
@@ -723,10 +727,7 @@ public class CDMAPhone extends PhoneBase {
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() {
@@ -748,8 +749,7 @@ public class CDMAPhone extends PhoneBase {
* @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.
@@ -1064,39 +1064,6 @@ public class CDMAPhone extends PhoneBase {
}
}
- @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:
@@ -1495,22 +1462,14 @@ public class CDMAPhone extends PhoneBase {
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) {
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
index d05ed62..7e5e707 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
@@ -40,8 +40,6 @@ import com.android.internal.telephony.DataConnection;
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;
@@ -112,6 +110,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.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);
@@ -153,8 +152,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
// 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);
@@ -224,12 +222,11 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
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 &&
@@ -244,7 +241,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
reason += " - psState= " + psState;
}
if (!subscriptionFromNv &&
- !(r != null && r.getRecordsLoaded())) {
+ !mCdmaPhone.mIccRecords.getRecordsLoaded()) {
reason += " - RUIM not loaded";
}
if (!(mCdmaPhone.mSST.isConcurrentVoiceAndDataAllowed() ||
@@ -1009,33 +1006,6 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
}
@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));
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
index 9a82f57..ff7a0810 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
@@ -65,7 +65,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
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();
@@ -353,18 +353,16 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
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());
}
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
index 16ff70e..b694e0a 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
@@ -115,6 +115,12 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
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";
@@ -156,10 +162,11 @@ public class CdmaServiceStateTracker extends 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();
@@ -196,17 +203,18 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
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);
@@ -277,6 +285,14 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
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();
@@ -389,16 +405,8 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
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="
@@ -490,6 +498,8 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
if (!isSubscriptionFromRuim) {
// NV is ready when subscription source is NV
sendMessage(obtainMessage(EVENT_NV_READY));
+ } else {
+ phone.getIccCard().registerForReady(this, EVENT_RUIM_READY, null);
}
}
@@ -1685,38 +1695,6 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
}
@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);
}
@@ -1749,6 +1727,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
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);
diff --git a/telephony/java/com/android/internal/telephony/cdma/RuimPhoneBookInterfaceManager.java b/telephony/java/com/android/internal/telephony/cdma/RuimPhoneBookInterfaceManager.java
index e919245..04ee2dd 100644
--- a/telephony/java/com/android/internal/telephony/cdma/RuimPhoneBookInterfaceManager.java
+++ b/telephony/java/com/android/internal/telephony/cdma/RuimPhoneBookInterfaceManager.java
@@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import android.os.Message;
import android.util.Log;
-import com.android.internal.telephony.IccFileHandler;
import com.android.internal.telephony.IccPhoneBookInterfaceManager;
/**
@@ -35,6 +34,7 @@ public class RuimPhoneBookInterfaceManager extends IccPhoneBookInterfaceManager
public RuimPhoneBookInterfaceManager(CDMAPhone phone) {
super(phone);
+ adnCache = phone.mIccRecords.getAdnCache();
//NOTE service "simphonebook" added by IccSmsInterfaceManagerProxy
}
@@ -61,12 +61,8 @@ public class RuimPhoneBookInterfaceManager extends IccPhoneBookInterfaceManager
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;
diff --git a/telephony/java/com/android/internal/telephony/cdma/RuimRecords.java b/telephony/java/com/android/internal/telephony/cdma/RuimRecords.java
index 80183c6..2fefa3f 100755
--- a/telephony/java/com/android/internal/telephony/cdma/RuimRecords.java
+++ b/telephony/java/com/android/internal/telephony/cdma/RuimRecords.java
@@ -199,7 +199,7 @@ public final class RuimRecords extends IccRecords {
boolean isRecordLoadResponse = false;
- if (mDestroyed.get()) {
+ if (mDestroyed) {
loge("Received message " + msg +
"[" + msg.what + "] while being destroyed. Ignoring.");
return;
@@ -317,20 +317,18 @@ public final class RuimRecords extends IccRecords {
// 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();
@@ -350,6 +348,13 @@ public final class RuimRecords extends IccRecords {
@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));
@@ -359,7 +364,7 @@ public final class RuimRecords extends IccRecords {
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++;
@@ -368,7 +373,7 @@ public final class RuimRecords extends IccRecords {
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
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
index 8dda74b..6e9cd51 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
@@ -59,7 +59,6 @@ import com.android.internal.telephony.Connection;
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;
@@ -138,11 +137,13 @@ public class GSMPhone extends PhoneBase {
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);
@@ -151,6 +152,7 @@ public class GSMPhone extends PhoneBase {
}
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);
@@ -794,8 +796,7 @@ public class GSMPhone extends PhoneBase {
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);
@@ -817,9 +818,8 @@ public class GSMPhone extends PhoneBase {
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(
@@ -852,31 +852,24 @@ public class GSMPhone extends PhoneBase {
}
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,
@@ -886,10 +879,7 @@ public class GSMPhone extends PhoneBase {
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) {
@@ -1257,9 +1247,8 @@ public class GSMPhone extends PhoneBase {
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) {
@@ -1332,41 +1321,12 @@ public class GSMPhone extends PhoneBase {
}
}
- @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;
}
@@ -1378,12 +1338,11 @@ public class GSMPhone extends PhoneBase {
* @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) {
@@ -1445,19 +1404,16 @@ public class GSMPhone extends PhoneBase {
}
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;
}
}
}
@@ -1516,35 +1472,22 @@ public class GSMPhone extends PhoneBase {
}
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
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index b44ba0b..40ee58c 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -59,8 +59,6 @@ import com.android.internal.telephony.DataConnection.UpdateLinkPropertyResult;
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;
@@ -180,6 +178,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.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);
@@ -220,8 +219,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
//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);
@@ -622,12 +620,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
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 &&
@@ -639,7 +635,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
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();
@@ -1900,8 +1896,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
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);
}
@@ -2213,8 +2208,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
*/
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.
@@ -2325,9 +2319,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
}
}
- 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) {
@@ -2336,7 +2329,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
+ 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;
@@ -2355,7 +2348,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
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);
}
@@ -2563,33 +2556,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
}
@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);
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java b/telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java
index 9e34b6a..9b3d5cd 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java
@@ -885,10 +885,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
*/
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);
@@ -1206,10 +1203,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
(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);
@@ -1234,10 +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
- IccRecords r = phone.mIccRecords.get();
- if (r != null) {
- r.setVoiceCallForwardingFlag(1, false);
- }
+ phone.mIccRecords.setVoiceCallForwardingFlag(1, false);
} else {
SpannableStringBuilder tb = new SpannableStringBuilder();
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
index 7c03d03..c0acf5b 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
@@ -124,6 +124,12 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
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;
@@ -186,9 +192,10 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
};
public GsmServiceStateTracker(GSMPhone phone) {
- super(phone, phone.mCM);
+ super();
this.phone = phone;
+ cm = phone.mCM;
ss = new ServiceState();
newSS = new ServiceState();
cellLoc = new GsmCellLocation();
@@ -206,6 +213,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
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(
@@ -222,6 +230,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
mAutoTimeZoneObserver);
setSignalStrengthDefaultValues();
+ mNeedToRegForSimLoaded = true;
// Monitor locale change
IntentFilter filter = new IntentFilter();
@@ -233,13 +242,12 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
}
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);
@@ -277,6 +285,15 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
// 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);
@@ -478,11 +495,8 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
}
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
@@ -1131,7 +1145,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
((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) );
@@ -1658,35 +1672,6 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
}
@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);
}
@@ -1726,6 +1711,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
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);
diff --git a/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java b/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java
index 3077995..80988fd 100755
--- a/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SIMRecords.java
@@ -521,7 +521,7 @@ public class SIMRecords extends IccRecords {
boolean isRecordLoadResponse = false;
- if (mDestroyed.get()) {
+ if (mDestroyed) {
loge("Received message " + msg + "[" + msg.what + "] " +
" while being destroyed. Ignoring.");
return;
@@ -1299,6 +1299,12 @@ public class SIMRecords extends IccRecords {
@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();
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/SimPhoneBookInterfaceManager.java b/telephony/java/com/android/internal/telephony/gsm/SimPhoneBookInterfaceManager.java
index 37f9a4f..35ba0d1 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SimPhoneBookInterfaceManager.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SimPhoneBookInterfaceManager.java
@@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import android.os.Message;
import android.util.Log;
-import com.android.internal.telephony.IccFileHandler;
import com.android.internal.telephony.IccPhoneBookInterfaceManager;
/**
@@ -35,6 +34,7 @@ public class SimPhoneBookInterfaceManager extends IccPhoneBookInterfaceManager {
public SimPhoneBookInterfaceManager(GSMPhone phone) {
super(phone);
+ adnCache = phone.mIccRecords.getAdnCache();
//NOTE service "simphonebook" added by IccSmsInterfaceManagerProxy
}
@@ -61,11 +61,8 @@ public class SimPhoneBookInterfaceManager extends IccPhoneBookInterfaceManager {
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;
diff --git a/telephony/java/com/android/internal/telephony/sip/SipPhoneBase.java b/telephony/java/com/android/internal/telephony/sip/SipPhoneBase.java
index 0243522..5c4b446 100755
--- a/telephony/java/com/android/internal/telephony/sip/SipPhoneBase.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipPhoneBase.java
@@ -461,8 +461,4 @@ abstract class SipPhoneBase extends PhoneBase {
notifyPhoneStateChanged();
}
}
-
- @Override
- protected void onUpdateIccAvailability() {
- }
}
diff --git a/telephony/java/com/android/internal/telephony/uicc/UiccController.java b/telephony/java/com/android/internal/telephony/uicc/UiccController.java
index 4e12d6d..5961efd 100644
--- a/telephony/java/com/android/internal/telephony/uicc/UiccController.java
+++ b/telephony/java/com/android/internal/telephony/uicc/UiccController.java
@@ -16,150 +16,78 @@
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