blob: 9a06c3ebaeab9288c706c7b7c262464fa3a66ee8 [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;
Nathan Harolddaea8be2018-06-05 14:02:35 -070043import android.provider.Settings;
Meng Wang586741c2017-04-26 15:02:51 -070044import android.telephony.CarrierConfigManager;
Fan Zhangc7162cd2018-06-18 15:21:41 -070045import android.telephony.CellIdentityCdma;
46import android.telephony.CellIdentityGsm;
47import android.telephony.CellIdentityLte;
48import android.telephony.CellIdentityWcdma;
Wink Saville79bff2a2012-06-01 14:37:21 -070049import android.telephony.CellInfo;
Nathan Haroldcea413a2015-11-23 15:48:10 -080050import android.telephony.CellInfoCdma;
51import android.telephony.CellInfoGsm;
52import android.telephony.CellInfoLte;
53import android.telephony.CellInfoWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080054import android.telephony.CellLocation;
Nathan Haroldcea413a2015-11-23 15:48:10 -080055import android.telephony.CellSignalStrengthCdma;
56import android.telephony.CellSignalStrengthGsm;
57import android.telephony.CellSignalStrengthLte;
58import android.telephony.CellSignalStrengthWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080059import android.telephony.PhoneStateListener;
Nathan Harold433ca442018-04-23 18:20:43 -070060import android.telephony.PhysicalChannelConfig;
Fan Zhangc7162cd2018-06-18 15:21:41 -070061import android.telephony.PreciseCallState;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080062import android.telephony.ServiceState;
Nathan Harold2b77d742016-03-19 13:22:10 -070063import android.telephony.SignalStrength;
Nathan Haroldcea413a2015-11-23 15:48:10 -080064import android.telephony.SubscriptionManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080065import android.telephony.TelephonyManager;
jsh534f5ae2009-09-24 09:19:22 -070066import android.telephony.cdma.CdmaCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080067import android.telephony.gsm.GsmCellLocation;
Nathan Harold6e16fdf2018-04-17 17:01:32 -070068import android.text.TextUtils;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080069import android.util.Log;
70import android.view.Menu;
71import android.view.MenuItem;
72import android.view.View;
73import android.view.View.OnClickListener;
74import android.widget.AdapterView;
75import android.widget.ArrayAdapter;
76import android.widget.Button;
Nathan Harold2b77d742016-03-19 13:22:10 -070077import android.widget.CompoundButton;
78import android.widget.CompoundButton.OnCheckedChangeListener;
Jason Monk39b46742015-09-10 15:52:51 -040079import android.widget.EditText;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080080import android.widget.Spinner;
Nathan Harold2b77d742016-03-19 13:22:10 -070081import android.widget.Switch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080082import android.widget.TextView;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080083
Fan Zhang23f8d592018-08-28 15:11:40 -070084import androidx.appcompat.app.AlertDialog;
Pengquan Meng7f602c72019-01-28 19:12:18 -080085import androidx.appcompat.app.AlertDialog.Builder;
Fan Zhang23f8d592018-08-28 15:11:40 -070086
Jason Monk39b46742015-09-10 15:52:51 -040087import com.android.ims.ImsConfig;
88import com.android.ims.ImsException;
89import com.android.ims.ImsManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080090import com.android.internal.telephony.Phone;
91import com.android.internal.telephony.PhoneFactory;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080092
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080093import java.io.IOException;
Jason Monk39b46742015-09-10 15:52:51 -040094import java.net.HttpURLConnection;
95import java.net.URL;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080096import java.util.List;
97
Pengquan Meng7f602c72019-01-28 19:12:18 -080098// TODO(b/123598192) consider to move this activity to telephony package.
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080099public class RadioInfo extends Activity {
Nathan Harold2b77d742016-03-19 13:22:10 -0700100 private static final String TAG = "RadioInfo";
johnwang342101a2009-09-23 16:22:34 -0700101
Nathan Harold2b77d742016-03-19 13:22:10 -0700102 private static final String[] mPreferredNetworkLabels = {
103 "WCDMA preferred",
104 "GSM only",
105 "WCDMA only",
106 "GSM auto (PRL)",
107 "CDMA auto (PRL)",
108 "CDMA only",
109 "EvDo only",
110 "Global auto (PRL)",
111 "LTE/CDMA auto (PRL)",
112 "LTE/UMTS auto (PRL)",
113 "LTE/CDMA/UMTS auto (PRL)",
114 "LTE only",
115 "LTE/WCDMA",
116 "TD-SCDMA only",
117 "TD-SCDMA/WCDMA",
118 "LTE/TD-SCDMA",
119 "TD-SCDMA/GSM",
120 "TD-SCDMA/UMTS",
121 "LTE/TD-SCDMA/WCDMA",
122 "LTE/TD-SCDMA/UMTS",
123 "TD-SCDMA/CDMA/UMTS",
124 "Global/TD-SCDMA",
125 "Unknown"
126 };
127
Jordan Liub69e8f22019-04-02 12:13:31 -0700128 private static String[] mPhoneIndexLabels;
Nathan Harold2b77d742016-03-19 13:22:10 -0700129
130 private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE;
131 private static final int CELL_INFO_LIST_RATE_MAX = 0;
132
Nathan Harold12e1f552016-06-17 13:55:38 -0700133
134 private static final int IMS_VOLTE_PROVISIONED_CONFIG_ID =
135 ImsConfig.ConfigConstants.VLT_SETTING_ENABLED;
136
137 private static final int IMS_VT_PROVISIONED_CONFIG_ID =
138 ImsConfig.ConfigConstants.LVC_SETTING_ENABLED;
139
140 private static final int IMS_WFC_PROVISIONED_CONFIG_ID =
141 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED;
142
Meng Wang586741c2017-04-26 15:02:51 -0700143 private static final int EAB_PROVISIONED_CONFIG_ID =
144 ImsConfig.ConfigConstants.EAB_SETTING_ENABLED;
145
Nathan Harold2b77d742016-03-19 13:22:10 -0700146 //Values in must match mCellInfoRefreshRates
147 private static final String[] mCellInfoRefreshRateLabels = {
148 "Disabled",
149 "Immediate",
150 "Min 5s",
151 "Min 10s",
152 "Min 60s"
153 };
154
155 //Values in seconds, must match mCellInfoRefreshRateLabels
156 private static final int mCellInfoRefreshRates[] = {
157 CELL_INFO_LIST_RATE_DISABLED,
158 CELL_INFO_LIST_RATE_MAX,
159 5000,
160 10000,
161 60000
162 };
163
Jordan Liub69e8f22019-04-02 12:13:31 -0700164 private static void log(String s) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700165 Log.d(TAG, s);
166 }
167
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800168 private static final int EVENT_CFI_CHANGED = 302;
169
170 private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000;
171 private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800172 private static final int EVENT_QUERY_SMSC_DONE = 1005;
173 private static final int EVENT_UPDATE_SMSC_DONE = 1006;
174
Jordan Liub69e8f22019-04-02 12:13:31 -0700175 private static final int MENU_ITEM_SELECT_BAND = 0;
176 private static final int MENU_ITEM_VIEW_ADN = 1;
177 private static final int MENU_ITEM_VIEW_FDN = 2;
178 private static final int MENU_ITEM_VIEW_SDN = 3;
179 private static final int MENU_ITEM_GET_IMS_STATUS = 4;
180 private static final int MENU_ITEM_TOGGLE_DATA = 5;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800181
Wink Savillec3886682009-04-02 11:00:56 -0700182 private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800183 private TextView number;
Jordan Liub69e8f22019-04-02 12:13:31 -0700184 private TextView mSubscriptionId;
185 private TextView mDds;
Meng Wang9053f172017-06-23 16:02:14 -0700186 private TextView mSubscriberId;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800187 private TextView callState;
188 private TextView operatorName;
189 private TextView roamingState;
190 private TextView gsmState;
191 private TextView gprsState;
Nathan Harold2b77d742016-03-19 13:22:10 -0700192 private TextView voiceNetwork;
193 private TextView dataNetwork;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800194 private TextView dBm;
195 private TextView mMwi;
196 private TextView mCfi;
197 private TextView mLocation;
Wink Saville79bff2a2012-06-01 14:37:21 -0700198 private TextView mCellInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800199 private TextView sent;
200 private TextView received;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800201 private TextView mPingHostnameV4;
202 private TextView mPingHostnameV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800203 private TextView mHttpClientTest;
Nathan Harold433ca442018-04-23 18:20:43 -0700204 private TextView mPhyChanConfig;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800205 private TextView dnsCheckState;
Nathan Haroldf10ea322018-04-24 13:31:07 -0700206 private TextView mDownlinkKbps;
207 private TextView mUplinkKbps;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800208 private EditText smsc;
Nathan Harold2b77d742016-03-19 13:22:10 -0700209 private Switch radioPowerOnSwitch;
210 private Button cellInfoRefreshRateButton;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800211 private Button dnsCheckToggleButton;
212 private Button pingTestButton;
213 private Button updateSmscButton;
214 private Button refreshSmscButton;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800215 private Button oemInfoButton;
Youhan Wangfd781e92016-12-16 15:53:16 -0800216 private Button carrierProvisioningButton;
217 private Button triggercarrierProvisioningButton;
Nathan Harold12e1f552016-06-17 13:55:38 -0700218 private Switch imsVolteProvisionedSwitch;
219 private Switch imsVtProvisionedSwitch;
220 private Switch imsWfcProvisionedSwitch;
Meng Wang586741c2017-04-26 15:02:51 -0700221 private Switch eabProvisionedSwitch;
Naina Nallurid1b57f62019-01-08 15:19:58 -0800222 private Switch cbrsDataSwitch;
Pengquan Meng7f602c72019-01-28 19:12:18 -0800223 private Switch dsdsSwitch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800224 private Spinner preferredNetworkType;
Jordan Liub69e8f22019-04-02 12:13:31 -0700225 private Spinner mSelectPhoneIndex;
Nathan Harold2b77d742016-03-19 13:22:10 -0700226 private Spinner cellInfoRefreshRateSpinner;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800227
Nathan Haroldf10ea322018-04-24 13:31:07 -0700228 private ConnectivityManager mConnectivityManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800229 private TelephonyManager mTelephonyManager;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800230 private ImsManager mImsManager = null;
Jordan Liu4cb626c2019-04-11 21:53:13 +0000231 private Phone phone = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800232
Nathan Haroldcea413a2015-11-23 15:48:10 -0800233 private String mPingHostnameResultV4;
234 private String mPingHostnameResultV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800235 private String mHttpClientTestResult;
236 private boolean mMwiValue = false;
237 private boolean mCfiValue = false;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800238
239 private List<CellInfo> mCellInfoResult = null;
240 private CellLocation mCellLocationResult = null;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800241
242 private int mPreferredNetworkTypeResult;
Nathan Harold2b77d742016-03-19 13:22:10 -0700243 private int mCellInfoRefreshRateIndex;
Jordan Liub69e8f22019-04-02 12:13:31 -0700244 private int mSelectedPhoneIndex;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800245
Nathan Haroldf10ea322018-04-24 13:31:07 -0700246 private final NetworkRequest mDefaultNetworkRequest = new NetworkRequest.Builder()
247 .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
248 .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
249 .build();
250
251 private final NetworkCallback mNetworkCallback = new NetworkCallback() {
252 public void onCapabilitiesChanged(Network n, NetworkCapabilities nc) {
253 int dlbw = nc.getLinkDownstreamBandwidthKbps();
254 int ulbw = nc.getLinkUpstreamBandwidthKbps();
255 updateBandwidths(dlbw, ulbw);
256 }
257 };
258
Jordan Liu4cb626c2019-04-11 21:53:13 +0000259 private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800260 @Override
261 public void onDataConnectionStateChanged(int state) {
262 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800263 updateNetworkType();
264 }
265
266 @Override
267 public void onDataActivity(int direction) {
268 updateDataStats2();
269 }
270
271 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700272 public void onCallStateChanged(int state, String incomingNumber) {
273 updateNetworkType();
274 updatePhoneState(state);
275 }
276
277 @Override
278 public void onPreciseCallStateChanged(PreciseCallState preciseState) {
279 updateNetworkType();
280 }
281
282 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800283 public void onCellLocationChanged(CellLocation location) {
284 updateLocation(location);
285 }
286
287 @Override
288 public void onMessageWaitingIndicatorChanged(boolean mwi) {
289 mMwiValue = mwi;
290 updateMessageWaiting();
291 }
292
293 @Override
294 public void onCallForwardingIndicatorChanged(boolean cfi) {
295 mCfiValue = cfi;
296 updateCallRedirect();
297 }
Wink Saville79bff2a2012-06-01 14:37:21 -0700298
299 @Override
300 public void onCellInfoChanged(List<CellInfo> arrayCi) {
Wink Savillebf471282013-04-05 15:04:05 -0700301 log("onCellInfoChanged: arrayCi=" + arrayCi);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800302 mCellInfoResult = arrayCi;
303 updateCellInfo(mCellInfoResult);
Wink Saville79bff2a2012-06-01 14:37:21 -0700304 }
Wink Saville4f0d8812014-04-15 22:05:24 -0700305
306 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700307 public void onSignalStrengthsChanged(SignalStrength signalStrength) {
308 log("onSignalStrengthChanged: SignalStrength=" +signalStrength);
309 updateSignalStrength(signalStrength);
310 }
311
312 @Override
313 public void onServiceStateChanged(ServiceState serviceState) {
314 log("onServiceStateChanged: ServiceState=" + serviceState);
315 updateServiceState(serviceState);
316 updateRadioPowerState();
317 updateNetworkType();
Nathan Harold12e1f552016-06-17 13:55:38 -0700318 updateImsProvisionedState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700319 }
Nathan Harold433ca442018-04-23 18:20:43 -0700320
321 @Override
322 public void onPhysicalChannelConfigurationChanged(
323 List<PhysicalChannelConfig> configs) {
324 updatePhysicalChannelConfiguration(configs);
325 }
326
Jordan Liu4cb626c2019-04-11 21:53:13 +0000327 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800328
Nathan Harold433ca442018-04-23 18:20:43 -0700329 private void updatePhysicalChannelConfiguration(List<PhysicalChannelConfig> configs) {
330 StringBuilder sb = new StringBuilder();
331 String div = "";
332 sb.append("{");
333 if (configs != null) {
334 for(PhysicalChannelConfig c : configs) {
335 sb.append(div).append(c);
336 div = ",";
337 }
338 }
339 sb.append("}");
340 mPhyChanConfig.setText(sb.toString());
341 }
342
Nathan Haroldcea413a2015-11-23 15:48:10 -0800343 private void updatePreferredNetworkType(int type) {
344 if (type >= mPreferredNetworkLabels.length || type < 0) {
345 log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
346 "type=" + type);
347 type = mPreferredNetworkLabels.length - 1; //set to Unknown
348 }
349 mPreferredNetworkTypeResult = type;
350
351 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
352 }
353
Jordan Liub69e8f22019-04-02 12:13:31 -0700354 private void updatePhoneIndex(int phoneIndex, int subId) {
355 // unregister listeners on the old subId
Jordan Liu4cb626c2019-04-11 21:53:13 +0000356 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
Jordan Liub69e8f22019-04-02 12:13:31 -0700357 mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
358
359 // update the subId
360 mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId);
Jordan Liu4cb626c2019-04-11 21:53:13 +0000361 mImsManager = ImsManager.getInstance(getApplicationContext(), phoneIndex);
Jordan Liub69e8f22019-04-02 12:13:31 -0700362
363 // update the phoneId
Jordan Liu4cb626c2019-04-11 21:53:13 +0000364 phone = PhoneFactory.getPhone(phoneIndex);
Jordan Liub69e8f22019-04-02 12:13:31 -0700365
366 updateAllFields();
367 }
368
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800369 private Handler mHandler = new Handler() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800370 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800371 public void handleMessage(Message msg) {
372 AsyncResult ar;
373 switch (msg.what) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800374 case EVENT_QUERY_PREFERRED_TYPE_DONE:
375 ar= (AsyncResult) msg.obj;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800376 if (ar.exception == null && ar.result != null) {
377 updatePreferredNetworkType(((int[])ar.result)[0]);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800378 } else {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800379 //In case of an exception, we will set this to unknown
380 updatePreferredNetworkType(mPreferredNetworkLabels.length-1);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800381 }
382 break;
383 case EVENT_SET_PREFERRED_TYPE_DONE:
384 ar= (AsyncResult) msg.obj;
385 if (ar.exception != null) {
Nathan Harolded38afa2016-04-13 00:29:30 -0700386 log("Set preferred network type failed.");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800387 }
388 break;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800389 case EVENT_QUERY_SMSC_DONE:
390 ar= (AsyncResult) msg.obj;
391 if (ar.exception != null) {
392 smsc.setText("refresh error");
393 } else {
jsh21dd4072009-05-12 11:26:55 -0700394 smsc.setText((String)ar.result);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800395 }
396 break;
397 case EVENT_UPDATE_SMSC_DONE:
398 updateSmscButton.setEnabled(true);
399 ar= (AsyncResult) msg.obj;
400 if (ar.exception != null) {
401 smsc.setText("update error");
402 }
403 break;
404 default:
Nathan Haroldcea413a2015-11-23 15:48:10 -0800405 super.handleMessage(msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800406 break;
407
408 }
409 }
410 };
411
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800412 @Override
413 public void onCreate(Bundle icicle) {
414 super.onCreate(icicle);
fionaxub54cb2d2016-09-22 15:01:05 -0700415 if (!android.os.Process.myUserHandle().isSystem()) {
416 Log.e(TAG, "Not run from system user, don't do anything.");
417 finish();
418 return;
419 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800420
421 setContentView(R.layout.radio_info);
422
Nathan Haroldcea413a2015-11-23 15:48:10 -0800423 log("Started onCreate");
424
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800425 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
Nathan Haroldf10ea322018-04-24 13:31:07 -0700426 mConnectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
Jordan Liu4cb626c2019-04-11 21:53:13 +0000427 phone = PhoneFactory.getDefaultPhone();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800428
Nathan Haroldcea413a2015-11-23 15:48:10 -0800429 mImsManager = ImsManager.getInstance(getApplicationContext(),
430 SubscriptionManager.getDefaultVoicePhoneId());
431
Jordan Liub69e8f22019-04-02 12:13:31 -0700432 mPhoneIndexLabels = getPhoneIndexLabels(mTelephonyManager);
433
Meng Wang9053f172017-06-23 16:02:14 -0700434 mDeviceId = (TextView) findViewById(R.id.imei);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800435 number = (TextView) findViewById(R.id.number);
Jordan Liub69e8f22019-04-02 12:13:31 -0700436 mSubscriptionId = (TextView) findViewById(R.id.subid);
437 mDds = (TextView) findViewById(R.id.dds);
Meng Wang9053f172017-06-23 16:02:14 -0700438 mSubscriberId = (TextView) findViewById(R.id.imsi);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800439 callState = (TextView) findViewById(R.id.call);
440 operatorName = (TextView) findViewById(R.id.operator);
441 roamingState = (TextView) findViewById(R.id.roaming);
442 gsmState = (TextView) findViewById(R.id.gsm);
443 gprsState = (TextView) findViewById(R.id.gprs);
Nathan Harold2b77d742016-03-19 13:22:10 -0700444 voiceNetwork = (TextView) findViewById(R.id.voice_network);
445 dataNetwork = (TextView) findViewById(R.id.data_network);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800446 dBm = (TextView) findViewById(R.id.dbm);
447 mMwi = (TextView) findViewById(R.id.mwi);
448 mCfi = (TextView) findViewById(R.id.cfi);
449 mLocation = (TextView) findViewById(R.id.location);
Wink Saville79bff2a2012-06-01 14:37:21 -0700450 mCellInfo = (TextView) findViewById(R.id.cellinfo);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800451 mCellInfo.setTypeface(Typeface.MONOSPACE);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800452
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800453 sent = (TextView) findViewById(R.id.sent);
454 received = (TextView) findViewById(R.id.received);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800455 smsc = (EditText) findViewById(R.id.smsc);
456 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800457 mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4);
458 mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800459 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
460
Nathan Harold433ca442018-04-23 18:20:43 -0700461 mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config);
462
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800463 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
Jordan Liub69e8f22019-04-02 12:13:31 -0700464 ArrayAdapter<String> preferredNetworkTypeAdapter = new ArrayAdapter<String> (this,
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800465 android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
Jordan Liub69e8f22019-04-02 12:13:31 -0700466 preferredNetworkTypeAdapter
467 .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
468 preferredNetworkType.setAdapter(preferredNetworkTypeAdapter);
469
470 mSelectPhoneIndex = (Spinner) findViewById(R.id.phoneIndex);
471 ArrayAdapter<String> phoneIndexAdapter = new ArrayAdapter<String> (this,
472 android.R.layout.simple_spinner_item, mPhoneIndexLabels);
473 phoneIndexAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
474 mSelectPhoneIndex.setAdapter(phoneIndexAdapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800475
Nathan Harold2b77d742016-03-19 13:22:10 -0700476 cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select);
477 ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this,
478 android.R.layout.simple_spinner_item, mCellInfoRefreshRateLabels);
479 cellInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
480 cellInfoRefreshRateSpinner.setAdapter(cellInfoAdapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800481
Nathan Harold12e1f552016-06-17 13:55:38 -0700482 imsVolteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch);
483 imsVtProvisionedSwitch = (Switch) findViewById(R.id.vt_provisioned_switch);
484 imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
Meng Wang69439b52017-05-01 08:31:14 -0700485 eabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch);
Wink Savillebf471282013-04-05 15:04:05 -0700486
Jordan Liu4cb626c2019-04-11 21:53:13 +0000487 if (!ImsManager.isImsSupportedOnDevice(phone.getContext())) {
Brad Ebinger5dfe7f82019-03-11 17:33:53 -0700488 imsVolteProvisionedSwitch.setVisibility(View.GONE);
489 imsVtProvisionedSwitch.setVisibility(View.GONE);
490 imsWfcProvisionedSwitch.setVisibility(View.GONE);
491 eabProvisionedSwitch.setVisibility(View.GONE);
492 }
493
Naina Nallurid1b57f62019-01-08 15:19:58 -0800494 cbrsDataSwitch = (Switch) findViewById(R.id.cbrs_data_switch);
495 cbrsDataSwitch.setVisibility(isCbrsSupported() ? View.VISIBLE : View.GONE);
496
Pengquan Meng7f602c72019-01-28 19:12:18 -0800497 dsdsSwitch = findViewById(R.id.dsds_switch);
498 if (isDsdsSupported()) {
499 dsdsSwitch.setVisibility(View.VISIBLE);
500 dsdsSwitch.setOnClickListener(v -> {
chen xu4f379d22019-04-03 10:31:19 -0700501 if (mTelephonyManager.doesSwitchMultiSimConfigTriggerReboot()) {
Pengquan Meng7f602c72019-01-28 19:12:18 -0800502 // Undo the click action until user clicks the confirm dialog.
503 dsdsSwitch.toggle();
504 showDsdsChangeDialog();
505 } else {
506 performDsdsSwitch();
507 }
508 });
509 dsdsSwitch.setChecked(isDsdsEnabled());
510 } else {
511 dsdsSwitch.setVisibility(View.GONE);
512 }
513
Nathan Harold2b77d742016-03-19 13:22:10 -0700514 radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
Wink Saville426fc662011-09-25 14:39:02 -0700515
Nathan Haroldf10ea322018-04-24 13:31:07 -0700516 mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
517 mUplinkKbps = (TextView) findViewById(R.id.ul_kbps);
518 updateBandwidths(0, 0);
519
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800520 pingTestButton = (Button) findViewById(R.id.ping_test);
521 pingTestButton.setOnClickListener(mPingButtonHandler);
522 updateSmscButton = (Button) findViewById(R.id.update_smsc);
523 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
524 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
525 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
526 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
527 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
Youhan Wangfd781e92016-12-16 15:53:16 -0800528 carrierProvisioningButton = (Button) findViewById(R.id.carrier_provisioning);
529 carrierProvisioningButton.setOnClickListener(mCarrierProvisioningButtonHandler);
530 triggercarrierProvisioningButton = (Button) findViewById(R.id.trigger_carrier_provisioning);
531 triggercarrierProvisioningButton.setOnClickListener(
532 mTriggerCarrierProvisioningButtonHandler);
johnwang342101a2009-09-23 16:22:34 -0700533
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800534 oemInfoButton = (Button) findViewById(R.id.oem_info);
535 oemInfoButton.setOnClickListener(mOemInfoButtonHandler);
536 PackageManager pm = getPackageManager();
537 Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO");
538 List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0);
539 if (oemInfoIntentList.size() == 0) {
540 oemInfoButton.setEnabled(false);
541 }
542
Nathan Harolded38afa2016-04-13 00:29:30 -0700543 mCellInfoRefreshRateIndex = 0; //disabled
Nathan Haroldcea413a2015-11-23 15:48:10 -0800544 mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown
Jordan Liub69e8f22019-04-02 12:13:31 -0700545 mSelectedPhoneIndex = 0; //phone 0
Nathan Haroldcea413a2015-11-23 15:48:10 -0800546
547 //FIXME: Replace with TelephonyManager call
Jordan Liu4cb626c2019-04-11 21:53:13 +0000548 phone.getPreferredNetworkType(
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800549 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800550
Nathan Haroldcea413a2015-11-23 15:48:10 -0800551 restoreFromBundle(icicle);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800552 }
553
554 @Override
555 protected void onResume() {
556 super.onResume();
557
Nathan Haroldcea413a2015-11-23 15:48:10 -0800558 log("Started onResume");
559
Jordan Liub69e8f22019-04-02 12:13:31 -0700560 updateAllFields();
561 }
562
563 private void updateAllFields() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800564 updateMessageWaiting();
565 updateCallRedirect();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800566 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800567 updateDataStats2();
Nathan Harold2b77d742016-03-19 13:22:10 -0700568 updateRadioPowerState();
Nathan Harold12e1f552016-06-17 13:55:38 -0700569 updateImsProvisionedState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800570 updateProperties();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800571 updateDnsCheckState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700572 updateNetworkType();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800573
Nathan Haroldcea413a2015-11-23 15:48:10 -0800574 updateLocation(mCellLocationResult);
575 updateCellInfo(mCellInfoResult);
Jordan Liub69e8f22019-04-02 12:13:31 -0700576 updateSubscriptionIds();
Nathan Haroldcea413a2015-11-23 15:48:10 -0800577
578 mPingHostnameV4.setText(mPingHostnameResultV4);
579 mPingHostnameV6.setText(mPingHostnameResultV6);
580 mHttpClientTest.setText(mHttpClientTestResult);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800581
Nathan Harold2b77d742016-03-19 13:22:10 -0700582 cellInfoRefreshRateSpinner.setOnItemSelectedListener(mCellInfoRefreshRateHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700583 //set selection after registering listener to force update
584 cellInfoRefreshRateSpinner.setSelection(mCellInfoRefreshRateIndex);
585
586 //set selection before registering to prevent update
587 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
Nathan Harold2b77d742016-03-19 13:22:10 -0700588 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700589
Jordan Liub69e8f22019-04-02 12:13:31 -0700590 // set phone index
591 mSelectPhoneIndex.setSelection(mSelectedPhoneIndex, true);
592 mSelectPhoneIndex.setOnItemSelectedListener(mSelectPhoneIndexHandler);
593
Nathan Harold2b77d742016-03-19 13:22:10 -0700594 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
Nathan Harold12e1f552016-06-17 13:55:38 -0700595 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
596 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
597 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Meng Wang586741c2017-04-26 15:02:51 -0700598 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
Nathan Harold2b77d742016-03-19 13:22:10 -0700599
Naina Nallurid1b57f62019-01-08 15:19:58 -0800600 if (isCbrsSupported()) {
601 cbrsDataSwitch.setChecked(getCbrsDataState());
602 cbrsDataSwitch.setOnCheckedChangeListener(mCbrsDataSwitchChangeListener);
603 }
604
Jordan Liub69e8f22019-04-02 12:13:31 -0700605 registerPhoneStateListener();
Nathan Harolded38afa2016-04-13 00:29:30 -0700606
Nathan Haroldf10ea322018-04-24 13:31:07 -0700607 mConnectivityManager.registerNetworkCallback(
608 mDefaultNetworkRequest, mNetworkCallback, mHandler);
609
Nathan Harolded38afa2016-04-13 00:29:30 -0700610 smsc.clearFocus();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800611 }
612
613 @Override
Nathan Haroldcea413a2015-11-23 15:48:10 -0800614 protected void onPause() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800615 super.onPause();
616
Wink Savillebf471282013-04-05 15:04:05 -0700617 log("onPause: unregister phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800618
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800619 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -0700620 mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
Nathan Haroldf10ea322018-04-24 13:31:07 -0700621 mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
622
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800623 }
624
Nathan Haroldcea413a2015-11-23 15:48:10 -0800625 private void restoreFromBundle(Bundle b) {
Nathan Harolde272c202016-10-27 13:45:00 -0700626 if(b == null) {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800627 return;
628 }
629
630 mPingHostnameResultV4 = b.getString("mPingHostnameResultV4","");
631 mPingHostnameResultV6 = b.getString("mPingHostnameResultV6","");
632 mHttpClientTestResult = b.getString("mHttpClientTestResult","");
633
634 mPingHostnameV4.setText(mPingHostnameResultV4);
635 mPingHostnameV6.setText(mPingHostnameResultV6);
636 mHttpClientTest.setText(mHttpClientTestResult);
637
Nathan Harold2b77d742016-03-19 13:22:10 -0700638 mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult",
639 mPreferredNetworkLabels.length - 1);
640
Jordan Liub69e8f22019-04-02 12:13:31 -0700641 mSelectedPhoneIndex = b.getInt("mSelectedPhoneIndex", 0);
642
Nathan Harold2b77d742016-03-19 13:22:10 -0700643 mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800644 }
645
646 @Override
647 protected void onSaveInstanceState(Bundle outState) {
648 outState.putString("mPingHostnameResultV4", mPingHostnameResultV4);
649 outState.putString("mPingHostnameResultV6", mPingHostnameResultV6);
650 outState.putString("mHttpClientTestResult", mHttpClientTestResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700651
Nathan Haroldcea413a2015-11-23 15:48:10 -0800652 outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult);
Jordan Liub69e8f22019-04-02 12:13:31 -0700653 outState.putInt("mSelectedPhoneIndex", mSelectedPhoneIndex);
Nathan Harold2b77d742016-03-19 13:22:10 -0700654 outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex);
655
Nathan Haroldcea413a2015-11-23 15:48:10 -0800656 }
657
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800658 @Override
659 public boolean onCreateOptionsMenu(Menu menu) {
Wink Savillec3886682009-04-02 11:00:56 -0700660 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
661 .setOnMenuItemClickListener(mSelectBandCallback)
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800662 .setAlphabeticShortcut('b');
663 menu.add(1, MENU_ITEM_VIEW_ADN, 0,
664 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
665 menu.add(1, MENU_ITEM_VIEW_FDN, 0,
666 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
667 menu.add(1, MENU_ITEM_VIEW_SDN, 0,
668 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
Jordan Liu4cb626c2019-04-11 21:53:13 +0000669 if (ImsManager.isImsSupportedOnDevice(phone.getContext())) {
Brad Ebinger5dfe7f82019-03-11 17:33:53 -0700670 menu.add(1, MENU_ITEM_GET_IMS_STATUS,
671 0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus);
672 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800673 menu.add(1, MENU_ITEM_TOGGLE_DATA,
Nathan Harold2b77d742016-03-19 13:22:10 -0700674 0, R.string.radio_info_data_connection_disable).setOnMenuItemClickListener(mToggleData);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800675 return true;
676 }
677
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800678 @Override
Wink Savillec3886682009-04-02 11:00:56 -0700679 public boolean onPrepareOptionsMenu(Menu menu) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800680 // Get the TOGGLE DATA menu item in the right state.
681 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
682 int state = mTelephonyManager.getDataState();
683 boolean visible = true;
684
685 switch (state) {
686 case TelephonyManager.DATA_CONNECTED:
687 case TelephonyManager.DATA_SUSPENDED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700688 item.setTitle(R.string.radio_info_data_connection_disable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800689 break;
690 case TelephonyManager.DATA_DISCONNECTED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700691 item.setTitle(R.string.radio_info_data_connection_enable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800692 break;
693 default:
694 visible = false;
695 break;
696 }
697 item.setVisible(visible);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800698 return true;
699 }
700
Jordan Liub69e8f22019-04-02 12:13:31 -0700701 // returns array of string labels for each phone index. The array index is equal to the phone
702 // index.
703 private static String[] getPhoneIndexLabels(TelephonyManager tm) {
704 int phones = tm.getPhoneCount();
705 String[] labels = new String[phones];
706 for (int i = 0; i < phones; i++) {
707 labels[i] = "Phone " + i;
708 }
709 return labels;
710 }
711
712 // register mPhoneStateListener for relevant fields using the current TelephonyManager
713 private void registerPhoneStateListener() {
714 mTelephonyManager.listen(mPhoneStateListener,
715 PhoneStateListener.LISTEN_CALL_STATE
716 //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
717 // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
718 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
719 | PhoneStateListener.LISTEN_DATA_ACTIVITY
720 | PhoneStateListener.LISTEN_CELL_LOCATION
721 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
722 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
723 | PhoneStateListener.LISTEN_CELL_INFO
724 | PhoneStateListener.LISTEN_SERVICE_STATE
725 | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
726 | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION);
727 }
728
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800729 private void updateDnsCheckState() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800730 //FIXME: Replace with a TelephonyManager call
Jordan Liu4cb626c2019-04-11 21:53:13 +0000731 dnsCheckState.setText(phone.isDnsCheckDisabled() ?
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800732 "0.0.0.0 allowed" :"0.0.0.0 not allowed");
733 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700734
Nathan Haroldf10ea322018-04-24 13:31:07 -0700735 private void updateBandwidths(int dlbw, int ulbw) {
736 dlbw = (dlbw < 0 || dlbw == Integer.MAX_VALUE) ? -1 : dlbw;
737 ulbw = (ulbw < 0 || ulbw == Integer.MAX_VALUE) ? -1 : ulbw;
738 mDownlinkKbps.setText(String.format("%-5d", dlbw));
739 mUplinkKbps.setText(String.format("%-5d", ulbw));
740 }
741
742
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800743 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700744 updateSignalStrength(SignalStrength signalStrength) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800745 Resources r = getResources();
746
Nathan Harold2b77d742016-03-19 13:22:10 -0700747 int signalDbm = signalStrength.getDbm();
Wink Savillee2a14e32009-05-29 14:06:30 -0700748
Nathan Harold2b77d742016-03-19 13:22:10 -0700749 int signalAsu = signalStrength.getAsuLevel();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800750
751 if (-1 == signalAsu) signalAsu = 0;
752
753 dBm.setText(String.valueOf(signalDbm) + " "
754 + r.getString(R.string.radioInfo_display_dbm) + " "
755 + String.valueOf(signalAsu) + " "
756 + r.getString(R.string.radioInfo_display_asu));
757 }
758
759 private final void updateLocation(CellLocation location) {
jsh534f5ae2009-09-24 09:19:22 -0700760 Resources r = getResources();
Wink Savillec3886682009-04-02 11:00:56 -0700761 if (location instanceof GsmCellLocation) {
762 GsmCellLocation loc = (GsmCellLocation)location;
jsh534f5ae2009-09-24 09:19:22 -0700763 int lac = loc.getLac();
764 int cid = loc.getCid();
765 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
766 + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
767 + " "
768 + r.getString(R.string.radioInfo_cid) + " = "
769 + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
770 } else if (location instanceof CdmaCellLocation) {
771 CdmaCellLocation loc = (CdmaCellLocation)location;
772 int bid = loc.getBaseStationId();
773 int sid = loc.getSystemId();
774 int nid = loc.getNetworkId();
775 int lat = loc.getBaseStationLatitude();
776 int lon = loc.getBaseStationLongitude();
777 mLocation.setText("BID = "
778 + ((bid == -1) ? "unknown" : Integer.toHexString(bid))
779 + " "
780 + "SID = "
781 + ((sid == -1) ? "unknown" : Integer.toHexString(sid))
782 + " "
783 + "NID = "
784 + ((nid == -1) ? "unknown" : Integer.toHexString(nid))
785 + "\n"
786 + "LAT = "
787 + ((lat == -1) ? "unknown" : Integer.toHexString(lat))
788 + " "
789 + "LONG = "
790 + ((lon == -1) ? "unknown" : Integer.toHexString(lon)));
791 } else {
792 mLocation.setText("unknown");
Wink Savillec3886682009-04-02 11:00:56 -0700793 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800794
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800795
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800796 }
797
Nathan Haroldcea413a2015-11-23 15:48:10 -0800798 private final String getCellInfoDisplayString(int i) {
799 return (i != Integer.MAX_VALUE) ? Integer.toString(i) : "";
800 }
801
802 private final String getCellInfoDisplayString(long i) {
803 return (i != Long.MAX_VALUE) ? Long.toString(i) : "";
804 }
805
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700806 private final String getConnectionStatusString(CellInfo ci) {
807 String regStr = "";
808 String connStatStr = "";
809 String connector = "";
810
811 if (ci.isRegistered()) {
812 regStr = "R";
813 }
814 switch (ci.getCellConnectionStatus()) {
815 case CellInfo.CONNECTION_PRIMARY_SERVING: connStatStr = "P"; break;
816 case CellInfo.CONNECTION_SECONDARY_SERVING: connStatStr = "S"; break;
817 case CellInfo.CONNECTION_NONE: connStatStr = "N"; break;
818 case CellInfo.CONNECTION_UNKNOWN: /* Field is unsupported */ break;
819 default: break;
820 }
821 if (!TextUtils.isEmpty(regStr) && !TextUtils.isEmpty(connStatStr)) {
822 connector = "+";
823 }
824
825 return regStr + connector + connStatStr;
826 }
827
Nathan Haroldcea413a2015-11-23 15:48:10 -0800828 private final String buildCdmaInfoString(CellInfoCdma ci) {
829 CellIdentityCdma cidCdma = ci.getCellIdentity();
830 CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
831
832 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 -0700833 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800834 getCellInfoDisplayString(cidCdma.getSystemId()),
835 getCellInfoDisplayString(cidCdma.getNetworkId()),
836 getCellInfoDisplayString(cidCdma.getBasestationId()),
837 getCellInfoDisplayString(ssCdma.getCdmaDbm()),
838 getCellInfoDisplayString(ssCdma.getCdmaEcio()),
839 getCellInfoDisplayString(ssCdma.getEvdoDbm()),
840 getCellInfoDisplayString(ssCdma.getEvdoEcio()),
841 getCellInfoDisplayString(ssCdma.getEvdoSnr()));
842 }
843
844 private final String buildGsmInfoString(CellInfoGsm ci) {
845 CellIdentityGsm cidGsm = ci.getCellIdentity();
846 CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
847
Nathan Harold2b77d742016-03-19 13:22:10 -0700848 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 -0700849 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800850 getCellInfoDisplayString(cidGsm.getMcc()),
851 getCellInfoDisplayString(cidGsm.getMnc()),
852 getCellInfoDisplayString(cidGsm.getLac()),
853 getCellInfoDisplayString(cidGsm.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700854 getCellInfoDisplayString(cidGsm.getArfcn()),
855 getCellInfoDisplayString(cidGsm.getBsic()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800856 getCellInfoDisplayString(ssGsm.getDbm()));
857 }
858
859 private final String buildLteInfoString(CellInfoLte ci) {
860 CellIdentityLte cidLte = ci.getCellIdentity();
861 CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
862
863 return String.format(
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700864 "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
865 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800866 getCellInfoDisplayString(cidLte.getMcc()),
867 getCellInfoDisplayString(cidLte.getMnc()),
868 getCellInfoDisplayString(cidLte.getTac()),
869 getCellInfoDisplayString(cidLte.getCi()),
870 getCellInfoDisplayString(cidLte.getPci()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700871 getCellInfoDisplayString(cidLte.getEarfcn()),
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700872 getCellInfoDisplayString(cidLte.getBandwidth()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800873 getCellInfoDisplayString(ssLte.getDbm()),
874 getCellInfoDisplayString(ssLte.getRsrq()),
875 getCellInfoDisplayString(ssLte.getTimingAdvance()));
876 }
877
878 private final String buildWcdmaInfoString(CellInfoWcdma ci) {
879 CellIdentityWcdma cidWcdma = ci.getCellIdentity();
880 CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength();
881
Nathan Harold2b77d742016-03-19 13:22:10 -0700882 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 -0700883 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800884 getCellInfoDisplayString(cidWcdma.getMcc()),
885 getCellInfoDisplayString(cidWcdma.getMnc()),
886 getCellInfoDisplayString(cidWcdma.getLac()),
887 getCellInfoDisplayString(cidWcdma.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700888 getCellInfoDisplayString(cidWcdma.getUarfcn()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800889 getCellInfoDisplayString(cidWcdma.getPsc()),
890 getCellInfoDisplayString(ssWcdma.getDbm()));
891 }
892
893 private final String buildCellInfoString(List<CellInfo> arrayCi) {
894 String value = new String();
895 StringBuilder cdmaCells = new StringBuilder(),
896 gsmCells = new StringBuilder(),
897 lteCells = new StringBuilder(),
898 wcdmaCells = new StringBuilder();
899
900 if (arrayCi != null) {
901 for (CellInfo ci : arrayCi) {
902
903 if (ci instanceof CellInfoLte) {
904 lteCells.append(buildLteInfoString((CellInfoLte) ci));
905 } else if (ci instanceof CellInfoWcdma) {
906 wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
907 } else if (ci instanceof CellInfoGsm) {
908 gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
909 } else if (ci instanceof CellInfoCdma) {
910 cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
Wink Saville79bff2a2012-06-01 14:37:21 -0700911 }
912 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800913 if (lteCells.length() != 0) {
914 value += String.format(
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700915 "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s"
916 + " %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
917 "SRV", "MCC", "MNC", "TAC", "CID", "PCI",
918 "EARFCN", "BW", "RSRP", "RSRQ", "TA");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800919 value += lteCells.toString();
920 }
921 if (wcdmaCells.length() != 0) {
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700922 value += String.format(
923 "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 -0700924 "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800925 value += wcdmaCells.toString();
926 }
927 if (gsmCells.length() != 0) {
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700928 value += String.format(
929 "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 -0700930 "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800931 value += gsmCells.toString();
932 }
933 if (cdmaCells.length() != 0) {
934 value += String.format(
935 "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n",
936 "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
937 value += cdmaCells.toString();
938 }
939 } else {
940 value ="unknown";
Wink Saville79bff2a2012-06-01 14:37:21 -0700941 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800942
943 return value.toString();
944 }
945
946 private final void updateCellInfo(List<CellInfo> arrayCi) {
947 mCellInfo.setText(buildCellInfoString(arrayCi));
Wink Saville79bff2a2012-06-01 14:37:21 -0700948 }
949
Jordan Liub69e8f22019-04-02 12:13:31 -0700950 private final void updateSubscriptionIds() {
Jordan Liu4cb626c2019-04-11 21:53:13 +0000951 mSubscriptionId.setText(Integer.toString(phone.getSubId()));
Jordan Liub69e8f22019-04-02 12:13:31 -0700952 mDds.setText(Integer.toString(SubscriptionManager.getDefaultDataSubscriptionId()));
953 }
954
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800955 private final void
956 updateMessageWaiting() {
957 mMwi.setText(String.valueOf(mMwiValue));
958 }
959
960 private final void
961 updateCallRedirect() {
962 mCfi.setText(String.valueOf(mCfiValue));
963 }
964
965
966 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700967 updateServiceState(ServiceState serviceState) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800968 int state = serviceState.getState();
969 Resources r = getResources();
970 String display = r.getString(R.string.radioInfo_unknown);
johnwang342101a2009-09-23 16:22:34 -0700971
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800972 switch (state) {
973 case ServiceState.STATE_IN_SERVICE:
974 display = r.getString(R.string.radioInfo_service_in);
975 break;
976 case ServiceState.STATE_OUT_OF_SERVICE:
977 case ServiceState.STATE_EMERGENCY_ONLY:
978 display = r.getString(R.string.radioInfo_service_emergency);
979 break;
980 case ServiceState.STATE_POWER_OFF:
981 display = r.getString(R.string.radioInfo_service_off);
982 break;
983 }
johnwang342101a2009-09-23 16:22:34 -0700984
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800985 gsmState.setText(display);
johnwang342101a2009-09-23 16:22:34 -0700986
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800987 if (serviceState.getRoaming()) {
988 roamingState.setText(R.string.radioInfo_roaming_in);
989 } else {
990 roamingState.setText(R.string.radioInfo_roaming_not);
991 }
992
993 operatorName.setText(serviceState.getOperatorAlphaLong());
994 }
995
996 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700997 updatePhoneState(int state) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800998 Resources r = getResources();
999 String display = r.getString(R.string.radioInfo_unknown);
1000
1001 switch (state) {
Nathan Harold2b77d742016-03-19 13:22:10 -07001002 case TelephonyManager.CALL_STATE_IDLE:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001003 display = r.getString(R.string.radioInfo_phone_idle);
1004 break;
Nathan Harold2b77d742016-03-19 13:22:10 -07001005 case TelephonyManager.CALL_STATE_RINGING:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001006 display = r.getString(R.string.radioInfo_phone_ringing);
1007 break;
Nathan Harold2b77d742016-03-19 13:22:10 -07001008 case TelephonyManager.CALL_STATE_OFFHOOK:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001009 display = r.getString(R.string.radioInfo_phone_offhook);
1010 break;
1011 }
1012
1013 callState.setText(display);
1014 }
1015
1016 private final void
1017 updateDataState() {
1018 int state = mTelephonyManager.getDataState();
1019 Resources r = getResources();
1020 String display = r.getString(R.string.radioInfo_unknown);
1021
1022 switch (state) {
1023 case TelephonyManager.DATA_CONNECTED:
1024 display = r.getString(R.string.radioInfo_data_connected);
1025 break;
1026 case TelephonyManager.DATA_CONNECTING:
1027 display = r.getString(R.string.radioInfo_data_connecting);
1028 break;
1029 case TelephonyManager.DATA_DISCONNECTED:
1030 display = r.getString(R.string.radioInfo_data_disconnected);
1031 break;
1032 case TelephonyManager.DATA_SUSPENDED:
1033 display = r.getString(R.string.radioInfo_data_suspended);
1034 break;
1035 }
johnwang342101a2009-09-23 16:22:34 -07001036
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001037 gprsState.setText(display);
1038 }
1039
1040 private final void updateNetworkType() {
Jordan Liu4cb626c2019-04-11 21:53:13 +00001041 if(phone != null) {
1042 ServiceState ss = phone.getServiceState();
Nathan Harold2b77d742016-03-19 13:22:10 -07001043 dataNetwork.setText(ServiceState.rilRadioTechnologyToString(
Jordan Liu4cb626c2019-04-11 21:53:13 +00001044 phone.getServiceState().getRilDataRadioTechnology()));
Nathan Harold2b77d742016-03-19 13:22:10 -07001045 voiceNetwork.setText(ServiceState.rilRadioTechnologyToString(
Jordan Liu4cb626c2019-04-11 21:53:13 +00001046 phone.getServiceState().getRilVoiceRadioTechnology()));
Nathan Harold2b77d742016-03-19 13:22:10 -07001047 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001048 }
1049
1050 private final void
1051 updateProperties() {
1052 String s;
1053 Resources r = getResources();
1054
Jordan Liu4cb626c2019-04-11 21:53:13 +00001055 s = phone.getDeviceId();
johnwang342101a2009-09-23 16:22:34 -07001056 if (s == null) s = r.getString(R.string.radioInfo_unknown);
Wink Savillec3886682009-04-02 11:00:56 -07001057 mDeviceId.setText(s);
johnwang342101a2009-09-23 16:22:34 -07001058
Jordan Liu4cb626c2019-04-11 21:53:13 +00001059 s = phone.getSubscriberId();
Meng Wang9053f172017-06-23 16:02:14 -07001060 if (s == null) s = r.getString(R.string.radioInfo_unknown);
1061 mSubscriberId.setText(s);
1062
Nathan Haroldcea413a2015-11-23 15:48:10 -08001063 //FIXME: Replace with a TelephonyManager call
Jordan Liu4cb626c2019-04-11 21:53:13 +00001064 s = phone.getLine1Number();
johnwang342101a2009-09-23 16:22:34 -07001065 if (s == null) s = r.getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001066 number.setText(s);
1067 }
1068
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001069 private final void updateDataStats2() {
1070 Resources r = getResources();
1071
Jeff Sharkey93029862011-05-27 18:26:15 -07001072 long txPackets = TrafficStats.getMobileTxPackets();
1073 long rxPackets = TrafficStats.getMobileRxPackets();
1074 long txBytes = TrafficStats.getMobileTxBytes();
1075 long rxBytes = TrafficStats.getMobileRxBytes();
johnwang342101a2009-09-23 16:22:34 -07001076
Jeff Sharkey93029862011-05-27 18:26:15 -07001077 String packets = r.getString(R.string.radioInfo_display_packets);
1078 String bytes = r.getString(R.string.radioInfo_display_bytes);
johnwang342101a2009-09-23 16:22:34 -07001079
Jeff Sharkey93029862011-05-27 18:26:15 -07001080 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
1081 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001082 }
1083
1084 /**
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001085 * Ping a host name
1086 */
1087 private final void pingHostname() {
1088 try {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001089 try {
1090 Process p4 = Runtime.getRuntime().exec("ping -c 1 www.google.com");
1091 int status4 = p4.waitFor();
1092 if (status4 == 0) {
1093 mPingHostnameResultV4 = "Pass";
1094 } else {
1095 mPingHostnameResultV4 = String.format("Fail(%d)", status4);
1096 }
1097 } catch (IOException e) {
1098 mPingHostnameResultV4 = "Fail: IOException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001099 }
Nathan Haroldcea413a2015-11-23 15:48:10 -08001100 try {
1101 Process p6 = Runtime.getRuntime().exec("ping6 -c 1 www.google.com");
1102 int status6 = p6.waitFor();
1103 if (status6 == 0) {
1104 mPingHostnameResultV6 = "Pass";
1105 } else {
1106 mPingHostnameResultV6 = String.format("Fail(%d)", status6);
1107 }
1108 } catch (IOException e) {
1109 mPingHostnameResultV6 = "Fail: IOException";
1110 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001111 } catch (InterruptedException e) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001112 mPingHostnameResultV4 = mPingHostnameResultV6 = "Fail: InterruptedException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001113 }
1114 }
1115
1116 /**
1117 * This function checks for basic functionality of HTTP Client.
1118 */
1119 private void httpClientTest() {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001120 HttpURLConnection urlConnection = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001121 try {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001122 // TODO: Hardcoded for now, make it UI configurable
Alex Klyubinb0090232015-04-02 11:08:51 -07001123 URL url = new URL("https://www.google.com");
Narayan Kamathf25627c2014-12-12 13:53:28 +00001124 urlConnection = (HttpURLConnection) url.openConnection();
1125 if (urlConnection.getResponseCode() == 200) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001126 mHttpClientTestResult = "Pass";
1127 } else {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001128 mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001129 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001130 } catch (IOException e) {
1131 mHttpClientTestResult = "Fail: IOException";
Narayan Kamathf25627c2014-12-12 13:53:28 +00001132 } finally {
1133 if (urlConnection != null) {
1134 urlConnection.disconnect();
1135 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001136 }
1137 }
1138
1139 private void refreshSmsc() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001140 //FIXME: Replace with a TelephonyManager call
Jordan Liu4cb626c2019-04-11 21:53:13 +00001141 phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001142 }
1143
Nathan Haroldcea413a2015-11-23 15:48:10 -08001144 private final void updateAllCellInfo() {
1145
1146 mCellInfo.setText("");
Nathan Haroldcea413a2015-11-23 15:48:10 -08001147 mLocation.setText("");
1148
1149 final Runnable updateAllCellInfoResults = new Runnable() {
1150 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001151 updateLocation(mCellLocationResult);
1152 updateCellInfo(mCellInfoResult);
1153 }
1154 };
1155
1156 Thread locThread = new Thread() {
1157 @Override
1158 public void run() {
1159 mCellInfoResult = mTelephonyManager.getAllCellInfo();
1160 mCellLocationResult = mTelephonyManager.getCellLocation();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001161
1162 mHandler.post(updateAllCellInfoResults);
1163 }
1164 };
1165 locThread.start();
1166 }
1167
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001168 private final void updatePingState() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001169 // Set all to unknown since the threads will take a few secs to update.
Nathan Haroldcea413a2015-11-23 15:48:10 -08001170 mPingHostnameResultV4 = getResources().getString(R.string.radioInfo_unknown);
1171 mPingHostnameResultV6 = getResources().getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001172 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
1173
Nathan Haroldcea413a2015-11-23 15:48:10 -08001174 mPingHostnameV4.setText(mPingHostnameResultV4);
1175 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001176 mHttpClientTest.setText(mHttpClientTestResult);
1177
1178 final Runnable updatePingResults = new Runnable() {
1179 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001180 mPingHostnameV4.setText(mPingHostnameResultV4);
1181 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001182 mHttpClientTest.setText(mHttpClientTestResult);
1183 }
1184 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001185
1186 Thread hostname = new Thread() {
1187 @Override
1188 public void run() {
1189 pingHostname();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001190 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001191 }
1192 };
1193 hostname.start();
1194
1195 Thread httpClient = new Thread() {
1196 @Override
1197 public void run() {
1198 httpClientTest();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001199 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001200 }
1201 };
1202 httpClient.start();
1203 }
1204
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001205 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
1206 public boolean onMenuItemClick(MenuItem item) {
1207 Intent intent = new Intent(Intent.ACTION_VIEW);
1208 // XXX We need to specify the component here because if we don't
1209 // the activity manager will try to resolve the type by calling
1210 // the content provider, which causes it to be loaded in a process
1211 // other than the Dialer process, which causes a lot of stuff to
1212 // break.
Jordan Liu4cb626c2019-04-11 21:53:13 +00001213 intent.setClassName("com.android.phone",
1214 "com.android.phone.SimContacts");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001215 startActivity(intent);
1216 return true;
1217 }
1218 };
1219
1220 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
1221 public boolean onMenuItemClick(MenuItem item) {
1222 Intent intent = new Intent(Intent.ACTION_VIEW);
1223 // XXX We need to specify the component here because if we don't
1224 // the activity manager will try to resolve the type by calling
1225 // the content provider, which causes it to be loaded in a process
1226 // other than the Dialer process, which causes a lot of stuff to
1227 // break.
Jordan Liu4cb626c2019-04-11 21:53:13 +00001228 intent.setClassName("com.android.phone",
1229 "com.android.phone.settings.fdn.FdnList");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001230 startActivity(intent);
1231 return true;
1232 }
1233 };
1234
1235 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
1236 public boolean onMenuItemClick(MenuItem item) {
1237 Intent intent = new Intent(
Wink Savillec3886682009-04-02 11:00:56 -07001238 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001239 // XXX We need to specify the component here because if we don't
1240 // the activity manager will try to resolve the type by calling
1241 // the content provider, which causes it to be loaded in a process
1242 // other than the Dialer process, which causes a lot of stuff to
1243 // break.
Jordan Liu4cb626c2019-04-11 21:53:13 +00001244 intent.setClassName("com.android.phone",
1245 "com.android.phone.ADNList");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001246 startActivity(intent);
1247 return true;
1248 }
1249 };
1250
Nathan Harolde272c202016-10-27 13:45:00 -07001251 private MenuItem.OnMenuItemClickListener mGetImsStatus = new MenuItem.OnMenuItemClickListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001252 public boolean onMenuItemClick(MenuItem item) {
Jordan Liu4cb626c2019-04-11 21:53:13 +00001253 boolean isImsRegistered = phone.isImsRegistered();
1254 boolean availableVolte = phone.isVolteEnabled();
1255 boolean availableWfc = phone.isWifiCallingEnabled();
1256 boolean availableVt = phone.isVideoEnabled();
1257 boolean availableUt = phone.isUtEnabled();
Nathan Harolde272c202016-10-27 13:45:00 -07001258
1259 final String imsRegString = isImsRegistered ?
1260 getString(R.string.radio_info_ims_reg_status_registered) :
1261 getString(R.string.radio_info_ims_reg_status_not_registered);
1262
1263 final String available = getString(R.string.radio_info_ims_feature_status_available);
1264 final String unavailable = getString(
1265 R.string.radio_info_ims_feature_status_unavailable);
1266
1267 String imsStatus = getString(R.string.radio_info_ims_reg_status,
1268 imsRegString,
1269 availableVolte ? available : unavailable,
1270 availableWfc ? available : unavailable,
1271 availableVt ? available : unavailable,
1272 availableUt ? available : unavailable);
1273
1274 AlertDialog imsDialog = new AlertDialog.Builder(RadioInfo.this)
1275 .setMessage(imsStatus)
1276 .setTitle(getString(R.string.radio_info_ims_reg_status_title))
1277 .create();
1278
1279 imsDialog.show();
1280
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001281 return true;
1282 }
1283 };
1284
1285 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
1286 public boolean onMenuItemClick(MenuItem item) {
1287 Intent intent = new Intent();
1288 intent.setClass(RadioInfo.this, BandMode.class);
1289 startActivity(intent);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001290 return true;
1291 }
1292 };
johnwang342101a2009-09-23 16:22:34 -07001293
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001294 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
1295 public boolean onMenuItemClick(MenuItem item) {
1296 int state = mTelephonyManager.getDataState();
1297 switch (state) {
1298 case TelephonyManager.DATA_CONNECTED:
Jack Yu50972ed2018-12-13 11:51:20 -08001299 mTelephonyManager.setDataEnabled(false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001300 break;
1301 case TelephonyManager.DATA_DISCONNECTED:
Jack Yu50972ed2018-12-13 11:51:20 -08001302 mTelephonyManager.setDataEnabled(true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001303 break;
1304 default:
1305 // do nothing
1306 break;
1307 }
1308 return true;
1309 }
1310 };
1311
Nathan Harold2b77d742016-03-19 13:22:10 -07001312 private boolean isRadioOn() {
1313 //FIXME: Replace with a TelephonyManager call
Jordan Liu4cb626c2019-04-11 21:53:13 +00001314 return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
Nathan Harold2b77d742016-03-19 13:22:10 -07001315 }
1316
1317 private void updateRadioPowerState() {
1318 //delightful hack to prevent on-checked-changed calls from
1319 //actually forcing the radio preference to its transient/current value.
1320 radioPowerOnSwitch.setOnCheckedChangeListener(null);
1321 radioPowerOnSwitch.setChecked(isRadioOn());
1322 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
1323 }
1324
Nathan Harolde272c202016-10-27 13:45:00 -07001325 void setImsVolteProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001326 Log.d(TAG, "setImsVolteProvisioned state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001327 setImsConfigProvisionedState(IMS_VOLTE_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001328 }
1329
Nathan Harolde272c202016-10-27 13:45:00 -07001330 void setImsVtProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001331 Log.d(TAG, "setImsVtProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001332 setImsConfigProvisionedState(IMS_VT_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001333 }
1334
Nathan Harolde272c202016-10-27 13:45:00 -07001335 void setImsWfcProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001336 Log.d(TAG, "setImsWfcProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001337 setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001338 }
1339
Meng Wang586741c2017-04-26 15:02:51 -07001340 void setEabProvisionedState(boolean state) {
1341 Log.d(TAG, "setEabProvisioned() state: " + ((state)? "on":"off"));
1342 setImsConfigProvisionedState(EAB_PROVISIONED_CONFIG_ID, state);
1343 }
1344
Nathan Harolde272c202016-10-27 13:45:00 -07001345 void setImsConfigProvisionedState(int configItem, boolean state) {
Jordan Liu4cb626c2019-04-11 21:53:13 +00001346 if (phone != null && mImsManager != null) {
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001347 QueuedWork.queue(new Runnable() {
Nathan Harold12e1f552016-06-17 13:55:38 -07001348 public void run() {
1349 try {
1350 mImsManager.getConfigInterface().setProvisionedValue(
1351 configItem,
1352 state? 1 : 0);
1353 } catch (ImsException e) {
1354 Log.e(TAG, "setImsConfigProvisioned() exception:", e);
1355 }
1356 }
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001357 }, false);
Nathan Harold12e1f552016-06-17 13:55:38 -07001358 }
1359 }
1360
Nathan Harold2b77d742016-03-19 13:22:10 -07001361 OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() {
1362 @Override
1363 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1364 log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
Jordan Liu4cb626c2019-04-11 21:53:13 +00001365 phone.setRadioPower(isChecked);
Nathan Harold2b77d742016-03-19 13:22:10 -07001366 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001367 };
1368
Nathan Harold12e1f552016-06-17 13:55:38 -07001369 private boolean isImsVolteProvisioned() {
Jordan Liu4cb626c2019-04-11 21:53:13 +00001370 if (phone != null && mImsManager != null) {
1371 return mImsManager.isVolteEnabledByPlatform(phone.getContext())
1372 && mImsManager.isVolteProvisionedOnDevice(phone.getContext());
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -08001373 }
1374 return false;
1375 }
1376
Nathan Harold12e1f552016-06-17 13:55:38 -07001377 OnCheckedChangeListener mImsVolteCheckedChangeListener = new OnCheckedChangeListener() {
Wink Saville426fc662011-09-25 14:39:02 -07001378 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -07001379 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001380 setImsVolteProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001381 }
Wink Saville426fc662011-09-25 14:39:02 -07001382 };
1383
Nathan Harold12e1f552016-06-17 13:55:38 -07001384 private boolean isImsVtProvisioned() {
Jordan Liu4cb626c2019-04-11 21:53:13 +00001385 if (phone != null && mImsManager != null) {
1386 return mImsManager.isVtEnabledByPlatform(phone.getContext())
1387 && mImsManager.isVtProvisionedOnDevice(phone.getContext());
Nathan Harold12e1f552016-06-17 13:55:38 -07001388 }
1389 return false;
1390 }
1391
1392 OnCheckedChangeListener mImsVtCheckedChangeListener = new OnCheckedChangeListener() {
1393 @Override
1394 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1395 setImsVtProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001396 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001397 };
1398
1399 private boolean isImsWfcProvisioned() {
Jordan Liu4cb626c2019-04-11 21:53:13 +00001400 if (phone != null && mImsManager != null) {
1401 return mImsManager.isWfcEnabledByPlatform(phone.getContext())
1402 && mImsManager.isWfcProvisionedOnDevice(phone.getContext());
Nathan Harold12e1f552016-06-17 13:55:38 -07001403 }
1404 return false;
1405 }
1406
1407 OnCheckedChangeListener mImsWfcCheckedChangeListener = new OnCheckedChangeListener() {
1408 @Override
1409 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1410 setImsWfcProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001411 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001412 };
1413
Meng Wang586741c2017-04-26 15:02:51 -07001414 private boolean isEabProvisioned() {
1415 return isFeatureProvisioned(EAB_PROVISIONED_CONFIG_ID, false);
1416 }
1417
1418 OnCheckedChangeListener mEabCheckedChangeListener = new OnCheckedChangeListener() {
1419 @Override
1420 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1421 setEabProvisionedState(isChecked);
1422 }
1423 };
1424
1425 private boolean isFeatureProvisioned(int featureId, boolean defaultValue) {
1426 boolean provisioned = defaultValue;
1427 if (mImsManager != null) {
1428 try {
1429 ImsConfig imsConfig = mImsManager.getConfigInterface();
1430 if (imsConfig != null) {
1431 provisioned =
1432 (imsConfig.getProvisionedValue(featureId)
1433 == ImsConfig.FeatureValueConstants.ON);
1434 }
1435 } catch (ImsException ex) {
1436 Log.e(TAG, "isFeatureProvisioned() exception:", ex);
1437 }
1438 }
1439
1440 log("isFeatureProvisioned() featureId=" + featureId + " provisioned=" + provisioned);
1441 return provisioned;
1442 }
1443
1444 private static boolean isEabEnabledByPlatform(Context context) {
1445 if (context != null) {
1446 CarrierConfigManager configManager = (CarrierConfigManager)
1447 context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
1448 if (configManager != null && configManager.getConfig().getBoolean(
1449 CarrierConfigManager.KEY_USE_RCS_PRESENCE_BOOL)) {
1450 return true;
1451 }
1452 }
1453 return false;
1454 }
1455
Nathan Harold12e1f552016-06-17 13:55:38 -07001456 private void updateImsProvisionedState() {
Jordan Liu4cb626c2019-04-11 21:53:13 +00001457 if (!ImsManager.isImsSupportedOnDevice(phone.getContext())) {
Brad Ebinger5dfe7f82019-03-11 17:33:53 -07001458 return;
1459 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001460 log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
Nathan Harold2b77d742016-03-19 13:22:10 -07001461 //delightful hack to prevent on-checked-changed calls from
1462 //actually forcing the ims provisioning to its transient/current value.
Nathan Harold12e1f552016-06-17 13:55:38 -07001463 imsVolteProvisionedSwitch.setOnCheckedChangeListener(null);
1464 imsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned());
1465 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001466 imsVolteProvisionedSwitch.setEnabled(!Build.IS_USER
Jordan Liu4cb626c2019-04-11 21:53:13 +00001467 && mImsManager.isVolteEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001468
1469 imsVtProvisionedSwitch.setOnCheckedChangeListener(null);
1470 imsVtProvisionedSwitch.setChecked(isImsVtProvisioned());
1471 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001472 imsVtProvisionedSwitch.setEnabled(!Build.IS_USER
Jordan Liu4cb626c2019-04-11 21:53:13 +00001473 && mImsManager.isVtEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001474
1475 imsWfcProvisionedSwitch.setOnCheckedChangeListener(null);
1476 imsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned());
1477 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001478 imsWfcProvisionedSwitch.setEnabled(!Build.IS_USER
Jordan Liu4cb626c2019-04-11 21:53:13 +00001479 && mImsManager.isWfcEnabledByPlatform(phone.getContext()));
Meng Wang586741c2017-04-26 15:02:51 -07001480
1481 eabProvisionedSwitch.setOnCheckedChangeListener(null);
1482 eabProvisionedSwitch.setChecked(isEabProvisioned());
1483 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001484 eabProvisionedSwitch.setEnabled(!Build.IS_USER
Jordan Liu4cb626c2019-04-11 21:53:13 +00001485 && isEabEnabledByPlatform(phone.getContext()));
Wink Saville426fc662011-09-25 14:39:02 -07001486 }
1487
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001488 OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
1489 public void onClick(View v) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001490 //FIXME: Replace with a TelephonyManager call
Jordan Liu4cb626c2019-04-11 21:53:13 +00001491 phone.disableDnsCheck(!phone.isDnsCheckDisabled());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001492 updateDnsCheckState();
1493 }
1494 };
johnwang342101a2009-09-23 16:22:34 -07001495
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001496 OnClickListener mOemInfoButtonHandler = new OnClickListener() {
1497 public void onClick(View v) {
1498 Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO");
1499 try {
1500 startActivity(intent);
1501 } catch (android.content.ActivityNotFoundException ex) {
Wink Savillebf471282013-04-05 15:04:05 -07001502 log("OEM-specific Info/Settings Activity Not Found : " + ex);
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001503 // If the activity does not exist, there are no OEM
1504 // settings, and so we can just do nothing...
1505 }
1506 }
1507 };
1508
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001509 OnClickListener mPingButtonHandler = new OnClickListener() {
1510 public void onClick(View v) {
1511 updatePingState();
1512 }
1513 };
1514
1515 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
1516 public void onClick(View v) {
1517 updateSmscButton.setEnabled(false);
Jordan Liu4cb626c2019-04-11 21:53:13 +00001518 phone.setSmscAddress(smsc.getText().toString(),
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001519 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
1520 }
1521 };
1522
1523 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
1524 public void onClick(View v) {
1525 refreshSmsc();
1526 }
1527 };
1528
Youhan Wangfd781e92016-12-16 15:53:16 -08001529 OnClickListener mCarrierProvisioningButtonHandler = new OnClickListener() {
1530 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001531 final Intent intent = new Intent("com.android.settings.CARRIER_PROVISIONING");
1532 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1533 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001534 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001535 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001536 }
1537 };
1538
1539 OnClickListener mTriggerCarrierProvisioningButtonHandler = new OnClickListener() {
1540 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001541 final Intent intent = new Intent("com.android.settings.TRIGGER_CARRIER_PROVISIONING");
1542 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1543 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001544 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001545 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001546 }
1547 };
1548
Nathan Haroldcea413a2015-11-23 15:48:10 -08001549 AdapterView.OnItemSelectedListener mPreferredNetworkHandler =
1550 new AdapterView.OnItemSelectedListener() {
1551
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001552 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001553 if (mPreferredNetworkTypeResult != pos && pos >= 0
1554 && pos <= mPreferredNetworkLabels.length - 2) {
1555 mPreferredNetworkTypeResult = pos;
Nathan Harolddaea8be2018-06-05 14:02:35 -07001556
1557 // TODO: Possibly migrate this to TelephonyManager.setPreferredNetworkType()
1558 // which today still has some issues (mostly that the "set" is conditional
1559 // on a successful modem call, which is not what we want). Instead we always
1560 // want this setting to be set, so that if the radio hiccups and this setting
1561 // is for some reason unsuccessful, future calls to the radio will reflect
1562 // the users's preference which is set here.
Jordan Liu4cb626c2019-04-11 21:53:13 +00001563 final int subId = phone.getSubId();
Nathan Harolddaea8be2018-06-05 14:02:35 -07001564 if (SubscriptionManager.isUsableSubIdValue(subId)) {
Jordan Liu4cb626c2019-04-11 21:53:13 +00001565 Settings.Global.putInt(phone.getContext().getContentResolver(),
Nathan Harolddaea8be2018-06-05 14:02:35 -07001566 PREFERRED_NETWORK_MODE + subId, mPreferredNetworkTypeResult);
1567 }
1568 log("Calling setPreferredNetworkType(" + mPreferredNetworkTypeResult + ")");
Nathan Haroldcea413a2015-11-23 15:48:10 -08001569 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
Jordan Liu4cb626c2019-04-11 21:53:13 +00001570 phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001571 }
1572 }
1573
1574 public void onNothingSelected(AdapterView parent) {
1575 }
1576 };
1577
Jordan Liub69e8f22019-04-02 12:13:31 -07001578 AdapterView.OnItemSelectedListener mSelectPhoneIndexHandler =
1579 new AdapterView.OnItemSelectedListener() {
1580
1581 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1582 if (pos >= 0 && pos <= mPhoneIndexLabels.length - 1) {
1583 // the array position is equal to the phone index
1584 int phoneIndex = pos;
1585 Phone[] phones = PhoneFactory.getPhones();
1586 if (phones == null || phones.length <= phoneIndex) {
1587 log("phoneIndex " + phoneIndex + " is invalid");
1588 return;
1589 }
1590 log("switching to phone " + phoneIndex);
1591 // getSubId says it takes a slotIndex, but it actually takes a phone index
1592 int[] subIds = SubscriptionManager.getSubId(phoneIndex);
1593 if (subIds == null || subIds.length < 1) {
1594 log("no subscription found for phoneIndex " + phoneIndex);
1595 return;
1596 }
1597 mSelectedPhoneIndex = phoneIndex;
1598
1599 updatePhoneIndex(phoneIndex, subIds[0]);
1600 }
1601 }
1602
1603 public void onNothingSelected(AdapterView parent) {
1604 }
1605 };
1606
Nathan Harold2b77d742016-03-19 13:22:10 -07001607 AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler =
1608 new AdapterView.OnItemSelectedListener() {
Wink Savillebf471282013-04-05 15:04:05 -07001609
Nathan Harold2b77d742016-03-19 13:22:10 -07001610 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1611 mCellInfoRefreshRateIndex = pos;
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -07001612 mTelephonyManager.setCellInfoListRate(mCellInfoRefreshRates[pos]);
Nathan Harold2b77d742016-03-19 13:22:10 -07001613 updateAllCellInfo();
1614 }
1615
1616 public void onNothingSelected(AdapterView parent) {
1617 }
1618 };
1619
Naina Nallurid1b57f62019-01-08 15:19:58 -08001620 boolean isCbrsSupported() {
1621 return getResources().getBoolean(
1622 com.android.internal.R.bool.config_cbrs_supported);
1623 }
1624
1625 void updateCbrsDataState(boolean state) {
1626 Log.d(TAG, "setCbrsDataSwitchState() state:" + ((state)? "on":"off"));
1627 if (mTelephonyManager != null) {
1628 QueuedWork.queue(new Runnable() {
1629 public void run() {
1630 mTelephonyManager.setOpportunisticNetworkState(state);
1631 cbrsDataSwitch.setChecked(getCbrsDataState());
1632 }
1633 }, false);
1634 }
1635 }
1636
1637 boolean getCbrsDataState() {
1638 boolean state = false;
1639 if (mTelephonyManager != null) {
1640 state = mTelephonyManager.isOpportunisticNetworkEnabled();
1641 }
1642 Log.d(TAG, "getCbrsDataState() state:" +((state)? "on":"off"));
1643 return state;
1644 }
1645
1646 OnCheckedChangeListener mCbrsDataSwitchChangeListener = new OnCheckedChangeListener() {
1647 @Override
1648 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1649 updateCbrsDataState(isChecked);
1650 }
1651 };
1652
Pengquan Meng7f602c72019-01-28 19:12:18 -08001653 private void showDsdsChangeDialog() {
1654 final AlertDialog confirmDialog = new Builder(RadioInfo.this)
1655 .setTitle(R.string.dsds_dialog_title)
1656 .setMessage(R.string.dsds_dialog_message)
1657 .setPositiveButton(R.string.dsds_dialog_confirm, mOnDsdsDialogConfirmedListener)
1658 .setNegativeButton(R.string.dsds_dialog_cancel, mOnDsdsDialogConfirmedListener)
1659 .create();
1660 confirmDialog.show();
1661 }
Naina Nallurid1b57f62019-01-08 15:19:58 -08001662
Pengquan Meng7f602c72019-01-28 19:12:18 -08001663 private static boolean isDsdsSupported() {
Michele3dafea22019-03-19 15:53:45 -07001664 return (TelephonyManager.getDefault().isMultiSimSupported()
1665 == TelephonyManager.MULTISIM_ALLOWED);
Pengquan Meng7f602c72019-01-28 19:12:18 -08001666 }
1667
1668 private static boolean isDsdsEnabled() {
1669 return TelephonyManager.getDefault().getPhoneCount() > 1;
1670 }
1671
1672 private void performDsdsSwitch() {
1673 mTelephonyManager.switchMultiSimConfig(dsdsSwitch.isChecked() ? 2 : 1);
1674 }
1675
1676 DialogInterface.OnClickListener mOnDsdsDialogConfirmedListener =
1677 new DialogInterface.OnClickListener() {
1678 @Override
1679 public void onClick(DialogInterface dialog, int which) {
1680 if (which == DialogInterface.BUTTON_POSITIVE) {
1681 dsdsSwitch.toggle();
1682 performDsdsSwitch();
1683 }
1684 }
1685 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001686}