blob: cec00d0dfbc6cc75f6b81fad43b7a55f690dd91c [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;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080020import android.content.Intent;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +080021import android.content.pm.PackageManager;
22import android.content.pm.ResolveInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080023import android.content.res.Resources;
Jeff Sharkey93029862011-05-27 18:26:15 -070024import android.net.TrafficStats;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080025import android.net.Uri;
26import android.os.AsyncResult;
27import android.os.Bundle;
28import android.os.Handler;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080029import android.os.Message;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080030import android.os.SystemProperties;
Wink Saville79bff2a2012-06-01 14:37:21 -070031import android.telephony.CellInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080032import android.telephony.CellLocation;
Wink Saville4f0d8812014-04-15 22:05:24 -070033import android.telephony.DataConnectionRealTimeInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080034import android.telephony.PhoneStateListener;
35import android.telephony.ServiceState;
36import android.telephony.TelephonyManager;
37import android.telephony.NeighboringCellInfo;
jsh534f5ae2009-09-24 09:19:22 -070038import android.telephony.cdma.CdmaCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080039import android.telephony.gsm.GsmCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080040import android.util.Log;
41import android.view.Menu;
42import android.view.MenuItem;
43import android.view.View;
44import android.view.View.OnClickListener;
45import android.widget.AdapterView;
46import android.widget.ArrayAdapter;
47import android.widget.Button;
48import android.widget.Spinner;
49import android.widget.TextView;
50import android.widget.EditText;
51
52import com.android.internal.telephony.Phone;
Wink Saville55434042012-06-14 12:33:43 -070053import com.android.internal.telephony.PhoneConstants;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080054import com.android.internal.telephony.PhoneFactory;
55import com.android.internal.telephony.PhoneStateIntentReceiver;
56import com.android.internal.telephony.TelephonyProperties;
Narayan Kamathf25627c2014-12-12 13:53:28 +000057import java.net.HttpURLConnection;
58import java.net.URL;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080059
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080060import java.io.IOException;
61import java.net.UnknownHostException;
62import java.util.ArrayList;
63import java.util.List;
64
65public class RadioInfo extends Activity {
66 private final String TAG = "phone";
johnwang342101a2009-09-23 16:22:34 -070067
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080068 private static final int EVENT_PHONE_STATE_CHANGED = 100;
69 private static final int EVENT_SIGNAL_STRENGTH_CHANGED = 200;
70 private static final int EVENT_SERVICE_STATE_CHANGED = 300;
71 private static final int EVENT_CFI_CHANGED = 302;
72
73 private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000;
74 private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001;
75 private static final int EVENT_QUERY_NEIGHBORING_CIDS_DONE = 1002;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080076 private static final int EVENT_QUERY_SMSC_DONE = 1005;
77 private static final int EVENT_UPDATE_SMSC_DONE = 1006;
78
79 private static final int MENU_ITEM_SELECT_BAND = 0;
80 private static final int MENU_ITEM_VIEW_ADN = 1;
81 private static final int MENU_ITEM_VIEW_FDN = 2;
82 private static final int MENU_ITEM_VIEW_SDN = 3;
83 private static final int MENU_ITEM_GET_PDP_LIST = 4;
84 private static final int MENU_ITEM_TOGGLE_DATA = 5;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +080085
86 static final String ENABLE_DATA_STR = "Enable data connection";
87 static final String DISABLE_DATA_STR = "Disable data connection";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080088
Wink Savillec3886682009-04-02 11:00:56 -070089 private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080090 private TextView number;
91 private TextView callState;
92 private TextView operatorName;
93 private TextView roamingState;
94 private TextView gsmState;
95 private TextView gprsState;
96 private TextView network;
97 private TextView dBm;
98 private TextView mMwi;
99 private TextView mCfi;
100 private TextView mLocation;
101 private TextView mNeighboringCids;
Wink Saville79bff2a2012-06-01 14:37:21 -0700102 private TextView mCellInfo;
Wink Saville4f0d8812014-04-15 22:05:24 -0700103 private TextView mDcRtInfoTv;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800104 private TextView resets;
105 private TextView attempts;
106 private TextView successes;
107 private TextView disconnects;
108 private TextView sentSinceReceived;
109 private TextView sent;
110 private TextView received;
111 private TextView mPingIpAddr;
112 private TextView mPingHostname;
113 private TextView mHttpClientTest;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800114 private TextView dnsCheckState;
115 private EditText smsc;
116 private Button radioPowerButton;
Wink Savillebf471282013-04-05 15:04:05 -0700117 private Button cellInfoListRateButton;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800118 private Button dnsCheckToggleButton;
119 private Button pingTestButton;
120 private Button updateSmscButton;
121 private Button refreshSmscButton;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800122 private Button oemInfoButton;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800123 private Spinner preferredNetworkType;
124
125 private TelephonyManager mTelephonyManager;
126 private Phone phone = null;
127 private PhoneStateIntentReceiver mPhoneStateReceiver;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800128
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800129 private String mPingIpAddrResult;
130 private String mPingHostnameResult;
131 private String mHttpClientTestResult;
132 private boolean mMwiValue = false;
133 private boolean mCfiValue = false;
Wink Saville79bff2a2012-06-01 14:37:21 -0700134 private List<CellInfo> mCellInfoValue;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800135
136 private PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
137 @Override
138 public void onDataConnectionStateChanged(int state) {
139 updateDataState();
140 updateDataStats();
141 updatePdpList();
142 updateNetworkType();
143 }
144
145 @Override
146 public void onDataActivity(int direction) {
147 updateDataStats2();
148 }
149
150 @Override
151 public void onCellLocationChanged(CellLocation location) {
152 updateLocation(location);
153 }
154
155 @Override
156 public void onMessageWaitingIndicatorChanged(boolean mwi) {
157 mMwiValue = mwi;
158 updateMessageWaiting();
159 }
160
161 @Override
162 public void onCallForwardingIndicatorChanged(boolean cfi) {
163 mCfiValue = cfi;
164 updateCallRedirect();
165 }
Wink Saville79bff2a2012-06-01 14:37:21 -0700166
167 @Override
168 public void onCellInfoChanged(List<CellInfo> arrayCi) {
Wink Savillebf471282013-04-05 15:04:05 -0700169 log("onCellInfoChanged: arrayCi=" + arrayCi);
170 updateCellInfoTv(arrayCi);
Wink Saville79bff2a2012-06-01 14:37:21 -0700171 }
Wink Saville4f0d8812014-04-15 22:05:24 -0700172
173 @Override
174 public void onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo) {
175 log("onDataConnectionRealTimeInfoChanged: dcRtInfo=" + dcRtInfo);
176 updateDcRtInfoTv(dcRtInfo);
177 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800178 };
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];
Ricardo Cerqueira32310ee2012-04-12 23:34:38 +0100201 if (type >= mPreferredNetworkLabels.length) {
Wink Savillebf471282013-04-05 15:04:05 -0700202 log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
Ricardo Cerqueira32310ee2012-04-12 23:34:38 +0100203 "type=" + type);
204 type = mPreferredNetworkLabels.length - 1;
205 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800206 preferredNetworkType.setSelection(type, true);
207 } else {
Ricardo Cerqueira32310ee2012-04-12 23:34:38 +0100208 preferredNetworkType.setSelection(mPreferredNetworkLabels.length - 1, true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800209 }
210 break;
211 case EVENT_SET_PREFERRED_TYPE_DONE:
212 ar= (AsyncResult) msg.obj;
213 if (ar.exception != null) {
214 phone.getPreferredNetworkType(
215 obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
216 }
217 break;
218 case EVENT_QUERY_NEIGHBORING_CIDS_DONE:
219 ar= (AsyncResult) msg.obj;
220 if (ar.exception == null) {
221 updateNeighboringCids((ArrayList<NeighboringCellInfo>)ar.result);
222 } else {
223 mNeighboringCids.setText("unknown");
224 }
225 break;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800226 case EVENT_QUERY_SMSC_DONE:
227 ar= (AsyncResult) msg.obj;
228 if (ar.exception != null) {
229 smsc.setText("refresh error");
230 } else {
jsh21dd4072009-05-12 11:26:55 -0700231 smsc.setText((String)ar.result);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800232 }
233 break;
234 case EVENT_UPDATE_SMSC_DONE:
235 updateSmscButton.setEnabled(true);
236 ar= (AsyncResult) msg.obj;
237 if (ar.exception != null) {
238 smsc.setText("update error");
239 }
240 break;
241 default:
242 break;
243
244 }
245 }
246 };
247
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800248 @Override
249 public void onCreate(Bundle icicle) {
250 super.onCreate(icicle);
251
252 setContentView(R.layout.radio_info);
253
254 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
255 phone = PhoneFactory.getDefaultPhone();
256
Wink Savillec3886682009-04-02 11:00:56 -0700257 mDeviceId= (TextView) findViewById(R.id.imei);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800258 number = (TextView) findViewById(R.id.number);
259 callState = (TextView) findViewById(R.id.call);
260 operatorName = (TextView) findViewById(R.id.operator);
261 roamingState = (TextView) findViewById(R.id.roaming);
262 gsmState = (TextView) findViewById(R.id.gsm);
263 gprsState = (TextView) findViewById(R.id.gprs);
264 network = (TextView) findViewById(R.id.network);
265 dBm = (TextView) findViewById(R.id.dbm);
266 mMwi = (TextView) findViewById(R.id.mwi);
267 mCfi = (TextView) findViewById(R.id.cfi);
268 mLocation = (TextView) findViewById(R.id.location);
269 mNeighboringCids = (TextView) findViewById(R.id.neighboring);
Wink Saville79bff2a2012-06-01 14:37:21 -0700270 mCellInfo = (TextView) findViewById(R.id.cellinfo);
Wink Saville4f0d8812014-04-15 22:05:24 -0700271 mDcRtInfoTv = (TextView) findViewById(R.id.dcrtinfo);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800272
273 resets = (TextView) findViewById(R.id.resets);
274 attempts = (TextView) findViewById(R.id.attempts);
275 successes = (TextView) findViewById(R.id.successes);
276 disconnects = (TextView) findViewById(R.id.disconnects);
277 sentSinceReceived = (TextView) findViewById(R.id.sentSinceReceived);
278 sent = (TextView) findViewById(R.id.sent);
279 received = (TextView) findViewById(R.id.received);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800280 smsc = (EditText) findViewById(R.id.smsc);
281 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
282
283 mPingIpAddr = (TextView) findViewById(R.id.pingIpAddr);
284 mPingHostname = (TextView) findViewById(R.id.pingHostname);
285 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
286
287 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
288 ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
289 android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
johnwang342101a2009-09-23 16:22:34 -0700290 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800291 preferredNetworkType.setAdapter(adapter);
292 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
293
294 radioPowerButton = (Button) findViewById(R.id.radio_power);
295 radioPowerButton.setOnClickListener(mPowerButtonHandler);
296
Wink Savillebf471282013-04-05 15:04:05 -0700297 cellInfoListRateButton = (Button) findViewById(R.id.cell_info_list_rate);
298 cellInfoListRateButton.setOnClickListener(mCellInfoListRateHandler);
299
Wink Saville1e596f32011-09-19 14:24:39 -0700300 imsRegRequiredButton = (Button) findViewById(R.id.ims_reg_required);
301 imsRegRequiredButton.setOnClickListener(mImsRegRequiredHandler);
302
Wink Saville382a75b2011-09-22 15:17:00 -0700303 smsOverImsButton = (Button) findViewById(R.id.sms_over_ims);
304 smsOverImsButton.setOnClickListener(mSmsOverImsHandler);
305
Wink Saville426fc662011-09-25 14:39:02 -0700306 lteRamDumpButton = (Button) findViewById(R.id.lte_ram_dump);
307 lteRamDumpButton.setOnClickListener(mLteRamDumpHandler);
308
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800309 pingTestButton = (Button) findViewById(R.id.ping_test);
310 pingTestButton.setOnClickListener(mPingButtonHandler);
311 updateSmscButton = (Button) findViewById(R.id.update_smsc);
312 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
313 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
314 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
315 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
316 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
johnwang342101a2009-09-23 16:22:34 -0700317
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800318 oemInfoButton = (Button) findViewById(R.id.oem_info);
319 oemInfoButton.setOnClickListener(mOemInfoButtonHandler);
320 PackageManager pm = getPackageManager();
321 Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO");
322 List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0);
323 if (oemInfoIntentList.size() == 0) {
324 oemInfoButton.setEnabled(false);
325 }
326
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800327 mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler);
328 mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED);
329 mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED);
330 mPhoneStateReceiver.notifyPhoneCallState(EVENT_PHONE_STATE_CHANGED);
johnwang342101a2009-09-23 16:22:34 -0700331
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800332 phone.getPreferredNetworkType(
333 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
334 phone.getNeighboringCids(
335 mHandler.obtainMessage(EVENT_QUERY_NEIGHBORING_CIDS_DONE));
336
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800337 CellLocation.requestLocationUpdate();
Wink Saville79bff2a2012-06-01 14:37:21 -0700338
339 // Get current cell info
340 mCellInfoValue = mTelephonyManager.getAllCellInfo();
Wink Savillebf471282013-04-05 15:04:05 -0700341 log("onCreate: mCellInfoValue=" + mCellInfoValue);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800342 }
343
344 @Override
345 protected void onResume() {
346 super.onResume();
347
348 updatePhoneState();
349 updateSignalStrength();
350 updateMessageWaiting();
351 updateCallRedirect();
352 updateServiceState();
353 updateLocation(mTelephonyManager.getCellLocation());
354 updateDataState();
355 updateDataStats();
356 updateDataStats2();
357 updatePowerState();
Wink Savillebf471282013-04-05 15:04:05 -0700358 updateCellInfoListRate();
Wink Saville1e596f32011-09-19 14:24:39 -0700359 updateImsRegRequiredState();
Wink Saville382a75b2011-09-22 15:17:00 -0700360 updateSmsOverImsState();
Wink Saville426fc662011-09-25 14:39:02 -0700361 updateLteRamDumpState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800362 updateProperties();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800363 updateDnsCheckState();
364
Wink Savillebf471282013-04-05 15:04:05 -0700365 log("onResume: register phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800366
367 mPhoneStateReceiver.registerIntent();
368 mTelephonyManager.listen(mPhoneStateListener,
369 PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
370 | PhoneStateListener.LISTEN_DATA_ACTIVITY
371 | PhoneStateListener.LISTEN_CELL_LOCATION
372 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
Wink Saville79bff2a2012-06-01 14:37:21 -0700373 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
Wink Saville4f0d8812014-04-15 22:05:24 -0700374 | PhoneStateListener.LISTEN_CELL_INFO
375 | PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800376 }
377
378 @Override
379 public void onPause() {
380 super.onPause();
381
Wink Savillebf471282013-04-05 15:04:05 -0700382 log("onPause: unregister phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800383
384 mPhoneStateReceiver.unregisterIntent();
385 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
386 }
387
388 @Override
389 public boolean onCreateOptionsMenu(Menu menu) {
Wink Savillec3886682009-04-02 11:00:56 -0700390 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
391 .setOnMenuItemClickListener(mSelectBandCallback)
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800392 .setAlphabeticShortcut('b');
393 menu.add(1, MENU_ITEM_VIEW_ADN, 0,
394 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
395 menu.add(1, MENU_ITEM_VIEW_FDN, 0,
396 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
397 menu.add(1, MENU_ITEM_VIEW_SDN, 0,
398 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
399 menu.add(1, MENU_ITEM_GET_PDP_LIST,
400 0, R.string.radioInfo_menu_getPDP).setOnMenuItemClickListener(mGetPdpList);
401 menu.add(1, MENU_ITEM_TOGGLE_DATA,
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800402 0, DISABLE_DATA_STR).setOnMenuItemClickListener(mToggleData);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800403 return true;
404 }
405
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800406 @Override
Wink Savillec3886682009-04-02 11:00:56 -0700407 public boolean onPrepareOptionsMenu(Menu menu) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800408 // Get the TOGGLE DATA menu item in the right state.
409 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
410 int state = mTelephonyManager.getDataState();
411 boolean visible = true;
412
413 switch (state) {
414 case TelephonyManager.DATA_CONNECTED:
415 case TelephonyManager.DATA_SUSPENDED:
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800416 item.setTitle(DISABLE_DATA_STR);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800417 break;
418 case TelephonyManager.DATA_DISCONNECTED:
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800419 item.setTitle(ENABLE_DATA_STR);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800420 break;
421 default:
422 visible = false;
423 break;
424 }
425 item.setVisible(visible);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800426 return true;
427 }
428
429 private boolean isRadioOn() {
430 return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
431 }
johnwang342101a2009-09-23 16:22:34 -0700432
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800433 private void updatePowerState() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800434 String buttonText = isRadioOn() ?
435 getString(R.string.turn_off_radio) :
436 getString(R.string.turn_on_radio);
Wink Savillec3886682009-04-02 11:00:56 -0700437 radioPowerButton.setText(buttonText);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800438 }
439
Wink Savillebf471282013-04-05 15:04:05 -0700440 private void updateCellInfoListRate() {
441 cellInfoListRateButton.setText("CellInfoListRate " + mCellInfoListRateHandler.getRate());
442 updateCellInfoTv(mTelephonyManager.getAllCellInfo());
443 }
444
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800445 private void updateDnsCheckState() {
Mike Lockwood5304c7e2009-04-05 11:37:45 -0700446 dnsCheckState.setText(phone.isDnsCheckDisabled() ?
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800447 "0.0.0.0 allowed" :"0.0.0.0 not allowed");
448 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700449
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800450 private final void
451 updateSignalStrength() {
Wink Savillee2a14e32009-05-29 14:06:30 -0700452 // TODO PhoneStateIntentReceiver is deprecated and PhoneStateListener
453 // should probably used instead.
454 int state = mPhoneStateReceiver.getServiceState().getState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800455 Resources r = getResources();
456
457 if ((ServiceState.STATE_OUT_OF_SERVICE == state) ||
458 (ServiceState.STATE_POWER_OFF == state)) {
459 dBm.setText("0");
460 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700461
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800462 int signalDbm = mPhoneStateReceiver.getSignalStrengthDbm();
Wink Savillee2a14e32009-05-29 14:06:30 -0700463
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800464 if (-1 == signalDbm) signalDbm = 0;
465
Wink Saville882c74a2011-02-17 12:00:03 -0800466 int signalAsu = mPhoneStateReceiver.getSignalStrengthLevelAsu();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800467
468 if (-1 == signalAsu) signalAsu = 0;
469
470 dBm.setText(String.valueOf(signalDbm) + " "
471 + r.getString(R.string.radioInfo_display_dbm) + " "
472 + String.valueOf(signalAsu) + " "
473 + r.getString(R.string.radioInfo_display_asu));
474 }
475
476 private final void updateLocation(CellLocation location) {
jsh534f5ae2009-09-24 09:19:22 -0700477 Resources r = getResources();
Wink Savillec3886682009-04-02 11:00:56 -0700478 if (location instanceof GsmCellLocation) {
479 GsmCellLocation loc = (GsmCellLocation)location;
jsh534f5ae2009-09-24 09:19:22 -0700480 int lac = loc.getLac();
481 int cid = loc.getCid();
482 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
483 + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
484 + " "
485 + r.getString(R.string.radioInfo_cid) + " = "
486 + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
487 } else if (location instanceof CdmaCellLocation) {
488 CdmaCellLocation loc = (CdmaCellLocation)location;
489 int bid = loc.getBaseStationId();
490 int sid = loc.getSystemId();
491 int nid = loc.getNetworkId();
492 int lat = loc.getBaseStationLatitude();
493 int lon = loc.getBaseStationLongitude();
494 mLocation.setText("BID = "
495 + ((bid == -1) ? "unknown" : Integer.toHexString(bid))
496 + " "
497 + "SID = "
498 + ((sid == -1) ? "unknown" : Integer.toHexString(sid))
499 + " "
500 + "NID = "
501 + ((nid == -1) ? "unknown" : Integer.toHexString(nid))
502 + "\n"
503 + "LAT = "
504 + ((lat == -1) ? "unknown" : Integer.toHexString(lat))
505 + " "
506 + "LONG = "
507 + ((lon == -1) ? "unknown" : Integer.toHexString(lon)));
508 } else {
509 mLocation.setText("unknown");
Wink Savillec3886682009-04-02 11:00:56 -0700510 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800511
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800512
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800513 }
514
515 private final void updateNeighboringCids(ArrayList<NeighboringCellInfo> cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700516 StringBuilder sb = new StringBuilder();
517
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800518 if (cids != null) {
519 if ( cids.isEmpty() ) {
johnwangf02c65f2009-09-25 17:26:54 -0700520 sb.append("no neighboring cells");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800521 } else {
522 for (NeighboringCellInfo cell : cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700523 sb.append(cell.toString()).append(" ");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800524 }
525 }
526 } else {
johnwangf02c65f2009-09-25 17:26:54 -0700527 sb.append("unknown");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800528 }
johnwangf02c65f2009-09-25 17:26:54 -0700529 mNeighboringCids.setText(sb.toString());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800530 }
531
Wink Savillebf471282013-04-05 15:04:05 -0700532 private final void updateCellInfoTv(List<CellInfo> arrayCi) {
533 mCellInfoValue = arrayCi;
Wink Saville79bff2a2012-06-01 14:37:21 -0700534 StringBuilder value = new StringBuilder();
535 if (mCellInfoValue != null) {
536 int index = 0;
537 for (CellInfo ci : mCellInfoValue) {
538 value.append('[');
539 value.append(index);
540 value.append("]=");
541 value.append(ci.toString());
542 if (++index < mCellInfoValue.size()) {
543 value.append("\n");
544 }
545 }
546 }
547 mCellInfo.setText(value.toString());
548 }
549
Wink Saville4f0d8812014-04-15 22:05:24 -0700550 private final void updateDcRtInfoTv(DataConnectionRealTimeInfo dcRtInfo) {
551 mDcRtInfoTv.setText(dcRtInfo.toString());
552 }
553
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800554 private final void
555 updateMessageWaiting() {
556 mMwi.setText(String.valueOf(mMwiValue));
557 }
558
559 private final void
560 updateCallRedirect() {
561 mCfi.setText(String.valueOf(mCfiValue));
562 }
563
564
565 private final void
566 updateServiceState() {
567 ServiceState serviceState = mPhoneStateReceiver.getServiceState();
568 int state = serviceState.getState();
569 Resources r = getResources();
570 String display = r.getString(R.string.radioInfo_unknown);
johnwang342101a2009-09-23 16:22:34 -0700571
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800572 switch (state) {
573 case ServiceState.STATE_IN_SERVICE:
574 display = r.getString(R.string.radioInfo_service_in);
575 break;
576 case ServiceState.STATE_OUT_OF_SERVICE:
577 case ServiceState.STATE_EMERGENCY_ONLY:
578 display = r.getString(R.string.radioInfo_service_emergency);
579 break;
580 case ServiceState.STATE_POWER_OFF:
581 display = r.getString(R.string.radioInfo_service_off);
582 break;
583 }
johnwang342101a2009-09-23 16:22:34 -0700584
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800585 gsmState.setText(display);
johnwang342101a2009-09-23 16:22:34 -0700586
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800587 if (serviceState.getRoaming()) {
588 roamingState.setText(R.string.radioInfo_roaming_in);
589 } else {
590 roamingState.setText(R.string.radioInfo_roaming_not);
591 }
592
593 operatorName.setText(serviceState.getOperatorAlphaLong());
594 }
595
596 private final void
597 updatePhoneState() {
Wink Saville55434042012-06-14 12:33:43 -0700598 PhoneConstants.State state = mPhoneStateReceiver.getPhoneState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800599 Resources r = getResources();
600 String display = r.getString(R.string.radioInfo_unknown);
601
602 switch (state) {
603 case IDLE:
604 display = r.getString(R.string.radioInfo_phone_idle);
605 break;
606 case RINGING:
607 display = r.getString(R.string.radioInfo_phone_ringing);
608 break;
609 case OFFHOOK:
610 display = r.getString(R.string.radioInfo_phone_offhook);
611 break;
612 }
613
614 callState.setText(display);
615 }
616
617 private final void
618 updateDataState() {
619 int state = mTelephonyManager.getDataState();
620 Resources r = getResources();
621 String display = r.getString(R.string.radioInfo_unknown);
622
623 switch (state) {
624 case TelephonyManager.DATA_CONNECTED:
625 display = r.getString(R.string.radioInfo_data_connected);
626 break;
627 case TelephonyManager.DATA_CONNECTING:
628 display = r.getString(R.string.radioInfo_data_connecting);
629 break;
630 case TelephonyManager.DATA_DISCONNECTED:
631 display = r.getString(R.string.radioInfo_data_disconnected);
632 break;
633 case TelephonyManager.DATA_SUSPENDED:
634 display = r.getString(R.string.radioInfo_data_suspended);
635 break;
636 }
johnwang342101a2009-09-23 16:22:34 -0700637
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800638 gprsState.setText(display);
639 }
640
641 private final void updateNetworkType() {
642 Resources r = getResources();
643 String display = SystemProperties.get(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
644 r.getString(R.string.radioInfo_unknown));
645
646 network.setText(display);
647 }
648
649 private final void
650 updateProperties() {
651 String s;
652 Resources r = getResources();
653
654 s = phone.getDeviceId();
johnwang342101a2009-09-23 16:22:34 -0700655 if (s == null) s = r.getString(R.string.radioInfo_unknown);
Wink Savillec3886682009-04-02 11:00:56 -0700656 mDeviceId.setText(s);
johnwang342101a2009-09-23 16:22:34 -0700657
Wink Savillec3886682009-04-02 11:00:56 -0700658
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800659 s = phone.getLine1Number();
johnwang342101a2009-09-23 16:22:34 -0700660 if (s == null) s = r.getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800661 number.setText(s);
662 }
663
664 private final void updateDataStats() {
665 String s;
666
667 s = SystemProperties.get("net.gsm.radio-reset", "0");
668 resets.setText(s);
669
670 s = SystemProperties.get("net.gsm.attempt-gprs", "0");
671 attempts.setText(s);
672
673 s = SystemProperties.get("net.gsm.succeed-gprs", "0");
674 successes.setText(s);
675
676 //s = SystemProperties.get("net.gsm.disconnect", "0");
677 //disconnects.setText(s);
678
679 s = SystemProperties.get("net.ppp.reset-by-timeout", "0");
680 sentSinceReceived.setText(s);
681 }
682
683 private final void updateDataStats2() {
684 Resources r = getResources();
685
Jeff Sharkey93029862011-05-27 18:26:15 -0700686 long txPackets = TrafficStats.getMobileTxPackets();
687 long rxPackets = TrafficStats.getMobileRxPackets();
688 long txBytes = TrafficStats.getMobileTxBytes();
689 long rxBytes = TrafficStats.getMobileRxBytes();
johnwang342101a2009-09-23 16:22:34 -0700690
Jeff Sharkey93029862011-05-27 18:26:15 -0700691 String packets = r.getString(R.string.radioInfo_display_packets);
692 String bytes = r.getString(R.string.radioInfo_display_bytes);
johnwang342101a2009-09-23 16:22:34 -0700693
Jeff Sharkey93029862011-05-27 18:26:15 -0700694 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
695 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800696 }
697
698 /**
699 * Ping a IP address.
700 */
701 private final void pingIpAddr() {
702 try {
703 // This is hardcoded IP addr. This is for testing purposes.
704 // We would need to get rid of this before release.
705 String ipAddress = "74.125.47.104";
706 Process p = Runtime.getRuntime().exec("ping -c 1 " + ipAddress);
707 int status = p.waitFor();
708 if (status == 0) {
709 mPingIpAddrResult = "Pass";
710 } else {
711 mPingIpAddrResult = "Fail: IP addr not reachable";
712 }
713 } catch (IOException e) {
714 mPingIpAddrResult = "Fail: IOException";
715 } catch (InterruptedException e) {
716 mPingIpAddrResult = "Fail: InterruptedException";
717 }
718 }
719
720 /**
721 * Ping a host name
722 */
723 private final void pingHostname() {
724 try {
johnwang342101a2009-09-23 16:22:34 -0700725 Process p = Runtime.getRuntime().exec("ping -c 1 www.google.com");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800726 int status = p.waitFor();
727 if (status == 0) {
728 mPingHostnameResult = "Pass";
729 } else {
730 mPingHostnameResult = "Fail: Host unreachable";
731 }
732 } catch (UnknownHostException e) {
733 mPingHostnameResult = "Fail: Unknown Host";
734 } catch (IOException e) {
735 mPingHostnameResult= "Fail: IOException";
736 } catch (InterruptedException e) {
737 mPingHostnameResult = "Fail: InterruptedException";
738 }
739 }
740
741 /**
742 * This function checks for basic functionality of HTTP Client.
743 */
744 private void httpClientTest() {
Narayan Kamathf25627c2014-12-12 13:53:28 +0000745 HttpURLConnection urlConnection = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800746 try {
Narayan Kamathf25627c2014-12-12 13:53:28 +0000747 // TODO: Hardcoded for now, make it UI configurable
748 URL url = new URL("http://www.google.com");
749 urlConnection = (HttpURLConnection) url.openConnection();
750 if (urlConnection.getResponseCode() == 200) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800751 mHttpClientTestResult = "Pass";
752 } else {
Narayan Kamathf25627c2014-12-12 13:53:28 +0000753 mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800754 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800755 } catch (IOException e) {
756 mHttpClientTestResult = "Fail: IOException";
Narayan Kamathf25627c2014-12-12 13:53:28 +0000757 } finally {
758 if (urlConnection != null) {
759 urlConnection.disconnect();
760 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800761 }
762 }
763
764 private void refreshSmsc() {
jsh21dd4072009-05-12 11:26:55 -0700765 phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800766 }
767
768 private final void updatePingState() {
769 final Handler handler = new Handler();
770 // Set all to unknown since the threads will take a few secs to update.
771 mPingIpAddrResult = getResources().getString(R.string.radioInfo_unknown);
772 mPingHostnameResult = getResources().getString(R.string.radioInfo_unknown);
773 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
774
775 mPingIpAddr.setText(mPingIpAddrResult);
776 mPingHostname.setText(mPingHostnameResult);
777 mHttpClientTest.setText(mHttpClientTestResult);
778
779 final Runnable updatePingResults = new Runnable() {
780 public void run() {
781 mPingIpAddr.setText(mPingIpAddrResult);
782 mPingHostname.setText(mPingHostnameResult);
783 mHttpClientTest.setText(mHttpClientTestResult);
784 }
785 };
786 Thread ipAddr = new Thread() {
787 @Override
788 public void run() {
789 pingIpAddr();
790 handler.post(updatePingResults);
791 }
792 };
793 ipAddr.start();
794
795 Thread hostname = new Thread() {
796 @Override
797 public void run() {
798 pingHostname();
799 handler.post(updatePingResults);
800 }
801 };
802 hostname.start();
803
804 Thread httpClient = new Thread() {
805 @Override
806 public void run() {
807 httpClientTest();
808 handler.post(updatePingResults);
809 }
810 };
811 httpClient.start();
812 }
813
814 private final void updatePdpList() {
815 StringBuilder sb = new StringBuilder("========DATA=======\n");
816
Wink Saville2c3ec092011-04-20 10:24:36 -0700817// List<DataConnection> dcs = phone.getCurrentDataConnectionList();
818//
819// for (DataConnection dc : dcs) {
820// sb.append(" State=").append(dc.getStateAsString()).append("\n");
821// if (dc.isActive()) {
822// long timeElapsed =
823// (System.currentTimeMillis() - dc.getConnectionTime())/1000;
824// sb.append(" connected at ")
825// .append(DateUtils.timeString(dc.getConnectionTime()))
826// .append(" and elapsed ")
827// .append(DateUtils.formatElapsedTime(timeElapsed));
828//
829// if (dc instanceof GsmDataConnection) {
830// GsmDataConnection pdp = (GsmDataConnection)dc;
831// sb.append("\n to ")
832// .append(pdp.getApn().toString());
833// }
834// sb.append("\nLinkProperties: ");
835// sb.append(phone.getLinkProperties(phone.getActiveApnTypes()[0]).toString());
836// } else if (dc.isInactive()) {
837// sb.append(" disconnected with last try at ")
838// .append(DateUtils.timeString(dc.getLastFailTime()))
839// .append("\n fail because ")
840// .append(dc.getLastFailCause().toString());
841// } else {
842// if (dc instanceof GsmDataConnection) {
843// GsmDataConnection pdp = (GsmDataConnection)dc;
844// sb.append(" is connecting to ")
845// .append(pdp.getApn().toString());
846// } else {
847// sb.append(" is connecting");
848// }
849// }
850// sb.append("\n===================");
851// }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800852
853 disconnects.setText(sb.toString());
854 }
855
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800856 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
857 public boolean onMenuItemClick(MenuItem item) {
858 Intent intent = new Intent(Intent.ACTION_VIEW);
859 // XXX We need to specify the component here because if we don't
860 // the activity manager will try to resolve the type by calling
861 // the content provider, which causes it to be loaded in a process
862 // other than the Dialer process, which causes a lot of stuff to
863 // break.
864 intent.setClassName("com.android.phone",
865 "com.android.phone.SimContacts");
866 startActivity(intent);
867 return true;
868 }
869 };
870
871 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
872 public boolean onMenuItemClick(MenuItem item) {
873 Intent intent = new Intent(Intent.ACTION_VIEW);
874 // XXX We need to specify the component here because if we don't
875 // the activity manager will try to resolve the type by calling
876 // the content provider, which causes it to be loaded in a process
877 // other than the Dialer process, which causes a lot of stuff to
878 // break.
879 intent.setClassName("com.android.phone",
880 "com.android.phone.FdnList");
881 startActivity(intent);
882 return true;
883 }
884 };
885
886 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
887 public boolean onMenuItemClick(MenuItem item) {
888 Intent intent = new Intent(
Wink Savillec3886682009-04-02 11:00:56 -0700889 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800890 // XXX We need to specify the component here because if we don't
891 // the activity manager will try to resolve the type by calling
892 // the content provider, which causes it to be loaded in a process
893 // other than the Dialer process, which causes a lot of stuff to
894 // break.
895 intent.setClassName("com.android.phone",
896 "com.android.phone.ADNList");
897 startActivity(intent);
898 return true;
899 }
900 };
901
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800902 private MenuItem.OnMenuItemClickListener mGetPdpList = new MenuItem.OnMenuItemClickListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800903 public boolean onMenuItemClick(MenuItem item) {
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800904 phone.getDataCallList(null);
905 return true;
906 }
907 };
908
909 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
910 public boolean onMenuItemClick(MenuItem item) {
911 Intent intent = new Intent();
912 intent.setClass(RadioInfo.this, BandMode.class);
913 startActivity(intent);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800914 return true;
915 }
916 };
johnwang342101a2009-09-23 16:22:34 -0700917
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800918 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
919 public boolean onMenuItemClick(MenuItem item) {
920 int state = mTelephonyManager.getDataState();
921 switch (state) {
922 case TelephonyManager.DATA_CONNECTED:
Robert Greenwalt0d4c5002014-05-21 20:02:32 -0700923 phone.setDataEnabled(false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800924 break;
925 case TelephonyManager.DATA_DISCONNECTED:
Robert Greenwalt0d4c5002014-05-21 20:02:32 -0700926 phone.setDataEnabled(true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800927 break;
928 default:
929 // do nothing
930 break;
931 }
932 return true;
933 }
934 };
935
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800936 OnClickListener mPowerButtonHandler = new OnClickListener() {
937 public void onClick(View v) {
938 //log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
939 phone.setRadioPower(!isRadioOn());
940 }
941 };
942
Wink Savillebf471282013-04-05 15:04:05 -0700943 class CellInfoListRateHandler implements OnClickListener {
944 int rates[] = {Integer.MAX_VALUE, 0, 1000};
945 int index = 0;
946
947 public int getRate() {
948 return rates[index];
949 }
950
951 @Override
952 public void onClick(View v) {
953 index += 1;
954 if (index >= rates.length) {
955 index = 0;
956 }
957 phone.setCellInfoListRate(rates[index]);
958 updateCellInfoListRate();
959 }
960 }
961 CellInfoListRateHandler mCellInfoListRateHandler = new CellInfoListRateHandler();
962
Wink Saville426fc662011-09-25 14:39:02 -0700963 private Button imsRegRequiredButton;
964 static final String PROPERTY_IMS_REG_REQUIRED = "persist.radio.imsregrequired";
Wink Saville1e596f32011-09-19 14:24:39 -0700965 OnClickListener mImsRegRequiredHandler = new OnClickListener() {
966 @Override
967 public void onClick(View v) {
Wink Savillebf471282013-04-05 15:04:05 -0700968 log(String.format("toggle %s: currently %s",
Wink Saville426fc662011-09-25 14:39:02 -0700969 PROPERTY_IMS_REG_REQUIRED, (isImsRegRequired() ? "on":"off")));
Wink Saville1e596f32011-09-19 14:24:39 -0700970 boolean newValue = !isImsRegRequired();
Wink Saville426fc662011-09-25 14:39:02 -0700971 SystemProperties.set(PROPERTY_IMS_REG_REQUIRED,
Wink Saville1e596f32011-09-19 14:24:39 -0700972 newValue ? "1":"0");
973 updateImsRegRequiredState();
974 }
975 };
976
Wink Saville426fc662011-09-25 14:39:02 -0700977 private boolean isImsRegRequired() {
978 return SystemProperties.getBoolean(PROPERTY_IMS_REG_REQUIRED, false);
979 }
980
981 private void updateImsRegRequiredState() {
Wink Savillebf471282013-04-05 15:04:05 -0700982 log("updateImsRegRequiredState isImsRegRequired()=" + isImsRegRequired());
Wink Saville426fc662011-09-25 14:39:02 -0700983 String buttonText = isImsRegRequired() ?
984 getString(R.string.ims_reg_required_off) :
985 getString(R.string.ims_reg_required_on);
986 imsRegRequiredButton.setText(buttonText);
987 }
988
989 private Button smsOverImsButton;
Wink Saville382a75b2011-09-22 15:17:00 -0700990 static final String PROPERTY_SMS_OVER_IMS = "persist.radio.imsallowmtsms";
991 OnClickListener mSmsOverImsHandler = new OnClickListener() {
992 @Override
993 public void onClick(View v) {
Wink Savillebf471282013-04-05 15:04:05 -0700994 log(String.format("toggle %s: currently %s",
Wink Saville382a75b2011-09-22 15:17:00 -0700995 PROPERTY_SMS_OVER_IMS, (isSmsOverImsEnabled() ? "on":"off")));
996 boolean newValue = !isSmsOverImsEnabled();
997 SystemProperties.set(PROPERTY_SMS_OVER_IMS, newValue ? "1":"0");
998 updateSmsOverImsState();
999 }
1000 };
1001
Wink Saville426fc662011-09-25 14:39:02 -07001002 private boolean isSmsOverImsEnabled() {
1003 return SystemProperties.getBoolean(PROPERTY_SMS_OVER_IMS, false);
1004 }
1005
1006 private void updateSmsOverImsState() {
Wink Savillebf471282013-04-05 15:04:05 -07001007 log("updateSmsOverImsState isSmsOverImsEnabled()=" + isSmsOverImsEnabled());
Wink Saville426fc662011-09-25 14:39:02 -07001008 String buttonText = isSmsOverImsEnabled() ?
1009 getString(R.string.sms_over_ims_off) :
1010 getString(R.string.sms_over_ims_on);
1011 smsOverImsButton.setText(buttonText);
1012 }
1013
1014 private Button lteRamDumpButton;
1015 static final String PROPERTY_LTE_RAM_DUMP = "persist.radio.ramdump";
1016 OnClickListener mLteRamDumpHandler = new OnClickListener() {
1017 @Override
1018 public void onClick(View v) {
Wink Savillebf471282013-04-05 15:04:05 -07001019 log(String.format("toggle %s: currently %s",
Wink Saville426fc662011-09-25 14:39:02 -07001020 PROPERTY_LTE_RAM_DUMP, (isSmsOverImsEnabled() ? "on":"off")));
1021 boolean newValue = !isLteRamDumpEnabled();
1022 SystemProperties.set(PROPERTY_LTE_RAM_DUMP, newValue ? "1":"0");
1023 updateLteRamDumpState();
1024 }
1025 };
1026
1027 private boolean isLteRamDumpEnabled() {
1028 return SystemProperties.getBoolean(PROPERTY_LTE_RAM_DUMP, false);
1029 }
1030
1031 private void updateLteRamDumpState() {
Wink Savillebf471282013-04-05 15:04:05 -07001032 log("updateLteRamDumpState isLteRamDumpEnabled()=" + isLteRamDumpEnabled());
Wink Saville426fc662011-09-25 14:39:02 -07001033 String buttonText = isLteRamDumpEnabled() ?
1034 getString(R.string.lte_ram_dump_off) :
1035 getString(R.string.lte_ram_dump_on);
1036 lteRamDumpButton.setText(buttonText);
1037 }
1038
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001039 OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
1040 public void onClick(View v) {
Wink Savillec3886682009-04-02 11:00:56 -07001041 phone.disableDnsCheck(!phone.isDnsCheckDisabled());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001042 updateDnsCheckState();
1043 }
1044 };
johnwang342101a2009-09-23 16:22:34 -07001045
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001046 OnClickListener mOemInfoButtonHandler = new OnClickListener() {
1047 public void onClick(View v) {
1048 Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO");
1049 try {
1050 startActivity(intent);
1051 } catch (android.content.ActivityNotFoundException ex) {
Wink Savillebf471282013-04-05 15:04:05 -07001052 log("OEM-specific Info/Settings Activity Not Found : " + ex);
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001053 // If the activity does not exist, there are no OEM
1054 // settings, and so we can just do nothing...
1055 }
1056 }
1057 };
1058
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001059 OnClickListener mPingButtonHandler = new OnClickListener() {
1060 public void onClick(View v) {
1061 updatePingState();
1062 }
1063 };
1064
1065 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
1066 public void onClick(View v) {
1067 updateSmscButton.setEnabled(false);
jsh21dd4072009-05-12 11:26:55 -07001068 phone.setSmscAddress(smsc.getText().toString(),
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001069 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
1070 }
1071 };
1072
1073 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
1074 public void onClick(View v) {
1075 refreshSmsc();
1076 }
1077 };
1078
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001079 AdapterView.OnItemSelectedListener
1080 mPreferredNetworkHandler = new AdapterView.OnItemSelectedListener() {
1081 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1082 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
Ricardo Cerqueira32310ee2012-04-12 23:34:38 +01001083 if (pos>=0 && pos<=(mPreferredNetworkLabels.length - 2)) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001084 phone.setPreferredNetworkType(pos, msg);
1085 }
1086 }
1087
1088 public void onNothingSelected(AdapterView parent) {
1089 }
1090 };
1091
1092 private String[] mPreferredNetworkLabels = {
jsh87fa11b2009-08-18 18:00:15 -07001093 "WCDMA preferred",
1094 "GSM only",
1095 "WCDMA only",
1096 "GSM auto (PRL)",
1097 "CDMA auto (PRL)",
1098 "CDMA only",
1099 "EvDo only",
1100 "GSM/CDMA auto (PRL)",
Ricardo Cerqueira32310ee2012-04-12 23:34:38 +01001101 "LTE/CDMA auto (PRL)",
1102 "LTE/GSM auto (PRL)",
1103 "LTE/GSM/CDMA auto (PRL)",
1104 "LTE only",
jsh87fa11b2009-08-18 18:00:15 -07001105 "Unknown"};
Wink Savillebf471282013-04-05 15:04:05 -07001106
1107 private void log(String s) {
1108 Log.d(TAG, "[RadioInfo] " + s);
1109 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001110}