Telephony: Fix exception if PROPERTY_OPERATOR_NUMERIC is not set

and minor fixes.

Fix the following
 - When PROPERTY_OPERATOR_NUMERIC is not set, the value is "" when CDMAPhone
is initialized. The constructor tries to extract MCC and MNC from this
property and results in a StringIndexOutOfBounds exception. Check for empty
OperatorNumeric string before trying to extract MCC and MNC
 - Handle RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING response gracefully.

Change-Id: I749d6801bb4794d56e8fd672dec69dfea2b5c756
This commit is contained in:
Wink Saville
2009-12-02 15:07:34 -08:00
parent dfac0e5ece
commit 144fdfec24
3 changed files with 33 additions and 31 deletions

View File

@@ -24,6 +24,7 @@ import android.net.wifi.WifiManager;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import java.util.Arrays;
@@ -573,34 +574,36 @@ public final class MccTable
* @param mccmnc truncated imsi with just the MCC and MNC - MNC assumed to be from 4th to end
*/
public static void updateMccMncConfiguration(PhoneBase phone, String mccmnc) {
int mcc, mnc;
if (!TextUtils.isEmpty(mccmnc)) {
int mcc, mnc;
try {
mcc = Integer.parseInt(mccmnc.substring(0,3));
mnc = Integer.parseInt(mccmnc.substring(3));
} catch (NumberFormatException e) {
Log.e(LOG_TAG, "Error parsing IMSI");
return;
}
try {
mcc = Integer.parseInt(mccmnc.substring(0,3));
mnc = Integer.parseInt(mccmnc.substring(3));
} catch (NumberFormatException e) {
Log.e(LOG_TAG, "Error parsing IMSI");
return;
}
Log.d(LOG_TAG, "updateMccMncConfiguration: mcc=" + mcc + ", mnc=" + mnc);
Log.d(LOG_TAG, "updateMccMncConfiguration: mcc=" + mcc + ", mnc=" + mnc);
if (mcc != 0) {
setTimezoneFromMccIfNeeded(phone, mcc);
setLocaleFromMccIfNeeded(phone, mcc);
setWifiChannelsFromMccIfNeeded(phone, mcc);
}
try {
Configuration config = ActivityManagerNative.getDefault().getConfiguration();
if (mcc != 0) {
config.mcc = mcc;
setTimezoneFromMccIfNeeded(phone, mcc);
setLocaleFromMccIfNeeded(phone, mcc);
setWifiChannelsFromMccIfNeeded(phone, mcc);
}
if (mnc != 0) {
config.mnc = mnc;
try {
Configuration config = ActivityManagerNative.getDefault().getConfiguration();
if (mcc != 0) {
config.mcc = mcc;
}
if (mnc != 0) {
config.mnc = mnc;
}
ActivityManagerNative.getDefault().updateConfiguration(config);
} catch (RemoteException e) {
Log.e(LOG_TAG, "Can't update configuration", e);
}
ActivityManagerNative.getDefault().updateConfiguration(config);
} catch (RemoteException e) {
Log.e(LOG_TAG, "Can't update configuration", e);
}
}