1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings; 18 19 import android.app.Activity; 20 import android.app.QueuedWork; 21 import android.content.Intent; 22 import android.content.pm.PackageManager; 23 import android.content.pm.ResolveInfo; 24 import android.content.res.Resources; 25 import android.graphics.Typeface; 26 import android.net.TrafficStats; 27 import android.net.Uri; 28 import android.os.AsyncResult; 29 import android.os.Bundle; 30 import android.os.Handler; 31 import android.os.Message; 32 import android.os.SystemProperties; 33 import android.telephony.CellInfo; 34 import android.telephony.CellInfoCdma; 35 import android.telephony.CellInfoGsm; 36 import android.telephony.CellInfoLte; 37 import android.telephony.CellInfoWcdma; 38 import android.telephony.CellIdentityCdma; 39 import android.telephony.CellIdentityGsm; 40 import android.telephony.CellIdentityLte; 41 import android.telephony.CellIdentityWcdma; 42 import android.telephony.CellLocation; 43 import android.telephony.CellSignalStrengthCdma; 44 import android.telephony.CellSignalStrengthGsm; 45 import android.telephony.CellSignalStrengthLte; 46 import android.telephony.CellSignalStrengthWcdma; 47 import android.telephony.DataConnectionRealTimeInfo; 48 import android.telephony.NeighboringCellInfo; 49 import android.telephony.PreciseCallState; 50 import android.telephony.PhoneStateListener; 51 import android.telephony.ServiceState; 52 import android.telephony.SignalStrength; 53 import android.telephony.SubscriptionManager; 54 import android.telephony.TelephonyManager; 55 import android.telephony.cdma.CdmaCellLocation; 56 import android.telephony.gsm.GsmCellLocation; 57 import android.util.Log; 58 import android.view.Menu; 59 import android.view.MenuItem; 60 import android.view.View; 61 import android.view.View.OnClickListener; 62 import android.widget.AdapterView; 63 import android.widget.ArrayAdapter; 64 import android.widget.Button; 65 import android.widget.CompoundButton; 66 import android.widget.CompoundButton.OnCheckedChangeListener; 67 import android.widget.EditText; 68 import android.widget.Spinner; 69 import android.widget.Switch; 70 import android.widget.TextView; 71 72 import com.android.ims.ImsConfig; 73 import com.android.ims.ImsException; 74 import com.android.ims.ImsManager; 75 import com.android.internal.telephony.Phone; 76 import com.android.internal.telephony.PhoneConstants; 77 import com.android.internal.telephony.PhoneFactory; 78 import com.android.internal.telephony.RILConstants; 79 import com.android.internal.telephony.TelephonyProperties; 80 81 import java.io.IOException; 82 import java.net.HttpURLConnection; 83 import java.net.URL; 84 import java.net.UnknownHostException; 85 import java.util.ArrayList; 86 import java.util.List; 87 88 public class RadioInfo extends Activity { 89 private static final String TAG = "RadioInfo"; 90 91 private static final String[] mPreferredNetworkLabels = { 92 "WCDMA preferred", 93 "GSM only", 94 "WCDMA only", 95 "GSM auto (PRL)", 96 "CDMA auto (PRL)", 97 "CDMA only", 98 "EvDo only", 99 "Global auto (PRL)", 100 "LTE/CDMA auto (PRL)", 101 "LTE/UMTS auto (PRL)", 102 "LTE/CDMA/UMTS auto (PRL)", 103 "LTE only", 104 "LTE/WCDMA", 105 "TD-SCDMA only", 106 "TD-SCDMA/WCDMA", 107 "LTE/TD-SCDMA", 108 "TD-SCDMA/GSM", 109 "TD-SCDMA/UMTS", 110 "LTE/TD-SCDMA/WCDMA", 111 "LTE/TD-SCDMA/UMTS", 112 "TD-SCDMA/CDMA/UMTS", 113 "Global/TD-SCDMA", 114 "Unknown" 115 }; 116 117 118 private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE; 119 private static final int CELL_INFO_LIST_RATE_MAX = 0; 120 121 //Values in must match mCellInfoRefreshRates 122 private static final String[] mCellInfoRefreshRateLabels = { 123 "Disabled", 124 "Immediate", 125 "Min 5s", 126 "Min 10s", 127 "Min 60s" 128 }; 129 130 //Values in seconds, must match mCellInfoRefreshRateLabels 131 private static final int mCellInfoRefreshRates[] = { 132 CELL_INFO_LIST_RATE_DISABLED, 133 CELL_INFO_LIST_RATE_MAX, 134 5000, 135 10000, 136 60000 137 }; 138 log(String s)139 private void log(String s) { 140 Log.d(TAG, s); 141 } 142 143 private static final int EVENT_CFI_CHANGED = 302; 144 145 private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000; 146 private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001; 147 private static final int EVENT_QUERY_SMSC_DONE = 1005; 148 private static final int EVENT_UPDATE_SMSC_DONE = 1006; 149 150 private static final int MENU_ITEM_SELECT_BAND = 0; 151 private static final int MENU_ITEM_VIEW_ADN = 1; 152 private static final int MENU_ITEM_VIEW_FDN = 2; 153 private static final int MENU_ITEM_VIEW_SDN = 3; 154 private static final int MENU_ITEM_GET_PDP_LIST = 4; 155 private static final int MENU_ITEM_TOGGLE_DATA = 5; 156 157 private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA 158 private TextView number; 159 private TextView callState; 160 private TextView operatorName; 161 private TextView roamingState; 162 private TextView gsmState; 163 private TextView gprsState; 164 private TextView voiceNetwork; 165 private TextView dataNetwork; 166 private TextView dBm; 167 private TextView mMwi; 168 private TextView mCfi; 169 private TextView mLocation; 170 private TextView mNeighboringCids; 171 private TextView mCellInfo; 172 private TextView mDcRtInfoTv; 173 private TextView sent; 174 private TextView received; 175 private TextView mPingHostnameV4; 176 private TextView mPingHostnameV6; 177 private TextView mHttpClientTest; 178 private TextView dnsCheckState; 179 private EditText smsc; 180 private Switch radioPowerOnSwitch; 181 private Button cellInfoRefreshRateButton; 182 private Button dnsCheckToggleButton; 183 private Button pingTestButton; 184 private Button updateSmscButton; 185 private Button refreshSmscButton; 186 private Button oemInfoButton; 187 private Switch imsVoLteProvisionedSwitch; 188 private Spinner preferredNetworkType; 189 private Spinner cellInfoRefreshRateSpinner; 190 191 private TelephonyManager mTelephonyManager; 192 private ImsManager mImsManager = null; 193 private Phone phone = null; 194 195 private String mPingHostnameResultV4; 196 private String mPingHostnameResultV6; 197 private String mHttpClientTestResult; 198 private boolean mMwiValue = false; 199 private boolean mCfiValue = false; 200 201 private List<CellInfo> mCellInfoResult = null; 202 private CellLocation mCellLocationResult = null; 203 private List<NeighboringCellInfo> mNeighboringCellResult = null; 204 205 private int mPreferredNetworkTypeResult; 206 private int mCellInfoRefreshRateIndex; 207 208 private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() { 209 @Override 210 public void onDataConnectionStateChanged(int state) { 211 updateDataState(); 212 updateNetworkType(); 213 } 214 215 @Override 216 public void onDataActivity(int direction) { 217 updateDataStats2(); 218 } 219 220 @Override 221 public void onCallStateChanged(int state, String incomingNumber) { 222 updateNetworkType(); 223 updatePhoneState(state); 224 } 225 226 @Override 227 public void onPreciseCallStateChanged(PreciseCallState preciseState) { 228 updateNetworkType(); 229 } 230 231 @Override 232 public void onCellLocationChanged(CellLocation location) { 233 updateLocation(location); 234 } 235 236 @Override 237 public void onMessageWaitingIndicatorChanged(boolean mwi) { 238 mMwiValue = mwi; 239 updateMessageWaiting(); 240 } 241 242 @Override 243 public void onCallForwardingIndicatorChanged(boolean cfi) { 244 mCfiValue = cfi; 245 updateCallRedirect(); 246 } 247 248 @Override 249 public void onCellInfoChanged(List<CellInfo> arrayCi) { 250 log("onCellInfoChanged: arrayCi=" + arrayCi); 251 mCellInfoResult = arrayCi; 252 updateCellInfo(mCellInfoResult); 253 } 254 255 @Override 256 public void onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo) { 257 log("onDataConnectionRealTimeInfoChanged: dcRtInfo=" + dcRtInfo); 258 updateDcRtInfoTv(dcRtInfo); 259 } 260 261 @Override 262 public void onSignalStrengthsChanged(SignalStrength signalStrength) { 263 log("onSignalStrengthChanged: SignalStrength=" +signalStrength); 264 updateSignalStrength(signalStrength); 265 } 266 267 @Override 268 public void onServiceStateChanged(ServiceState serviceState) { 269 log("onServiceStateChanged: ServiceState=" + serviceState); 270 updateServiceState(serviceState); 271 updateRadioPowerState(); 272 updateNetworkType(); 273 updateImsVoLteProvisionedState(); 274 } 275 }; 276 updatePreferredNetworkType(int type)277 private void updatePreferredNetworkType(int type) { 278 if (type >= mPreferredNetworkLabels.length || type < 0) { 279 log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " + 280 "type=" + type); 281 type = mPreferredNetworkLabels.length - 1; //set to Unknown 282 } 283 mPreferredNetworkTypeResult = type; 284 285 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true); 286 } 287 288 private Handler mHandler = new Handler() { 289 @Override 290 public void handleMessage(Message msg) { 291 AsyncResult ar; 292 switch (msg.what) { 293 case EVENT_QUERY_PREFERRED_TYPE_DONE: 294 ar= (AsyncResult) msg.obj; 295 if (ar.exception == null && ar.result != null) { 296 updatePreferredNetworkType(((int[])ar.result)[0]); 297 } else { 298 //In case of an exception, we will set this to unknown 299 updatePreferredNetworkType(mPreferredNetworkLabels.length-1); 300 } 301 break; 302 case EVENT_SET_PREFERRED_TYPE_DONE: 303 ar= (AsyncResult) msg.obj; 304 if (ar.exception != null) { 305 log("Set preferred network type failed."); 306 } 307 break; 308 case EVENT_QUERY_SMSC_DONE: 309 ar= (AsyncResult) msg.obj; 310 if (ar.exception != null) { 311 smsc.setText("refresh error"); 312 } else { 313 smsc.setText((String)ar.result); 314 } 315 break; 316 case EVENT_UPDATE_SMSC_DONE: 317 updateSmscButton.setEnabled(true); 318 ar= (AsyncResult) msg.obj; 319 if (ar.exception != null) { 320 smsc.setText("update error"); 321 } 322 break; 323 default: 324 super.handleMessage(msg); 325 break; 326 327 } 328 } 329 }; 330 331 @Override onCreate(Bundle icicle)332 public void onCreate(Bundle icicle) { 333 super.onCreate(icicle); 334 335 setContentView(R.layout.radio_info); 336 337 log("Started onCreate"); 338 339 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 340 phone = PhoneFactory.getDefaultPhone(); 341 342 //TODO: Need to update this if the default phoneId changes? 343 // Better to have an instance per phone? 344 mImsManager = ImsManager.getInstance(getApplicationContext(), 345 SubscriptionManager.getDefaultVoicePhoneId()); 346 347 mDeviceId= (TextView) findViewById(R.id.imei); 348 number = (TextView) findViewById(R.id.number); 349 callState = (TextView) findViewById(R.id.call); 350 operatorName = (TextView) findViewById(R.id.operator); 351 roamingState = (TextView) findViewById(R.id.roaming); 352 gsmState = (TextView) findViewById(R.id.gsm); 353 gprsState = (TextView) findViewById(R.id.gprs); 354 voiceNetwork = (TextView) findViewById(R.id.voice_network); 355 dataNetwork = (TextView) findViewById(R.id.data_network); 356 dBm = (TextView) findViewById(R.id.dbm); 357 mMwi = (TextView) findViewById(R.id.mwi); 358 mCfi = (TextView) findViewById(R.id.cfi); 359 mLocation = (TextView) findViewById(R.id.location); 360 mNeighboringCids = (TextView) findViewById(R.id.neighboring); 361 mCellInfo = (TextView) findViewById(R.id.cellinfo); 362 mCellInfo.setTypeface(Typeface.MONOSPACE); 363 mDcRtInfoTv = (TextView) findViewById(R.id.dcrtinfo); 364 365 sent = (TextView) findViewById(R.id.sent); 366 received = (TextView) findViewById(R.id.received); 367 smsc = (EditText) findViewById(R.id.smsc); 368 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState); 369 mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4); 370 mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6); 371 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest); 372 373 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType); 374 ArrayAdapter<String> adapter = new ArrayAdapter<String> (this, 375 android.R.layout.simple_spinner_item, mPreferredNetworkLabels); 376 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 377 preferredNetworkType.setAdapter(adapter); 378 379 cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select); 380 ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this, 381 android.R.layout.simple_spinner_item, mCellInfoRefreshRateLabels); 382 cellInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 383 cellInfoRefreshRateSpinner.setAdapter(cellInfoAdapter); 384 385 imsVoLteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch); 386 387 radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power); 388 389 pingTestButton = (Button) findViewById(R.id.ping_test); 390 pingTestButton.setOnClickListener(mPingButtonHandler); 391 updateSmscButton = (Button) findViewById(R.id.update_smsc); 392 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler); 393 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc); 394 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler); 395 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle); 396 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler); 397 398 oemInfoButton = (Button) findViewById(R.id.oem_info); 399 oemInfoButton.setOnClickListener(mOemInfoButtonHandler); 400 PackageManager pm = getPackageManager(); 401 Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO"); 402 List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0); 403 if (oemInfoIntentList.size() == 0) { 404 oemInfoButton.setEnabled(false); 405 } 406 407 mCellInfoRefreshRateIndex = 0; //disabled 408 mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown 409 410 //FIXME: Replace with TelephonyManager call 411 phone.getPreferredNetworkType( 412 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE)); 413 414 restoreFromBundle(icicle); 415 } 416 417 @Override onResume()418 protected void onResume() { 419 super.onResume(); 420 421 log("Started onResume"); 422 423 updateMessageWaiting(); 424 updateCallRedirect(); 425 updateDataState(); 426 updateDataStats2(); 427 updateRadioPowerState(); 428 updateImsVoLteProvisionedState(); 429 updateProperties(); 430 updateDnsCheckState(); 431 updateNetworkType(); 432 433 updateNeighboringCids(mNeighboringCellResult); 434 updateLocation(mCellLocationResult); 435 updateCellInfo(mCellInfoResult); 436 437 mPingHostnameV4.setText(mPingHostnameResultV4); 438 mPingHostnameV6.setText(mPingHostnameResultV6); 439 mHttpClientTest.setText(mHttpClientTestResult); 440 441 cellInfoRefreshRateSpinner.setOnItemSelectedListener(mCellInfoRefreshRateHandler); 442 //set selection after registering listener to force update 443 cellInfoRefreshRateSpinner.setSelection(mCellInfoRefreshRateIndex); 444 445 //set selection before registering to prevent update 446 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true); 447 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler); 448 449 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener); 450 imsVoLteProvisionedSwitch.setOnCheckedChangeListener(mImsVoLteCheckedChangeListener); 451 452 mTelephonyManager.listen(mPhoneStateListener, 453 PhoneStateListener.LISTEN_CALL_STATE 454 //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE 455 // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE 456 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE 457 | PhoneStateListener.LISTEN_DATA_ACTIVITY 458 | PhoneStateListener.LISTEN_CELL_LOCATION 459 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR 460 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR 461 | PhoneStateListener.LISTEN_CELL_INFO 462 | PhoneStateListener.LISTEN_SERVICE_STATE 463 | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS 464 | PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO); 465 466 smsc.clearFocus(); 467 } 468 469 @Override onPause()470 protected void onPause() { 471 super.onPause(); 472 473 log("onPause: unregister phone & data intents"); 474 475 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); 476 phone.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED); 477 } 478 restoreFromBundle(Bundle b)479 private void restoreFromBundle(Bundle b) { 480 if( b == null) { 481 return; 482 } 483 484 mPingHostnameResultV4 = b.getString("mPingHostnameResultV4",""); 485 mPingHostnameResultV6 = b.getString("mPingHostnameResultV6",""); 486 mHttpClientTestResult = b.getString("mHttpClientTestResult",""); 487 488 mPingHostnameV4.setText(mPingHostnameResultV4); 489 mPingHostnameV6.setText(mPingHostnameResultV6); 490 mHttpClientTest.setText(mHttpClientTestResult); 491 492 mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult", 493 mPreferredNetworkLabels.length - 1); 494 495 mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0); 496 } 497 498 @Override onSaveInstanceState(Bundle outState)499 protected void onSaveInstanceState(Bundle outState) { 500 outState.putString("mPingHostnameResultV4", mPingHostnameResultV4); 501 outState.putString("mPingHostnameResultV6", mPingHostnameResultV6); 502 outState.putString("mHttpClientTestResult", mHttpClientTestResult); 503 504 outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult); 505 outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex); 506 507 } 508 509 @Override onCreateOptionsMenu(Menu menu)510 public boolean onCreateOptionsMenu(Menu menu) { 511 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label) 512 .setOnMenuItemClickListener(mSelectBandCallback) 513 .setAlphabeticShortcut('b'); 514 menu.add(1, MENU_ITEM_VIEW_ADN, 0, 515 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback); 516 menu.add(1, MENU_ITEM_VIEW_FDN, 0, 517 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback); 518 menu.add(1, MENU_ITEM_VIEW_SDN, 0, 519 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback); 520 menu.add(1, MENU_ITEM_GET_PDP_LIST, 521 0, R.string.radioInfo_menu_getPDP).setOnMenuItemClickListener(mGetPdpList); 522 menu.add(1, MENU_ITEM_TOGGLE_DATA, 523 0, R.string.radio_info_data_connection_disable).setOnMenuItemClickListener(mToggleData); 524 return true; 525 } 526 527 @Override onPrepareOptionsMenu(Menu menu)528 public boolean onPrepareOptionsMenu(Menu menu) { 529 // Get the TOGGLE DATA menu item in the right state. 530 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA); 531 int state = mTelephonyManager.getDataState(); 532 boolean visible = true; 533 534 switch (state) { 535 case TelephonyManager.DATA_CONNECTED: 536 case TelephonyManager.DATA_SUSPENDED: 537 item.setTitle(R.string.radio_info_data_connection_disable); 538 break; 539 case TelephonyManager.DATA_DISCONNECTED: 540 item.setTitle(R.string.radio_info_data_connection_enable); 541 break; 542 default: 543 visible = false; 544 break; 545 } 546 item.setVisible(visible); 547 return true; 548 } 549 updateDnsCheckState()550 private void updateDnsCheckState() { 551 //FIXME: Replace with a TelephonyManager call 552 dnsCheckState.setText(phone.isDnsCheckDisabled() ? 553 "0.0.0.0 allowed" :"0.0.0.0 not allowed"); 554 } 555 556 private final void updateSignalStrength(SignalStrength signalStrength)557 updateSignalStrength(SignalStrength signalStrength) { 558 Resources r = getResources(); 559 560 int signalDbm = signalStrength.getDbm(); 561 562 int signalAsu = signalStrength.getAsuLevel(); 563 564 if (-1 == signalAsu) signalAsu = 0; 565 566 dBm.setText(String.valueOf(signalDbm) + " " 567 + r.getString(R.string.radioInfo_display_dbm) + " " 568 + String.valueOf(signalAsu) + " " 569 + r.getString(R.string.radioInfo_display_asu)); 570 } 571 updateLocation(CellLocation location)572 private final void updateLocation(CellLocation location) { 573 Resources r = getResources(); 574 if (location instanceof GsmCellLocation) { 575 GsmCellLocation loc = (GsmCellLocation)location; 576 int lac = loc.getLac(); 577 int cid = loc.getCid(); 578 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = " 579 + ((lac == -1) ? "unknown" : Integer.toHexString(lac)) 580 + " " 581 + r.getString(R.string.radioInfo_cid) + " = " 582 + ((cid == -1) ? "unknown" : Integer.toHexString(cid))); 583 } else if (location instanceof CdmaCellLocation) { 584 CdmaCellLocation loc = (CdmaCellLocation)location; 585 int bid = loc.getBaseStationId(); 586 int sid = loc.getSystemId(); 587 int nid = loc.getNetworkId(); 588 int lat = loc.getBaseStationLatitude(); 589 int lon = loc.getBaseStationLongitude(); 590 mLocation.setText("BID = " 591 + ((bid == -1) ? "unknown" : Integer.toHexString(bid)) 592 + " " 593 + "SID = " 594 + ((sid == -1) ? "unknown" : Integer.toHexString(sid)) 595 + " " 596 + "NID = " 597 + ((nid == -1) ? "unknown" : Integer.toHexString(nid)) 598 + "\n" 599 + "LAT = " 600 + ((lat == -1) ? "unknown" : Integer.toHexString(lat)) 601 + " " 602 + "LONG = " 603 + ((lon == -1) ? "unknown" : Integer.toHexString(lon))); 604 } else { 605 mLocation.setText("unknown"); 606 } 607 608 609 } 610 updateNeighboringCids(List<NeighboringCellInfo> cids)611 private final void updateNeighboringCids(List<NeighboringCellInfo> cids) { 612 StringBuilder sb = new StringBuilder(); 613 614 if (cids != null) { 615 if ( cids.isEmpty() ) { 616 sb.append("no neighboring cells"); 617 } else { 618 for (NeighboringCellInfo cell : cids) { 619 sb.append(cell.toString()).append(" "); 620 } 621 } 622 } else { 623 sb.append("unknown"); 624 } 625 mNeighboringCids.setText(sb.toString()); 626 } 627 getCellInfoDisplayString(int i)628 private final String getCellInfoDisplayString(int i) { 629 return (i != Integer.MAX_VALUE) ? Integer.toString(i) : ""; 630 } 631 getCellInfoDisplayString(long i)632 private final String getCellInfoDisplayString(long i) { 633 return (i != Long.MAX_VALUE) ? Long.toString(i) : ""; 634 } 635 buildCdmaInfoString(CellInfoCdma ci)636 private final String buildCdmaInfoString(CellInfoCdma ci) { 637 CellIdentityCdma cidCdma = ci.getCellIdentity(); 638 CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength(); 639 640 return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s", 641 ci.isRegistered() ? "S " : " ", 642 getCellInfoDisplayString(cidCdma.getSystemId()), 643 getCellInfoDisplayString(cidCdma.getNetworkId()), 644 getCellInfoDisplayString(cidCdma.getBasestationId()), 645 getCellInfoDisplayString(ssCdma.getCdmaDbm()), 646 getCellInfoDisplayString(ssCdma.getCdmaEcio()), 647 getCellInfoDisplayString(ssCdma.getEvdoDbm()), 648 getCellInfoDisplayString(ssCdma.getEvdoEcio()), 649 getCellInfoDisplayString(ssCdma.getEvdoSnr())); 650 } 651 buildGsmInfoString(CellInfoGsm ci)652 private final String buildGsmInfoString(CellInfoGsm ci) { 653 CellIdentityGsm cidGsm = ci.getCellIdentity(); 654 CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength(); 655 656 return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", 657 ci.isRegistered() ? "S " : " ", 658 getCellInfoDisplayString(cidGsm.getMcc()), 659 getCellInfoDisplayString(cidGsm.getMnc()), 660 getCellInfoDisplayString(cidGsm.getLac()), 661 getCellInfoDisplayString(cidGsm.getCid()), 662 getCellInfoDisplayString(cidGsm.getArfcn()), 663 getCellInfoDisplayString(cidGsm.getBsic()), 664 getCellInfoDisplayString(ssGsm.getDbm())); 665 } 666 buildLteInfoString(CellInfoLte ci)667 private final String buildLteInfoString(CellInfoLte ci) { 668 CellIdentityLte cidLte = ci.getCellIdentity(); 669 CellSignalStrengthLte ssLte = ci.getCellSignalStrength(); 670 671 return String.format( 672 "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n", 673 ci.isRegistered() ? "S " : " ", 674 getCellInfoDisplayString(cidLte.getMcc()), 675 getCellInfoDisplayString(cidLte.getMnc()), 676 getCellInfoDisplayString(cidLte.getTac()), 677 getCellInfoDisplayString(cidLte.getCi()), 678 getCellInfoDisplayString(cidLte.getPci()), 679 getCellInfoDisplayString(cidLte.getEarfcn()), 680 getCellInfoDisplayString(ssLte.getDbm()), 681 getCellInfoDisplayString(ssLte.getRsrq()), 682 getCellInfoDisplayString(ssLte.getTimingAdvance())); 683 } 684 buildWcdmaInfoString(CellInfoWcdma ci)685 private final String buildWcdmaInfoString(CellInfoWcdma ci) { 686 CellIdentityWcdma cidWcdma = ci.getCellIdentity(); 687 CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength(); 688 689 return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n", 690 ci.isRegistered() ? "S " : " ", 691 getCellInfoDisplayString(cidWcdma.getMcc()), 692 getCellInfoDisplayString(cidWcdma.getMnc()), 693 getCellInfoDisplayString(cidWcdma.getLac()), 694 getCellInfoDisplayString(cidWcdma.getCid()), 695 getCellInfoDisplayString(cidWcdma.getUarfcn()), 696 getCellInfoDisplayString(cidWcdma.getPsc()), 697 getCellInfoDisplayString(ssWcdma.getDbm())); 698 } 699 buildCellInfoString(List<CellInfo> arrayCi)700 private final String buildCellInfoString(List<CellInfo> arrayCi) { 701 String value = new String(); 702 StringBuilder cdmaCells = new StringBuilder(), 703 gsmCells = new StringBuilder(), 704 lteCells = new StringBuilder(), 705 wcdmaCells = new StringBuilder(); 706 707 if (arrayCi != null) { 708 for (CellInfo ci : arrayCi) { 709 710 if (ci instanceof CellInfoLte) { 711 lteCells.append(buildLteInfoString((CellInfoLte) ci)); 712 } else if (ci instanceof CellInfoWcdma) { 713 wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci)); 714 } else if (ci instanceof CellInfoGsm) { 715 gsmCells.append(buildGsmInfoString((CellInfoGsm) ci)); 716 } else if (ci instanceof CellInfoCdma) { 717 cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci)); 718 } 719 } 720 if (lteCells.length() != 0) { 721 value += String.format( 722 "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n", 723 "SRV", "MCC", "MNC", "TAC", "CID", "PCI", "EARFCN", "RSRP", "RSRQ", "TA"); 724 value += lteCells.toString(); 725 } 726 if (wcdmaCells.length() != 0) { 727 value += String.format("WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n", 728 "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP"); 729 value += wcdmaCells.toString(); 730 } 731 if (gsmCells.length() != 0) { 732 value += String.format("GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", 733 "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI"); 734 value += gsmCells.toString(); 735 } 736 if (cdmaCells.length() != 0) { 737 value += String.format( 738 "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n", 739 "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR"); 740 value += cdmaCells.toString(); 741 } 742 } else { 743 value ="unknown"; 744 } 745 746 return value.toString(); 747 } 748 updateCellInfo(List<CellInfo> arrayCi)749 private final void updateCellInfo(List<CellInfo> arrayCi) { 750 mCellInfo.setText(buildCellInfoString(arrayCi)); 751 } 752 updateDcRtInfoTv(DataConnectionRealTimeInfo dcRtInfo)753 private final void updateDcRtInfoTv(DataConnectionRealTimeInfo dcRtInfo) { 754 mDcRtInfoTv.setText(dcRtInfo.toString()); 755 } 756 757 private final void updateMessageWaiting()758 updateMessageWaiting() { 759 mMwi.setText(String.valueOf(mMwiValue)); 760 } 761 762 private final void updateCallRedirect()763 updateCallRedirect() { 764 mCfi.setText(String.valueOf(mCfiValue)); 765 } 766 767 768 private final void updateServiceState(ServiceState serviceState)769 updateServiceState(ServiceState serviceState) { 770 int state = serviceState.getState(); 771 Resources r = getResources(); 772 String display = r.getString(R.string.radioInfo_unknown); 773 774 switch (state) { 775 case ServiceState.STATE_IN_SERVICE: 776 display = r.getString(R.string.radioInfo_service_in); 777 break; 778 case ServiceState.STATE_OUT_OF_SERVICE: 779 case ServiceState.STATE_EMERGENCY_ONLY: 780 display = r.getString(R.string.radioInfo_service_emergency); 781 break; 782 case ServiceState.STATE_POWER_OFF: 783 display = r.getString(R.string.radioInfo_service_off); 784 break; 785 } 786 787 gsmState.setText(display); 788 789 if (serviceState.getRoaming()) { 790 roamingState.setText(R.string.radioInfo_roaming_in); 791 } else { 792 roamingState.setText(R.string.radioInfo_roaming_not); 793 } 794 795 operatorName.setText(serviceState.getOperatorAlphaLong()); 796 } 797 798 private final void updatePhoneState(int state)799 updatePhoneState(int state) { 800 Resources r = getResources(); 801 String display = r.getString(R.string.radioInfo_unknown); 802 803 switch (state) { 804 case TelephonyManager.CALL_STATE_IDLE: 805 display = r.getString(R.string.radioInfo_phone_idle); 806 break; 807 case TelephonyManager.CALL_STATE_RINGING: 808 display = r.getString(R.string.radioInfo_phone_ringing); 809 break; 810 case TelephonyManager.CALL_STATE_OFFHOOK: 811 display = r.getString(R.string.radioInfo_phone_offhook); 812 break; 813 } 814 815 callState.setText(display); 816 } 817 818 private final void updateDataState()819 updateDataState() { 820 int state = mTelephonyManager.getDataState(); 821 Resources r = getResources(); 822 String display = r.getString(R.string.radioInfo_unknown); 823 824 switch (state) { 825 case TelephonyManager.DATA_CONNECTED: 826 display = r.getString(R.string.radioInfo_data_connected); 827 break; 828 case TelephonyManager.DATA_CONNECTING: 829 display = r.getString(R.string.radioInfo_data_connecting); 830 break; 831 case TelephonyManager.DATA_DISCONNECTED: 832 display = r.getString(R.string.radioInfo_data_disconnected); 833 break; 834 case TelephonyManager.DATA_SUSPENDED: 835 display = r.getString(R.string.radioInfo_data_suspended); 836 break; 837 } 838 839 gprsState.setText(display); 840 } 841 updateNetworkType()842 private final void updateNetworkType() { 843 if( phone != null ) { 844 ServiceState ss = phone.getServiceState(); 845 dataNetwork.setText(ServiceState.rilRadioTechnologyToString( 846 phone.getServiceState().getRilDataRadioTechnology())); 847 voiceNetwork.setText(ServiceState.rilRadioTechnologyToString( 848 phone.getServiceState().getRilVoiceRadioTechnology())); 849 } 850 } 851 852 private final void updateProperties()853 updateProperties() { 854 String s; 855 Resources r = getResources(); 856 857 s = phone.getDeviceId(); 858 if (s == null) s = r.getString(R.string.radioInfo_unknown); 859 mDeviceId.setText(s); 860 861 //FIXME: Replace with a TelephonyManager call 862 s = phone.getLine1Number(); 863 if (s == null) s = r.getString(R.string.radioInfo_unknown); 864 number.setText(s); 865 } 866 updateDataStats2()867 private final void updateDataStats2() { 868 Resources r = getResources(); 869 870 long txPackets = TrafficStats.getMobileTxPackets(); 871 long rxPackets = TrafficStats.getMobileRxPackets(); 872 long txBytes = TrafficStats.getMobileTxBytes(); 873 long rxBytes = TrafficStats.getMobileRxBytes(); 874 875 String packets = r.getString(R.string.radioInfo_display_packets); 876 String bytes = r.getString(R.string.radioInfo_display_bytes); 877 878 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes); 879 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes); 880 } 881 882 /** 883 * Ping a host name 884 */ pingHostname()885 private final void pingHostname() { 886 try { 887 try { 888 Process p4 = Runtime.getRuntime().exec("ping -c 1 www.google.com"); 889 int status4 = p4.waitFor(); 890 if (status4 == 0) { 891 mPingHostnameResultV4 = "Pass"; 892 } else { 893 mPingHostnameResultV4 = String.format("Fail(%d)", status4); 894 } 895 } catch (IOException e) { 896 mPingHostnameResultV4 = "Fail: IOException"; 897 } 898 try { 899 Process p6 = Runtime.getRuntime().exec("ping6 -c 1 www.google.com"); 900 int status6 = p6.waitFor(); 901 if (status6 == 0) { 902 mPingHostnameResultV6 = "Pass"; 903 } else { 904 mPingHostnameResultV6 = String.format("Fail(%d)", status6); 905 } 906 } catch (IOException e) { 907 mPingHostnameResultV6 = "Fail: IOException"; 908 } 909 } catch (InterruptedException e) { 910 mPingHostnameResultV4 = mPingHostnameResultV6 = "Fail: InterruptedException"; 911 } 912 } 913 914 /** 915 * This function checks for basic functionality of HTTP Client. 916 */ httpClientTest()917 private void httpClientTest() { 918 HttpURLConnection urlConnection = null; 919 try { 920 // TODO: Hardcoded for now, make it UI configurable 921 URL url = new URL("https://www.google.com"); 922 urlConnection = (HttpURLConnection) url.openConnection(); 923 if (urlConnection.getResponseCode() == 200) { 924 mHttpClientTestResult = "Pass"; 925 } else { 926 mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage(); 927 } 928 } catch (IOException e) { 929 mHttpClientTestResult = "Fail: IOException"; 930 } finally { 931 if (urlConnection != null) { 932 urlConnection.disconnect(); 933 } 934 } 935 } 936 refreshSmsc()937 private void refreshSmsc() { 938 //FIXME: Replace with a TelephonyManager call 939 phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE)); 940 } 941 updateAllCellInfo()942 private final void updateAllCellInfo() { 943 944 mCellInfo.setText(""); 945 mNeighboringCids.setText(""); 946 mLocation.setText(""); 947 948 final Runnable updateAllCellInfoResults = new Runnable() { 949 public void run() { 950 updateNeighboringCids(mNeighboringCellResult); 951 updateLocation(mCellLocationResult); 952 updateCellInfo(mCellInfoResult); 953 } 954 }; 955 956 Thread locThread = new Thread() { 957 @Override 958 public void run() { 959 mCellInfoResult = mTelephonyManager.getAllCellInfo(); 960 mCellLocationResult = mTelephonyManager.getCellLocation(); 961 mNeighboringCellResult = mTelephonyManager.getNeighboringCellInfo(); 962 963 mHandler.post(updateAllCellInfoResults); 964 } 965 }; 966 locThread.start(); 967 } 968 updatePingState()969 private final void updatePingState() { 970 // Set all to unknown since the threads will take a few secs to update. 971 mPingHostnameResultV4 = getResources().getString(R.string.radioInfo_unknown); 972 mPingHostnameResultV6 = getResources().getString(R.string.radioInfo_unknown); 973 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown); 974 975 mPingHostnameV4.setText(mPingHostnameResultV4); 976 mPingHostnameV6.setText(mPingHostnameResultV6); 977 mHttpClientTest.setText(mHttpClientTestResult); 978 979 final Runnable updatePingResults = new Runnable() { 980 public void run() { 981 mPingHostnameV4.setText(mPingHostnameResultV4); 982 mPingHostnameV6.setText(mPingHostnameResultV6); 983 mHttpClientTest.setText(mHttpClientTestResult); 984 } 985 }; 986 987 Thread hostname = new Thread() { 988 @Override 989 public void run() { 990 pingHostname(); 991 mHandler.post(updatePingResults); 992 } 993 }; 994 hostname.start(); 995 996 Thread httpClient = new Thread() { 997 @Override 998 public void run() { 999 httpClientTest(); 1000 mHandler.post(updatePingResults); 1001 } 1002 }; 1003 httpClient.start(); 1004 } 1005 1006 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() { 1007 public boolean onMenuItemClick(MenuItem item) { 1008 Intent intent = new Intent(Intent.ACTION_VIEW); 1009 // XXX We need to specify the component here because if we don't 1010 // the activity manager will try to resolve the type by calling 1011 // the content provider, which causes it to be loaded in a process 1012 // other than the Dialer process, which causes a lot of stuff to 1013 // break. 1014 intent.setClassName("com.android.phone", 1015 "com.android.phone.SimContacts"); 1016 startActivity(intent); 1017 return true; 1018 } 1019 }; 1020 1021 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() { 1022 public boolean onMenuItemClick(MenuItem item) { 1023 Intent intent = new Intent(Intent.ACTION_VIEW); 1024 // XXX We need to specify the component here because if we don't 1025 // the activity manager will try to resolve the type by calling 1026 // the content provider, which causes it to be loaded in a process 1027 // other than the Dialer process, which causes a lot of stuff to 1028 // break. 1029 intent.setClassName("com.android.phone", 1030 "com.android.phone.settings.fdn.FdnList"); 1031 startActivity(intent); 1032 return true; 1033 } 1034 }; 1035 1036 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() { 1037 public boolean onMenuItemClick(MenuItem item) { 1038 Intent intent = new Intent( 1039 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn")); 1040 // XXX We need to specify the component here because if we don't 1041 // the activity manager will try to resolve the type by calling 1042 // the content provider, which causes it to be loaded in a process 1043 // other than the Dialer process, which causes a lot of stuff to 1044 // break. 1045 intent.setClassName("com.android.phone", 1046 "com.android.phone.ADNList"); 1047 startActivity(intent); 1048 return true; 1049 } 1050 }; 1051 1052 private MenuItem.OnMenuItemClickListener mGetPdpList = new MenuItem.OnMenuItemClickListener() { 1053 public boolean onMenuItemClick(MenuItem item) { 1054 //FIXME: Replace with a TelephonyManager call 1055 phone.getDataCallList(null); 1056 return true; 1057 } 1058 }; 1059 1060 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() { 1061 public boolean onMenuItemClick(MenuItem item) { 1062 Intent intent = new Intent(); 1063 intent.setClass(RadioInfo.this, BandMode.class); 1064 startActivity(intent); 1065 return true; 1066 } 1067 }; 1068 1069 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() { 1070 public boolean onMenuItemClick(MenuItem item) { 1071 int state = mTelephonyManager.getDataState(); 1072 switch (state) { 1073 case TelephonyManager.DATA_CONNECTED: 1074 //FIXME: Replace with a TelephonyManager call 1075 phone.setDataEnabled(false); 1076 break; 1077 case TelephonyManager.DATA_DISCONNECTED: 1078 //FIXME: Replace with a TelephonyManager call 1079 phone.setDataEnabled(true); 1080 break; 1081 default: 1082 // do nothing 1083 break; 1084 } 1085 return true; 1086 } 1087 }; 1088 isRadioOn()1089 private boolean isRadioOn() { 1090 //FIXME: Replace with a TelephonyManager call 1091 return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF; 1092 } 1093 updateRadioPowerState()1094 private void updateRadioPowerState() { 1095 //delightful hack to prevent on-checked-changed calls from 1096 //actually forcing the radio preference to its transient/current value. 1097 radioPowerOnSwitch.setOnCheckedChangeListener(null); 1098 radioPowerOnSwitch.setChecked(isRadioOn()); 1099 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener); 1100 } 1101 1102 OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() { 1103 @Override 1104 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 1105 log("toggle radio power: currently " + (isRadioOn()?"on":"off")); 1106 phone.setRadioPower(isChecked); 1107 } 1108 }; 1109 setImsVoLteProvisionedState( boolean state )1110 void setImsVoLteProvisionedState( boolean state ) { 1111 log(String.format("toggle VoLTE provisioned: %s", ((state) ? "on":"off"))); 1112 1113 if (phone != null && mImsManager != null) { 1114 QueuedWork.singleThreadExecutor().submit(new Runnable() { 1115 public void run() { 1116 try { 1117 mImsManager.getConfigInterface().setProvisionedValue( 1118 ImsConfig.ConfigConstants.VLT_SETTING_ENABLED, 1119 state? 1 : 0); 1120 } catch (ImsException e) { 1121 Log.e(TAG, "setImsVoLteProvisioned() exception:", e); 1122 } 1123 } 1124 }); 1125 } 1126 } 1127 isImsVoLteProvisioned()1128 private boolean isImsVoLteProvisioned() { 1129 if (phone != null && mImsManager != null) { 1130 return mImsManager.isVolteEnabledByPlatform(phone.getContext()) 1131 && mImsManager.isVolteProvisionedOnDevice(phone.getContext()); 1132 } 1133 return false; 1134 } 1135 1136 OnCheckedChangeListener mImsVoLteCheckedChangeListener = new OnCheckedChangeListener() { 1137 @Override 1138 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 1139 setImsVoLteProvisionedState(isChecked); 1140 } 1141 }; 1142 updateImsVoLteProvisionedState()1143 private void updateImsVoLteProvisionedState() { 1144 log("updateImsVoLteProvisionedState isImsVoLteProvisioned()=" + isImsVoLteProvisioned()); 1145 //delightful hack to prevent on-checked-changed calls from 1146 //actually forcing the ims provisioning to its transient/current value. 1147 imsVoLteProvisionedSwitch.setOnCheckedChangeListener(null); 1148 imsVoLteProvisionedSwitch.setChecked(isImsVoLteProvisioned()); 1149 imsVoLteProvisionedSwitch.setOnCheckedChangeListener(mImsVoLteCheckedChangeListener); 1150 } 1151 1152 OnClickListener mDnsCheckButtonHandler = new OnClickListener() { 1153 public void onClick(View v) { 1154 //FIXME: Replace with a TelephonyManager call 1155 phone.disableDnsCheck(!phone.isDnsCheckDisabled()); 1156 updateDnsCheckState(); 1157 } 1158 }; 1159 1160 OnClickListener mOemInfoButtonHandler = new OnClickListener() { 1161 public void onClick(View v) { 1162 Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO"); 1163 try { 1164 startActivity(intent); 1165 } catch (android.content.ActivityNotFoundException ex) { 1166 log("OEM-specific Info/Settings Activity Not Found : " + ex); 1167 // If the activity does not exist, there are no OEM 1168 // settings, and so we can just do nothing... 1169 } 1170 } 1171 }; 1172 1173 OnClickListener mPingButtonHandler = new OnClickListener() { 1174 public void onClick(View v) { 1175 updatePingState(); 1176 } 1177 }; 1178 1179 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() { 1180 public void onClick(View v) { 1181 updateSmscButton.setEnabled(false); 1182 phone.setSmscAddress(smsc.getText().toString(), 1183 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE)); 1184 } 1185 }; 1186 1187 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() { 1188 public void onClick(View v) { 1189 refreshSmsc(); 1190 } 1191 }; 1192 1193 AdapterView.OnItemSelectedListener mPreferredNetworkHandler = 1194 new AdapterView.OnItemSelectedListener() { 1195 1196 public void onItemSelected(AdapterView parent, View v, int pos, long id) { 1197 if (mPreferredNetworkTypeResult != pos && pos >= 0 1198 && pos <= mPreferredNetworkLabels.length - 2) { 1199 mPreferredNetworkTypeResult = pos; 1200 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE); 1201 phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg); 1202 } 1203 } 1204 1205 public void onNothingSelected(AdapterView parent) { 1206 } 1207 }; 1208 1209 AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler = 1210 new AdapterView.OnItemSelectedListener() { 1211 1212 public void onItemSelected(AdapterView parent, View v, int pos, long id) { 1213 mCellInfoRefreshRateIndex = pos; 1214 phone.setCellInfoListRate(mCellInfoRefreshRates[pos]); 1215 updateAllCellInfo(); 1216 } 1217 1218 public void onNothingSelected(AdapterView parent) { 1219 } 1220 }; 1221 1222 } 1223