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.
This commit is contained in:
@@ -18,17 +18,23 @@ package com.android.internal.telephony.cdma;
|
|||||||
|
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManagerNative;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.ContentValues;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.database.SQLException;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.AsyncResult;
|
import android.os.AsyncResult;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Registrant;
|
import android.os.Registrant;
|
||||||
import android.os.RegistrantList;
|
import android.os.RegistrantList;
|
||||||
|
import android.os.RemoteException;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.provider.Telephony;
|
||||||
import android.telephony.CellLocation;
|
import android.telephony.CellLocation;
|
||||||
import android.telephony.PhoneNumberUtils;
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.telephony.ServiceState;
|
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.CommandsInterface;
|
||||||
import com.android.internal.telephony.Connection;
|
import com.android.internal.telephony.Connection;
|
||||||
import com.android.internal.telephony.DataConnection;
|
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.IccCard;
|
||||||
import com.android.internal.telephony.IccException;
|
import com.android.internal.telephony.IccException;
|
||||||
import com.android.internal.telephony.IccFileHandler;
|
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.TelephonyIntents;
|
||||||
import com.android.internal.telephony.TelephonyProperties;
|
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.List;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
@@ -154,6 +168,23 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false");
|
String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false");
|
||||||
mIsPhoneInECMState = inEcm.equals("true");
|
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.
|
// Notify voicemails.
|
||||||
notifier.notifyMessageWaitingChanged(this);
|
notifier.notifyMessageWaitingChanged(this);
|
||||||
}
|
}
|
||||||
@@ -427,13 +458,7 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getSubscriberId() {
|
public String getSubscriberId() {
|
||||||
// Subscriber ID is the combination of MCC+MNC+MIN as CDMA IMSI
|
return mSST.getImsi();
|
||||||
// TODO(Moto): Replace with call to mRuimRecords.getIMSI_M() when implemented.
|
|
||||||
if ((getServiceState().getOperatorNumeric() != null) && (getCdmaMIN() != null)) {
|
|
||||||
return (getServiceState().getOperatorNumeric() + getCdmaMIN());
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canConference() {
|
public boolean canConference() {
|
||||||
@@ -1244,4 +1269,66 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
editor.commit();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,8 @@ package com.android.internal.telephony.cdma;
|
|||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.database.SQLException;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.AsyncResult;
|
import android.os.AsyncResult;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
@@ -35,7 +32,6 @@ import android.os.SystemProperties;
|
|||||||
import android.provider.Checkin;
|
import android.provider.Checkin;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.provider.Settings.SettingNotFoundException;
|
import android.provider.Settings.SettingNotFoundException;
|
||||||
import android.provider.Telephony;
|
|
||||||
import android.provider.Telephony.Intents;
|
import android.provider.Telephony.Intents;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SignalStrength;
|
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_ISROAMING;
|
||||||
import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_NUMERIC;
|
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_ALPHA;
|
||||||
|
import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -634,27 +631,6 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
|
|||||||
} else {
|
} else {
|
||||||
newSS.setOperatorName(opNames[0], opNames[1], opNames[2]);
|
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 {
|
} else {
|
||||||
Log.w(LOG_TAG, "error parsing opNames");
|
Log.w(LOG_TAG, "error parsing opNames");
|
||||||
}
|
}
|
||||||
@@ -1444,4 +1420,19 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
|
|||||||
return mMin;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,21 +123,12 @@ public final class RuimRecords extends IccRecords {
|
|||||||
|
|
||||||
adnCache.reset();
|
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
|
// recordsRequested is set to false indicating that the SIM
|
||||||
// read requests made so far are not valid. This is set to
|
// read requests made so far are not valid. This is set to
|
||||||
// true only when fresh set of read requests are made.
|
// true only when fresh set of read requests are made.
|
||||||
recordsRequested = false;
|
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() {
|
public String getMdnNumber() {
|
||||||
return mMyMobileNumber;
|
return mMyMobileNumber;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user