diff --git a/res/layout/radio_info.xml b/res/layout/radio_info.xml index fc8cc263c2a..5c918fc2292 100644 --- a/res/layout/radio_info.xml +++ b/res/layout/radio_info.xml @@ -25,6 +25,19 @@ android:descendantFocusability="beforeDescendants" android:focusableInTouchMode="true"> + + + + + @@ -37,6 +50,18 @@ + + + + + + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index a0e572deabc..9c24dd34a9e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -484,6 +484,10 @@ "PAC URL: " + + Current subId: + + SubId of default data SIM: DL Bandwidth (kbps): @@ -531,6 +535,8 @@ Data Network Type: + Select phone index + Set Preferred Network Type: Ping Hostname(www.google.com) IPv4: diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java index 0b7d1bea241..e0ce1c0cc8e 100644 --- a/src/com/android/settings/RadioInfo.java +++ b/src/com/android/settings/RadioInfo.java @@ -125,6 +125,7 @@ public class RadioInfo extends Activity { "Unknown" }; + private static String[] mPhoneIndexLabels; private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE; private static final int CELL_INFO_LIST_RATE_MAX = 0; @@ -160,7 +161,7 @@ public class RadioInfo extends Activity { 60000 }; - private void log(String s) { + private static void log(String s) { Log.d(TAG, s); } @@ -171,15 +172,17 @@ public class RadioInfo extends Activity { private static final int EVENT_QUERY_SMSC_DONE = 1005; private static final int EVENT_UPDATE_SMSC_DONE = 1006; - private static final int MENU_ITEM_SELECT_BAND = 0; - private static final int MENU_ITEM_VIEW_ADN = 1; - private static final int MENU_ITEM_VIEW_FDN = 2; - private static final int MENU_ITEM_VIEW_SDN = 3; - private static final int MENU_ITEM_GET_IMS_STATUS = 4; - private static final int MENU_ITEM_TOGGLE_DATA = 5; + private static final int MENU_ITEM_SELECT_BAND = 0; + private static final int MENU_ITEM_VIEW_ADN = 1; + private static final int MENU_ITEM_VIEW_FDN = 2; + private static final int MENU_ITEM_VIEW_SDN = 3; + private static final int MENU_ITEM_GET_IMS_STATUS = 4; + private static final int MENU_ITEM_TOGGLE_DATA = 5; private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA private TextView number; + private TextView mSubscriptionId; + private TextView mDds; private TextView mSubscriberId; private TextView callState; private TextView operatorName; @@ -219,12 +222,13 @@ public class RadioInfo extends Activity { private Switch cbrsDataSwitch; private Switch dsdsSwitch; private Spinner preferredNetworkType; + private Spinner mSelectPhoneIndex; private Spinner cellInfoRefreshRateSpinner; private ConnectivityManager mConnectivityManager; private TelephonyManager mTelephonyManager; private ImsManager mImsManager = null; - private Phone phone = null; + private Phone mPhone = null; private String mPingHostnameResultV4; private String mPingHostnameResultV6; @@ -237,6 +241,7 @@ public class RadioInfo extends Activity { private int mPreferredNetworkTypeResult; private int mCellInfoRefreshRateIndex; + private int mSelectedPhoneIndex; private final NetworkRequest mDefaultNetworkRequest = new NetworkRequest.Builder() .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) @@ -251,7 +256,9 @@ public class RadioInfo extends Activity { } }; - private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() { + // not final because we need to recreate this object to register on a new subId (b/117555407) + private PhoneStateListener mPhoneStateListener = new RadioInfoPhoneStateListener(); + private class RadioInfoPhoneStateListener extends PhoneStateListener { @Override public void onDataConnectionStateChanged(int state) { updateDataState(); @@ -319,7 +326,7 @@ public class RadioInfo extends Activity { updatePhysicalChannelConfiguration(configs); } - }; + } private void updatePhysicalChannelConfiguration(List configs) { StringBuilder sb = new StringBuilder(); @@ -346,6 +353,21 @@ public class RadioInfo extends Activity { preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true); } + private void updatePhoneIndex(int phoneIndex, int subId) { + // unregister listeners on the old subId + unregisterPhoneStateListener(); + mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED); + + // update the subId + mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId); + + // update the phoneId + mImsManager = ImsManager.getInstance(getApplicationContext(), phoneIndex); + mPhone = PhoneFactory.getPhone(phoneIndex); + + updateAllFields(); + } + private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { @@ -404,15 +426,17 @@ public class RadioInfo extends Activity { mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); mConnectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE); - phone = PhoneFactory.getDefaultPhone(); + mPhone = PhoneFactory.getDefaultPhone(); - //TODO: Need to update this if the default phoneId changes? - // Better to have an instance per phone? mImsManager = ImsManager.getInstance(getApplicationContext(), SubscriptionManager.getDefaultVoicePhoneId()); + mPhoneIndexLabels = getPhoneIndexLabels(mTelephonyManager); + mDeviceId = (TextView) findViewById(R.id.imei); number = (TextView) findViewById(R.id.number); + mSubscriptionId = (TextView) findViewById(R.id.subid); + mDds = (TextView) findViewById(R.id.dds); mSubscriberId = (TextView) findViewById(R.id.imsi); callState = (TextView) findViewById(R.id.call); operatorName = (TextView) findViewById(R.id.operator); @@ -439,10 +463,17 @@ public class RadioInfo extends Activity { mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config); preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType); - ArrayAdapter adapter = new ArrayAdapter (this, + ArrayAdapter preferredNetworkTypeAdapter = new ArrayAdapter (this, android.R.layout.simple_spinner_item, mPreferredNetworkLabels); - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - preferredNetworkType.setAdapter(adapter); + preferredNetworkTypeAdapter + .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + preferredNetworkType.setAdapter(preferredNetworkTypeAdapter); + + mSelectPhoneIndex = (Spinner) findViewById(R.id.phoneIndex); + ArrayAdapter phoneIndexAdapter = new ArrayAdapter (this, + android.R.layout.simple_spinner_item, mPhoneIndexLabels); + phoneIndexAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mSelectPhoneIndex.setAdapter(phoneIndexAdapter); cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select); ArrayAdapter cellInfoAdapter = new ArrayAdapter(this, @@ -455,7 +486,7 @@ public class RadioInfo extends Activity { imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch); eabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch); - if (!ImsManager.isImsSupportedOnDevice(phone.getContext())) { + if (!ImsManager.isImsSupportedOnDevice(mPhone.getContext())) { imsVolteProvisionedSwitch.setVisibility(View.GONE); imsVtProvisionedSwitch.setVisibility(View.GONE); imsWfcProvisionedSwitch.setVisibility(View.GONE); @@ -513,9 +544,10 @@ public class RadioInfo extends Activity { mCellInfoRefreshRateIndex = 0; //disabled mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown + mSelectedPhoneIndex = 0; //phone 0 //FIXME: Replace with TelephonyManager call - phone.getPreferredNetworkType( + mPhone.getPreferredNetworkType( mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE)); restoreFromBundle(icicle); @@ -527,6 +559,10 @@ public class RadioInfo extends Activity { log("Started onResume"); + updateAllFields(); + } + + private void updateAllFields() { updateMessageWaiting(); updateCallRedirect(); updateDataState(); @@ -539,6 +575,7 @@ public class RadioInfo extends Activity { updateLocation(mCellLocationResult); updateCellInfo(mCellInfoResult); + updateSubscriptionIds(); mPingHostnameV4.setText(mPingHostnameResultV4); mPingHostnameV6.setText(mPingHostnameResultV6); @@ -552,6 +589,10 @@ public class RadioInfo extends Activity { preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true); preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler); + // set phone index + mSelectPhoneIndex.setSelection(mSelectedPhoneIndex, true); + mSelectPhoneIndex.setOnItemSelectedListener(mSelectPhoneIndexHandler); + radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener); imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener); imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener); @@ -563,19 +604,8 @@ public class RadioInfo extends Activity { cbrsDataSwitch.setOnCheckedChangeListener(mCbrsDataSwitchChangeListener); } - mTelephonyManager.listen(mPhoneStateListener, - PhoneStateListener.LISTEN_CALL_STATE - //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE - // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE - | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE - | PhoneStateListener.LISTEN_DATA_ACTIVITY - | PhoneStateListener.LISTEN_CELL_LOCATION - | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR - | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR - | PhoneStateListener.LISTEN_CELL_INFO - | PhoneStateListener.LISTEN_SERVICE_STATE - | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS - | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION); + unregisterPhoneStateListener(); + registerPhoneStateListener(); mConnectivityManager.registerNetworkCallback( mDefaultNetworkRequest, mNetworkCallback, mHandler); @@ -611,6 +641,8 @@ public class RadioInfo extends Activity { mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult", mPreferredNetworkLabels.length - 1); + mSelectedPhoneIndex = b.getInt("mSelectedPhoneIndex", 0); + mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0); } @@ -621,6 +653,7 @@ public class RadioInfo extends Activity { outState.putString("mHttpClientTestResult", mHttpClientTestResult); outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult); + outState.putInt("mSelectedPhoneIndex", mSelectedPhoneIndex); outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex); } @@ -636,7 +669,7 @@ public class RadioInfo extends Activity { R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback); menu.add(1, MENU_ITEM_VIEW_SDN, 0, R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback); - if (ImsManager.isImsSupportedOnDevice(phone.getContext())) { + if (ImsManager.isImsSupportedOnDevice(mPhone.getContext())) { menu.add(1, MENU_ITEM_GET_IMS_STATUS, 0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus); } @@ -668,9 +701,61 @@ public class RadioInfo extends Activity { return true; } + // returns array of string labels for each phone index. The array index is equal to the phone + // index. + private static String[] getPhoneIndexLabels(TelephonyManager tm) { + int phones = tm.getPhoneCount(); + String[] labels = new String[phones]; + for (int i = 0; i < phones; i++) { + labels[i] = "Phone " + i; + } + return labels; + } + + private void unregisterPhoneStateListener() { + mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); + + // clear all fields so they are blank until the next listener event occurs + operatorName.setText(""); + gprsState.setText(""); + dataNetwork.setText(""); + voiceNetwork.setText(""); + sent.setText(""); + received.setText(""); + callState.setText(""); + mLocation.setText(""); + mMwiValue = false; + mMwi.setText(""); + mCfiValue = false; + mCfi.setText(""); + mCellInfo.setText(""); + dBm.setText(""); + gsmState.setText(""); + roamingState.setText(""); + mPhyChanConfig.setText(""); + } + + // register mPhoneStateListener for relevant fields using the current TelephonyManager + private void registerPhoneStateListener() { + mPhoneStateListener = new RadioInfoPhoneStateListener(); + mTelephonyManager.listen(mPhoneStateListener, + PhoneStateListener.LISTEN_CALL_STATE + //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE + // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE + | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE + | PhoneStateListener.LISTEN_DATA_ACTIVITY + | PhoneStateListener.LISTEN_CELL_LOCATION + | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR + | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR + | PhoneStateListener.LISTEN_CELL_INFO + | PhoneStateListener.LISTEN_SERVICE_STATE + | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS + | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION); + } + private void updateDnsCheckState() { //FIXME: Replace with a TelephonyManager call - dnsCheckState.setText(phone.isDnsCheckDisabled() ? + dnsCheckState.setText(mPhone.isDnsCheckDisabled() ? "0.0.0.0 allowed" :"0.0.0.0 not allowed"); } @@ -889,6 +974,11 @@ public class RadioInfo extends Activity { mCellInfo.setText(buildCellInfoString(arrayCi)); } + private final void updateSubscriptionIds() { + mSubscriptionId.setText(Integer.toString(mPhone.getSubId())); + mDds.setText(Integer.toString(SubscriptionManager.getDefaultDataSubscriptionId())); + } + private final void updateMessageWaiting() { mMwi.setText(String.valueOf(mMwiValue)); @@ -975,12 +1065,12 @@ public class RadioInfo extends Activity { } private final void updateNetworkType() { - if(phone != null) { - ServiceState ss = phone.getServiceState(); + if(mPhone != null) { + ServiceState ss = mPhone.getServiceState(); dataNetwork.setText(ServiceState.rilRadioTechnologyToString( - phone.getServiceState().getRilDataRadioTechnology())); + mPhone.getServiceState().getRilDataRadioTechnology())); voiceNetwork.setText(ServiceState.rilRadioTechnologyToString( - phone.getServiceState().getRilVoiceRadioTechnology())); + mPhone.getServiceState().getRilVoiceRadioTechnology())); } } @@ -989,16 +1079,16 @@ public class RadioInfo extends Activity { String s; Resources r = getResources(); - s = phone.getDeviceId(); + s = mPhone.getDeviceId(); if (s == null) s = r.getString(R.string.radioInfo_unknown); mDeviceId.setText(s); - s = phone.getSubscriberId(); + s = mPhone.getSubscriberId(); if (s == null) s = r.getString(R.string.radioInfo_unknown); mSubscriberId.setText(s); //FIXME: Replace with a TelephonyManager call - s = phone.getLine1Number(); + s = mPhone.getLine1Number(); if (s == null) s = r.getString(R.string.radioInfo_unknown); number.setText(s); } @@ -1075,7 +1165,7 @@ public class RadioInfo extends Activity { private void refreshSmsc() { //FIXME: Replace with a TelephonyManager call - phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE)); + mPhone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE)); } private final void updateAllCellInfo() { @@ -1147,8 +1237,7 @@ public class RadioInfo extends Activity { // the content provider, which causes it to be loaded in a process // other than the Dialer process, which causes a lot of stuff to // break. - intent.setClassName("com.android.phone", - "com.android.phone.SimContacts"); + intent.setClassName("com.android.phone", "com.android.phone.SimContacts"); startActivity(intent); return true; } @@ -1162,8 +1251,7 @@ public class RadioInfo extends Activity { // the content provider, which causes it to be loaded in a process // other than the Dialer process, which causes a lot of stuff to // break. - intent.setClassName("com.android.phone", - "com.android.phone.settings.fdn.FdnList"); + intent.setClassName("com.android.phone", "com.android.phone.settings.fdn.FdnList"); startActivity(intent); return true; } @@ -1178,8 +1266,7 @@ public class RadioInfo extends Activity { // the content provider, which causes it to be loaded in a process // other than the Dialer process, which causes a lot of stuff to // break. - intent.setClassName("com.android.phone", - "com.android.phone.ADNList"); + intent.setClassName("com.android.phone", "com.android.phone.ADNList"); startActivity(intent); return true; } @@ -1187,11 +1274,11 @@ public class RadioInfo extends Activity { private MenuItem.OnMenuItemClickListener mGetImsStatus = new MenuItem.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { - boolean isImsRegistered = phone.isImsRegistered(); - boolean availableVolte = phone.isVolteEnabled(); - boolean availableWfc = phone.isWifiCallingEnabled(); - boolean availableVt = phone.isVideoEnabled(); - boolean availableUt = phone.isUtEnabled(); + boolean isImsRegistered = mPhone.isImsRegistered(); + boolean availableVolte = mPhone.isVolteEnabled(); + boolean availableWfc = mPhone.isWifiCallingEnabled(); + boolean availableVt = mPhone.isVideoEnabled(); + boolean availableUt = mPhone.isUtEnabled(); final String imsRegString = isImsRegistered ? getString(R.string.radio_info_ims_reg_status_registered) : @@ -1248,7 +1335,7 @@ public class RadioInfo extends Activity { private boolean isRadioOn() { //FIXME: Replace with a TelephonyManager call - return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF; + return mPhone.getServiceState().getState() != ServiceState.STATE_POWER_OFF; } private void updateRadioPowerState() { @@ -1280,7 +1367,7 @@ public class RadioInfo extends Activity { } void setImsConfigProvisionedState(int configItem, boolean state) { - if (phone != null && mImsManager != null) { + if (mPhone != null && mImsManager != null) { QueuedWork.queue(new Runnable() { public void run() { try { @@ -1299,14 +1386,14 @@ public class RadioInfo extends Activity { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { log("toggle radio power: currently " + (isRadioOn()?"on":"off")); - phone.setRadioPower(isChecked); + mPhone.setRadioPower(isChecked); } }; private boolean isImsVolteProvisioned() { - if (phone != null && mImsManager != null) { - return mImsManager.isVolteEnabledByPlatform(phone.getContext()) - && mImsManager.isVolteProvisionedOnDevice(phone.getContext()); + if (mPhone != null && mImsManager != null) { + return mImsManager.isVolteEnabledByPlatform(mPhone.getContext()) + && mImsManager.isVolteProvisionedOnDevice(mPhone.getContext()); } return false; } @@ -1319,9 +1406,9 @@ public class RadioInfo extends Activity { }; private boolean isImsVtProvisioned() { - if (phone != null && mImsManager != null) { - return mImsManager.isVtEnabledByPlatform(phone.getContext()) - && mImsManager.isVtProvisionedOnDevice(phone.getContext()); + if (mPhone != null && mImsManager != null) { + return mImsManager.isVtEnabledByPlatform(mPhone.getContext()) + && mImsManager.isVtProvisionedOnDevice(mPhone.getContext()); } return false; } @@ -1334,9 +1421,9 @@ public class RadioInfo extends Activity { }; private boolean isImsWfcProvisioned() { - if (phone != null && mImsManager != null) { - return mImsManager.isWfcEnabledByPlatform(phone.getContext()) - && mImsManager.isWfcProvisionedOnDevice(phone.getContext()); + if (mPhone != null && mImsManager != null) { + return mImsManager.isWfcEnabledByPlatform(mPhone.getContext()) + && mImsManager.isWfcProvisionedOnDevice(mPhone.getContext()); } return false; } @@ -1391,7 +1478,7 @@ public class RadioInfo extends Activity { } private void updateImsProvisionedState() { - if (!ImsManager.isImsSupportedOnDevice(phone.getContext())) { + if (!ImsManager.isImsSupportedOnDevice(mPhone.getContext())) { return; } log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned()); @@ -1401,31 +1488,31 @@ public class RadioInfo extends Activity { imsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned()); imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener); imsVolteProvisionedSwitch.setEnabled(!Build.IS_USER - && mImsManager.isVolteEnabledByPlatform(phone.getContext())); + && mImsManager.isVolteEnabledByPlatform(mPhone.getContext())); imsVtProvisionedSwitch.setOnCheckedChangeListener(null); imsVtProvisionedSwitch.setChecked(isImsVtProvisioned()); imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener); imsVtProvisionedSwitch.setEnabled(!Build.IS_USER - && mImsManager.isVtEnabledByPlatform(phone.getContext())); + && mImsManager.isVtEnabledByPlatform(mPhone.getContext())); imsWfcProvisionedSwitch.setOnCheckedChangeListener(null); imsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned()); imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener); imsWfcProvisionedSwitch.setEnabled(!Build.IS_USER - && mImsManager.isWfcEnabledByPlatform(phone.getContext())); + && mImsManager.isWfcEnabledByPlatform(mPhone.getContext())); eabProvisionedSwitch.setOnCheckedChangeListener(null); eabProvisionedSwitch.setChecked(isEabProvisioned()); eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener); eabProvisionedSwitch.setEnabled(!Build.IS_USER - && isEabEnabledByPlatform(phone.getContext())); + && isEabEnabledByPlatform(mPhone.getContext())); } OnClickListener mDnsCheckButtonHandler = new OnClickListener() { public void onClick(View v) { //FIXME: Replace with a TelephonyManager call - phone.disableDnsCheck(!phone.isDnsCheckDisabled()); + mPhone.disableDnsCheck(!mPhone.isDnsCheckDisabled()); updateDnsCheckState(); } }; @@ -1452,7 +1539,7 @@ public class RadioInfo extends Activity { OnClickListener mUpdateSmscButtonHandler = new OnClickListener() { public void onClick(View v) { updateSmscButton.setEnabled(false); - phone.setSmscAddress(smsc.getText().toString(), + mPhone.setSmscAddress(smsc.getText().toString(), mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE)); } }; @@ -1497,14 +1584,40 @@ public class RadioInfo extends Activity { // want this setting to be set, so that if the radio hiccups and this setting // is for some reason unsuccessful, future calls to the radio will reflect // the users's preference which is set here. - final int subId = phone.getSubId(); + final int subId = mPhone.getSubId(); if (SubscriptionManager.isUsableSubIdValue(subId)) { - Settings.Global.putInt(phone.getContext().getContentResolver(), + Settings.Global.putInt(mPhone.getContext().getContentResolver(), PREFERRED_NETWORK_MODE + subId, mPreferredNetworkTypeResult); } log("Calling setPreferredNetworkType(" + mPreferredNetworkTypeResult + ")"); Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE); - phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg); + mPhone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg); + } + } + + public void onNothingSelected(AdapterView parent) { + } + }; + + AdapterView.OnItemSelectedListener mSelectPhoneIndexHandler = + new AdapterView.OnItemSelectedListener() { + + public void onItemSelected(AdapterView parent, View v, int pos, long id) { + if (pos >= 0 && pos <= mPhoneIndexLabels.length - 1) { + // the array position is equal to the phone index + int phoneIndex = pos; + Phone[] phones = PhoneFactory.getPhones(); + if (phones == null || phones.length <= phoneIndex) { + return; + } + // getSubId says it takes a slotIndex, but it actually takes a phone index + int[] subIds = SubscriptionManager.getSubId(phoneIndex); + if (subIds == null || subIds.length < 1) { + return; + } + mSelectedPhoneIndex = phoneIndex; + + updatePhoneIndex(phoneIndex, subIds[0]); } }