blob: 170db1695b4ec4599dd718b3b4b50654d5f51ffb [file] [log] [blame]
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settings;
18
Nathan Haroldf10ea322018-04-24 13:31:07 -070019import static android.net.ConnectivityManager.NetworkCallback;
20
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080021import android.app.Activity;
Nathan Harolde272c202016-10-27 13:45:00 -070022import android.app.AlertDialog;
23import android.app.Dialog;
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -080024import android.app.QueuedWork;
Youhan Wangfd781e92016-12-16 15:53:16 -080025import android.content.ComponentName;
Meng Wang586741c2017-04-26 15:02:51 -070026import android.content.Context;
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;
39import android.os.Bundle;
40import android.os.Handler;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080041import android.os.Message;
Meng Wang586741c2017-04-26 15:02:51 -070042import android.telephony.CarrierConfigManager;
Wink Saville79bff2a2012-06-01 14:37:21 -070043import android.telephony.CellInfo;
Nathan Haroldcea413a2015-11-23 15:48:10 -080044import android.telephony.CellInfoCdma;
45import android.telephony.CellInfoGsm;
46import android.telephony.CellInfoLte;
47import android.telephony.CellInfoWcdma;
48import android.telephony.CellIdentityCdma;
49import android.telephony.CellIdentityGsm;
50import android.telephony.CellIdentityLte;
51import android.telephony.CellIdentityWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080052import android.telephony.CellLocation;
Nathan Haroldcea413a2015-11-23 15:48:10 -080053import android.telephony.CellSignalStrengthCdma;
54import android.telephony.CellSignalStrengthGsm;
55import android.telephony.CellSignalStrengthLte;
56import android.telephony.CellSignalStrengthWcdma;
Wink Saville4f0d8812014-04-15 22:05:24 -070057import android.telephony.DataConnectionRealTimeInfo;
Jason Monk39b46742015-09-10 15:52:51 -040058import android.telephony.NeighboringCellInfo;
Nathan Harold2b77d742016-03-19 13:22:10 -070059import android.telephony.PreciseCallState;
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;
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
Jason Monk39b46742015-09-10 15:52:51 -040084import com.android.ims.ImsConfig;
85import com.android.ims.ImsException;
86import com.android.ims.ImsManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080087import com.android.internal.telephony.Phone;
Wink Saville55434042012-06-14 12:33:43 -070088import com.android.internal.telephony.PhoneConstants;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080089import com.android.internal.telephony.PhoneFactory;
Nathan Haroldcea413a2015-11-23 15:48:10 -080090import com.android.internal.telephony.RILConstants;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080091import com.android.internal.telephony.TelephonyProperties;
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.net.UnknownHostException;
97import java.util.ArrayList;
98import java.util.List;
99
100public 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
129
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
164 private void log(String s) {
165 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
175 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;
Nathan Harolde272c202016-10-27 13:45:00 -0700179 private static final int MENU_ITEM_GET_IMS_STATUS = 4;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800180 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;
Meng Wang9053f172017-06-23 16:02:14 -0700184 private TextView mSubscriberId;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800185 private TextView callState;
186 private TextView operatorName;
187 private TextView roamingState;
188 private TextView gsmState;
189 private TextView gprsState;
Nathan Harold2b77d742016-03-19 13:22:10 -0700190 private TextView voiceNetwork;
191 private TextView dataNetwork;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800192 private TextView dBm;
193 private TextView mMwi;
194 private TextView mCfi;
195 private TextView mLocation;
196 private TextView mNeighboringCids;
Wink Saville79bff2a2012-06-01 14:37:21 -0700197 private TextView mCellInfo;
Wink Saville4f0d8812014-04-15 22:05:24 -0700198 private TextView mDcRtInfoTv;
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;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800222 private Spinner preferredNetworkType;
Nathan Harold2b77d742016-03-19 13:22:10 -0700223 private Spinner cellInfoRefreshRateSpinner;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800224
Nathan Haroldf10ea322018-04-24 13:31:07 -0700225 private ConnectivityManager mConnectivityManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800226 private TelephonyManager mTelephonyManager;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800227 private ImsManager mImsManager = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800228 private Phone phone = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800229
Nathan Haroldcea413a2015-11-23 15:48:10 -0800230 private String mPingHostnameResultV4;
231 private String mPingHostnameResultV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800232 private String mHttpClientTestResult;
233 private boolean mMwiValue = false;
234 private boolean mCfiValue = false;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800235
236 private List<CellInfo> mCellInfoResult = null;
237 private CellLocation mCellLocationResult = null;
238 private List<NeighboringCellInfo> mNeighboringCellResult = null;
239
240 private int mPreferredNetworkTypeResult;
Nathan Harold2b77d742016-03-19 13:22:10 -0700241 private int mCellInfoRefreshRateIndex;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800242
Nathan Haroldf10ea322018-04-24 13:31:07 -0700243 private final NetworkRequest mDefaultNetworkRequest = new NetworkRequest.Builder()
244 .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
245 .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
246 .build();
247
248 private final NetworkCallback mNetworkCallback = new NetworkCallback() {
249 public void onCapabilitiesChanged(Network n, NetworkCapabilities nc) {
250 int dlbw = nc.getLinkDownstreamBandwidthKbps();
251 int ulbw = nc.getLinkUpstreamBandwidthKbps();
252 updateBandwidths(dlbw, ulbw);
253 }
254 };
255
Nathan Harold2b77d742016-03-19 13:22:10 -0700256 private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800257 @Override
258 public void onDataConnectionStateChanged(int state) {
259 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800260 updateNetworkType();
261 }
262
263 @Override
264 public void onDataActivity(int direction) {
265 updateDataStats2();
266 }
267
268 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700269 public void onCallStateChanged(int state, String incomingNumber) {
270 updateNetworkType();
271 updatePhoneState(state);
272 }
273
274 @Override
275 public void onPreciseCallStateChanged(PreciseCallState preciseState) {
276 updateNetworkType();
277 }
278
279 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800280 public void onCellLocationChanged(CellLocation location) {
281 updateLocation(location);
282 }
283
284 @Override
285 public void onMessageWaitingIndicatorChanged(boolean mwi) {
286 mMwiValue = mwi;
287 updateMessageWaiting();
288 }
289
290 @Override
291 public void onCallForwardingIndicatorChanged(boolean cfi) {
292 mCfiValue = cfi;
293 updateCallRedirect();
294 }
Wink Saville79bff2a2012-06-01 14:37:21 -0700295
296 @Override
297 public void onCellInfoChanged(List<CellInfo> arrayCi) {
Wink Savillebf471282013-04-05 15:04:05 -0700298 log("onCellInfoChanged: arrayCi=" + arrayCi);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800299 mCellInfoResult = arrayCi;
300 updateCellInfo(mCellInfoResult);
Wink Saville79bff2a2012-06-01 14:37:21 -0700301 }
Wink Saville4f0d8812014-04-15 22:05:24 -0700302
303 @Override
304 public void onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo) {
305 log("onDataConnectionRealTimeInfoChanged: dcRtInfo=" + dcRtInfo);
306 updateDcRtInfoTv(dcRtInfo);
307 }
Nathan Harold2b77d742016-03-19 13:22:10 -0700308
309 @Override
310 public void onSignalStrengthsChanged(SignalStrength signalStrength) {
311 log("onSignalStrengthChanged: SignalStrength=" +signalStrength);
312 updateSignalStrength(signalStrength);
313 }
314
315 @Override
316 public void onServiceStateChanged(ServiceState serviceState) {
317 log("onServiceStateChanged: ServiceState=" + serviceState);
318 updateServiceState(serviceState);
319 updateRadioPowerState();
320 updateNetworkType();
Nathan Harold12e1f552016-06-17 13:55:38 -0700321 updateImsProvisionedState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700322 }
Nathan Harold433ca442018-04-23 18:20:43 -0700323
324 @Override
325 public void onPhysicalChannelConfigurationChanged(
326 List<PhysicalChannelConfig> configs) {
327 updatePhysicalChannelConfiguration(configs);
328 }
329
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800330 };
331
Nathan Harold433ca442018-04-23 18:20:43 -0700332 private void updatePhysicalChannelConfiguration(List<PhysicalChannelConfig> configs) {
333 StringBuilder sb = new StringBuilder();
334 String div = "";
335 sb.append("{");
336 if (configs != null) {
337 for(PhysicalChannelConfig c : configs) {
338 sb.append(div).append(c);
339 div = ",";
340 }
341 }
342 sb.append("}");
343 mPhyChanConfig.setText(sb.toString());
344 }
345
Nathan Haroldcea413a2015-11-23 15:48:10 -0800346 private void updatePreferredNetworkType(int type) {
347 if (type >= mPreferredNetworkLabels.length || type < 0) {
348 log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
349 "type=" + type);
350 type = mPreferredNetworkLabels.length - 1; //set to Unknown
351 }
352 mPreferredNetworkTypeResult = type;
353
354 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
355 }
356
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800357 private Handler mHandler = new Handler() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800358 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800359 public void handleMessage(Message msg) {
360 AsyncResult ar;
361 switch (msg.what) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800362 case EVENT_QUERY_PREFERRED_TYPE_DONE:
363 ar= (AsyncResult) msg.obj;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800364 if (ar.exception == null && ar.result != null) {
365 updatePreferredNetworkType(((int[])ar.result)[0]);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800366 } else {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800367 //In case of an exception, we will set this to unknown
368 updatePreferredNetworkType(mPreferredNetworkLabels.length-1);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800369 }
370 break;
371 case EVENT_SET_PREFERRED_TYPE_DONE:
372 ar= (AsyncResult) msg.obj;
373 if (ar.exception != null) {
Nathan Harolded38afa2016-04-13 00:29:30 -0700374 log("Set preferred network type failed.");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800375 }
376 break;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800377 case EVENT_QUERY_SMSC_DONE:
378 ar= (AsyncResult) msg.obj;
379 if (ar.exception != null) {
380 smsc.setText("refresh error");
381 } else {
jsh21dd4072009-05-12 11:26:55 -0700382 smsc.setText((String)ar.result);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800383 }
384 break;
385 case EVENT_UPDATE_SMSC_DONE:
386 updateSmscButton.setEnabled(true);
387 ar= (AsyncResult) msg.obj;
388 if (ar.exception != null) {
389 smsc.setText("update error");
390 }
391 break;
392 default:
Nathan Haroldcea413a2015-11-23 15:48:10 -0800393 super.handleMessage(msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800394 break;
395
396 }
397 }
398 };
399
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800400 @Override
401 public void onCreate(Bundle icicle) {
402 super.onCreate(icicle);
fionaxub54cb2d2016-09-22 15:01:05 -0700403 if (!android.os.Process.myUserHandle().isSystem()) {
404 Log.e(TAG, "Not run from system user, don't do anything.");
405 finish();
406 return;
407 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800408
409 setContentView(R.layout.radio_info);
410
Nathan Haroldcea413a2015-11-23 15:48:10 -0800411 log("Started onCreate");
412
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800413 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
Nathan Haroldf10ea322018-04-24 13:31:07 -0700414 mConnectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800415 phone = PhoneFactory.getDefaultPhone();
416
Nathan Haroldcea413a2015-11-23 15:48:10 -0800417 //TODO: Need to update this if the default phoneId changes?
418 // Better to have an instance per phone?
419 mImsManager = ImsManager.getInstance(getApplicationContext(),
420 SubscriptionManager.getDefaultVoicePhoneId());
421
Meng Wang9053f172017-06-23 16:02:14 -0700422 mDeviceId = (TextView) findViewById(R.id.imei);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800423 number = (TextView) findViewById(R.id.number);
Meng Wang9053f172017-06-23 16:02:14 -0700424 mSubscriberId = (TextView) findViewById(R.id.imsi);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800425 callState = (TextView) findViewById(R.id.call);
426 operatorName = (TextView) findViewById(R.id.operator);
427 roamingState = (TextView) findViewById(R.id.roaming);
428 gsmState = (TextView) findViewById(R.id.gsm);
429 gprsState = (TextView) findViewById(R.id.gprs);
Nathan Harold2b77d742016-03-19 13:22:10 -0700430 voiceNetwork = (TextView) findViewById(R.id.voice_network);
431 dataNetwork = (TextView) findViewById(R.id.data_network);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800432 dBm = (TextView) findViewById(R.id.dbm);
433 mMwi = (TextView) findViewById(R.id.mwi);
434 mCfi = (TextView) findViewById(R.id.cfi);
435 mLocation = (TextView) findViewById(R.id.location);
436 mNeighboringCids = (TextView) findViewById(R.id.neighboring);
Wink Saville79bff2a2012-06-01 14:37:21 -0700437 mCellInfo = (TextView) findViewById(R.id.cellinfo);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800438 mCellInfo.setTypeface(Typeface.MONOSPACE);
Wink Saville4f0d8812014-04-15 22:05:24 -0700439 mDcRtInfoTv = (TextView) findViewById(R.id.dcrtinfo);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800440
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800441 sent = (TextView) findViewById(R.id.sent);
442 received = (TextView) findViewById(R.id.received);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800443 smsc = (EditText) findViewById(R.id.smsc);
444 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800445 mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4);
446 mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800447 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
448
Nathan Harold433ca442018-04-23 18:20:43 -0700449 mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config);
450
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800451 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
452 ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
453 android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
johnwang342101a2009-09-23 16:22:34 -0700454 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800455 preferredNetworkType.setAdapter(adapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800456
Nathan Harold2b77d742016-03-19 13:22:10 -0700457 cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select);
458 ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this,
459 android.R.layout.simple_spinner_item, mCellInfoRefreshRateLabels);
460 cellInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
461 cellInfoRefreshRateSpinner.setAdapter(cellInfoAdapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800462
Nathan Harold12e1f552016-06-17 13:55:38 -0700463 imsVolteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch);
464 imsVtProvisionedSwitch = (Switch) findViewById(R.id.vt_provisioned_switch);
465 imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
Meng Wang69439b52017-05-01 08:31:14 -0700466 eabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch);
Wink Savillebf471282013-04-05 15:04:05 -0700467
Nathan Harold2b77d742016-03-19 13:22:10 -0700468 radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
Wink Saville426fc662011-09-25 14:39:02 -0700469
Nathan Haroldf10ea322018-04-24 13:31:07 -0700470 mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
471 mUplinkKbps = (TextView) findViewById(R.id.ul_kbps);
472 updateBandwidths(0, 0);
473
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800474 pingTestButton = (Button) findViewById(R.id.ping_test);
475 pingTestButton.setOnClickListener(mPingButtonHandler);
476 updateSmscButton = (Button) findViewById(R.id.update_smsc);
477 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
478 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
479 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
480 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
481 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
Youhan Wangfd781e92016-12-16 15:53:16 -0800482 carrierProvisioningButton = (Button) findViewById(R.id.carrier_provisioning);
483 carrierProvisioningButton.setOnClickListener(mCarrierProvisioningButtonHandler);
484 triggercarrierProvisioningButton = (Button) findViewById(R.id.trigger_carrier_provisioning);
485 triggercarrierProvisioningButton.setOnClickListener(
486 mTriggerCarrierProvisioningButtonHandler);
johnwang342101a2009-09-23 16:22:34 -0700487
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800488 oemInfoButton = (Button) findViewById(R.id.oem_info);
489 oemInfoButton.setOnClickListener(mOemInfoButtonHandler);
490 PackageManager pm = getPackageManager();
491 Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO");
492 List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0);
493 if (oemInfoIntentList.size() == 0) {
494 oemInfoButton.setEnabled(false);
495 }
496
Nathan Harolded38afa2016-04-13 00:29:30 -0700497 mCellInfoRefreshRateIndex = 0; //disabled
Nathan Haroldcea413a2015-11-23 15:48:10 -0800498 mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown
499
500 //FIXME: Replace with TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800501 phone.getPreferredNetworkType(
502 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800503
Nathan Haroldcea413a2015-11-23 15:48:10 -0800504 restoreFromBundle(icicle);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800505 }
506
507 @Override
508 protected void onResume() {
509 super.onResume();
510
Nathan Haroldcea413a2015-11-23 15:48:10 -0800511 log("Started onResume");
512
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800513 updateMessageWaiting();
514 updateCallRedirect();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800515 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800516 updateDataStats2();
Nathan Harold2b77d742016-03-19 13:22:10 -0700517 updateRadioPowerState();
Nathan Harold12e1f552016-06-17 13:55:38 -0700518 updateImsProvisionedState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800519 updateProperties();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800520 updateDnsCheckState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700521 updateNetworkType();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800522
Nathan Haroldcea413a2015-11-23 15:48:10 -0800523 updateNeighboringCids(mNeighboringCellResult);
524 updateLocation(mCellLocationResult);
525 updateCellInfo(mCellInfoResult);
526
527 mPingHostnameV4.setText(mPingHostnameResultV4);
528 mPingHostnameV6.setText(mPingHostnameResultV6);
529 mHttpClientTest.setText(mHttpClientTestResult);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800530
Nathan Harold2b77d742016-03-19 13:22:10 -0700531 cellInfoRefreshRateSpinner.setOnItemSelectedListener(mCellInfoRefreshRateHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700532 //set selection after registering listener to force update
533 cellInfoRefreshRateSpinner.setSelection(mCellInfoRefreshRateIndex);
534
535 //set selection before registering to prevent update
536 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
Nathan Harold2b77d742016-03-19 13:22:10 -0700537 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700538
Nathan Harold2b77d742016-03-19 13:22:10 -0700539 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
Nathan Harold12e1f552016-06-17 13:55:38 -0700540 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
541 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
542 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Meng Wang586741c2017-04-26 15:02:51 -0700543 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
Nathan Harold2b77d742016-03-19 13:22:10 -0700544
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800545 mTelephonyManager.listen(mPhoneStateListener,
Nathan Harold2b77d742016-03-19 13:22:10 -0700546 PhoneStateListener.LISTEN_CALL_STATE
547 //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
548 // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
549 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800550 | PhoneStateListener.LISTEN_DATA_ACTIVITY
551 | PhoneStateListener.LISTEN_CELL_LOCATION
552 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
Wink Saville79bff2a2012-06-01 14:37:21 -0700553 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
Wink Saville4f0d8812014-04-15 22:05:24 -0700554 | PhoneStateListener.LISTEN_CELL_INFO
Nathan Harold2b77d742016-03-19 13:22:10 -0700555 | PhoneStateListener.LISTEN_SERVICE_STATE
556 | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
Nathan Harold433ca442018-04-23 18:20:43 -0700557 | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION);
Nathan Harolded38afa2016-04-13 00:29:30 -0700558
Nathan Haroldf10ea322018-04-24 13:31:07 -0700559 mConnectivityManager.registerNetworkCallback(
560 mDefaultNetworkRequest, mNetworkCallback, mHandler);
561
Nathan Harolded38afa2016-04-13 00:29:30 -0700562 smsc.clearFocus();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800563 }
564
565 @Override
Nathan Haroldcea413a2015-11-23 15:48:10 -0800566 protected void onPause() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800567 super.onPause();
568
Wink Savillebf471282013-04-05 15:04:05 -0700569 log("onPause: unregister phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800570
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800571 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -0700572 mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
Nathan Haroldf10ea322018-04-24 13:31:07 -0700573 mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
574
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800575 }
576
Nathan Haroldcea413a2015-11-23 15:48:10 -0800577 private void restoreFromBundle(Bundle b) {
Nathan Harolde272c202016-10-27 13:45:00 -0700578 if(b == null) {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800579 return;
580 }
581
582 mPingHostnameResultV4 = b.getString("mPingHostnameResultV4","");
583 mPingHostnameResultV6 = b.getString("mPingHostnameResultV6","");
584 mHttpClientTestResult = b.getString("mHttpClientTestResult","");
585
586 mPingHostnameV4.setText(mPingHostnameResultV4);
587 mPingHostnameV6.setText(mPingHostnameResultV6);
588 mHttpClientTest.setText(mHttpClientTestResult);
589
Nathan Harold2b77d742016-03-19 13:22:10 -0700590 mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult",
591 mPreferredNetworkLabels.length - 1);
592
593 mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800594 }
595
596 @Override
597 protected void onSaveInstanceState(Bundle outState) {
598 outState.putString("mPingHostnameResultV4", mPingHostnameResultV4);
599 outState.putString("mPingHostnameResultV6", mPingHostnameResultV6);
600 outState.putString("mHttpClientTestResult", mHttpClientTestResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700601
Nathan Haroldcea413a2015-11-23 15:48:10 -0800602 outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700603 outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex);
604
Nathan Haroldcea413a2015-11-23 15:48:10 -0800605 }
606
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800607 @Override
608 public boolean onCreateOptionsMenu(Menu menu) {
Wink Savillec3886682009-04-02 11:00:56 -0700609 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
610 .setOnMenuItemClickListener(mSelectBandCallback)
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800611 .setAlphabeticShortcut('b');
612 menu.add(1, MENU_ITEM_VIEW_ADN, 0,
613 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
614 menu.add(1, MENU_ITEM_VIEW_FDN, 0,
615 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
616 menu.add(1, MENU_ITEM_VIEW_SDN, 0,
617 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
Nathan Harolde272c202016-10-27 13:45:00 -0700618 menu.add(1, MENU_ITEM_GET_IMS_STATUS,
619 0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800620 menu.add(1, MENU_ITEM_TOGGLE_DATA,
Nathan Harold2b77d742016-03-19 13:22:10 -0700621 0, R.string.radio_info_data_connection_disable).setOnMenuItemClickListener(mToggleData);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800622 return true;
623 }
624
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800625 @Override
Wink Savillec3886682009-04-02 11:00:56 -0700626 public boolean onPrepareOptionsMenu(Menu menu) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800627 // Get the TOGGLE DATA menu item in the right state.
628 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
629 int state = mTelephonyManager.getDataState();
630 boolean visible = true;
631
632 switch (state) {
633 case TelephonyManager.DATA_CONNECTED:
634 case TelephonyManager.DATA_SUSPENDED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700635 item.setTitle(R.string.radio_info_data_connection_disable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800636 break;
637 case TelephonyManager.DATA_DISCONNECTED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700638 item.setTitle(R.string.radio_info_data_connection_enable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800639 break;
640 default:
641 visible = false;
642 break;
643 }
644 item.setVisible(visible);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800645 return true;
646 }
647
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800648 private void updateDnsCheckState() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800649 //FIXME: Replace with a TelephonyManager call
Mike Lockwood5304c7e2009-04-05 11:37:45 -0700650 dnsCheckState.setText(phone.isDnsCheckDisabled() ?
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800651 "0.0.0.0 allowed" :"0.0.0.0 not allowed");
652 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700653
Nathan Haroldf10ea322018-04-24 13:31:07 -0700654 private void updateBandwidths(int dlbw, int ulbw) {
655 dlbw = (dlbw < 0 || dlbw == Integer.MAX_VALUE) ? -1 : dlbw;
656 ulbw = (ulbw < 0 || ulbw == Integer.MAX_VALUE) ? -1 : ulbw;
657 mDownlinkKbps.setText(String.format("%-5d", dlbw));
658 mUplinkKbps.setText(String.format("%-5d", ulbw));
659 }
660
661
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800662 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700663 updateSignalStrength(SignalStrength signalStrength) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800664 Resources r = getResources();
665
Nathan Harold2b77d742016-03-19 13:22:10 -0700666 int signalDbm = signalStrength.getDbm();
Wink Savillee2a14e32009-05-29 14:06:30 -0700667
Nathan Harold2b77d742016-03-19 13:22:10 -0700668 int signalAsu = signalStrength.getAsuLevel();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800669
670 if (-1 == signalAsu) signalAsu = 0;
671
672 dBm.setText(String.valueOf(signalDbm) + " "
673 + r.getString(R.string.radioInfo_display_dbm) + " "
674 + String.valueOf(signalAsu) + " "
675 + r.getString(R.string.radioInfo_display_asu));
676 }
677
678 private final void updateLocation(CellLocation location) {
jsh534f5ae2009-09-24 09:19:22 -0700679 Resources r = getResources();
Wink Savillec3886682009-04-02 11:00:56 -0700680 if (location instanceof GsmCellLocation) {
681 GsmCellLocation loc = (GsmCellLocation)location;
jsh534f5ae2009-09-24 09:19:22 -0700682 int lac = loc.getLac();
683 int cid = loc.getCid();
684 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
685 + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
686 + " "
687 + r.getString(R.string.radioInfo_cid) + " = "
688 + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
689 } else if (location instanceof CdmaCellLocation) {
690 CdmaCellLocation loc = (CdmaCellLocation)location;
691 int bid = loc.getBaseStationId();
692 int sid = loc.getSystemId();
693 int nid = loc.getNetworkId();
694 int lat = loc.getBaseStationLatitude();
695 int lon = loc.getBaseStationLongitude();
696 mLocation.setText("BID = "
697 + ((bid == -1) ? "unknown" : Integer.toHexString(bid))
698 + " "
699 + "SID = "
700 + ((sid == -1) ? "unknown" : Integer.toHexString(sid))
701 + " "
702 + "NID = "
703 + ((nid == -1) ? "unknown" : Integer.toHexString(nid))
704 + "\n"
705 + "LAT = "
706 + ((lat == -1) ? "unknown" : Integer.toHexString(lat))
707 + " "
708 + "LONG = "
709 + ((lon == -1) ? "unknown" : Integer.toHexString(lon)));
710 } else {
711 mLocation.setText("unknown");
Wink Savillec3886682009-04-02 11:00:56 -0700712 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800713
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800714
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800715 }
716
Nathan Haroldcea413a2015-11-23 15:48:10 -0800717 private final void updateNeighboringCids(List<NeighboringCellInfo> cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700718 StringBuilder sb = new StringBuilder();
719
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800720 if (cids != null) {
Nathan Harolde272c202016-10-27 13:45:00 -0700721 if (cids.isEmpty()) {
johnwangf02c65f2009-09-25 17:26:54 -0700722 sb.append("no neighboring cells");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800723 } else {
724 for (NeighboringCellInfo cell : cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700725 sb.append(cell.toString()).append(" ");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800726 }
727 }
728 } else {
johnwangf02c65f2009-09-25 17:26:54 -0700729 sb.append("unknown");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800730 }
johnwangf02c65f2009-09-25 17:26:54 -0700731 mNeighboringCids.setText(sb.toString());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800732 }
733
Nathan Haroldcea413a2015-11-23 15:48:10 -0800734 private final String getCellInfoDisplayString(int i) {
735 return (i != Integer.MAX_VALUE) ? Integer.toString(i) : "";
736 }
737
738 private final String getCellInfoDisplayString(long i) {
739 return (i != Long.MAX_VALUE) ? Long.toString(i) : "";
740 }
741
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700742 private final String getConnectionStatusString(CellInfo ci) {
743 String regStr = "";
744 String connStatStr = "";
745 String connector = "";
746
747 if (ci.isRegistered()) {
748 regStr = "R";
749 }
750 switch (ci.getCellConnectionStatus()) {
751 case CellInfo.CONNECTION_PRIMARY_SERVING: connStatStr = "P"; break;
752 case CellInfo.CONNECTION_SECONDARY_SERVING: connStatStr = "S"; break;
753 case CellInfo.CONNECTION_NONE: connStatStr = "N"; break;
754 case CellInfo.CONNECTION_UNKNOWN: /* Field is unsupported */ break;
755 default: break;
756 }
757 if (!TextUtils.isEmpty(regStr) && !TextUtils.isEmpty(connStatStr)) {
758 connector = "+";
759 }
760
761 return regStr + connector + connStatStr;
762 }
763
Nathan Haroldcea413a2015-11-23 15:48:10 -0800764 private final String buildCdmaInfoString(CellInfoCdma ci) {
765 CellIdentityCdma cidCdma = ci.getCellIdentity();
766 CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
767
768 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 -0700769 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800770 getCellInfoDisplayString(cidCdma.getSystemId()),
771 getCellInfoDisplayString(cidCdma.getNetworkId()),
772 getCellInfoDisplayString(cidCdma.getBasestationId()),
773 getCellInfoDisplayString(ssCdma.getCdmaDbm()),
774 getCellInfoDisplayString(ssCdma.getCdmaEcio()),
775 getCellInfoDisplayString(ssCdma.getEvdoDbm()),
776 getCellInfoDisplayString(ssCdma.getEvdoEcio()),
777 getCellInfoDisplayString(ssCdma.getEvdoSnr()));
778 }
779
780 private final String buildGsmInfoString(CellInfoGsm ci) {
781 CellIdentityGsm cidGsm = ci.getCellIdentity();
782 CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
783
Nathan Harold2b77d742016-03-19 13:22:10 -0700784 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 -0700785 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800786 getCellInfoDisplayString(cidGsm.getMcc()),
787 getCellInfoDisplayString(cidGsm.getMnc()),
788 getCellInfoDisplayString(cidGsm.getLac()),
789 getCellInfoDisplayString(cidGsm.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700790 getCellInfoDisplayString(cidGsm.getArfcn()),
791 getCellInfoDisplayString(cidGsm.getBsic()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800792 getCellInfoDisplayString(ssGsm.getDbm()));
793 }
794
795 private final String buildLteInfoString(CellInfoLte ci) {
796 CellIdentityLte cidLte = ci.getCellIdentity();
797 CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
798
799 return String.format(
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700800 "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
801 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800802 getCellInfoDisplayString(cidLte.getMcc()),
803 getCellInfoDisplayString(cidLte.getMnc()),
804 getCellInfoDisplayString(cidLte.getTac()),
805 getCellInfoDisplayString(cidLte.getCi()),
806 getCellInfoDisplayString(cidLte.getPci()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700807 getCellInfoDisplayString(cidLte.getEarfcn()),
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700808 getCellInfoDisplayString(cidLte.getBandwidth()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800809 getCellInfoDisplayString(ssLte.getDbm()),
810 getCellInfoDisplayString(ssLte.getRsrq()),
811 getCellInfoDisplayString(ssLte.getTimingAdvance()));
812 }
813
814 private final String buildWcdmaInfoString(CellInfoWcdma ci) {
815 CellIdentityWcdma cidWcdma = ci.getCellIdentity();
816 CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength();
817
Nathan Harold2b77d742016-03-19 13:22:10 -0700818 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 -0700819 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800820 getCellInfoDisplayString(cidWcdma.getMcc()),
821 getCellInfoDisplayString(cidWcdma.getMnc()),
822 getCellInfoDisplayString(cidWcdma.getLac()),
823 getCellInfoDisplayString(cidWcdma.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700824 getCellInfoDisplayString(cidWcdma.getUarfcn()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800825 getCellInfoDisplayString(cidWcdma.getPsc()),
826 getCellInfoDisplayString(ssWcdma.getDbm()));
827 }
828
829 private final String buildCellInfoString(List<CellInfo> arrayCi) {
830 String value = new String();
831 StringBuilder cdmaCells = new StringBuilder(),
832 gsmCells = new StringBuilder(),
833 lteCells = new StringBuilder(),
834 wcdmaCells = new StringBuilder();
835
836 if (arrayCi != null) {
837 for (CellInfo ci : arrayCi) {
838
839 if (ci instanceof CellInfoLte) {
840 lteCells.append(buildLteInfoString((CellInfoLte) ci));
841 } else if (ci instanceof CellInfoWcdma) {
842 wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
843 } else if (ci instanceof CellInfoGsm) {
844 gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
845 } else if (ci instanceof CellInfoCdma) {
846 cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
Wink Saville79bff2a2012-06-01 14:37:21 -0700847 }
848 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800849 if (lteCells.length() != 0) {
850 value += String.format(
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700851 "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s"
852 + " %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
853 "SRV", "MCC", "MNC", "TAC", "CID", "PCI",
854 "EARFCN", "BW", "RSRP", "RSRQ", "TA");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800855 value += lteCells.toString();
856 }
857 if (wcdmaCells.length() != 0) {
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700858 value += String.format(
859 "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 -0700860 "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800861 value += wcdmaCells.toString();
862 }
863 if (gsmCells.length() != 0) {
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700864 value += String.format(
865 "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 -0700866 "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800867 value += gsmCells.toString();
868 }
869 if (cdmaCells.length() != 0) {
870 value += String.format(
871 "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n",
872 "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
873 value += cdmaCells.toString();
874 }
875 } else {
876 value ="unknown";
Wink Saville79bff2a2012-06-01 14:37:21 -0700877 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800878
879 return value.toString();
880 }
881
882 private final void updateCellInfo(List<CellInfo> arrayCi) {
883 mCellInfo.setText(buildCellInfoString(arrayCi));
Wink Saville79bff2a2012-06-01 14:37:21 -0700884 }
885
Wink Saville4f0d8812014-04-15 22:05:24 -0700886 private final void updateDcRtInfoTv(DataConnectionRealTimeInfo dcRtInfo) {
887 mDcRtInfoTv.setText(dcRtInfo.toString());
888 }
889
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800890 private final void
891 updateMessageWaiting() {
892 mMwi.setText(String.valueOf(mMwiValue));
893 }
894
895 private final void
896 updateCallRedirect() {
897 mCfi.setText(String.valueOf(mCfiValue));
898 }
899
900
901 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700902 updateServiceState(ServiceState serviceState) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800903 int state = serviceState.getState();
904 Resources r = getResources();
905 String display = r.getString(R.string.radioInfo_unknown);
johnwang342101a2009-09-23 16:22:34 -0700906
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800907 switch (state) {
908 case ServiceState.STATE_IN_SERVICE:
909 display = r.getString(R.string.radioInfo_service_in);
910 break;
911 case ServiceState.STATE_OUT_OF_SERVICE:
912 case ServiceState.STATE_EMERGENCY_ONLY:
913 display = r.getString(R.string.radioInfo_service_emergency);
914 break;
915 case ServiceState.STATE_POWER_OFF:
916 display = r.getString(R.string.radioInfo_service_off);
917 break;
918 }
johnwang342101a2009-09-23 16:22:34 -0700919
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800920 gsmState.setText(display);
johnwang342101a2009-09-23 16:22:34 -0700921
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800922 if (serviceState.getRoaming()) {
923 roamingState.setText(R.string.radioInfo_roaming_in);
924 } else {
925 roamingState.setText(R.string.radioInfo_roaming_not);
926 }
927
928 operatorName.setText(serviceState.getOperatorAlphaLong());
929 }
930
931 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700932 updatePhoneState(int state) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800933 Resources r = getResources();
934 String display = r.getString(R.string.radioInfo_unknown);
935
936 switch (state) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700937 case TelephonyManager.CALL_STATE_IDLE:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800938 display = r.getString(R.string.radioInfo_phone_idle);
939 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700940 case TelephonyManager.CALL_STATE_RINGING:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800941 display = r.getString(R.string.radioInfo_phone_ringing);
942 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700943 case TelephonyManager.CALL_STATE_OFFHOOK:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800944 display = r.getString(R.string.radioInfo_phone_offhook);
945 break;
946 }
947
948 callState.setText(display);
949 }
950
951 private final void
952 updateDataState() {
953 int state = mTelephonyManager.getDataState();
954 Resources r = getResources();
955 String display = r.getString(R.string.radioInfo_unknown);
956
957 switch (state) {
958 case TelephonyManager.DATA_CONNECTED:
959 display = r.getString(R.string.radioInfo_data_connected);
960 break;
961 case TelephonyManager.DATA_CONNECTING:
962 display = r.getString(R.string.radioInfo_data_connecting);
963 break;
964 case TelephonyManager.DATA_DISCONNECTED:
965 display = r.getString(R.string.radioInfo_data_disconnected);
966 break;
967 case TelephonyManager.DATA_SUSPENDED:
968 display = r.getString(R.string.radioInfo_data_suspended);
969 break;
970 }
johnwang342101a2009-09-23 16:22:34 -0700971
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800972 gprsState.setText(display);
973 }
974
975 private final void updateNetworkType() {
Nathan Harolde272c202016-10-27 13:45:00 -0700976 if(phone != null) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700977 ServiceState ss = phone.getServiceState();
978 dataNetwork.setText(ServiceState.rilRadioTechnologyToString(
979 phone.getServiceState().getRilDataRadioTechnology()));
980 voiceNetwork.setText(ServiceState.rilRadioTechnologyToString(
981 phone.getServiceState().getRilVoiceRadioTechnology()));
982 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800983 }
984
985 private final void
986 updateProperties() {
987 String s;
988 Resources r = getResources();
989
990 s = phone.getDeviceId();
johnwang342101a2009-09-23 16:22:34 -0700991 if (s == null) s = r.getString(R.string.radioInfo_unknown);
Wink Savillec3886682009-04-02 11:00:56 -0700992 mDeviceId.setText(s);
johnwang342101a2009-09-23 16:22:34 -0700993
Meng Wang9053f172017-06-23 16:02:14 -0700994 s = phone.getSubscriberId();
995 if (s == null) s = r.getString(R.string.radioInfo_unknown);
996 mSubscriberId.setText(s);
997
Nathan Haroldcea413a2015-11-23 15:48:10 -0800998 //FIXME: Replace with a TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800999 s = phone.getLine1Number();
johnwang342101a2009-09-23 16:22:34 -07001000 if (s == null) s = r.getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001001 number.setText(s);
1002 }
1003
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001004 private final void updateDataStats2() {
1005 Resources r = getResources();
1006
Jeff Sharkey93029862011-05-27 18:26:15 -07001007 long txPackets = TrafficStats.getMobileTxPackets();
1008 long rxPackets = TrafficStats.getMobileRxPackets();
1009 long txBytes = TrafficStats.getMobileTxBytes();
1010 long rxBytes = TrafficStats.getMobileRxBytes();
johnwang342101a2009-09-23 16:22:34 -07001011
Jeff Sharkey93029862011-05-27 18:26:15 -07001012 String packets = r.getString(R.string.radioInfo_display_packets);
1013 String bytes = r.getString(R.string.radioInfo_display_bytes);
johnwang342101a2009-09-23 16:22:34 -07001014
Jeff Sharkey93029862011-05-27 18:26:15 -07001015 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
1016 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001017 }
1018
1019 /**
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001020 * Ping a host name
1021 */
1022 private final void pingHostname() {
1023 try {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001024 try {
1025 Process p4 = Runtime.getRuntime().exec("ping -c 1 www.google.com");
1026 int status4 = p4.waitFor();
1027 if (status4 == 0) {
1028 mPingHostnameResultV4 = "Pass";
1029 } else {
1030 mPingHostnameResultV4 = String.format("Fail(%d)", status4);
1031 }
1032 } catch (IOException e) {
1033 mPingHostnameResultV4 = "Fail: IOException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001034 }
Nathan Haroldcea413a2015-11-23 15:48:10 -08001035 try {
1036 Process p6 = Runtime.getRuntime().exec("ping6 -c 1 www.google.com");
1037 int status6 = p6.waitFor();
1038 if (status6 == 0) {
1039 mPingHostnameResultV6 = "Pass";
1040 } else {
1041 mPingHostnameResultV6 = String.format("Fail(%d)", status6);
1042 }
1043 } catch (IOException e) {
1044 mPingHostnameResultV6 = "Fail: IOException";
1045 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001046 } catch (InterruptedException e) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001047 mPingHostnameResultV4 = mPingHostnameResultV6 = "Fail: InterruptedException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001048 }
1049 }
1050
1051 /**
1052 * This function checks for basic functionality of HTTP Client.
1053 */
1054 private void httpClientTest() {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001055 HttpURLConnection urlConnection = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001056 try {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001057 // TODO: Hardcoded for now, make it UI configurable
Alex Klyubinb0090232015-04-02 11:08:51 -07001058 URL url = new URL("https://www.google.com");
Narayan Kamathf25627c2014-12-12 13:53:28 +00001059 urlConnection = (HttpURLConnection) url.openConnection();
1060 if (urlConnection.getResponseCode() == 200) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001061 mHttpClientTestResult = "Pass";
1062 } else {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001063 mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001064 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001065 } catch (IOException e) {
1066 mHttpClientTestResult = "Fail: IOException";
Narayan Kamathf25627c2014-12-12 13:53:28 +00001067 } finally {
1068 if (urlConnection != null) {
1069 urlConnection.disconnect();
1070 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001071 }
1072 }
1073
1074 private void refreshSmsc() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001075 //FIXME: Replace with a TelephonyManager call
jsh21dd4072009-05-12 11:26:55 -07001076 phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001077 }
1078
Nathan Haroldcea413a2015-11-23 15:48:10 -08001079 private final void updateAllCellInfo() {
1080
1081 mCellInfo.setText("");
1082 mNeighboringCids.setText("");
1083 mLocation.setText("");
1084
1085 final Runnable updateAllCellInfoResults = new Runnable() {
1086 public void run() {
1087 updateNeighboringCids(mNeighboringCellResult);
1088 updateLocation(mCellLocationResult);
1089 updateCellInfo(mCellInfoResult);
1090 }
1091 };
1092
1093 Thread locThread = new Thread() {
1094 @Override
1095 public void run() {
1096 mCellInfoResult = mTelephonyManager.getAllCellInfo();
1097 mCellLocationResult = mTelephonyManager.getCellLocation();
1098 mNeighboringCellResult = mTelephonyManager.getNeighboringCellInfo();
1099
1100 mHandler.post(updateAllCellInfoResults);
1101 }
1102 };
1103 locThread.start();
1104 }
1105
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001106 private final void updatePingState() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001107 // Set all to unknown since the threads will take a few secs to update.
Nathan Haroldcea413a2015-11-23 15:48:10 -08001108 mPingHostnameResultV4 = getResources().getString(R.string.radioInfo_unknown);
1109 mPingHostnameResultV6 = getResources().getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001110 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
1111
Nathan Haroldcea413a2015-11-23 15:48:10 -08001112 mPingHostnameV4.setText(mPingHostnameResultV4);
1113 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001114 mHttpClientTest.setText(mHttpClientTestResult);
1115
1116 final Runnable updatePingResults = new Runnable() {
1117 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001118 mPingHostnameV4.setText(mPingHostnameResultV4);
1119 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001120 mHttpClientTest.setText(mHttpClientTestResult);
1121 }
1122 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001123
1124 Thread hostname = new Thread() {
1125 @Override
1126 public void run() {
1127 pingHostname();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001128 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001129 }
1130 };
1131 hostname.start();
1132
1133 Thread httpClient = new Thread() {
1134 @Override
1135 public void run() {
1136 httpClientTest();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001137 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001138 }
1139 };
1140 httpClient.start();
1141 }
1142
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001143 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
1144 public boolean onMenuItemClick(MenuItem item) {
1145 Intent intent = new Intent(Intent.ACTION_VIEW);
1146 // XXX We need to specify the component here because if we don't
1147 // the activity manager will try to resolve the type by calling
1148 // the content provider, which causes it to be loaded in a process
1149 // other than the Dialer process, which causes a lot of stuff to
1150 // break.
1151 intent.setClassName("com.android.phone",
1152 "com.android.phone.SimContacts");
1153 startActivity(intent);
1154 return true;
1155 }
1156 };
1157
1158 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
1159 public boolean onMenuItemClick(MenuItem item) {
1160 Intent intent = new Intent(Intent.ACTION_VIEW);
1161 // XXX We need to specify the component here because if we don't
1162 // the activity manager will try to resolve the type by calling
1163 // the content provider, which causes it to be loaded in a process
1164 // other than the Dialer process, which causes a lot of stuff to
1165 // break.
1166 intent.setClassName("com.android.phone",
Andrew Leeda90d682014-10-31 13:12:20 -07001167 "com.android.phone.settings.fdn.FdnList");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001168 startActivity(intent);
1169 return true;
1170 }
1171 };
1172
1173 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
1174 public boolean onMenuItemClick(MenuItem item) {
1175 Intent intent = new Intent(
Wink Savillec3886682009-04-02 11:00:56 -07001176 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001177 // XXX We need to specify the component here because if we don't
1178 // the activity manager will try to resolve the type by calling
1179 // the content provider, which causes it to be loaded in a process
1180 // other than the Dialer process, which causes a lot of stuff to
1181 // break.
1182 intent.setClassName("com.android.phone",
1183 "com.android.phone.ADNList");
1184 startActivity(intent);
1185 return true;
1186 }
1187 };
1188
Nathan Harolde272c202016-10-27 13:45:00 -07001189 private MenuItem.OnMenuItemClickListener mGetImsStatus = new MenuItem.OnMenuItemClickListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001190 public boolean onMenuItemClick(MenuItem item) {
Nathan Harolde272c202016-10-27 13:45:00 -07001191 boolean isImsRegistered = phone.isImsRegistered();
1192 boolean availableVolte = phone.isVolteEnabled();
1193 boolean availableWfc = phone.isWifiCallingEnabled();
1194 boolean availableVt = phone.isVideoEnabled();
1195 boolean availableUt = phone.isUtEnabled();
1196
1197 final String imsRegString = isImsRegistered ?
1198 getString(R.string.radio_info_ims_reg_status_registered) :
1199 getString(R.string.radio_info_ims_reg_status_not_registered);
1200
1201 final String available = getString(R.string.radio_info_ims_feature_status_available);
1202 final String unavailable = getString(
1203 R.string.radio_info_ims_feature_status_unavailable);
1204
1205 String imsStatus = getString(R.string.radio_info_ims_reg_status,
1206 imsRegString,
1207 availableVolte ? available : unavailable,
1208 availableWfc ? available : unavailable,
1209 availableVt ? available : unavailable,
1210 availableUt ? available : unavailable);
1211
1212 AlertDialog imsDialog = new AlertDialog.Builder(RadioInfo.this)
1213 .setMessage(imsStatus)
1214 .setTitle(getString(R.string.radio_info_ims_reg_status_title))
1215 .create();
1216
1217 imsDialog.show();
1218
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001219 return true;
1220 }
1221 };
1222
1223 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
1224 public boolean onMenuItemClick(MenuItem item) {
1225 Intent intent = new Intent();
1226 intent.setClass(RadioInfo.this, BandMode.class);
1227 startActivity(intent);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001228 return true;
1229 }
1230 };
johnwang342101a2009-09-23 16:22:34 -07001231
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001232 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
1233 public boolean onMenuItemClick(MenuItem item) {
1234 int state = mTelephonyManager.getDataState();
1235 switch (state) {
1236 case TelephonyManager.DATA_CONNECTED:
Nathan Haroldcea413a2015-11-23 15:48:10 -08001237 //FIXME: Replace with a TelephonyManager call
Malcolm Chenf612f592017-11-29 18:01:25 -08001238 phone.setUserDataEnabled(false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001239 break;
1240 case TelephonyManager.DATA_DISCONNECTED:
Nathan Haroldcea413a2015-11-23 15:48:10 -08001241 //FIXME: Replace with a TelephonyManager call
Malcolm Chenf612f592017-11-29 18:01:25 -08001242 phone.setUserDataEnabled(true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001243 break;
1244 default:
1245 // do nothing
1246 break;
1247 }
1248 return true;
1249 }
1250 };
1251
Nathan Harold2b77d742016-03-19 13:22:10 -07001252 private boolean isRadioOn() {
1253 //FIXME: Replace with a TelephonyManager call
1254 return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
1255 }
1256
1257 private void updateRadioPowerState() {
1258 //delightful hack to prevent on-checked-changed calls from
1259 //actually forcing the radio preference to its transient/current value.
1260 radioPowerOnSwitch.setOnCheckedChangeListener(null);
1261 radioPowerOnSwitch.setChecked(isRadioOn());
1262 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
1263 }
1264
Nathan Harolde272c202016-10-27 13:45:00 -07001265 void setImsVolteProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001266 Log.d(TAG, "setImsVolteProvisioned state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001267 setImsConfigProvisionedState(IMS_VOLTE_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001268 }
1269
Nathan Harolde272c202016-10-27 13:45:00 -07001270 void setImsVtProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001271 Log.d(TAG, "setImsVtProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001272 setImsConfigProvisionedState(IMS_VT_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001273 }
1274
Nathan Harolde272c202016-10-27 13:45:00 -07001275 void setImsWfcProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001276 Log.d(TAG, "setImsWfcProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001277 setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001278 }
1279
Meng Wang586741c2017-04-26 15:02:51 -07001280 void setEabProvisionedState(boolean state) {
1281 Log.d(TAG, "setEabProvisioned() state: " + ((state)? "on":"off"));
1282 setImsConfigProvisionedState(EAB_PROVISIONED_CONFIG_ID, state);
1283 }
1284
Nathan Harolde272c202016-10-27 13:45:00 -07001285 void setImsConfigProvisionedState(int configItem, boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001286 if (phone != null && mImsManager != null) {
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001287 QueuedWork.queue(new Runnable() {
Nathan Harold12e1f552016-06-17 13:55:38 -07001288 public void run() {
1289 try {
1290 mImsManager.getConfigInterface().setProvisionedValue(
1291 configItem,
1292 state? 1 : 0);
1293 } catch (ImsException e) {
1294 Log.e(TAG, "setImsConfigProvisioned() exception:", e);
1295 }
1296 }
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001297 }, false);
Nathan Harold12e1f552016-06-17 13:55:38 -07001298 }
1299 }
1300
Nathan Harold2b77d742016-03-19 13:22:10 -07001301 OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() {
1302 @Override
1303 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1304 log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
1305 phone.setRadioPower(isChecked);
1306 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001307 };
1308
Nathan Harold12e1f552016-06-17 13:55:38 -07001309 private boolean isImsVolteProvisioned() {
Nathan Harold2b77d742016-03-19 13:22:10 -07001310 if (phone != null && mImsManager != null) {
1311 return mImsManager.isVolteEnabledByPlatform(phone.getContext())
1312 && mImsManager.isVolteProvisionedOnDevice(phone.getContext());
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -08001313 }
1314 return false;
1315 }
1316
Nathan Harold12e1f552016-06-17 13:55:38 -07001317 OnCheckedChangeListener mImsVolteCheckedChangeListener = new OnCheckedChangeListener() {
Wink Saville426fc662011-09-25 14:39:02 -07001318 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -07001319 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001320 setImsVolteProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001321 }
Wink Saville426fc662011-09-25 14:39:02 -07001322 };
1323
Nathan Harold12e1f552016-06-17 13:55:38 -07001324 private boolean isImsVtProvisioned() {
1325 if (phone != null && mImsManager != null) {
1326 return mImsManager.isVtEnabledByPlatform(phone.getContext())
1327 && mImsManager.isVtProvisionedOnDevice(phone.getContext());
1328 }
1329 return false;
1330 }
1331
1332 OnCheckedChangeListener mImsVtCheckedChangeListener = new OnCheckedChangeListener() {
1333 @Override
1334 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1335 setImsVtProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001336 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001337 };
1338
1339 private boolean isImsWfcProvisioned() {
1340 if (phone != null && mImsManager != null) {
1341 return mImsManager.isWfcEnabledByPlatform(phone.getContext())
1342 && mImsManager.isWfcProvisionedOnDevice(phone.getContext());
1343 }
1344 return false;
1345 }
1346
1347 OnCheckedChangeListener mImsWfcCheckedChangeListener = new OnCheckedChangeListener() {
1348 @Override
1349 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1350 setImsWfcProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001351 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001352 };
1353
Meng Wang586741c2017-04-26 15:02:51 -07001354 private boolean isEabProvisioned() {
1355 return isFeatureProvisioned(EAB_PROVISIONED_CONFIG_ID, false);
1356 }
1357
1358 OnCheckedChangeListener mEabCheckedChangeListener = new OnCheckedChangeListener() {
1359 @Override
1360 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1361 setEabProvisionedState(isChecked);
1362 }
1363 };
1364
1365 private boolean isFeatureProvisioned(int featureId, boolean defaultValue) {
1366 boolean provisioned = defaultValue;
1367 if (mImsManager != null) {
1368 try {
1369 ImsConfig imsConfig = mImsManager.getConfigInterface();
1370 if (imsConfig != null) {
1371 provisioned =
1372 (imsConfig.getProvisionedValue(featureId)
1373 == ImsConfig.FeatureValueConstants.ON);
1374 }
1375 } catch (ImsException ex) {
1376 Log.e(TAG, "isFeatureProvisioned() exception:", ex);
1377 }
1378 }
1379
1380 log("isFeatureProvisioned() featureId=" + featureId + " provisioned=" + provisioned);
1381 return provisioned;
1382 }
1383
1384 private static boolean isEabEnabledByPlatform(Context context) {
1385 if (context != null) {
1386 CarrierConfigManager configManager = (CarrierConfigManager)
1387 context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
1388 if (configManager != null && configManager.getConfig().getBoolean(
1389 CarrierConfigManager.KEY_USE_RCS_PRESENCE_BOOL)) {
1390 return true;
1391 }
1392 }
1393 return false;
1394 }
1395
Nathan Harold12e1f552016-06-17 13:55:38 -07001396 private void updateImsProvisionedState() {
1397 log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
Nathan Harold2b77d742016-03-19 13:22:10 -07001398 //delightful hack to prevent on-checked-changed calls from
1399 //actually forcing the ims provisioning to its transient/current value.
Nathan Harold12e1f552016-06-17 13:55:38 -07001400 imsVolteProvisionedSwitch.setOnCheckedChangeListener(null);
1401 imsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned());
1402 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001403 imsVolteProvisionedSwitch.setEnabled(
1404 mImsManager.isVolteEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001405
1406 imsVtProvisionedSwitch.setOnCheckedChangeListener(null);
1407 imsVtProvisionedSwitch.setChecked(isImsVtProvisioned());
1408 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001409 imsVtProvisionedSwitch.setEnabled(
1410 mImsManager.isVtEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001411
1412 imsWfcProvisionedSwitch.setOnCheckedChangeListener(null);
1413 imsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned());
1414 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001415 imsWfcProvisionedSwitch.setEnabled(
1416 mImsManager.isWfcEnabledByPlatform(phone.getContext()));
Meng Wang586741c2017-04-26 15:02:51 -07001417
1418 eabProvisionedSwitch.setOnCheckedChangeListener(null);
1419 eabProvisionedSwitch.setChecked(isEabProvisioned());
1420 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
1421 eabProvisionedSwitch.setEnabled(isEabEnabledByPlatform(phone.getContext()));
Wink Saville426fc662011-09-25 14:39:02 -07001422 }
1423
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001424 OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
1425 public void onClick(View v) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001426 //FIXME: Replace with a TelephonyManager call
Wink Savillec3886682009-04-02 11:00:56 -07001427 phone.disableDnsCheck(!phone.isDnsCheckDisabled());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001428 updateDnsCheckState();
1429 }
1430 };
johnwang342101a2009-09-23 16:22:34 -07001431
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001432 OnClickListener mOemInfoButtonHandler = new OnClickListener() {
1433 public void onClick(View v) {
1434 Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO");
1435 try {
1436 startActivity(intent);
1437 } catch (android.content.ActivityNotFoundException ex) {
Wink Savillebf471282013-04-05 15:04:05 -07001438 log("OEM-specific Info/Settings Activity Not Found : " + ex);
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001439 // If the activity does not exist, there are no OEM
1440 // settings, and so we can just do nothing...
1441 }
1442 }
1443 };
1444
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001445 OnClickListener mPingButtonHandler = new OnClickListener() {
1446 public void onClick(View v) {
1447 updatePingState();
1448 }
1449 };
1450
1451 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
1452 public void onClick(View v) {
1453 updateSmscButton.setEnabled(false);
jsh21dd4072009-05-12 11:26:55 -07001454 phone.setSmscAddress(smsc.getText().toString(),
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001455 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
1456 }
1457 };
1458
1459 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
1460 public void onClick(View v) {
1461 refreshSmsc();
1462 }
1463 };
1464
Youhan Wangfd781e92016-12-16 15:53:16 -08001465 OnClickListener mCarrierProvisioningButtonHandler = new OnClickListener() {
1466 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001467 final Intent intent = new Intent("com.android.settings.CARRIER_PROVISIONING");
1468 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1469 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001470 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001471 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001472 }
1473 };
1474
1475 OnClickListener mTriggerCarrierProvisioningButtonHandler = new OnClickListener() {
1476 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001477 final Intent intent = new Intent("com.android.settings.TRIGGER_CARRIER_PROVISIONING");
1478 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1479 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001480 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001481 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001482 }
1483 };
1484
Nathan Haroldcea413a2015-11-23 15:48:10 -08001485 AdapterView.OnItemSelectedListener mPreferredNetworkHandler =
1486 new AdapterView.OnItemSelectedListener() {
1487
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001488 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001489 if (mPreferredNetworkTypeResult != pos && pos >= 0
1490 && pos <= mPreferredNetworkLabels.length - 2) {
1491 mPreferredNetworkTypeResult = pos;
1492 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
1493 phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001494 }
1495 }
1496
1497 public void onNothingSelected(AdapterView parent) {
1498 }
1499 };
1500
Nathan Harold2b77d742016-03-19 13:22:10 -07001501 AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler =
1502 new AdapterView.OnItemSelectedListener() {
Wink Savillebf471282013-04-05 15:04:05 -07001503
Nathan Harold2b77d742016-03-19 13:22:10 -07001504 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1505 mCellInfoRefreshRateIndex = pos;
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -07001506 mTelephonyManager.setCellInfoListRate(mCellInfoRefreshRates[pos]);
Nathan Harold2b77d742016-03-19 13:22:10 -07001507 updateAllCellInfo();
1508 }
1509
1510 public void onNothingSelected(AdapterView parent) {
1511 }
1512 };
1513
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001514}