blob: 79327f24bec4acc8284e2bc73ba93ccbc9b6c8c7 [file] [log] [blame]
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001/*
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
17package com.android.settings;
18
19import android.app.Activity;
20import android.app.AlertDialog;
21import android.content.DialogInterface;
22import android.content.Intent;
23import android.content.SharedPreferences;
24import android.content.res.Resources;
25import android.net.Uri;
26import android.os.AsyncResult;
27import android.os.Bundle;
28import android.os.Handler;
29import android.os.INetStatService;
30import android.os.Message;
31import android.os.RemoteException;
32import android.os.ServiceManager;
33import android.os.SystemProperties;
34import android.preference.PreferenceManager;
35import android.telephony.CellLocation;
36import android.telephony.PhoneStateListener;
37import android.telephony.ServiceState;
38import android.telephony.TelephonyManager;
39import android.telephony.NeighboringCellInfo;
40import android.telephony.gsm.GsmCellLocation;
41import android.text.format.DateUtils;
42import android.util.Log;
43import android.view.Menu;
44import android.view.MenuItem;
45import android.view.View;
46import android.view.View.OnClickListener;
47import android.widget.AdapterView;
48import android.widget.ArrayAdapter;
49import android.widget.Button;
50import android.widget.Spinner;
51import android.widget.TextView;
52import android.widget.EditText;
53
54import com.android.internal.telephony.Phone;
55import com.android.internal.telephony.PhoneFactory;
56import com.android.internal.telephony.PhoneStateIntentReceiver;
57import com.android.internal.telephony.TelephonyProperties;
58import com.android.internal.telephony.gsm.GSMPhone;
59import com.android.internal.telephony.gsm.PdpConnection;
60
61import org.apache.http.HttpResponse;
62import org.apache.http.client.HttpClient;
63import org.apache.http.client.methods.HttpGet;
64import org.apache.http.impl.client.DefaultHttpClient;
65
66import java.io.ByteArrayOutputStream;
67import java.io.DataOutputStream;
68import java.io.IOException;
69import java.net.UnknownHostException;
70import java.util.ArrayList;
71import java.util.List;
72
73public class RadioInfo extends Activity {
74 private final String TAG = "phone";
75
76 private static final int EVENT_PHONE_STATE_CHANGED = 100;
77 private static final int EVENT_SIGNAL_STRENGTH_CHANGED = 200;
78 private static final int EVENT_SERVICE_STATE_CHANGED = 300;
79 private static final int EVENT_CFI_CHANGED = 302;
80
81 private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000;
82 private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001;
83 private static final int EVENT_QUERY_NEIGHBORING_CIDS_DONE = 1002;
84 private static final int EVENT_SET_QXDMLOG_DONE = 1003;
85 private static final int EVENT_SET_CIPHER_DONE = 1004;
86 private static final int EVENT_QUERY_SMSC_DONE = 1005;
87 private static final int EVENT_UPDATE_SMSC_DONE = 1006;
88
89 private static final int MENU_ITEM_SELECT_BAND = 0;
90 private static final int MENU_ITEM_VIEW_ADN = 1;
91 private static final int MENU_ITEM_VIEW_FDN = 2;
92 private static final int MENU_ITEM_VIEW_SDN = 3;
93 private static final int MENU_ITEM_GET_PDP_LIST = 4;
94 private static final int MENU_ITEM_TOGGLE_DATA = 5;
95 private static final int MENU_ITEM_TOGGLE_DATA_ON_BOOT = 6;
96
Wink Savillef9e02412009-04-02 01:37:03 -070097 private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080098 private TextView number;
99 private TextView callState;
100 private TextView operatorName;
101 private TextView roamingState;
102 private TextView gsmState;
103 private TextView gprsState;
104 private TextView network;
105 private TextView dBm;
106 private TextView mMwi;
107 private TextView mCfi;
108 private TextView mLocation;
109 private TextView mNeighboringCids;
110 private TextView resets;
111 private TextView attempts;
112 private TextView successes;
113 private TextView disconnects;
114 private TextView sentSinceReceived;
115 private TextView sent;
116 private TextView received;
117 private TextView mPingIpAddr;
118 private TextView mPingHostname;
119 private TextView mHttpClientTest;
120 private TextView cipherState;
121 private TextView dnsCheckState;
122 private EditText smsc;
123 private Button radioPowerButton;
124 private Button qxdmLogButton;
125 private Button cipherToggleButton;
126 private Button dnsCheckToggleButton;
127 private Button pingTestButton;
128 private Button updateSmscButton;
129 private Button refreshSmscButton;
130 private Spinner preferredNetworkType;
131
132 private TelephonyManager mTelephonyManager;
133 private Phone phone = null;
134 private PhoneStateIntentReceiver mPhoneStateReceiver;
135 private INetStatService netstat;
136
137 private OemCommands mOem = null;
138 private boolean mQxdmLogEnabled;
139 // The requested cipher state
140 private boolean mCipherOn;
141
142 private String mPingIpAddrResult;
143 private String mPingHostnameResult;
144 private String mHttpClientTestResult;
145 private boolean mMwiValue = false;
146 private boolean mCfiValue = false;
147
148 private PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
149 @Override
150 public void onDataConnectionStateChanged(int state) {
151 updateDataState();
152 updateDataStats();
153 updatePdpList();
154 updateNetworkType();
155 }
156
157 @Override
158 public void onDataActivity(int direction) {
159 updateDataStats2();
160 }
161
162 @Override
163 public void onCellLocationChanged(CellLocation location) {
164 updateLocation(location);
165 }
166
167 @Override
168 public void onMessageWaitingIndicatorChanged(boolean mwi) {
169 mMwiValue = mwi;
170 updateMessageWaiting();
171 }
172
173 @Override
174 public void onCallForwardingIndicatorChanged(boolean cfi) {
175 mCfiValue = cfi;
176 updateCallRedirect();
177 }
178 };
179
180 private Handler mHandler = new Handler() {
181 public void handleMessage(Message msg) {
182 AsyncResult ar;
183 switch (msg.what) {
184 case EVENT_PHONE_STATE_CHANGED:
185 updatePhoneState();
186 break;
187
188 case EVENT_SIGNAL_STRENGTH_CHANGED:
189 updateSignalStrength();
190 break;
191
192 case EVENT_SERVICE_STATE_CHANGED:
193 updateServiceState();
194 updatePowerState();
195 break;
196
197 case EVENT_QUERY_PREFERRED_TYPE_DONE:
198 ar= (AsyncResult) msg.obj;
199 if (ar.exception == null) {
200 int type = ((int[])ar.result)[0];
201 preferredNetworkType.setSelection(type, true);
202 } else {
203 preferredNetworkType.setSelection(3, true);
204 }
205 break;
206 case EVENT_SET_PREFERRED_TYPE_DONE:
207 ar= (AsyncResult) msg.obj;
208 if (ar.exception != null) {
209 phone.getPreferredNetworkType(
210 obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
211 }
212 break;
213 case EVENT_QUERY_NEIGHBORING_CIDS_DONE:
214 ar= (AsyncResult) msg.obj;
215 if (ar.exception == null) {
216 updateNeighboringCids((ArrayList<NeighboringCellInfo>)ar.result);
217 } else {
218 mNeighboringCids.setText("unknown");
219 }
220 break;
221 case EVENT_SET_QXDMLOG_DONE:
222 ar= (AsyncResult) msg.obj;
223 if (ar.exception == null) {
224 mQxdmLogEnabled = !mQxdmLogEnabled;
225
226 updateQxdmState(mQxdmLogEnabled);
227 displayQxdmEnableResult();
228 }
229 break;
230 case EVENT_SET_CIPHER_DONE:
231 ar= (AsyncResult) msg.obj;
232 if (ar.exception == null) {
233 setCiphPref(mCipherOn);
234 }
235 updateCiphState();
236 break;
237 case EVENT_QUERY_SMSC_DONE:
238 ar= (AsyncResult) msg.obj;
239 if (ar.exception != null) {
240 smsc.setText("refresh error");
241 } else {
242 byte[] buf = (byte[]) ar.result;
243 smsc.setText(new String(buf));
244 }
245 break;
246 case EVENT_UPDATE_SMSC_DONE:
247 updateSmscButton.setEnabled(true);
248 ar= (AsyncResult) msg.obj;
249 if (ar.exception != null) {
250 smsc.setText("update error");
251 }
252 break;
253 default:
254 break;
255
256 }
257 }
258 };
259
260 private class OemCommands {
261
262 public final int OEM_QXDM_SDLOG_DEFAULT_FILE_SIZE = 32;
263 public final int OEM_QXDM_SDLOG_DEFAULT_MASK = 0;
264 public final int OEM_QXDM_SDLOG_DEFAULT_MAX_INDEX = 8;
265
266 final int SIZE_OF_INT = 4;
267 final int OEM_FEATURE_ENABLE = 1;
268 final int OEM_FEATURE_DISABLE = 0;
269 final int OEM_SIMPE_FEAUTURE_LEN = 1;
270
271 final int OEM_QXDM_SDLOG_FUNCTAG = 0x00010000;
272 final int OEM_QXDM_SDLOG_LEN = 4;
273 final int OEM_PS_AUTO_ATTACH_FUNCTAG = 0x00020000;
274 final int OEM_CIPHERING_FUNCTAG = 0x00020001;
275 final int OEM_SMSC_UPDATE_FUNCTAG = 0x00020002;
276 final int OEM_SMSC_QUERY_FUNCTAG = 0x00020003;
277 final int OEM_SMSC_QUERY_LEN = 0;
278
279 /**
280 * The OEM interface to store QXDM to SD.
281 *
282 * To start/stop logging QXDM logs to SD card, use tag
283 * OEM_RIL_HOOK_QXDM_SD_LOG_SETUP 0x00010000
284 *
285 * "data" is a const oem_ril_hook_qxdm_sdlog_setup_data_st *
286 * ((const oem_ril_hook_qxdm_sdlog_setup_data_st *)data)->head.func_tag
287 * should be OEM_RIL_HOOK_QXDM_SD_LOG_SETUP
288 * ((const oem_ril_hook_qxdm_sdlog_setup_data_st *)data)->head.len
289 * should be "sizeof(unsigned int) * 4"
290 * ((const oem_ril_hook_qxdm_sdlog_setup_data_st *)data)->mode
291 * could be 0 for 'stop logging', or 1 for 'start logging'
292 * ((const oem_ril_hook_qxdm_sdlog_setup_data_st *)data)->log_file_size
293 * will assign the size of each log file, and it could be a value between
294 * 1 and 512 (in megabytes, default value is recommended to set as 32).
295 * This value will be ignored when mode == 0.
296 * ((const oem_ril_hook_qxdm_sdlog_setup_data_st *)data)->log_mask will
297 * assign the rule to filter logs, and it is a bitmask (bit0 is for MsgAll,
298 * bit1 is for LogAll, and bit2 is for EventAll) recommended to be set as 0
299 * by default. This value will be ignored when mode == 0.
300 * ((const oem_ril_hook_qxdm_sdlog_setup_data_st *)data)->log_max_fileindex
301 * set the how many logfiles will storted before roll over. This value will
302 * be ignored when mode == 0.
303 *
304 * "response" is NULL
305 *
306 * typedef struct _oem_ril_hook_raw_head_st {
307 * unsigned int func_tag;
308 * unsigned int len;
309 * } oem_ril_hook_raw_head_st;
310 *
311 * typedef struct _oem_ril_hook_qxdm_sdlog_setup_data_st {
312 * oem_ril_hook_raw_head_st head;
313 * unsigned int mode;
314 * unsigned int log_file_size;
315 * unsigned int log_mask;
316 * unsigned int log_max_fileindex;
317 * } oem_ril_hook_qxdm_sdlog_setup_data_st;
318 *
319 * @param enable set true to start logging QXDM in SD card
320 * @param fileSize is the log file size in MB
321 * @param mask is the log mask to filter
322 * @param maxIndex is the maximum roll-over file number
323 * @return byteArray to use in RIL RAW command
324 */
325 byte[] getQxdmSdlogData(boolean enable, int fileSize, int mask, int maxIndex) {
326 ByteArrayOutputStream bos = new ByteArrayOutputStream();
327 DataOutputStream dos = new DataOutputStream(bos);
328 try {
329 writeIntLittleEndian(dos, OEM_QXDM_SDLOG_FUNCTAG);
330 writeIntLittleEndian(dos, OEM_QXDM_SDLOG_LEN * SIZE_OF_INT);
331 writeIntLittleEndian(dos, enable ?
332 OEM_FEATURE_ENABLE : OEM_FEATURE_DISABLE);
333 writeIntLittleEndian(dos, fileSize);
334 writeIntLittleEndian(dos, mask);
335 writeIntLittleEndian(dos, maxIndex);
336 } catch (IOException e) {
337 return null;
338 }
339 return bos.toByteArray();
340 }
341
342 byte[] getSmscQueryData() {
343 ByteArrayOutputStream bos = new ByteArrayOutputStream();
344 DataOutputStream dos = new DataOutputStream(bos);
345 try {
346 writeIntLittleEndian(dos, OEM_SMSC_QUERY_FUNCTAG);
347 writeIntLittleEndian(dos, OEM_SMSC_QUERY_LEN * SIZE_OF_INT);
348 } catch (IOException e) {
349 return null;
350 }
351 return bos.toByteArray();
352 }
353
354 byte[] getSmscUpdateData(String smsc) {
355 ByteArrayOutputStream bos = new ByteArrayOutputStream();
356 DataOutputStream dos = new DataOutputStream(bos);
357 try {
358 byte[] smsc_bytes = smsc.getBytes();
359 writeIntLittleEndian(dos, OEM_SMSC_UPDATE_FUNCTAG);
360 writeIntLittleEndian(dos, smsc_bytes.length);
361 dos.write(smsc_bytes);
362 } catch (IOException e) {
363 return null;
364 }
365 return bos.toByteArray();
366 }
367
368 byte[] getPsAutoAttachData(boolean enable) {
369 return getSimpleFeatureData(OEM_PS_AUTO_ATTACH_FUNCTAG, enable);
370 }
371
372 byte[] getCipheringData(boolean enable) {
373 return getSimpleFeatureData(OEM_CIPHERING_FUNCTAG, enable);
374 }
375
376 private byte[] getSimpleFeatureData(int tag, boolean enable) {
377 ByteArrayOutputStream bos = new ByteArrayOutputStream();
378 DataOutputStream dos = new DataOutputStream(bos);
379 try {
380 writeIntLittleEndian(dos, tag);
381 writeIntLittleEndian(dos, OEM_SIMPE_FEAUTURE_LEN * SIZE_OF_INT);
382 writeIntLittleEndian(dos, enable ?
383 OEM_FEATURE_ENABLE : OEM_FEATURE_DISABLE);
384 } catch (IOException e) {
385 return null;
386 }
387 return bos.toByteArray();
388 }
389
390 private void writeIntLittleEndian(DataOutputStream dos, int val)
391 throws IOException {
392 dos.writeByte(val);
393 dos.writeByte(val >> 8);
394 dos.writeByte(val >> 16);
395 dos.writeByte(val >> 24);
396 }
397 }
398
399 @Override
400 public void onCreate(Bundle icicle) {
401 super.onCreate(icicle);
402
403 setContentView(R.layout.radio_info);
404
405 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
406 phone = PhoneFactory.getDefaultPhone();
407
Wink Savillef9e02412009-04-02 01:37:03 -0700408 mDeviceId= (TextView) findViewById(R.id.imei);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800409 number = (TextView) findViewById(R.id.number);
410 callState = (TextView) findViewById(R.id.call);
411 operatorName = (TextView) findViewById(R.id.operator);
412 roamingState = (TextView) findViewById(R.id.roaming);
413 gsmState = (TextView) findViewById(R.id.gsm);
414 gprsState = (TextView) findViewById(R.id.gprs);
415 network = (TextView) findViewById(R.id.network);
416 dBm = (TextView) findViewById(R.id.dbm);
417 mMwi = (TextView) findViewById(R.id.mwi);
418 mCfi = (TextView) findViewById(R.id.cfi);
419 mLocation = (TextView) findViewById(R.id.location);
420 mNeighboringCids = (TextView) findViewById(R.id.neighboring);
421
422 resets = (TextView) findViewById(R.id.resets);
423 attempts = (TextView) findViewById(R.id.attempts);
424 successes = (TextView) findViewById(R.id.successes);
425 disconnects = (TextView) findViewById(R.id.disconnects);
426 sentSinceReceived = (TextView) findViewById(R.id.sentSinceReceived);
427 sent = (TextView) findViewById(R.id.sent);
428 received = (TextView) findViewById(R.id.received);
429 cipherState = (TextView) findViewById(R.id.ciphState);
430 smsc = (EditText) findViewById(R.id.smsc);
431 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
432
433 mPingIpAddr = (TextView) findViewById(R.id.pingIpAddr);
434 mPingHostname = (TextView) findViewById(R.id.pingHostname);
435 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
436
437 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
438 ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
439 android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
440 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
441 preferredNetworkType.setAdapter(adapter);
442 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
443
444 radioPowerButton = (Button) findViewById(R.id.radio_power);
445 radioPowerButton.setOnClickListener(mPowerButtonHandler);
446
447 qxdmLogButton = (Button) findViewById(R.id.qxdm_log);
448 qxdmLogButton.setOnClickListener(mQxdmButtonHandler);
449
450 cipherToggleButton = (Button) findViewById(R.id.ciph_toggle);
451 cipherToggleButton.setOnClickListener(mCipherButtonHandler);
452 pingTestButton = (Button) findViewById(R.id.ping_test);
453 pingTestButton.setOnClickListener(mPingButtonHandler);
454 updateSmscButton = (Button) findViewById(R.id.update_smsc);
455 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
456 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
457 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
458 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
459 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
460
461 mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler);
462 mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED);
463 mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED);
464 mPhoneStateReceiver.notifyPhoneCallState(EVENT_PHONE_STATE_CHANGED);
465
466 updateQxdmState(null);
467 mOem = new OemCommands();
468
469 phone.getPreferredNetworkType(
470 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
471 phone.getNeighboringCids(
472 mHandler.obtainMessage(EVENT_QUERY_NEIGHBORING_CIDS_DONE));
473
474 netstat = INetStatService.Stub.asInterface(ServiceManager.getService("netstat"));
475
476 CellLocation.requestLocationUpdate();
477 }
478
479 @Override
480 protected void onResume() {
481 super.onResume();
482
483 updatePhoneState();
484 updateSignalStrength();
485 updateMessageWaiting();
486 updateCallRedirect();
487 updateServiceState();
488 updateLocation(mTelephonyManager.getCellLocation());
489 updateDataState();
490 updateDataStats();
491 updateDataStats2();
492 updatePowerState();
493 updateQxdmState(null);
494 updateProperties();
495 updateCiphState();
496 updateDnsCheckState();
497
498 Log.i(TAG, "[RadioInfo] onResume: register phone & data intents");
499
500 mPhoneStateReceiver.registerIntent();
501 mTelephonyManager.listen(mPhoneStateListener,
502 PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
503 | PhoneStateListener.LISTEN_DATA_ACTIVITY
504 | PhoneStateListener.LISTEN_CELL_LOCATION
505 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
506 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR);
507 }
508
509 @Override
510 public void onPause() {
511 super.onPause();
512
513 Log.i(TAG, "[RadioInfo] onPause: unregister phone & data intents");
514
515 mPhoneStateReceiver.unregisterIntent();
516 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
517 }
518
519 @Override
520 public boolean onCreateOptionsMenu(Menu menu) {
Wink Savillef9e02412009-04-02 01:37:03 -0700521 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
522 .setOnMenuItemClickListener(mSelectBandCallback)
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800523 .setAlphabeticShortcut('b');
524 menu.add(1, MENU_ITEM_VIEW_ADN, 0,
525 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
526 menu.add(1, MENU_ITEM_VIEW_FDN, 0,
527 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
528 menu.add(1, MENU_ITEM_VIEW_SDN, 0,
529 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
530 menu.add(1, MENU_ITEM_GET_PDP_LIST,
531 0, R.string.radioInfo_menu_getPDP).setOnMenuItemClickListener(mGetPdpList);
532 menu.add(1, MENU_ITEM_TOGGLE_DATA,
533 0, R.string.radioInfo_menu_disableData).setOnMenuItemClickListener(mToggleData);
534 menu.add(1, MENU_ITEM_TOGGLE_DATA_ON_BOOT,
Wink Savillef9e02412009-04-02 01:37:03 -0700535 0, R.string.radioInfo_menu_disableDataOnBoot).setOnMenuItemClickListener(
536 mToggleDataOnBoot);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800537 return true;
538 }
539
540
541 @Override
Wink Savillef9e02412009-04-02 01:37:03 -0700542 public boolean onPrepareOptionsMenu(Menu menu) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800543 // Get the TOGGLE DATA menu item in the right state.
544 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
545 int state = mTelephonyManager.getDataState();
546 boolean visible = true;
547
548 switch (state) {
549 case TelephonyManager.DATA_CONNECTED:
550 case TelephonyManager.DATA_SUSPENDED:
551 item.setTitle(R.string.radioInfo_menu_disableData);
552 break;
553 case TelephonyManager.DATA_DISCONNECTED:
554 item.setTitle(R.string.radioInfo_menu_enableData);
555 break;
556 default:
557 visible = false;
558 break;
559 }
560 item.setVisible(visible);
561
562 // Get the toggle-data-on-boot menu item in the right state.
563 item = menu.findItem(MENU_ITEM_TOGGLE_DATA_ON_BOOT);
The Android Open Source Project86997be2009-03-05 14:34:39 -0800564 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800565 boolean value = sp.getBoolean(GSMPhone.DATA_DISABLED_ON_BOOT_KEY, false);
566 if (value) {
567 item.setTitle(R.string.radioInfo_menu_enableDataOnBoot);
568 } else {
569 item.setTitle(R.string.radioInfo_menu_disableDataOnBoot);
570 }
571 return true;
572 }
573
574 private boolean isRadioOn() {
575 return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
576 }
577
578 private void updatePowerState() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800579 String buttonText = isRadioOn() ?
580 getString(R.string.turn_off_radio) :
581 getString(R.string.turn_on_radio);
Wink Savillef9e02412009-04-02 01:37:03 -0700582 radioPowerButton.setText(buttonText);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800583 }
584
585 private void updateQxdmState(Boolean newQxdmStatus) {
586 SharedPreferences sp =
The Android Open Source Project86997be2009-03-05 14:34:39 -0800587 PreferenceManager.getDefaultSharedPreferences(phone.getContext());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800588 mQxdmLogEnabled = sp.getBoolean("qxdmstatus", false);
589 // This is called from onCreate, onResume, and the handler when the status
590 // is updated.
591 if (newQxdmStatus != null) {
592 SharedPreferences.Editor editor = sp.edit();
593 editor.putBoolean("qxdmstatus", newQxdmStatus);
594 editor.commit();
595 mQxdmLogEnabled = newQxdmStatus;
596 }
597
598 String buttonText = mQxdmLogEnabled ?
599 getString(R.string.turn_off_qxdm) :
600 getString(R.string.turn_on_qxdm);
601 qxdmLogButton.setText(buttonText);
602 }
603
604 private void setCiphPref(boolean value) {
The Android Open Source Project86997be2009-03-05 14:34:39 -0800605 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800606 SharedPreferences.Editor editor = sp.edit();
607 editor.putBoolean(GSMPhone.CIPHERING_KEY, value);
608 editor.commit();
609 }
610
611 private boolean getCiphPref() {
The Android Open Source Project86997be2009-03-05 14:34:39 -0800612 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800613 boolean ret = sp.getBoolean(GSMPhone.CIPHERING_KEY, true);
614 return ret;
615 }
616
617 private void updateCiphState() {
618 cipherState.setText(getCiphPref() ? "Ciphering ON" : "Ciphering OFF");
619 }
620
621 private void updateDnsCheckState() {
Mike Lockwood550f0772009-04-05 11:35:30 -0700622 dnsCheckState.setText(phone.isDnsCheckDisabled() ?
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800623 "0.0.0.0 allowed" :"0.0.0.0 not allowed");
624 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700625
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800626 private final void
627 updateSignalStrength() {
Wink Savillee2a14e32009-05-29 14:06:30 -0700628 // TODO PhoneStateIntentReceiver is deprecated and PhoneStateListener
629 // should probably used instead.
630 int state = mPhoneStateReceiver.getServiceState().getState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800631 Resources r = getResources();
632
633 if ((ServiceState.STATE_OUT_OF_SERVICE == state) ||
634 (ServiceState.STATE_POWER_OFF == state)) {
635 dBm.setText("0");
636 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700637
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800638 int signalDbm = mPhoneStateReceiver.getSignalStrengthDbm();
Wink Savillee2a14e32009-05-29 14:06:30 -0700639
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800640 if (-1 == signalDbm) signalDbm = 0;
641
642 int signalAsu = mPhoneStateReceiver.getSignalStrength();
643
644 if (-1 == signalAsu) signalAsu = 0;
645
646 dBm.setText(String.valueOf(signalDbm) + " "
647 + r.getString(R.string.radioInfo_display_dbm) + " "
648 + String.valueOf(signalAsu) + " "
649 + r.getString(R.string.radioInfo_display_asu));
650 }
651
652 private final void updateLocation(CellLocation location) {
Wink Savillef9e02412009-04-02 01:37:03 -0700653 int lac = -1;
654 int cid = -1;
655 if (location instanceof GsmCellLocation) {
656 GsmCellLocation loc = (GsmCellLocation)location;
657 lac = loc.getLac();
658 cid = loc.getCid();
659 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800660
Wink Savillef9e02412009-04-02 01:37:03 -0700661 Resources r = getResources();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800662
663 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
664 + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
665 + " "
666 + r.getString(R.string.radioInfo_cid) + " = "
667 + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
668 }
669
670 private final void updateNeighboringCids(ArrayList<NeighboringCellInfo> cids) {
671 String neighborings = "";
672 if (cids != null) {
673 if ( cids.isEmpty() ) {
674 neighborings = "no neighboring cells";
675 } else {
676 for (NeighboringCellInfo cell : cids) {
677 neighborings += "{" + Integer.toHexString(cell.getCid())
678 + "@" + cell.getRssi() + "} ";
679 }
680 }
681 } else {
682 neighborings = "unknown";
683 }
684 mNeighboringCids.setText(neighborings);
685 }
686
687 private final void
688 updateMessageWaiting() {
689 mMwi.setText(String.valueOf(mMwiValue));
690 }
691
692 private final void
693 updateCallRedirect() {
694 mCfi.setText(String.valueOf(mCfiValue));
695 }
696
697
698 private final void
699 updateServiceState() {
700 ServiceState serviceState = mPhoneStateReceiver.getServiceState();
701 int state = serviceState.getState();
702 Resources r = getResources();
703 String display = r.getString(R.string.radioInfo_unknown);
704
705 switch (state) {
706 case ServiceState.STATE_IN_SERVICE:
707 display = r.getString(R.string.radioInfo_service_in);
708 break;
709 case ServiceState.STATE_OUT_OF_SERVICE:
710 case ServiceState.STATE_EMERGENCY_ONLY:
711 display = r.getString(R.string.radioInfo_service_emergency);
712 break;
713 case ServiceState.STATE_POWER_OFF:
714 display = r.getString(R.string.radioInfo_service_off);
715 break;
716 }
717
718 gsmState.setText(display);
719
720 if (serviceState.getRoaming()) {
721 roamingState.setText(R.string.radioInfo_roaming_in);
722 } else {
723 roamingState.setText(R.string.radioInfo_roaming_not);
724 }
725
726 operatorName.setText(serviceState.getOperatorAlphaLong());
727 }
728
729 private final void
730 updatePhoneState() {
731 Phone.State state = mPhoneStateReceiver.getPhoneState();
732 Resources r = getResources();
733 String display = r.getString(R.string.radioInfo_unknown);
734
735 switch (state) {
736 case IDLE:
737 display = r.getString(R.string.radioInfo_phone_idle);
738 break;
739 case RINGING:
740 display = r.getString(R.string.radioInfo_phone_ringing);
741 break;
742 case OFFHOOK:
743 display = r.getString(R.string.radioInfo_phone_offhook);
744 break;
745 }
746
747 callState.setText(display);
748 }
749
750 private final void
751 updateDataState() {
752 int state = mTelephonyManager.getDataState();
753 Resources r = getResources();
754 String display = r.getString(R.string.radioInfo_unknown);
755
756 switch (state) {
757 case TelephonyManager.DATA_CONNECTED:
758 display = r.getString(R.string.radioInfo_data_connected);
759 break;
760 case TelephonyManager.DATA_CONNECTING:
761 display = r.getString(R.string.radioInfo_data_connecting);
762 break;
763 case TelephonyManager.DATA_DISCONNECTED:
764 display = r.getString(R.string.radioInfo_data_disconnected);
765 break;
766 case TelephonyManager.DATA_SUSPENDED:
767 display = r.getString(R.string.radioInfo_data_suspended);
768 break;
769 }
770
771 gprsState.setText(display);
772 }
773
774 private final void updateNetworkType() {
775 Resources r = getResources();
776 String display = SystemProperties.get(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
777 r.getString(R.string.radioInfo_unknown));
778
779 network.setText(display);
780 }
781
782 private final void
783 updateProperties() {
784 String s;
785 Resources r = getResources();
786
787 s = phone.getDeviceId();
788 if (s == null) s = r.getString(R.string.radioInfo_unknown);
Wink Savillef9e02412009-04-02 01:37:03 -0700789 mDeviceId.setText(s);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800790
Wink Savillef9e02412009-04-02 01:37:03 -0700791
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800792 s = phone.getLine1Number();
793 if (s == null) s = r.getString(R.string.radioInfo_unknown);
794 number.setText(s);
795 }
796
797 private final void updateDataStats() {
798 String s;
799
800 s = SystemProperties.get("net.gsm.radio-reset", "0");
801 resets.setText(s);
802
803 s = SystemProperties.get("net.gsm.attempt-gprs", "0");
804 attempts.setText(s);
805
806 s = SystemProperties.get("net.gsm.succeed-gprs", "0");
807 successes.setText(s);
808
809 //s = SystemProperties.get("net.gsm.disconnect", "0");
810 //disconnects.setText(s);
811
812 s = SystemProperties.get("net.ppp.reset-by-timeout", "0");
813 sentSinceReceived.setText(s);
814 }
815
816 private final void updateDataStats2() {
817 Resources r = getResources();
818
819 try {
820 long txPackets = netstat.getMobileTxPackets();
821 long rxPackets = netstat.getMobileRxPackets();
822 long txBytes = netstat.getMobileTxBytes();
823 long rxBytes = netstat.getMobileRxBytes();
824
825 String packets = r.getString(R.string.radioInfo_display_packets);
826 String bytes = r.getString(R.string.radioInfo_display_bytes);
827
828 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
829 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
830 } catch (RemoteException e) {
831 }
832 }
833
834 /**
835 * Ping a IP address.
836 */
837 private final void pingIpAddr() {
838 try {
839 // This is hardcoded IP addr. This is for testing purposes.
840 // We would need to get rid of this before release.
841 String ipAddress = "74.125.47.104";
842 Process p = Runtime.getRuntime().exec("ping -c 1 " + ipAddress);
843 int status = p.waitFor();
844 if (status == 0) {
845 mPingIpAddrResult = "Pass";
846 } else {
847 mPingIpAddrResult = "Fail: IP addr not reachable";
848 }
849 } catch (IOException e) {
850 mPingIpAddrResult = "Fail: IOException";
851 } catch (InterruptedException e) {
852 mPingIpAddrResult = "Fail: InterruptedException";
853 }
854 }
855
856 /**
857 * Ping a host name
858 */
859 private final void pingHostname() {
860 try {
861 Process p = Runtime.getRuntime().exec("ping -c 1 www.google.com");
862 int status = p.waitFor();
863 if (status == 0) {
864 mPingHostnameResult = "Pass";
865 } else {
866 mPingHostnameResult = "Fail: Host unreachable";
867 }
868 } catch (UnknownHostException e) {
869 mPingHostnameResult = "Fail: Unknown Host";
870 } catch (IOException e) {
871 mPingHostnameResult= "Fail: IOException";
872 } catch (InterruptedException e) {
873 mPingHostnameResult = "Fail: InterruptedException";
874 }
875 }
876
877 /**
878 * This function checks for basic functionality of HTTP Client.
879 */
880 private void httpClientTest() {
881 HttpClient client = new DefaultHttpClient();
882 try {
883 HttpGet request = new HttpGet("http://www.google.com");
884 HttpResponse response = client.execute(request);
885 if (response.getStatusLine().getStatusCode() == 200) {
886 mHttpClientTestResult = "Pass";
887 } else {
888 mHttpClientTestResult = "Fail: Code: " + String.valueOf(response);
889 }
890 request.abort();
891 } catch (IOException e) {
892 mHttpClientTestResult = "Fail: IOException";
893 }
894 }
895
896 private void refreshSmsc() {
897 byte[] data = mOem.getSmscQueryData();
898 if (data == null) return;
899 phone.invokeOemRilRequestRaw(data,
900 mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
901 }
902
903 private final void updatePingState() {
904 final Handler handler = new Handler();
905 // Set all to unknown since the threads will take a few secs to update.
906 mPingIpAddrResult = getResources().getString(R.string.radioInfo_unknown);
907 mPingHostnameResult = getResources().getString(R.string.radioInfo_unknown);
908 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
909
910 mPingIpAddr.setText(mPingIpAddrResult);
911 mPingHostname.setText(mPingHostnameResult);
912 mHttpClientTest.setText(mHttpClientTestResult);
913
914 final Runnable updatePingResults = new Runnable() {
915 public void run() {
916 mPingIpAddr.setText(mPingIpAddrResult);
917 mPingHostname.setText(mPingHostnameResult);
918 mHttpClientTest.setText(mHttpClientTestResult);
919 }
920 };
921 Thread ipAddr = new Thread() {
922 @Override
923 public void run() {
924 pingIpAddr();
925 handler.post(updatePingResults);
926 }
927 };
928 ipAddr.start();
929
930 Thread hostname = new Thread() {
931 @Override
932 public void run() {
933 pingHostname();
934 handler.post(updatePingResults);
935 }
936 };
937 hostname.start();
938
939 Thread httpClient = new Thread() {
940 @Override
941 public void run() {
942 httpClientTest();
943 handler.post(updatePingResults);
944 }
945 };
946 httpClient.start();
947 }
948
949 private final void updatePdpList() {
950 StringBuilder sb = new StringBuilder("========DATA=======\n");
951
952 List<PdpConnection> pdps = phone.getCurrentPdpList();
953
954 for (PdpConnection pdp : pdps) {
955 sb.append(" State: ").append(pdp.getState().toString()).append("\n");
956 if (pdp.getState().isActive()) {
957 long timeElapsed =
958 (System.currentTimeMillis() - pdp.getConnectionTime())/1000;
959 sb.append(" connected at ")
960 .append(DateUtils.timeString(pdp.getConnectionTime()))
961 .append(" and elapsed ")
962 .append(DateUtils.formatElapsedTime(timeElapsed))
963 .append("\n to ")
964 .append(pdp.getApn().toString())
965 .append("\ninterface: ")
966 .append(phone.getInterfaceName(phone.getActiveApnTypes()[0]))
967 .append("\naddress: ")
968 .append(phone.getIpAddress(phone.getActiveApnTypes()[0]))
969 .append("\ngateway: ")
970 .append(phone.getGateway(phone.getActiveApnTypes()[0]));
971 String[] dns = phone.getDnsServers(phone.getActiveApnTypes()[0]);
972 if (dns != null) {
973 sb.append("\ndns: ").append(dns[0]).append(", ").append(dns[1]);
974 }
975 } else if (pdp.getState().isInactive()) {
976 sb.append(" disconnected with last try at ")
977 .append(DateUtils.timeString(pdp.getLastFailTime()))
978 .append("\n fail because ")
979 .append(pdp.getLastFailCause().toString());
980 } else {
981 sb.append(" is connecting to ")
982 .append(pdp.getApn().toString());
983 }
984 sb.append("\n===================");
985 }
986
987
988 disconnects.setText(sb.toString());
989 }
990
991 private void displayQxdmEnableResult() {
992 String status = mQxdmLogEnabled ? "Start QXDM Log" : "Stop QXDM Log";
993
994 DialogInterface mProgressPanel = new AlertDialog.
995 Builder(this).setMessage(status).show();
996
997 mHandler.postDelayed(
998 new Runnable() {
999 public void run() {
1000 finish();
1001 }
1002 }, 2000);
1003 }
1004
1005 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
1006 public boolean onMenuItemClick(MenuItem item) {
1007 Intent intent = new Intent(Intent.ACTION_VIEW);
1008 // XXX We need to specify the component here because if we don't
1009 // the activity manager will try to resolve the type by calling
1010 // the content provider, which causes it to be loaded in a process
1011 // other than the Dialer process, which causes a lot of stuff to
1012 // break.
1013 intent.setClassName("com.android.phone",
1014 "com.android.phone.SimContacts");
1015 startActivity(intent);
1016 return true;
1017 }
1018 };
1019
1020 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
1021 public boolean onMenuItemClick(MenuItem item) {
1022 Intent intent = new Intent(Intent.ACTION_VIEW);
1023 // XXX We need to specify the component here because if we don't
1024 // the activity manager will try to resolve the type by calling
1025 // the content provider, which causes it to be loaded in a process
1026 // other than the Dialer process, which causes a lot of stuff to
1027 // break.
1028 intent.setClassName("com.android.phone",
1029 "com.android.phone.FdnList");
1030 startActivity(intent);
1031 return true;
1032 }
1033 };
1034
1035 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
1036 public boolean onMenuItemClick(MenuItem item) {
1037 Intent intent = new Intent(
Wink Savillef9e02412009-04-02 01:37:03 -07001038 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001039 // XXX We need to specify the component here because if we don't
1040 // the activity manager will try to resolve the type by calling
1041 // the content provider, which causes it to be loaded in a process
1042 // other than the Dialer process, which causes a lot of stuff to
1043 // break.
1044 intent.setClassName("com.android.phone",
1045 "com.android.phone.ADNList");
1046 startActivity(intent);
1047 return true;
1048 }
1049 };
1050
1051 private void toggleDataDisabledOnBoot() {
The Android Open Source Project86997be2009-03-05 14:34:39 -08001052 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(phone.getContext());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001053 SharedPreferences.Editor editor = sp.edit();
1054 boolean value = sp.getBoolean(GSMPhone.DATA_DISABLED_ON_BOOT_KEY, false);
1055 editor.putBoolean(GSMPhone.DATA_DISABLED_ON_BOOT_KEY, !value);
1056 byte[] data = mOem.getPsAutoAttachData(value);
1057 if (data == null) {
1058 // don't commit
1059 return;
1060 }
1061
1062 editor.commit();
1063 phone.invokeOemRilRequestRaw(data, null);
1064 }
1065
1066 private MenuItem.OnMenuItemClickListener mToggleDataOnBoot = new MenuItem.OnMenuItemClickListener() {
1067 public boolean onMenuItemClick(MenuItem item) {
1068 toggleDataDisabledOnBoot();
1069 return true;
1070 }
1071 };
1072
1073 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
1074 public boolean onMenuItemClick(MenuItem item) {
1075 int state = mTelephonyManager.getDataState();
1076 switch (state) {
1077 case TelephonyManager.DATA_CONNECTED:
1078 phone.disableDataConnectivity();
1079 break;
1080 case TelephonyManager.DATA_DISCONNECTED:
1081 phone.enableDataConnectivity();
1082 break;
1083 default:
1084 // do nothing
1085 break;
1086 }
1087 return true;
1088 }
1089 };
1090
1091 private MenuItem.OnMenuItemClickListener mGetPdpList = new MenuItem.OnMenuItemClickListener() {
1092 public boolean onMenuItemClick(MenuItem item) {
Wink Savillef9e02412009-04-02 01:37:03 -07001093 phone.getDataCallList(null);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001094 return true;
1095 }
1096 };
1097
1098 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
1099 public boolean onMenuItemClick(MenuItem item) {
1100 Intent intent = new Intent();
1101 intent.setClass(RadioInfo.this, BandMode.class);
1102 startActivity(intent);
1103 return true;
1104 }
1105 };
1106
1107 OnClickListener mPowerButtonHandler = new OnClickListener() {
1108 public void onClick(View v) {
1109 //log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
1110 phone.setRadioPower(!isRadioOn());
1111 }
1112 };
1113
1114 OnClickListener mCipherButtonHandler = new OnClickListener() {
1115 public void onClick(View v) {
1116 mCipherOn = !getCiphPref();
1117 byte[] data = mOem.getCipheringData(mCipherOn);
1118
1119 if (data == null)
1120 return;
1121
1122 cipherState.setText("Setting...");
1123 phone.invokeOemRilRequestRaw(data,
1124 mHandler.obtainMessage(EVENT_SET_CIPHER_DONE));
1125 }
1126 };
1127
1128 OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
1129 public void onClick(View v) {
Wink Savillef9e02412009-04-02 01:37:03 -07001130 phone.disableDnsCheck(!phone.isDnsCheckDisabled());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001131 updateDnsCheckState();
1132 }
1133 };
1134
1135 OnClickListener mPingButtonHandler = new OnClickListener() {
1136 public void onClick(View v) {
1137 updatePingState();
1138 }
1139 };
1140
1141 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
1142 public void onClick(View v) {
1143 updateSmscButton.setEnabled(false);
1144 byte[] data = mOem.getSmscUpdateData(smsc.getText().toString());
1145 if (data == null) return;
1146 phone.invokeOemRilRequestRaw(data,
1147 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
1148 }
1149 };
1150
1151 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
1152 public void onClick(View v) {
1153 refreshSmsc();
1154 }
1155 };
1156
1157 OnClickListener mQxdmButtonHandler = new OnClickListener() {
1158 public void onClick(View v) {
1159 byte[] data = mOem.getQxdmSdlogData(
1160 !mQxdmLogEnabled,
1161 mOem.OEM_QXDM_SDLOG_DEFAULT_FILE_SIZE,
1162 mOem.OEM_QXDM_SDLOG_DEFAULT_MASK,
1163 mOem.OEM_QXDM_SDLOG_DEFAULT_MAX_INDEX);
1164
1165 if (data == null)
1166 return;
1167
1168 phone.invokeOemRilRequestRaw(data,
1169 mHandler.obtainMessage(EVENT_SET_QXDMLOG_DONE));
1170 }
1171 };
1172
1173 AdapterView.OnItemSelectedListener
1174 mPreferredNetworkHandler = new AdapterView.OnItemSelectedListener() {
1175 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1176 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
Wink Savilleead69282009-05-13 11:51:03 -07001177 if (pos>=0 && pos<=7) { //IS THIS NEEDED to extend to the entire range of values
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001178 phone.setPreferredNetworkType(pos, msg);
1179 }
1180 }
1181
1182 public void onNothingSelected(AdapterView parent) {
1183 }
1184 };
1185
1186 private String[] mPreferredNetworkLabels = {
1187 "WCDMA preferred", "GSM only", "WCDMA only", "Unknown"};
1188}