blob: 776e3b25bc6dc22c69c398e7487e44b03fb79f09 [file] [log] [blame]
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settings;
18
19import android.app.Activity;
Nathan Harolde272c202016-10-27 13:45:00 -070020import android.app.AlertDialog;
21import android.app.Dialog;
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -080022import android.app.QueuedWork;
Youhan Wangfd781e92016-12-16 15:53:16 -080023import android.content.ComponentName;
Meng Wang586741c2017-04-26 15:02:51 -070024import android.content.Context;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080025import android.content.Intent;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +080026import android.content.pm.PackageManager;
27import android.content.pm.ResolveInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080028import android.content.res.Resources;
Nathan Haroldcea413a2015-11-23 15:48:10 -080029import android.graphics.Typeface;
Jeff Sharkey93029862011-05-27 18:26:15 -070030import android.net.TrafficStats;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080031import android.net.Uri;
32import android.os.AsyncResult;
33import android.os.Bundle;
34import android.os.Handler;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080035import android.os.Message;
Meng Wang586741c2017-04-26 15:02:51 -070036import android.telephony.CarrierConfigManager;
Wink Saville79bff2a2012-06-01 14:37:21 -070037import android.telephony.CellInfo;
Nathan Haroldcea413a2015-11-23 15:48:10 -080038import android.telephony.CellInfoCdma;
39import android.telephony.CellInfoGsm;
40import android.telephony.CellInfoLte;
41import android.telephony.CellInfoWcdma;
42import android.telephony.CellIdentityCdma;
43import android.telephony.CellIdentityGsm;
44import android.telephony.CellIdentityLte;
45import android.telephony.CellIdentityWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080046import android.telephony.CellLocation;
Nathan Haroldcea413a2015-11-23 15:48:10 -080047import android.telephony.CellSignalStrengthCdma;
48import android.telephony.CellSignalStrengthGsm;
49import android.telephony.CellSignalStrengthLte;
50import android.telephony.CellSignalStrengthWcdma;
Wink Saville4f0d8812014-04-15 22:05:24 -070051import android.telephony.DataConnectionRealTimeInfo;
Jason Monk39b46742015-09-10 15:52:51 -040052import android.telephony.NeighboringCellInfo;
Nathan Harold2b77d742016-03-19 13:22:10 -070053import android.telephony.PreciseCallState;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080054import android.telephony.PhoneStateListener;
55import android.telephony.ServiceState;
Nathan Harold2b77d742016-03-19 13:22:10 -070056import android.telephony.SignalStrength;
Nathan Haroldcea413a2015-11-23 15:48:10 -080057import android.telephony.SubscriptionManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080058import android.telephony.TelephonyManager;
jsh534f5ae2009-09-24 09:19:22 -070059import android.telephony.cdma.CdmaCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080060import android.telephony.gsm.GsmCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080061import android.util.Log;
62import android.view.Menu;
63import android.view.MenuItem;
64import android.view.View;
65import android.view.View.OnClickListener;
66import android.widget.AdapterView;
67import android.widget.ArrayAdapter;
68import android.widget.Button;
Nathan Harold2b77d742016-03-19 13:22:10 -070069import android.widget.CompoundButton;
70import android.widget.CompoundButton.OnCheckedChangeListener;
Jason Monk39b46742015-09-10 15:52:51 -040071import android.widget.EditText;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080072import android.widget.Spinner;
Nathan Harold2b77d742016-03-19 13:22:10 -070073import android.widget.Switch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080074import android.widget.TextView;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080075
Jason Monk39b46742015-09-10 15:52:51 -040076import com.android.ims.ImsConfig;
77import com.android.ims.ImsException;
78import com.android.ims.ImsManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080079import com.android.internal.telephony.Phone;
Wink Saville55434042012-06-14 12:33:43 -070080import com.android.internal.telephony.PhoneConstants;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080081import com.android.internal.telephony.PhoneFactory;
Nathan Haroldcea413a2015-11-23 15:48:10 -080082import com.android.internal.telephony.RILConstants;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080083import com.android.internal.telephony.TelephonyProperties;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080084
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080085import java.io.IOException;
Jason Monk39b46742015-09-10 15:52:51 -040086import java.net.HttpURLConnection;
87import java.net.URL;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080088import java.net.UnknownHostException;
89import java.util.ArrayList;
90import java.util.List;
91
92public class RadioInfo extends Activity {
Nathan Harold2b77d742016-03-19 13:22:10 -070093 private static final String TAG = "RadioInfo";
johnwang342101a2009-09-23 16:22:34 -070094
Nathan Harold2b77d742016-03-19 13:22:10 -070095 private static final String[] mPreferredNetworkLabels = {
96 "WCDMA preferred",
97 "GSM only",
98 "WCDMA only",
99 "GSM auto (PRL)",
100 "CDMA auto (PRL)",
101 "CDMA only",
102 "EvDo only",
103 "Global auto (PRL)",
104 "LTE/CDMA auto (PRL)",
105 "LTE/UMTS auto (PRL)",
106 "LTE/CDMA/UMTS auto (PRL)",
107 "LTE only",
108 "LTE/WCDMA",
109 "TD-SCDMA only",
110 "TD-SCDMA/WCDMA",
111 "LTE/TD-SCDMA",
112 "TD-SCDMA/GSM",
113 "TD-SCDMA/UMTS",
114 "LTE/TD-SCDMA/WCDMA",
115 "LTE/TD-SCDMA/UMTS",
116 "TD-SCDMA/CDMA/UMTS",
117 "Global/TD-SCDMA",
118 "Unknown"
119 };
120
121
122 private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE;
123 private static final int CELL_INFO_LIST_RATE_MAX = 0;
124
Nathan Harold12e1f552016-06-17 13:55:38 -0700125
126 private static final int IMS_VOLTE_PROVISIONED_CONFIG_ID =
127 ImsConfig.ConfigConstants.VLT_SETTING_ENABLED;
128
129 private static final int IMS_VT_PROVISIONED_CONFIG_ID =
130 ImsConfig.ConfigConstants.LVC_SETTING_ENABLED;
131
132 private static final int IMS_WFC_PROVISIONED_CONFIG_ID =
133 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED;
134
Meng Wang586741c2017-04-26 15:02:51 -0700135 private static final int EAB_PROVISIONED_CONFIG_ID =
136 ImsConfig.ConfigConstants.EAB_SETTING_ENABLED;
137
Nathan Harold2b77d742016-03-19 13:22:10 -0700138 //Values in must match mCellInfoRefreshRates
139 private static final String[] mCellInfoRefreshRateLabels = {
140 "Disabled",
141 "Immediate",
142 "Min 5s",
143 "Min 10s",
144 "Min 60s"
145 };
146
147 //Values in seconds, must match mCellInfoRefreshRateLabels
148 private static final int mCellInfoRefreshRates[] = {
149 CELL_INFO_LIST_RATE_DISABLED,
150 CELL_INFO_LIST_RATE_MAX,
151 5000,
152 10000,
153 60000
154 };
155
156 private void log(String s) {
157 Log.d(TAG, s);
158 }
159
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800160 private static final int EVENT_CFI_CHANGED = 302;
161
162 private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000;
163 private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800164 private static final int EVENT_QUERY_SMSC_DONE = 1005;
165 private static final int EVENT_UPDATE_SMSC_DONE = 1006;
166
167 private static final int MENU_ITEM_SELECT_BAND = 0;
168 private static final int MENU_ITEM_VIEW_ADN = 1;
169 private static final int MENU_ITEM_VIEW_FDN = 2;
170 private static final int MENU_ITEM_VIEW_SDN = 3;
Nathan Harolde272c202016-10-27 13:45:00 -0700171 private static final int MENU_ITEM_GET_IMS_STATUS = 4;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800172 private static final int MENU_ITEM_TOGGLE_DATA = 5;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800173
Wink Savillec3886682009-04-02 11:00:56 -0700174 private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800175 private TextView number;
Meng Wang9053f172017-06-23 16:02:14 -0700176 private TextView mSubscriberId;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800177 private TextView callState;
178 private TextView operatorName;
179 private TextView roamingState;
180 private TextView gsmState;
181 private TextView gprsState;
Nathan Harold2b77d742016-03-19 13:22:10 -0700182 private TextView voiceNetwork;
183 private TextView dataNetwork;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800184 private TextView dBm;
185 private TextView mMwi;
186 private TextView mCfi;
187 private TextView mLocation;
188 private TextView mNeighboringCids;
Wink Saville79bff2a2012-06-01 14:37:21 -0700189 private TextView mCellInfo;
Wink Saville4f0d8812014-04-15 22:05:24 -0700190 private TextView mDcRtInfoTv;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800191 private TextView sent;
192 private TextView received;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800193 private TextView mPingHostnameV4;
194 private TextView mPingHostnameV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800195 private TextView mHttpClientTest;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800196 private TextView dnsCheckState;
197 private EditText smsc;
Nathan Harold2b77d742016-03-19 13:22:10 -0700198 private Switch radioPowerOnSwitch;
199 private Button cellInfoRefreshRateButton;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800200 private Button dnsCheckToggleButton;
201 private Button pingTestButton;
202 private Button updateSmscButton;
203 private Button refreshSmscButton;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800204 private Button oemInfoButton;
Youhan Wangfd781e92016-12-16 15:53:16 -0800205 private Button carrierProvisioningButton;
206 private Button triggercarrierProvisioningButton;
Nathan Harold12e1f552016-06-17 13:55:38 -0700207 private Switch imsVolteProvisionedSwitch;
208 private Switch imsVtProvisionedSwitch;
209 private Switch imsWfcProvisionedSwitch;
Meng Wang586741c2017-04-26 15:02:51 -0700210 private Switch eabProvisionedSwitch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800211 private Spinner preferredNetworkType;
Nathan Harold2b77d742016-03-19 13:22:10 -0700212 private Spinner cellInfoRefreshRateSpinner;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800213
214 private TelephonyManager mTelephonyManager;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800215 private ImsManager mImsManager = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800216 private Phone phone = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800217
Nathan Haroldcea413a2015-11-23 15:48:10 -0800218 private String mPingHostnameResultV4;
219 private String mPingHostnameResultV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800220 private String mHttpClientTestResult;
221 private boolean mMwiValue = false;
222 private boolean mCfiValue = false;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800223
224 private List<CellInfo> mCellInfoResult = null;
225 private CellLocation mCellLocationResult = null;
226 private List<NeighboringCellInfo> mNeighboringCellResult = null;
227
228 private int mPreferredNetworkTypeResult;
Nathan Harold2b77d742016-03-19 13:22:10 -0700229 private int mCellInfoRefreshRateIndex;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800230
Nathan Harold2b77d742016-03-19 13:22:10 -0700231 private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800232 @Override
233 public void onDataConnectionStateChanged(int state) {
234 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800235 updateNetworkType();
236 }
237
238 @Override
239 public void onDataActivity(int direction) {
240 updateDataStats2();
241 }
242
243 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700244 public void onCallStateChanged(int state, String incomingNumber) {
245 updateNetworkType();
246 updatePhoneState(state);
247 }
248
249 @Override
250 public void onPreciseCallStateChanged(PreciseCallState preciseState) {
251 updateNetworkType();
252 }
253
254 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800255 public void onCellLocationChanged(CellLocation location) {
256 updateLocation(location);
257 }
258
259 @Override
260 public void onMessageWaitingIndicatorChanged(boolean mwi) {
261 mMwiValue = mwi;
262 updateMessageWaiting();
263 }
264
265 @Override
266 public void onCallForwardingIndicatorChanged(boolean cfi) {
267 mCfiValue = cfi;
268 updateCallRedirect();
269 }
Wink Saville79bff2a2012-06-01 14:37:21 -0700270
271 @Override
272 public void onCellInfoChanged(List<CellInfo> arrayCi) {
Wink Savillebf471282013-04-05 15:04:05 -0700273 log("onCellInfoChanged: arrayCi=" + arrayCi);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800274 mCellInfoResult = arrayCi;
275 updateCellInfo(mCellInfoResult);
Wink Saville79bff2a2012-06-01 14:37:21 -0700276 }
Wink Saville4f0d8812014-04-15 22:05:24 -0700277
278 @Override
279 public void onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo) {
280 log("onDataConnectionRealTimeInfoChanged: dcRtInfo=" + dcRtInfo);
281 updateDcRtInfoTv(dcRtInfo);
282 }
Nathan Harold2b77d742016-03-19 13:22:10 -0700283
284 @Override
285 public void onSignalStrengthsChanged(SignalStrength signalStrength) {
286 log("onSignalStrengthChanged: SignalStrength=" +signalStrength);
287 updateSignalStrength(signalStrength);
288 }
289
290 @Override
291 public void onServiceStateChanged(ServiceState serviceState) {
292 log("onServiceStateChanged: ServiceState=" + serviceState);
293 updateServiceState(serviceState);
294 updateRadioPowerState();
295 updateNetworkType();
Nathan Harold12e1f552016-06-17 13:55:38 -0700296 updateImsProvisionedState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700297 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800298 };
299
Nathan Haroldcea413a2015-11-23 15:48:10 -0800300 private void updatePreferredNetworkType(int type) {
301 if (type >= mPreferredNetworkLabels.length || type < 0) {
302 log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
303 "type=" + type);
304 type = mPreferredNetworkLabels.length - 1; //set to Unknown
305 }
306 mPreferredNetworkTypeResult = type;
307
308 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
309 }
310
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800311 private Handler mHandler = new Handler() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800312 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800313 public void handleMessage(Message msg) {
314 AsyncResult ar;
315 switch (msg.what) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800316 case EVENT_QUERY_PREFERRED_TYPE_DONE:
317 ar= (AsyncResult) msg.obj;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800318 if (ar.exception == null && ar.result != null) {
319 updatePreferredNetworkType(((int[])ar.result)[0]);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800320 } else {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800321 //In case of an exception, we will set this to unknown
322 updatePreferredNetworkType(mPreferredNetworkLabels.length-1);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800323 }
324 break;
325 case EVENT_SET_PREFERRED_TYPE_DONE:
326 ar= (AsyncResult) msg.obj;
327 if (ar.exception != null) {
Nathan Harolded38afa2016-04-13 00:29:30 -0700328 log("Set preferred network type failed.");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800329 }
330 break;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800331 case EVENT_QUERY_SMSC_DONE:
332 ar= (AsyncResult) msg.obj;
333 if (ar.exception != null) {
334 smsc.setText("refresh error");
335 } else {
jsh21dd4072009-05-12 11:26:55 -0700336 smsc.setText((String)ar.result);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800337 }
338 break;
339 case EVENT_UPDATE_SMSC_DONE:
340 updateSmscButton.setEnabled(true);
341 ar= (AsyncResult) msg.obj;
342 if (ar.exception != null) {
343 smsc.setText("update error");
344 }
345 break;
346 default:
Nathan Haroldcea413a2015-11-23 15:48:10 -0800347 super.handleMessage(msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800348 break;
349
350 }
351 }
352 };
353
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800354 @Override
355 public void onCreate(Bundle icicle) {
356 super.onCreate(icicle);
fionaxub54cb2d2016-09-22 15:01:05 -0700357 if (!android.os.Process.myUserHandle().isSystem()) {
358 Log.e(TAG, "Not run from system user, don't do anything.");
359 finish();
360 return;
361 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800362
363 setContentView(R.layout.radio_info);
364
Nathan Haroldcea413a2015-11-23 15:48:10 -0800365 log("Started onCreate");
366
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800367 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
368 phone = PhoneFactory.getDefaultPhone();
369
Nathan Haroldcea413a2015-11-23 15:48:10 -0800370 //TODO: Need to update this if the default phoneId changes?
371 // Better to have an instance per phone?
372 mImsManager = ImsManager.getInstance(getApplicationContext(),
373 SubscriptionManager.getDefaultVoicePhoneId());
374
Meng Wang9053f172017-06-23 16:02:14 -0700375 mDeviceId = (TextView) findViewById(R.id.imei);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800376 number = (TextView) findViewById(R.id.number);
Meng Wang9053f172017-06-23 16:02:14 -0700377 mSubscriberId = (TextView) findViewById(R.id.imsi);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800378 callState = (TextView) findViewById(R.id.call);
379 operatorName = (TextView) findViewById(R.id.operator);
380 roamingState = (TextView) findViewById(R.id.roaming);
381 gsmState = (TextView) findViewById(R.id.gsm);
382 gprsState = (TextView) findViewById(R.id.gprs);
Nathan Harold2b77d742016-03-19 13:22:10 -0700383 voiceNetwork = (TextView) findViewById(R.id.voice_network);
384 dataNetwork = (TextView) findViewById(R.id.data_network);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800385 dBm = (TextView) findViewById(R.id.dbm);
386 mMwi = (TextView) findViewById(R.id.mwi);
387 mCfi = (TextView) findViewById(R.id.cfi);
388 mLocation = (TextView) findViewById(R.id.location);
389 mNeighboringCids = (TextView) findViewById(R.id.neighboring);
Wink Saville79bff2a2012-06-01 14:37:21 -0700390 mCellInfo = (TextView) findViewById(R.id.cellinfo);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800391 mCellInfo.setTypeface(Typeface.MONOSPACE);
Wink Saville4f0d8812014-04-15 22:05:24 -0700392 mDcRtInfoTv = (TextView) findViewById(R.id.dcrtinfo);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800393
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800394 sent = (TextView) findViewById(R.id.sent);
395 received = (TextView) findViewById(R.id.received);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800396 smsc = (EditText) findViewById(R.id.smsc);
397 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800398 mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4);
399 mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800400 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
401
402 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
403 ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
404 android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
johnwang342101a2009-09-23 16:22:34 -0700405 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800406 preferredNetworkType.setAdapter(adapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800407
Nathan Harold2b77d742016-03-19 13:22:10 -0700408 cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select);
409 ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this,
410 android.R.layout.simple_spinner_item, mCellInfoRefreshRateLabels);
411 cellInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
412 cellInfoRefreshRateSpinner.setAdapter(cellInfoAdapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800413
Nathan Harold12e1f552016-06-17 13:55:38 -0700414 imsVolteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch);
415 imsVtProvisionedSwitch = (Switch) findViewById(R.id.vt_provisioned_switch);
416 imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
Meng Wang69439b52017-05-01 08:31:14 -0700417 eabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch);
Wink Savillebf471282013-04-05 15:04:05 -0700418
Nathan Harold2b77d742016-03-19 13:22:10 -0700419 radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
Wink Saville426fc662011-09-25 14:39:02 -0700420
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800421 pingTestButton = (Button) findViewById(R.id.ping_test);
422 pingTestButton.setOnClickListener(mPingButtonHandler);
423 updateSmscButton = (Button) findViewById(R.id.update_smsc);
424 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
425 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
426 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
427 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
428 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
Youhan Wangfd781e92016-12-16 15:53:16 -0800429 carrierProvisioningButton = (Button) findViewById(R.id.carrier_provisioning);
430 carrierProvisioningButton.setOnClickListener(mCarrierProvisioningButtonHandler);
431 triggercarrierProvisioningButton = (Button) findViewById(R.id.trigger_carrier_provisioning);
432 triggercarrierProvisioningButton.setOnClickListener(
433 mTriggerCarrierProvisioningButtonHandler);
johnwang342101a2009-09-23 16:22:34 -0700434
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800435 oemInfoButton = (Button) findViewById(R.id.oem_info);
436 oemInfoButton.setOnClickListener(mOemInfoButtonHandler);
437 PackageManager pm = getPackageManager();
438 Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO");
439 List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0);
440 if (oemInfoIntentList.size() == 0) {
441 oemInfoButton.setEnabled(false);
442 }
443
Nathan Harolded38afa2016-04-13 00:29:30 -0700444 mCellInfoRefreshRateIndex = 0; //disabled
Nathan Haroldcea413a2015-11-23 15:48:10 -0800445 mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown
446
447 //FIXME: Replace with TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800448 phone.getPreferredNetworkType(
449 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800450
Nathan Haroldcea413a2015-11-23 15:48:10 -0800451 restoreFromBundle(icicle);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800452 }
453
454 @Override
455 protected void onResume() {
456 super.onResume();
457
Nathan Haroldcea413a2015-11-23 15:48:10 -0800458 log("Started onResume");
459
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800460 updateMessageWaiting();
461 updateCallRedirect();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800462 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800463 updateDataStats2();
Nathan Harold2b77d742016-03-19 13:22:10 -0700464 updateRadioPowerState();
Nathan Harold12e1f552016-06-17 13:55:38 -0700465 updateImsProvisionedState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800466 updateProperties();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800467 updateDnsCheckState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700468 updateNetworkType();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800469
Nathan Haroldcea413a2015-11-23 15:48:10 -0800470 updateNeighboringCids(mNeighboringCellResult);
471 updateLocation(mCellLocationResult);
472 updateCellInfo(mCellInfoResult);
473
474 mPingHostnameV4.setText(mPingHostnameResultV4);
475 mPingHostnameV6.setText(mPingHostnameResultV6);
476 mHttpClientTest.setText(mHttpClientTestResult);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800477
Nathan Harold2b77d742016-03-19 13:22:10 -0700478 cellInfoRefreshRateSpinner.setOnItemSelectedListener(mCellInfoRefreshRateHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700479 //set selection after registering listener to force update
480 cellInfoRefreshRateSpinner.setSelection(mCellInfoRefreshRateIndex);
481
482 //set selection before registering to prevent update
483 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
Nathan Harold2b77d742016-03-19 13:22:10 -0700484 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700485
Nathan Harold2b77d742016-03-19 13:22:10 -0700486 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
Nathan Harold12e1f552016-06-17 13:55:38 -0700487 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
488 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
489 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Meng Wang586741c2017-04-26 15:02:51 -0700490 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
Nathan Harold2b77d742016-03-19 13:22:10 -0700491
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800492 mTelephonyManager.listen(mPhoneStateListener,
Nathan Harold2b77d742016-03-19 13:22:10 -0700493 PhoneStateListener.LISTEN_CALL_STATE
494 //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
495 // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
496 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800497 | PhoneStateListener.LISTEN_DATA_ACTIVITY
498 | PhoneStateListener.LISTEN_CELL_LOCATION
499 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
Wink Saville79bff2a2012-06-01 14:37:21 -0700500 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
Wink Saville4f0d8812014-04-15 22:05:24 -0700501 | PhoneStateListener.LISTEN_CELL_INFO
Nathan Harold2b77d742016-03-19 13:22:10 -0700502 | PhoneStateListener.LISTEN_SERVICE_STATE
503 | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
Wink Saville4f0d8812014-04-15 22:05:24 -0700504 | PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO);
Nathan Harolded38afa2016-04-13 00:29:30 -0700505
506 smsc.clearFocus();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800507 }
508
509 @Override
Nathan Haroldcea413a2015-11-23 15:48:10 -0800510 protected void onPause() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800511 super.onPause();
512
Wink Savillebf471282013-04-05 15:04:05 -0700513 log("onPause: unregister phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800514
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800515 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -0700516 mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800517 }
518
Nathan Haroldcea413a2015-11-23 15:48:10 -0800519 private void restoreFromBundle(Bundle b) {
Nathan Harolde272c202016-10-27 13:45:00 -0700520 if(b == null) {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800521 return;
522 }
523
524 mPingHostnameResultV4 = b.getString("mPingHostnameResultV4","");
525 mPingHostnameResultV6 = b.getString("mPingHostnameResultV6","");
526 mHttpClientTestResult = b.getString("mHttpClientTestResult","");
527
528 mPingHostnameV4.setText(mPingHostnameResultV4);
529 mPingHostnameV6.setText(mPingHostnameResultV6);
530 mHttpClientTest.setText(mHttpClientTestResult);
531
Nathan Harold2b77d742016-03-19 13:22:10 -0700532 mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult",
533 mPreferredNetworkLabels.length - 1);
534
535 mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800536 }
537
538 @Override
539 protected void onSaveInstanceState(Bundle outState) {
540 outState.putString("mPingHostnameResultV4", mPingHostnameResultV4);
541 outState.putString("mPingHostnameResultV6", mPingHostnameResultV6);
542 outState.putString("mHttpClientTestResult", mHttpClientTestResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700543
Nathan Haroldcea413a2015-11-23 15:48:10 -0800544 outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700545 outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex);
546
Nathan Haroldcea413a2015-11-23 15:48:10 -0800547 }
548
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800549 @Override
550 public boolean onCreateOptionsMenu(Menu menu) {
Wink Savillec3886682009-04-02 11:00:56 -0700551 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
552 .setOnMenuItemClickListener(mSelectBandCallback)
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800553 .setAlphabeticShortcut('b');
554 menu.add(1, MENU_ITEM_VIEW_ADN, 0,
555 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
556 menu.add(1, MENU_ITEM_VIEW_FDN, 0,
557 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
558 menu.add(1, MENU_ITEM_VIEW_SDN, 0,
559 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
Nathan Harolde272c202016-10-27 13:45:00 -0700560 menu.add(1, MENU_ITEM_GET_IMS_STATUS,
561 0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800562 menu.add(1, MENU_ITEM_TOGGLE_DATA,
Nathan Harold2b77d742016-03-19 13:22:10 -0700563 0, R.string.radio_info_data_connection_disable).setOnMenuItemClickListener(mToggleData);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800564 return true;
565 }
566
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800567 @Override
Wink Savillec3886682009-04-02 11:00:56 -0700568 public boolean onPrepareOptionsMenu(Menu menu) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800569 // Get the TOGGLE DATA menu item in the right state.
570 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
571 int state = mTelephonyManager.getDataState();
572 boolean visible = true;
573
574 switch (state) {
575 case TelephonyManager.DATA_CONNECTED:
576 case TelephonyManager.DATA_SUSPENDED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700577 item.setTitle(R.string.radio_info_data_connection_disable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800578 break;
579 case TelephonyManager.DATA_DISCONNECTED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700580 item.setTitle(R.string.radio_info_data_connection_enable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800581 break;
582 default:
583 visible = false;
584 break;
585 }
586 item.setVisible(visible);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800587 return true;
588 }
589
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800590 private void updateDnsCheckState() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800591 //FIXME: Replace with a TelephonyManager call
Mike Lockwood5304c7e2009-04-05 11:37:45 -0700592 dnsCheckState.setText(phone.isDnsCheckDisabled() ?
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800593 "0.0.0.0 allowed" :"0.0.0.0 not allowed");
594 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700595
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800596 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700597 updateSignalStrength(SignalStrength signalStrength) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800598 Resources r = getResources();
599
Nathan Harold2b77d742016-03-19 13:22:10 -0700600 int signalDbm = signalStrength.getDbm();
Wink Savillee2a14e32009-05-29 14:06:30 -0700601
Nathan Harold2b77d742016-03-19 13:22:10 -0700602 int signalAsu = signalStrength.getAsuLevel();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800603
604 if (-1 == signalAsu) signalAsu = 0;
605
606 dBm.setText(String.valueOf(signalDbm) + " "
607 + r.getString(R.string.radioInfo_display_dbm) + " "
608 + String.valueOf(signalAsu) + " "
609 + r.getString(R.string.radioInfo_display_asu));
610 }
611
612 private final void updateLocation(CellLocation location) {
jsh534f5ae2009-09-24 09:19:22 -0700613 Resources r = getResources();
Wink Savillec3886682009-04-02 11:00:56 -0700614 if (location instanceof GsmCellLocation) {
615 GsmCellLocation loc = (GsmCellLocation)location;
jsh534f5ae2009-09-24 09:19:22 -0700616 int lac = loc.getLac();
617 int cid = loc.getCid();
618 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
619 + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
620 + " "
621 + r.getString(R.string.radioInfo_cid) + " = "
622 + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
623 } else if (location instanceof CdmaCellLocation) {
624 CdmaCellLocation loc = (CdmaCellLocation)location;
625 int bid = loc.getBaseStationId();
626 int sid = loc.getSystemId();
627 int nid = loc.getNetworkId();
628 int lat = loc.getBaseStationLatitude();
629 int lon = loc.getBaseStationLongitude();
630 mLocation.setText("BID = "
631 + ((bid == -1) ? "unknown" : Integer.toHexString(bid))
632 + " "
633 + "SID = "
634 + ((sid == -1) ? "unknown" : Integer.toHexString(sid))
635 + " "
636 + "NID = "
637 + ((nid == -1) ? "unknown" : Integer.toHexString(nid))
638 + "\n"
639 + "LAT = "
640 + ((lat == -1) ? "unknown" : Integer.toHexString(lat))
641 + " "
642 + "LONG = "
643 + ((lon == -1) ? "unknown" : Integer.toHexString(lon)));
644 } else {
645 mLocation.setText("unknown");
Wink Savillec3886682009-04-02 11:00:56 -0700646 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800647
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800648
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800649 }
650
Nathan Haroldcea413a2015-11-23 15:48:10 -0800651 private final void updateNeighboringCids(List<NeighboringCellInfo> cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700652 StringBuilder sb = new StringBuilder();
653
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800654 if (cids != null) {
Nathan Harolde272c202016-10-27 13:45:00 -0700655 if (cids.isEmpty()) {
johnwangf02c65f2009-09-25 17:26:54 -0700656 sb.append("no neighboring cells");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800657 } else {
658 for (NeighboringCellInfo cell : cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700659 sb.append(cell.toString()).append(" ");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800660 }
661 }
662 } else {
johnwangf02c65f2009-09-25 17:26:54 -0700663 sb.append("unknown");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800664 }
johnwangf02c65f2009-09-25 17:26:54 -0700665 mNeighboringCids.setText(sb.toString());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800666 }
667
Nathan Haroldcea413a2015-11-23 15:48:10 -0800668 private final String getCellInfoDisplayString(int i) {
669 return (i != Integer.MAX_VALUE) ? Integer.toString(i) : "";
670 }
671
672 private final String getCellInfoDisplayString(long i) {
673 return (i != Long.MAX_VALUE) ? Long.toString(i) : "";
674 }
675
676 private final String buildCdmaInfoString(CellInfoCdma ci) {
677 CellIdentityCdma cidCdma = ci.getCellIdentity();
678 CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
679
680 return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s",
681 ci.isRegistered() ? "S " : " ",
682 getCellInfoDisplayString(cidCdma.getSystemId()),
683 getCellInfoDisplayString(cidCdma.getNetworkId()),
684 getCellInfoDisplayString(cidCdma.getBasestationId()),
685 getCellInfoDisplayString(ssCdma.getCdmaDbm()),
686 getCellInfoDisplayString(ssCdma.getCdmaEcio()),
687 getCellInfoDisplayString(ssCdma.getEvdoDbm()),
688 getCellInfoDisplayString(ssCdma.getEvdoEcio()),
689 getCellInfoDisplayString(ssCdma.getEvdoSnr()));
690 }
691
692 private final String buildGsmInfoString(CellInfoGsm ci) {
693 CellIdentityGsm cidGsm = ci.getCellIdentity();
694 CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
695
Nathan Harold2b77d742016-03-19 13:22:10 -0700696 return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
Nathan Haroldcea413a2015-11-23 15:48:10 -0800697 ci.isRegistered() ? "S " : " ",
698 getCellInfoDisplayString(cidGsm.getMcc()),
699 getCellInfoDisplayString(cidGsm.getMnc()),
700 getCellInfoDisplayString(cidGsm.getLac()),
701 getCellInfoDisplayString(cidGsm.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700702 getCellInfoDisplayString(cidGsm.getArfcn()),
703 getCellInfoDisplayString(cidGsm.getBsic()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800704 getCellInfoDisplayString(ssGsm.getDbm()));
705 }
706
707 private final String buildLteInfoString(CellInfoLte ci) {
708 CellIdentityLte cidLte = ci.getCellIdentity();
709 CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
710
711 return String.format(
Nathan Harold2b77d742016-03-19 13:22:10 -0700712 "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n",
Nathan Haroldcea413a2015-11-23 15:48:10 -0800713 ci.isRegistered() ? "S " : " ",
714 getCellInfoDisplayString(cidLte.getMcc()),
715 getCellInfoDisplayString(cidLte.getMnc()),
716 getCellInfoDisplayString(cidLte.getTac()),
717 getCellInfoDisplayString(cidLte.getCi()),
718 getCellInfoDisplayString(cidLte.getPci()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700719 getCellInfoDisplayString(cidLte.getEarfcn()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800720 getCellInfoDisplayString(ssLte.getDbm()),
721 getCellInfoDisplayString(ssLte.getRsrq()),
722 getCellInfoDisplayString(ssLte.getTimingAdvance()));
723 }
724
725 private final String buildWcdmaInfoString(CellInfoWcdma ci) {
726 CellIdentityWcdma cidWcdma = ci.getCellIdentity();
727 CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength();
728
Nathan Harold2b77d742016-03-19 13:22:10 -0700729 return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
Nathan Haroldcea413a2015-11-23 15:48:10 -0800730 ci.isRegistered() ? "S " : " ",
731 getCellInfoDisplayString(cidWcdma.getMcc()),
732 getCellInfoDisplayString(cidWcdma.getMnc()),
733 getCellInfoDisplayString(cidWcdma.getLac()),
734 getCellInfoDisplayString(cidWcdma.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700735 getCellInfoDisplayString(cidWcdma.getUarfcn()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800736 getCellInfoDisplayString(cidWcdma.getPsc()),
737 getCellInfoDisplayString(ssWcdma.getDbm()));
738 }
739
740 private final String buildCellInfoString(List<CellInfo> arrayCi) {
741 String value = new String();
742 StringBuilder cdmaCells = new StringBuilder(),
743 gsmCells = new StringBuilder(),
744 lteCells = new StringBuilder(),
745 wcdmaCells = new StringBuilder();
746
747 if (arrayCi != null) {
748 for (CellInfo ci : arrayCi) {
749
750 if (ci instanceof CellInfoLte) {
751 lteCells.append(buildLteInfoString((CellInfoLte) ci));
752 } else if (ci instanceof CellInfoWcdma) {
753 wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
754 } else if (ci instanceof CellInfoGsm) {
755 gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
756 } else if (ci instanceof CellInfoCdma) {
757 cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
Wink Saville79bff2a2012-06-01 14:37:21 -0700758 }
759 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800760 if (lteCells.length() != 0) {
761 value += String.format(
Nathan Harold2b77d742016-03-19 13:22:10 -0700762 "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n",
763 "SRV", "MCC", "MNC", "TAC", "CID", "PCI", "EARFCN", "RSRP", "RSRQ", "TA");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800764 value += lteCells.toString();
765 }
766 if (wcdmaCells.length() != 0) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700767 value += String.format("WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
768 "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800769 value += wcdmaCells.toString();
770 }
771 if (gsmCells.length() != 0) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700772 value += String.format("GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
773 "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800774 value += gsmCells.toString();
775 }
776 if (cdmaCells.length() != 0) {
777 value += String.format(
778 "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n",
779 "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
780 value += cdmaCells.toString();
781 }
782 } else {
783 value ="unknown";
Wink Saville79bff2a2012-06-01 14:37:21 -0700784 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800785
786 return value.toString();
787 }
788
789 private final void updateCellInfo(List<CellInfo> arrayCi) {
790 mCellInfo.setText(buildCellInfoString(arrayCi));
Wink Saville79bff2a2012-06-01 14:37:21 -0700791 }
792
Wink Saville4f0d8812014-04-15 22:05:24 -0700793 private final void updateDcRtInfoTv(DataConnectionRealTimeInfo dcRtInfo) {
794 mDcRtInfoTv.setText(dcRtInfo.toString());
795 }
796
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800797 private final void
798 updateMessageWaiting() {
799 mMwi.setText(String.valueOf(mMwiValue));
800 }
801
802 private final void
803 updateCallRedirect() {
804 mCfi.setText(String.valueOf(mCfiValue));
805 }
806
807
808 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700809 updateServiceState(ServiceState serviceState) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800810 int state = serviceState.getState();
811 Resources r = getResources();
812 String display = r.getString(R.string.radioInfo_unknown);
johnwang342101a2009-09-23 16:22:34 -0700813
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800814 switch (state) {
815 case ServiceState.STATE_IN_SERVICE:
816 display = r.getString(R.string.radioInfo_service_in);
817 break;
818 case ServiceState.STATE_OUT_OF_SERVICE:
819 case ServiceState.STATE_EMERGENCY_ONLY:
820 display = r.getString(R.string.radioInfo_service_emergency);
821 break;
822 case ServiceState.STATE_POWER_OFF:
823 display = r.getString(R.string.radioInfo_service_off);
824 break;
825 }
johnwang342101a2009-09-23 16:22:34 -0700826
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800827 gsmState.setText(display);
johnwang342101a2009-09-23 16:22:34 -0700828
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800829 if (serviceState.getRoaming()) {
830 roamingState.setText(R.string.radioInfo_roaming_in);
831 } else {
832 roamingState.setText(R.string.radioInfo_roaming_not);
833 }
834
835 operatorName.setText(serviceState.getOperatorAlphaLong());
836 }
837
838 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700839 updatePhoneState(int state) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800840 Resources r = getResources();
841 String display = r.getString(R.string.radioInfo_unknown);
842
843 switch (state) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700844 case TelephonyManager.CALL_STATE_IDLE:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800845 display = r.getString(R.string.radioInfo_phone_idle);
846 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700847 case TelephonyManager.CALL_STATE_RINGING:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800848 display = r.getString(R.string.radioInfo_phone_ringing);
849 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700850 case TelephonyManager.CALL_STATE_OFFHOOK:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800851 display = r.getString(R.string.radioInfo_phone_offhook);
852 break;
853 }
854
855 callState.setText(display);
856 }
857
858 private final void
859 updateDataState() {
860 int state = mTelephonyManager.getDataState();
861 Resources r = getResources();
862 String display = r.getString(R.string.radioInfo_unknown);
863
864 switch (state) {
865 case TelephonyManager.DATA_CONNECTED:
866 display = r.getString(R.string.radioInfo_data_connected);
867 break;
868 case TelephonyManager.DATA_CONNECTING:
869 display = r.getString(R.string.radioInfo_data_connecting);
870 break;
871 case TelephonyManager.DATA_DISCONNECTED:
872 display = r.getString(R.string.radioInfo_data_disconnected);
873 break;
874 case TelephonyManager.DATA_SUSPENDED:
875 display = r.getString(R.string.radioInfo_data_suspended);
876 break;
877 }
johnwang342101a2009-09-23 16:22:34 -0700878
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800879 gprsState.setText(display);
880 }
881
882 private final void updateNetworkType() {
Nathan Harolde272c202016-10-27 13:45:00 -0700883 if(phone != null) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700884 ServiceState ss = phone.getServiceState();
885 dataNetwork.setText(ServiceState.rilRadioTechnologyToString(
886 phone.getServiceState().getRilDataRadioTechnology()));
887 voiceNetwork.setText(ServiceState.rilRadioTechnologyToString(
888 phone.getServiceState().getRilVoiceRadioTechnology()));
889 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800890 }
891
892 private final void
893 updateProperties() {
894 String s;
895 Resources r = getResources();
896
897 s = phone.getDeviceId();
johnwang342101a2009-09-23 16:22:34 -0700898 if (s == null) s = r.getString(R.string.radioInfo_unknown);
Wink Savillec3886682009-04-02 11:00:56 -0700899 mDeviceId.setText(s);
johnwang342101a2009-09-23 16:22:34 -0700900
Meng Wang9053f172017-06-23 16:02:14 -0700901 s = phone.getSubscriberId();
902 if (s == null) s = r.getString(R.string.radioInfo_unknown);
903 mSubscriberId.setText(s);
904
Nathan Haroldcea413a2015-11-23 15:48:10 -0800905 //FIXME: Replace with a TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800906 s = phone.getLine1Number();
johnwang342101a2009-09-23 16:22:34 -0700907 if (s == null) s = r.getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800908 number.setText(s);
909 }
910
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800911 private final void updateDataStats2() {
912 Resources r = getResources();
913
Jeff Sharkey93029862011-05-27 18:26:15 -0700914 long txPackets = TrafficStats.getMobileTxPackets();
915 long rxPackets = TrafficStats.getMobileRxPackets();
916 long txBytes = TrafficStats.getMobileTxBytes();
917 long rxBytes = TrafficStats.getMobileRxBytes();
johnwang342101a2009-09-23 16:22:34 -0700918
Jeff Sharkey93029862011-05-27 18:26:15 -0700919 String packets = r.getString(R.string.radioInfo_display_packets);
920 String bytes = r.getString(R.string.radioInfo_display_bytes);
johnwang342101a2009-09-23 16:22:34 -0700921
Jeff Sharkey93029862011-05-27 18:26:15 -0700922 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
923 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800924 }
925
926 /**
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800927 * Ping a host name
928 */
929 private final void pingHostname() {
930 try {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800931 try {
932 Process p4 = Runtime.getRuntime().exec("ping -c 1 www.google.com");
933 int status4 = p4.waitFor();
934 if (status4 == 0) {
935 mPingHostnameResultV4 = "Pass";
936 } else {
937 mPingHostnameResultV4 = String.format("Fail(%d)", status4);
938 }
939 } catch (IOException e) {
940 mPingHostnameResultV4 = "Fail: IOException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800941 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800942 try {
943 Process p6 = Runtime.getRuntime().exec("ping6 -c 1 www.google.com");
944 int status6 = p6.waitFor();
945 if (status6 == 0) {
946 mPingHostnameResultV6 = "Pass";
947 } else {
948 mPingHostnameResultV6 = String.format("Fail(%d)", status6);
949 }
950 } catch (IOException e) {
951 mPingHostnameResultV6 = "Fail: IOException";
952 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800953 } catch (InterruptedException e) {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800954 mPingHostnameResultV4 = mPingHostnameResultV6 = "Fail: InterruptedException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800955 }
956 }
957
958 /**
959 * This function checks for basic functionality of HTTP Client.
960 */
961 private void httpClientTest() {
Narayan Kamathf25627c2014-12-12 13:53:28 +0000962 HttpURLConnection urlConnection = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800963 try {
Narayan Kamathf25627c2014-12-12 13:53:28 +0000964 // TODO: Hardcoded for now, make it UI configurable
Alex Klyubinb0090232015-04-02 11:08:51 -0700965 URL url = new URL("https://www.google.com");
Narayan Kamathf25627c2014-12-12 13:53:28 +0000966 urlConnection = (HttpURLConnection) url.openConnection();
967 if (urlConnection.getResponseCode() == 200) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800968 mHttpClientTestResult = "Pass";
969 } else {
Narayan Kamathf25627c2014-12-12 13:53:28 +0000970 mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800971 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800972 } catch (IOException e) {
973 mHttpClientTestResult = "Fail: IOException";
Narayan Kamathf25627c2014-12-12 13:53:28 +0000974 } finally {
975 if (urlConnection != null) {
976 urlConnection.disconnect();
977 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800978 }
979 }
980
981 private void refreshSmsc() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800982 //FIXME: Replace with a TelephonyManager call
jsh21dd4072009-05-12 11:26:55 -0700983 phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800984 }
985
Nathan Haroldcea413a2015-11-23 15:48:10 -0800986 private final void updateAllCellInfo() {
987
988 mCellInfo.setText("");
989 mNeighboringCids.setText("");
990 mLocation.setText("");
991
992 final Runnable updateAllCellInfoResults = new Runnable() {
993 public void run() {
994 updateNeighboringCids(mNeighboringCellResult);
995 updateLocation(mCellLocationResult);
996 updateCellInfo(mCellInfoResult);
997 }
998 };
999
1000 Thread locThread = new Thread() {
1001 @Override
1002 public void run() {
1003 mCellInfoResult = mTelephonyManager.getAllCellInfo();
1004 mCellLocationResult = mTelephonyManager.getCellLocation();
1005 mNeighboringCellResult = mTelephonyManager.getNeighboringCellInfo();
1006
1007 mHandler.post(updateAllCellInfoResults);
1008 }
1009 };
1010 locThread.start();
1011 }
1012
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001013 private final void updatePingState() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001014 // Set all to unknown since the threads will take a few secs to update.
Nathan Haroldcea413a2015-11-23 15:48:10 -08001015 mPingHostnameResultV4 = getResources().getString(R.string.radioInfo_unknown);
1016 mPingHostnameResultV6 = getResources().getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001017 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
1018
Nathan Haroldcea413a2015-11-23 15:48:10 -08001019 mPingHostnameV4.setText(mPingHostnameResultV4);
1020 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001021 mHttpClientTest.setText(mHttpClientTestResult);
1022
1023 final Runnable updatePingResults = new Runnable() {
1024 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001025 mPingHostnameV4.setText(mPingHostnameResultV4);
1026 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001027 mHttpClientTest.setText(mHttpClientTestResult);
1028 }
1029 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001030
1031 Thread hostname = new Thread() {
1032 @Override
1033 public void run() {
1034 pingHostname();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001035 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001036 }
1037 };
1038 hostname.start();
1039
1040 Thread httpClient = new Thread() {
1041 @Override
1042 public void run() {
1043 httpClientTest();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001044 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001045 }
1046 };
1047 httpClient.start();
1048 }
1049
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001050 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
1051 public boolean onMenuItemClick(MenuItem item) {
1052 Intent intent = new Intent(Intent.ACTION_VIEW);
1053 // XXX We need to specify the component here because if we don't
1054 // the activity manager will try to resolve the type by calling
1055 // the content provider, which causes it to be loaded in a process
1056 // other than the Dialer process, which causes a lot of stuff to
1057 // break.
1058 intent.setClassName("com.android.phone",
1059 "com.android.phone.SimContacts");
1060 startActivity(intent);
1061 return true;
1062 }
1063 };
1064
1065 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
1066 public boolean onMenuItemClick(MenuItem item) {
1067 Intent intent = new Intent(Intent.ACTION_VIEW);
1068 // XXX We need to specify the component here because if we don't
1069 // the activity manager will try to resolve the type by calling
1070 // the content provider, which causes it to be loaded in a process
1071 // other than the Dialer process, which causes a lot of stuff to
1072 // break.
1073 intent.setClassName("com.android.phone",
Andrew Leeda90d682014-10-31 13:12:20 -07001074 "com.android.phone.settings.fdn.FdnList");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001075 startActivity(intent);
1076 return true;
1077 }
1078 };
1079
1080 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
1081 public boolean onMenuItemClick(MenuItem item) {
1082 Intent intent = new Intent(
Wink Savillec3886682009-04-02 11:00:56 -07001083 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001084 // XXX We need to specify the component here because if we don't
1085 // the activity manager will try to resolve the type by calling
1086 // the content provider, which causes it to be loaded in a process
1087 // other than the Dialer process, which causes a lot of stuff to
1088 // break.
1089 intent.setClassName("com.android.phone",
1090 "com.android.phone.ADNList");
1091 startActivity(intent);
1092 return true;
1093 }
1094 };
1095
Nathan Harolde272c202016-10-27 13:45:00 -07001096 private MenuItem.OnMenuItemClickListener mGetImsStatus = new MenuItem.OnMenuItemClickListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001097 public boolean onMenuItemClick(MenuItem item) {
Nathan Harolde272c202016-10-27 13:45:00 -07001098 boolean isImsRegistered = phone.isImsRegistered();
1099 boolean availableVolte = phone.isVolteEnabled();
1100 boolean availableWfc = phone.isWifiCallingEnabled();
1101 boolean availableVt = phone.isVideoEnabled();
1102 boolean availableUt = phone.isUtEnabled();
1103
1104 final String imsRegString = isImsRegistered ?
1105 getString(R.string.radio_info_ims_reg_status_registered) :
1106 getString(R.string.radio_info_ims_reg_status_not_registered);
1107
1108 final String available = getString(R.string.radio_info_ims_feature_status_available);
1109 final String unavailable = getString(
1110 R.string.radio_info_ims_feature_status_unavailable);
1111
1112 String imsStatus = getString(R.string.radio_info_ims_reg_status,
1113 imsRegString,
1114 availableVolte ? available : unavailable,
1115 availableWfc ? available : unavailable,
1116 availableVt ? available : unavailable,
1117 availableUt ? available : unavailable);
1118
1119 AlertDialog imsDialog = new AlertDialog.Builder(RadioInfo.this)
1120 .setMessage(imsStatus)
1121 .setTitle(getString(R.string.radio_info_ims_reg_status_title))
1122 .create();
1123
1124 imsDialog.show();
1125
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001126 return true;
1127 }
1128 };
1129
1130 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
1131 public boolean onMenuItemClick(MenuItem item) {
1132 Intent intent = new Intent();
1133 intent.setClass(RadioInfo.this, BandMode.class);
1134 startActivity(intent);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001135 return true;
1136 }
1137 };
johnwang342101a2009-09-23 16:22:34 -07001138
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001139 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
1140 public boolean onMenuItemClick(MenuItem item) {
1141 int state = mTelephonyManager.getDataState();
1142 switch (state) {
1143 case TelephonyManager.DATA_CONNECTED:
Nathan Haroldcea413a2015-11-23 15:48:10 -08001144 //FIXME: Replace with a TelephonyManager call
Robert Greenwalt0d4c5002014-05-21 20:02:32 -07001145 phone.setDataEnabled(false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001146 break;
1147 case TelephonyManager.DATA_DISCONNECTED:
Nathan Haroldcea413a2015-11-23 15:48:10 -08001148 //FIXME: Replace with a TelephonyManager call
Robert Greenwalt0d4c5002014-05-21 20:02:32 -07001149 phone.setDataEnabled(true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001150 break;
1151 default:
1152 // do nothing
1153 break;
1154 }
1155 return true;
1156 }
1157 };
1158
Nathan Harold2b77d742016-03-19 13:22:10 -07001159 private boolean isRadioOn() {
1160 //FIXME: Replace with a TelephonyManager call
1161 return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
1162 }
1163
1164 private void updateRadioPowerState() {
1165 //delightful hack to prevent on-checked-changed calls from
1166 //actually forcing the radio preference to its transient/current value.
1167 radioPowerOnSwitch.setOnCheckedChangeListener(null);
1168 radioPowerOnSwitch.setChecked(isRadioOn());
1169 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
1170 }
1171
Nathan Harolde272c202016-10-27 13:45:00 -07001172 void setImsVolteProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001173 Log.d(TAG, "setImsVolteProvisioned state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001174 setImsConfigProvisionedState(IMS_VOLTE_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001175 }
1176
Nathan Harolde272c202016-10-27 13:45:00 -07001177 void setImsVtProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001178 Log.d(TAG, "setImsVtProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001179 setImsConfigProvisionedState(IMS_VT_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001180 }
1181
Nathan Harolde272c202016-10-27 13:45:00 -07001182 void setImsWfcProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001183 Log.d(TAG, "setImsWfcProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001184 setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001185 }
1186
Meng Wang586741c2017-04-26 15:02:51 -07001187 void setEabProvisionedState(boolean state) {
1188 Log.d(TAG, "setEabProvisioned() state: " + ((state)? "on":"off"));
1189 setImsConfigProvisionedState(EAB_PROVISIONED_CONFIG_ID, state);
1190 }
1191
Nathan Harolde272c202016-10-27 13:45:00 -07001192 void setImsConfigProvisionedState(int configItem, boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001193 if (phone != null && mImsManager != null) {
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001194 QueuedWork.queue(new Runnable() {
Nathan Harold12e1f552016-06-17 13:55:38 -07001195 public void run() {
1196 try {
1197 mImsManager.getConfigInterface().setProvisionedValue(
1198 configItem,
1199 state? 1 : 0);
1200 } catch (ImsException e) {
1201 Log.e(TAG, "setImsConfigProvisioned() exception:", e);
1202 }
1203 }
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001204 }, false);
Nathan Harold12e1f552016-06-17 13:55:38 -07001205 }
1206 }
1207
Nathan Harold2b77d742016-03-19 13:22:10 -07001208 OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() {
1209 @Override
1210 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1211 log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
1212 phone.setRadioPower(isChecked);
1213 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001214 };
1215
Nathan Harold12e1f552016-06-17 13:55:38 -07001216 private boolean isImsVolteProvisioned() {
Nathan Harold2b77d742016-03-19 13:22:10 -07001217 if (phone != null && mImsManager != null) {
1218 return mImsManager.isVolteEnabledByPlatform(phone.getContext())
1219 && mImsManager.isVolteProvisionedOnDevice(phone.getContext());
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -08001220 }
1221 return false;
1222 }
1223
Nathan Harold12e1f552016-06-17 13:55:38 -07001224 OnCheckedChangeListener mImsVolteCheckedChangeListener = new OnCheckedChangeListener() {
Wink Saville426fc662011-09-25 14:39:02 -07001225 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -07001226 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001227 setImsVolteProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001228 }
Wink Saville426fc662011-09-25 14:39:02 -07001229 };
1230
Nathan Harold12e1f552016-06-17 13:55:38 -07001231 private boolean isImsVtProvisioned() {
1232 if (phone != null && mImsManager != null) {
1233 return mImsManager.isVtEnabledByPlatform(phone.getContext())
1234 && mImsManager.isVtProvisionedOnDevice(phone.getContext());
1235 }
1236 return false;
1237 }
1238
1239 OnCheckedChangeListener mImsVtCheckedChangeListener = new OnCheckedChangeListener() {
1240 @Override
1241 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1242 setImsVtProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001243 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001244 };
1245
1246 private boolean isImsWfcProvisioned() {
1247 if (phone != null && mImsManager != null) {
1248 return mImsManager.isWfcEnabledByPlatform(phone.getContext())
1249 && mImsManager.isWfcProvisionedOnDevice(phone.getContext());
1250 }
1251 return false;
1252 }
1253
1254 OnCheckedChangeListener mImsWfcCheckedChangeListener = new OnCheckedChangeListener() {
1255 @Override
1256 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1257 setImsWfcProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001258 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001259 };
1260
Meng Wang586741c2017-04-26 15:02:51 -07001261 private boolean isEabProvisioned() {
1262 return isFeatureProvisioned(EAB_PROVISIONED_CONFIG_ID, false);
1263 }
1264
1265 OnCheckedChangeListener mEabCheckedChangeListener = new OnCheckedChangeListener() {
1266 @Override
1267 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1268 setEabProvisionedState(isChecked);
1269 }
1270 };
1271
1272 private boolean isFeatureProvisioned(int featureId, boolean defaultValue) {
1273 boolean provisioned = defaultValue;
1274 if (mImsManager != null) {
1275 try {
1276 ImsConfig imsConfig = mImsManager.getConfigInterface();
1277 if (imsConfig != null) {
1278 provisioned =
1279 (imsConfig.getProvisionedValue(featureId)
1280 == ImsConfig.FeatureValueConstants.ON);
1281 }
1282 } catch (ImsException ex) {
1283 Log.e(TAG, "isFeatureProvisioned() exception:", ex);
1284 }
1285 }
1286
1287 log("isFeatureProvisioned() featureId=" + featureId + " provisioned=" + provisioned);
1288 return provisioned;
1289 }
1290
1291 private static boolean isEabEnabledByPlatform(Context context) {
1292 if (context != null) {
1293 CarrierConfigManager configManager = (CarrierConfigManager)
1294 context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
1295 if (configManager != null && configManager.getConfig().getBoolean(
1296 CarrierConfigManager.KEY_USE_RCS_PRESENCE_BOOL)) {
1297 return true;
1298 }
1299 }
1300 return false;
1301 }
1302
Nathan Harold12e1f552016-06-17 13:55:38 -07001303 private void updateImsProvisionedState() {
1304 log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
Nathan Harold2b77d742016-03-19 13:22:10 -07001305 //delightful hack to prevent on-checked-changed calls from
1306 //actually forcing the ims provisioning to its transient/current value.
Nathan Harold12e1f552016-06-17 13:55:38 -07001307 imsVolteProvisionedSwitch.setOnCheckedChangeListener(null);
1308 imsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned());
1309 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001310 imsVolteProvisionedSwitch.setEnabled(
1311 mImsManager.isVolteEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001312
1313 imsVtProvisionedSwitch.setOnCheckedChangeListener(null);
1314 imsVtProvisionedSwitch.setChecked(isImsVtProvisioned());
1315 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001316 imsVtProvisionedSwitch.setEnabled(
1317 mImsManager.isVtEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001318
1319 imsWfcProvisionedSwitch.setOnCheckedChangeListener(null);
1320 imsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned());
1321 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001322 imsWfcProvisionedSwitch.setEnabled(
1323 mImsManager.isWfcEnabledByPlatform(phone.getContext()));
Meng Wang586741c2017-04-26 15:02:51 -07001324
1325 eabProvisionedSwitch.setOnCheckedChangeListener(null);
1326 eabProvisionedSwitch.setChecked(isEabProvisioned());
1327 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
1328 eabProvisionedSwitch.setEnabled(isEabEnabledByPlatform(phone.getContext()));
Wink Saville426fc662011-09-25 14:39:02 -07001329 }
1330
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001331 OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
1332 public void onClick(View v) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001333 //FIXME: Replace with a TelephonyManager call
Wink Savillec3886682009-04-02 11:00:56 -07001334 phone.disableDnsCheck(!phone.isDnsCheckDisabled());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001335 updateDnsCheckState();
1336 }
1337 };
johnwang342101a2009-09-23 16:22:34 -07001338
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001339 OnClickListener mOemInfoButtonHandler = new OnClickListener() {
1340 public void onClick(View v) {
1341 Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO");
1342 try {
1343 startActivity(intent);
1344 } catch (android.content.ActivityNotFoundException ex) {
Wink Savillebf471282013-04-05 15:04:05 -07001345 log("OEM-specific Info/Settings Activity Not Found : " + ex);
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001346 // If the activity does not exist, there are no OEM
1347 // settings, and so we can just do nothing...
1348 }
1349 }
1350 };
1351
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001352 OnClickListener mPingButtonHandler = new OnClickListener() {
1353 public void onClick(View v) {
1354 updatePingState();
1355 }
1356 };
1357
1358 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
1359 public void onClick(View v) {
1360 updateSmscButton.setEnabled(false);
jsh21dd4072009-05-12 11:26:55 -07001361 phone.setSmscAddress(smsc.getText().toString(),
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001362 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
1363 }
1364 };
1365
1366 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
1367 public void onClick(View v) {
1368 refreshSmsc();
1369 }
1370 };
1371
Youhan Wangfd781e92016-12-16 15:53:16 -08001372 OnClickListener mCarrierProvisioningButtonHandler = new OnClickListener() {
1373 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001374 final Intent intent = new Intent("com.android.settings.CARRIER_PROVISIONING");
1375 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1376 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001377 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001378 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001379 }
1380 };
1381
1382 OnClickListener mTriggerCarrierProvisioningButtonHandler = new OnClickListener() {
1383 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001384 final Intent intent = new Intent("com.android.settings.TRIGGER_CARRIER_PROVISIONING");
1385 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1386 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001387 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001388 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001389 }
1390 };
1391
Nathan Haroldcea413a2015-11-23 15:48:10 -08001392 AdapterView.OnItemSelectedListener mPreferredNetworkHandler =
1393 new AdapterView.OnItemSelectedListener() {
1394
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001395 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001396 if (mPreferredNetworkTypeResult != pos && pos >= 0
1397 && pos <= mPreferredNetworkLabels.length - 2) {
1398 mPreferredNetworkTypeResult = pos;
1399 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
1400 phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001401 }
1402 }
1403
1404 public void onNothingSelected(AdapterView parent) {
1405 }
1406 };
1407
Nathan Harold2b77d742016-03-19 13:22:10 -07001408 AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler =
1409 new AdapterView.OnItemSelectedListener() {
Wink Savillebf471282013-04-05 15:04:05 -07001410
Nathan Harold2b77d742016-03-19 13:22:10 -07001411 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1412 mCellInfoRefreshRateIndex = pos;
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -07001413 mTelephonyManager.setCellInfoListRate(mCellInfoRefreshRates[pos]);
Nathan Harold2b77d742016-03-19 13:22:10 -07001414 updateAllCellInfo();
1415 }
1416
1417 public void onNothingSelected(AdapterView parent) {
1418 }
1419 };
1420
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001421}