summaryrefslogtreecommitdiffstats
path: root/src/java/com/android/internal/telephony/gsm
diff options
context:
space:
mode:
authorAlex Yakavenka <ayakav@codeaurora.org>2012-07-10 00:48:53 -0700
committerAlex Yakavenka <ayakav@codeaurora.org>2012-09-07 10:09:59 -0700
commite287feac673ff68565b766e0e463d105fa9cef9d (patch)
tree7ee79096f25919ee91fa8114eabb202a3e7925b9 /src/java/com/android/internal/telephony/gsm
parent7ac8d8026b997141d106762574478eb9daaf3f38 (diff)
downloadframeworks_opt_telephony-e287feac673ff68565b766e0e463d105fa9cef9d.zip
frameworks_opt_telephony-e287feac673ff68565b766e0e463d105fa9cef9d.tar.gz
frameworks_opt_telephony-e287feac673ff68565b766e0e463d105fa9cef9d.tar.bz2
Telephony: Remove CdmaLteUicc objects
-Pass IccCard object to GsmMmiCode -Create IccCardProxy -Make IccCard an interface and pass instance of IccCardProxy to external applications (PhoneApp). IccCardProxy will use internal UiccCard to map Icc requests to current active application on UiccCard to maintain backwards compatibility for external applications -Add documentation to UiccController The primary advantage of UiccController is that we can work with multiple uicc applications at the same time. And that is a requirement for modes like Cdma/Lte. The existing code supports Cdma/Lte only partially and with guessing on modem side. However, some things modem can guess, while others - it can't. For instance, when a user tries to edit the fdn list the current code will pass ef_id for fdn (0x6F3B). But the modem will have no clue which fdn list the user wants to edit (csim or usim, both have path 7FFF), and it's impossible for modem to guess correctly all the time. All the modem can do is try to be consistent and hope another device is doing same things. Imagine you bring your card from another Cdma/Lte device to your new Cdma/Lte device: if this modem uses different fdn file, it won't work as all existing entries won't be there. Another example is when the modem's guess is wrong for files like csim/ef_li (7FFF 6F3A) versus usim/ef_adn (7FFF 6F3A). They have same ef_ids so Android really should pass aid of the app it wants to access. Without aids there is no way modem can know for sure which file Android wants to read! However, in the current code even Android doesn't know which aid it wants to read file from since CdmaLteRecords has only 1 aid. All of these problems cause more and more hacks, both in the modem and in Android side. UiccController cleans up current code and provides framework to work with multiple Uicc applications at the same time. Change-Id: I60216887b14140bdf833a8ed579ba16cad932bdc
Diffstat (limited to 'src/java/com/android/internal/telephony/gsm')
-rw-r--r--src/java/com/android/internal/telephony/gsm/GSMPhone.java33
-rw-r--r--src/java/com/android/internal/telephony/gsm/GsmConnection.java9
-rw-r--r--src/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java10
-rw-r--r--src/java/com/android/internal/telephony/gsm/GsmMmiCode.java47
-rwxr-xr-xsrc/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java29
-rw-r--r--src/java/com/android/internal/telephony/gsm/SIMFileHandler.java29
-rwxr-xr-xsrc/java/com/android/internal/telephony/gsm/SIMRecords.java79
7 files changed, 116 insertions, 120 deletions
diff --git a/src/java/com/android/internal/telephony/gsm/GSMPhone.java b/src/java/com/android/internal/telephony/gsm/GSMPhone.java
index b429cd2..c1cd019 100644
--- a/src/java/com/android/internal/telephony/gsm/GSMPhone.java
+++ b/src/java/com/android/internal/telephony/gsm/GSMPhone.java
@@ -50,13 +50,13 @@ import static com.android.internal.telephony.CommandsInterface.CF_REASON_UNCONDI
import static com.android.internal.telephony.CommandsInterface.SERVICE_CLASS_VOICE;
import static com.android.internal.telephony.TelephonyProperties.PROPERTY_BASEBAND_VERSION;
+import com.android.internal.telephony.IccCardApplicationStatus.AppState;
import com.android.internal.telephony.cat.CatService;
import com.android.internal.telephony.Call;
import com.android.internal.telephony.CallForwardInfo;
import com.android.internal.telephony.CallStateException;
import com.android.internal.telephony.CommandsInterface;
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;
@@ -71,6 +71,8 @@ import com.android.internal.telephony.PhoneProxy;
import com.android.internal.telephony.PhoneSubInfo;
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.UUSInfo;
+import com.android.internal.telephony.UiccCard;
+import com.android.internal.telephony.UiccCardApplication;
import com.android.internal.telephony.test.SimulatedRadioControl;
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.IccVmNotSupportedException;
@@ -710,7 +712,8 @@ public class GSMPhone extends PhoneBase {
// Only look at the Network portion for mmi
String networkPortion = PhoneNumberUtils.extractNetworkPortionAlt(newDialString);
- GsmMmiCode mmi = GsmMmiCode.newFromDialString(networkPortion, this);
+ GsmMmiCode mmi =
+ GsmMmiCode.newFromDialString(networkPortion, this, mUiccApplication.get());
if (LOCAL_DEBUG) Log.d(LOG_TAG,
"dialing w/ mmi '" + mmi + "'...");
@@ -729,7 +732,7 @@ public class GSMPhone extends PhoneBase {
}
public boolean handlePinMmi(String dialString) {
- GsmMmiCode mmi = GsmMmiCode.newFromDialString(dialString, this);
+ GsmMmiCode mmi = GsmMmiCode.newFromDialString(dialString, this, mUiccApplication.get());
if (mmi != null && mmi.isPinCommand()) {
mPendingMMIs.add(mmi);
@@ -742,7 +745,7 @@ public class GSMPhone extends PhoneBase {
}
public void sendUssdResponse(String ussdMessge) {
- GsmMmiCode mmi = GsmMmiCode.newFromUssdUserInput(ussdMessge, this);
+ GsmMmiCode mmi = GsmMmiCode.newFromUssdUserInput(ussdMessge, this, mUiccApplication.get());
mPendingMMIs.add(mmi);
mMmiRegistrants.notifyRegistrants(new AsyncResult(null, mmi, null));
mmi.sendUssd(ussdMessge);
@@ -1139,7 +1142,8 @@ public class GSMPhone extends PhoneBase {
GsmMmiCode mmi;
mmi = GsmMmiCode.newNetworkInitiatedUssd(ussdMessage,
isUssdRequest,
- GSMPhone.this);
+ GSMPhone.this,
+ mUiccApplication.get());
onNetworkInitiatedUssd(mmi);
}
}
@@ -1339,23 +1343,24 @@ public class GSMPhone extends PhoneBase {
return;
}
- IccCard newIccCard = mUiccController.getIccCard();
+ UiccCardApplication newUiccApplication =
+ mUiccController.getUiccCardApplication(UiccController.APP_FAM_3GPP);
- IccCard c = mIccCard.get();
- if (c != newIccCard) {
- if (c != null) {
+ UiccCardApplication app = mUiccApplication.get();
+ if (app != newUiccApplication) {
+ if (app != null) {
if (LOCAL_DEBUG) log("Removing stale icc objects.");
if (mIccRecords.get() != null) {
unregisterForSimRecordEvents();
mSimPhoneBookIntManager.updateIccRecords(null);
}
mIccRecords.set(null);
- mIccCard.set(null);
+ mUiccApplication.set(null);
}
- if (newIccCard != null) {
- if (LOCAL_DEBUG) log("New card found");
- mIccCard.set(newIccCard);
- mIccRecords.set(newIccCard.getIccRecords());
+ if (newUiccApplication != null) {
+ if (LOCAL_DEBUG) log("New Uicc application found");
+ mUiccApplication.set(newUiccApplication);
+ mIccRecords.set(newUiccApplication.getIccRecords());
registerForSimRecordEvents();
mSimPhoneBookIntManager.updateIccRecords(mIccRecords.get());
}
diff --git a/src/java/com/android/internal/telephony/gsm/GsmConnection.java b/src/java/com/android/internal/telephony/gsm/GsmConnection.java
index 83e1b0e..875b680 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmConnection.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmConnection.java
@@ -29,6 +29,8 @@ import android.telephony.ServiceState;
import android.text.TextUtils;
import com.android.internal.telephony.*;
+import com.android.internal.telephony.IccCardApplicationStatus.AppState;
+import com.android.internal.telephony.uicc.UiccController;
/**
* {@hide}
@@ -371,13 +373,16 @@ public class GsmConnection extends Connection {
default:
GSMPhone phone = owner.phone;
int serviceState = phone.getServiceState().getState();
+ AppState uiccAppState = UiccController
+ .getInstance()
+ .getUiccCardApplication(UiccController.APP_FAM_3GPP)
+ .getState();
if (serviceState == ServiceState.STATE_POWER_OFF) {
return DisconnectCause.POWER_OFF;
} else if (serviceState == ServiceState.STATE_OUT_OF_SERVICE
|| serviceState == ServiceState.STATE_EMERGENCY_ONLY ) {
return DisconnectCause.OUT_OF_SERVICE;
- } else if (phone.getIccCard() != null &&
- phone.getIccCard().getState() != IccCardConstants.State.READY) {
+ } else if (uiccAppState != AppState.APPSTATE_READY) {
return DisconnectCause.ICC_ERROR;
} else if (causeCode == CallFailCause.ERROR_UNSPECIFIED) {
if (phone.mSST.mRestrictedState.isCsRestricted()) {
diff --git a/src/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/src/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index 9bacbae..6ca7c0c 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -67,6 +67,8 @@ import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.RetryManager;
+import com.android.internal.telephony.UiccCard;
+import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.util.AsyncChannel;
import java.io.FileDescriptor;
@@ -2349,11 +2351,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
return;
}
- IccCard newIccCard = mUiccController.getIccCard();
- IccRecords newIccRecords = null;
- if (newIccCard != null) {
- newIccRecords = newIccCard.getIccRecords();
- }
+ IccRecords newIccRecords = mUiccController.getIccRecords(UiccController.APP_FAM_3GPP);
IccRecords r = mIccRecords.get();
if (r != newIccRecords) {
@@ -2363,7 +2361,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
mIccRecords.set(null);
}
if (newIccRecords != null) {
- log("New card found");
+ log("New records found");
mIccRecords.set(newIccRecords);
newIccRecords.registerForRecordsLoaded(
this, DctConstants.EVENT_RECORDS_LOADED, null);
diff --git a/src/java/com/android/internal/telephony/gsm/GsmMmiCode.java b/src/java/com/android/internal/telephony/gsm/GsmMmiCode.java
index 1f7836e..fdc0606 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmMmiCode.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmMmiCode.java
@@ -18,6 +18,7 @@ package com.android.internal.telephony.gsm;
import android.content.Context;
import com.android.internal.telephony.*;
+import com.android.internal.telephony.IccCardApplicationStatus.AppState;
import android.os.*;
import android.telephony.PhoneNumberUtils;
@@ -110,6 +111,8 @@ public final class GsmMmiCode extends Handler implements MmiCode {
GSMPhone phone;
Context context;
+ UiccCardApplication mUiccApplication;
+ IccRecords mIccRecords;
String action; // One of ACTION_*
String sc; // Service Code
@@ -173,7 +176,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
*/
static GsmMmiCode
- newFromDialString(String dialString, GSMPhone phone) {
+ newFromDialString(String dialString, GSMPhone phone, UiccCardApplication app) {
Matcher m;
GsmMmiCode ret = null;
@@ -181,7 +184,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
// Is this formatted like a standard supplementary service code?
if (m.matches()) {
- ret = new GsmMmiCode(phone);
+ ret = new GsmMmiCode(phone, app);
ret.poundString = makeEmptyNull(m.group(MATCH_GROUP_POUND_STRING));
ret.action = makeEmptyNull(m.group(MATCH_GROUP_ACTION));
ret.sc = makeEmptyNull(m.group(MATCH_GROUP_SERVICE_CODE));
@@ -196,14 +199,14 @@ public final class GsmMmiCode extends Handler implements MmiCode {
// "Entry of any characters defined in the 3GPP TS 23.038 [8] Default Alphabet
// (up to the maximum defined in 3GPP TS 24.080 [10]), followed by #SEND".
- ret = new GsmMmiCode(phone);
+ ret = new GsmMmiCode(phone, app);
ret.poundString = dialString;
} else if (isTwoDigitShortCode(phone.getContext(), dialString)) {
//Is a country-specific exception to short codes as defined in TS 22.030, 6.5.3.2
ret = null;
} else if (isShortCode(dialString, phone)) {
// this may be a short code, as defined in TS 22.030, 6.5.3.2
- ret = new GsmMmiCode(phone);
+ ret = new GsmMmiCode(phone, app);
ret.dialingNumber = dialString;
}
@@ -212,10 +215,10 @@ public final class GsmMmiCode extends Handler implements MmiCode {
static GsmMmiCode
newNetworkInitiatedUssd (String ussdMessage,
- boolean isUssdRequest, GSMPhone phone) {
+ boolean isUssdRequest, GSMPhone phone, UiccCardApplication app) {
GsmMmiCode ret;
- ret = new GsmMmiCode(phone);
+ ret = new GsmMmiCode(phone, app);
ret.message = ussdMessage;
ret.isUssdRequest = isUssdRequest;
@@ -231,8 +234,10 @@ public final class GsmMmiCode extends Handler implements MmiCode {
return ret;
}
- static GsmMmiCode newFromUssdUserInput(String ussdMessge, GSMPhone phone) {
- GsmMmiCode ret = new GsmMmiCode(phone);
+ static GsmMmiCode newFromUssdUserInput(String ussdMessge,
+ GSMPhone phone,
+ UiccCardApplication app) {
+ GsmMmiCode ret = new GsmMmiCode(phone, app);
ret.message = ussdMessge;
ret.state = State.PENDING;
@@ -383,12 +388,16 @@ public final class GsmMmiCode extends Handler implements MmiCode {
//***** Constructor
- GsmMmiCode (GSMPhone phone) {
+ GsmMmiCode (GSMPhone phone, UiccCardApplication app) {
// The telephony unit-test cases may create GsmMmiCode's
// in secondary threads
super(phone.getHandler().getLooper());
this.phone = phone;
this.context = phone.getContext();
+ mUiccApplication = app;
+ if (app != null) {
+ mIccRecords = app.getIccRecords();
+ }
}
//***** MmiCode implementation
@@ -764,8 +773,9 @@ public final class GsmMmiCode extends Handler implements MmiCode {
} else if (pinLen < 4 || pinLen > 8 ) {
// invalid length
handlePasswordError(com.android.internal.R.string.invalidPin);
- } else if (sc.equals(SC_PIN) && phone.getIccCard().getState() ==
- IccCardConstants.State.PUK_REQUIRED ) {
+ } else if (sc.equals(SC_PIN) &&
+ mUiccApplication != null &&
+ mUiccApplication.getState() == AppState.APPSTATE_PUK ) {
// Sim is puk-locked
handlePasswordError(com.android.internal.R.string.needPuk);
} else {
@@ -885,9 +895,8 @@ 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);
+ if (mIccRecords != null) {
+ mIccRecords.setVoiceCallForwardingFlag(1, cffEnabled);
}
}
@@ -1206,9 +1215,8 @@ 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);
+ if (mIccRecords != null) {
+ mIccRecords.setVoiceCallForwardingFlag(1, cffEnabled);
}
}
@@ -1234,9 +1242,8 @@ 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);
+ if (mIccRecords != null) {
+ mIccRecords.setVoiceCallForwardingFlag(1, false);
}
} else {
diff --git a/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
index 42443fe..a0be5d0 100755
--- a/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
@@ -30,6 +30,10 @@ import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.ServiceStateTracker;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyProperties;
+import com.android.internal.telephony.UiccCard;
+import com.android.internal.telephony.UiccCardApplication;
+import com.android.internal.telephony.IccCardApplicationStatus.AppState;
+import com.android.internal.telephony.uicc.UiccController;
import android.app.AlarmManager;
import android.app.Notification;
@@ -187,7 +191,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
};
public GsmServiceStateTracker(GSMPhone phone) {
- super(phone, phone.mCM);
+ super(phone.getContext(), phone.mCM);
this.phone = phone;
ss = new ServiceState();
@@ -239,7 +243,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
cm.unregisterForAvailable(this);
cm.unregisterForRadioStateChanged(this);
cm.unregisterForVoiceNetworkStateChanged(this);
- if (mIccCard != null) {mIccCard.unregisterForReady(this);}
+ if (mUiccApplcation != null) {mUiccApplcation.unregisterForReady(this);}
if (mIccRecords != null) {mIccRecords.unregisterForRecordsLoaded(this);}
cm.unSetOnSignalStrengthUpdate(this);
cm.unSetOnRestrictedStateChanged(this);
@@ -1087,7 +1091,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 != null && mIccCard.getState() == IccCardConstants.State.READY) {
+ if (mUiccApplcation != null && mUiccApplcation.getState() == AppState.APPSTATE_READY) {
newRs.setCsNormalRestricted(
((state & RILConstants.RIL_RESTRICTED_STATE_CS_NORMAL) != 0) ||
((state & RILConstants.RIL_RESTRICTED_STATE_CS_ALL) != 0) );
@@ -1619,23 +1623,24 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
return;
}
- IccCard newIccCard = mUiccController.getIccCard();
+ UiccCardApplication newUiccApplication =
+ mUiccController.getUiccCardApplication(UiccController.APP_FAM_3GPP);
- if (mIccCard != newIccCard) {
- if (mIccCard != null) {
+ if (mUiccApplcation != newUiccApplication) {
+ if (mUiccApplcation != null) {
log("Removing stale icc objects.");
- mIccCard.unregisterForReady(this);
+ mUiccApplcation.unregisterForReady(this);
if (mIccRecords != null) {
mIccRecords.unregisterForRecordsLoaded(this);
}
mIccRecords = null;
- mIccCard = null;
+ mUiccApplcation = null;
}
- if (newIccCard != null) {
+ if (newUiccApplication != null) {
log("New card found");
- mIccCard = newIccCard;
- mIccRecords = mIccCard.getIccRecords();
- mIccCard.registerForReady(this, EVENT_SIM_READY, null);
+ mUiccApplcation = newUiccApplication;
+ mIccRecords = mUiccApplcation.getIccRecords();
+ mUiccApplcation.registerForReady(this, EVENT_SIM_READY, null);
if (mIccRecords != null) {
mIccRecords.registerForRecordsLoaded(this, EVENT_SIM_RECORDS_LOADED, null);
}
diff --git a/src/java/com/android/internal/telephony/gsm/SIMFileHandler.java b/src/java/com/android/internal/telephony/gsm/SIMFileHandler.java
index dcc9cfd..0387a70 100644
--- a/src/java/com/android/internal/telephony/gsm/SIMFileHandler.java
+++ b/src/java/com/android/internal/telephony/gsm/SIMFileHandler.java
@@ -20,11 +20,9 @@ import android.os.Message;
import android.util.Log;
import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.IccCard;
-import com.android.internal.telephony.IccCardApplication;
import com.android.internal.telephony.IccConstants;
import com.android.internal.telephony.IccFileHandler;
-import com.android.internal.telephony.PhoneBase;
+import com.android.internal.telephony.UiccCardApplication;
/**
* {@hide}
@@ -36,21 +34,13 @@ public final class SIMFileHandler extends IccFileHandler implements IccConstants
//***** Constructor
- public SIMFileHandler(IccCard card, String aid, CommandsInterface ci) {
- super(card, aid, ci);
- }
-
- protected void finalize() {
- Log.d(LOG_TAG, "SIMFileHandler finalized");
+ public SIMFileHandler(UiccCardApplication app, String aid, CommandsInterface ci) {
+ super(app, aid, ci);
}
//***** Overridden from IccFileHandler
@Override
- public void handleMessage(Message msg) {
- super.handleMessage(msg);
- }
-
protected String getEFPath(int efid) {
// TODO(): DF_GSM can be 7F20 or 7F21 to handle backward compatibility.
// Implement this after discussion with OEMs.
@@ -78,29 +68,20 @@ public final class SIMFileHandler extends IccFileHandler implements IccConstants
case EF_INFO_CPHS:
case EF_CSP_CPHS:
return MF_SIM + DF_GSM;
-
- case EF_PBR:
- // we only support global phonebook.
- return MF_SIM + DF_TELECOM + DF_PHONEBOOK;
}
String path = getCommonIccEFPath(efid);
if (path == null) {
- // The EFids in USIM phone book entries are decided by the card manufacturer.
- // So if we don't match any of the cases above and if its a USIM return
- // the phone book path.
- if (mParentCard != null
- && mParentCard.isApplicationOnIcc(IccCardApplication.AppType.APPTYPE_USIM)) {
- return MF_SIM + DF_TELECOM + DF_PHONEBOOK;
- }
Log.e(LOG_TAG, "Error: EF Path being returned in null");
}
return path;
}
+ @Override
protected void logd(String msg) {
Log.d(LOG_TAG, "[SIMFileHandler] " + msg);
}
+ @Override
protected void loge(String msg) {
Log.e(LOG_TAG, "[SIMFileHandler] " + msg);
}
diff --git a/src/java/com/android/internal/telephony/gsm/SIMRecords.java b/src/java/com/android/internal/telephony/gsm/SIMRecords.java
index be33d6e..ddaf4b9 100755
--- a/src/java/com/android/internal/telephony/gsm/SIMRecords.java
+++ b/src/java/com/android/internal/telephony/gsm/SIMRecords.java
@@ -31,7 +31,6 @@ import com.android.internal.telephony.AdnRecordCache;
import com.android.internal.telephony.AdnRecordLoader;
import com.android.internal.telephony.BaseCommands;
import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.IccFileHandler;
import com.android.internal.telephony.IccRecords;
@@ -43,6 +42,7 @@ import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.SmsMessageBase;
import com.android.internal.telephony.IccRefreshResponse;
+import com.android.internal.telephony.UiccCardApplication;
import java.util.ArrayList;
@@ -66,7 +66,6 @@ public class SIMRecords extends IccRecords {
// ***** Cached SIM State; cleared on channel close
- private String imsi;
private boolean callForwardingEnabled;
@@ -125,9 +124,9 @@ public class SIMRecords extends IccRecords {
// ***** Event Constants
- private static final int EVENT_RADIO_OFF_OR_NOT_AVAILABLE = 2;
- protected static final int EVENT_GET_IMSI_DONE = 3;
- protected static final int EVENT_GET_ICCID_DONE = 4;
+ private static final int EVENT_APP_READY = 1;
+ private static final int EVENT_GET_IMSI_DONE = 3;
+ private static final int EVENT_GET_ICCID_DONE = 4;
private static final int EVENT_GET_MBI_DONE = 5;
private static final int EVENT_GET_MBDN_DONE = 6;
private static final int EVENT_GET_MWIS_DONE = 7;
@@ -176,8 +175,8 @@ public class SIMRecords extends IccRecords {
// ***** Constructor
- public SIMRecords(IccCard card, Context c, CommandsInterface ci) {
- super(card, c, ci);
+ public SIMRecords(UiccCardApplication app, Context c, CommandsInterface ci) {
+ super(app, c, ci);
adnCache = new AdnRecordCache(mFh);
@@ -189,23 +188,22 @@ public class SIMRecords extends IccRecords {
// recordsToLoad is set to 0 because no requests are made yet
recordsToLoad = 0;
- mCi.registerForOffOrNotAvailable(
- this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
mCi.setOnSmsOnSim(this, EVENT_SMS_ON_SIM, null);
mCi.registerForIccRefresh(this, EVENT_SIM_REFRESH, null);
// Start off by setting empty state
- onRadioOffOrNotAvailable();
-
+ resetRecords();
+ mParentApp.registerForReady(this, EVENT_APP_READY, null);
}
@Override
public void dispose() {
if (DBG) log("Disposing SIMRecords " + this);
//Unregister for all events
- mCi.unregisterForOffOrNotAvailable( this);
mCi.unregisterForIccRefresh(this);
mCi.unSetOnSmsOnSim(this);
+ mParentApp.unregisterForReady(this);
+ resetRecords();
super.dispose();
}
@@ -213,8 +211,8 @@ public class SIMRecords extends IccRecords {
if(DBG) log("finalized");
}
- protected void onRadioOffOrNotAvailable() {
- imsi = null;
+ protected void resetRecords() {
+ mImsi = null;
msisdn = null;
voiceMailNum = null;
countVoiceMessages = 0;
@@ -248,7 +246,7 @@ public class SIMRecords extends IccRecords {
*/
@Override
public String getIMSI() {
- return imsi;
+ return mImsi;
}
public String getMsisdnNumber() {
@@ -499,7 +497,7 @@ public class SIMRecords extends IccRecords {
*/
@Override
public String getOperatorNumeric() {
- if (imsi == null) {
+ if (mImsi == null) {
log("getOperatorNumeric: IMSI == null");
return null;
}
@@ -510,7 +508,7 @@ public class SIMRecords extends IccRecords {
// Length = length of MCC + length of MNC
// length of mcc = 3 (TS 23.003 Section 2.2)
- return imsi.substring(0, 3 + mncLength);
+ return mImsi.substring(0, 3 + mncLength);
}
// ***** Overridden from Handler
@@ -529,9 +527,9 @@ public class SIMRecords extends IccRecords {
}
try { switch (msg.what) {
- case EVENT_RADIO_OFF_OR_NOT_AVAILABLE:
- onRadioOffOrNotAvailable();
- break;
+ case EVENT_APP_READY:
+ onReady();
+ break;
/* IO events */
case EVENT_GET_IMSI_DONE:
@@ -544,20 +542,20 @@ public class SIMRecords extends IccRecords {
break;
}
- imsi = (String) ar.result;
+ mImsi = (String) ar.result;
// IMSI (MCC+MNC+MSIN) is at least 6 digits, but not more
// than 15 (and usually 15).
- if (imsi != null && (imsi.length() < 6 || imsi.length() > 15)) {
- loge("invalid IMSI " + imsi);
- imsi = null;
+ if (mImsi != null && (mImsi.length() < 6 || mImsi.length() > 15)) {
+ loge("invalid IMSI " + mImsi);
+ mImsi = null;
}
log("IMSI: " + /* imsi.substring(0, 6) +*/ "xxxxxxx");
if (((mncLength == UNKNOWN) || (mncLength == 2)) &&
- ((imsi != null) && (imsi.length() >= 6))) {
- String mccmncCode = imsi.substring(0, 6);
+ ((mImsi != null) && (mImsi.length() >= 6))) {
+ String mccmncCode = mImsi.substring(0, 6);
for (String mccmnc : MCCMNC_CODES_HAVING_3DIGITS_MNC) {
if (mccmnc.equals(mccmncCode)) {
mncLength = 3;
@@ -570,7 +568,7 @@ public class SIMRecords extends IccRecords {
// the SIM has told us all it knows, but it didn't know the mnc length.
// guess using the mcc
try {
- int mcc = Integer.parseInt(imsi.substring(0,3));
+ int mcc = Integer.parseInt(mImsi.substring(0,3));
mncLength = MccTable.smallestDigitsMccForMnc(mcc);
} catch (NumberFormatException e) {
mncLength = UNKNOWN;
@@ -580,10 +578,9 @@ public class SIMRecords extends IccRecords {
if (mncLength != UNKNOWN && mncLength != UNINITIALIZED) {
// finally have both the imsi and the mncLength and can parse the imsi properly
- MccTable.updateMccMncConfiguration(mContext, imsi.substring(0, 3 + mncLength));
+ MccTable.updateMccMncConfiguration(mContext, mImsi.substring(0, 3 + mncLength));
}
- mParentCard.broadcastIccStateChangedIntent(
- IccCardConstants.INTENT_VALUE_ICC_IMSI, null);
+ mImsiReadyRegistrants.notifyRegistrants();
break;
case EVENT_GET_MBI_DONE:
@@ -815,8 +812,8 @@ public class SIMRecords extends IccRecords {
}
} finally {
if (((mncLength == UNINITIALIZED) || (mncLength == UNKNOWN) ||
- (mncLength == 2)) && ((imsi != null) && (imsi.length() >= 6))) {
- String mccmncCode = imsi.substring(0, 6);
+ (mncLength == 2)) && ((mImsi != null) && (mImsi.length() >= 6))) {
+ String mccmncCode = mImsi.substring(0, 6);
for (String mccmnc : MCCMNC_CODES_HAVING_3DIGITS_MNC) {
if (mccmnc.equals(mccmncCode)) {
mncLength = 3;
@@ -826,9 +823,9 @@ public class SIMRecords extends IccRecords {
}
if (mncLength == UNKNOWN || mncLength == UNINITIALIZED) {
- if (imsi != null) {
+ if (mImsi != null) {
try {
- int mcc = Integer.parseInt(imsi.substring(0,3));
+ int mcc = Integer.parseInt(mImsi.substring(0,3));
mncLength = MccTable.smallestDigitsMccForMnc(mcc);
} catch (NumberFormatException e) {
@@ -842,11 +839,11 @@ public class SIMRecords extends IccRecords {
log("MNC length not present in EF_AD");
}
}
- if (imsi != null && mncLength != UNKNOWN) {
+ if (mImsi != null && mncLength != UNKNOWN) {
// finally have both imsi and the length of the mnc and can parse
// the imsi properly
MccTable.updateMccMncConfiguration(mContext,
- imsi.substring(0, 3 + mncLength));
+ mImsi.substring(0, 3 + mncLength));
}
}
break;
@@ -1141,7 +1138,7 @@ public class SIMRecords extends IccRecords {
}
if (refreshResponse.aid != null &&
- !refreshResponse.aid.equals(mParentCard.getAid())) {
+ !refreshResponse.aid.equals(mParentApp.getAid())) {
// This is for different app. Ignore.
return;
}
@@ -1264,9 +1261,9 @@ public class SIMRecords extends IccRecords {
operator + "'");
SystemProperties.set(PROPERTY_ICC_OPERATOR_NUMERIC, operator);
- if (imsi != null) {
+ if (mImsi != null) {
SystemProperties.set(PROPERTY_ICC_OPERATOR_ISO_COUNTRY,
- MccTable.countryCodeForMcc(Integer.parseInt(imsi.substring(0,3))));
+ MccTable.countryCodeForMcc(Integer.parseInt(mImsi.substring(0,3))));
}
else {
loge("onAllRecordsLoaded: imsi is NULL!");
@@ -1277,8 +1274,6 @@ public class SIMRecords extends IccRecords {
recordsLoadedRegistrants.notifyRegistrants(
new AsyncResult(null, null, null));
- mParentCard.broadcastIccStateChangedIntent(
- IccCardConstants.INTENT_VALUE_ICC_LOADED, null);
}
//***** Private methods
@@ -1308,7 +1303,7 @@ public class SIMRecords extends IccRecords {
if (DBG) log("fetchSimRecords " + recordsToLoad);
- mCi.getIMSIForApp(mParentCard.getAid(), obtainMessage(EVENT_GET_IMSI_DONE));
+ mCi.getIMSIForApp(mParentApp.getAid(), obtainMessage(EVENT_GET_IMSI_DONE));
recordsToLoad++;
mFh.loadEFTransparent(EF_ICCID, obtainMessage(EVENT_GET_ICCID_DONE));