blob: df936263fde836b080b006f001c87650881928b7 [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;
Robert Greenwalt99be5002010-11-24 17:20:59 -080020import android.content.Context;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080021import android.content.Intent;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +080022import android.content.pm.PackageManager;
23import android.content.pm.ResolveInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080024import android.content.res.Resources;
Robert Greenwalt99be5002010-11-24 17:20:59 -080025import android.net.ConnectivityManager;
Jeff Sharkey93029862011-05-27 18:26:15 -070026import android.net.TrafficStats;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080027import android.net.Uri;
28import android.os.AsyncResult;
29import android.os.Bundle;
30import android.os.Handler;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080031import android.os.Message;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080032import android.os.SystemProperties;
Wink Saville79bff2a2012-06-01 14:37:21 -070033import android.telephony.CellInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080034import android.telephony.CellLocation;
35import android.telephony.PhoneStateListener;
36import android.telephony.ServiceState;
37import android.telephony.TelephonyManager;
38import android.telephony.NeighboringCellInfo;
jsh534f5ae2009-09-24 09:19:22 -070039import android.telephony.cdma.CdmaCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080040import android.telephony.gsm.GsmCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080041import android.util.Log;
42import android.view.Menu;
43import android.view.MenuItem;
44import android.view.View;
45import android.view.View.OnClickListener;
46import android.widget.AdapterView;
47import android.widget.ArrayAdapter;
48import android.widget.Button;
49import android.widget.Spinner;
50import android.widget.TextView;
51import android.widget.EditText;
52
53import com.android.internal.telephony.Phone;
Wink Saville55434042012-06-14 12:33:43 -070054import com.android.internal.telephony.PhoneConstants;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080055import com.android.internal.telephony.PhoneFactory;
56import com.android.internal.telephony.PhoneStateIntentReceiver;
57import com.android.internal.telephony.TelephonyProperties;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080058import org.apache.http.HttpResponse;
59import org.apache.http.client.HttpClient;
60import org.apache.http.client.methods.HttpGet;
61import org.apache.http.impl.client.DefaultHttpClient;
62
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080063import java.io.IOException;
64import java.net.UnknownHostException;
65import java.util.ArrayList;
66import java.util.List;
67
68public class RadioInfo extends Activity {
69 private final String TAG = "phone";
johnwang342101a2009-09-23 16:22:34 -070070
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080071 private static final int EVENT_PHONE_STATE_CHANGED = 100;
72 private static final int EVENT_SIGNAL_STRENGTH_CHANGED = 200;
73 private static final int EVENT_SERVICE_STATE_CHANGED = 300;
74 private static final int EVENT_CFI_CHANGED = 302;
75
76 private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000;
77 private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001;
78 private static final int EVENT_QUERY_NEIGHBORING_CIDS_DONE = 1002;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080079 private static final int EVENT_QUERY_SMSC_DONE = 1005;
80 private static final int EVENT_UPDATE_SMSC_DONE = 1006;
81
82 private static final int MENU_ITEM_SELECT_BAND = 0;
83 private static final int MENU_ITEM_VIEW_ADN = 1;
84 private static final int MENU_ITEM_VIEW_FDN = 2;
85 private static final int MENU_ITEM_VIEW_SDN = 3;
86 private static final int MENU_ITEM_GET_PDP_LIST = 4;
87 private static final int MENU_ITEM_TOGGLE_DATA = 5;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +080088
89 static final String ENABLE_DATA_STR = "Enable data connection";
90 static final String DISABLE_DATA_STR = "Disable data connection";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080091
Wink Savillec3886682009-04-02 11:00:56 -070092 private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080093 private TextView number;
94 private TextView callState;
95 private TextView operatorName;
96 private TextView roamingState;
97 private TextView gsmState;
98 private TextView gprsState;
99 private TextView network;
100 private TextView dBm;
101 private TextView mMwi;
102 private TextView mCfi;
103 private TextView mLocation;
104 private TextView mNeighboringCids;
Wink Saville79bff2a2012-06-01 14:37:21 -0700105 private TextView mCellInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800106 private TextView resets;
107 private TextView attempts;
108 private TextView successes;
109 private TextView disconnects;
110 private TextView sentSinceReceived;
111 private TextView sent;
112 private TextView received;
113 private TextView mPingIpAddr;
114 private TextView mPingHostname;
115 private TextView mHttpClientTest;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800116 private TextView dnsCheckState;
117 private EditText smsc;
118 private Button radioPowerButton;
Wink Savillebf471282013-04-05 15:04:05 -0700119 private Button cellInfoListRateButton;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800120 private Button dnsCheckToggleButton;
121 private Button pingTestButton;
122 private Button updateSmscButton;
123 private Button refreshSmscButton;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800124 private Button oemInfoButton;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800125 private Spinner preferredNetworkType;
126
127 private TelephonyManager mTelephonyManager;
128 private Phone phone = null;
129 private PhoneStateIntentReceiver mPhoneStateReceiver;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800130
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800131 private String mPingIpAddrResult;
132 private String mPingHostnameResult;
133 private String mHttpClientTestResult;
134 private boolean mMwiValue = false;
135 private boolean mCfiValue = false;
Wink Saville79bff2a2012-06-01 14:37:21 -0700136 private List<CellInfo> mCellInfoValue;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800137
138 private PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
139 @Override
140 public void onDataConnectionStateChanged(int state) {
141 updateDataState();
142 updateDataStats();
143 updatePdpList();
144 updateNetworkType();
145 }
146
147 @Override
148 public void onDataActivity(int direction) {
149 updateDataStats2();
150 }
151
152 @Override
153 public void onCellLocationChanged(CellLocation location) {
154 updateLocation(location);
155 }
156
157 @Override
158 public void onMessageWaitingIndicatorChanged(boolean mwi) {
159 mMwiValue = mwi;
160 updateMessageWaiting();
161 }
162
163 @Override
164 public void onCallForwardingIndicatorChanged(boolean cfi) {
165 mCfiValue = cfi;
166 updateCallRedirect();
167 }
Wink Saville79bff2a2012-06-01 14:37:21 -0700168
169 @Override
170 public void onCellInfoChanged(List<CellInfo> arrayCi) {
Wink Savillebf471282013-04-05 15:04:05 -0700171 log("onCellInfoChanged: arrayCi=" + arrayCi);
172 updateCellInfoTv(arrayCi);
Wink Saville79bff2a2012-06-01 14:37:21 -0700173 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800174 };
175
176 private Handler mHandler = new Handler() {
177 public void handleMessage(Message msg) {
178 AsyncResult ar;
179 switch (msg.what) {
180 case EVENT_PHONE_STATE_CHANGED:
181 updatePhoneState();
182 break;
183
184 case EVENT_SIGNAL_STRENGTH_CHANGED:
185 updateSignalStrength();
186 break;
187
188 case EVENT_SERVICE_STATE_CHANGED:
189 updateServiceState();
190 updatePowerState();
191 break;
192
193 case EVENT_QUERY_PREFERRED_TYPE_DONE:
194 ar= (AsyncResult) msg.obj;
195 if (ar.exception == null) {
196 int type = ((int[])ar.result)[0];
Ricardo Cerqueira32310ee2012-04-12 23:34:38 +0100197 if (type >= mPreferredNetworkLabels.length) {
Wink Savillebf471282013-04-05 15:04:05 -0700198 log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
Ricardo Cerqueira32310ee2012-04-12 23:34:38 +0100199 "type=" + type);
200 type = mPreferredNetworkLabels.length - 1;
201 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800202 preferredNetworkType.setSelection(type, true);
203 } else {
Ricardo Cerqueira32310ee2012-04-12 23:34:38 +0100204 preferredNetworkType.setSelection(mPreferredNetworkLabels.length - 1, true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800205 }
206 break;
207 case EVENT_SET_PREFERRED_TYPE_DONE:
208 ar= (AsyncResult) msg.obj;
209 if (ar.exception != null) {
210 phone.getPreferredNetworkType(
211 obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
212 }
213 break;
214 case EVENT_QUERY_NEIGHBORING_CIDS_DONE:
215 ar= (AsyncResult) msg.obj;
216 if (ar.exception == null) {
217 updateNeighboringCids((ArrayList<NeighboringCellInfo>)ar.result);
218 } else {
219 mNeighboringCids.setText("unknown");
220 }
221 break;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800222 case EVENT_QUERY_SMSC_DONE:
223 ar= (AsyncResult) msg.obj;
224 if (ar.exception != null) {
225 smsc.setText("refresh error");
226 } else {
jsh21dd4072009-05-12 11:26:55 -0700227 smsc.setText((String)ar.result);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800228 }
229 break;
230 case EVENT_UPDATE_SMSC_DONE:
231 updateSmscButton.setEnabled(true);
232 ar= (AsyncResult) msg.obj;
233 if (ar.exception != null) {
234 smsc.setText("update error");
235 }
236 break;
237 default:
238 break;
239
240 }
241 }
242 };
243
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800244 @Override
245 public void onCreate(Bundle icicle) {
246 super.onCreate(icicle);
247
248 setContentView(R.layout.radio_info);
249
250 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
251 phone = PhoneFactory.getDefaultPhone();
252
Wink Savillec3886682009-04-02 11:00:56 -0700253 mDeviceId= (TextView) findViewById(R.id.imei);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800254 number = (TextView) findViewById(R.id.number);
255 callState = (TextView) findViewById(R.id.call);
256 operatorName = (TextView) findViewById(R.id.operator);
257 roamingState = (TextView) findViewById(R.id.roaming);
258 gsmState = (TextView) findViewById(R.id.gsm);
259 gprsState = (TextView) findViewById(R.id.gprs);
260 network = (TextView) findViewById(R.id.network);
261 dBm = (TextView) findViewById(R.id.dbm);
262 mMwi = (TextView) findViewById(R.id.mwi);
263 mCfi = (TextView) findViewById(R.id.cfi);
264 mLocation = (TextView) findViewById(R.id.location);
265 mNeighboringCids = (TextView) findViewById(R.id.neighboring);
Wink Saville79bff2a2012-06-01 14:37:21 -0700266 mCellInfo = (TextView) findViewById(R.id.cellinfo);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800267
268 resets = (TextView) findViewById(R.id.resets);
269 attempts = (TextView) findViewById(R.id.attempts);
270 successes = (TextView) findViewById(R.id.successes);
271 disconnects = (TextView) findViewById(R.id.disconnects);
272 sentSinceReceived = (TextView) findViewById(R.id.sentSinceReceived);
273 sent = (TextView) findViewById(R.id.sent);
274 received = (TextView) findViewById(R.id.received);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800275 smsc = (EditText) findViewById(R.id.smsc);
276 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
277
278 mPingIpAddr = (TextView) findViewById(R.id.pingIpAddr);
279 mPingHostname = (TextView) findViewById(R.id.pingHostname);
280 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
281
282 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
283 ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
284 android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
johnwang342101a2009-09-23 16:22:34 -0700285 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800286 preferredNetworkType.setAdapter(adapter);
287 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
288
289 radioPowerButton = (Button) findViewById(R.id.radio_power);
290 radioPowerButton.setOnClickListener(mPowerButtonHandler);
291
Wink Savillebf471282013-04-05 15:04:05 -0700292 cellInfoListRateButton = (Button) findViewById(R.id.cell_info_list_rate);
293 cellInfoListRateButton.setOnClickListener(mCellInfoListRateHandler);
294
Wink Saville1e596f32011-09-19 14:24:39 -0700295 imsRegRequiredButton = (Button) findViewById(R.id.ims_reg_required);
296 imsRegRequiredButton.setOnClickListener(mImsRegRequiredHandler);
297
Wink Saville382a75b2011-09-22 15:17:00 -0700298 smsOverImsButton = (Button) findViewById(R.id.sms_over_ims);
299 smsOverImsButton.setOnClickListener(mSmsOverImsHandler);
300
Wink Saville426fc662011-09-25 14:39:02 -0700301 lteRamDumpButton = (Button) findViewById(R.id.lte_ram_dump);
302 lteRamDumpButton.setOnClickListener(mLteRamDumpHandler);
303
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800304 pingTestButton = (Button) findViewById(R.id.ping_test);
305 pingTestButton.setOnClickListener(mPingButtonHandler);
306 updateSmscButton = (Button) findViewById(R.id.update_smsc);
307 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
308 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
309 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
310 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
311 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
johnwang342101a2009-09-23 16:22:34 -0700312
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800313 oemInfoButton = (Button) findViewById(R.id.oem_info);
314 oemInfoButton.setOnClickListener(mOemInfoButtonHandler);
315 PackageManager pm = getPackageManager();
316 Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO");
317 List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0);
318 if (oemInfoIntentList.size() == 0) {
319 oemInfoButton.setEnabled(false);
320 }
321
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800322 mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler);
323 mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED);
324 mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED);
325 mPhoneStateReceiver.notifyPhoneCallState(EVENT_PHONE_STATE_CHANGED);
johnwang342101a2009-09-23 16:22:34 -0700326
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800327 phone.getPreferredNetworkType(
328 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
329 phone.getNeighboringCids(
330 mHandler.obtainMessage(EVENT_QUERY_NEIGHBORING_CIDS_DONE));
331
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800332 CellLocation.requestLocationUpdate();
Wink Saville79bff2a2012-06-01 14:37:21 -0700333
334 // Get current cell info
335 mCellInfoValue = mTelephonyManager.getAllCellInfo();
Wink Savillebf471282013-04-05 15:04:05 -0700336 log("onCreate: mCellInfoValue=" + mCellInfoValue);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800337 }
338
339 @Override
340 protected void onResume() {
341 super.onResume();
342
343 updatePhoneState();
344 updateSignalStrength();
345 updateMessageWaiting();
346 updateCallRedirect();
347 updateServiceState();
348 updateLocation(mTelephonyManager.getCellLocation());
349 updateDataState();
350 updateDataStats();
351 updateDataStats2();
352 updatePowerState();
Wink Savillebf471282013-04-05 15:04:05 -0700353 updateCellInfoListRate();
Wink Saville1e596f32011-09-19 14:24:39 -0700354 updateImsRegRequiredState();
Wink Saville382a75b2011-09-22 15:17:00 -0700355 updateSmsOverImsState();
Wink Saville426fc662011-09-25 14:39:02 -0700356 updateLteRamDumpState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800357 updateProperties();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800358 updateDnsCheckState();
359
Wink Savillebf471282013-04-05 15:04:05 -0700360 log("onResume: register phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800361
362 mPhoneStateReceiver.registerIntent();
363 mTelephonyManager.listen(mPhoneStateListener,
364 PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
365 | PhoneStateListener.LISTEN_DATA_ACTIVITY
366 | PhoneStateListener.LISTEN_CELL_LOCATION
367 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
Wink Saville79bff2a2012-06-01 14:37:21 -0700368 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
369 | PhoneStateListener.LISTEN_CELL_INFO);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800370 }
371
372 @Override
373 public void onPause() {
374 super.onPause();
375
Wink Savillebf471282013-04-05 15:04:05 -0700376 log("onPause: unregister phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800377
378 mPhoneStateReceiver.unregisterIntent();
379 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
380 }
381
382 @Override
383 public boolean onCreateOptionsMenu(Menu menu) {
Wink Savillec3886682009-04-02 11:00:56 -0700384 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
385 .setOnMenuItemClickListener(mSelectBandCallback)
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800386 .setAlphabeticShortcut('b');
387 menu.add(1, MENU_ITEM_VIEW_ADN, 0,
388 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
389 menu.add(1, MENU_ITEM_VIEW_FDN, 0,
390 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
391 menu.add(1, MENU_ITEM_VIEW_SDN, 0,
392 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
393 menu.add(1, MENU_ITEM_GET_PDP_LIST,
394 0, R.string.radioInfo_menu_getPDP).setOnMenuItemClickListener(mGetPdpList);
395 menu.add(1, MENU_ITEM_TOGGLE_DATA,
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800396 0, DISABLE_DATA_STR).setOnMenuItemClickListener(mToggleData);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800397 return true;
398 }
399
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800400 @Override
Wink Savillec3886682009-04-02 11:00:56 -0700401 public boolean onPrepareOptionsMenu(Menu menu) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800402 // Get the TOGGLE DATA menu item in the right state.
403 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
404 int state = mTelephonyManager.getDataState();
405 boolean visible = true;
406
407 switch (state) {
408 case TelephonyManager.DATA_CONNECTED:
409 case TelephonyManager.DATA_SUSPENDED:
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800410 item.setTitle(DISABLE_DATA_STR);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800411 break;
412 case TelephonyManager.DATA_DISCONNECTED:
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800413 item.setTitle(ENABLE_DATA_STR);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800414 break;
415 default:
416 visible = false;
417 break;
418 }
419 item.setVisible(visible);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800420 return true;
421 }
422
423 private boolean isRadioOn() {
424 return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
425 }
johnwang342101a2009-09-23 16:22:34 -0700426
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800427 private void updatePowerState() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800428 String buttonText = isRadioOn() ?
429 getString(R.string.turn_off_radio) :
430 getString(R.string.turn_on_radio);
Wink Savillec3886682009-04-02 11:00:56 -0700431 radioPowerButton.setText(buttonText);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800432 }
433
Wink Savillebf471282013-04-05 15:04:05 -0700434 private void updateCellInfoListRate() {
435 cellInfoListRateButton.setText("CellInfoListRate " + mCellInfoListRateHandler.getRate());
436 updateCellInfoTv(mTelephonyManager.getAllCellInfo());
437 }
438
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800439 private void updateDnsCheckState() {
Mike Lockwood5304c7e2009-04-05 11:37:45 -0700440 dnsCheckState.setText(phone.isDnsCheckDisabled() ?
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800441 "0.0.0.0 allowed" :"0.0.0.0 not allowed");
442 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700443
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800444 private final void
445 updateSignalStrength() {
Wink Savillee2a14e32009-05-29 14:06:30 -0700446 // TODO PhoneStateIntentReceiver is deprecated and PhoneStateListener
447 // should probably used instead.
448 int state = mPhoneStateReceiver.getServiceState().getState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800449 Resources r = getResources();
450
451 if ((ServiceState.STATE_OUT_OF_SERVICE == state) ||
452 (ServiceState.STATE_POWER_OFF == state)) {
453 dBm.setText("0");
454 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700455
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800456 int signalDbm = mPhoneStateReceiver.getSignalStrengthDbm();
Wink Savillee2a14e32009-05-29 14:06:30 -0700457
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800458 if (-1 == signalDbm) signalDbm = 0;
459
Wink Saville882c74a2011-02-17 12:00:03 -0800460 int signalAsu = mPhoneStateReceiver.getSignalStrengthLevelAsu();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800461
462 if (-1 == signalAsu) signalAsu = 0;
463
464 dBm.setText(String.valueOf(signalDbm) + " "
465 + r.getString(R.string.radioInfo_display_dbm) + " "
466 + String.valueOf(signalAsu) + " "
467 + r.getString(R.string.radioInfo_display_asu));
468 }
469
470 private final void updateLocation(CellLocation location) {
jsh534f5ae2009-09-24 09:19:22 -0700471 Resources r = getResources();
Wink Savillec3886682009-04-02 11:00:56 -0700472 if (location instanceof GsmCellLocation) {
473 GsmCellLocation loc = (GsmCellLocation)location;
jsh534f5ae2009-09-24 09:19:22 -0700474 int lac = loc.getLac();
475 int cid = loc.getCid();
476 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
477 + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
478 + " "
479 + r.getString(R.string.radioInfo_cid) + " = "
480 + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
481 } else if (location instanceof CdmaCellLocation) {
482 CdmaCellLocation loc = (CdmaCellLocation)location;
483 int bid = loc.getBaseStationId();
484 int sid = loc.getSystemId();
485 int nid = loc.getNetworkId();
486 int lat = loc.getBaseStationLatitude();
487 int lon = loc.getBaseStationLongitude();
488 mLocation.setText("BID = "
489 + ((bid == -1) ? "unknown" : Integer.toHexString(bid))
490 + " "
491 + "SID = "
492 + ((sid == -1) ? "unknown" : Integer.toHexString(sid))
493 + " "
494 + "NID = "
495 + ((nid == -1) ? "unknown" : Integer.toHexString(nid))
496 + "\n"
497 + "LAT = "
498 + ((lat == -1) ? "unknown" : Integer.toHexString(lat))
499 + " "
500 + "LONG = "
501 + ((lon == -1) ? "unknown" : Integer.toHexString(lon)));
502 } else {
503 mLocation.setText("unknown");
Wink Savillec3886682009-04-02 11:00:56 -0700504 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800505
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800506
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800507 }
508
509 private final void updateNeighboringCids(ArrayList<NeighboringCellInfo> cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700510 StringBuilder sb = new StringBuilder();
511
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800512 if (cids != null) {
513 if ( cids.isEmpty() ) {
johnwangf02c65f2009-09-25 17:26:54 -0700514 sb.append("no neighboring cells");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800515 } else {
516 for (NeighboringCellInfo cell : cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700517 sb.append(cell.toString()).append(" ");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800518 }
519 }
520 } else {
johnwangf02c65f2009-09-25 17:26:54 -0700521 sb.append("unknown");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800522 }
johnwangf02c65f2009-09-25 17:26:54 -0700523 mNeighboringCids.setText(sb.toString());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800524 }
525
Wink Savillebf471282013-04-05 15:04:05 -0700526 private final void updateCellInfoTv(List<CellInfo> arrayCi) {
527 mCellInfoValue = arrayCi;
Wink Saville79bff2a2012-06-01 14:37:21 -0700528 StringBuilder value = new StringBuilder();
529 if (mCellInfoValue != null) {
530 int index = 0;
531 for (CellInfo ci : mCellInfoValue) {
532 value.append('[');
533 value.append(index);
534 value.append("]=");
535 value.append(ci.toString());
536 if (++index < mCellInfoValue.size()) {
537 value.append("\n");
538 }
539 }
540 }
541 mCellInfo.setText(value.toString());
542 }
543
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800544 private final void
545 updateMessageWaiting() {
546 mMwi.setText(String.valueOf(mMwiValue));
547 }
548
549 private final void
550 updateCallRedirect() {
551 mCfi.setText(String.valueOf(mCfiValue));
552 }
553
554
555 private final void
556 updateServiceState() {
557 ServiceState serviceState = mPhoneStateReceiver.getServiceState();
558 int state = serviceState.getState();
559 Resources r = getResources();
560 String display = r.getString(R.string.radioInfo_unknown);
johnwang342101a2009-09-23 16:22:34 -0700561
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800562 switch (state) {
563 case ServiceState.STATE_IN_SERVICE:
564 display = r.getString(R.string.radioInfo_service_in);
565 break;
566 case ServiceState.STATE_OUT_OF_SERVICE:
567 case ServiceState.STATE_EMERGENCY_ONLY:
568 display = r.getString(R.string.radioInfo_service_emergency);
569 break;
570 case ServiceState.STATE_POWER_OFF:
571 display = r.getString(R.string.radioInfo_service_off);
572 break;
573 }
johnwang342101a2009-09-23 16:22:34 -0700574
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800575 gsmState.setText(display);
johnwang342101a2009-09-23 16:22:34 -0700576
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800577 if (serviceState.getRoaming()) {
578 roamingState.setText(R.string.radioInfo_roaming_in);
579 } else {
580 roamingState.setText(R.string.radioInfo_roaming_not);
581 }
582
583 operatorName.setText(serviceState.getOperatorAlphaLong());
584 }
585
586 private final void
587 updatePhoneState() {
Wink Saville55434042012-06-14 12:33:43 -0700588 PhoneConstants.State state = mPhoneStateReceiver.getPhoneState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800589 Resources r = getResources();
590 String display = r.getString(R.string.radioInfo_unknown);
591
592 switch (state) {
593 case IDLE:
594 display = r.getString(R.string.radioInfo_phone_idle);
595 break;
596 case RINGING:
597 display = r.getString(R.string.radioInfo_phone_ringing);
598 break;
599 case OFFHOOK:
600 display = r.getString(R.string.radioInfo_phone_offhook);
601 break;
602 }
603
604 callState.setText(display);
605 }
606
607 private final void
608 updateDataState() {
609 int state = mTelephonyManager.getDataState();
610 Resources r = getResources();
611 String display = r.getString(R.string.radioInfo_unknown);
612
613 switch (state) {
614 case TelephonyManager.DATA_CONNECTED:
615 display = r.getString(R.string.radioInfo_data_connected);
616 break;
617 case TelephonyManager.DATA_CONNECTING:
618 display = r.getString(R.string.radioInfo_data_connecting);
619 break;
620 case TelephonyManager.DATA_DISCONNECTED:
621 display = r.getString(R.string.radioInfo_data_disconnected);
622 break;
623 case TelephonyManager.DATA_SUSPENDED:
624 display = r.getString(R.string.radioInfo_data_suspended);
625 break;
626 }
johnwang342101a2009-09-23 16:22:34 -0700627
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800628 gprsState.setText(display);
629 }
630
631 private final void updateNetworkType() {
632 Resources r = getResources();
633 String display = SystemProperties.get(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
634 r.getString(R.string.radioInfo_unknown));
635
636 network.setText(display);
637 }
638
639 private final void
640 updateProperties() {
641 String s;
642 Resources r = getResources();
643
644 s = phone.getDeviceId();
johnwang342101a2009-09-23 16:22:34 -0700645 if (s == null) s = r.getString(R.string.radioInfo_unknown);
Wink Savillec3886682009-04-02 11:00:56 -0700646 mDeviceId.setText(s);
johnwang342101a2009-09-23 16:22:34 -0700647
Wink Savillec3886682009-04-02 11:00:56 -0700648
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800649 s = phone.getLine1Number();
johnwang342101a2009-09-23 16:22:34 -0700650 if (s == null) s = r.getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800651 number.setText(s);
652 }
653
654 private final void updateDataStats() {
655 String s;
656
657 s = SystemProperties.get("net.gsm.radio-reset", "0");
658 resets.setText(s);
659
660 s = SystemProperties.get("net.gsm.attempt-gprs", "0");
661 attempts.setText(s);
662
663 s = SystemProperties.get("net.gsm.succeed-gprs", "0");
664 successes.setText(s);
665
666 //s = SystemProperties.get("net.gsm.disconnect", "0");
667 //disconnects.setText(s);
668
669 s = SystemProperties.get("net.ppp.reset-by-timeout", "0");
670 sentSinceReceived.setText(s);
671 }
672
673 private final void updateDataStats2() {
674 Resources r = getResources();
675
Jeff Sharkey93029862011-05-27 18:26:15 -0700676 long txPackets = TrafficStats.getMobileTxPackets();
677 long rxPackets = TrafficStats.getMobileRxPackets();
678 long txBytes = TrafficStats.getMobileTxBytes();
679 long rxBytes = TrafficStats.getMobileRxBytes();
johnwang342101a2009-09-23 16:22:34 -0700680
Jeff Sharkey93029862011-05-27 18:26:15 -0700681 String packets = r.getString(R.string.radioInfo_display_packets);
682 String bytes = r.getString(R.string.radioInfo_display_bytes);
johnwang342101a2009-09-23 16:22:34 -0700683
Jeff Sharkey93029862011-05-27 18:26:15 -0700684 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
685 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800686 }
687
688 /**
689 * Ping a IP address.
690 */
691 private final void pingIpAddr() {
692 try {
693 // This is hardcoded IP addr. This is for testing purposes.
694 // We would need to get rid of this before release.
695 String ipAddress = "74.125.47.104";
696 Process p = Runtime.getRuntime().exec("ping -c 1 " + ipAddress);
697 int status = p.waitFor();
698 if (status == 0) {
699 mPingIpAddrResult = "Pass";
700 } else {
701 mPingIpAddrResult = "Fail: IP addr not reachable";
702 }
703 } catch (IOException e) {
704 mPingIpAddrResult = "Fail: IOException";
705 } catch (InterruptedException e) {
706 mPingIpAddrResult = "Fail: InterruptedException";
707 }
708 }
709
710 /**
711 * Ping a host name
712 */
713 private final void pingHostname() {
714 try {
johnwang342101a2009-09-23 16:22:34 -0700715 Process p = Runtime.getRuntime().exec("ping -c 1 www.google.com");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800716 int status = p.waitFor();
717 if (status == 0) {
718 mPingHostnameResult = "Pass";
719 } else {
720 mPingHostnameResult = "Fail: Host unreachable";
721 }
722 } catch (UnknownHostException e) {
723 mPingHostnameResult = "Fail: Unknown Host";
724 } catch (IOException e) {
725 mPingHostnameResult= "Fail: IOException";
726 } catch (InterruptedException e) {
727 mPingHostnameResult = "Fail: InterruptedException";
728 }
729 }
730
731 /**
732 * This function checks for basic functionality of HTTP Client.
733 */
734 private void httpClientTest() {
735 HttpClient client = new DefaultHttpClient();
736 try {
737 HttpGet request = new HttpGet("http://www.google.com");
738 HttpResponse response = client.execute(request);
739 if (response.getStatusLine().getStatusCode() == 200) {
740 mHttpClientTestResult = "Pass";
741 } else {
742 mHttpClientTestResult = "Fail: Code: " + String.valueOf(response);
743 }
744 request.abort();
745 } catch (IOException e) {
746 mHttpClientTestResult = "Fail: IOException";
747 }
748 }
749
750 private void refreshSmsc() {
jsh21dd4072009-05-12 11:26:55 -0700751 phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800752 }
753
754 private final void updatePingState() {
755 final Handler handler = new Handler();
756 // Set all to unknown since the threads will take a few secs to update.
757 mPingIpAddrResult = getResources().getString(R.string.radioInfo_unknown);
758 mPingHostnameResult = getResources().getString(R.string.radioInfo_unknown);
759 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
760
761 mPingIpAddr.setText(mPingIpAddrResult);
762 mPingHostname.setText(mPingHostnameResult);
763 mHttpClientTest.setText(mHttpClientTestResult);
764
765 final Runnable updatePingResults = new Runnable() {
766 public void run() {
767 mPingIpAddr.setText(mPingIpAddrResult);
768 mPingHostname.setText(mPingHostnameResult);
769 mHttpClientTest.setText(mHttpClientTestResult);
770 }
771 };
772 Thread ipAddr = new Thread() {
773 @Override
774 public void run() {
775 pingIpAddr();
776 handler.post(updatePingResults);
777 }
778 };
779 ipAddr.start();
780
781 Thread hostname = new Thread() {
782 @Override
783 public void run() {
784 pingHostname();
785 handler.post(updatePingResults);
786 }
787 };
788 hostname.start();
789
790 Thread httpClient = new Thread() {
791 @Override
792 public void run() {
793 httpClientTest();
794 handler.post(updatePingResults);
795 }
796 };
797 httpClient.start();
798 }
799
800 private final void updatePdpList() {
801 StringBuilder sb = new StringBuilder("========DATA=======\n");
802
Wink Saville2c3ec092011-04-20 10:24:36 -0700803// List<DataConnection> dcs = phone.getCurrentDataConnectionList();
804//
805// for (DataConnection dc : dcs) {
806// sb.append(" State=").append(dc.getStateAsString()).append("\n");
807// if (dc.isActive()) {
808// long timeElapsed =
809// (System.currentTimeMillis() - dc.getConnectionTime())/1000;
810// sb.append(" connected at ")
811// .append(DateUtils.timeString(dc.getConnectionTime()))
812// .append(" and elapsed ")
813// .append(DateUtils.formatElapsedTime(timeElapsed));
814//
815// if (dc instanceof GsmDataConnection) {
816// GsmDataConnection pdp = (GsmDataConnection)dc;
817// sb.append("\n to ")
818// .append(pdp.getApn().toString());
819// }
820// sb.append("\nLinkProperties: ");
821// sb.append(phone.getLinkProperties(phone.getActiveApnTypes()[0]).toString());
822// } else if (dc.isInactive()) {
823// sb.append(" disconnected with last try at ")
824// .append(DateUtils.timeString(dc.getLastFailTime()))
825// .append("\n fail because ")
826// .append(dc.getLastFailCause().toString());
827// } else {
828// if (dc instanceof GsmDataConnection) {
829// GsmDataConnection pdp = (GsmDataConnection)dc;
830// sb.append(" is connecting to ")
831// .append(pdp.getApn().toString());
832// } else {
833// sb.append(" is connecting");
834// }
835// }
836// sb.append("\n===================");
837// }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800838
839 disconnects.setText(sb.toString());
840 }
841
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800842 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
843 public boolean onMenuItemClick(MenuItem item) {
844 Intent intent = new Intent(Intent.ACTION_VIEW);
845 // XXX We need to specify the component here because if we don't
846 // the activity manager will try to resolve the type by calling
847 // the content provider, which causes it to be loaded in a process
848 // other than the Dialer process, which causes a lot of stuff to
849 // break.
850 intent.setClassName("com.android.phone",
851 "com.android.phone.SimContacts");
852 startActivity(intent);
853 return true;
854 }
855 };
856
857 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
858 public boolean onMenuItemClick(MenuItem item) {
859 Intent intent = new Intent(Intent.ACTION_VIEW);
860 // XXX We need to specify the component here because if we don't
861 // the activity manager will try to resolve the type by calling
862 // the content provider, which causes it to be loaded in a process
863 // other than the Dialer process, which causes a lot of stuff to
864 // break.
865 intent.setClassName("com.android.phone",
866 "com.android.phone.FdnList");
867 startActivity(intent);
868 return true;
869 }
870 };
871
872 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
873 public boolean onMenuItemClick(MenuItem item) {
874 Intent intent = new Intent(
Wink Savillec3886682009-04-02 11:00:56 -0700875 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800876 // XXX We need to specify the component here because if we don't
877 // the activity manager will try to resolve the type by calling
878 // the content provider, which causes it to be loaded in a process
879 // other than the Dialer process, which causes a lot of stuff to
880 // break.
881 intent.setClassName("com.android.phone",
882 "com.android.phone.ADNList");
883 startActivity(intent);
884 return true;
885 }
886 };
887
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800888 private MenuItem.OnMenuItemClickListener mGetPdpList = new MenuItem.OnMenuItemClickListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800889 public boolean onMenuItemClick(MenuItem item) {
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800890 phone.getDataCallList(null);
891 return true;
892 }
893 };
894
895 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
896 public boolean onMenuItemClick(MenuItem item) {
897 Intent intent = new Intent();
898 intent.setClass(RadioInfo.this, BandMode.class);
899 startActivity(intent);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800900 return true;
901 }
902 };
johnwang342101a2009-09-23 16:22:34 -0700903
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800904 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
905 public boolean onMenuItemClick(MenuItem item) {
Robert Greenwalt99be5002010-11-24 17:20:59 -0800906 ConnectivityManager cm =
907 (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800908 int state = mTelephonyManager.getDataState();
909 switch (state) {
910 case TelephonyManager.DATA_CONNECTED:
Robert Greenwalt99be5002010-11-24 17:20:59 -0800911 cm.setMobileDataEnabled(false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800912 break;
913 case TelephonyManager.DATA_DISCONNECTED:
Robert Greenwalt99be5002010-11-24 17:20:59 -0800914 cm.setMobileDataEnabled(true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800915 break;
916 default:
917 // do nothing
918 break;
919 }
920 return true;
921 }
922 };
923
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800924 OnClickListener mPowerButtonHandler = new OnClickListener() {
925 public void onClick(View v) {
926 //log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
927 phone.setRadioPower(!isRadioOn());
928 }
929 };
930
Wink Savillebf471282013-04-05 15:04:05 -0700931 class CellInfoListRateHandler implements OnClickListener {
932 int rates[] = {Integer.MAX_VALUE, 0, 1000};
933 int index = 0;
934
935 public int getRate() {
936 return rates[index];
937 }
938
939 @Override
940 public void onClick(View v) {
941 index += 1;
942 if (index >= rates.length) {
943 index = 0;
944 }
945 phone.setCellInfoListRate(rates[index]);
946 updateCellInfoListRate();
947 }
948 }
949 CellInfoListRateHandler mCellInfoListRateHandler = new CellInfoListRateHandler();
950
Wink Saville426fc662011-09-25 14:39:02 -0700951 private Button imsRegRequiredButton;
952 static final String PROPERTY_IMS_REG_REQUIRED = "persist.radio.imsregrequired";
Wink Saville1e596f32011-09-19 14:24:39 -0700953 OnClickListener mImsRegRequiredHandler = new OnClickListener() {
954 @Override
955 public void onClick(View v) {
Wink Savillebf471282013-04-05 15:04:05 -0700956 log(String.format("toggle %s: currently %s",
Wink Saville426fc662011-09-25 14:39:02 -0700957 PROPERTY_IMS_REG_REQUIRED, (isImsRegRequired() ? "on":"off")));
Wink Saville1e596f32011-09-19 14:24:39 -0700958 boolean newValue = !isImsRegRequired();
Wink Saville426fc662011-09-25 14:39:02 -0700959 SystemProperties.set(PROPERTY_IMS_REG_REQUIRED,
Wink Saville1e596f32011-09-19 14:24:39 -0700960 newValue ? "1":"0");
961 updateImsRegRequiredState();
962 }
963 };
964
Wink Saville426fc662011-09-25 14:39:02 -0700965 private boolean isImsRegRequired() {
966 return SystemProperties.getBoolean(PROPERTY_IMS_REG_REQUIRED, false);
967 }
968
969 private void updateImsRegRequiredState() {
Wink Savillebf471282013-04-05 15:04:05 -0700970 log("updateImsRegRequiredState isImsRegRequired()=" + isImsRegRequired());
Wink Saville426fc662011-09-25 14:39:02 -0700971 String buttonText = isImsRegRequired() ?
972 getString(R.string.ims_reg_required_off) :
973 getString(R.string.ims_reg_required_on);
974 imsRegRequiredButton.setText(buttonText);
975 }
976
977 private Button smsOverImsButton;
Wink Saville382a75b2011-09-22 15:17:00 -0700978 static final String PROPERTY_SMS_OVER_IMS = "persist.radio.imsallowmtsms";
979 OnClickListener mSmsOverImsHandler = new OnClickListener() {
980 @Override
981 public void onClick(View v) {
Wink Savillebf471282013-04-05 15:04:05 -0700982 log(String.format("toggle %s: currently %s",
Wink Saville382a75b2011-09-22 15:17:00 -0700983 PROPERTY_SMS_OVER_IMS, (isSmsOverImsEnabled() ? "on":"off")));
984 boolean newValue = !isSmsOverImsEnabled();
985 SystemProperties.set(PROPERTY_SMS_OVER_IMS, newValue ? "1":"0");
986 updateSmsOverImsState();
987 }
988 };
989
Wink Saville426fc662011-09-25 14:39:02 -0700990 private boolean isSmsOverImsEnabled() {
991 return SystemProperties.getBoolean(PROPERTY_SMS_OVER_IMS, false);
992 }
993
994 private void updateSmsOverImsState() {
Wink Savillebf471282013-04-05 15:04:05 -0700995 log("updateSmsOverImsState isSmsOverImsEnabled()=" + isSmsOverImsEnabled());
Wink Saville426fc662011-09-25 14:39:02 -0700996 String buttonText = isSmsOverImsEnabled() ?
997 getString(R.string.sms_over_ims_off) :
998 getString(R.string.sms_over_ims_on);
999 smsOverImsButton.setText(buttonText);
1000 }
1001
1002 private Button lteRamDumpButton;
1003 static final String PROPERTY_LTE_RAM_DUMP = "persist.radio.ramdump";
1004 OnClickListener mLteRamDumpHandler = new OnClickListener() {
1005 @Override
1006 public void onClick(View v) {
Wink Savillebf471282013-04-05 15:04:05 -07001007 log(String.format("toggle %s: currently %s",
Wink Saville426fc662011-09-25 14:39:02 -07001008 PROPERTY_LTE_RAM_DUMP, (isSmsOverImsEnabled() ? "on":"off")));
1009 boolean newValue = !isLteRamDumpEnabled();
1010 SystemProperties.set(PROPERTY_LTE_RAM_DUMP, newValue ? "1":"0");
1011 updateLteRamDumpState();
1012 }
1013 };
1014
1015 private boolean isLteRamDumpEnabled() {
1016 return SystemProperties.getBoolean(PROPERTY_LTE_RAM_DUMP, false);
1017 }
1018
1019 private void updateLteRamDumpState() {
Wink Savillebf471282013-04-05 15:04:05 -07001020 log("updateLteRamDumpState isLteRamDumpEnabled()=" + isLteRamDumpEnabled());
Wink Saville426fc662011-09-25 14:39:02 -07001021 String buttonText = isLteRamDumpEnabled() ?
1022 getString(R.string.lte_ram_dump_off) :
1023 getString(R.string.lte_ram_dump_on);
1024 lteRamDumpButton.setText(buttonText);
1025 }
1026
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001027 OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
1028 public void onClick(View v) {
Wink Savillec3886682009-04-02 11:00:56 -07001029 phone.disableDnsCheck(!phone.isDnsCheckDisabled());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001030 updateDnsCheckState();
1031 }
1032 };
johnwang342101a2009-09-23 16:22:34 -07001033
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001034 OnClickListener mOemInfoButtonHandler = new OnClickListener() {
1035 public void onClick(View v) {
1036 Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO");
1037 try {
1038 startActivity(intent);
1039 } catch (android.content.ActivityNotFoundException ex) {
Wink Savillebf471282013-04-05 15:04:05 -07001040 log("OEM-specific Info/Settings Activity Not Found : " + ex);
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001041 // If the activity does not exist, there are no OEM
1042 // settings, and so we can just do nothing...
1043 }
1044 }
1045 };
1046
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001047 OnClickListener mPingButtonHandler = new OnClickListener() {
1048 public void onClick(View v) {
1049 updatePingState();
1050 }
1051 };
1052
1053 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
1054 public void onClick(View v) {
1055 updateSmscButton.setEnabled(false);
jsh21dd4072009-05-12 11:26:55 -07001056 phone.setSmscAddress(smsc.getText().toString(),
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001057 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
1058 }
1059 };
1060
1061 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
1062 public void onClick(View v) {
1063 refreshSmsc();
1064 }
1065 };
1066
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001067 AdapterView.OnItemSelectedListener
1068 mPreferredNetworkHandler = new AdapterView.OnItemSelectedListener() {
1069 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1070 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
Ricardo Cerqueira32310ee2012-04-12 23:34:38 +01001071 if (pos>=0 && pos<=(mPreferredNetworkLabels.length - 2)) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001072 phone.setPreferredNetworkType(pos, msg);
1073 }
1074 }
1075
1076 public void onNothingSelected(AdapterView parent) {
1077 }
1078 };
1079
1080 private String[] mPreferredNetworkLabels = {
jsh87fa11b2009-08-18 18:00:15 -07001081 "WCDMA preferred",
1082 "GSM only",
1083 "WCDMA only",
1084 "GSM auto (PRL)",
1085 "CDMA auto (PRL)",
1086 "CDMA only",
1087 "EvDo only",
1088 "GSM/CDMA auto (PRL)",
Ricardo Cerqueira32310ee2012-04-12 23:34:38 +01001089 "LTE/CDMA auto (PRL)",
1090 "LTE/GSM auto (PRL)",
1091 "LTE/GSM/CDMA auto (PRL)",
1092 "LTE only",
jsh87fa11b2009-08-18 18:00:15 -07001093 "Unknown"};
Wink Savillebf471282013-04-05 15:04:05 -07001094
1095 private void log(String s) {
1096 Log.d(TAG, "[RadioInfo] " + s);
1097 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001098}