blob: dde3461a8768e9744f5d5e2a0c2f67bb0f8f6c94 [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;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080024import android.content.Intent;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +080025import android.content.pm.PackageManager;
26import android.content.pm.ResolveInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080027import android.content.res.Resources;
Nathan Haroldcea413a2015-11-23 15:48:10 -080028import android.graphics.Typeface;
Jeff Sharkey93029862011-05-27 18:26:15 -070029import android.net.TrafficStats;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080030import android.net.Uri;
31import android.os.AsyncResult;
32import android.os.Bundle;
33import android.os.Handler;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080034import android.os.Message;
Wink Saville79bff2a2012-06-01 14:37:21 -070035import android.telephony.CellInfo;
Nathan Haroldcea413a2015-11-23 15:48:10 -080036import android.telephony.CellInfoCdma;
37import android.telephony.CellInfoGsm;
38import android.telephony.CellInfoLte;
39import android.telephony.CellInfoWcdma;
40import android.telephony.CellIdentityCdma;
41import android.telephony.CellIdentityGsm;
42import android.telephony.CellIdentityLte;
43import android.telephony.CellIdentityWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080044import android.telephony.CellLocation;
Nathan Haroldcea413a2015-11-23 15:48:10 -080045import android.telephony.CellSignalStrengthCdma;
46import android.telephony.CellSignalStrengthGsm;
47import android.telephony.CellSignalStrengthLte;
48import android.telephony.CellSignalStrengthWcdma;
Wink Saville4f0d8812014-04-15 22:05:24 -070049import android.telephony.DataConnectionRealTimeInfo;
Jason Monk39b46742015-09-10 15:52:51 -040050import android.telephony.NeighboringCellInfo;
Nathan Harold2b77d742016-03-19 13:22:10 -070051import android.telephony.PreciseCallState;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080052import android.telephony.PhoneStateListener;
53import android.telephony.ServiceState;
Nathan Harold2b77d742016-03-19 13:22:10 -070054import android.telephony.SignalStrength;
Nathan Haroldcea413a2015-11-23 15:48:10 -080055import android.telephony.SubscriptionManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080056import android.telephony.TelephonyManager;
jsh534f5ae2009-09-24 09:19:22 -070057import android.telephony.cdma.CdmaCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080058import android.telephony.gsm.GsmCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080059import android.util.Log;
60import android.view.Menu;
61import android.view.MenuItem;
62import android.view.View;
63import android.view.View.OnClickListener;
64import android.widget.AdapterView;
65import android.widget.ArrayAdapter;
66import android.widget.Button;
Nathan Harold2b77d742016-03-19 13:22:10 -070067import android.widget.CompoundButton;
68import android.widget.CompoundButton.OnCheckedChangeListener;
Jason Monk39b46742015-09-10 15:52:51 -040069import android.widget.EditText;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080070import android.widget.Spinner;
Nathan Harold2b77d742016-03-19 13:22:10 -070071import android.widget.Switch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080072import android.widget.TextView;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080073
Jason Monk39b46742015-09-10 15:52:51 -040074import com.android.ims.ImsConfig;
75import com.android.ims.ImsException;
76import com.android.ims.ImsManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080077import com.android.internal.telephony.Phone;
Wink Saville55434042012-06-14 12:33:43 -070078import com.android.internal.telephony.PhoneConstants;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080079import com.android.internal.telephony.PhoneFactory;
Nathan Haroldcea413a2015-11-23 15:48:10 -080080import com.android.internal.telephony.RILConstants;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080081import com.android.internal.telephony.TelephonyProperties;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080082
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080083import java.io.IOException;
Jason Monk39b46742015-09-10 15:52:51 -040084import java.net.HttpURLConnection;
85import java.net.URL;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080086import java.net.UnknownHostException;
87import java.util.ArrayList;
88import java.util.List;
89
90public class RadioInfo extends Activity {
Nathan Harold2b77d742016-03-19 13:22:10 -070091 private static final String TAG = "RadioInfo";
johnwang342101a2009-09-23 16:22:34 -070092
Nathan Harold2b77d742016-03-19 13:22:10 -070093 private static final String[] mPreferredNetworkLabels = {
94 "WCDMA preferred",
95 "GSM only",
96 "WCDMA only",
97 "GSM auto (PRL)",
98 "CDMA auto (PRL)",
99 "CDMA only",
100 "EvDo only",
101 "Global auto (PRL)",
102 "LTE/CDMA auto (PRL)",
103 "LTE/UMTS auto (PRL)",
104 "LTE/CDMA/UMTS auto (PRL)",
105 "LTE only",
106 "LTE/WCDMA",
107 "TD-SCDMA only",
108 "TD-SCDMA/WCDMA",
109 "LTE/TD-SCDMA",
110 "TD-SCDMA/GSM",
111 "TD-SCDMA/UMTS",
112 "LTE/TD-SCDMA/WCDMA",
113 "LTE/TD-SCDMA/UMTS",
114 "TD-SCDMA/CDMA/UMTS",
115 "Global/TD-SCDMA",
116 "Unknown"
117 };
118
119
120 private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE;
121 private static final int CELL_INFO_LIST_RATE_MAX = 0;
122
Nathan Harold12e1f552016-06-17 13:55:38 -0700123
124 private static final int IMS_VOLTE_PROVISIONED_CONFIG_ID =
125 ImsConfig.ConfigConstants.VLT_SETTING_ENABLED;
126
127 private static final int IMS_VT_PROVISIONED_CONFIG_ID =
128 ImsConfig.ConfigConstants.LVC_SETTING_ENABLED;
129
130 private static final int IMS_WFC_PROVISIONED_CONFIG_ID =
131 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED;
132
Nathan Harold2b77d742016-03-19 13:22:10 -0700133 //Values in must match mCellInfoRefreshRates
134 private static final String[] mCellInfoRefreshRateLabels = {
135 "Disabled",
136 "Immediate",
137 "Min 5s",
138 "Min 10s",
139 "Min 60s"
140 };
141
142 //Values in seconds, must match mCellInfoRefreshRateLabels
143 private static final int mCellInfoRefreshRates[] = {
144 CELL_INFO_LIST_RATE_DISABLED,
145 CELL_INFO_LIST_RATE_MAX,
146 5000,
147 10000,
148 60000
149 };
150
151 private void log(String s) {
152 Log.d(TAG, s);
153 }
154
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800155 private static final int EVENT_CFI_CHANGED = 302;
156
157 private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000;
158 private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800159 private static final int EVENT_QUERY_SMSC_DONE = 1005;
160 private static final int EVENT_UPDATE_SMSC_DONE = 1006;
161
162 private static final int MENU_ITEM_SELECT_BAND = 0;
163 private static final int MENU_ITEM_VIEW_ADN = 1;
164 private static final int MENU_ITEM_VIEW_FDN = 2;
165 private static final int MENU_ITEM_VIEW_SDN = 3;
Nathan Harolde272c202016-10-27 13:45:00 -0700166 private static final int MENU_ITEM_GET_IMS_STATUS = 4;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800167 private static final int MENU_ITEM_TOGGLE_DATA = 5;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800168
Wink Savillec3886682009-04-02 11:00:56 -0700169 private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800170 private TextView number;
171 private TextView callState;
172 private TextView operatorName;
173 private TextView roamingState;
174 private TextView gsmState;
175 private TextView gprsState;
Nathan Harold2b77d742016-03-19 13:22:10 -0700176 private TextView voiceNetwork;
177 private TextView dataNetwork;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800178 private TextView dBm;
179 private TextView mMwi;
180 private TextView mCfi;
181 private TextView mLocation;
182 private TextView mNeighboringCids;
Wink Saville79bff2a2012-06-01 14:37:21 -0700183 private TextView mCellInfo;
Wink Saville4f0d8812014-04-15 22:05:24 -0700184 private TextView mDcRtInfoTv;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800185 private TextView sent;
186 private TextView received;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800187 private TextView mPingHostnameV4;
188 private TextView mPingHostnameV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800189 private TextView mHttpClientTest;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800190 private TextView dnsCheckState;
191 private EditText smsc;
Nathan Harold2b77d742016-03-19 13:22:10 -0700192 private Switch radioPowerOnSwitch;
193 private Button cellInfoRefreshRateButton;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800194 private Button dnsCheckToggleButton;
195 private Button pingTestButton;
196 private Button updateSmscButton;
197 private Button refreshSmscButton;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800198 private Button oemInfoButton;
Youhan Wangfd781e92016-12-16 15:53:16 -0800199 private Button carrierProvisioningButton;
200 private Button triggercarrierProvisioningButton;
Nathan Harold12e1f552016-06-17 13:55:38 -0700201 private Switch imsVolteProvisionedSwitch;
202 private Switch imsVtProvisionedSwitch;
203 private Switch imsWfcProvisionedSwitch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800204 private Spinner preferredNetworkType;
Nathan Harold2b77d742016-03-19 13:22:10 -0700205 private Spinner cellInfoRefreshRateSpinner;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800206
207 private TelephonyManager mTelephonyManager;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800208 private ImsManager mImsManager = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800209 private Phone phone = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800210
Nathan Haroldcea413a2015-11-23 15:48:10 -0800211 private String mPingHostnameResultV4;
212 private String mPingHostnameResultV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800213 private String mHttpClientTestResult;
214 private boolean mMwiValue = false;
215 private boolean mCfiValue = false;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800216
217 private List<CellInfo> mCellInfoResult = null;
218 private CellLocation mCellLocationResult = null;
219 private List<NeighboringCellInfo> mNeighboringCellResult = null;
220
221 private int mPreferredNetworkTypeResult;
Nathan Harold2b77d742016-03-19 13:22:10 -0700222 private int mCellInfoRefreshRateIndex;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800223
Nathan Harold2b77d742016-03-19 13:22:10 -0700224 private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800225 @Override
226 public void onDataConnectionStateChanged(int state) {
227 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800228 updateNetworkType();
229 }
230
231 @Override
232 public void onDataActivity(int direction) {
233 updateDataStats2();
234 }
235
236 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700237 public void onCallStateChanged(int state, String incomingNumber) {
238 updateNetworkType();
239 updatePhoneState(state);
240 }
241
242 @Override
243 public void onPreciseCallStateChanged(PreciseCallState preciseState) {
244 updateNetworkType();
245 }
246
247 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800248 public void onCellLocationChanged(CellLocation location) {
249 updateLocation(location);
250 }
251
252 @Override
253 public void onMessageWaitingIndicatorChanged(boolean mwi) {
254 mMwiValue = mwi;
255 updateMessageWaiting();
256 }
257
258 @Override
259 public void onCallForwardingIndicatorChanged(boolean cfi) {
260 mCfiValue = cfi;
261 updateCallRedirect();
262 }
Wink Saville79bff2a2012-06-01 14:37:21 -0700263
264 @Override
265 public void onCellInfoChanged(List<CellInfo> arrayCi) {
Wink Savillebf471282013-04-05 15:04:05 -0700266 log("onCellInfoChanged: arrayCi=" + arrayCi);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800267 mCellInfoResult = arrayCi;
268 updateCellInfo(mCellInfoResult);
Wink Saville79bff2a2012-06-01 14:37:21 -0700269 }
Wink Saville4f0d8812014-04-15 22:05:24 -0700270
271 @Override
272 public void onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo) {
273 log("onDataConnectionRealTimeInfoChanged: dcRtInfo=" + dcRtInfo);
274 updateDcRtInfoTv(dcRtInfo);
275 }
Nathan Harold2b77d742016-03-19 13:22:10 -0700276
277 @Override
278 public void onSignalStrengthsChanged(SignalStrength signalStrength) {
279 log("onSignalStrengthChanged: SignalStrength=" +signalStrength);
280 updateSignalStrength(signalStrength);
281 }
282
283 @Override
284 public void onServiceStateChanged(ServiceState serviceState) {
285 log("onServiceStateChanged: ServiceState=" + serviceState);
286 updateServiceState(serviceState);
287 updateRadioPowerState();
288 updateNetworkType();
Nathan Harold12e1f552016-06-17 13:55:38 -0700289 updateImsProvisionedState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700290 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800291 };
292
Nathan Haroldcea413a2015-11-23 15:48:10 -0800293 private void updatePreferredNetworkType(int type) {
294 if (type >= mPreferredNetworkLabels.length || type < 0) {
295 log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
296 "type=" + type);
297 type = mPreferredNetworkLabels.length - 1; //set to Unknown
298 }
299 mPreferredNetworkTypeResult = type;
300
301 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
302 }
303
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800304 private Handler mHandler = new Handler() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800305 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800306 public void handleMessage(Message msg) {
307 AsyncResult ar;
308 switch (msg.what) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800309 case EVENT_QUERY_PREFERRED_TYPE_DONE:
310 ar= (AsyncResult) msg.obj;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800311 if (ar.exception == null && ar.result != null) {
312 updatePreferredNetworkType(((int[])ar.result)[0]);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800313 } else {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800314 //In case of an exception, we will set this to unknown
315 updatePreferredNetworkType(mPreferredNetworkLabels.length-1);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800316 }
317 break;
318 case EVENT_SET_PREFERRED_TYPE_DONE:
319 ar= (AsyncResult) msg.obj;
320 if (ar.exception != null) {
Nathan Harolded38afa2016-04-13 00:29:30 -0700321 log("Set preferred network type failed.");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800322 }
323 break;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800324 case EVENT_QUERY_SMSC_DONE:
325 ar= (AsyncResult) msg.obj;
326 if (ar.exception != null) {
327 smsc.setText("refresh error");
328 } else {
jsh21dd4072009-05-12 11:26:55 -0700329 smsc.setText((String)ar.result);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800330 }
331 break;
332 case EVENT_UPDATE_SMSC_DONE:
333 updateSmscButton.setEnabled(true);
334 ar= (AsyncResult) msg.obj;
335 if (ar.exception != null) {
336 smsc.setText("update error");
337 }
338 break;
339 default:
Nathan Haroldcea413a2015-11-23 15:48:10 -0800340 super.handleMessage(msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800341 break;
342
343 }
344 }
345 };
346
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800347 @Override
348 public void onCreate(Bundle icicle) {
349 super.onCreate(icicle);
fionaxub54cb2d2016-09-22 15:01:05 -0700350 if (!android.os.Process.myUserHandle().isSystem()) {
351 Log.e(TAG, "Not run from system user, don't do anything.");
352 finish();
353 return;
354 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800355
356 setContentView(R.layout.radio_info);
357
Nathan Haroldcea413a2015-11-23 15:48:10 -0800358 log("Started onCreate");
359
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800360 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
361 phone = PhoneFactory.getDefaultPhone();
362
Nathan Haroldcea413a2015-11-23 15:48:10 -0800363 //TODO: Need to update this if the default phoneId changes?
364 // Better to have an instance per phone?
365 mImsManager = ImsManager.getInstance(getApplicationContext(),
366 SubscriptionManager.getDefaultVoicePhoneId());
367
Wink Savillec3886682009-04-02 11:00:56 -0700368 mDeviceId= (TextView) findViewById(R.id.imei);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800369 number = (TextView) findViewById(R.id.number);
370 callState = (TextView) findViewById(R.id.call);
371 operatorName = (TextView) findViewById(R.id.operator);
372 roamingState = (TextView) findViewById(R.id.roaming);
373 gsmState = (TextView) findViewById(R.id.gsm);
374 gprsState = (TextView) findViewById(R.id.gprs);
Nathan Harold2b77d742016-03-19 13:22:10 -0700375 voiceNetwork = (TextView) findViewById(R.id.voice_network);
376 dataNetwork = (TextView) findViewById(R.id.data_network);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800377 dBm = (TextView) findViewById(R.id.dbm);
378 mMwi = (TextView) findViewById(R.id.mwi);
379 mCfi = (TextView) findViewById(R.id.cfi);
380 mLocation = (TextView) findViewById(R.id.location);
381 mNeighboringCids = (TextView) findViewById(R.id.neighboring);
Wink Saville79bff2a2012-06-01 14:37:21 -0700382 mCellInfo = (TextView) findViewById(R.id.cellinfo);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800383 mCellInfo.setTypeface(Typeface.MONOSPACE);
Wink Saville4f0d8812014-04-15 22:05:24 -0700384 mDcRtInfoTv = (TextView) findViewById(R.id.dcrtinfo);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800385
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800386 sent = (TextView) findViewById(R.id.sent);
387 received = (TextView) findViewById(R.id.received);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800388 smsc = (EditText) findViewById(R.id.smsc);
389 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800390 mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4);
391 mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800392 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
393
394 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
395 ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
396 android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
johnwang342101a2009-09-23 16:22:34 -0700397 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800398 preferredNetworkType.setAdapter(adapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800399
Nathan Harold2b77d742016-03-19 13:22:10 -0700400 cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select);
401 ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this,
402 android.R.layout.simple_spinner_item, mCellInfoRefreshRateLabels);
403 cellInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
404 cellInfoRefreshRateSpinner.setAdapter(cellInfoAdapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800405
Nathan Harold12e1f552016-06-17 13:55:38 -0700406 imsVolteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch);
407 imsVtProvisionedSwitch = (Switch) findViewById(R.id.vt_provisioned_switch);
408 imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
Wink Savillebf471282013-04-05 15:04:05 -0700409
Nathan Harold2b77d742016-03-19 13:22:10 -0700410 radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
Wink Saville426fc662011-09-25 14:39:02 -0700411
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800412 pingTestButton = (Button) findViewById(R.id.ping_test);
413 pingTestButton.setOnClickListener(mPingButtonHandler);
414 updateSmscButton = (Button) findViewById(R.id.update_smsc);
415 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
416 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
417 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
418 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
419 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
Youhan Wangfd781e92016-12-16 15:53:16 -0800420 carrierProvisioningButton = (Button) findViewById(R.id.carrier_provisioning);
421 carrierProvisioningButton.setOnClickListener(mCarrierProvisioningButtonHandler);
422 triggercarrierProvisioningButton = (Button) findViewById(R.id.trigger_carrier_provisioning);
423 triggercarrierProvisioningButton.setOnClickListener(
424 mTriggerCarrierProvisioningButtonHandler);
johnwang342101a2009-09-23 16:22:34 -0700425
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800426 oemInfoButton = (Button) findViewById(R.id.oem_info);
427 oemInfoButton.setOnClickListener(mOemInfoButtonHandler);
428 PackageManager pm = getPackageManager();
429 Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO");
430 List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0);
431 if (oemInfoIntentList.size() == 0) {
432 oemInfoButton.setEnabled(false);
433 }
434
Nathan Harolded38afa2016-04-13 00:29:30 -0700435 mCellInfoRefreshRateIndex = 0; //disabled
Nathan Haroldcea413a2015-11-23 15:48:10 -0800436 mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown
437
438 //FIXME: Replace with TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800439 phone.getPreferredNetworkType(
440 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800441
Nathan Haroldcea413a2015-11-23 15:48:10 -0800442 restoreFromBundle(icicle);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800443 }
444
445 @Override
446 protected void onResume() {
447 super.onResume();
448
Nathan Haroldcea413a2015-11-23 15:48:10 -0800449 log("Started onResume");
450
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800451 updateMessageWaiting();
452 updateCallRedirect();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800453 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800454 updateDataStats2();
Nathan Harold2b77d742016-03-19 13:22:10 -0700455 updateRadioPowerState();
Nathan Harold12e1f552016-06-17 13:55:38 -0700456 updateImsProvisionedState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800457 updateProperties();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800458 updateDnsCheckState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700459 updateNetworkType();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800460
Nathan Haroldcea413a2015-11-23 15:48:10 -0800461 updateNeighboringCids(mNeighboringCellResult);
462 updateLocation(mCellLocationResult);
463 updateCellInfo(mCellInfoResult);
464
465 mPingHostnameV4.setText(mPingHostnameResultV4);
466 mPingHostnameV6.setText(mPingHostnameResultV6);
467 mHttpClientTest.setText(mHttpClientTestResult);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800468
Nathan Harold2b77d742016-03-19 13:22:10 -0700469 cellInfoRefreshRateSpinner.setOnItemSelectedListener(mCellInfoRefreshRateHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700470 //set selection after registering listener to force update
471 cellInfoRefreshRateSpinner.setSelection(mCellInfoRefreshRateIndex);
472
473 //set selection before registering to prevent update
474 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
Nathan Harold2b77d742016-03-19 13:22:10 -0700475 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700476
Nathan Harold2b77d742016-03-19 13:22:10 -0700477 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
Nathan Harold12e1f552016-06-17 13:55:38 -0700478 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
479 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
480 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Nathan Harold2b77d742016-03-19 13:22:10 -0700481
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800482 mTelephonyManager.listen(mPhoneStateListener,
Nathan Harold2b77d742016-03-19 13:22:10 -0700483 PhoneStateListener.LISTEN_CALL_STATE
484 //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
485 // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
486 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800487 | PhoneStateListener.LISTEN_DATA_ACTIVITY
488 | PhoneStateListener.LISTEN_CELL_LOCATION
489 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
Wink Saville79bff2a2012-06-01 14:37:21 -0700490 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
Wink Saville4f0d8812014-04-15 22:05:24 -0700491 | PhoneStateListener.LISTEN_CELL_INFO
Nathan Harold2b77d742016-03-19 13:22:10 -0700492 | PhoneStateListener.LISTEN_SERVICE_STATE
493 | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
Wink Saville4f0d8812014-04-15 22:05:24 -0700494 | PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO);
Nathan Harolded38afa2016-04-13 00:29:30 -0700495
496 smsc.clearFocus();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800497 }
498
499 @Override
Nathan Haroldcea413a2015-11-23 15:48:10 -0800500 protected void onPause() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800501 super.onPause();
502
Wink Savillebf471282013-04-05 15:04:05 -0700503 log("onPause: unregister phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800504
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800505 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -0700506 mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800507 }
508
Nathan Haroldcea413a2015-11-23 15:48:10 -0800509 private void restoreFromBundle(Bundle b) {
Nathan Harolde272c202016-10-27 13:45:00 -0700510 if(b == null) {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800511 return;
512 }
513
514 mPingHostnameResultV4 = b.getString("mPingHostnameResultV4","");
515 mPingHostnameResultV6 = b.getString("mPingHostnameResultV6","");
516 mHttpClientTestResult = b.getString("mHttpClientTestResult","");
517
518 mPingHostnameV4.setText(mPingHostnameResultV4);
519 mPingHostnameV6.setText(mPingHostnameResultV6);
520 mHttpClientTest.setText(mHttpClientTestResult);
521
Nathan Harold2b77d742016-03-19 13:22:10 -0700522 mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult",
523 mPreferredNetworkLabels.length - 1);
524
525 mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800526 }
527
528 @Override
529 protected void onSaveInstanceState(Bundle outState) {
530 outState.putString("mPingHostnameResultV4", mPingHostnameResultV4);
531 outState.putString("mPingHostnameResultV6", mPingHostnameResultV6);
532 outState.putString("mHttpClientTestResult", mHttpClientTestResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700533
Nathan Haroldcea413a2015-11-23 15:48:10 -0800534 outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700535 outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex);
536
Nathan Haroldcea413a2015-11-23 15:48:10 -0800537 }
538
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800539 @Override
540 public boolean onCreateOptionsMenu(Menu menu) {
Wink Savillec3886682009-04-02 11:00:56 -0700541 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
542 .setOnMenuItemClickListener(mSelectBandCallback)
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800543 .setAlphabeticShortcut('b');
544 menu.add(1, MENU_ITEM_VIEW_ADN, 0,
545 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
546 menu.add(1, MENU_ITEM_VIEW_FDN, 0,
547 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
548 menu.add(1, MENU_ITEM_VIEW_SDN, 0,
549 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
Nathan Harolde272c202016-10-27 13:45:00 -0700550 menu.add(1, MENU_ITEM_GET_IMS_STATUS,
551 0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800552 menu.add(1, MENU_ITEM_TOGGLE_DATA,
Nathan Harold2b77d742016-03-19 13:22:10 -0700553 0, R.string.radio_info_data_connection_disable).setOnMenuItemClickListener(mToggleData);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800554 return true;
555 }
556
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800557 @Override
Wink Savillec3886682009-04-02 11:00:56 -0700558 public boolean onPrepareOptionsMenu(Menu menu) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800559 // Get the TOGGLE DATA menu item in the right state.
560 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
561 int state = mTelephonyManager.getDataState();
562 boolean visible = true;
563
564 switch (state) {
565 case TelephonyManager.DATA_CONNECTED:
566 case TelephonyManager.DATA_SUSPENDED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700567 item.setTitle(R.string.radio_info_data_connection_disable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800568 break;
569 case TelephonyManager.DATA_DISCONNECTED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700570 item.setTitle(R.string.radio_info_data_connection_enable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800571 break;
572 default:
573 visible = false;
574 break;
575 }
576 item.setVisible(visible);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800577 return true;
578 }
579
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800580 private void updateDnsCheckState() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800581 //FIXME: Replace with a TelephonyManager call
Mike Lockwood5304c7e2009-04-05 11:37:45 -0700582 dnsCheckState.setText(phone.isDnsCheckDisabled() ?
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800583 "0.0.0.0 allowed" :"0.0.0.0 not allowed");
584 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700585
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800586 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700587 updateSignalStrength(SignalStrength signalStrength) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800588 Resources r = getResources();
589
Nathan Harold2b77d742016-03-19 13:22:10 -0700590 int signalDbm = signalStrength.getDbm();
Wink Savillee2a14e32009-05-29 14:06:30 -0700591
Nathan Harold2b77d742016-03-19 13:22:10 -0700592 int signalAsu = signalStrength.getAsuLevel();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800593
594 if (-1 == signalAsu) signalAsu = 0;
595
596 dBm.setText(String.valueOf(signalDbm) + " "
597 + r.getString(R.string.radioInfo_display_dbm) + " "
598 + String.valueOf(signalAsu) + " "
599 + r.getString(R.string.radioInfo_display_asu));
600 }
601
602 private final void updateLocation(CellLocation location) {
jsh534f5ae2009-09-24 09:19:22 -0700603 Resources r = getResources();
Wink Savillec3886682009-04-02 11:00:56 -0700604 if (location instanceof GsmCellLocation) {
605 GsmCellLocation loc = (GsmCellLocation)location;
jsh534f5ae2009-09-24 09:19:22 -0700606 int lac = loc.getLac();
607 int cid = loc.getCid();
608 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
609 + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
610 + " "
611 + r.getString(R.string.radioInfo_cid) + " = "
612 + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
613 } else if (location instanceof CdmaCellLocation) {
614 CdmaCellLocation loc = (CdmaCellLocation)location;
615 int bid = loc.getBaseStationId();
616 int sid = loc.getSystemId();
617 int nid = loc.getNetworkId();
618 int lat = loc.getBaseStationLatitude();
619 int lon = loc.getBaseStationLongitude();
620 mLocation.setText("BID = "
621 + ((bid == -1) ? "unknown" : Integer.toHexString(bid))
622 + " "
623 + "SID = "
624 + ((sid == -1) ? "unknown" : Integer.toHexString(sid))
625 + " "
626 + "NID = "
627 + ((nid == -1) ? "unknown" : Integer.toHexString(nid))
628 + "\n"
629 + "LAT = "
630 + ((lat == -1) ? "unknown" : Integer.toHexString(lat))
631 + " "
632 + "LONG = "
633 + ((lon == -1) ? "unknown" : Integer.toHexString(lon)));
634 } else {
635 mLocation.setText("unknown");
Wink Savillec3886682009-04-02 11:00:56 -0700636 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800637
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800638
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800639 }
640
Nathan Haroldcea413a2015-11-23 15:48:10 -0800641 private final void updateNeighboringCids(List<NeighboringCellInfo> cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700642 StringBuilder sb = new StringBuilder();
643
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800644 if (cids != null) {
Nathan Harolde272c202016-10-27 13:45:00 -0700645 if (cids.isEmpty()) {
johnwangf02c65f2009-09-25 17:26:54 -0700646 sb.append("no neighboring cells");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800647 } else {
648 for (NeighboringCellInfo cell : cids) {
johnwangf02c65f2009-09-25 17:26:54 -0700649 sb.append(cell.toString()).append(" ");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800650 }
651 }
652 } else {
johnwangf02c65f2009-09-25 17:26:54 -0700653 sb.append("unknown");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800654 }
johnwangf02c65f2009-09-25 17:26:54 -0700655 mNeighboringCids.setText(sb.toString());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800656 }
657
Nathan Haroldcea413a2015-11-23 15:48:10 -0800658 private final String getCellInfoDisplayString(int i) {
659 return (i != Integer.MAX_VALUE) ? Integer.toString(i) : "";
660 }
661
662 private final String getCellInfoDisplayString(long i) {
663 return (i != Long.MAX_VALUE) ? Long.toString(i) : "";
664 }
665
666 private final String buildCdmaInfoString(CellInfoCdma ci) {
667 CellIdentityCdma cidCdma = ci.getCellIdentity();
668 CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
669
670 return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s",
671 ci.isRegistered() ? "S " : " ",
672 getCellInfoDisplayString(cidCdma.getSystemId()),
673 getCellInfoDisplayString(cidCdma.getNetworkId()),
674 getCellInfoDisplayString(cidCdma.getBasestationId()),
675 getCellInfoDisplayString(ssCdma.getCdmaDbm()),
676 getCellInfoDisplayString(ssCdma.getCdmaEcio()),
677 getCellInfoDisplayString(ssCdma.getEvdoDbm()),
678 getCellInfoDisplayString(ssCdma.getEvdoEcio()),
679 getCellInfoDisplayString(ssCdma.getEvdoSnr()));
680 }
681
682 private final String buildGsmInfoString(CellInfoGsm ci) {
683 CellIdentityGsm cidGsm = ci.getCellIdentity();
684 CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
685
Nathan Harold2b77d742016-03-19 13:22:10 -0700686 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 -0800687 ci.isRegistered() ? "S " : " ",
688 getCellInfoDisplayString(cidGsm.getMcc()),
689 getCellInfoDisplayString(cidGsm.getMnc()),
690 getCellInfoDisplayString(cidGsm.getLac()),
691 getCellInfoDisplayString(cidGsm.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700692 getCellInfoDisplayString(cidGsm.getArfcn()),
693 getCellInfoDisplayString(cidGsm.getBsic()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800694 getCellInfoDisplayString(ssGsm.getDbm()));
695 }
696
697 private final String buildLteInfoString(CellInfoLte ci) {
698 CellIdentityLte cidLte = ci.getCellIdentity();
699 CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
700
701 return String.format(
Nathan Harold2b77d742016-03-19 13:22:10 -0700702 "%-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 -0800703 ci.isRegistered() ? "S " : " ",
704 getCellInfoDisplayString(cidLte.getMcc()),
705 getCellInfoDisplayString(cidLte.getMnc()),
706 getCellInfoDisplayString(cidLte.getTac()),
707 getCellInfoDisplayString(cidLte.getCi()),
708 getCellInfoDisplayString(cidLte.getPci()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700709 getCellInfoDisplayString(cidLte.getEarfcn()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800710 getCellInfoDisplayString(ssLte.getDbm()),
711 getCellInfoDisplayString(ssLte.getRsrq()),
712 getCellInfoDisplayString(ssLte.getTimingAdvance()));
713 }
714
715 private final String buildWcdmaInfoString(CellInfoWcdma ci) {
716 CellIdentityWcdma cidWcdma = ci.getCellIdentity();
717 CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength();
718
Nathan Harold2b77d742016-03-19 13:22:10 -0700719 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 -0800720 ci.isRegistered() ? "S " : " ",
721 getCellInfoDisplayString(cidWcdma.getMcc()),
722 getCellInfoDisplayString(cidWcdma.getMnc()),
723 getCellInfoDisplayString(cidWcdma.getLac()),
724 getCellInfoDisplayString(cidWcdma.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700725 getCellInfoDisplayString(cidWcdma.getUarfcn()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800726 getCellInfoDisplayString(cidWcdma.getPsc()),
727 getCellInfoDisplayString(ssWcdma.getDbm()));
728 }
729
730 private final String buildCellInfoString(List<CellInfo> arrayCi) {
731 String value = new String();
732 StringBuilder cdmaCells = new StringBuilder(),
733 gsmCells = new StringBuilder(),
734 lteCells = new StringBuilder(),
735 wcdmaCells = new StringBuilder();
736
737 if (arrayCi != null) {
738 for (CellInfo ci : arrayCi) {
739
740 if (ci instanceof CellInfoLte) {
741 lteCells.append(buildLteInfoString((CellInfoLte) ci));
742 } else if (ci instanceof CellInfoWcdma) {
743 wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
744 } else if (ci instanceof CellInfoGsm) {
745 gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
746 } else if (ci instanceof CellInfoCdma) {
747 cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
Wink Saville79bff2a2012-06-01 14:37:21 -0700748 }
749 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800750 if (lteCells.length() != 0) {
751 value += String.format(
Nathan Harold2b77d742016-03-19 13:22:10 -0700752 "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n",
753 "SRV", "MCC", "MNC", "TAC", "CID", "PCI", "EARFCN", "RSRP", "RSRQ", "TA");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800754 value += lteCells.toString();
755 }
756 if (wcdmaCells.length() != 0) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700757 value += String.format("WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
758 "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800759 value += wcdmaCells.toString();
760 }
761 if (gsmCells.length() != 0) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700762 value += String.format("GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
763 "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800764 value += gsmCells.toString();
765 }
766 if (cdmaCells.length() != 0) {
767 value += String.format(
768 "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n",
769 "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
770 value += cdmaCells.toString();
771 }
772 } else {
773 value ="unknown";
Wink Saville79bff2a2012-06-01 14:37:21 -0700774 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800775
776 return value.toString();
777 }
778
779 private final void updateCellInfo(List<CellInfo> arrayCi) {
780 mCellInfo.setText(buildCellInfoString(arrayCi));
Wink Saville79bff2a2012-06-01 14:37:21 -0700781 }
782
Wink Saville4f0d8812014-04-15 22:05:24 -0700783 private final void updateDcRtInfoTv(DataConnectionRealTimeInfo dcRtInfo) {
784 mDcRtInfoTv.setText(dcRtInfo.toString());
785 }
786
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800787 private final void
788 updateMessageWaiting() {
789 mMwi.setText(String.valueOf(mMwiValue));
790 }
791
792 private final void
793 updateCallRedirect() {
794 mCfi.setText(String.valueOf(mCfiValue));
795 }
796
797
798 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700799 updateServiceState(ServiceState serviceState) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800800 int state = serviceState.getState();
801 Resources r = getResources();
802 String display = r.getString(R.string.radioInfo_unknown);
johnwang342101a2009-09-23 16:22:34 -0700803
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800804 switch (state) {
805 case ServiceState.STATE_IN_SERVICE:
806 display = r.getString(R.string.radioInfo_service_in);
807 break;
808 case ServiceState.STATE_OUT_OF_SERVICE:
809 case ServiceState.STATE_EMERGENCY_ONLY:
810 display = r.getString(R.string.radioInfo_service_emergency);
811 break;
812 case ServiceState.STATE_POWER_OFF:
813 display = r.getString(R.string.radioInfo_service_off);
814 break;
815 }
johnwang342101a2009-09-23 16:22:34 -0700816
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800817 gsmState.setText(display);
johnwang342101a2009-09-23 16:22:34 -0700818
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800819 if (serviceState.getRoaming()) {
820 roamingState.setText(R.string.radioInfo_roaming_in);
821 } else {
822 roamingState.setText(R.string.radioInfo_roaming_not);
823 }
824
825 operatorName.setText(serviceState.getOperatorAlphaLong());
826 }
827
828 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700829 updatePhoneState(int state) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800830 Resources r = getResources();
831 String display = r.getString(R.string.radioInfo_unknown);
832
833 switch (state) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700834 case TelephonyManager.CALL_STATE_IDLE:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800835 display = r.getString(R.string.radioInfo_phone_idle);
836 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700837 case TelephonyManager.CALL_STATE_RINGING:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800838 display = r.getString(R.string.radioInfo_phone_ringing);
839 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700840 case TelephonyManager.CALL_STATE_OFFHOOK:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800841 display = r.getString(R.string.radioInfo_phone_offhook);
842 break;
843 }
844
845 callState.setText(display);
846 }
847
848 private final void
849 updateDataState() {
850 int state = mTelephonyManager.getDataState();
851 Resources r = getResources();
852 String display = r.getString(R.string.radioInfo_unknown);
853
854 switch (state) {
855 case TelephonyManager.DATA_CONNECTED:
856 display = r.getString(R.string.radioInfo_data_connected);
857 break;
858 case TelephonyManager.DATA_CONNECTING:
859 display = r.getString(R.string.radioInfo_data_connecting);
860 break;
861 case TelephonyManager.DATA_DISCONNECTED:
862 display = r.getString(R.string.radioInfo_data_disconnected);
863 break;
864 case TelephonyManager.DATA_SUSPENDED:
865 display = r.getString(R.string.radioInfo_data_suspended);
866 break;
867 }
johnwang342101a2009-09-23 16:22:34 -0700868
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800869 gprsState.setText(display);
870 }
871
872 private final void updateNetworkType() {
Nathan Harolde272c202016-10-27 13:45:00 -0700873 if(phone != null) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700874 ServiceState ss = phone.getServiceState();
875 dataNetwork.setText(ServiceState.rilRadioTechnologyToString(
876 phone.getServiceState().getRilDataRadioTechnology()));
877 voiceNetwork.setText(ServiceState.rilRadioTechnologyToString(
878 phone.getServiceState().getRilVoiceRadioTechnology()));
879 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800880 }
881
882 private final void
883 updateProperties() {
884 String s;
885 Resources r = getResources();
886
887 s = phone.getDeviceId();
johnwang342101a2009-09-23 16:22:34 -0700888 if (s == null) s = r.getString(R.string.radioInfo_unknown);
Wink Savillec3886682009-04-02 11:00:56 -0700889 mDeviceId.setText(s);
johnwang342101a2009-09-23 16:22:34 -0700890
Nathan Haroldcea413a2015-11-23 15:48:10 -0800891 //FIXME: Replace with a TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800892 s = phone.getLine1Number();
johnwang342101a2009-09-23 16:22:34 -0700893 if (s == null) s = r.getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800894 number.setText(s);
895 }
896
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800897 private final void updateDataStats2() {
898 Resources r = getResources();
899
Jeff Sharkey93029862011-05-27 18:26:15 -0700900 long txPackets = TrafficStats.getMobileTxPackets();
901 long rxPackets = TrafficStats.getMobileRxPackets();
902 long txBytes = TrafficStats.getMobileTxBytes();
903 long rxBytes = TrafficStats.getMobileRxBytes();
johnwang342101a2009-09-23 16:22:34 -0700904
Jeff Sharkey93029862011-05-27 18:26:15 -0700905 String packets = r.getString(R.string.radioInfo_display_packets);
906 String bytes = r.getString(R.string.radioInfo_display_bytes);
johnwang342101a2009-09-23 16:22:34 -0700907
Jeff Sharkey93029862011-05-27 18:26:15 -0700908 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
909 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800910 }
911
912 /**
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800913 * Ping a host name
914 */
915 private final void pingHostname() {
916 try {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800917 try {
918 Process p4 = Runtime.getRuntime().exec("ping -c 1 www.google.com");
919 int status4 = p4.waitFor();
920 if (status4 == 0) {
921 mPingHostnameResultV4 = "Pass";
922 } else {
923 mPingHostnameResultV4 = String.format("Fail(%d)", status4);
924 }
925 } catch (IOException e) {
926 mPingHostnameResultV4 = "Fail: IOException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800927 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800928 try {
929 Process p6 = Runtime.getRuntime().exec("ping6 -c 1 www.google.com");
930 int status6 = p6.waitFor();
931 if (status6 == 0) {
932 mPingHostnameResultV6 = "Pass";
933 } else {
934 mPingHostnameResultV6 = String.format("Fail(%d)", status6);
935 }
936 } catch (IOException e) {
937 mPingHostnameResultV6 = "Fail: IOException";
938 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800939 } catch (InterruptedException e) {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800940 mPingHostnameResultV4 = mPingHostnameResultV6 = "Fail: InterruptedException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800941 }
942 }
943
944 /**
945 * This function checks for basic functionality of HTTP Client.
946 */
947 private void httpClientTest() {
Narayan Kamathf25627c2014-12-12 13:53:28 +0000948 HttpURLConnection urlConnection = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800949 try {
Narayan Kamathf25627c2014-12-12 13:53:28 +0000950 // TODO: Hardcoded for now, make it UI configurable
Alex Klyubinb0090232015-04-02 11:08:51 -0700951 URL url = new URL("https://www.google.com");
Narayan Kamathf25627c2014-12-12 13:53:28 +0000952 urlConnection = (HttpURLConnection) url.openConnection();
953 if (urlConnection.getResponseCode() == 200) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800954 mHttpClientTestResult = "Pass";
955 } else {
Narayan Kamathf25627c2014-12-12 13:53:28 +0000956 mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800957 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800958 } catch (IOException e) {
959 mHttpClientTestResult = "Fail: IOException";
Narayan Kamathf25627c2014-12-12 13:53:28 +0000960 } finally {
961 if (urlConnection != null) {
962 urlConnection.disconnect();
963 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800964 }
965 }
966
967 private void refreshSmsc() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800968 //FIXME: Replace with a TelephonyManager call
jsh21dd4072009-05-12 11:26:55 -0700969 phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800970 }
971
Nathan Haroldcea413a2015-11-23 15:48:10 -0800972 private final void updateAllCellInfo() {
973
974 mCellInfo.setText("");
975 mNeighboringCids.setText("");
976 mLocation.setText("");
977
978 final Runnable updateAllCellInfoResults = new Runnable() {
979 public void run() {
980 updateNeighboringCids(mNeighboringCellResult);
981 updateLocation(mCellLocationResult);
982 updateCellInfo(mCellInfoResult);
983 }
984 };
985
986 Thread locThread = new Thread() {
987 @Override
988 public void run() {
989 mCellInfoResult = mTelephonyManager.getAllCellInfo();
990 mCellLocationResult = mTelephonyManager.getCellLocation();
991 mNeighboringCellResult = mTelephonyManager.getNeighboringCellInfo();
992
993 mHandler.post(updateAllCellInfoResults);
994 }
995 };
996 locThread.start();
997 }
998
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800999 private final void updatePingState() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001000 // Set all to unknown since the threads will take a few secs to update.
Nathan Haroldcea413a2015-11-23 15:48:10 -08001001 mPingHostnameResultV4 = getResources().getString(R.string.radioInfo_unknown);
1002 mPingHostnameResultV6 = getResources().getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001003 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
1004
Nathan Haroldcea413a2015-11-23 15:48:10 -08001005 mPingHostnameV4.setText(mPingHostnameResultV4);
1006 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001007 mHttpClientTest.setText(mHttpClientTestResult);
1008
1009 final Runnable updatePingResults = new Runnable() {
1010 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001011 mPingHostnameV4.setText(mPingHostnameResultV4);
1012 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001013 mHttpClientTest.setText(mHttpClientTestResult);
1014 }
1015 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001016
1017 Thread hostname = new Thread() {
1018 @Override
1019 public void run() {
1020 pingHostname();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001021 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001022 }
1023 };
1024 hostname.start();
1025
1026 Thread httpClient = new Thread() {
1027 @Override
1028 public void run() {
1029 httpClientTest();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001030 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001031 }
1032 };
1033 httpClient.start();
1034 }
1035
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001036 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
1037 public boolean onMenuItemClick(MenuItem item) {
1038 Intent intent = new Intent(Intent.ACTION_VIEW);
1039 // XXX We need to specify the component here because if we don't
1040 // the activity manager will try to resolve the type by calling
1041 // the content provider, which causes it to be loaded in a process
1042 // other than the Dialer process, which causes a lot of stuff to
1043 // break.
1044 intent.setClassName("com.android.phone",
1045 "com.android.phone.SimContacts");
1046 startActivity(intent);
1047 return true;
1048 }
1049 };
1050
1051 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
1052 public boolean onMenuItemClick(MenuItem item) {
1053 Intent intent = new Intent(Intent.ACTION_VIEW);
1054 // XXX We need to specify the component here because if we don't
1055 // the activity manager will try to resolve the type by calling
1056 // the content provider, which causes it to be loaded in a process
1057 // other than the Dialer process, which causes a lot of stuff to
1058 // break.
1059 intent.setClassName("com.android.phone",
Andrew Leeda90d682014-10-31 13:12:20 -07001060 "com.android.phone.settings.fdn.FdnList");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001061 startActivity(intent);
1062 return true;
1063 }
1064 };
1065
1066 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
1067 public boolean onMenuItemClick(MenuItem item) {
1068 Intent intent = new Intent(
Wink Savillec3886682009-04-02 11:00:56 -07001069 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001070 // XXX We need to specify the component here because if we don't
1071 // the activity manager will try to resolve the type by calling
1072 // the content provider, which causes it to be loaded in a process
1073 // other than the Dialer process, which causes a lot of stuff to
1074 // break.
1075 intent.setClassName("com.android.phone",
1076 "com.android.phone.ADNList");
1077 startActivity(intent);
1078 return true;
1079 }
1080 };
1081
Nathan Harolde272c202016-10-27 13:45:00 -07001082 private MenuItem.OnMenuItemClickListener mGetImsStatus = new MenuItem.OnMenuItemClickListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001083 public boolean onMenuItemClick(MenuItem item) {
Nathan Harolde272c202016-10-27 13:45:00 -07001084 boolean isImsRegistered = phone.isImsRegistered();
1085 boolean availableVolte = phone.isVolteEnabled();
1086 boolean availableWfc = phone.isWifiCallingEnabled();
1087 boolean availableVt = phone.isVideoEnabled();
1088 boolean availableUt = phone.isUtEnabled();
1089
1090 final String imsRegString = isImsRegistered ?
1091 getString(R.string.radio_info_ims_reg_status_registered) :
1092 getString(R.string.radio_info_ims_reg_status_not_registered);
1093
1094 final String available = getString(R.string.radio_info_ims_feature_status_available);
1095 final String unavailable = getString(
1096 R.string.radio_info_ims_feature_status_unavailable);
1097
1098 String imsStatus = getString(R.string.radio_info_ims_reg_status,
1099 imsRegString,
1100 availableVolte ? available : unavailable,
1101 availableWfc ? available : unavailable,
1102 availableVt ? available : unavailable,
1103 availableUt ? available : unavailable);
1104
1105 AlertDialog imsDialog = new AlertDialog.Builder(RadioInfo.this)
1106 .setMessage(imsStatus)
1107 .setTitle(getString(R.string.radio_info_ims_reg_status_title))
1108 .create();
1109
1110 imsDialog.show();
1111
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001112 return true;
1113 }
1114 };
1115
1116 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
1117 public boolean onMenuItemClick(MenuItem item) {
1118 Intent intent = new Intent();
1119 intent.setClass(RadioInfo.this, BandMode.class);
1120 startActivity(intent);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001121 return true;
1122 }
1123 };
johnwang342101a2009-09-23 16:22:34 -07001124
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001125 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
1126 public boolean onMenuItemClick(MenuItem item) {
1127 int state = mTelephonyManager.getDataState();
1128 switch (state) {
1129 case TelephonyManager.DATA_CONNECTED:
Nathan Haroldcea413a2015-11-23 15:48:10 -08001130 //FIXME: Replace with a TelephonyManager call
Robert Greenwalt0d4c5002014-05-21 20:02:32 -07001131 phone.setDataEnabled(false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001132 break;
1133 case TelephonyManager.DATA_DISCONNECTED:
Nathan Haroldcea413a2015-11-23 15:48:10 -08001134 //FIXME: Replace with a TelephonyManager call
Robert Greenwalt0d4c5002014-05-21 20:02:32 -07001135 phone.setDataEnabled(true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001136 break;
1137 default:
1138 // do nothing
1139 break;
1140 }
1141 return true;
1142 }
1143 };
1144
Nathan Harold2b77d742016-03-19 13:22:10 -07001145 private boolean isRadioOn() {
1146 //FIXME: Replace with a TelephonyManager call
1147 return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
1148 }
1149
1150 private void updateRadioPowerState() {
1151 //delightful hack to prevent on-checked-changed calls from
1152 //actually forcing the radio preference to its transient/current value.
1153 radioPowerOnSwitch.setOnCheckedChangeListener(null);
1154 radioPowerOnSwitch.setChecked(isRadioOn());
1155 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
1156 }
1157
Nathan Harolde272c202016-10-27 13:45:00 -07001158 void setImsVolteProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001159 Log.d(TAG, "setImsVolteProvisioned state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001160 setImsConfigProvisionedState(IMS_VOLTE_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001161 }
1162
Nathan Harolde272c202016-10-27 13:45:00 -07001163 void setImsVtProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001164 Log.d(TAG, "setImsVtProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001165 setImsConfigProvisionedState(IMS_VT_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001166 }
1167
Nathan Harolde272c202016-10-27 13:45:00 -07001168 void setImsWfcProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001169 Log.d(TAG, "setImsWfcProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001170 setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001171 }
1172
Nathan Harolde272c202016-10-27 13:45:00 -07001173 void setImsConfigProvisionedState(int configItem, boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001174 if (phone != null && mImsManager != null) {
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001175 QueuedWork.queue(new Runnable() {
Nathan Harold12e1f552016-06-17 13:55:38 -07001176 public void run() {
1177 try {
1178 mImsManager.getConfigInterface().setProvisionedValue(
1179 configItem,
1180 state? 1 : 0);
1181 } catch (ImsException e) {
1182 Log.e(TAG, "setImsConfigProvisioned() exception:", e);
1183 }
1184 }
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001185 }, false);
Nathan Harold12e1f552016-06-17 13:55:38 -07001186 }
1187 }
1188
Nathan Harold2b77d742016-03-19 13:22:10 -07001189 OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() {
1190 @Override
1191 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1192 log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
1193 phone.setRadioPower(isChecked);
1194 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001195 };
1196
Nathan Harold12e1f552016-06-17 13:55:38 -07001197 private boolean isImsVolteProvisioned() {
Nathan Harold2b77d742016-03-19 13:22:10 -07001198 if (phone != null && mImsManager != null) {
1199 return mImsManager.isVolteEnabledByPlatform(phone.getContext())
1200 && mImsManager.isVolteProvisionedOnDevice(phone.getContext());
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -08001201 }
1202 return false;
1203 }
1204
Nathan Harold12e1f552016-06-17 13:55:38 -07001205 OnCheckedChangeListener mImsVolteCheckedChangeListener = new OnCheckedChangeListener() {
Wink Saville426fc662011-09-25 14:39:02 -07001206 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -07001207 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001208 setImsVolteProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001209 }
Wink Saville426fc662011-09-25 14:39:02 -07001210 };
1211
Nathan Harold12e1f552016-06-17 13:55:38 -07001212 private boolean isImsVtProvisioned() {
1213 if (phone != null && mImsManager != null) {
1214 return mImsManager.isVtEnabledByPlatform(phone.getContext())
1215 && mImsManager.isVtProvisionedOnDevice(phone.getContext());
1216 }
1217 return false;
1218 }
1219
1220 OnCheckedChangeListener mImsVtCheckedChangeListener = new OnCheckedChangeListener() {
1221 @Override
1222 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1223 setImsVtProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001224 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001225 };
1226
1227 private boolean isImsWfcProvisioned() {
1228 if (phone != null && mImsManager != null) {
1229 return mImsManager.isWfcEnabledByPlatform(phone.getContext())
1230 && mImsManager.isWfcProvisionedOnDevice(phone.getContext());
1231 }
1232 return false;
1233 }
1234
1235 OnCheckedChangeListener mImsWfcCheckedChangeListener = new OnCheckedChangeListener() {
1236 @Override
1237 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1238 setImsWfcProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001239 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001240 };
1241
1242 private void updateImsProvisionedState() {
1243 log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
Nathan Harold2b77d742016-03-19 13:22:10 -07001244 //delightful hack to prevent on-checked-changed calls from
1245 //actually forcing the ims provisioning to its transient/current value.
Nathan Harold12e1f552016-06-17 13:55:38 -07001246 imsVolteProvisionedSwitch.setOnCheckedChangeListener(null);
1247 imsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned());
1248 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001249 imsVolteProvisionedSwitch.setEnabled(
1250 mImsManager.isVolteEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001251
1252 imsVtProvisionedSwitch.setOnCheckedChangeListener(null);
1253 imsVtProvisionedSwitch.setChecked(isImsVtProvisioned());
1254 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001255 imsVtProvisionedSwitch.setEnabled(
1256 mImsManager.isVtEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001257
1258 imsWfcProvisionedSwitch.setOnCheckedChangeListener(null);
1259 imsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned());
1260 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Nathan Harold6dc15e92016-10-28 11:45:59 -07001261 imsWfcProvisionedSwitch.setEnabled(
1262 mImsManager.isWfcEnabledByPlatform(phone.getContext()));
Wink Saville426fc662011-09-25 14:39:02 -07001263 }
1264
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001265 OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
1266 public void onClick(View v) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001267 //FIXME: Replace with a TelephonyManager call
Wink Savillec3886682009-04-02 11:00:56 -07001268 phone.disableDnsCheck(!phone.isDnsCheckDisabled());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001269 updateDnsCheckState();
1270 }
1271 };
johnwang342101a2009-09-23 16:22:34 -07001272
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001273 OnClickListener mOemInfoButtonHandler = new OnClickListener() {
1274 public void onClick(View v) {
1275 Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO");
1276 try {
1277 startActivity(intent);
1278 } catch (android.content.ActivityNotFoundException ex) {
Wink Savillebf471282013-04-05 15:04:05 -07001279 log("OEM-specific Info/Settings Activity Not Found : " + ex);
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001280 // If the activity does not exist, there are no OEM
1281 // settings, and so we can just do nothing...
1282 }
1283 }
1284 };
1285
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001286 OnClickListener mPingButtonHandler = new OnClickListener() {
1287 public void onClick(View v) {
1288 updatePingState();
1289 }
1290 };
1291
1292 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
1293 public void onClick(View v) {
1294 updateSmscButton.setEnabled(false);
jsh21dd4072009-05-12 11:26:55 -07001295 phone.setSmscAddress(smsc.getText().toString(),
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001296 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
1297 }
1298 };
1299
1300 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
1301 public void onClick(View v) {
1302 refreshSmsc();
1303 }
1304 };
1305
Youhan Wangfd781e92016-12-16 15:53:16 -08001306 OnClickListener mCarrierProvisioningButtonHandler = new OnClickListener() {
1307 public void onClick(View v) {
1308 final Intent intent = new Intent();
1309 final ComponentName serviceComponent = new ComponentName("com.android.omadm.service",
1310 "DMIntentReceiver");
1311 intent.setComponent(serviceComponent);
1312 intent.setAction("com.android.settings.CARRIER_PROVISIONING");
1313 getApplicationContext().sendBroadcast(
1314 intent, android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
1315 }
1316 };
1317
1318 OnClickListener mTriggerCarrierProvisioningButtonHandler = new OnClickListener() {
1319 public void onClick(View v) {
1320 final Intent intent = new Intent();
1321 final ComponentName serviceComponent = new ComponentName("com.android.omadm.service",
1322 "DMIntentReceiver");
1323 intent.setComponent(serviceComponent);
1324 intent.setAction("com.android.settings.TRIGGER_CARRIER_PROVISIONING");
1325 getApplicationContext().sendBroadcast(
1326 intent, android.Manifest.permission.MODIFY_PHONE_STATE);
1327 }
1328 };
1329
Nathan Haroldcea413a2015-11-23 15:48:10 -08001330 AdapterView.OnItemSelectedListener mPreferredNetworkHandler =
1331 new AdapterView.OnItemSelectedListener() {
1332
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001333 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001334 if (mPreferredNetworkTypeResult != pos && pos >= 0
1335 && pos <= mPreferredNetworkLabels.length - 2) {
1336 mPreferredNetworkTypeResult = pos;
1337 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
1338 phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001339 }
1340 }
1341
1342 public void onNothingSelected(AdapterView parent) {
1343 }
1344 };
1345
Nathan Harold2b77d742016-03-19 13:22:10 -07001346 AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler =
1347 new AdapterView.OnItemSelectedListener() {
Wink Savillebf471282013-04-05 15:04:05 -07001348
Nathan Harold2b77d742016-03-19 13:22:10 -07001349 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1350 mCellInfoRefreshRateIndex = pos;
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -07001351 mTelephonyManager.setCellInfoListRate(mCellInfoRefreshRates[pos]);
Nathan Harold2b77d742016-03-19 13:22:10 -07001352 updateAllCellInfo();
1353 }
1354
1355 public void onNothingSelected(AdapterView parent) {
1356 }
1357 };
1358
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001359}