summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2009-07-16 15:56:22 -0700
committerWink Saville <wink@google.com>2009-07-16 16:07:13 -0700
commitabccd7eaa52d0b8579ba3d1c954dfe7529945c0f (patch)
treec6d582f5df220620aeb6fca343405eaaf9d2eb21 /telephony
parent0a6a05cdb57561e2d932a62a018c83ca5667f4da (diff)
downloadframeworks_base-abccd7eaa52d0b8579ba3d1c954dfe7529945c0f.zip
frameworks_base-abccd7eaa52d0b8579ba3d1c954dfe7529945c0f.tar.gz
frameworks_base-abccd7eaa52d0b8579ba3d1c954dfe7529945c0f.tar.bz2
DO NOT MERGE. Implement IMSI function for CDMA phones
Includes support to get the MCC and MNC from system properties, since they are known to be unreliable from the network. This is known to conflict with master and will be added by hand so as not to break the build.
Diffstat (limited to 'telephony')
-rwxr-xr-xtelephony/java/com/android/internal/telephony/cdma/CDMAPhone.java101
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java41
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/RuimRecords.java9
3 files changed, 110 insertions, 41 deletions
diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
index 0ab9d34..23eedfe 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
@@ -18,17 +18,23 @@ package com.android.internal.telephony.cdma;
import android.app.ActivityManagerNative;
import android.content.Context;
+import android.content.ContentValues;
import android.content.Intent;
+import android.content.res.Configuration;
import android.content.SharedPreferences;
+import android.database.SQLException;
+import android.net.Uri;
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.os.RemoteException;
import android.os.SystemProperties;
import android.preference.PreferenceManager;
import android.provider.Settings;
+import android.provider.Telephony;
import android.telephony.CellLocation;
import android.telephony.PhoneNumberUtils;
import android.telephony.ServiceState;
@@ -41,6 +47,10 @@ import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.DataConnection;
+// TODO(Moto): need to move MccTable from telephony.gsm to telephony
+// since there is no difference between CDMA and GSM for MccTable and
+// CDMA uses gsm's MccTable is not good.
+import com.android.internal.telephony.gsm.MccTable;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.IccException;
import com.android.internal.telephony.IccFileHandler;
@@ -56,6 +66,10 @@ import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyProperties;
+import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA;
+import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC;
+import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY;
+
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
@@ -154,6 +168,23 @@ public class CDMAPhone extends PhoneBase {
String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false");
mIsPhoneInECMState = inEcm.equals("true");
+ // Sets operator alpha property by retrieving from build-time system property
+ String operatorAlpha = SystemProperties.get("ro.cdma.home.operator.alpha");
+ setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, operatorAlpha);
+
+ // Sets operator numeric property by retrieving from build-time system property
+ String operatorNumeric = SystemProperties.get("ro.cdma.home.operator.numeric");
+ setSystemProperty(PROPERTY_ICC_OPERATOR_NUMERIC, operatorNumeric);
+
+ // Sets iso country property by retrieving from build-time system property
+ setIsoCountryProperty(operatorNumeric);
+
+ // Sets current entry in the telephony carrier table
+ updateCurrentCarrierInProvider(operatorNumeric);
+
+ // Updates MCC MNC device configuration information
+ updateMccMncConfiguration(operatorNumeric);
+
// Notify voicemails.
notifier.notifyMessageWaitingChanged(this);
}
@@ -427,13 +458,7 @@ public class CDMAPhone extends PhoneBase {
}
public String getSubscriberId() {
- // Subscriber ID is the combination of MCC+MNC+MIN as CDMA IMSI
- // TODO(Moto): Replace with call to mRuimRecords.getIMSI_M() when implemented.
- if ((getServiceState().getOperatorNumeric() != null) && (getCdmaMIN() != null)) {
- return (getServiceState().getOperatorNumeric() + getCdmaMIN());
- } else {
- return null;
- }
+ return mSST.getImsi();
}
public boolean canConference() {
@@ -1244,4 +1269,66 @@ public class CDMAPhone extends PhoneBase {
editor.commit();
}
+ /**
+ * Sets PROPERTY_ICC_OPERATOR_ISO_COUNTRY property
+ *
+ */
+ private void setIsoCountryProperty(String operatorNumeric) {
+ if (TextUtils.isEmpty(operatorNumeric)) {
+ setSystemProperty(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, "");
+ } else {
+ String iso = "";
+ try {
+ iso = MccTable.countryCodeForMcc(Integer.parseInt(
+ operatorNumeric.substring(0,3)));
+ } catch (NumberFormatException ex) {
+ Log.w(LOG_TAG, "countryCodeForMcc error" + ex);
+ } catch (StringIndexOutOfBoundsException ex) {
+ Log.w(LOG_TAG, "countryCodeForMcc error" + ex);
+ }
+
+ setSystemProperty(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, iso);
+ }
+ }
+
+ /**
+ * Sets the "current" field in the telephony provider according to the build-time
+ * operator numeric property
+ *
+ * @return true for success; false otherwise.
+ */
+ // TODO(Moto): move this method into PhoneBase, since it looks identical to
+ // the one in GsmPhone
+ private boolean updateCurrentCarrierInProvider(String operatorNumeric) {
+ if (!TextUtils.isEmpty(operatorNumeric)) {
+ try {
+ Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
+ ContentValues map = new ContentValues();
+ map.put(Telephony.Carriers.NUMERIC, operatorNumeric);
+ getContext().getContentResolver().insert(uri, map);
+ return true;
+ } catch (SQLException e) {
+ Log.e(LOG_TAG, "Can't store current operator", e);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Updates MCC and MNC device configuration information for application retrieving
+ * correct version of resources
+ *
+ */
+ private void updateMccMncConfiguration(String operatorNumeric) {
+ if (operatorNumeric.length() >= 5) {
+ Configuration config = new Configuration();
+ config.mcc = Integer.parseInt(operatorNumeric.substring(0,3));
+ config.mnc = Integer.parseInt(operatorNumeric.substring(3));
+ try {
+ ActivityManagerNative.getDefault().updateConfiguration(config);
+ } catch (RemoteException e) {
+ Log.e(LOG_TAG, "Can't update configuration", e);
+ }
+ }
+ }
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
index abb4a43..23a0520 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
@@ -19,11 +19,8 @@ package com.android.internal.telephony.cdma;
import android.app.AlarmManager;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.ContentValues;
import android.content.Intent;
import android.database.ContentObserver;
-import android.database.SQLException;
-import android.net.Uri;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
@@ -35,7 +32,6 @@ import android.os.SystemProperties;
import android.provider.Checkin;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
-import android.provider.Telephony;
import android.provider.Telephony.Intents;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
@@ -64,6 +60,7 @@ import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERAT
import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_ISROAMING;
import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_NUMERIC;
import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA;
+import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC;
import java.util.Arrays;
import java.util.Date;
@@ -634,27 +631,6 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
} else {
newSS.setOperatorName(opNames[0], opNames[1], opNames[2]);
}
-
- if (!(opNames[2].equals(currentCarrier))) {
- // TODO(Moto): jsh asks, "This uses the MCC+MNC of the current registered
- // network to set the "current" entry in the APN table. But the correct
- // entry should be the MCC+MNC that matches the subscribed operator
- // (eg, phone issuer). These can be different when roaming."
- try {
- // Set the current field of the telephony provider according to
- // the CDMA's operator
- Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
- ContentValues map = new ContentValues();
- map.put(Telephony.Carriers.NUMERIC, opNames[2]);
- cr.insert(uri, map);
- // save current carrier for the next time check
- currentCarrier = opNames[2];
- } catch (SQLException e) {
- Log.e(LOG_TAG, "Can't store current operator", e);
- }
- } else {
- Log.i(LOG_TAG, "current carrier is not changed");
- }
} else {
Log.w(LOG_TAG, "error parsing opNames");
}
@@ -1444,4 +1420,19 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
return mMin;
}
+ /**
+ * Returns IMSI as MCC + MNC + MIN
+ */
+ /*package*/ String getImsi() {
+ // TODO(Moto): When RUIM is enabled, IMSI will come from RUIM
+ // not build-time props. Moto will provide implementation
+ // for RUIM-ready case later.
+ String operatorNumeric = SystemProperties.get(PROPERTY_ICC_OPERATOR_NUMERIC, "");
+
+ if (!TextUtils.isEmpty(operatorNumeric) && getCdmaMin() != null) {
+ return (operatorNumeric + getCdmaMin());
+ } else {
+ return null;
+ }
+ }
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/RuimRecords.java b/telephony/java/com/android/internal/telephony/cdma/RuimRecords.java
index 4d888f6..55f48b1 100644
--- a/telephony/java/com/android/internal/telephony/cdma/RuimRecords.java
+++ b/telephony/java/com/android/internal/telephony/cdma/RuimRecords.java
@@ -123,21 +123,12 @@ public final class RuimRecords extends IccRecords {
adnCache.reset();
- phone.setSystemProperty(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, null);
- phone.setSystemProperty(TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY, null);
-
// recordsRequested is set to false indicating that the SIM
// read requests made so far are not valid. This is set to
// true only when fresh set of read requests are made.
recordsRequested = false;
}
- /** Returns null if RUIM is not yet ready */
- public String getIMSI_M() {
- // TODO(Moto): mImsi is not initialized, fix.
- return mImsi;
- }
-
public String getMdnNumber() {
return mMyMobileNumber;
}