blob: eeb4779f8e977c3bd84053d8778bd67481597f3d [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;
Nathan Harolde272c202016-10-27 13:45:00 -070020import android.app.AlertDialog;
21import android.app.Dialog;
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -080022import android.app.QueuedWork;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080023import android.content.Intent;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +080024import android.content.pm.PackageManager;
25import android.content.pm.ResolveInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080026import android.content.res.Resources;
Nathan Haroldcea413a2015-11-23 15:48:10 -080027import android.graphics.Typeface;
Jeff Sharkey93029862011-05-27 18:26:15 -070028import android.net.TrafficStats;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080029import android.net.Uri;
30import android.os.AsyncResult;
31import android.os.Bundle;
32import android.os.Handler;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080033import android.os.Message;
Wink Saville79bff2a2012-06-01 14:37:21 -070034import android.telephony.CellInfo;
Nathan Haroldcea413a2015-11-23 15:48:10 -080035import android.telephony.CellInfoCdma;
36import android.telephony.CellInfoGsm;
37import android.telephony.CellInfoLte;
38import android.telephony.CellInfoWcdma;
39import android.telephony.CellIdentityCdma;
40import android.telephony.CellIdentityGsm;
41import android.telephony.CellIdentityLte;
42import android.telephony.CellIdentityWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080043import android.telephony.CellLocation;
Nathan Haroldcea413a2015-11-23 15:48:10 -080044import android.telephony.CellSignalStrengthCdma;
45import android.telephony.CellSignalStrengthGsm;
46import android.telephony.CellSignalStrengthLte;
47import android.telephony.CellSignalStrengthWcdma;
Wink Saville4f0d8812014-04-15 22:05:24 -070048import android.telephony.DataConnectionRealTimeInfo;
Jason Monk39b46742015-09-10 15:52:51 -040049import android.telephony.NeighboringCellInfo;
Nathan Harold2b77d742016-03-19 13:22:10 -070050import android.telephony.PreciseCallState;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080051import android.telephony.PhoneStateListener;
52import android.telephony.ServiceState;
Nathan Harold2b77d742016-03-19 13:22:10 -070053import android.telephony.SignalStrength;
Nathan Haroldcea413a2015-11-23 15:48:10 -080054import android.telephony.SubscriptionManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080055import android.telephony.TelephonyManager;
jsh534f5ae2009-09-24 09:19:22 -070056import android.telephony.cdma.CdmaCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080057import android.telephony.gsm.GsmCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080058import android.util.Log;
59import android.view.Menu;
60import android.view.MenuItem;
61import android.view.View;
62import android.view.View.OnClickListener;
63import android.widget.AdapterView;
64import android.widget.ArrayAdapter;
65import android.widget.Button;
Nathan Harold2b77d742016-03-19 13:22:10 -070066import android.widget.CompoundButton;
67import android.widget.CompoundButton.OnCheckedChangeListener;
Jason Monk39b46742015-09-10 15:52:51 -040068import android.widget.EditText;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080069import android.widget.Spinner;
Nathan Harold2b77d742016-03-19 13:22:10 -070070import android.widget.Switch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080071import android.widget.TextView;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080072
Jason Monk39b46742015-09-10 15:52:51 -040073import com.android.ims.ImsConfig;
74import com.android.ims.ImsException;
75import com.android.ims.ImsManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080076import com.android.internal.telephony.Phone;
Wink Saville55434042012-06-14 12:33:43 -070077import com.android.internal.telephony.PhoneConstants;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080078import com.android.internal.telephony.PhoneFactory;
Nathan Haroldcea413a2015-11-23 15:48:10 -080079import com.android.internal.telephony.RILConstants;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080080import com.android.internal.telephony.TelephonyProperties;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080081
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080082import java.io.IOException;
Jason Monk39b46742015-09-10 15:52:51 -040083import java.net.HttpURLConnection;
84import java.net.URL;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080085import java.net.UnknownHostException;
86import java.util.ArrayList;
87import java.util.List;
88
89public class RadioInfo extends Activity {
Nathan Harold2b77d742016-03-19 13:22:10 -070090 private static final String TAG = "RadioInfo";
johnwang342101a2009-09-23 16:22:34 -070091
Nathan Harold2b77d742016-03-19 13:22:10 -070092 private static final String[] mPreferredNetworkLabels = {
93 "WCDMA preferred",
94 "GSM only",
95 "WCDMA only",
96 "GSM auto (PRL)",
97 "CDMA auto (PRL)",
98 "CDMA only",
99 "EvDo only",
100 "Global auto (PRL)",
101 "LTE/CDMA auto (PRL)",
102 "LTE/UMTS auto (PRL)",
103 "LTE/CDMA/UMTS auto (PRL)",
104 "LTE only",
105 "LTE/WCDMA",
106 "TD-SCDMA only",
107 "TD-SCDMA/WCDMA",
108 "LTE/TD-SCDMA",
109 "TD-SCDMA/GSM",
110 "TD-SCDMA/UMTS",
111 "LTE/TD-SCDMA/WCDMA",
112 "LTE/TD-SCDMA/UMTS",
113 "TD-SCDMA/CDMA/UMTS",
114 "Global/TD-SCDMA",
115 "Unknown"
116 };
117
118
119 private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE;
120 private static final int CELL_INFO_LIST_RATE_MAX = 0;
121
Nathan Harold12e1f552016-06-17 13:55:38 -0700122
123 private static final int IMS_VOLTE_PROVISIONED_CONFIG_ID =
124 ImsConfig.ConfigConstants.VLT_SETTING_ENABLED;
125
126 private static final int IMS_VT_PROVISIONED_CONFIG_ID =
127 ImsConfig.ConfigConstants.LVC_SETTING_ENABLED;
128
129 private static final int IMS_WFC_PROVISIONED_CONFIG_ID =
130 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED;
131
Nathan Harold2b77d742016-03-19 13:22:10 -0700132 //Values in must match mCellInfoRefreshRates
133 private static final String[] mCellInfoRefreshRateLabels = {
134 "Disabled",
135 "Immediate",
136 "Min 5s",
137 "Min 10s",
138 "Min 60s"
139 };
140
141 //Values in seconds, must match mCellInfoRefreshRateLabels
142 private static final int mCellInfoRefreshRates[] = {
143 CELL_INFO_LIST_RATE_DISABLED,
144 CELL_INFO_LIST_RATE_MAX,
145 5000,
146 10000,
147 60000
148 };
149
150 private void log(String s) {
151 Log.d(TAG, s);
152 }
153
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800154 private static final int EVENT_CFI_CHANGED = 302;
155
156 private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000;
157 private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800158 private static final int EVENT_QUERY_SMSC_DONE = 1005;
159 private static final int EVENT_UPDATE_SMSC_DONE = 1006;
160
161 private static final int MENU_ITEM_SELECT_BAND = 0;
162 private static final int MENU_ITEM_VIEW_ADN = 1;
163 private static final int MENU_ITEM_VIEW_FDN = 2;
164 private static final int MENU_ITEM_VIEW_SDN = 3;
Nathan Harolde272c202016-10-27 13:45:00 -0700165 private static final int MENU_ITEM_GET_IMS_STATUS = 4;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800166 private static final int MENU_ITEM_TOGGLE_DATA = 5;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800167
Wink Savillec3886682009-04-02 11:00:56 -0700168 private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800169 private TextView number;
170 private TextView callState;
171 private TextView operatorName;
172 private TextView roamingState;
173 private TextView gsmState;
174 private TextView gprsState;
Nathan Harold2b77d742016-03-19 13:22:10 -0700175 private TextView voiceNetwork;
176 private TextView dataNetwork;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800177 private TextView dBm;
178 private TextView mMwi;
179 private TextView mCfi;
180 private TextView mLocation;
181 private TextView mNeighboringCids;
Wink Saville79bff2a2012-06-01 14:37:21 -0700182 private TextView mCellInfo;
Wink Saville4f0d8812014-04-15 22:05:24 -0700183 private TextView mDcRtInfoTv;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800184 private TextView sent;
185 private TextView received;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800186 private TextView mPingHostnameV4;
187 private TextView mPingHostnameV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800188 private TextView mHttpClientTest;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800189 private TextView dnsCheckState;
190 private EditText smsc;
Nathan Harold2b77d742016-03-19 13:22:10 -0700191 private Switch radioPowerOnSwitch;
192 private Button cellInfoRefreshRateButton;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800193 private Button dnsCheckToggleButton;
194 private Button pingTestButton;
195 private Button updateSmscButton;
196 private Button refreshSmscButton;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800197 private Button oemInfoButton;
Nathan Harold12e1f552016-06-17 13:55:38 -0700198 private Switch imsVolteProvisionedSwitch;
199 private Switch imsVtProvisionedSwitch;
200 private Switch imsWfcProvisionedSwitch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800201 private Spinner preferredNetworkType;
Nathan Harold2b77d742016-03-19 13:22:10 -0700202 private Spinner cellInfoRefreshRateSpinner;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800203
204 private TelephonyManager mTelephonyManager;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800205 private ImsManager mImsManager = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800206 private Phone phone = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800207
Nathan Haroldcea413a2015-11-23 15:48:10 -0800208 private String mPingHostnameResultV4;
209 private String mPingHostnameResultV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800210 private String mHttpClientTestResult;
211 private boolean mMwiValue = false;
212 private boolean mCfiValue = false;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800213
214 private List<CellInfo> mCellInfoResult = null;
215 private CellLocation mCellLocationResult = null;
216 private List<NeighboringCellInfo> mNeighboringCellResult = null;
217
218 private int mPreferredNetworkTypeResult;
Nathan Harold2b77d742016-03-19 13:22:10 -0700219 private int mCellInfoRefreshRateIndex;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800220
Nathan Harold2b77d742016-03-19 13:22:10 -0700221 private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800222 @Override
223 public void onDataConnectionStateChanged(int state) {
224 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800225 updateNetworkType();
226 }
227
228 @Override
229 public void onDataActivity(int direction) {
230 updateDataStats2();
231 }
232
233 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700234 public void onCallStateChanged(int state, String incomingNumber) {
235 updateNetworkType();
236 updatePhoneState(state);
237 }
238
239 @Override
240 public void onPreciseCallStateChanged(PreciseCallState preciseState) {
241 updateNetworkType();
242 }
243
244 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800245 public void onCellLocationChanged(CellLocation location) {
246 updateLocation(location);
247 }
248
249 @Override
250 public void onMessageWaitingIndicatorChanged(boolean mwi) {
251 mMwiValue = mwi;
252 updateMessageWaiting();
253 }
254
255 @Override
256 public void onCallForwardingIndicatorChanged(boolean cfi) {
257 mCfiValue = cfi;
258 updateCallRedirect();
259 }
Wink Saville79bff2a2012-06-01 14:37:21 -0700260
261 @Override
262 public void onCellInfoChanged(List<CellInfo> arrayCi) {
Wink Savillebf471282013-04-05 15:04:05 -0700263 log("onCellInfoChanged: arrayCi=" + arrayCi);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800264 mCellInfoResult = arrayCi;
265 updateCellInfo(mCellInfoResult);
Wink Saville79bff2a2012-06-01 14:37:21 -0700266 }
Wink Saville4f0d8812014-04-15 22:05:24 -0700267
268 @Override
269 public void onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo) {
270 log("onDataConnectionRealTimeInfoChanged: dcRtInfo=" + dcRtInfo);
271 updateDcRtInfoTv(dcRtInfo);
272 }
Nathan Harold2b77d742016-03-19 13:22:10 -0700273
274 @Override
275 public void onSignalStrengthsChanged(SignalStrength signalStrength) {
276 log("onSignalStrengthChanged: SignalStrength=" +signalStrength);
277 updateSignalStrength(signalStrength);
278 }
279
280 @Override
281 public void onServiceStateChanged(ServiceState serviceState) {
282 log("onServiceStateChanged: ServiceState=" + serviceState);
283 updateServiceState(serviceState);
284 updateRadioPowerState();
285 updateNetworkType();
Nathan Harold12e1f552016-06-17 13:55:38 -0700286 updateImsProvisionedState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700287 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800288 };
289
Nathan Haroldcea413a2015-11-23 15:48:10 -0800290 private void updatePreferredNetworkType(int type) {
291 if (type >= mPreferredNetworkLabels.length || type < 0) {
292 log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
293 "type=" + type);
294 type = mPreferredNetworkLabels.length - 1; //set to Unknown
295 }
296 mPreferredNetworkTypeResult = type;
297
298 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
299 }
300
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800301 private Handler mHandler = new Handler() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800302 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800303 public void handleMessage(Message msg) {
304 AsyncResult ar;
305 switch (msg.what) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800306 case EVENT_QUERY_PREFERRED_TYPE_DONE:
307 ar= (AsyncResult) msg.obj;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800308 if (ar.exception == null && ar.result != null) {
309 updatePreferredNetworkType(((int[])ar.result)[0]);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800310 } else {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800311 //In case of an exception, we will set this to unknown
312 updatePreferredNetworkType(mPreferredNetworkLabels.length-1);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800313 }
314 break;
315 case EVENT_SET_PREFERRED_TYPE_DONE:
316 ar= (AsyncResult) msg.obj;
317 if (ar.exception != null) {
Nathan Harolded38afa2016-04-13 00:29:30 -0700318 log("Set preferred network type failed.");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800319 }
320 break;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800321 case EVENT_QUERY_SMSC_DONE:
322 ar= (AsyncResult) msg.obj;
323 if (ar.exception != null) {
324 smsc.setText("refresh error");
325 } else {
jsh21dd4072009-05-12 11:26:55 -0700326 smsc.setText((String)ar.result);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800327 }
328 break;
329 case EVENT_UPDATE_SMSC_DONE:
330 updateSmscButton.setEnabled(true);
331 ar= (AsyncResult) msg.obj;
332 if (ar.exception != null) {
333 smsc.setText("update error");
334 }
335 break;
336 default:
Nathan Haroldcea413a2015-11-23 15:48:10 -0800337 super.handleMessage(msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800338 break;
339
340 }
341 }
342 };
343
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800344 @Override
345 public void onCreate(Bundle icicle) {
346 super.onCreate(icicle);
fionaxub54cb2d2016-09-22 15:01:05 -0700347 if (!android.os.Process.myUserHandle().isSystem()) {
348 Log.e(TAG, "Not run from system user, don't do anything.");
349 finish();
350 return;
351 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800352
353 setContentView(R.layout.radio_info);
354
Nathan Haroldcea413a2015-11-23 15:48:10 -0800355 log("Started onCreate");
356
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800357 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
358 phone = PhoneFactory.getDefaultPhone();
359
Nathan Haroldcea413a2015-11-23 15:48:10 -0800360 //TODO: Need to update this if the default phoneId changes?
361 // Better to have an instance per phone?
362 mImsManager = ImsManager.getInstance(getApplicationContext(),
363 SubscriptionManager.getDefaultVoicePhoneId());
364
Wink Savillec3886682009-04-02 11:00:56 -0700365 mDeviceId= (TextView) findViewById(R.id.imei);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800366 number = (TextView) findViewById(R.id.number);
367 callState = (TextView) findViewById(R.id.call);
368 operatorName = (TextView) findViewById(R.id.operator);
369 roamingState = (TextView) findViewById(R.id.roaming);
370 gsmState = (TextView) findViewById(R.id.gsm);
371 gprsState = (TextView) findViewById(R.id.gprs);
Nathan Harold2b77d742016-03-19 13:22:10 -0700372 voiceNetwork = (TextView) findViewById(R.id.voice_network);
373 dataNetwork = (TextView) findViewById(R.id.data_network);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800374 dBm = (TextView) findViewById(R.id.dbm);
375 mMwi = (TextView) findViewById(R.id.mwi);
376 mCfi = (TextView) findViewById(R.id.cfi);
377 mLocation = (TextView) findViewById(R.id.location);
378 mNeighboringCids = (TextView) findViewById(R.id.neighboring);
Wink Saville79bff2a2012-06-01 14:37:21 -0700379 mCellInfo = (TextView) findViewById(R.id.cellinfo);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800380 mCellInfo.setTypeface(Typeface.MONOSPACE);
Wink Saville4f0d8812014-04-15 22:05:24 -0700381 mDcRtInfoTv = (TextView) findViewById(R.id.dcrtinfo);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800382
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800383 sent = (TextView) findViewById(R.id.sent);
384 received = (TextView) findViewById(R.id.received);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800385 smsc = (EditText) findViewById(R.id.smsc);
386 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800387 mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4);
388 mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800389 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
390
391 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
392 ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
393 android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
johnwang342101a2009-09-23 16:22:34 -0700394 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800395 preferredNetworkType.setAdapter(adapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800396
Nathan Harold2b77d742016-03-19 13:22:10 -0700397 cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select);
398 ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this,
399 android.R.layout.simple_spinner_item, mCellInfoRefreshRateLabels);
400 cellInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
401 cellInfoRefreshRateSpinner.setAdapter(cellInfoAdapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800402
Nathan Harold12e1f552016-06-17 13:55:38 -0700403 imsVolteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch);
404 imsVtProvisionedSwitch = (Switch) findViewById(R.id.vt_provisioned_switch);
405 imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
Wink Savillebf471282013-04-05 15:04:05 -0700406
Nathan Harold2b77d742016-03-19 13:22:10 -0700407 radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
Wink Saville426fc662011-09-25 14:39:02 -0700408
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800409 pingTestButton = (Button) findViewById(R.id.ping_test);
410 pingTestButton.setOnClickListener(mPingButtonHandler);
411 updateSmscButton = (Button) findViewById(R.id.update_smsc);
412 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
413 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
414 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
415 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
416 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
johnwang342101a2009-09-23 16:22:34 -0700417
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800418 oemInfoButton = (Button) findViewById(R.id.oem_info);
419 oemInfoButton.setOnClickListener(mOemInfoButtonHandler);
420 PackageManager pm = getPackageManager();
421 Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO");
422 List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0);
423 if (oemInfoIntentList.size() == 0) {
424 oemInfoButton.setEnabled(false);
425 }
426
Nathan Harolded38afa2016-04-13 00:29:30 -0700427 mCellInfoRefreshRateIndex = 0; //disabled
Nathan Haroldcea413a2015-11-23 15:48:10 -0800428 mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown
429
430 //FIXME: Replace with TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800431 phone.getPreferredNetworkType(
432 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800433
Nathan Haroldcea413a2015-11-23 15:48:10 -0800434 restoreFromBundle(icicle);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800435 }
436
437 @Override
438 protected void onResume() {
439 super.onResume();
440
Nathan Haroldcea413a2015-11-23 15:48:10 -0800441 log("Started onResume");
442
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800443 updateMessageWaiting();
444 updateCallRedirect();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800445 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800446 updateDataStats2();
Nathan Harold2b77d742016-03-19 13:22:10 -0700447 updateRadioPowerState();
Nathan Harold12e1f552016-06-17 13:55:38 -0700448 updateImsProvisionedState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800449 updateProperties();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800450 updateDnsCheckState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700451 updateNetworkType();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800452
Nathan Haroldcea413a2015-11-23 15:48:10 -0800453 updateNeighboringCids(mNeighboringCellResult);
454 updateLocation(mCellLocationResult);
455 updateCellInfo(mCellInfoResult);
456
457 mPingHostnameV4.setText(mPingHostnameResultV4);
458 mPingHostnameV6.setText(mPingHostnameResultV6);
459 mHttpClientTest.setText(mHttpClientTestResult);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800460
Nathan Harold2b77d742016-03-19 13:22:10 -0700461 cellInfoRefreshRateSpinner.setOnItemSelectedListener(mCellInfoRefreshRateHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700462 //set selection after registering listener to force update
463 cellInfoRefreshRateSpinner.setSelection(mCellInfoRefreshRateIndex);
464
465 //set selection before registering to prevent update
466 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
Nathan Harold2b77d742016-03-19 13:22:10 -0700467 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700468
Nathan Harold2b77d742016-03-19 13:22:10 -0700469 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
Nathan Harold12e1f552016-06-17 13:55:38 -0700470 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
471 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
472 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Nathan Harold2b77d742016-03-19 13:22:10 -0700473
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800474 mTelephonyManager.listen(mPhoneStateListener,
Nathan Harold2b77d742016-03-19 13:22:10 -0700475 PhoneStateListener.LISTEN_CALL_STATE
476 //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
477 // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
478 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800479 | PhoneStateListener.LISTEN_DATA_ACTIVITY
480 | PhoneStateListener.LISTEN_CELL_LOCATION
481 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
Wink Saville79bff2a2012-06-01 14:37:21 -0700482 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
Wink Saville4f0d8812014-04-15 22:05:24 -0700483 | PhoneStateListener.LISTEN_CELL_INFO
Nathan Harold2b77d742016-03-19 13:22:10 -0700484 | PhoneStateListener.LISTEN_SERVICE_STATE
485 | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
Wink Saville4f0d8812014-04-15 22:05:24 -0700486 | PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO);
Nathan Harolded38afa2016-04-13 00:29:30 -0700487
488 smsc.clearFocus();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800489 }
490
491 @Override
Nathan Haroldcea413a2015-11-23 15:48:10 -0800492 protected void onPause() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800493 super.onPause();
494
Wink Savillebf471282013-04-05 15:04:05 -0700495 log("onPause: unregister phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800496
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800497 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -0700498 mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800499 }
500
Nathan Haroldcea413a2015-11-23 15:48:10 -0800501 private void restoreFromBundle(Bundle b) {
Nathan Harolde272c202016-10-27 13:45:00 -0700502 if(b == null) {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800503 return;
504 }
505
506 mPingHostnameResultV4 = b.getString("mPingHostnameResultV4","");
507 mPingHostnameResultV6 = b.getString("mPingHostnameResultV6","");
508 mHttpClientTestResult = b.getString("mHttpClientTestResult","");
509
510 mPingHostnameV4.setText(mPingHostnameResultV4);
511 mPingHostnameV6.setText(mPingHostnameResultV6);
512 mHttpClientTest.setText(mHttpClientTestResult);
513
Nathan Harold2b77d742016-03-19 13:22:10 -0700514 mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult",
515 mPreferredNetworkLabels.length - 1);
516
517 mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800518 }
519
520 @Override
521 protected void onSaveInstanceState(Bundle outState) {
522 outState.putString("mPingHostnameResultV4", mPingHostnameResultV4);
523 outState.putString("mPingHostnameResultV6", mPingHostnameResultV6);
524 outState.putString("mHttpClientTestResult", mHttpClientTestResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700525
Nathan Haroldcea413a2015-11-23 15:48:10 -0800526 outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700527 outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex);
528
Nathan Haroldcea413a2015-11-23 15:48:10 -0800529 }
530
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800531 @Override
532 public boolean onCreateOptionsMenu(Menu menu) {
Wink Savillec3886682009-04-02 11:00:56 -0700533 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
534 .setOnMenuItemClickListener(mSelectBandCallback)
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800535 .setAlphabeticShortcut('b');
536 menu.add(1, MENU_ITEM_VIEW_ADN, 0,
537 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
538 menu.add(1, MENU_ITEM_VIEW_FDN, 0,
539 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
540 menu.add(1, MENU_ITEM_VIEW_SDN, 0,
541 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
Nathan Harolde272c202016-10-27 13:45:00 -0700542 menu.add(1, MENU_ITEM_GET_IMS_STATUS,
543 0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800544 menu.add(1, MENU_ITEM_TOGGLE_DATA,
Nathan Harold2b77d742016-03-19 13:22:10 -0700545 0, R.string.radio_info_data_connection_disable).setOnMenuItemClickListener(mToggleData);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800546 return true;
547 }
548
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800549 @Override
Wink Savillec3886682009-04-02 11:00:56 -0700550 public boolean onPrepareOptionsMenu(Menu menu) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800551 // Get the TOGGLE DATA menu item in the right state.
552 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
553 int state = mTelephonyManager.getDataState();
554 boolean visible = true;
555
556 switch (state) {
557 case TelephonyManager.DATA_CONNECTED:
558 case TelephonyManager.DATA_SUSPENDED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700559 item.setTitle(R.string.radio_info_data_connection_disable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800560 break;
561 case TelephonyManager.DATA_DISCONNECTED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700562 item.setTitle(R.string.radio_info_data_connection_enable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800563 break;
564 default:
565 visible = false;
566 break;
567 }
568 item.setVisible(visible);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800569 return true;
570 }
571
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800572 private void updateDnsCheckState() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800573 //FIXME: Replace with a TelephonyManager call
Mike Lockwood5304c7e2009-04-05 11:37:45 -0700574 dnsCheckState.setText(phone.isDnsCheckDisabled() ?
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800575 "0.0.0.0 allowed" :"0.0.0.0 not allowed");
576 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700577
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800578 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700579 updateSignalStrength(SignalStrength signalStrength) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800580 Resources r = getResources();
581
Nathan Harold2b77d742016-03-19 13:22:10 -0700582 int signalDbm = signalStrength.getDbm();
Wink Savillee2a14e32009-05-29 14:06:30 -0700583
Nathan Harold2b77d742016-03-19 13:22:10 -0700584 int signalAsu = signalStrength.getAsuLevel();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800585
586 if (-1 == signalAsu) signalAsu = 0;
587
588 dBm.setText(String.valueOf(signalDbm) + " "
589 + r.getString(R.string.radioInfo_display_dbm) + " "
590 + String.valueOf(signalAsu) + " "
591 + r.getString(R.string.radioInfo_display_asu));
592 }
593
594 private final void updateLocation(CellLocation location) {
jsh534f5ae2009-09-24 09:19:22 -0700595 Resources r = getResources();
Wink Savillec3886682009-04-02 11:00:56 -0700596 if (location instanceof GsmCellLocation) {
597 GsmCellLocation loc = (GsmCellLocation)location;
jsh534f5ae2009-09-24 09:19:22 -0700598 int lac = loc.getLac();
599 int cid = loc.getCid();
600 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
601 + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
602 + " "
603 + r.getString(R.string.radioInfo_cid) + " = "
604 + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
605 } else if (location instanceof CdmaCellLocation) {
606 CdmaCellLocation loc = (CdmaCellLocation)location;
607 int bid = loc.getBaseStationId();
608 int sid = loc.getSystemId();
609 int nid = loc.getNetworkId();
610 int lat = loc.getBaseStationLatitude();
611 int lon = loc.getBaseStationLongitude();
612 mLocation.setText("BID = "
613 + ((bid == -1) ? "unknown" : Integer.toHexString(bid))
614 + " "
615 + "SID = "
616 + ((sid == -1) ? "unknown" : Integer.toHexString(sid))
617 + " "
618 + "NID = "
619 + ((nid == -1) ? "unknown" : Integer.toHexString(nid))
620 + "\n"
621 + "LAT = "
622 + ((lat == -1) ? "unknown" : Integer.toHexString(lat))
623 + " "
624 + "LONG = "
625 + ((lon == -1) ? "unknown" : Integer.toHexString(lon)));
626 } else {
627 mLocation.setText("unknown");
Wink Savillec3886682009-04-02 11:00:56 -0700628 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800629
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800630
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800631 }
632
Nathan Haroldcea413a2015-11-23 15:48:10 -0800633 private final void updateNeighboringCids(List<NeighboringCellInfo> cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700634 StringBuilder sb = new StringBuilder();
635
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800636 if (cids != null) {
Nathan Harolde272c202016-10-27 13:45:00 -0700637 if (cids.isEmpty()) {
johnwangf02c65f2009-09-25 17:26:54 -0700638 sb.append("no neighboring cells");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800639 } else {
640 for (NeighboringCellInfo cell : cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700641 sb.append(cell.toString()).append(" ");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800642 }
643 }
644 } else {
johnwangf02c65f2009-09-25 17:26:54 -0700645 sb.append("unknown");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800646 }
johnwangf02c65f2009-09-25 17:26:54 -0700647 mNeighboringCids.setText(sb.toString());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800648 }
649
Nathan Haroldcea413a2015-11-23 15:48:10 -0800650 private final String getCellInfoDisplayString(int i) {
651 return (i != Integer.MAX_VALUE) ? Integer.toString(i) : "";
652 }
653
654 private final String getCellInfoDisplayString(long i) {
655 return (i != Long.MAX_VALUE) ? Long.toString(i) : "";
656 }
657
658 private final String buildCdmaInfoString(CellInfoCdma ci) {
659 CellIdentityCdma cidCdma = ci.getCellIdentity();
660 CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
661
662 return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s",
663 ci.isRegistered() ? "S " : " ",
664 getCellInfoDisplayString(cidCdma.getSystemId()),
665 getCellInfoDisplayString(cidCdma.getNetworkId()),
666 getCellInfoDisplayString(cidCdma.getBasestationId()),
667 getCellInfoDisplayString(ssCdma.getCdmaDbm()),
668 getCellInfoDisplayString(ssCdma.getCdmaEcio()),
669 getCellInfoDisplayString(ssCdma.getEvdoDbm()),
670 getCellInfoDisplayString(ssCdma.getEvdoEcio()),
671 getCellInfoDisplayString(ssCdma.getEvdoSnr()));
672 }
673
674 private final String buildGsmInfoString(CellInfoGsm ci) {
675 CellIdentityGsm cidGsm = ci.getCellIdentity();
676 CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
677
Nathan Harold2b77d742016-03-19 13:22:10 -0700678 return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
Nathan Haroldcea413a2015-11-23 15:48:10 -0800679 ci.isRegistered() ? "S " : " ",
680 getCellInfoDisplayString(cidGsm.getMcc()),
681 getCellInfoDisplayString(cidGsm.getMnc()),
682 getCellInfoDisplayString(cidGsm.getLac()),
683 getCellInfoDisplayString(cidGsm.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700684 getCellInfoDisplayString(cidGsm.getArfcn()),
685 getCellInfoDisplayString(cidGsm.getBsic()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800686 getCellInfoDisplayString(ssGsm.getDbm()));
687 }
688
689 private final String buildLteInfoString(CellInfoLte ci) {
690 CellIdentityLte cidLte = ci.getCellIdentity();
691 CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
692
693 return String.format(
Nathan Harold2b77d742016-03-19 13:22:10 -0700694 "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n",
Nathan Haroldcea413a2015-11-23 15:48:10 -0800695 ci.isRegistered() ? "S " : " ",
696 getCellInfoDisplayString(cidLte.getMcc()),
697 getCellInfoDisplayString(cidLte.getMnc()),
698 getCellInfoDisplayString(cidLte.getTac()),
699 getCellInfoDisplayString(cidLte.getCi()),
700 getCellInfoDisplayString(cidLte.getPci()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700701 getCellInfoDisplayString(cidLte.getEarfcn()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800702 getCellInfoDisplayString(ssLte.getDbm()),
703 getCellInfoDisplayString(ssLte.getRsrq()),
704 getCellInfoDisplayString(ssLte.getTimingAdvance()));
705 }
706
707 private final String buildWcdmaInfoString(CellInfoWcdma ci) {
708 CellIdentityWcdma cidWcdma = ci.getCellIdentity();
709 CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength();
710
Nathan Harold2b77d742016-03-19 13:22:10 -0700711 return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
Nathan Haroldcea413a2015-11-23 15:48:10 -0800712 ci.isRegistered() ? "S " : " ",
713 getCellInfoDisplayString(cidWcdma.getMcc()),
714 getCellInfoDisplayString(cidWcdma.getMnc()),
715 getCellInfoDisplayString(cidWcdma.getLac()),
716 getCellInfoDisplayString(cidWcdma.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700717 getCellInfoDisplayString(cidWcdma.getUarfcn()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800718 getCellInfoDisplayString(cidWcdma.getPsc()),
719 getCellInfoDisplayString(ssWcdma.getDbm()));
720 }
721
722 private final String buildCellInfoString(List<CellInfo> arrayCi) {
723 String value = new String();
724 StringBuilder cdmaCells = new StringBuilder(),
725 gsmCells = new StringBuilder(),
726 lteCells = new StringBuilder(),
727 wcdmaCells = new StringBuilder();
728
729 if (arrayCi != null) {
730 for (CellInfo ci : arrayCi) {
731
732 if (ci instanceof CellInfoLte) {
733 lteCells.append(buildLteInfoString((CellInfoLte) ci));
734 } else if (ci instanceof CellInfoWcdma) {
735 wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
736 } else if (ci instanceof CellInfoGsm) {
737 gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
738 } else if (ci instanceof CellInfoCdma) {
739 cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
Wink Saville79bff2a2012-06-01 14:37:21 -0700740 }
741 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800742 if (lteCells.length() != 0) {
743 value += String.format(
Nathan Harold2b77d742016-03-19 13:22:10 -0700744 "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n",
745 "SRV", "MCC", "MNC", "TAC", "CID", "PCI", "EARFCN", "RSRP", "RSRQ", "TA");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800746 value += lteCells.toString();
747 }
748 if (wcdmaCells.length() != 0) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700749 value += String.format("WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
750 "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800751 value += wcdmaCells.toString();
752 }
753 if (gsmCells.length() != 0) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700754 value += String.format("GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
755 "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800756 value += gsmCells.toString();
757 }
758 if (cdmaCells.length() != 0) {
759 value += String.format(
760 "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n",
761 "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
762 value += cdmaCells.toString();
763 }
764 } else {
765 value ="unknown";
Wink Saville79bff2a2012-06-01 14:37:21 -0700766 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800767
768 return value.toString();
769 }
770
771 private final void updateCellInfo(List<CellInfo> arrayCi) {
772 mCellInfo.setText(buildCellInfoString(arrayCi));
Wink Saville79bff2a2012-06-01 14:37:21 -0700773 }
774
Wink Saville4f0d8812014-04-15 22:05:24 -0700775 private final void updateDcRtInfoTv(DataConnectionRealTimeInfo dcRtInfo) {
776 mDcRtInfoTv.setText(dcRtInfo.toString());
777 }
778
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800779 private final void
780 updateMessageWaiting() {
781 mMwi.setText(String.valueOf(mMwiValue));
782 }
783
784 private final void
785 updateCallRedirect() {
786 mCfi.setText(String.valueOf(mCfiValue));
787 }
788
789
790 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700791 updateServiceState(ServiceState serviceState) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800792 int state = serviceState.getState();
793 Resources r = getResources();
794 String display = r.getString(R.string.radioInfo_unknown);
johnwang342101a2009-09-23 16:22:34 -0700795
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800796 switch (state) {
797 case ServiceState.STATE_IN_SERVICE:
798 display = r.getString(R.string.radioInfo_service_in);
799 break;
800 case ServiceState.STATE_OUT_OF_SERVICE:
801 case ServiceState.STATE_EMERGENCY_ONLY:
802 display = r.getString(R.string.radioInfo_service_emergency);
803 break;
804 case ServiceState.STATE_POWER_OFF:
805 display = r.getString(R.string.radioInfo_service_off);
806 break;
807 }
johnwang342101a2009-09-23 16:22:34 -0700808
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800809 gsmState.setText(display);
johnwang342101a2009-09-23 16:22:34 -0700810
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800811 if (serviceState.getRoaming()) {
812 roamingState.setText(R.string.radioInfo_roaming_in);
813 } else {
814 roamingState.setText(R.string.radioInfo_roaming_not);
815 }
816
817 operatorName.setText(serviceState.getOperatorAlphaLong());
818 }
819
820 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700821 updatePhoneState(int state) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800822 Resources r = getResources();
823 String display = r.getString(R.string.radioInfo_unknown);
824
825 switch (state) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700826 case TelephonyManager.CALL_STATE_IDLE:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800827 display = r.getString(R.string.radioInfo_phone_idle);
828 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700829 case TelephonyManager.CALL_STATE_RINGING:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800830 display = r.getString(R.string.radioInfo_phone_ringing);
831 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700832 case TelephonyManager.CALL_STATE_OFFHOOK:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800833 display = r.getString(R.string.radioInfo_phone_offhook);
834 break;
835 }
836
837 callState.setText(display);
838 }
839
840 private final void
841 updateDataState() {
842 int state = mTelephonyManager.getDataState();
843 Resources r = getResources();
844 String display = r.getString(R.string.radioInfo_unknown);
845
846 switch (state) {
847 case TelephonyManager.DATA_CONNECTED:
848 display = r.getString(R.string.radioInfo_data_connected);
849 break;
850 case TelephonyManager.DATA_CONNECTING:
851 display = r.getString(R.string.radioInfo_data_connecting);
852 break;
853 case TelephonyManager.DATA_DISCONNECTED:
854 display = r.getString(R.string.radioInfo_data_disconnected);
855 break;
856 case TelephonyManager.DATA_SUSPENDED:
857 display = r.getString(R.string.radioInfo_data_suspended);
858 break;
859 }
johnwang342101a2009-09-23 16:22:34 -0700860
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800861 gprsState.setText(display);
862 }
863
864 private final void updateNetworkType() {
Nathan Harolde272c202016-10-27 13:45:00 -0700865 if(phone != null) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700866 ServiceState ss = phone.getServiceState();
867 dataNetwork.setText(ServiceState.rilRadioTechnologyToString(
868 phone.getServiceState().getRilDataRadioTechnology()));
869 voiceNetwork.setText(ServiceState.rilRadioTechnologyToString(
870 phone.getServiceState().getRilVoiceRadioTechnology()));
871 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800872 }
873
874 private final void
875 updateProperties() {
876 String s;
877 Resources r = getResources();
878
879 s = phone.getDeviceId();
johnwang342101a2009-09-23 16:22:34 -0700880 if (s == null) s = r.getString(R.string.radioInfo_unknown);
Wink Savillec3886682009-04-02 11:00:56 -0700881 mDeviceId.setText(s);
johnwang342101a2009-09-23 16:22:34 -0700882
Nathan Haroldcea413a2015-11-23 15:48:10 -0800883 //FIXME: Replace with a TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800884 s = phone.getLine1Number();
johnwang342101a2009-09-23 16:22:34 -0700885 if (s == null) s = r.getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800886 number.setText(s);
887 }
888
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800889 private final void updateDataStats2() {
890 Resources r = getResources();
891
Jeff Sharkey93029862011-05-27 18:26:15 -0700892 long txPackets = TrafficStats.getMobileTxPackets();
893 long rxPackets = TrafficStats.getMobileRxPackets();
894 long txBytes = TrafficStats.getMobileTxBytes();
895 long rxBytes = TrafficStats.getMobileRxBytes();
johnwang342101a2009-09-23 16:22:34 -0700896
Jeff Sharkey93029862011-05-27 18:26:15 -0700897 String packets = r.getString(R.string.radioInfo_display_packets);
898 String bytes = r.getString(R.string.radioInfo_display_bytes);
johnwang342101a2009-09-23 16:22:34 -0700899
Jeff Sharkey93029862011-05-27 18:26:15 -0700900 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
901 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800902 }
903
904 /**
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800905 * Ping a host name
906 */
907 private final void pingHostname() {
908 try {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800909 try {
910 Process p4 = Runtime.getRuntime().exec("ping -c 1 www.google.com");
911 int status4 = p4.waitFor();
912 if (status4 == 0) {
913 mPingHostnameResultV4 = "Pass";
914 } else {
915 mPingHostnameResultV4 = String.format("Fail(%d)", status4);
916 }
917 } catch (IOException e) {
918 mPingHostnameResultV4 = "Fail: IOException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800919 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800920 try {
921 Process p6 = Runtime.getRuntime().exec("ping6 -c 1 www.google.com");
922 int status6 = p6.waitFor();
923 if (status6 == 0) {
924 mPingHostnameResultV6 = "Pass";
925 } else {
926 mPingHostnameResultV6 = String.format("Fail(%d)", status6);
927 }
928 } catch (IOException e) {
929 mPingHostnameResultV6 = "Fail: IOException";
930 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800931 } catch (InterruptedException e) {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800932 mPingHostnameResultV4 = mPingHostnameResultV6 = "Fail: InterruptedException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800933 }
934 }
935
936 /**
937 * This function checks for basic functionality of HTTP Client.
938 */
939 private void httpClientTest() {
Narayan Kamathf25627c2014-12-12 13:53:28 +0000940 HttpURLConnection urlConnection = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800941 try {
Narayan Kamathf25627c2014-12-12 13:53:28 +0000942 // TODO: Hardcoded for now, make it UI configurable
Alex Klyubinb0090232015-04-02 11:08:51 -0700943 URL url = new URL("https://www.google.com");
Narayan Kamathf25627c2014-12-12 13:53:28 +0000944 urlConnection = (HttpURLConnection) url.openConnection();
945 if (urlConnection.getResponseCode() == 200) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800946 mHttpClientTestResult = "Pass";
947 } else {
Narayan Kamathf25627c2014-12-12 13:53:28 +0000948 mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800949 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800950 } catch (IOException e) {
951 mHttpClientTestResult = "Fail: IOException";
Narayan Kamathf25627c2014-12-12 13:53:28 +0000952 } finally {
953 if (urlConnection != null) {
954 urlConnection.disconnect();
955 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800956 }
957 }
958
959 private void refreshSmsc() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800960 //FIXME: Replace with a TelephonyManager call
jsh21dd4072009-05-12 11:26:55 -0700961 phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800962 }
963
Nathan Haroldcea413a2015-11-23 15:48:10 -0800964 private final void updateAllCellInfo() {
965
966 mCellInfo.setText("");
967 mNeighboringCids.setText("");
968 mLocation.setText("");
969
970 final Runnable updateAllCellInfoResults = new Runnable() {
971 public void run() {
972 updateNeighboringCids(mNeighboringCellResult);
973 updateLocation(mCellLocationResult);
974 updateCellInfo(mCellInfoResult);
975 }
976 };
977
978 Thread locThread = new Thread() {
979 @Override
980 public void run() {
981 mCellInfoResult = mTelephonyManager.getAllCellInfo();
982 mCellLocationResult = mTelephonyManager.getCellLocation();
983 mNeighboringCellResult = mTelephonyManager.getNeighboringCellInfo();
984
985 mHandler.post(updateAllCellInfoResults);
986 }
987 };
988 locThread.start();
989 }
990
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800991 private final void updatePingState() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800992 // Set all to unknown since the threads will take a few secs to update.
Nathan Haroldcea413a2015-11-23 15:48:10 -0800993 mPingHostnameResultV4 = getResources().getString(R.string.radioInfo_unknown);
994 mPingHostnameResultV6 = getResources().getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800995 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
996
Nathan Haroldcea413a2015-11-23 15:48:10 -0800997 mPingHostnameV4.setText(mPingHostnameResultV4);
998 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800999 mHttpClientTest.setText(mHttpClientTestResult);
1000
1001 final Runnable updatePingResults = new Runnable() {
1002 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001003 mPingHostnameV4.setText(mPingHostnameResultV4);
1004 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001005 mHttpClientTest.setText(mHttpClientTestResult);
1006 }
1007 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001008
1009 Thread hostname = new Thread() {
1010 @Override
1011 public void run() {
1012 pingHostname();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001013 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001014 }
1015 };
1016 hostname.start();
1017
1018 Thread httpClient = new Thread() {
1019 @Override
1020 public void run() {
1021 httpClientTest();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001022 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001023 }
1024 };
1025 httpClient.start();
1026 }
1027
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001028 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
1029 public boolean onMenuItemClick(MenuItem item) {
1030 Intent intent = new Intent(Intent.ACTION_VIEW);
1031 // XXX We need to specify the component here because if we don't
1032 // the activity manager will try to resolve the type by calling
1033 // the content provider, which causes it to be loaded in a process
1034 // other than the Dialer process, which causes a lot of stuff to
1035 // break.
1036 intent.setClassName("com.android.phone",
1037 "com.android.phone.SimContacts");
1038 startActivity(intent);
1039 return true;
1040 }
1041 };
1042
1043 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
1044 public boolean onMenuItemClick(MenuItem item) {
1045 Intent intent = new Intent(Intent.ACTION_VIEW);
1046 // XXX We need to specify the component here because if we don't
1047 // the activity manager will try to resolve the type by calling
1048 // the content provider, which causes it to be loaded in a process
1049 // other than the Dialer process, which causes a lot of stuff to
1050 // break.
1051 intent.setClassName("com.android.phone",
Andrew Leeda90d682014-10-31 13:12:20 -07001052 "com.android.phone.settings.fdn.FdnList");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001053 startActivity(intent);
1054 return true;
1055 }
1056 };
1057
1058 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
1059 public boolean onMenuItemClick(MenuItem item) {
1060 Intent intent = new Intent(
Wink Savillec3886682009-04-02 11:00:56 -07001061 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001062 // XXX We need to specify the component here because if we don't
1063 // the activity manager will try to resolve the type by calling
1064 // the content provider, which causes it to be loaded in a process
1065 // other than the Dialer process, which causes a lot of stuff to
1066 // break.
1067 intent.setClassName("com.android.phone",
1068 "com.android.phone.ADNList");
1069 startActivity(intent);
1070 return true;
1071 }
1072 };
1073
Nathan Harolde272c202016-10-27 13:45:00 -07001074 private MenuItem.OnMenuItemClickListener mGetImsStatus = new MenuItem.OnMenuItemClickListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001075 public boolean onMenuItemClick(MenuItem item) {
Nathan Harolde272c202016-10-27 13:45:00 -07001076 boolean isImsRegistered = phone.isImsRegistered();
1077 boolean availableVolte = phone.isVolteEnabled();
1078 boolean availableWfc = phone.isWifiCallingEnabled();
1079 boolean availableVt = phone.isVideoEnabled();
1080 boolean availableUt = phone.isUtEnabled();
1081
1082 final String imsRegString = isImsRegistered ?
1083 getString(R.string.radio_info_ims_reg_status_registered) :
1084 getString(R.string.radio_info_ims_reg_status_not_registered);
1085
1086 final String available = getString(R.string.radio_info_ims_feature_status_available);
1087 final String unavailable = getString(
1088 R.string.radio_info_ims_feature_status_unavailable);
1089
1090 String imsStatus = getString(R.string.radio_info_ims_reg_status,
1091 imsRegString,
1092 availableVolte ? available : unavailable,
1093 availableWfc ? available : unavailable,
1094 availableVt ? available : unavailable,
1095 availableUt ? available : unavailable);
1096
1097 AlertDialog imsDialog = new AlertDialog.Builder(RadioInfo.this)
1098 .setMessage(imsStatus)
1099 .setTitle(getString(R.string.radio_info_ims_reg_status_title))
1100 .create();
1101
1102 imsDialog.show();
1103
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001104 return true;
1105 }
1106 };
1107
1108 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
1109 public boolean onMenuItemClick(MenuItem item) {
1110 Intent intent = new Intent();
1111 intent.setClass(RadioInfo.this, BandMode.class);
1112 startActivity(intent);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001113 return true;
1114 }
1115 };
johnwang342101a2009-09-23 16:22:34 -07001116
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001117 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
1118 public boolean onMenuItemClick(MenuItem item) {
1119 int state = mTelephonyManager.getDataState();
1120 switch (state) {
1121 case TelephonyManager.DATA_CONNECTED:
Nathan Haroldcea413a2015-11-23 15:48:10 -08001122 //FIXME: Replace with a TelephonyManager call
Robert Greenwalt0d4c5002014-05-21 20:02:32 -07001123 phone.setDataEnabled(false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001124 break;
1125 case TelephonyManager.DATA_DISCONNECTED:
Nathan Haroldcea413a2015-11-23 15:48:10 -08001126 //FIXME: Replace with a TelephonyManager call
Robert Greenwalt0d4c5002014-05-21 20:02:32 -07001127 phone.setDataEnabled(true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001128 break;
1129 default:
1130 // do nothing
1131 break;
1132 }
1133 return true;
1134 }
1135 };
1136
Nathan Harold2b77d742016-03-19 13:22:10 -07001137 private boolean isRadioOn() {
1138 //FIXME: Replace with a TelephonyManager call
1139 return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
1140 }
1141
1142 private void updateRadioPowerState() {
1143 //delightful hack to prevent on-checked-changed calls from
1144 //actually forcing the radio preference to its transient/current value.
1145 radioPowerOnSwitch.setOnCheckedChangeListener(null);
1146 radioPowerOnSwitch.setChecked(isRadioOn());
1147 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
1148 }
1149
Nathan Harolde272c202016-10-27 13:45:00 -07001150 void setImsVolteProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001151 Log.d(TAG, "setImsVolteProvisioned state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001152 setImsConfigProvisionedState(IMS_VOLTE_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001153 }
1154
Nathan Harolde272c202016-10-27 13:45:00 -07001155 void setImsVtProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001156 Log.d(TAG, "setImsVtProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001157 setImsConfigProvisionedState(IMS_VT_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001158 }
1159
Nathan Harolde272c202016-10-27 13:45:00 -07001160 void setImsWfcProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001161 Log.d(TAG, "setImsWfcProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001162 setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001163 }
1164
Nathan Harolde272c202016-10-27 13:45:00 -07001165 void setImsConfigProvisionedState(int configItem, boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001166 if (phone != null && mImsManager != null) {
Philip P. Moltmannb92663a2017-02-13 20:58:46 +00001167 QueuedWork.singleThreadExecutor().submit(new Runnable() {
Nathan Harold12e1f552016-06-17 13:55:38 -07001168 public void run() {
1169 try {
1170 mImsManager.getConfigInterface().setProvisionedValue(
1171 configItem,
1172 state? 1 : 0);
1173 } catch (ImsException e) {
1174 Log.e(TAG, "setImsConfigProvisioned() exception:", e);
1175 }
1176 }
Philip P. Moltmannb92663a2017-02-13 20:58:46 +00001177 });
Nathan Harold12e1f552016-06-17 13:55:38 -07001178 }
1179 }
1180
Nathan Harold2b77d742016-03-19 13:22:10 -07001181 OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() {
1182 @Override
1183 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1184 log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
1185 phone.setRadioPower(isChecked);
1186 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001187 };
1188
Nathan Harold12e1f552016-06-17 13:55:38 -07001189 private boolean isImsVolteProvisioned() {
Nathan Harold2b77d742016-03-19 13:22:10 -07001190 if (phone != null && mImsManager != null) {
1191 return mImsManager.isVolteEnabledByPlatform(phone.getContext())
1192 && mImsManager.isVolteProvisionedOnDevice(phone.getContext());
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -08001193 }
1194 return false;
1195 }
1196
Nathan Harold12e1f552016-06-17 13:55:38 -07001197 OnCheckedChangeListener mImsVolteCheckedChangeListener = new OnCheckedChangeListener() {
Wink Saville426fc662011-09-25 14:39:02 -07001198 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -07001199 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001200 setImsVolteProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001201 }
Wink Saville426fc662011-09-25 14:39:02 -07001202 };
1203
Nathan Harold12e1f552016-06-17 13:55:38 -07001204 private boolean isImsVtProvisioned() {
1205 if (phone != null && mImsManager != null) {
1206 return mImsManager.isVtEnabledByPlatform(phone.getContext())
1207 && mImsManager.isVtProvisionedOnDevice(phone.getContext());
1208 }
1209 return false;
1210 }
1211
1212 OnCheckedChangeListener mImsVtCheckedChangeListener = new OnCheckedChangeListener() {
1213 @Override
1214 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1215 setImsVtProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001216 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001217 };
1218
1219 private boolean isImsWfcProvisioned() {
1220 if (phone != null && mImsManager != null) {
1221 return mImsManager.isWfcEnabledByPlatform(phone.getContext())
1222 && mImsManager.isWfcProvisionedOnDevice(phone.getContext());
1223 }
1224 return false;
1225 }
1226
1227 OnCheckedChangeListener mImsWfcCheckedChangeListener = new OnCheckedChangeListener() {
1228 @Override
1229 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1230 setImsWfcProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001231 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001232 };
1233
1234 private void updateImsProvisionedState() {
1235 log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
Nathan Harold2b77d742016-03-19 13:22:10 -07001236 //delightful hack to prevent on-checked-changed calls from
1237 //actually forcing the ims provisioning to its transient/current value.
Nathan Harold12e1f552016-06-17 13:55:38 -07001238 imsVolteProvisionedSwitch.setOnCheckedChangeListener(null);
1239 imsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned());
1240 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001241 imsVolteProvisionedSwitch.setEnabled(
1242 mImsManager.isVolteEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001243
1244 imsVtProvisionedSwitch.setOnCheckedChangeListener(null);
1245 imsVtProvisionedSwitch.setChecked(isImsVtProvisioned());
1246 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001247 imsVtProvisionedSwitch.setEnabled(
1248 mImsManager.isVtEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001249
1250 imsWfcProvisionedSwitch.setOnCheckedChangeListener(null);
1251 imsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned());
1252 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001253 imsWfcProvisionedSwitch.setEnabled(
1254 mImsManager.isWfcEnabledByPlatform(phone.getContext()));
Wink Saville426fc662011-09-25 14:39:02 -07001255 }
1256
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001257 OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
1258 public void onClick(View v) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001259 //FIXME: Replace with a TelephonyManager call
Wink Savillec3886682009-04-02 11:00:56 -07001260 phone.disableDnsCheck(!phone.isDnsCheckDisabled());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001261 updateDnsCheckState();
1262 }
1263 };
johnwang342101a2009-09-23 16:22:34 -07001264
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001265 OnClickListener mOemInfoButtonHandler = new OnClickListener() {
1266 public void onClick(View v) {
1267 Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO");
1268 try {
1269 startActivity(intent);
1270 } catch (android.content.ActivityNotFoundException ex) {
Wink Savillebf471282013-04-05 15:04:05 -07001271 log("OEM-specific Info/Settings Activity Not Found : " + ex);
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001272 // If the activity does not exist, there are no OEM
1273 // settings, and so we can just do nothing...
1274 }
1275 }
1276 };
1277
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001278 OnClickListener mPingButtonHandler = new OnClickListener() {
1279 public void onClick(View v) {
1280 updatePingState();
1281 }
1282 };
1283
1284 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
1285 public void onClick(View v) {
1286 updateSmscButton.setEnabled(false);
jsh21dd4072009-05-12 11:26:55 -07001287 phone.setSmscAddress(smsc.getText().toString(),
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001288 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
1289 }
1290 };
1291
1292 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
1293 public void onClick(View v) {
1294 refreshSmsc();
1295 }
1296 };
1297
Nathan Haroldcea413a2015-11-23 15:48:10 -08001298 AdapterView.OnItemSelectedListener mPreferredNetworkHandler =
1299 new AdapterView.OnItemSelectedListener() {
1300
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001301 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001302 if (mPreferredNetworkTypeResult != pos && pos >= 0
1303 && pos <= mPreferredNetworkLabels.length - 2) {
1304 mPreferredNetworkTypeResult = pos;
1305 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
1306 phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001307 }
1308 }
1309
1310 public void onNothingSelected(AdapterView parent) {
1311 }
1312 };
1313
Nathan Harold2b77d742016-03-19 13:22:10 -07001314 AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler =
1315 new AdapterView.OnItemSelectedListener() {
Wink Savillebf471282013-04-05 15:04:05 -07001316
Nathan Harold2b77d742016-03-19 13:22:10 -07001317 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1318 mCellInfoRefreshRateIndex = pos;
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -07001319 mTelephonyManager.setCellInfoListRate(mCellInfoRefreshRates[pos]);
Nathan Harold2b77d742016-03-19 13:22:10 -07001320 updateAllCellInfo();
1321 }
1322
1323 public void onNothingSelected(AdapterView parent) {
1324 }
1325 };
1326
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001327}