blob: ec683f7ec2ff5dbc6cf05fc0c1fac0b878597036 [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;
Youhan Wangfd781e92016-12-16 15:53:16 -080023import android.content.ComponentName;
Meng Wang586741c2017-04-26 15:02:51 -070024import android.content.Context;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080025import android.content.Intent;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +080026import android.content.pm.PackageManager;
27import android.content.pm.ResolveInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080028import android.content.res.Resources;
Nathan Haroldcea413a2015-11-23 15:48:10 -080029import android.graphics.Typeface;
Jeff Sharkey93029862011-05-27 18:26:15 -070030import android.net.TrafficStats;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080031import android.net.Uri;
32import android.os.AsyncResult;
33import android.os.Bundle;
34import android.os.Handler;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080035import android.os.Message;
Meng Wang586741c2017-04-26 15:02:51 -070036import android.telephony.CarrierConfigManager;
Wink Saville79bff2a2012-06-01 14:37:21 -070037import android.telephony.CellInfo;
Nathan Haroldcea413a2015-11-23 15:48:10 -080038import android.telephony.CellInfoCdma;
39import android.telephony.CellInfoGsm;
40import android.telephony.CellInfoLte;
41import android.telephony.CellInfoWcdma;
42import android.telephony.CellIdentityCdma;
43import android.telephony.CellIdentityGsm;
44import android.telephony.CellIdentityLte;
45import android.telephony.CellIdentityWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080046import android.telephony.CellLocation;
Nathan Haroldcea413a2015-11-23 15:48:10 -080047import android.telephony.CellSignalStrengthCdma;
48import android.telephony.CellSignalStrengthGsm;
49import android.telephony.CellSignalStrengthLte;
50import android.telephony.CellSignalStrengthWcdma;
Wink Saville4f0d8812014-04-15 22:05:24 -070051import android.telephony.DataConnectionRealTimeInfo;
Jason Monk39b46742015-09-10 15:52:51 -040052import android.telephony.NeighboringCellInfo;
Nathan Harold2b77d742016-03-19 13:22:10 -070053import android.telephony.PreciseCallState;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080054import android.telephony.PhoneStateListener;
Nathan Harold433ca442018-04-23 18:20:43 -070055import android.telephony.PhysicalChannelConfig;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080056import android.telephony.ServiceState;
Nathan Harold2b77d742016-03-19 13:22:10 -070057import android.telephony.SignalStrength;
Nathan Haroldcea413a2015-11-23 15:48:10 -080058import android.telephony.SubscriptionManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080059import android.telephony.TelephonyManager;
jsh534f5ae2009-09-24 09:19:22 -070060import android.telephony.cdma.CdmaCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080061import android.telephony.gsm.GsmCellLocation;
Nathan Harold6e16fdf2018-04-17 17:01:32 -070062import android.text.TextUtils;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080063import android.util.Log;
64import android.view.Menu;
65import android.view.MenuItem;
66import android.view.View;
67import android.view.View.OnClickListener;
68import android.widget.AdapterView;
69import android.widget.ArrayAdapter;
70import android.widget.Button;
Nathan Harold2b77d742016-03-19 13:22:10 -070071import android.widget.CompoundButton;
72import android.widget.CompoundButton.OnCheckedChangeListener;
Jason Monk39b46742015-09-10 15:52:51 -040073import android.widget.EditText;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080074import android.widget.Spinner;
Nathan Harold2b77d742016-03-19 13:22:10 -070075import android.widget.Switch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080076import android.widget.TextView;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080077
Jason Monk39b46742015-09-10 15:52:51 -040078import com.android.ims.ImsConfig;
79import com.android.ims.ImsException;
80import com.android.ims.ImsManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080081import com.android.internal.telephony.Phone;
Wink Saville55434042012-06-14 12:33:43 -070082import com.android.internal.telephony.PhoneConstants;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080083import com.android.internal.telephony.PhoneFactory;
Nathan Haroldcea413a2015-11-23 15:48:10 -080084import com.android.internal.telephony.RILConstants;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080085import com.android.internal.telephony.TelephonyProperties;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080086
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080087import java.io.IOException;
Jason Monk39b46742015-09-10 15:52:51 -040088import java.net.HttpURLConnection;
89import java.net.URL;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080090import java.net.UnknownHostException;
91import java.util.ArrayList;
92import java.util.List;
93
94public class RadioInfo extends Activity {
Nathan Harold2b77d742016-03-19 13:22:10 -070095 private static final String TAG = "RadioInfo";
johnwang342101a2009-09-23 16:22:34 -070096
Nathan Harold2b77d742016-03-19 13:22:10 -070097 private static final String[] mPreferredNetworkLabels = {
98 "WCDMA preferred",
99 "GSM only",
100 "WCDMA only",
101 "GSM auto (PRL)",
102 "CDMA auto (PRL)",
103 "CDMA only",
104 "EvDo only",
105 "Global auto (PRL)",
106 "LTE/CDMA auto (PRL)",
107 "LTE/UMTS auto (PRL)",
108 "LTE/CDMA/UMTS auto (PRL)",
109 "LTE only",
110 "LTE/WCDMA",
111 "TD-SCDMA only",
112 "TD-SCDMA/WCDMA",
113 "LTE/TD-SCDMA",
114 "TD-SCDMA/GSM",
115 "TD-SCDMA/UMTS",
116 "LTE/TD-SCDMA/WCDMA",
117 "LTE/TD-SCDMA/UMTS",
118 "TD-SCDMA/CDMA/UMTS",
119 "Global/TD-SCDMA",
120 "Unknown"
121 };
122
123
124 private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE;
125 private static final int CELL_INFO_LIST_RATE_MAX = 0;
126
Nathan Harold12e1f552016-06-17 13:55:38 -0700127
128 private static final int IMS_VOLTE_PROVISIONED_CONFIG_ID =
129 ImsConfig.ConfigConstants.VLT_SETTING_ENABLED;
130
131 private static final int IMS_VT_PROVISIONED_CONFIG_ID =
132 ImsConfig.ConfigConstants.LVC_SETTING_ENABLED;
133
134 private static final int IMS_WFC_PROVISIONED_CONFIG_ID =
135 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED;
136
Meng Wang586741c2017-04-26 15:02:51 -0700137 private static final int EAB_PROVISIONED_CONFIG_ID =
138 ImsConfig.ConfigConstants.EAB_SETTING_ENABLED;
139
Nathan Harold2b77d742016-03-19 13:22:10 -0700140 //Values in must match mCellInfoRefreshRates
141 private static final String[] mCellInfoRefreshRateLabels = {
142 "Disabled",
143 "Immediate",
144 "Min 5s",
145 "Min 10s",
146 "Min 60s"
147 };
148
149 //Values in seconds, must match mCellInfoRefreshRateLabels
150 private static final int mCellInfoRefreshRates[] = {
151 CELL_INFO_LIST_RATE_DISABLED,
152 CELL_INFO_LIST_RATE_MAX,
153 5000,
154 10000,
155 60000
156 };
157
158 private void log(String s) {
159 Log.d(TAG, s);
160 }
161
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800162 private static final int EVENT_CFI_CHANGED = 302;
163
164 private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000;
165 private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800166 private static final int EVENT_QUERY_SMSC_DONE = 1005;
167 private static final int EVENT_UPDATE_SMSC_DONE = 1006;
168
169 private static final int MENU_ITEM_SELECT_BAND = 0;
170 private static final int MENU_ITEM_VIEW_ADN = 1;
171 private static final int MENU_ITEM_VIEW_FDN = 2;
172 private static final int MENU_ITEM_VIEW_SDN = 3;
Nathan Harolde272c202016-10-27 13:45:00 -0700173 private static final int MENU_ITEM_GET_IMS_STATUS = 4;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800174 private static final int MENU_ITEM_TOGGLE_DATA = 5;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800175
Wink Savillec3886682009-04-02 11:00:56 -0700176 private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800177 private TextView number;
Meng Wang9053f172017-06-23 16:02:14 -0700178 private TextView mSubscriberId;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800179 private TextView callState;
180 private TextView operatorName;
181 private TextView roamingState;
182 private TextView gsmState;
183 private TextView gprsState;
Nathan Harold2b77d742016-03-19 13:22:10 -0700184 private TextView voiceNetwork;
185 private TextView dataNetwork;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800186 private TextView dBm;
187 private TextView mMwi;
188 private TextView mCfi;
189 private TextView mLocation;
190 private TextView mNeighboringCids;
Wink Saville79bff2a2012-06-01 14:37:21 -0700191 private TextView mCellInfo;
Wink Saville4f0d8812014-04-15 22:05:24 -0700192 private TextView mDcRtInfoTv;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800193 private TextView sent;
194 private TextView received;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800195 private TextView mPingHostnameV4;
196 private TextView mPingHostnameV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800197 private TextView mHttpClientTest;
Nathan Harold433ca442018-04-23 18:20:43 -0700198 private TextView mPhyChanConfig;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800199 private TextView dnsCheckState;
200 private EditText smsc;
Nathan Harold2b77d742016-03-19 13:22:10 -0700201 private Switch radioPowerOnSwitch;
202 private Button cellInfoRefreshRateButton;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800203 private Button dnsCheckToggleButton;
204 private Button pingTestButton;
205 private Button updateSmscButton;
206 private Button refreshSmscButton;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800207 private Button oemInfoButton;
Youhan Wangfd781e92016-12-16 15:53:16 -0800208 private Button carrierProvisioningButton;
209 private Button triggercarrierProvisioningButton;
Nathan Harold12e1f552016-06-17 13:55:38 -0700210 private Switch imsVolteProvisionedSwitch;
211 private Switch imsVtProvisionedSwitch;
212 private Switch imsWfcProvisionedSwitch;
Meng Wang586741c2017-04-26 15:02:51 -0700213 private Switch eabProvisionedSwitch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800214 private Spinner preferredNetworkType;
Nathan Harold2b77d742016-03-19 13:22:10 -0700215 private Spinner cellInfoRefreshRateSpinner;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800216
217 private TelephonyManager mTelephonyManager;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800218 private ImsManager mImsManager = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800219 private Phone phone = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800220
Nathan Haroldcea413a2015-11-23 15:48:10 -0800221 private String mPingHostnameResultV4;
222 private String mPingHostnameResultV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800223 private String mHttpClientTestResult;
224 private boolean mMwiValue = false;
225 private boolean mCfiValue = false;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800226
227 private List<CellInfo> mCellInfoResult = null;
228 private CellLocation mCellLocationResult = null;
229 private List<NeighboringCellInfo> mNeighboringCellResult = null;
230
231 private int mPreferredNetworkTypeResult;
Nathan Harold2b77d742016-03-19 13:22:10 -0700232 private int mCellInfoRefreshRateIndex;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800233
Nathan Harold2b77d742016-03-19 13:22:10 -0700234 private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800235 @Override
236 public void onDataConnectionStateChanged(int state) {
237 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800238 updateNetworkType();
239 }
240
241 @Override
242 public void onDataActivity(int direction) {
243 updateDataStats2();
244 }
245
246 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700247 public void onCallStateChanged(int state, String incomingNumber) {
248 updateNetworkType();
249 updatePhoneState(state);
250 }
251
252 @Override
253 public void onPreciseCallStateChanged(PreciseCallState preciseState) {
254 updateNetworkType();
255 }
256
257 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800258 public void onCellLocationChanged(CellLocation location) {
259 updateLocation(location);
260 }
261
262 @Override
263 public void onMessageWaitingIndicatorChanged(boolean mwi) {
264 mMwiValue = mwi;
265 updateMessageWaiting();
266 }
267
268 @Override
269 public void onCallForwardingIndicatorChanged(boolean cfi) {
270 mCfiValue = cfi;
271 updateCallRedirect();
272 }
Wink Saville79bff2a2012-06-01 14:37:21 -0700273
274 @Override
275 public void onCellInfoChanged(List<CellInfo> arrayCi) {
Wink Savillebf471282013-04-05 15:04:05 -0700276 log("onCellInfoChanged: arrayCi=" + arrayCi);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800277 mCellInfoResult = arrayCi;
278 updateCellInfo(mCellInfoResult);
Wink Saville79bff2a2012-06-01 14:37:21 -0700279 }
Wink Saville4f0d8812014-04-15 22:05:24 -0700280
281 @Override
282 public void onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo) {
283 log("onDataConnectionRealTimeInfoChanged: dcRtInfo=" + dcRtInfo);
284 updateDcRtInfoTv(dcRtInfo);
285 }
Nathan Harold2b77d742016-03-19 13:22:10 -0700286
287 @Override
288 public void onSignalStrengthsChanged(SignalStrength signalStrength) {
289 log("onSignalStrengthChanged: SignalStrength=" +signalStrength);
290 updateSignalStrength(signalStrength);
291 }
292
293 @Override
294 public void onServiceStateChanged(ServiceState serviceState) {
295 log("onServiceStateChanged: ServiceState=" + serviceState);
296 updateServiceState(serviceState);
297 updateRadioPowerState();
298 updateNetworkType();
Nathan Harold12e1f552016-06-17 13:55:38 -0700299 updateImsProvisionedState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700300 }
Nathan Harold433ca442018-04-23 18:20:43 -0700301
302 @Override
303 public void onPhysicalChannelConfigurationChanged(
304 List<PhysicalChannelConfig> configs) {
305 updatePhysicalChannelConfiguration(configs);
306 }
307
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800308 };
309
Nathan Harold433ca442018-04-23 18:20:43 -0700310 private void updatePhysicalChannelConfiguration(List<PhysicalChannelConfig> configs) {
311 StringBuilder sb = new StringBuilder();
312 String div = "";
313 sb.append("{");
314 if (configs != null) {
315 for(PhysicalChannelConfig c : configs) {
316 sb.append(div).append(c);
317 div = ",";
318 }
319 }
320 sb.append("}");
321 mPhyChanConfig.setText(sb.toString());
322 }
323
Nathan Haroldcea413a2015-11-23 15:48:10 -0800324 private void updatePreferredNetworkType(int type) {
325 if (type >= mPreferredNetworkLabels.length || type < 0) {
326 log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
327 "type=" + type);
328 type = mPreferredNetworkLabels.length - 1; //set to Unknown
329 }
330 mPreferredNetworkTypeResult = type;
331
332 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
333 }
334
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800335 private Handler mHandler = new Handler() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800336 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800337 public void handleMessage(Message msg) {
338 AsyncResult ar;
339 switch (msg.what) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800340 case EVENT_QUERY_PREFERRED_TYPE_DONE:
341 ar= (AsyncResult) msg.obj;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800342 if (ar.exception == null && ar.result != null) {
343 updatePreferredNetworkType(((int[])ar.result)[0]);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800344 } else {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800345 //In case of an exception, we will set this to unknown
346 updatePreferredNetworkType(mPreferredNetworkLabels.length-1);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800347 }
348 break;
349 case EVENT_SET_PREFERRED_TYPE_DONE:
350 ar= (AsyncResult) msg.obj;
351 if (ar.exception != null) {
Nathan Harolded38afa2016-04-13 00:29:30 -0700352 log("Set preferred network type failed.");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800353 }
354 break;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800355 case EVENT_QUERY_SMSC_DONE:
356 ar= (AsyncResult) msg.obj;
357 if (ar.exception != null) {
358 smsc.setText("refresh error");
359 } else {
jsh21dd4072009-05-12 11:26:55 -0700360 smsc.setText((String)ar.result);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800361 }
362 break;
363 case EVENT_UPDATE_SMSC_DONE:
364 updateSmscButton.setEnabled(true);
365 ar= (AsyncResult) msg.obj;
366 if (ar.exception != null) {
367 smsc.setText("update error");
368 }
369 break;
370 default:
Nathan Haroldcea413a2015-11-23 15:48:10 -0800371 super.handleMessage(msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800372 break;
373
374 }
375 }
376 };
377
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800378 @Override
379 public void onCreate(Bundle icicle) {
380 super.onCreate(icicle);
fionaxub54cb2d2016-09-22 15:01:05 -0700381 if (!android.os.Process.myUserHandle().isSystem()) {
382 Log.e(TAG, "Not run from system user, don't do anything.");
383 finish();
384 return;
385 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800386
387 setContentView(R.layout.radio_info);
388
Nathan Haroldcea413a2015-11-23 15:48:10 -0800389 log("Started onCreate");
390
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800391 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
392 phone = PhoneFactory.getDefaultPhone();
393
Nathan Haroldcea413a2015-11-23 15:48:10 -0800394 //TODO: Need to update this if the default phoneId changes?
395 // Better to have an instance per phone?
396 mImsManager = ImsManager.getInstance(getApplicationContext(),
397 SubscriptionManager.getDefaultVoicePhoneId());
398
Meng Wang9053f172017-06-23 16:02:14 -0700399 mDeviceId = (TextView) findViewById(R.id.imei);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800400 number = (TextView) findViewById(R.id.number);
Meng Wang9053f172017-06-23 16:02:14 -0700401 mSubscriberId = (TextView) findViewById(R.id.imsi);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800402 callState = (TextView) findViewById(R.id.call);
403 operatorName = (TextView) findViewById(R.id.operator);
404 roamingState = (TextView) findViewById(R.id.roaming);
405 gsmState = (TextView) findViewById(R.id.gsm);
406 gprsState = (TextView) findViewById(R.id.gprs);
Nathan Harold2b77d742016-03-19 13:22:10 -0700407 voiceNetwork = (TextView) findViewById(R.id.voice_network);
408 dataNetwork = (TextView) findViewById(R.id.data_network);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800409 dBm = (TextView) findViewById(R.id.dbm);
410 mMwi = (TextView) findViewById(R.id.mwi);
411 mCfi = (TextView) findViewById(R.id.cfi);
412 mLocation = (TextView) findViewById(R.id.location);
413 mNeighboringCids = (TextView) findViewById(R.id.neighboring);
Wink Saville79bff2a2012-06-01 14:37:21 -0700414 mCellInfo = (TextView) findViewById(R.id.cellinfo);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800415 mCellInfo.setTypeface(Typeface.MONOSPACE);
Wink Saville4f0d8812014-04-15 22:05:24 -0700416 mDcRtInfoTv = (TextView) findViewById(R.id.dcrtinfo);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800417
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800418 sent = (TextView) findViewById(R.id.sent);
419 received = (TextView) findViewById(R.id.received);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800420 smsc = (EditText) findViewById(R.id.smsc);
421 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800422 mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4);
423 mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800424 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
425
Nathan Harold433ca442018-04-23 18:20:43 -0700426 mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config);
427
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800428 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
429 ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
430 android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
johnwang342101a2009-09-23 16:22:34 -0700431 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800432 preferredNetworkType.setAdapter(adapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800433
Nathan Harold2b77d742016-03-19 13:22:10 -0700434 cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select);
435 ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this,
436 android.R.layout.simple_spinner_item, mCellInfoRefreshRateLabels);
437 cellInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
438 cellInfoRefreshRateSpinner.setAdapter(cellInfoAdapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800439
Nathan Harold12e1f552016-06-17 13:55:38 -0700440 imsVolteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch);
441 imsVtProvisionedSwitch = (Switch) findViewById(R.id.vt_provisioned_switch);
442 imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
Meng Wang69439b52017-05-01 08:31:14 -0700443 eabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch);
Wink Savillebf471282013-04-05 15:04:05 -0700444
Nathan Harold2b77d742016-03-19 13:22:10 -0700445 radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
Wink Saville426fc662011-09-25 14:39:02 -0700446
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800447 pingTestButton = (Button) findViewById(R.id.ping_test);
448 pingTestButton.setOnClickListener(mPingButtonHandler);
449 updateSmscButton = (Button) findViewById(R.id.update_smsc);
450 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
451 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
452 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
453 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
454 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
Youhan Wangfd781e92016-12-16 15:53:16 -0800455 carrierProvisioningButton = (Button) findViewById(R.id.carrier_provisioning);
456 carrierProvisioningButton.setOnClickListener(mCarrierProvisioningButtonHandler);
457 triggercarrierProvisioningButton = (Button) findViewById(R.id.trigger_carrier_provisioning);
458 triggercarrierProvisioningButton.setOnClickListener(
459 mTriggerCarrierProvisioningButtonHandler);
johnwang342101a2009-09-23 16:22:34 -0700460
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800461 oemInfoButton = (Button) findViewById(R.id.oem_info);
462 oemInfoButton.setOnClickListener(mOemInfoButtonHandler);
463 PackageManager pm = getPackageManager();
464 Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO");
465 List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0);
466 if (oemInfoIntentList.size() == 0) {
467 oemInfoButton.setEnabled(false);
468 }
469
Nathan Harolded38afa2016-04-13 00:29:30 -0700470 mCellInfoRefreshRateIndex = 0; //disabled
Nathan Haroldcea413a2015-11-23 15:48:10 -0800471 mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown
472
473 //FIXME: Replace with TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800474 phone.getPreferredNetworkType(
475 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800476
Nathan Haroldcea413a2015-11-23 15:48:10 -0800477 restoreFromBundle(icicle);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800478 }
479
480 @Override
481 protected void onResume() {
482 super.onResume();
483
Nathan Haroldcea413a2015-11-23 15:48:10 -0800484 log("Started onResume");
485
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800486 updateMessageWaiting();
487 updateCallRedirect();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800488 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800489 updateDataStats2();
Nathan Harold2b77d742016-03-19 13:22:10 -0700490 updateRadioPowerState();
Nathan Harold12e1f552016-06-17 13:55:38 -0700491 updateImsProvisionedState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800492 updateProperties();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800493 updateDnsCheckState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700494 updateNetworkType();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800495
Nathan Haroldcea413a2015-11-23 15:48:10 -0800496 updateNeighboringCids(mNeighboringCellResult);
497 updateLocation(mCellLocationResult);
498 updateCellInfo(mCellInfoResult);
499
500 mPingHostnameV4.setText(mPingHostnameResultV4);
501 mPingHostnameV6.setText(mPingHostnameResultV6);
502 mHttpClientTest.setText(mHttpClientTestResult);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800503
Nathan Harold2b77d742016-03-19 13:22:10 -0700504 cellInfoRefreshRateSpinner.setOnItemSelectedListener(mCellInfoRefreshRateHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700505 //set selection after registering listener to force update
506 cellInfoRefreshRateSpinner.setSelection(mCellInfoRefreshRateIndex);
507
508 //set selection before registering to prevent update
509 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
Nathan Harold2b77d742016-03-19 13:22:10 -0700510 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700511
Nathan Harold2b77d742016-03-19 13:22:10 -0700512 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
Nathan Harold12e1f552016-06-17 13:55:38 -0700513 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
514 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
515 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Meng Wang586741c2017-04-26 15:02:51 -0700516 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
Nathan Harold2b77d742016-03-19 13:22:10 -0700517
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800518 mTelephonyManager.listen(mPhoneStateListener,
Nathan Harold2b77d742016-03-19 13:22:10 -0700519 PhoneStateListener.LISTEN_CALL_STATE
520 //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
521 // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
522 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800523 | PhoneStateListener.LISTEN_DATA_ACTIVITY
524 | PhoneStateListener.LISTEN_CELL_LOCATION
525 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
Wink Saville79bff2a2012-06-01 14:37:21 -0700526 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
Wink Saville4f0d8812014-04-15 22:05:24 -0700527 | PhoneStateListener.LISTEN_CELL_INFO
Nathan Harold2b77d742016-03-19 13:22:10 -0700528 | PhoneStateListener.LISTEN_SERVICE_STATE
529 | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
Nathan Harold433ca442018-04-23 18:20:43 -0700530 | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION);
Nathan Harolded38afa2016-04-13 00:29:30 -0700531
532 smsc.clearFocus();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800533 }
534
535 @Override
Nathan Haroldcea413a2015-11-23 15:48:10 -0800536 protected void onPause() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800537 super.onPause();
538
Wink Savillebf471282013-04-05 15:04:05 -0700539 log("onPause: unregister phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800540
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800541 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -0700542 mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800543 }
544
Nathan Haroldcea413a2015-11-23 15:48:10 -0800545 private void restoreFromBundle(Bundle b) {
Nathan Harolde272c202016-10-27 13:45:00 -0700546 if(b == null) {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800547 return;
548 }
549
550 mPingHostnameResultV4 = b.getString("mPingHostnameResultV4","");
551 mPingHostnameResultV6 = b.getString("mPingHostnameResultV6","");
552 mHttpClientTestResult = b.getString("mHttpClientTestResult","");
553
554 mPingHostnameV4.setText(mPingHostnameResultV4);
555 mPingHostnameV6.setText(mPingHostnameResultV6);
556 mHttpClientTest.setText(mHttpClientTestResult);
557
Nathan Harold2b77d742016-03-19 13:22:10 -0700558 mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult",
559 mPreferredNetworkLabels.length - 1);
560
561 mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800562 }
563
564 @Override
565 protected void onSaveInstanceState(Bundle outState) {
566 outState.putString("mPingHostnameResultV4", mPingHostnameResultV4);
567 outState.putString("mPingHostnameResultV6", mPingHostnameResultV6);
568 outState.putString("mHttpClientTestResult", mHttpClientTestResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700569
Nathan Haroldcea413a2015-11-23 15:48:10 -0800570 outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700571 outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex);
572
Nathan Haroldcea413a2015-11-23 15:48:10 -0800573 }
574
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800575 @Override
576 public boolean onCreateOptionsMenu(Menu menu) {
Wink Savillec3886682009-04-02 11:00:56 -0700577 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
578 .setOnMenuItemClickListener(mSelectBandCallback)
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800579 .setAlphabeticShortcut('b');
580 menu.add(1, MENU_ITEM_VIEW_ADN, 0,
581 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
582 menu.add(1, MENU_ITEM_VIEW_FDN, 0,
583 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
584 menu.add(1, MENU_ITEM_VIEW_SDN, 0,
585 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
Nathan Harolde272c202016-10-27 13:45:00 -0700586 menu.add(1, MENU_ITEM_GET_IMS_STATUS,
587 0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800588 menu.add(1, MENU_ITEM_TOGGLE_DATA,
Nathan Harold2b77d742016-03-19 13:22:10 -0700589 0, R.string.radio_info_data_connection_disable).setOnMenuItemClickListener(mToggleData);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800590 return true;
591 }
592
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800593 @Override
Wink Savillec3886682009-04-02 11:00:56 -0700594 public boolean onPrepareOptionsMenu(Menu menu) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800595 // Get the TOGGLE DATA menu item in the right state.
596 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
597 int state = mTelephonyManager.getDataState();
598 boolean visible = true;
599
600 switch (state) {
601 case TelephonyManager.DATA_CONNECTED:
602 case TelephonyManager.DATA_SUSPENDED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700603 item.setTitle(R.string.radio_info_data_connection_disable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800604 break;
605 case TelephonyManager.DATA_DISCONNECTED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700606 item.setTitle(R.string.radio_info_data_connection_enable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800607 break;
608 default:
609 visible = false;
610 break;
611 }
612 item.setVisible(visible);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800613 return true;
614 }
615
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800616 private void updateDnsCheckState() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800617 //FIXME: Replace with a TelephonyManager call
Mike Lockwood5304c7e2009-04-05 11:37:45 -0700618 dnsCheckState.setText(phone.isDnsCheckDisabled() ?
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800619 "0.0.0.0 allowed" :"0.0.0.0 not allowed");
620 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700621
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800622 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700623 updateSignalStrength(SignalStrength signalStrength) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800624 Resources r = getResources();
625
Nathan Harold2b77d742016-03-19 13:22:10 -0700626 int signalDbm = signalStrength.getDbm();
Wink Savillee2a14e32009-05-29 14:06:30 -0700627
Nathan Harold2b77d742016-03-19 13:22:10 -0700628 int signalAsu = signalStrength.getAsuLevel();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800629
630 if (-1 == signalAsu) signalAsu = 0;
631
632 dBm.setText(String.valueOf(signalDbm) + " "
633 + r.getString(R.string.radioInfo_display_dbm) + " "
634 + String.valueOf(signalAsu) + " "
635 + r.getString(R.string.radioInfo_display_asu));
636 }
637
638 private final void updateLocation(CellLocation location) {
jsh534f5ae2009-09-24 09:19:22 -0700639 Resources r = getResources();
Wink Savillec3886682009-04-02 11:00:56 -0700640 if (location instanceof GsmCellLocation) {
641 GsmCellLocation loc = (GsmCellLocation)location;
jsh534f5ae2009-09-24 09:19:22 -0700642 int lac = loc.getLac();
643 int cid = loc.getCid();
644 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
645 + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
646 + " "
647 + r.getString(R.string.radioInfo_cid) + " = "
648 + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
649 } else if (location instanceof CdmaCellLocation) {
650 CdmaCellLocation loc = (CdmaCellLocation)location;
651 int bid = loc.getBaseStationId();
652 int sid = loc.getSystemId();
653 int nid = loc.getNetworkId();
654 int lat = loc.getBaseStationLatitude();
655 int lon = loc.getBaseStationLongitude();
656 mLocation.setText("BID = "
657 + ((bid == -1) ? "unknown" : Integer.toHexString(bid))
658 + " "
659 + "SID = "
660 + ((sid == -1) ? "unknown" : Integer.toHexString(sid))
661 + " "
662 + "NID = "
663 + ((nid == -1) ? "unknown" : Integer.toHexString(nid))
664 + "\n"
665 + "LAT = "
666 + ((lat == -1) ? "unknown" : Integer.toHexString(lat))
667 + " "
668 + "LONG = "
669 + ((lon == -1) ? "unknown" : Integer.toHexString(lon)));
670 } else {
671 mLocation.setText("unknown");
Wink Savillec3886682009-04-02 11:00:56 -0700672 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800673
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800674
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800675 }
676
Nathan Haroldcea413a2015-11-23 15:48:10 -0800677 private final void updateNeighboringCids(List<NeighboringCellInfo> cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700678 StringBuilder sb = new StringBuilder();
679
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800680 if (cids != null) {
Nathan Harolde272c202016-10-27 13:45:00 -0700681 if (cids.isEmpty()) {
johnwangf02c65f2009-09-25 17:26:54 -0700682 sb.append("no neighboring cells");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800683 } else {
684 for (NeighboringCellInfo cell : cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700685 sb.append(cell.toString()).append(" ");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800686 }
687 }
688 } else {
johnwangf02c65f2009-09-25 17:26:54 -0700689 sb.append("unknown");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800690 }
johnwangf02c65f2009-09-25 17:26:54 -0700691 mNeighboringCids.setText(sb.toString());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800692 }
693
Nathan Haroldcea413a2015-11-23 15:48:10 -0800694 private final String getCellInfoDisplayString(int i) {
695 return (i != Integer.MAX_VALUE) ? Integer.toString(i) : "";
696 }
697
698 private final String getCellInfoDisplayString(long i) {
699 return (i != Long.MAX_VALUE) ? Long.toString(i) : "";
700 }
701
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700702 private final String getConnectionStatusString(CellInfo ci) {
703 String regStr = "";
704 String connStatStr = "";
705 String connector = "";
706
707 if (ci.isRegistered()) {
708 regStr = "R";
709 }
710 switch (ci.getCellConnectionStatus()) {
711 case CellInfo.CONNECTION_PRIMARY_SERVING: connStatStr = "P"; break;
712 case CellInfo.CONNECTION_SECONDARY_SERVING: connStatStr = "S"; break;
713 case CellInfo.CONNECTION_NONE: connStatStr = "N"; break;
714 case CellInfo.CONNECTION_UNKNOWN: /* Field is unsupported */ break;
715 default: break;
716 }
717 if (!TextUtils.isEmpty(regStr) && !TextUtils.isEmpty(connStatStr)) {
718 connector = "+";
719 }
720
721 return regStr + connector + connStatStr;
722 }
723
Nathan Haroldcea413a2015-11-23 15:48:10 -0800724 private final String buildCdmaInfoString(CellInfoCdma ci) {
725 CellIdentityCdma cidCdma = ci.getCellIdentity();
726 CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
727
728 return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s",
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700729 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800730 getCellInfoDisplayString(cidCdma.getSystemId()),
731 getCellInfoDisplayString(cidCdma.getNetworkId()),
732 getCellInfoDisplayString(cidCdma.getBasestationId()),
733 getCellInfoDisplayString(ssCdma.getCdmaDbm()),
734 getCellInfoDisplayString(ssCdma.getCdmaEcio()),
735 getCellInfoDisplayString(ssCdma.getEvdoDbm()),
736 getCellInfoDisplayString(ssCdma.getEvdoEcio()),
737 getCellInfoDisplayString(ssCdma.getEvdoSnr()));
738 }
739
740 private final String buildGsmInfoString(CellInfoGsm ci) {
741 CellIdentityGsm cidGsm = ci.getCellIdentity();
742 CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
743
Nathan Harold2b77d742016-03-19 13:22:10 -0700744 return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700745 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800746 getCellInfoDisplayString(cidGsm.getMcc()),
747 getCellInfoDisplayString(cidGsm.getMnc()),
748 getCellInfoDisplayString(cidGsm.getLac()),
749 getCellInfoDisplayString(cidGsm.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700750 getCellInfoDisplayString(cidGsm.getArfcn()),
751 getCellInfoDisplayString(cidGsm.getBsic()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800752 getCellInfoDisplayString(ssGsm.getDbm()));
753 }
754
755 private final String buildLteInfoString(CellInfoLte ci) {
756 CellIdentityLte cidLte = ci.getCellIdentity();
757 CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
758
759 return String.format(
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700760 "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
761 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800762 getCellInfoDisplayString(cidLte.getMcc()),
763 getCellInfoDisplayString(cidLte.getMnc()),
764 getCellInfoDisplayString(cidLte.getTac()),
765 getCellInfoDisplayString(cidLte.getCi()),
766 getCellInfoDisplayString(cidLte.getPci()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700767 getCellInfoDisplayString(cidLte.getEarfcn()),
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700768 getCellInfoDisplayString(cidLte.getBandwidth()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800769 getCellInfoDisplayString(ssLte.getDbm()),
770 getCellInfoDisplayString(ssLte.getRsrq()),
771 getCellInfoDisplayString(ssLte.getTimingAdvance()));
772 }
773
774 private final String buildWcdmaInfoString(CellInfoWcdma ci) {
775 CellIdentityWcdma cidWcdma = ci.getCellIdentity();
776 CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength();
777
Nathan Harold2b77d742016-03-19 13:22:10 -0700778 return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700779 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800780 getCellInfoDisplayString(cidWcdma.getMcc()),
781 getCellInfoDisplayString(cidWcdma.getMnc()),
782 getCellInfoDisplayString(cidWcdma.getLac()),
783 getCellInfoDisplayString(cidWcdma.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700784 getCellInfoDisplayString(cidWcdma.getUarfcn()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800785 getCellInfoDisplayString(cidWcdma.getPsc()),
786 getCellInfoDisplayString(ssWcdma.getDbm()));
787 }
788
789 private final String buildCellInfoString(List<CellInfo> arrayCi) {
790 String value = new String();
791 StringBuilder cdmaCells = new StringBuilder(),
792 gsmCells = new StringBuilder(),
793 lteCells = new StringBuilder(),
794 wcdmaCells = new StringBuilder();
795
796 if (arrayCi != null) {
797 for (CellInfo ci : arrayCi) {
798
799 if (ci instanceof CellInfoLte) {
800 lteCells.append(buildLteInfoString((CellInfoLte) ci));
801 } else if (ci instanceof CellInfoWcdma) {
802 wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
803 } else if (ci instanceof CellInfoGsm) {
804 gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
805 } else if (ci instanceof CellInfoCdma) {
806 cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
Wink Saville79bff2a2012-06-01 14:37:21 -0700807 }
808 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800809 if (lteCells.length() != 0) {
810 value += String.format(
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700811 "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s"
812 + " %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
813 "SRV", "MCC", "MNC", "TAC", "CID", "PCI",
814 "EARFCN", "BW", "RSRP", "RSRQ", "TA");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800815 value += lteCells.toString();
816 }
817 if (wcdmaCells.length() != 0) {
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700818 value += String.format(
819 "WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
Nathan Harold2b77d742016-03-19 13:22:10 -0700820 "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800821 value += wcdmaCells.toString();
822 }
823 if (gsmCells.length() != 0) {
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700824 value += String.format(
825 "GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
Nathan Harold2b77d742016-03-19 13:22:10 -0700826 "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800827 value += gsmCells.toString();
828 }
829 if (cdmaCells.length() != 0) {
830 value += String.format(
831 "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n",
832 "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
833 value += cdmaCells.toString();
834 }
835 } else {
836 value ="unknown";
Wink Saville79bff2a2012-06-01 14:37:21 -0700837 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800838
839 return value.toString();
840 }
841
842 private final void updateCellInfo(List<CellInfo> arrayCi) {
843 mCellInfo.setText(buildCellInfoString(arrayCi));
Wink Saville79bff2a2012-06-01 14:37:21 -0700844 }
845
Wink Saville4f0d8812014-04-15 22:05:24 -0700846 private final void updateDcRtInfoTv(DataConnectionRealTimeInfo dcRtInfo) {
847 mDcRtInfoTv.setText(dcRtInfo.toString());
848 }
849
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800850 private final void
851 updateMessageWaiting() {
852 mMwi.setText(String.valueOf(mMwiValue));
853 }
854
855 private final void
856 updateCallRedirect() {
857 mCfi.setText(String.valueOf(mCfiValue));
858 }
859
860
861 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700862 updateServiceState(ServiceState serviceState) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800863 int state = serviceState.getState();
864 Resources r = getResources();
865 String display = r.getString(R.string.radioInfo_unknown);
johnwang342101a2009-09-23 16:22:34 -0700866
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800867 switch (state) {
868 case ServiceState.STATE_IN_SERVICE:
869 display = r.getString(R.string.radioInfo_service_in);
870 break;
871 case ServiceState.STATE_OUT_OF_SERVICE:
872 case ServiceState.STATE_EMERGENCY_ONLY:
873 display = r.getString(R.string.radioInfo_service_emergency);
874 break;
875 case ServiceState.STATE_POWER_OFF:
876 display = r.getString(R.string.radioInfo_service_off);
877 break;
878 }
johnwang342101a2009-09-23 16:22:34 -0700879
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800880 gsmState.setText(display);
johnwang342101a2009-09-23 16:22:34 -0700881
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800882 if (serviceState.getRoaming()) {
883 roamingState.setText(R.string.radioInfo_roaming_in);
884 } else {
885 roamingState.setText(R.string.radioInfo_roaming_not);
886 }
887
888 operatorName.setText(serviceState.getOperatorAlphaLong());
889 }
890
891 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700892 updatePhoneState(int state) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800893 Resources r = getResources();
894 String display = r.getString(R.string.radioInfo_unknown);
895
896 switch (state) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700897 case TelephonyManager.CALL_STATE_IDLE:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800898 display = r.getString(R.string.radioInfo_phone_idle);
899 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700900 case TelephonyManager.CALL_STATE_RINGING:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800901 display = r.getString(R.string.radioInfo_phone_ringing);
902 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700903 case TelephonyManager.CALL_STATE_OFFHOOK:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800904 display = r.getString(R.string.radioInfo_phone_offhook);
905 break;
906 }
907
908 callState.setText(display);
909 }
910
911 private final void
912 updateDataState() {
913 int state = mTelephonyManager.getDataState();
914 Resources r = getResources();
915 String display = r.getString(R.string.radioInfo_unknown);
916
917 switch (state) {
918 case TelephonyManager.DATA_CONNECTED:
919 display = r.getString(R.string.radioInfo_data_connected);
920 break;
921 case TelephonyManager.DATA_CONNECTING:
922 display = r.getString(R.string.radioInfo_data_connecting);
923 break;
924 case TelephonyManager.DATA_DISCONNECTED:
925 display = r.getString(R.string.radioInfo_data_disconnected);
926 break;
927 case TelephonyManager.DATA_SUSPENDED:
928 display = r.getString(R.string.radioInfo_data_suspended);
929 break;
930 }
johnwang342101a2009-09-23 16:22:34 -0700931
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800932 gprsState.setText(display);
933 }
934
935 private final void updateNetworkType() {
Nathan Harolde272c202016-10-27 13:45:00 -0700936 if(phone != null) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700937 ServiceState ss = phone.getServiceState();
938 dataNetwork.setText(ServiceState.rilRadioTechnologyToString(
939 phone.getServiceState().getRilDataRadioTechnology()));
940 voiceNetwork.setText(ServiceState.rilRadioTechnologyToString(
941 phone.getServiceState().getRilVoiceRadioTechnology()));
942 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800943 }
944
945 private final void
946 updateProperties() {
947 String s;
948 Resources r = getResources();
949
950 s = phone.getDeviceId();
johnwang342101a2009-09-23 16:22:34 -0700951 if (s == null) s = r.getString(R.string.radioInfo_unknown);
Wink Savillec3886682009-04-02 11:00:56 -0700952 mDeviceId.setText(s);
johnwang342101a2009-09-23 16:22:34 -0700953
Meng Wang9053f172017-06-23 16:02:14 -0700954 s = phone.getSubscriberId();
955 if (s == null) s = r.getString(R.string.radioInfo_unknown);
956 mSubscriberId.setText(s);
957
Nathan Haroldcea413a2015-11-23 15:48:10 -0800958 //FIXME: Replace with a TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800959 s = phone.getLine1Number();
johnwang342101a2009-09-23 16:22:34 -0700960 if (s == null) s = r.getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800961 number.setText(s);
962 }
963
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800964 private final void updateDataStats2() {
965 Resources r = getResources();
966
Jeff Sharkey93029862011-05-27 18:26:15 -0700967 long txPackets = TrafficStats.getMobileTxPackets();
968 long rxPackets = TrafficStats.getMobileRxPackets();
969 long txBytes = TrafficStats.getMobileTxBytes();
970 long rxBytes = TrafficStats.getMobileRxBytes();
johnwang342101a2009-09-23 16:22:34 -0700971
Jeff Sharkey93029862011-05-27 18:26:15 -0700972 String packets = r.getString(R.string.radioInfo_display_packets);
973 String bytes = r.getString(R.string.radioInfo_display_bytes);
johnwang342101a2009-09-23 16:22:34 -0700974
Jeff Sharkey93029862011-05-27 18:26:15 -0700975 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
976 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800977 }
978
979 /**
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800980 * Ping a host name
981 */
982 private final void pingHostname() {
983 try {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800984 try {
985 Process p4 = Runtime.getRuntime().exec("ping -c 1 www.google.com");
986 int status4 = p4.waitFor();
987 if (status4 == 0) {
988 mPingHostnameResultV4 = "Pass";
989 } else {
990 mPingHostnameResultV4 = String.format("Fail(%d)", status4);
991 }
992 } catch (IOException e) {
993 mPingHostnameResultV4 = "Fail: IOException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800994 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800995 try {
996 Process p6 = Runtime.getRuntime().exec("ping6 -c 1 www.google.com");
997 int status6 = p6.waitFor();
998 if (status6 == 0) {
999 mPingHostnameResultV6 = "Pass";
1000 } else {
1001 mPingHostnameResultV6 = String.format("Fail(%d)", status6);
1002 }
1003 } catch (IOException e) {
1004 mPingHostnameResultV6 = "Fail: IOException";
1005 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001006 } catch (InterruptedException e) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001007 mPingHostnameResultV4 = mPingHostnameResultV6 = "Fail: InterruptedException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001008 }
1009 }
1010
1011 /**
1012 * This function checks for basic functionality of HTTP Client.
1013 */
1014 private void httpClientTest() {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001015 HttpURLConnection urlConnection = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001016 try {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001017 // TODO: Hardcoded for now, make it UI configurable
Alex Klyubinb0090232015-04-02 11:08:51 -07001018 URL url = new URL("https://www.google.com");
Narayan Kamathf25627c2014-12-12 13:53:28 +00001019 urlConnection = (HttpURLConnection) url.openConnection();
1020 if (urlConnection.getResponseCode() == 200) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001021 mHttpClientTestResult = "Pass";
1022 } else {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001023 mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001024 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001025 } catch (IOException e) {
1026 mHttpClientTestResult = "Fail: IOException";
Narayan Kamathf25627c2014-12-12 13:53:28 +00001027 } finally {
1028 if (urlConnection != null) {
1029 urlConnection.disconnect();
1030 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001031 }
1032 }
1033
1034 private void refreshSmsc() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001035 //FIXME: Replace with a TelephonyManager call
jsh21dd4072009-05-12 11:26:55 -07001036 phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001037 }
1038
Nathan Haroldcea413a2015-11-23 15:48:10 -08001039 private final void updateAllCellInfo() {
1040
1041 mCellInfo.setText("");
1042 mNeighboringCids.setText("");
1043 mLocation.setText("");
1044
1045 final Runnable updateAllCellInfoResults = new Runnable() {
1046 public void run() {
1047 updateNeighboringCids(mNeighboringCellResult);
1048 updateLocation(mCellLocationResult);
1049 updateCellInfo(mCellInfoResult);
1050 }
1051 };
1052
1053 Thread locThread = new Thread() {
1054 @Override
1055 public void run() {
1056 mCellInfoResult = mTelephonyManager.getAllCellInfo();
1057 mCellLocationResult = mTelephonyManager.getCellLocation();
1058 mNeighboringCellResult = mTelephonyManager.getNeighboringCellInfo();
1059
1060 mHandler.post(updateAllCellInfoResults);
1061 }
1062 };
1063 locThread.start();
1064 }
1065
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001066 private final void updatePingState() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001067 // Set all to unknown since the threads will take a few secs to update.
Nathan Haroldcea413a2015-11-23 15:48:10 -08001068 mPingHostnameResultV4 = getResources().getString(R.string.radioInfo_unknown);
1069 mPingHostnameResultV6 = getResources().getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001070 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
1071
Nathan Haroldcea413a2015-11-23 15:48:10 -08001072 mPingHostnameV4.setText(mPingHostnameResultV4);
1073 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001074 mHttpClientTest.setText(mHttpClientTestResult);
1075
1076 final Runnable updatePingResults = new Runnable() {
1077 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001078 mPingHostnameV4.setText(mPingHostnameResultV4);
1079 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001080 mHttpClientTest.setText(mHttpClientTestResult);
1081 }
1082 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001083
1084 Thread hostname = new Thread() {
1085 @Override
1086 public void run() {
1087 pingHostname();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001088 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001089 }
1090 };
1091 hostname.start();
1092
1093 Thread httpClient = new Thread() {
1094 @Override
1095 public void run() {
1096 httpClientTest();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001097 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001098 }
1099 };
1100 httpClient.start();
1101 }
1102
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001103 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
1104 public boolean onMenuItemClick(MenuItem item) {
1105 Intent intent = new Intent(Intent.ACTION_VIEW);
1106 // XXX We need to specify the component here because if we don't
1107 // the activity manager will try to resolve the type by calling
1108 // the content provider, which causes it to be loaded in a process
1109 // other than the Dialer process, which causes a lot of stuff to
1110 // break.
1111 intent.setClassName("com.android.phone",
1112 "com.android.phone.SimContacts");
1113 startActivity(intent);
1114 return true;
1115 }
1116 };
1117
1118 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
1119 public boolean onMenuItemClick(MenuItem item) {
1120 Intent intent = new Intent(Intent.ACTION_VIEW);
1121 // XXX We need to specify the component here because if we don't
1122 // the activity manager will try to resolve the type by calling
1123 // the content provider, which causes it to be loaded in a process
1124 // other than the Dialer process, which causes a lot of stuff to
1125 // break.
1126 intent.setClassName("com.android.phone",
Andrew Leeda90d682014-10-31 13:12:20 -07001127 "com.android.phone.settings.fdn.FdnList");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001128 startActivity(intent);
1129 return true;
1130 }
1131 };
1132
1133 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
1134 public boolean onMenuItemClick(MenuItem item) {
1135 Intent intent = new Intent(
Wink Savillec3886682009-04-02 11:00:56 -07001136 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001137 // XXX We need to specify the component here because if we don't
1138 // the activity manager will try to resolve the type by calling
1139 // the content provider, which causes it to be loaded in a process
1140 // other than the Dialer process, which causes a lot of stuff to
1141 // break.
1142 intent.setClassName("com.android.phone",
1143 "com.android.phone.ADNList");
1144 startActivity(intent);
1145 return true;
1146 }
1147 };
1148
Nathan Harolde272c202016-10-27 13:45:00 -07001149 private MenuItem.OnMenuItemClickListener mGetImsStatus = new MenuItem.OnMenuItemClickListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001150 public boolean onMenuItemClick(MenuItem item) {
Nathan Harolde272c202016-10-27 13:45:00 -07001151 boolean isImsRegistered = phone.isImsRegistered();
1152 boolean availableVolte = phone.isVolteEnabled();
1153 boolean availableWfc = phone.isWifiCallingEnabled();
1154 boolean availableVt = phone.isVideoEnabled();
1155 boolean availableUt = phone.isUtEnabled();
1156
1157 final String imsRegString = isImsRegistered ?
1158 getString(R.string.radio_info_ims_reg_status_registered) :
1159 getString(R.string.radio_info_ims_reg_status_not_registered);
1160
1161 final String available = getString(R.string.radio_info_ims_feature_status_available);
1162 final String unavailable = getString(
1163 R.string.radio_info_ims_feature_status_unavailable);
1164
1165 String imsStatus = getString(R.string.radio_info_ims_reg_status,
1166 imsRegString,
1167 availableVolte ? available : unavailable,
1168 availableWfc ? available : unavailable,
1169 availableVt ? available : unavailable,
1170 availableUt ? available : unavailable);
1171
1172 AlertDialog imsDialog = new AlertDialog.Builder(RadioInfo.this)
1173 .setMessage(imsStatus)
1174 .setTitle(getString(R.string.radio_info_ims_reg_status_title))
1175 .create();
1176
1177 imsDialog.show();
1178
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001179 return true;
1180 }
1181 };
1182
1183 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
1184 public boolean onMenuItemClick(MenuItem item) {
1185 Intent intent = new Intent();
1186 intent.setClass(RadioInfo.this, BandMode.class);
1187 startActivity(intent);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001188 return true;
1189 }
1190 };
johnwang342101a2009-09-23 16:22:34 -07001191
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001192 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
1193 public boolean onMenuItemClick(MenuItem item) {
1194 int state = mTelephonyManager.getDataState();
1195 switch (state) {
1196 case TelephonyManager.DATA_CONNECTED:
Nathan Haroldcea413a2015-11-23 15:48:10 -08001197 //FIXME: Replace with a TelephonyManager call
Malcolm Chenf612f592017-11-29 18:01:25 -08001198 phone.setUserDataEnabled(false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001199 break;
1200 case TelephonyManager.DATA_DISCONNECTED:
Nathan Haroldcea413a2015-11-23 15:48:10 -08001201 //FIXME: Replace with a TelephonyManager call
Malcolm Chenf612f592017-11-29 18:01:25 -08001202 phone.setUserDataEnabled(true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001203 break;
1204 default:
1205 // do nothing
1206 break;
1207 }
1208 return true;
1209 }
1210 };
1211
Nathan Harold2b77d742016-03-19 13:22:10 -07001212 private boolean isRadioOn() {
1213 //FIXME: Replace with a TelephonyManager call
1214 return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
1215 }
1216
1217 private void updateRadioPowerState() {
1218 //delightful hack to prevent on-checked-changed calls from
1219 //actually forcing the radio preference to its transient/current value.
1220 radioPowerOnSwitch.setOnCheckedChangeListener(null);
1221 radioPowerOnSwitch.setChecked(isRadioOn());
1222 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
1223 }
1224
Nathan Harolde272c202016-10-27 13:45:00 -07001225 void setImsVolteProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001226 Log.d(TAG, "setImsVolteProvisioned state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001227 setImsConfigProvisionedState(IMS_VOLTE_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001228 }
1229
Nathan Harolde272c202016-10-27 13:45:00 -07001230 void setImsVtProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001231 Log.d(TAG, "setImsVtProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001232 setImsConfigProvisionedState(IMS_VT_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001233 }
1234
Nathan Harolde272c202016-10-27 13:45:00 -07001235 void setImsWfcProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001236 Log.d(TAG, "setImsWfcProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001237 setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001238 }
1239
Meng Wang586741c2017-04-26 15:02:51 -07001240 void setEabProvisionedState(boolean state) {
1241 Log.d(TAG, "setEabProvisioned() state: " + ((state)? "on":"off"));
1242 setImsConfigProvisionedState(EAB_PROVISIONED_CONFIG_ID, state);
1243 }
1244
Nathan Harolde272c202016-10-27 13:45:00 -07001245 void setImsConfigProvisionedState(int configItem, boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001246 if (phone != null && mImsManager != null) {
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001247 QueuedWork.queue(new Runnable() {
Nathan Harold12e1f552016-06-17 13:55:38 -07001248 public void run() {
1249 try {
1250 mImsManager.getConfigInterface().setProvisionedValue(
1251 configItem,
1252 state? 1 : 0);
1253 } catch (ImsException e) {
1254 Log.e(TAG, "setImsConfigProvisioned() exception:", e);
1255 }
1256 }
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001257 }, false);
Nathan Harold12e1f552016-06-17 13:55:38 -07001258 }
1259 }
1260
Nathan Harold2b77d742016-03-19 13:22:10 -07001261 OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() {
1262 @Override
1263 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1264 log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
1265 phone.setRadioPower(isChecked);
1266 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001267 };
1268
Nathan Harold12e1f552016-06-17 13:55:38 -07001269 private boolean isImsVolteProvisioned() {
Nathan Harold2b77d742016-03-19 13:22:10 -07001270 if (phone != null && mImsManager != null) {
1271 return mImsManager.isVolteEnabledByPlatform(phone.getContext())
1272 && mImsManager.isVolteProvisionedOnDevice(phone.getContext());
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -08001273 }
1274 return false;
1275 }
1276
Nathan Harold12e1f552016-06-17 13:55:38 -07001277 OnCheckedChangeListener mImsVolteCheckedChangeListener = new OnCheckedChangeListener() {
Wink Saville426fc662011-09-25 14:39:02 -07001278 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -07001279 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001280 setImsVolteProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001281 }
Wink Saville426fc662011-09-25 14:39:02 -07001282 };
1283
Nathan Harold12e1f552016-06-17 13:55:38 -07001284 private boolean isImsVtProvisioned() {
1285 if (phone != null && mImsManager != null) {
1286 return mImsManager.isVtEnabledByPlatform(phone.getContext())
1287 && mImsManager.isVtProvisionedOnDevice(phone.getContext());
1288 }
1289 return false;
1290 }
1291
1292 OnCheckedChangeListener mImsVtCheckedChangeListener = new OnCheckedChangeListener() {
1293 @Override
1294 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1295 setImsVtProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001296 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001297 };
1298
1299 private boolean isImsWfcProvisioned() {
1300 if (phone != null && mImsManager != null) {
1301 return mImsManager.isWfcEnabledByPlatform(phone.getContext())
1302 && mImsManager.isWfcProvisionedOnDevice(phone.getContext());
1303 }
1304 return false;
1305 }
1306
1307 OnCheckedChangeListener mImsWfcCheckedChangeListener = new OnCheckedChangeListener() {
1308 @Override
1309 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1310 setImsWfcProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001311 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001312 };
1313
Meng Wang586741c2017-04-26 15:02:51 -07001314 private boolean isEabProvisioned() {
1315 return isFeatureProvisioned(EAB_PROVISIONED_CONFIG_ID, false);
1316 }
1317
1318 OnCheckedChangeListener mEabCheckedChangeListener = new OnCheckedChangeListener() {
1319 @Override
1320 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1321 setEabProvisionedState(isChecked);
1322 }
1323 };
1324
1325 private boolean isFeatureProvisioned(int featureId, boolean defaultValue) {
1326 boolean provisioned = defaultValue;
1327 if (mImsManager != null) {
1328 try {
1329 ImsConfig imsConfig = mImsManager.getConfigInterface();
1330 if (imsConfig != null) {
1331 provisioned =
1332 (imsConfig.getProvisionedValue(featureId)
1333 == ImsConfig.FeatureValueConstants.ON);
1334 }
1335 } catch (ImsException ex) {
1336 Log.e(TAG, "isFeatureProvisioned() exception:", ex);
1337 }
1338 }
1339
1340 log("isFeatureProvisioned() featureId=" + featureId + " provisioned=" + provisioned);
1341 return provisioned;
1342 }
1343
1344 private static boolean isEabEnabledByPlatform(Context context) {
1345 if (context != null) {
1346 CarrierConfigManager configManager = (CarrierConfigManager)
1347 context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
1348 if (configManager != null && configManager.getConfig().getBoolean(
1349 CarrierConfigManager.KEY_USE_RCS_PRESENCE_BOOL)) {
1350 return true;
1351 }
1352 }
1353 return false;
1354 }
1355
Nathan Harold12e1f552016-06-17 13:55:38 -07001356 private void updateImsProvisionedState() {
1357 log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
Nathan Harold2b77d742016-03-19 13:22:10 -07001358 //delightful hack to prevent on-checked-changed calls from
1359 //actually forcing the ims provisioning to its transient/current value.
Nathan Harold12e1f552016-06-17 13:55:38 -07001360 imsVolteProvisionedSwitch.setOnCheckedChangeListener(null);
1361 imsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned());
1362 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001363 imsVolteProvisionedSwitch.setEnabled(
1364 mImsManager.isVolteEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001365
1366 imsVtProvisionedSwitch.setOnCheckedChangeListener(null);
1367 imsVtProvisionedSwitch.setChecked(isImsVtProvisioned());
1368 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001369 imsVtProvisionedSwitch.setEnabled(
1370 mImsManager.isVtEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001371
1372 imsWfcProvisionedSwitch.setOnCheckedChangeListener(null);
1373 imsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned());
1374 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001375 imsWfcProvisionedSwitch.setEnabled(
1376 mImsManager.isWfcEnabledByPlatform(phone.getContext()));
Meng Wang586741c2017-04-26 15:02:51 -07001377
1378 eabProvisionedSwitch.setOnCheckedChangeListener(null);
1379 eabProvisionedSwitch.setChecked(isEabProvisioned());
1380 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
1381 eabProvisionedSwitch.setEnabled(isEabEnabledByPlatform(phone.getContext()));
Wink Saville426fc662011-09-25 14:39:02 -07001382 }
1383
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001384 OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
1385 public void onClick(View v) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001386 //FIXME: Replace with a TelephonyManager call
Wink Savillec3886682009-04-02 11:00:56 -07001387 phone.disableDnsCheck(!phone.isDnsCheckDisabled());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001388 updateDnsCheckState();
1389 }
1390 };
johnwang342101a2009-09-23 16:22:34 -07001391
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001392 OnClickListener mOemInfoButtonHandler = new OnClickListener() {
1393 public void onClick(View v) {
1394 Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO");
1395 try {
1396 startActivity(intent);
1397 } catch (android.content.ActivityNotFoundException ex) {
Wink Savillebf471282013-04-05 15:04:05 -07001398 log("OEM-specific Info/Settings Activity Not Found : " + ex);
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001399 // If the activity does not exist, there are no OEM
1400 // settings, and so we can just do nothing...
1401 }
1402 }
1403 };
1404
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001405 OnClickListener mPingButtonHandler = new OnClickListener() {
1406 public void onClick(View v) {
1407 updatePingState();
1408 }
1409 };
1410
1411 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
1412 public void onClick(View v) {
1413 updateSmscButton.setEnabled(false);
jsh21dd4072009-05-12 11:26:55 -07001414 phone.setSmscAddress(smsc.getText().toString(),
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001415 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
1416 }
1417 };
1418
1419 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
1420 public void onClick(View v) {
1421 refreshSmsc();
1422 }
1423 };
1424
Youhan Wangfd781e92016-12-16 15:53:16 -08001425 OnClickListener mCarrierProvisioningButtonHandler = new OnClickListener() {
1426 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001427 final Intent intent = new Intent("com.android.settings.CARRIER_PROVISIONING");
1428 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1429 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001430 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001431 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001432 }
1433 };
1434
1435 OnClickListener mTriggerCarrierProvisioningButtonHandler = new OnClickListener() {
1436 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001437 final Intent intent = new Intent("com.android.settings.TRIGGER_CARRIER_PROVISIONING");
1438 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1439 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001440 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001441 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001442 }
1443 };
1444
Nathan Haroldcea413a2015-11-23 15:48:10 -08001445 AdapterView.OnItemSelectedListener mPreferredNetworkHandler =
1446 new AdapterView.OnItemSelectedListener() {
1447
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001448 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001449 if (mPreferredNetworkTypeResult != pos && pos >= 0
1450 && pos <= mPreferredNetworkLabels.length - 2) {
1451 mPreferredNetworkTypeResult = pos;
1452 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
1453 phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001454 }
1455 }
1456
1457 public void onNothingSelected(AdapterView parent) {
1458 }
1459 };
1460
Nathan Harold2b77d742016-03-19 13:22:10 -07001461 AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler =
1462 new AdapterView.OnItemSelectedListener() {
Wink Savillebf471282013-04-05 15:04:05 -07001463
Nathan Harold2b77d742016-03-19 13:22:10 -07001464 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1465 mCellInfoRefreshRateIndex = pos;
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -07001466 mTelephonyManager.setCellInfoListRate(mCellInfoRefreshRates[pos]);
Nathan Harold2b77d742016-03-19 13:22:10 -07001467 updateAllCellInfo();
1468 }
1469
1470 public void onNothingSelected(AdapterView parent) {
1471 }
1472 };
1473
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001474}