blob: 5c6fe9cc4cdb88877b51d8951e13effa1af89b6c [file] [log] [blame]
Jordan Liu4cb626c2019-04-11 21:53:13 +00001/*
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08002 * 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
Nathan Haroldf10ea322018-04-24 13:31:07 -070019import static android.net.ConnectivityManager.NetworkCallback;
Nathan Harolddaea8be2018-06-05 14:02:35 -070020import static android.provider.Settings.Global.PREFERRED_NETWORK_MODE;
Nathan Haroldf10ea322018-04-24 13:31:07 -070021
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080022import android.app.Activity;
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -080023import android.app.QueuedWork;
Youhan Wangfd781e92016-12-16 15:53:16 -080024import android.content.ComponentName;
Meng Wang586741c2017-04-26 15:02:51 -070025import android.content.Context;
Pengquan Meng7f602c72019-01-28 19:12:18 -080026import android.content.DialogInterface;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080027import android.content.Intent;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +080028import android.content.pm.PackageManager;
29import android.content.pm.ResolveInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080030import android.content.res.Resources;
Nathan Haroldcea413a2015-11-23 15:48:10 -080031import android.graphics.Typeface;
Nathan Haroldf10ea322018-04-24 13:31:07 -070032import android.net.ConnectivityManager;
33import android.net.Network;
34import android.net.NetworkCapabilities;
35import android.net.NetworkRequest;
Jeff Sharkey93029862011-05-27 18:26:15 -070036import android.net.TrafficStats;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080037import android.net.Uri;
38import android.os.AsyncResult;
Sreekanth Badidac888e192018-02-05 17:18:40 +010039import android.os.Build;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080040import android.os.Bundle;
41import android.os.Handler;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080042import android.os.Message;
Pengquan Menga40d2742019-04-30 19:32:58 -070043import android.os.SystemProperties;
Nathan Harolddaea8be2018-06-05 14:02:35 -070044import android.provider.Settings;
Meng Wang586741c2017-04-26 15:02:51 -070045import android.telephony.CarrierConfigManager;
Fan Zhangc7162cd2018-06-18 15:21:41 -070046import android.telephony.CellIdentityCdma;
47import android.telephony.CellIdentityGsm;
48import android.telephony.CellIdentityLte;
49import android.telephony.CellIdentityWcdma;
Wink Saville79bff2a2012-06-01 14:37:21 -070050import android.telephony.CellInfo;
Nathan Haroldcea413a2015-11-23 15:48:10 -080051import android.telephony.CellInfoCdma;
52import android.telephony.CellInfoGsm;
53import android.telephony.CellInfoLte;
54import android.telephony.CellInfoWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080055import android.telephony.CellLocation;
Nathan Haroldcea413a2015-11-23 15:48:10 -080056import android.telephony.CellSignalStrengthCdma;
57import android.telephony.CellSignalStrengthGsm;
58import android.telephony.CellSignalStrengthLte;
59import android.telephony.CellSignalStrengthWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080060import android.telephony.PhoneStateListener;
Nathan Harold433ca442018-04-23 18:20:43 -070061import android.telephony.PhysicalChannelConfig;
Fan Zhangc7162cd2018-06-18 15:21:41 -070062import android.telephony.PreciseCallState;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080063import android.telephony.ServiceState;
Nathan Harold2b77d742016-03-19 13:22:10 -070064import android.telephony.SignalStrength;
Nathan Haroldcea413a2015-11-23 15:48:10 -080065import android.telephony.SubscriptionManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080066import android.telephony.TelephonyManager;
jsh534f5ae2009-09-24 09:19:22 -070067import android.telephony.cdma.CdmaCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080068import android.telephony.gsm.GsmCellLocation;
Nathan Harold6e16fdf2018-04-17 17:01:32 -070069import android.text.TextUtils;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080070import android.util.Log;
71import android.view.Menu;
72import android.view.MenuItem;
73import android.view.View;
74import android.view.View.OnClickListener;
75import android.widget.AdapterView;
76import android.widget.ArrayAdapter;
77import android.widget.Button;
Nathan Harold2b77d742016-03-19 13:22:10 -070078import android.widget.CompoundButton;
79import android.widget.CompoundButton.OnCheckedChangeListener;
Jason Monk39b46742015-09-10 15:52:51 -040080import android.widget.EditText;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080081import android.widget.Spinner;
Nathan Harold2b77d742016-03-19 13:22:10 -070082import android.widget.Switch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080083import android.widget.TextView;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080084
Fan Zhang23f8d592018-08-28 15:11:40 -070085import androidx.appcompat.app.AlertDialog;
Pengquan Meng7f602c72019-01-28 19:12:18 -080086import androidx.appcompat.app.AlertDialog.Builder;
Fan Zhang23f8d592018-08-28 15:11:40 -070087
Jason Monk39b46742015-09-10 15:52:51 -040088import com.android.ims.ImsConfig;
89import com.android.ims.ImsException;
90import com.android.ims.ImsManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080091import com.android.internal.telephony.Phone;
92import com.android.internal.telephony.PhoneFactory;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080093
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080094import java.io.IOException;
Jason Monk39b46742015-09-10 15:52:51 -040095import java.net.HttpURLConnection;
96import java.net.URL;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080097import java.util.List;
98
Pengquan Meng7f602c72019-01-28 19:12:18 -080099// TODO(b/123598192) consider to move this activity to telephony package.
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800100public class RadioInfo extends Activity {
Nathan Harold2b77d742016-03-19 13:22:10 -0700101 private static final String TAG = "RadioInfo";
johnwang342101a2009-09-23 16:22:34 -0700102
Nathan Harold2b77d742016-03-19 13:22:10 -0700103 private static final String[] mPreferredNetworkLabels = {
104 "WCDMA preferred",
105 "GSM only",
106 "WCDMA only",
107 "GSM auto (PRL)",
108 "CDMA auto (PRL)",
109 "CDMA only",
110 "EvDo only",
111 "Global auto (PRL)",
112 "LTE/CDMA auto (PRL)",
113 "LTE/UMTS auto (PRL)",
114 "LTE/CDMA/UMTS auto (PRL)",
115 "LTE only",
116 "LTE/WCDMA",
117 "TD-SCDMA only",
118 "TD-SCDMA/WCDMA",
119 "LTE/TD-SCDMA",
120 "TD-SCDMA/GSM",
121 "TD-SCDMA/UMTS",
122 "LTE/TD-SCDMA/WCDMA",
123 "LTE/TD-SCDMA/UMTS",
124 "TD-SCDMA/CDMA/UMTS",
125 "Global/TD-SCDMA",
126 "Unknown"
127 };
128
Jordan Liub69e8f22019-04-02 12:13:31 -0700129 private static String[] mPhoneIndexLabels;
Nathan Harold2b77d742016-03-19 13:22:10 -0700130
131 private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE;
132 private static final int CELL_INFO_LIST_RATE_MAX = 0;
133
Pengquan Menga40d2742019-04-30 19:32:58 -0700134 private static final String DSDS_MODE_PROPERTY = "ro.boot.hardware.dsds";
135
136 /**
137 * A value indicates the device is always on dsds mode.
138 * @see {@link #DSDS_MODE_PROPERTY}
139 */
140 private static final int ALWAYS_ON_DSDS_MODE = 1;
Nathan Harold12e1f552016-06-17 13:55:38 -0700141
142 private static final int IMS_VOLTE_PROVISIONED_CONFIG_ID =
143 ImsConfig.ConfigConstants.VLT_SETTING_ENABLED;
144
145 private static final int IMS_VT_PROVISIONED_CONFIG_ID =
146 ImsConfig.ConfigConstants.LVC_SETTING_ENABLED;
147
148 private static final int IMS_WFC_PROVISIONED_CONFIG_ID =
149 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED;
150
Meng Wang586741c2017-04-26 15:02:51 -0700151 private static final int EAB_PROVISIONED_CONFIG_ID =
152 ImsConfig.ConfigConstants.EAB_SETTING_ENABLED;
153
Nathan Harold2b77d742016-03-19 13:22:10 -0700154 //Values in must match mCellInfoRefreshRates
155 private static final String[] mCellInfoRefreshRateLabels = {
156 "Disabled",
157 "Immediate",
158 "Min 5s",
159 "Min 10s",
160 "Min 60s"
161 };
162
163 //Values in seconds, must match mCellInfoRefreshRateLabels
164 private static final int mCellInfoRefreshRates[] = {
165 CELL_INFO_LIST_RATE_DISABLED,
166 CELL_INFO_LIST_RATE_MAX,
167 5000,
168 10000,
169 60000
170 };
171
Jordan Liub69e8f22019-04-02 12:13:31 -0700172 private static void log(String s) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700173 Log.d(TAG, s);
174 }
175
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800176 private static final int EVENT_CFI_CHANGED = 302;
177
178 private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000;
179 private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800180 private static final int EVENT_QUERY_SMSC_DONE = 1005;
181 private static final int EVENT_UPDATE_SMSC_DONE = 1006;
182
Jordan Liub69e8f22019-04-02 12:13:31 -0700183 private static final int MENU_ITEM_SELECT_BAND = 0;
184 private static final int MENU_ITEM_VIEW_ADN = 1;
185 private static final int MENU_ITEM_VIEW_FDN = 2;
186 private static final int MENU_ITEM_VIEW_SDN = 3;
187 private static final int MENU_ITEM_GET_IMS_STATUS = 4;
188 private static final int MENU_ITEM_TOGGLE_DATA = 5;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800189
Wink Savillec3886682009-04-02 11:00:56 -0700190 private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800191 private TextView number;
Jordan Liub69e8f22019-04-02 12:13:31 -0700192 private TextView mSubscriptionId;
193 private TextView mDds;
Meng Wang9053f172017-06-23 16:02:14 -0700194 private TextView mSubscriberId;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800195 private TextView callState;
196 private TextView operatorName;
197 private TextView roamingState;
198 private TextView gsmState;
199 private TextView gprsState;
Nathan Harold2b77d742016-03-19 13:22:10 -0700200 private TextView voiceNetwork;
201 private TextView dataNetwork;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800202 private TextView dBm;
203 private TextView mMwi;
204 private TextView mCfi;
205 private TextView mLocation;
Wink Saville79bff2a2012-06-01 14:37:21 -0700206 private TextView mCellInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800207 private TextView sent;
208 private TextView received;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800209 private TextView mPingHostnameV4;
210 private TextView mPingHostnameV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800211 private TextView mHttpClientTest;
Nathan Harold433ca442018-04-23 18:20:43 -0700212 private TextView mPhyChanConfig;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800213 private TextView dnsCheckState;
Nathan Haroldf10ea322018-04-24 13:31:07 -0700214 private TextView mDownlinkKbps;
215 private TextView mUplinkKbps;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800216 private EditText smsc;
Nathan Harold2b77d742016-03-19 13:22:10 -0700217 private Switch radioPowerOnSwitch;
218 private Button cellInfoRefreshRateButton;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800219 private Button dnsCheckToggleButton;
220 private Button pingTestButton;
221 private Button updateSmscButton;
222 private Button refreshSmscButton;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800223 private Button oemInfoButton;
Youhan Wangfd781e92016-12-16 15:53:16 -0800224 private Button carrierProvisioningButton;
225 private Button triggercarrierProvisioningButton;
Nathan Harold12e1f552016-06-17 13:55:38 -0700226 private Switch imsVolteProvisionedSwitch;
227 private Switch imsVtProvisionedSwitch;
228 private Switch imsWfcProvisionedSwitch;
Meng Wang586741c2017-04-26 15:02:51 -0700229 private Switch eabProvisionedSwitch;
Naina Nallurid1b57f62019-01-08 15:19:58 -0800230 private Switch cbrsDataSwitch;
Pengquan Meng7f602c72019-01-28 19:12:18 -0800231 private Switch dsdsSwitch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800232 private Spinner preferredNetworkType;
Jordan Liub69e8f22019-04-02 12:13:31 -0700233 private Spinner mSelectPhoneIndex;
Nathan Harold2b77d742016-03-19 13:22:10 -0700234 private Spinner cellInfoRefreshRateSpinner;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800235
Nathan Haroldf10ea322018-04-24 13:31:07 -0700236 private ConnectivityManager mConnectivityManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800237 private TelephonyManager mTelephonyManager;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800238 private ImsManager mImsManager = null;
Jordan Liu84deb0a2019-04-05 14:39:41 -0700239 private Phone mPhone = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800240
Nathan Haroldcea413a2015-11-23 15:48:10 -0800241 private String mPingHostnameResultV4;
242 private String mPingHostnameResultV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800243 private String mHttpClientTestResult;
244 private boolean mMwiValue = false;
245 private boolean mCfiValue = false;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800246
247 private List<CellInfo> mCellInfoResult = null;
248 private CellLocation mCellLocationResult = null;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800249
250 private int mPreferredNetworkTypeResult;
Nathan Harold2b77d742016-03-19 13:22:10 -0700251 private int mCellInfoRefreshRateIndex;
Jordan Liub69e8f22019-04-02 12:13:31 -0700252 private int mSelectedPhoneIndex;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800253
Nathan Haroldf10ea322018-04-24 13:31:07 -0700254 private final NetworkRequest mDefaultNetworkRequest = new NetworkRequest.Builder()
255 .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
256 .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
257 .build();
258
259 private final NetworkCallback mNetworkCallback = new NetworkCallback() {
260 public void onCapabilitiesChanged(Network n, NetworkCapabilities nc) {
261 int dlbw = nc.getLinkDownstreamBandwidthKbps();
262 int ulbw = nc.getLinkUpstreamBandwidthKbps();
263 updateBandwidths(dlbw, ulbw);
264 }
265 };
266
Jordan Liu84deb0a2019-04-05 14:39:41 -0700267 // not final because we need to recreate this object to register on a new subId (b/117555407)
268 private PhoneStateListener mPhoneStateListener = new RadioInfoPhoneStateListener();
269 private class RadioInfoPhoneStateListener extends PhoneStateListener {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800270 @Override
271 public void onDataConnectionStateChanged(int state) {
272 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800273 updateNetworkType();
274 }
275
276 @Override
277 public void onDataActivity(int direction) {
278 updateDataStats2();
279 }
280
281 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700282 public void onCallStateChanged(int state, String incomingNumber) {
283 updateNetworkType();
284 updatePhoneState(state);
285 }
286
287 @Override
288 public void onPreciseCallStateChanged(PreciseCallState preciseState) {
289 updateNetworkType();
290 }
291
292 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800293 public void onCellLocationChanged(CellLocation location) {
294 updateLocation(location);
295 }
296
297 @Override
298 public void onMessageWaitingIndicatorChanged(boolean mwi) {
299 mMwiValue = mwi;
300 updateMessageWaiting();
301 }
302
303 @Override
304 public void onCallForwardingIndicatorChanged(boolean cfi) {
305 mCfiValue = cfi;
306 updateCallRedirect();
307 }
Wink Saville79bff2a2012-06-01 14:37:21 -0700308
309 @Override
310 public void onCellInfoChanged(List<CellInfo> arrayCi) {
Wink Savillebf471282013-04-05 15:04:05 -0700311 log("onCellInfoChanged: arrayCi=" + arrayCi);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800312 mCellInfoResult = arrayCi;
313 updateCellInfo(mCellInfoResult);
Wink Saville79bff2a2012-06-01 14:37:21 -0700314 }
Wink Saville4f0d8812014-04-15 22:05:24 -0700315
316 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700317 public void onSignalStrengthsChanged(SignalStrength signalStrength) {
318 log("onSignalStrengthChanged: SignalStrength=" +signalStrength);
319 updateSignalStrength(signalStrength);
320 }
321
322 @Override
323 public void onServiceStateChanged(ServiceState serviceState) {
324 log("onServiceStateChanged: ServiceState=" + serviceState);
325 updateServiceState(serviceState);
326 updateRadioPowerState();
327 updateNetworkType();
Nathan Harold12e1f552016-06-17 13:55:38 -0700328 updateImsProvisionedState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700329 }
Nathan Harold433ca442018-04-23 18:20:43 -0700330
331 @Override
332 public void onPhysicalChannelConfigurationChanged(
333 List<PhysicalChannelConfig> configs) {
334 updatePhysicalChannelConfiguration(configs);
335 }
336
Jordan Liu84deb0a2019-04-05 14:39:41 -0700337 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800338
Nathan Harold433ca442018-04-23 18:20:43 -0700339 private void updatePhysicalChannelConfiguration(List<PhysicalChannelConfig> configs) {
340 StringBuilder sb = new StringBuilder();
341 String div = "";
342 sb.append("{");
343 if (configs != null) {
344 for(PhysicalChannelConfig c : configs) {
345 sb.append(div).append(c);
346 div = ",";
347 }
348 }
349 sb.append("}");
350 mPhyChanConfig.setText(sb.toString());
351 }
352
Nathan Haroldcea413a2015-11-23 15:48:10 -0800353 private void updatePreferredNetworkType(int type) {
354 if (type >= mPreferredNetworkLabels.length || type < 0) {
355 log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
356 "type=" + type);
357 type = mPreferredNetworkLabels.length - 1; //set to Unknown
358 }
359 mPreferredNetworkTypeResult = type;
360
361 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
362 }
363
Jordan Liub69e8f22019-04-02 12:13:31 -0700364 private void updatePhoneIndex(int phoneIndex, int subId) {
365 // unregister listeners on the old subId
Jordan Liu84deb0a2019-04-05 14:39:41 -0700366 unregisterPhoneStateListener();
Jordan Liub69e8f22019-04-02 12:13:31 -0700367 mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
368
369 // update the subId
370 mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId);
Jordan Liub69e8f22019-04-02 12:13:31 -0700371
372 // update the phoneId
Jordan Liu84deb0a2019-04-05 14:39:41 -0700373 mImsManager = ImsManager.getInstance(getApplicationContext(), phoneIndex);
374 mPhone = PhoneFactory.getPhone(phoneIndex);
Jordan Liub69e8f22019-04-02 12:13:31 -0700375
376 updateAllFields();
377 }
378
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800379 private Handler mHandler = new Handler() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800380 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800381 public void handleMessage(Message msg) {
382 AsyncResult ar;
383 switch (msg.what) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800384 case EVENT_QUERY_PREFERRED_TYPE_DONE:
385 ar= (AsyncResult) msg.obj;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800386 if (ar.exception == null && ar.result != null) {
387 updatePreferredNetworkType(((int[])ar.result)[0]);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800388 } else {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800389 //In case of an exception, we will set this to unknown
390 updatePreferredNetworkType(mPreferredNetworkLabels.length-1);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800391 }
392 break;
393 case EVENT_SET_PREFERRED_TYPE_DONE:
394 ar= (AsyncResult) msg.obj;
395 if (ar.exception != null) {
Nathan Harolded38afa2016-04-13 00:29:30 -0700396 log("Set preferred network type failed.");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800397 }
398 break;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800399 case EVENT_QUERY_SMSC_DONE:
400 ar= (AsyncResult) msg.obj;
401 if (ar.exception != null) {
402 smsc.setText("refresh error");
403 } else {
jsh21dd4072009-05-12 11:26:55 -0700404 smsc.setText((String)ar.result);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800405 }
406 break;
407 case EVENT_UPDATE_SMSC_DONE:
408 updateSmscButton.setEnabled(true);
409 ar= (AsyncResult) msg.obj;
410 if (ar.exception != null) {
411 smsc.setText("update error");
412 }
413 break;
414 default:
Nathan Haroldcea413a2015-11-23 15:48:10 -0800415 super.handleMessage(msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800416 break;
417
418 }
419 }
420 };
421
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800422 @Override
423 public void onCreate(Bundle icicle) {
424 super.onCreate(icicle);
fionaxub54cb2d2016-09-22 15:01:05 -0700425 if (!android.os.Process.myUserHandle().isSystem()) {
426 Log.e(TAG, "Not run from system user, don't do anything.");
427 finish();
428 return;
429 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800430
431 setContentView(R.layout.radio_info);
432
Nathan Haroldcea413a2015-11-23 15:48:10 -0800433 log("Started onCreate");
434
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800435 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
Nathan Haroldf10ea322018-04-24 13:31:07 -0700436 mConnectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
Jordan Liu84deb0a2019-04-05 14:39:41 -0700437 mPhone = PhoneFactory.getDefaultPhone();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800438
Nathan Haroldcea413a2015-11-23 15:48:10 -0800439 mImsManager = ImsManager.getInstance(getApplicationContext(),
440 SubscriptionManager.getDefaultVoicePhoneId());
441
Jordan Liub69e8f22019-04-02 12:13:31 -0700442 mPhoneIndexLabels = getPhoneIndexLabels(mTelephonyManager);
443
Meng Wang9053f172017-06-23 16:02:14 -0700444 mDeviceId = (TextView) findViewById(R.id.imei);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800445 number = (TextView) findViewById(R.id.number);
Jordan Liub69e8f22019-04-02 12:13:31 -0700446 mSubscriptionId = (TextView) findViewById(R.id.subid);
447 mDds = (TextView) findViewById(R.id.dds);
Meng Wang9053f172017-06-23 16:02:14 -0700448 mSubscriberId = (TextView) findViewById(R.id.imsi);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800449 callState = (TextView) findViewById(R.id.call);
450 operatorName = (TextView) findViewById(R.id.operator);
451 roamingState = (TextView) findViewById(R.id.roaming);
452 gsmState = (TextView) findViewById(R.id.gsm);
453 gprsState = (TextView) findViewById(R.id.gprs);
Nathan Harold2b77d742016-03-19 13:22:10 -0700454 voiceNetwork = (TextView) findViewById(R.id.voice_network);
455 dataNetwork = (TextView) findViewById(R.id.data_network);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800456 dBm = (TextView) findViewById(R.id.dbm);
457 mMwi = (TextView) findViewById(R.id.mwi);
458 mCfi = (TextView) findViewById(R.id.cfi);
459 mLocation = (TextView) findViewById(R.id.location);
Wink Saville79bff2a2012-06-01 14:37:21 -0700460 mCellInfo = (TextView) findViewById(R.id.cellinfo);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800461 mCellInfo.setTypeface(Typeface.MONOSPACE);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800462
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800463 sent = (TextView) findViewById(R.id.sent);
464 received = (TextView) findViewById(R.id.received);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800465 smsc = (EditText) findViewById(R.id.smsc);
466 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800467 mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4);
468 mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800469 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
470
Nathan Harold433ca442018-04-23 18:20:43 -0700471 mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config);
472
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800473 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
Jordan Liub69e8f22019-04-02 12:13:31 -0700474 ArrayAdapter<String> preferredNetworkTypeAdapter = new ArrayAdapter<String> (this,
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800475 android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
Jordan Liub69e8f22019-04-02 12:13:31 -0700476 preferredNetworkTypeAdapter
477 .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
478 preferredNetworkType.setAdapter(preferredNetworkTypeAdapter);
479
480 mSelectPhoneIndex = (Spinner) findViewById(R.id.phoneIndex);
481 ArrayAdapter<String> phoneIndexAdapter = new ArrayAdapter<String> (this,
482 android.R.layout.simple_spinner_item, mPhoneIndexLabels);
483 phoneIndexAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
484 mSelectPhoneIndex.setAdapter(phoneIndexAdapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800485
Nathan Harold2b77d742016-03-19 13:22:10 -0700486 cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select);
487 ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this,
488 android.R.layout.simple_spinner_item, mCellInfoRefreshRateLabels);
489 cellInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
490 cellInfoRefreshRateSpinner.setAdapter(cellInfoAdapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800491
Nathan Harold12e1f552016-06-17 13:55:38 -0700492 imsVolteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch);
493 imsVtProvisionedSwitch = (Switch) findViewById(R.id.vt_provisioned_switch);
494 imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
Meng Wang69439b52017-05-01 08:31:14 -0700495 eabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch);
Wink Savillebf471282013-04-05 15:04:05 -0700496
Jordan Liu84deb0a2019-04-05 14:39:41 -0700497 if (!ImsManager.isImsSupportedOnDevice(mPhone.getContext())) {
Brad Ebinger5dfe7f82019-03-11 17:33:53 -0700498 imsVolteProvisionedSwitch.setVisibility(View.GONE);
499 imsVtProvisionedSwitch.setVisibility(View.GONE);
500 imsWfcProvisionedSwitch.setVisibility(View.GONE);
501 eabProvisionedSwitch.setVisibility(View.GONE);
502 }
503
Naina Nallurid1b57f62019-01-08 15:19:58 -0800504 cbrsDataSwitch = (Switch) findViewById(R.id.cbrs_data_switch);
505 cbrsDataSwitch.setVisibility(isCbrsSupported() ? View.VISIBLE : View.GONE);
506
Pengquan Meng7f602c72019-01-28 19:12:18 -0800507 dsdsSwitch = findViewById(R.id.dsds_switch);
Pengquan Menga40d2742019-04-30 19:32:58 -0700508 if (isDsdsSupported() && !dsdsModeOnly()) {
Pengquan Meng7f602c72019-01-28 19:12:18 -0800509 dsdsSwitch.setVisibility(View.VISIBLE);
510 dsdsSwitch.setOnClickListener(v -> {
chen xu4f379d22019-04-03 10:31:19 -0700511 if (mTelephonyManager.doesSwitchMultiSimConfigTriggerReboot()) {
Pengquan Meng7f602c72019-01-28 19:12:18 -0800512 // Undo the click action until user clicks the confirm dialog.
513 dsdsSwitch.toggle();
514 showDsdsChangeDialog();
515 } else {
516 performDsdsSwitch();
517 }
518 });
519 dsdsSwitch.setChecked(isDsdsEnabled());
520 } else {
521 dsdsSwitch.setVisibility(View.GONE);
522 }
523
Nathan Harold2b77d742016-03-19 13:22:10 -0700524 radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
Wink Saville426fc662011-09-25 14:39:02 -0700525
Nathan Haroldf10ea322018-04-24 13:31:07 -0700526 mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
527 mUplinkKbps = (TextView) findViewById(R.id.ul_kbps);
528 updateBandwidths(0, 0);
529
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800530 pingTestButton = (Button) findViewById(R.id.ping_test);
531 pingTestButton.setOnClickListener(mPingButtonHandler);
532 updateSmscButton = (Button) findViewById(R.id.update_smsc);
533 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
534 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
535 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
536 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
537 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
Youhan Wangfd781e92016-12-16 15:53:16 -0800538 carrierProvisioningButton = (Button) findViewById(R.id.carrier_provisioning);
539 carrierProvisioningButton.setOnClickListener(mCarrierProvisioningButtonHandler);
540 triggercarrierProvisioningButton = (Button) findViewById(R.id.trigger_carrier_provisioning);
541 triggercarrierProvisioningButton.setOnClickListener(
542 mTriggerCarrierProvisioningButtonHandler);
johnwang342101a2009-09-23 16:22:34 -0700543
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800544 oemInfoButton = (Button) findViewById(R.id.oem_info);
545 oemInfoButton.setOnClickListener(mOemInfoButtonHandler);
546 PackageManager pm = getPackageManager();
547 Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO");
548 List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0);
549 if (oemInfoIntentList.size() == 0) {
550 oemInfoButton.setEnabled(false);
551 }
552
Nathan Harolded38afa2016-04-13 00:29:30 -0700553 mCellInfoRefreshRateIndex = 0; //disabled
Nathan Haroldcea413a2015-11-23 15:48:10 -0800554 mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown
Jordan Liub69e8f22019-04-02 12:13:31 -0700555 mSelectedPhoneIndex = 0; //phone 0
Nathan Haroldcea413a2015-11-23 15:48:10 -0800556
557 //FIXME: Replace with TelephonyManager call
Jordan Liu84deb0a2019-04-05 14:39:41 -0700558 mPhone.getPreferredNetworkType(
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800559 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800560
Nathan Haroldcea413a2015-11-23 15:48:10 -0800561 restoreFromBundle(icicle);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800562 }
563
564 @Override
565 protected void onResume() {
566 super.onResume();
567
Nathan Haroldcea413a2015-11-23 15:48:10 -0800568 log("Started onResume");
569
Jordan Liub69e8f22019-04-02 12:13:31 -0700570 updateAllFields();
571 }
572
573 private void updateAllFields() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800574 updateMessageWaiting();
575 updateCallRedirect();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800576 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800577 updateDataStats2();
Nathan Harold2b77d742016-03-19 13:22:10 -0700578 updateRadioPowerState();
Nathan Harold12e1f552016-06-17 13:55:38 -0700579 updateImsProvisionedState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800580 updateProperties();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800581 updateDnsCheckState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700582 updateNetworkType();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800583
Nathan Haroldcea413a2015-11-23 15:48:10 -0800584 updateLocation(mCellLocationResult);
585 updateCellInfo(mCellInfoResult);
Jordan Liub69e8f22019-04-02 12:13:31 -0700586 updateSubscriptionIds();
Nathan Haroldcea413a2015-11-23 15:48:10 -0800587
588 mPingHostnameV4.setText(mPingHostnameResultV4);
589 mPingHostnameV6.setText(mPingHostnameResultV6);
590 mHttpClientTest.setText(mHttpClientTestResult);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800591
Nathan Harold2b77d742016-03-19 13:22:10 -0700592 cellInfoRefreshRateSpinner.setOnItemSelectedListener(mCellInfoRefreshRateHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700593 //set selection after registering listener to force update
594 cellInfoRefreshRateSpinner.setSelection(mCellInfoRefreshRateIndex);
595
596 //set selection before registering to prevent update
597 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
Nathan Harold2b77d742016-03-19 13:22:10 -0700598 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700599
Jordan Liub69e8f22019-04-02 12:13:31 -0700600 // set phone index
601 mSelectPhoneIndex.setSelection(mSelectedPhoneIndex, true);
602 mSelectPhoneIndex.setOnItemSelectedListener(mSelectPhoneIndexHandler);
603
Nathan Harold2b77d742016-03-19 13:22:10 -0700604 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
Nathan Harold12e1f552016-06-17 13:55:38 -0700605 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
606 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
607 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Meng Wang586741c2017-04-26 15:02:51 -0700608 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
Nathan Harold2b77d742016-03-19 13:22:10 -0700609
Naina Nallurid1b57f62019-01-08 15:19:58 -0800610 if (isCbrsSupported()) {
611 cbrsDataSwitch.setChecked(getCbrsDataState());
612 cbrsDataSwitch.setOnCheckedChangeListener(mCbrsDataSwitchChangeListener);
613 }
614
Jordan Liu84deb0a2019-04-05 14:39:41 -0700615 unregisterPhoneStateListener();
Jordan Liub69e8f22019-04-02 12:13:31 -0700616 registerPhoneStateListener();
Nathan Harolded38afa2016-04-13 00:29:30 -0700617
Nathan Haroldf10ea322018-04-24 13:31:07 -0700618 mConnectivityManager.registerNetworkCallback(
619 mDefaultNetworkRequest, mNetworkCallback, mHandler);
620
Nathan Harolded38afa2016-04-13 00:29:30 -0700621 smsc.clearFocus();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800622 }
623
624 @Override
Nathan Haroldcea413a2015-11-23 15:48:10 -0800625 protected void onPause() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800626 super.onPause();
627
Wink Savillebf471282013-04-05 15:04:05 -0700628 log("onPause: unregister phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800629
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800630 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -0700631 mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
Nathan Haroldf10ea322018-04-24 13:31:07 -0700632 mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
633
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800634 }
635
Nathan Haroldcea413a2015-11-23 15:48:10 -0800636 private void restoreFromBundle(Bundle b) {
Nathan Harolde272c202016-10-27 13:45:00 -0700637 if(b == null) {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800638 return;
639 }
640
641 mPingHostnameResultV4 = b.getString("mPingHostnameResultV4","");
642 mPingHostnameResultV6 = b.getString("mPingHostnameResultV6","");
643 mHttpClientTestResult = b.getString("mHttpClientTestResult","");
644
645 mPingHostnameV4.setText(mPingHostnameResultV4);
646 mPingHostnameV6.setText(mPingHostnameResultV6);
647 mHttpClientTest.setText(mHttpClientTestResult);
648
Nathan Harold2b77d742016-03-19 13:22:10 -0700649 mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult",
650 mPreferredNetworkLabels.length - 1);
651
Jordan Liub69e8f22019-04-02 12:13:31 -0700652 mSelectedPhoneIndex = b.getInt("mSelectedPhoneIndex", 0);
653
Nathan Harold2b77d742016-03-19 13:22:10 -0700654 mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800655 }
656
657 @Override
658 protected void onSaveInstanceState(Bundle outState) {
659 outState.putString("mPingHostnameResultV4", mPingHostnameResultV4);
660 outState.putString("mPingHostnameResultV6", mPingHostnameResultV6);
661 outState.putString("mHttpClientTestResult", mHttpClientTestResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700662
Nathan Haroldcea413a2015-11-23 15:48:10 -0800663 outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult);
Jordan Liub69e8f22019-04-02 12:13:31 -0700664 outState.putInt("mSelectedPhoneIndex", mSelectedPhoneIndex);
Nathan Harold2b77d742016-03-19 13:22:10 -0700665 outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex);
666
Nathan Haroldcea413a2015-11-23 15:48:10 -0800667 }
668
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800669 @Override
670 public boolean onCreateOptionsMenu(Menu menu) {
Wink Savillec3886682009-04-02 11:00:56 -0700671 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
672 .setOnMenuItemClickListener(mSelectBandCallback)
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800673 .setAlphabeticShortcut('b');
674 menu.add(1, MENU_ITEM_VIEW_ADN, 0,
675 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
676 menu.add(1, MENU_ITEM_VIEW_FDN, 0,
677 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
678 menu.add(1, MENU_ITEM_VIEW_SDN, 0,
679 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
Jordan Liu84deb0a2019-04-05 14:39:41 -0700680 if (ImsManager.isImsSupportedOnDevice(mPhone.getContext())) {
Brad Ebinger5dfe7f82019-03-11 17:33:53 -0700681 menu.add(1, MENU_ITEM_GET_IMS_STATUS,
682 0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus);
683 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800684 menu.add(1, MENU_ITEM_TOGGLE_DATA,
Nathan Harold2b77d742016-03-19 13:22:10 -0700685 0, R.string.radio_info_data_connection_disable).setOnMenuItemClickListener(mToggleData);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800686 return true;
687 }
688
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800689 @Override
Wink Savillec3886682009-04-02 11:00:56 -0700690 public boolean onPrepareOptionsMenu(Menu menu) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800691 // Get the TOGGLE DATA menu item in the right state.
692 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
693 int state = mTelephonyManager.getDataState();
694 boolean visible = true;
695
696 switch (state) {
697 case TelephonyManager.DATA_CONNECTED:
698 case TelephonyManager.DATA_SUSPENDED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700699 item.setTitle(R.string.radio_info_data_connection_disable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800700 break;
701 case TelephonyManager.DATA_DISCONNECTED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700702 item.setTitle(R.string.radio_info_data_connection_enable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800703 break;
704 default:
705 visible = false;
706 break;
707 }
708 item.setVisible(visible);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800709 return true;
710 }
711
Jordan Liub69e8f22019-04-02 12:13:31 -0700712 // returns array of string labels for each phone index. The array index is equal to the phone
713 // index.
714 private static String[] getPhoneIndexLabels(TelephonyManager tm) {
715 int phones = tm.getPhoneCount();
716 String[] labels = new String[phones];
717 for (int i = 0; i < phones; i++) {
718 labels[i] = "Phone " + i;
719 }
720 return labels;
721 }
722
Jordan Liu84deb0a2019-04-05 14:39:41 -0700723 private void unregisterPhoneStateListener() {
724 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
725
726 // clear all fields so they are blank until the next listener event occurs
727 operatorName.setText("");
728 gprsState.setText("");
729 dataNetwork.setText("");
730 voiceNetwork.setText("");
731 sent.setText("");
732 received.setText("");
733 callState.setText("");
734 mLocation.setText("");
735 mMwiValue = false;
736 mMwi.setText("");
737 mCfiValue = false;
738 mCfi.setText("");
739 mCellInfo.setText("");
740 dBm.setText("");
741 gsmState.setText("");
742 roamingState.setText("");
743 mPhyChanConfig.setText("");
744 }
745
Jordan Liub69e8f22019-04-02 12:13:31 -0700746 // register mPhoneStateListener for relevant fields using the current TelephonyManager
747 private void registerPhoneStateListener() {
Jordan Liu84deb0a2019-04-05 14:39:41 -0700748 mPhoneStateListener = new RadioInfoPhoneStateListener();
Jordan Liub69e8f22019-04-02 12:13:31 -0700749 mTelephonyManager.listen(mPhoneStateListener,
750 PhoneStateListener.LISTEN_CALL_STATE
751 //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
752 // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
753 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
754 | PhoneStateListener.LISTEN_DATA_ACTIVITY
755 | PhoneStateListener.LISTEN_CELL_LOCATION
756 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
757 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
758 | PhoneStateListener.LISTEN_CELL_INFO
759 | PhoneStateListener.LISTEN_SERVICE_STATE
760 | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
761 | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION);
762 }
763
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800764 private void updateDnsCheckState() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800765 //FIXME: Replace with a TelephonyManager call
Jordan Liu84deb0a2019-04-05 14:39:41 -0700766 dnsCheckState.setText(mPhone.isDnsCheckDisabled() ?
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800767 "0.0.0.0 allowed" :"0.0.0.0 not allowed");
768 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700769
Nathan Haroldf10ea322018-04-24 13:31:07 -0700770 private void updateBandwidths(int dlbw, int ulbw) {
771 dlbw = (dlbw < 0 || dlbw == Integer.MAX_VALUE) ? -1 : dlbw;
772 ulbw = (ulbw < 0 || ulbw == Integer.MAX_VALUE) ? -1 : ulbw;
773 mDownlinkKbps.setText(String.format("%-5d", dlbw));
774 mUplinkKbps.setText(String.format("%-5d", ulbw));
775 }
776
777
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800778 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700779 updateSignalStrength(SignalStrength signalStrength) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800780 Resources r = getResources();
781
Nathan Harold2b77d742016-03-19 13:22:10 -0700782 int signalDbm = signalStrength.getDbm();
Wink Savillee2a14e32009-05-29 14:06:30 -0700783
Nathan Harold2b77d742016-03-19 13:22:10 -0700784 int signalAsu = signalStrength.getAsuLevel();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800785
786 if (-1 == signalAsu) signalAsu = 0;
787
788 dBm.setText(String.valueOf(signalDbm) + " "
789 + r.getString(R.string.radioInfo_display_dbm) + " "
790 + String.valueOf(signalAsu) + " "
791 + r.getString(R.string.radioInfo_display_asu));
792 }
793
794 private final void updateLocation(CellLocation location) {
jsh534f5ae2009-09-24 09:19:22 -0700795 Resources r = getResources();
Wink Savillec3886682009-04-02 11:00:56 -0700796 if (location instanceof GsmCellLocation) {
797 GsmCellLocation loc = (GsmCellLocation)location;
jsh534f5ae2009-09-24 09:19:22 -0700798 int lac = loc.getLac();
799 int cid = loc.getCid();
800 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
801 + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
802 + " "
803 + r.getString(R.string.radioInfo_cid) + " = "
804 + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
805 } else if (location instanceof CdmaCellLocation) {
806 CdmaCellLocation loc = (CdmaCellLocation)location;
807 int bid = loc.getBaseStationId();
808 int sid = loc.getSystemId();
809 int nid = loc.getNetworkId();
810 int lat = loc.getBaseStationLatitude();
811 int lon = loc.getBaseStationLongitude();
812 mLocation.setText("BID = "
813 + ((bid == -1) ? "unknown" : Integer.toHexString(bid))
814 + " "
815 + "SID = "
816 + ((sid == -1) ? "unknown" : Integer.toHexString(sid))
817 + " "
818 + "NID = "
819 + ((nid == -1) ? "unknown" : Integer.toHexString(nid))
820 + "\n"
821 + "LAT = "
822 + ((lat == -1) ? "unknown" : Integer.toHexString(lat))
823 + " "
824 + "LONG = "
825 + ((lon == -1) ? "unknown" : Integer.toHexString(lon)));
826 } else {
827 mLocation.setText("unknown");
Wink Savillec3886682009-04-02 11:00:56 -0700828 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800829
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800830
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800831 }
832
Nathan Haroldcea413a2015-11-23 15:48:10 -0800833 private final String getCellInfoDisplayString(int i) {
834 return (i != Integer.MAX_VALUE) ? Integer.toString(i) : "";
835 }
836
837 private final String getCellInfoDisplayString(long i) {
838 return (i != Long.MAX_VALUE) ? Long.toString(i) : "";
839 }
840
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700841 private final String getConnectionStatusString(CellInfo ci) {
842 String regStr = "";
843 String connStatStr = "";
844 String connector = "";
845
846 if (ci.isRegistered()) {
847 regStr = "R";
848 }
849 switch (ci.getCellConnectionStatus()) {
850 case CellInfo.CONNECTION_PRIMARY_SERVING: connStatStr = "P"; break;
851 case CellInfo.CONNECTION_SECONDARY_SERVING: connStatStr = "S"; break;
852 case CellInfo.CONNECTION_NONE: connStatStr = "N"; break;
853 case CellInfo.CONNECTION_UNKNOWN: /* Field is unsupported */ break;
854 default: break;
855 }
856 if (!TextUtils.isEmpty(regStr) && !TextUtils.isEmpty(connStatStr)) {
857 connector = "+";
858 }
859
860 return regStr + connector + connStatStr;
861 }
862
Nathan Haroldcea413a2015-11-23 15:48:10 -0800863 private final String buildCdmaInfoString(CellInfoCdma ci) {
864 CellIdentityCdma cidCdma = ci.getCellIdentity();
865 CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
866
867 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 -0700868 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800869 getCellInfoDisplayString(cidCdma.getSystemId()),
870 getCellInfoDisplayString(cidCdma.getNetworkId()),
871 getCellInfoDisplayString(cidCdma.getBasestationId()),
872 getCellInfoDisplayString(ssCdma.getCdmaDbm()),
873 getCellInfoDisplayString(ssCdma.getCdmaEcio()),
874 getCellInfoDisplayString(ssCdma.getEvdoDbm()),
875 getCellInfoDisplayString(ssCdma.getEvdoEcio()),
876 getCellInfoDisplayString(ssCdma.getEvdoSnr()));
877 }
878
879 private final String buildGsmInfoString(CellInfoGsm ci) {
880 CellIdentityGsm cidGsm = ci.getCellIdentity();
881 CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
882
Nathan Harold2b77d742016-03-19 13:22:10 -0700883 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 -0700884 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800885 getCellInfoDisplayString(cidGsm.getMcc()),
886 getCellInfoDisplayString(cidGsm.getMnc()),
887 getCellInfoDisplayString(cidGsm.getLac()),
888 getCellInfoDisplayString(cidGsm.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700889 getCellInfoDisplayString(cidGsm.getArfcn()),
890 getCellInfoDisplayString(cidGsm.getBsic()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800891 getCellInfoDisplayString(ssGsm.getDbm()));
892 }
893
894 private final String buildLteInfoString(CellInfoLte ci) {
895 CellIdentityLte cidLte = ci.getCellIdentity();
896 CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
897
898 return String.format(
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700899 "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
900 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800901 getCellInfoDisplayString(cidLte.getMcc()),
902 getCellInfoDisplayString(cidLte.getMnc()),
903 getCellInfoDisplayString(cidLte.getTac()),
904 getCellInfoDisplayString(cidLte.getCi()),
905 getCellInfoDisplayString(cidLte.getPci()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700906 getCellInfoDisplayString(cidLte.getEarfcn()),
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700907 getCellInfoDisplayString(cidLte.getBandwidth()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800908 getCellInfoDisplayString(ssLte.getDbm()),
909 getCellInfoDisplayString(ssLte.getRsrq()),
910 getCellInfoDisplayString(ssLte.getTimingAdvance()));
911 }
912
913 private final String buildWcdmaInfoString(CellInfoWcdma ci) {
914 CellIdentityWcdma cidWcdma = ci.getCellIdentity();
915 CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength();
916
Nathan Harold2b77d742016-03-19 13:22:10 -0700917 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 -0700918 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800919 getCellInfoDisplayString(cidWcdma.getMcc()),
920 getCellInfoDisplayString(cidWcdma.getMnc()),
921 getCellInfoDisplayString(cidWcdma.getLac()),
922 getCellInfoDisplayString(cidWcdma.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700923 getCellInfoDisplayString(cidWcdma.getUarfcn()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800924 getCellInfoDisplayString(cidWcdma.getPsc()),
925 getCellInfoDisplayString(ssWcdma.getDbm()));
926 }
927
928 private final String buildCellInfoString(List<CellInfo> arrayCi) {
929 String value = new String();
930 StringBuilder cdmaCells = new StringBuilder(),
931 gsmCells = new StringBuilder(),
932 lteCells = new StringBuilder(),
933 wcdmaCells = new StringBuilder();
934
935 if (arrayCi != null) {
936 for (CellInfo ci : arrayCi) {
937
938 if (ci instanceof CellInfoLte) {
939 lteCells.append(buildLteInfoString((CellInfoLte) ci));
940 } else if (ci instanceof CellInfoWcdma) {
941 wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
942 } else if (ci instanceof CellInfoGsm) {
943 gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
944 } else if (ci instanceof CellInfoCdma) {
945 cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
Wink Saville79bff2a2012-06-01 14:37:21 -0700946 }
947 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800948 if (lteCells.length() != 0) {
949 value += String.format(
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700950 "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s"
951 + " %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
952 "SRV", "MCC", "MNC", "TAC", "CID", "PCI",
953 "EARFCN", "BW", "RSRP", "RSRQ", "TA");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800954 value += lteCells.toString();
955 }
956 if (wcdmaCells.length() != 0) {
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700957 value += String.format(
958 "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 -0700959 "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800960 value += wcdmaCells.toString();
961 }
962 if (gsmCells.length() != 0) {
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700963 value += String.format(
964 "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 -0700965 "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800966 value += gsmCells.toString();
967 }
968 if (cdmaCells.length() != 0) {
969 value += String.format(
970 "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n",
971 "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
972 value += cdmaCells.toString();
973 }
974 } else {
975 value ="unknown";
Wink Saville79bff2a2012-06-01 14:37:21 -0700976 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800977
978 return value.toString();
979 }
980
981 private final void updateCellInfo(List<CellInfo> arrayCi) {
982 mCellInfo.setText(buildCellInfoString(arrayCi));
Wink Saville79bff2a2012-06-01 14:37:21 -0700983 }
984
Jordan Liub69e8f22019-04-02 12:13:31 -0700985 private final void updateSubscriptionIds() {
Jordan Liu84deb0a2019-04-05 14:39:41 -0700986 mSubscriptionId.setText(Integer.toString(mPhone.getSubId()));
Jordan Liub69e8f22019-04-02 12:13:31 -0700987 mDds.setText(Integer.toString(SubscriptionManager.getDefaultDataSubscriptionId()));
988 }
989
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800990 private final void
991 updateMessageWaiting() {
992 mMwi.setText(String.valueOf(mMwiValue));
993 }
994
995 private final void
996 updateCallRedirect() {
997 mCfi.setText(String.valueOf(mCfiValue));
998 }
999
1000
1001 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -07001002 updateServiceState(ServiceState serviceState) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001003 int state = serviceState.getState();
1004 Resources r = getResources();
1005 String display = r.getString(R.string.radioInfo_unknown);
johnwang342101a2009-09-23 16:22:34 -07001006
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001007 switch (state) {
1008 case ServiceState.STATE_IN_SERVICE:
1009 display = r.getString(R.string.radioInfo_service_in);
1010 break;
1011 case ServiceState.STATE_OUT_OF_SERVICE:
1012 case ServiceState.STATE_EMERGENCY_ONLY:
1013 display = r.getString(R.string.radioInfo_service_emergency);
1014 break;
1015 case ServiceState.STATE_POWER_OFF:
1016 display = r.getString(R.string.radioInfo_service_off);
1017 break;
1018 }
johnwang342101a2009-09-23 16:22:34 -07001019
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001020 gsmState.setText(display);
johnwang342101a2009-09-23 16:22:34 -07001021
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001022 if (serviceState.getRoaming()) {
1023 roamingState.setText(R.string.radioInfo_roaming_in);
1024 } else {
1025 roamingState.setText(R.string.radioInfo_roaming_not);
1026 }
1027
1028 operatorName.setText(serviceState.getOperatorAlphaLong());
1029 }
1030
1031 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -07001032 updatePhoneState(int state) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001033 Resources r = getResources();
1034 String display = r.getString(R.string.radioInfo_unknown);
1035
1036 switch (state) {
Nathan Harold2b77d742016-03-19 13:22:10 -07001037 case TelephonyManager.CALL_STATE_IDLE:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001038 display = r.getString(R.string.radioInfo_phone_idle);
1039 break;
Nathan Harold2b77d742016-03-19 13:22:10 -07001040 case TelephonyManager.CALL_STATE_RINGING:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001041 display = r.getString(R.string.radioInfo_phone_ringing);
1042 break;
Nathan Harold2b77d742016-03-19 13:22:10 -07001043 case TelephonyManager.CALL_STATE_OFFHOOK:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001044 display = r.getString(R.string.radioInfo_phone_offhook);
1045 break;
1046 }
1047
1048 callState.setText(display);
1049 }
1050
1051 private final void
1052 updateDataState() {
1053 int state = mTelephonyManager.getDataState();
1054 Resources r = getResources();
1055 String display = r.getString(R.string.radioInfo_unknown);
1056
1057 switch (state) {
1058 case TelephonyManager.DATA_CONNECTED:
1059 display = r.getString(R.string.radioInfo_data_connected);
1060 break;
1061 case TelephonyManager.DATA_CONNECTING:
1062 display = r.getString(R.string.radioInfo_data_connecting);
1063 break;
1064 case TelephonyManager.DATA_DISCONNECTED:
1065 display = r.getString(R.string.radioInfo_data_disconnected);
1066 break;
1067 case TelephonyManager.DATA_SUSPENDED:
1068 display = r.getString(R.string.radioInfo_data_suspended);
1069 break;
1070 }
johnwang342101a2009-09-23 16:22:34 -07001071
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001072 gprsState.setText(display);
1073 }
1074
1075 private final void updateNetworkType() {
Jordan Liu84deb0a2019-04-05 14:39:41 -07001076 if(mPhone != null) {
1077 ServiceState ss = mPhone.getServiceState();
Nathan Harold2b77d742016-03-19 13:22:10 -07001078 dataNetwork.setText(ServiceState.rilRadioTechnologyToString(
Jordan Liu84deb0a2019-04-05 14:39:41 -07001079 mPhone.getServiceState().getRilDataRadioTechnology()));
Nathan Harold2b77d742016-03-19 13:22:10 -07001080 voiceNetwork.setText(ServiceState.rilRadioTechnologyToString(
Jordan Liu84deb0a2019-04-05 14:39:41 -07001081 mPhone.getServiceState().getRilVoiceRadioTechnology()));
Nathan Harold2b77d742016-03-19 13:22:10 -07001082 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001083 }
1084
1085 private final void
1086 updateProperties() {
1087 String s;
1088 Resources r = getResources();
1089
Jordan Liu84deb0a2019-04-05 14:39:41 -07001090 s = mPhone.getDeviceId();
johnwang342101a2009-09-23 16:22:34 -07001091 if (s == null) s = r.getString(R.string.radioInfo_unknown);
Wink Savillec3886682009-04-02 11:00:56 -07001092 mDeviceId.setText(s);
johnwang342101a2009-09-23 16:22:34 -07001093
Jordan Liu84deb0a2019-04-05 14:39:41 -07001094 s = mPhone.getSubscriberId();
Meng Wang9053f172017-06-23 16:02:14 -07001095 if (s == null) s = r.getString(R.string.radioInfo_unknown);
1096 mSubscriberId.setText(s);
1097
Nathan Haroldcea413a2015-11-23 15:48:10 -08001098 //FIXME: Replace with a TelephonyManager call
Jordan Liu84deb0a2019-04-05 14:39:41 -07001099 s = mPhone.getLine1Number();
johnwang342101a2009-09-23 16:22:34 -07001100 if (s == null) s = r.getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001101 number.setText(s);
1102 }
1103
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001104 private final void updateDataStats2() {
1105 Resources r = getResources();
1106
Jeff Sharkey93029862011-05-27 18:26:15 -07001107 long txPackets = TrafficStats.getMobileTxPackets();
1108 long rxPackets = TrafficStats.getMobileRxPackets();
1109 long txBytes = TrafficStats.getMobileTxBytes();
1110 long rxBytes = TrafficStats.getMobileRxBytes();
johnwang342101a2009-09-23 16:22:34 -07001111
Jeff Sharkey93029862011-05-27 18:26:15 -07001112 String packets = r.getString(R.string.radioInfo_display_packets);
1113 String bytes = r.getString(R.string.radioInfo_display_bytes);
johnwang342101a2009-09-23 16:22:34 -07001114
Jeff Sharkey93029862011-05-27 18:26:15 -07001115 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
1116 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001117 }
1118
1119 /**
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001120 * Ping a host name
1121 */
1122 private final void pingHostname() {
1123 try {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001124 try {
1125 Process p4 = Runtime.getRuntime().exec("ping -c 1 www.google.com");
1126 int status4 = p4.waitFor();
1127 if (status4 == 0) {
1128 mPingHostnameResultV4 = "Pass";
1129 } else {
1130 mPingHostnameResultV4 = String.format("Fail(%d)", status4);
1131 }
1132 } catch (IOException e) {
1133 mPingHostnameResultV4 = "Fail: IOException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001134 }
Nathan Haroldcea413a2015-11-23 15:48:10 -08001135 try {
1136 Process p6 = Runtime.getRuntime().exec("ping6 -c 1 www.google.com");
1137 int status6 = p6.waitFor();
1138 if (status6 == 0) {
1139 mPingHostnameResultV6 = "Pass";
1140 } else {
1141 mPingHostnameResultV6 = String.format("Fail(%d)", status6);
1142 }
1143 } catch (IOException e) {
1144 mPingHostnameResultV6 = "Fail: IOException";
1145 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001146 } catch (InterruptedException e) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001147 mPingHostnameResultV4 = mPingHostnameResultV6 = "Fail: InterruptedException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001148 }
1149 }
1150
1151 /**
1152 * This function checks for basic functionality of HTTP Client.
1153 */
1154 private void httpClientTest() {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001155 HttpURLConnection urlConnection = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001156 try {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001157 // TODO: Hardcoded for now, make it UI configurable
Alex Klyubinb0090232015-04-02 11:08:51 -07001158 URL url = new URL("https://www.google.com");
Narayan Kamathf25627c2014-12-12 13:53:28 +00001159 urlConnection = (HttpURLConnection) url.openConnection();
1160 if (urlConnection.getResponseCode() == 200) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001161 mHttpClientTestResult = "Pass";
1162 } else {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001163 mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001164 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001165 } catch (IOException e) {
1166 mHttpClientTestResult = "Fail: IOException";
Narayan Kamathf25627c2014-12-12 13:53:28 +00001167 } finally {
1168 if (urlConnection != null) {
1169 urlConnection.disconnect();
1170 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001171 }
1172 }
1173
1174 private void refreshSmsc() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001175 //FIXME: Replace with a TelephonyManager call
Jordan Liu84deb0a2019-04-05 14:39:41 -07001176 mPhone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001177 }
1178
Nathan Haroldcea413a2015-11-23 15:48:10 -08001179 private final void updateAllCellInfo() {
1180
1181 mCellInfo.setText("");
Nathan Haroldcea413a2015-11-23 15:48:10 -08001182 mLocation.setText("");
1183
1184 final Runnable updateAllCellInfoResults = new Runnable() {
1185 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001186 updateLocation(mCellLocationResult);
1187 updateCellInfo(mCellInfoResult);
1188 }
1189 };
1190
1191 Thread locThread = new Thread() {
1192 @Override
1193 public void run() {
1194 mCellInfoResult = mTelephonyManager.getAllCellInfo();
1195 mCellLocationResult = mTelephonyManager.getCellLocation();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001196
1197 mHandler.post(updateAllCellInfoResults);
1198 }
1199 };
1200 locThread.start();
1201 }
1202
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001203 private final void updatePingState() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001204 // Set all to unknown since the threads will take a few secs to update.
Nathan Haroldcea413a2015-11-23 15:48:10 -08001205 mPingHostnameResultV4 = getResources().getString(R.string.radioInfo_unknown);
1206 mPingHostnameResultV6 = getResources().getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001207 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
1208
Nathan Haroldcea413a2015-11-23 15:48:10 -08001209 mPingHostnameV4.setText(mPingHostnameResultV4);
1210 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001211 mHttpClientTest.setText(mHttpClientTestResult);
1212
1213 final Runnable updatePingResults = new Runnable() {
1214 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001215 mPingHostnameV4.setText(mPingHostnameResultV4);
1216 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001217 mHttpClientTest.setText(mHttpClientTestResult);
1218 }
1219 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001220
1221 Thread hostname = new Thread() {
1222 @Override
1223 public void run() {
1224 pingHostname();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001225 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001226 }
1227 };
1228 hostname.start();
1229
1230 Thread httpClient = new Thread() {
1231 @Override
1232 public void run() {
1233 httpClientTest();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001234 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001235 }
1236 };
1237 httpClient.start();
1238 }
1239
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001240 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
1241 public boolean onMenuItemClick(MenuItem item) {
1242 Intent intent = new Intent(Intent.ACTION_VIEW);
1243 // XXX We need to specify the component here because if we don't
1244 // the activity manager will try to resolve the type by calling
1245 // the content provider, which causes it to be loaded in a process
1246 // other than the Dialer process, which causes a lot of stuff to
1247 // break.
Jordan Liu84deb0a2019-04-05 14:39:41 -07001248 intent.setClassName("com.android.phone", "com.android.phone.SimContacts");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001249 startActivity(intent);
1250 return true;
1251 }
1252 };
1253
1254 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
1255 public boolean onMenuItemClick(MenuItem item) {
1256 Intent intent = new Intent(Intent.ACTION_VIEW);
1257 // XXX We need to specify the component here because if we don't
1258 // the activity manager will try to resolve the type by calling
1259 // the content provider, which causes it to be loaded in a process
1260 // other than the Dialer process, which causes a lot of stuff to
1261 // break.
Jordan Liu84deb0a2019-04-05 14:39:41 -07001262 intent.setClassName("com.android.phone", "com.android.phone.settings.fdn.FdnList");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001263 startActivity(intent);
1264 return true;
1265 }
1266 };
1267
1268 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
1269 public boolean onMenuItemClick(MenuItem item) {
1270 Intent intent = new Intent(
Wink Savillec3886682009-04-02 11:00:56 -07001271 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001272 // XXX We need to specify the component here because if we don't
1273 // the activity manager will try to resolve the type by calling
1274 // the content provider, which causes it to be loaded in a process
1275 // other than the Dialer process, which causes a lot of stuff to
1276 // break.
Jordan Liu84deb0a2019-04-05 14:39:41 -07001277 intent.setClassName("com.android.phone", "com.android.phone.ADNList");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001278 startActivity(intent);
1279 return true;
1280 }
1281 };
1282
Nathan Harolde272c202016-10-27 13:45:00 -07001283 private MenuItem.OnMenuItemClickListener mGetImsStatus = new MenuItem.OnMenuItemClickListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001284 public boolean onMenuItemClick(MenuItem item) {
Jordan Liu84deb0a2019-04-05 14:39:41 -07001285 boolean isImsRegistered = mPhone.isImsRegistered();
1286 boolean availableVolte = mPhone.isVolteEnabled();
1287 boolean availableWfc = mPhone.isWifiCallingEnabled();
1288 boolean availableVt = mPhone.isVideoEnabled();
1289 boolean availableUt = mPhone.isUtEnabled();
Nathan Harolde272c202016-10-27 13:45:00 -07001290
1291 final String imsRegString = isImsRegistered ?
1292 getString(R.string.radio_info_ims_reg_status_registered) :
1293 getString(R.string.radio_info_ims_reg_status_not_registered);
1294
1295 final String available = getString(R.string.radio_info_ims_feature_status_available);
1296 final String unavailable = getString(
1297 R.string.radio_info_ims_feature_status_unavailable);
1298
1299 String imsStatus = getString(R.string.radio_info_ims_reg_status,
1300 imsRegString,
1301 availableVolte ? available : unavailable,
1302 availableWfc ? available : unavailable,
1303 availableVt ? available : unavailable,
1304 availableUt ? available : unavailable);
1305
1306 AlertDialog imsDialog = new AlertDialog.Builder(RadioInfo.this)
1307 .setMessage(imsStatus)
1308 .setTitle(getString(R.string.radio_info_ims_reg_status_title))
1309 .create();
1310
1311 imsDialog.show();
1312
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001313 return true;
1314 }
1315 };
1316
1317 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
1318 public boolean onMenuItemClick(MenuItem item) {
1319 Intent intent = new Intent();
1320 intent.setClass(RadioInfo.this, BandMode.class);
1321 startActivity(intent);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001322 return true;
1323 }
1324 };
johnwang342101a2009-09-23 16:22:34 -07001325
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001326 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
1327 public boolean onMenuItemClick(MenuItem item) {
1328 int state = mTelephonyManager.getDataState();
1329 switch (state) {
1330 case TelephonyManager.DATA_CONNECTED:
Jack Yu50972ed2018-12-13 11:51:20 -08001331 mTelephonyManager.setDataEnabled(false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001332 break;
1333 case TelephonyManager.DATA_DISCONNECTED:
Jack Yu50972ed2018-12-13 11:51:20 -08001334 mTelephonyManager.setDataEnabled(true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001335 break;
1336 default:
1337 // do nothing
1338 break;
1339 }
1340 return true;
1341 }
1342 };
1343
Nathan Harold2b77d742016-03-19 13:22:10 -07001344 private boolean isRadioOn() {
1345 //FIXME: Replace with a TelephonyManager call
Jordan Liu84deb0a2019-04-05 14:39:41 -07001346 return mPhone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
Nathan Harold2b77d742016-03-19 13:22:10 -07001347 }
1348
1349 private void updateRadioPowerState() {
1350 //delightful hack to prevent on-checked-changed calls from
1351 //actually forcing the radio preference to its transient/current value.
1352 radioPowerOnSwitch.setOnCheckedChangeListener(null);
1353 radioPowerOnSwitch.setChecked(isRadioOn());
1354 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
1355 }
1356
Nathan Harolde272c202016-10-27 13:45:00 -07001357 void setImsVolteProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001358 Log.d(TAG, "setImsVolteProvisioned state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001359 setImsConfigProvisionedState(IMS_VOLTE_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001360 }
1361
Nathan Harolde272c202016-10-27 13:45:00 -07001362 void setImsVtProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001363 Log.d(TAG, "setImsVtProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001364 setImsConfigProvisionedState(IMS_VT_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001365 }
1366
Nathan Harolde272c202016-10-27 13:45:00 -07001367 void setImsWfcProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001368 Log.d(TAG, "setImsWfcProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001369 setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001370 }
1371
Meng Wang586741c2017-04-26 15:02:51 -07001372 void setEabProvisionedState(boolean state) {
1373 Log.d(TAG, "setEabProvisioned() state: " + ((state)? "on":"off"));
1374 setImsConfigProvisionedState(EAB_PROVISIONED_CONFIG_ID, state);
1375 }
1376
Nathan Harolde272c202016-10-27 13:45:00 -07001377 void setImsConfigProvisionedState(int configItem, boolean state) {
Jordan Liu84deb0a2019-04-05 14:39:41 -07001378 if (mPhone != null && mImsManager != null) {
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001379 QueuedWork.queue(new Runnable() {
Nathan Harold12e1f552016-06-17 13:55:38 -07001380 public void run() {
1381 try {
1382 mImsManager.getConfigInterface().setProvisionedValue(
1383 configItem,
1384 state? 1 : 0);
1385 } catch (ImsException e) {
1386 Log.e(TAG, "setImsConfigProvisioned() exception:", e);
1387 }
1388 }
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001389 }, false);
Nathan Harold12e1f552016-06-17 13:55:38 -07001390 }
1391 }
1392
Nathan Harold2b77d742016-03-19 13:22:10 -07001393 OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() {
1394 @Override
1395 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1396 log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
Jordan Liu84deb0a2019-04-05 14:39:41 -07001397 mPhone.setRadioPower(isChecked);
Nathan Harold2b77d742016-03-19 13:22:10 -07001398 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001399 };
1400
Nathan Harold12e1f552016-06-17 13:55:38 -07001401 private boolean isImsVolteProvisioned() {
Jordan Liu84deb0a2019-04-05 14:39:41 -07001402 if (mPhone != null && mImsManager != null) {
1403 return mImsManager.isVolteEnabledByPlatform(mPhone.getContext())
1404 && mImsManager.isVolteProvisionedOnDevice(mPhone.getContext());
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -08001405 }
1406 return false;
1407 }
1408
Nathan Harold12e1f552016-06-17 13:55:38 -07001409 OnCheckedChangeListener mImsVolteCheckedChangeListener = new OnCheckedChangeListener() {
Wink Saville426fc662011-09-25 14:39:02 -07001410 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -07001411 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001412 setImsVolteProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001413 }
Wink Saville426fc662011-09-25 14:39:02 -07001414 };
1415
Nathan Harold12e1f552016-06-17 13:55:38 -07001416 private boolean isImsVtProvisioned() {
Jordan Liu84deb0a2019-04-05 14:39:41 -07001417 if (mPhone != null && mImsManager != null) {
1418 return mImsManager.isVtEnabledByPlatform(mPhone.getContext())
1419 && mImsManager.isVtProvisionedOnDevice(mPhone.getContext());
Nathan Harold12e1f552016-06-17 13:55:38 -07001420 }
1421 return false;
1422 }
1423
1424 OnCheckedChangeListener mImsVtCheckedChangeListener = new OnCheckedChangeListener() {
1425 @Override
1426 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1427 setImsVtProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001428 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001429 };
1430
1431 private boolean isImsWfcProvisioned() {
Jordan Liu84deb0a2019-04-05 14:39:41 -07001432 if (mPhone != null && mImsManager != null) {
1433 return mImsManager.isWfcEnabledByPlatform(mPhone.getContext())
1434 && mImsManager.isWfcProvisionedOnDevice(mPhone.getContext());
Nathan Harold12e1f552016-06-17 13:55:38 -07001435 }
1436 return false;
1437 }
1438
1439 OnCheckedChangeListener mImsWfcCheckedChangeListener = new OnCheckedChangeListener() {
1440 @Override
1441 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1442 setImsWfcProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001443 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001444 };
1445
Meng Wang586741c2017-04-26 15:02:51 -07001446 private boolean isEabProvisioned() {
1447 return isFeatureProvisioned(EAB_PROVISIONED_CONFIG_ID, false);
1448 }
1449
1450 OnCheckedChangeListener mEabCheckedChangeListener = new OnCheckedChangeListener() {
1451 @Override
1452 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1453 setEabProvisionedState(isChecked);
1454 }
1455 };
1456
1457 private boolean isFeatureProvisioned(int featureId, boolean defaultValue) {
1458 boolean provisioned = defaultValue;
1459 if (mImsManager != null) {
1460 try {
1461 ImsConfig imsConfig = mImsManager.getConfigInterface();
1462 if (imsConfig != null) {
1463 provisioned =
1464 (imsConfig.getProvisionedValue(featureId)
1465 == ImsConfig.FeatureValueConstants.ON);
1466 }
1467 } catch (ImsException ex) {
1468 Log.e(TAG, "isFeatureProvisioned() exception:", ex);
1469 }
1470 }
1471
1472 log("isFeatureProvisioned() featureId=" + featureId + " provisioned=" + provisioned);
1473 return provisioned;
1474 }
1475
1476 private static boolean isEabEnabledByPlatform(Context context) {
1477 if (context != null) {
1478 CarrierConfigManager configManager = (CarrierConfigManager)
1479 context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
1480 if (configManager != null && configManager.getConfig().getBoolean(
1481 CarrierConfigManager.KEY_USE_RCS_PRESENCE_BOOL)) {
1482 return true;
1483 }
1484 }
1485 return false;
1486 }
1487
Nathan Harold12e1f552016-06-17 13:55:38 -07001488 private void updateImsProvisionedState() {
Jordan Liu84deb0a2019-04-05 14:39:41 -07001489 if (!ImsManager.isImsSupportedOnDevice(mPhone.getContext())) {
Brad Ebinger5dfe7f82019-03-11 17:33:53 -07001490 return;
1491 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001492 log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
Nathan Harold2b77d742016-03-19 13:22:10 -07001493 //delightful hack to prevent on-checked-changed calls from
1494 //actually forcing the ims provisioning to its transient/current value.
Nathan Harold12e1f552016-06-17 13:55:38 -07001495 imsVolteProvisionedSwitch.setOnCheckedChangeListener(null);
1496 imsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned());
1497 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001498 imsVolteProvisionedSwitch.setEnabled(!Build.IS_USER
Jordan Liu84deb0a2019-04-05 14:39:41 -07001499 && mImsManager.isVolteEnabledByPlatform(mPhone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001500
1501 imsVtProvisionedSwitch.setOnCheckedChangeListener(null);
1502 imsVtProvisionedSwitch.setChecked(isImsVtProvisioned());
1503 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001504 imsVtProvisionedSwitch.setEnabled(!Build.IS_USER
Jordan Liu84deb0a2019-04-05 14:39:41 -07001505 && mImsManager.isVtEnabledByPlatform(mPhone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001506
1507 imsWfcProvisionedSwitch.setOnCheckedChangeListener(null);
1508 imsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned());
1509 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001510 imsWfcProvisionedSwitch.setEnabled(!Build.IS_USER
Jordan Liu84deb0a2019-04-05 14:39:41 -07001511 && mImsManager.isWfcEnabledByPlatform(mPhone.getContext()));
Meng Wang586741c2017-04-26 15:02:51 -07001512
1513 eabProvisionedSwitch.setOnCheckedChangeListener(null);
1514 eabProvisionedSwitch.setChecked(isEabProvisioned());
1515 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001516 eabProvisionedSwitch.setEnabled(!Build.IS_USER
Jordan Liu84deb0a2019-04-05 14:39:41 -07001517 && isEabEnabledByPlatform(mPhone.getContext()));
Wink Saville426fc662011-09-25 14:39:02 -07001518 }
1519
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001520 OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
1521 public void onClick(View v) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001522 //FIXME: Replace with a TelephonyManager call
Jordan Liu84deb0a2019-04-05 14:39:41 -07001523 mPhone.disableDnsCheck(!mPhone.isDnsCheckDisabled());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001524 updateDnsCheckState();
1525 }
1526 };
johnwang342101a2009-09-23 16:22:34 -07001527
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001528 OnClickListener mOemInfoButtonHandler = new OnClickListener() {
1529 public void onClick(View v) {
1530 Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO");
1531 try {
1532 startActivity(intent);
1533 } catch (android.content.ActivityNotFoundException ex) {
Wink Savillebf471282013-04-05 15:04:05 -07001534 log("OEM-specific Info/Settings Activity Not Found : " + ex);
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001535 // If the activity does not exist, there are no OEM
1536 // settings, and so we can just do nothing...
1537 }
1538 }
1539 };
1540
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001541 OnClickListener mPingButtonHandler = new OnClickListener() {
1542 public void onClick(View v) {
1543 updatePingState();
1544 }
1545 };
1546
1547 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
1548 public void onClick(View v) {
1549 updateSmscButton.setEnabled(false);
Jordan Liu84deb0a2019-04-05 14:39:41 -07001550 mPhone.setSmscAddress(smsc.getText().toString(),
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001551 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
1552 }
1553 };
1554
1555 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
1556 public void onClick(View v) {
1557 refreshSmsc();
1558 }
1559 };
1560
Youhan Wangfd781e92016-12-16 15:53:16 -08001561 OnClickListener mCarrierProvisioningButtonHandler = new OnClickListener() {
1562 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001563 final Intent intent = new Intent("com.android.settings.CARRIER_PROVISIONING");
1564 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1565 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001566 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001567 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001568 }
1569 };
1570
1571 OnClickListener mTriggerCarrierProvisioningButtonHandler = new OnClickListener() {
1572 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001573 final Intent intent = new Intent("com.android.settings.TRIGGER_CARRIER_PROVISIONING");
1574 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1575 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001576 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001577 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001578 }
1579 };
1580
Nathan Haroldcea413a2015-11-23 15:48:10 -08001581 AdapterView.OnItemSelectedListener mPreferredNetworkHandler =
1582 new AdapterView.OnItemSelectedListener() {
1583
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001584 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001585 if (mPreferredNetworkTypeResult != pos && pos >= 0
1586 && pos <= mPreferredNetworkLabels.length - 2) {
1587 mPreferredNetworkTypeResult = pos;
Nathan Harolddaea8be2018-06-05 14:02:35 -07001588
1589 // TODO: Possibly migrate this to TelephonyManager.setPreferredNetworkType()
1590 // which today still has some issues (mostly that the "set" is conditional
1591 // on a successful modem call, which is not what we want). Instead we always
1592 // want this setting to be set, so that if the radio hiccups and this setting
1593 // is for some reason unsuccessful, future calls to the radio will reflect
1594 // the users's preference which is set here.
Jordan Liu84deb0a2019-04-05 14:39:41 -07001595 final int subId = mPhone.getSubId();
Nathan Harolddaea8be2018-06-05 14:02:35 -07001596 if (SubscriptionManager.isUsableSubIdValue(subId)) {
Jordan Liu84deb0a2019-04-05 14:39:41 -07001597 Settings.Global.putInt(mPhone.getContext().getContentResolver(),
Nathan Harolddaea8be2018-06-05 14:02:35 -07001598 PREFERRED_NETWORK_MODE + subId, mPreferredNetworkTypeResult);
1599 }
1600 log("Calling setPreferredNetworkType(" + mPreferredNetworkTypeResult + ")");
Nathan Haroldcea413a2015-11-23 15:48:10 -08001601 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
Jordan Liu84deb0a2019-04-05 14:39:41 -07001602 mPhone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg);
1603 }
1604 }
1605
1606 public void onNothingSelected(AdapterView parent) {
1607 }
1608 };
1609
1610 AdapterView.OnItemSelectedListener mSelectPhoneIndexHandler =
1611 new AdapterView.OnItemSelectedListener() {
1612
1613 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1614 if (pos >= 0 && pos <= mPhoneIndexLabels.length - 1) {
1615 // the array position is equal to the phone index
1616 int phoneIndex = pos;
1617 Phone[] phones = PhoneFactory.getPhones();
1618 if (phones == null || phones.length <= phoneIndex) {
Jordan Liub69e8f22019-04-02 12:13:31 -07001619 log("phoneIndex " + phoneIndex + " is invalid");
1620 return;
1621 }
1622 log("switching to phone " + phoneIndex);
1623 // getSubId says it takes a slotIndex, but it actually takes a phone index
Jordan Liu655c1be2019-08-07 16:51:36 -07001624 int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
Jordan Liub69e8f22019-04-02 12:13:31 -07001625 int[] subIds = SubscriptionManager.getSubId(phoneIndex);
Jordan Liu655c1be2019-08-07 16:51:36 -07001626 if (subIds != null && subIds.length > 0) {
1627 subId = subIds[0];
Jordan Liub69e8f22019-04-02 12:13:31 -07001628 }
1629 mSelectedPhoneIndex = phoneIndex;
1630
Jordan Liu655c1be2019-08-07 16:51:36 -07001631 updatePhoneIndex(phoneIndex, subId);
Jordan Liub69e8f22019-04-02 12:13:31 -07001632 }
1633 }
1634
1635 public void onNothingSelected(AdapterView parent) {
1636 }
1637 };
1638
Nathan Harold2b77d742016-03-19 13:22:10 -07001639 AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler =
1640 new AdapterView.OnItemSelectedListener() {
Wink Savillebf471282013-04-05 15:04:05 -07001641
Nathan Harold2b77d742016-03-19 13:22:10 -07001642 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1643 mCellInfoRefreshRateIndex = pos;
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -07001644 mTelephonyManager.setCellInfoListRate(mCellInfoRefreshRates[pos]);
Nathan Harold2b77d742016-03-19 13:22:10 -07001645 updateAllCellInfo();
1646 }
1647
1648 public void onNothingSelected(AdapterView parent) {
1649 }
1650 };
1651
Naina Nallurid1b57f62019-01-08 15:19:58 -08001652 boolean isCbrsSupported() {
1653 return getResources().getBoolean(
1654 com.android.internal.R.bool.config_cbrs_supported);
1655 }
1656
1657 void updateCbrsDataState(boolean state) {
1658 Log.d(TAG, "setCbrsDataSwitchState() state:" + ((state)? "on":"off"));
1659 if (mTelephonyManager != null) {
1660 QueuedWork.queue(new Runnable() {
1661 public void run() {
1662 mTelephonyManager.setOpportunisticNetworkState(state);
1663 cbrsDataSwitch.setChecked(getCbrsDataState());
1664 }
1665 }, false);
1666 }
1667 }
1668
1669 boolean getCbrsDataState() {
1670 boolean state = false;
1671 if (mTelephonyManager != null) {
1672 state = mTelephonyManager.isOpportunisticNetworkEnabled();
1673 }
1674 Log.d(TAG, "getCbrsDataState() state:" +((state)? "on":"off"));
1675 return state;
1676 }
1677
1678 OnCheckedChangeListener mCbrsDataSwitchChangeListener = new OnCheckedChangeListener() {
1679 @Override
1680 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1681 updateCbrsDataState(isChecked);
1682 }
1683 };
1684
Pengquan Meng7f602c72019-01-28 19:12:18 -08001685 private void showDsdsChangeDialog() {
1686 final AlertDialog confirmDialog = new Builder(RadioInfo.this)
1687 .setTitle(R.string.dsds_dialog_title)
1688 .setMessage(R.string.dsds_dialog_message)
1689 .setPositiveButton(R.string.dsds_dialog_confirm, mOnDsdsDialogConfirmedListener)
1690 .setNegativeButton(R.string.dsds_dialog_cancel, mOnDsdsDialogConfirmedListener)
1691 .create();
1692 confirmDialog.show();
1693 }
Naina Nallurid1b57f62019-01-08 15:19:58 -08001694
Pengquan Meng7f602c72019-01-28 19:12:18 -08001695 private static boolean isDsdsSupported() {
Michele3dafea22019-03-19 15:53:45 -07001696 return (TelephonyManager.getDefault().isMultiSimSupported()
1697 == TelephonyManager.MULTISIM_ALLOWED);
Pengquan Meng7f602c72019-01-28 19:12:18 -08001698 }
1699
1700 private static boolean isDsdsEnabled() {
1701 return TelephonyManager.getDefault().getPhoneCount() > 1;
1702 }
1703
1704 private void performDsdsSwitch() {
1705 mTelephonyManager.switchMultiSimConfig(dsdsSwitch.isChecked() ? 2 : 1);
1706 }
1707
Pengquan Menga40d2742019-04-30 19:32:58 -07001708 /**
1709 * @return {@code True} if the device is only supported dsds mode.
1710 */
1711 private boolean dsdsModeOnly() {
1712 String dsdsMode = SystemProperties.get(DSDS_MODE_PROPERTY);
1713 return !TextUtils.isEmpty(dsdsMode) && Integer.parseInt(dsdsMode) == ALWAYS_ON_DSDS_MODE;
1714 }
1715
Pengquan Meng7f602c72019-01-28 19:12:18 -08001716 DialogInterface.OnClickListener mOnDsdsDialogConfirmedListener =
1717 new DialogInterface.OnClickListener() {
1718 @Override
1719 public void onClick(DialogInterface dialog, int which) {
1720 if (which == DialogInterface.BUTTON_POSITIVE) {
1721 dsdsSwitch.toggle();
1722 performDsdsSwitch();
1723 }
1724 }
1725 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001726}