Merge commit 'a7493240ab97013458b2dbe16fcd27fb6e85c0af' * commit 'a7493240ab97013458b2dbe16fcd27fb6e85c0af': Telephony: Fix exception if PROPERTY_OPERATOR_NUMERIC is not set
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2191,6 +2191,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
|
||||
case RIL_REQUEST_SET_SMSC_ADDRESS: ret = responseVoid(p); break;
|
||||
case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
|
||||
case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: ret = responseVoid(p); break;
|
||||
case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: ret = responseVoid(p); break;
|
||||
default:
|
||||
throw new RuntimeException("Unrecognized solicited response: " + rr.mRequest);
|
||||
//break;
|
||||
|
||||
@@ -202,10 +202,6 @@ public class CDMAPhone extends PhoneBase {
|
||||
// Sets current entry in the telephony carrier table
|
||||
updateCurrentCarrierInProvider(operatorNumeric);
|
||||
|
||||
// Updates MCC MNC device configuration information
|
||||
MccTable.updateMccMncConfiguration(this, operatorNumeric);
|
||||
|
||||
|
||||
// Notify voicemails.
|
||||
notifier.notifyMessageWaitingChanged(this);
|
||||
}
|
||||
@@ -1393,20 +1389,22 @@ public class CDMAPhone extends PhoneBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the "current" field in the telephony provider according to the build-time
|
||||
* operator numeric property
|
||||
* 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) {
|
||||
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);
|
||||
|
||||
// Updates MCC MNC device configuration information
|
||||
MccTable.updateMccMncConfiguration(this, operatorNumeric);
|
||||
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
Log.e(LOG_TAG, "Can't store current operator", e);
|
||||
|
||||
Reference in New Issue
Block a user