blob: 6f6e6c4cfd925eaab555d36d549cee2ff254db11 [file] [log] [blame]
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settings;
18
Nathan Haroldf10ea322018-04-24 13:31:07 -070019import static android.net.ConnectivityManager.NetworkCallback;
Nathan Harolddaea8be2018-06-05 14:02:35 -070020import static android.provider.Settings.Global.PREFERRED_NETWORK_MODE;
Nathan Haroldf10ea322018-04-24 13:31:07 -070021
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080022import android.app.Activity;
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -080023import android.app.QueuedWork;
Youhan Wangfd781e92016-12-16 15:53:16 -080024import android.content.ComponentName;
Meng Wang586741c2017-04-26 15:02:51 -070025import android.content.Context;
Pengquan Meng7f602c72019-01-28 19:12:18 -080026import android.content.DialogInterface;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080027import android.content.Intent;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +080028import android.content.pm.PackageManager;
29import android.content.pm.ResolveInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080030import android.content.res.Resources;
Nathan Haroldcea413a2015-11-23 15:48:10 -080031import android.graphics.Typeface;
Nathan Haroldf10ea322018-04-24 13:31:07 -070032import android.net.ConnectivityManager;
33import android.net.Network;
34import android.net.NetworkCapabilities;
35import android.net.NetworkRequest;
Jeff Sharkey93029862011-05-27 18:26:15 -070036import android.net.TrafficStats;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080037import android.net.Uri;
38import android.os.AsyncResult;
Sreekanth Badidac888e192018-02-05 17:18:40 +010039import android.os.Build;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080040import android.os.Bundle;
41import android.os.Handler;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080042import android.os.Message;
Nathan Harolddaea8be2018-06-05 14:02:35 -070043import android.provider.Settings;
Pengquan Meng7f602c72019-01-28 19:12:18 -080044import android.provider.Telephony;
Meng Wang586741c2017-04-26 15:02:51 -070045import android.telephony.CarrierConfigManager;
Fan Zhangc7162cd2018-06-18 15:21:41 -070046import android.telephony.CellIdentityCdma;
47import android.telephony.CellIdentityGsm;
48import android.telephony.CellIdentityLte;
49import android.telephony.CellIdentityWcdma;
Wink Saville79bff2a2012-06-01 14:37:21 -070050import android.telephony.CellInfo;
Nathan Haroldcea413a2015-11-23 15:48:10 -080051import android.telephony.CellInfoCdma;
52import android.telephony.CellInfoGsm;
53import android.telephony.CellInfoLte;
54import android.telephony.CellInfoWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080055import android.telephony.CellLocation;
Nathan Haroldcea413a2015-11-23 15:48:10 -080056import android.telephony.CellSignalStrengthCdma;
57import android.telephony.CellSignalStrengthGsm;
58import android.telephony.CellSignalStrengthLte;
59import android.telephony.CellSignalStrengthWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080060import android.telephony.PhoneStateListener;
Nathan Harold433ca442018-04-23 18:20:43 -070061import android.telephony.PhysicalChannelConfig;
Fan Zhangc7162cd2018-06-18 15:21:41 -070062import android.telephony.PreciseCallState;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080063import android.telephony.ServiceState;
Nathan Harold2b77d742016-03-19 13:22:10 -070064import android.telephony.SignalStrength;
Nathan Haroldcea413a2015-11-23 15:48:10 -080065import android.telephony.SubscriptionManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080066import android.telephony.TelephonyManager;
jsh534f5ae2009-09-24 09:19:22 -070067import android.telephony.cdma.CdmaCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080068import android.telephony.gsm.GsmCellLocation;
Nathan Harold6e16fdf2018-04-17 17:01:32 -070069import android.text.TextUtils;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080070import android.util.Log;
71import android.view.Menu;
72import android.view.MenuItem;
73import android.view.View;
74import android.view.View.OnClickListener;
75import android.widget.AdapterView;
76import android.widget.ArrayAdapter;
77import android.widget.Button;
Nathan Harold2b77d742016-03-19 13:22:10 -070078import android.widget.CompoundButton;
79import android.widget.CompoundButton.OnCheckedChangeListener;
Jason Monk39b46742015-09-10 15:52:51 -040080import android.widget.EditText;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080081import android.widget.Spinner;
Nathan Harold2b77d742016-03-19 13:22:10 -070082import android.widget.Switch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080083import android.widget.TextView;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080084
Fan Zhang23f8d592018-08-28 15:11:40 -070085import androidx.appcompat.app.AlertDialog;
Pengquan Meng7f602c72019-01-28 19:12:18 -080086import androidx.appcompat.app.AlertDialog.Builder;
Fan Zhang23f8d592018-08-28 15:11:40 -070087
Jason Monk39b46742015-09-10 15:52:51 -040088import com.android.ims.ImsConfig;
89import com.android.ims.ImsException;
90import com.android.ims.ImsManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080091import com.android.internal.telephony.Phone;
Pengquan Meng7f602c72019-01-28 19:12:18 -080092import com.android.internal.telephony.PhoneConfigurationManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080093import com.android.internal.telephony.PhoneFactory;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080094
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080095import java.io.IOException;
Jason Monk39b46742015-09-10 15:52:51 -040096import java.net.HttpURLConnection;
97import java.net.URL;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080098import java.util.List;
99
Pengquan Meng7f602c72019-01-28 19:12:18 -0800100// TODO(b/123598192) consider to move this activity to telephony package.
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800101public class RadioInfo extends Activity {
Nathan Harold2b77d742016-03-19 13:22:10 -0700102 private static final String TAG = "RadioInfo";
johnwang342101a2009-09-23 16:22:34 -0700103
Nathan Harold2b77d742016-03-19 13:22:10 -0700104 private static final String[] mPreferredNetworkLabels = {
105 "WCDMA preferred",
106 "GSM only",
107 "WCDMA only",
108 "GSM auto (PRL)",
109 "CDMA auto (PRL)",
110 "CDMA only",
111 "EvDo only",
112 "Global auto (PRL)",
113 "LTE/CDMA auto (PRL)",
114 "LTE/UMTS auto (PRL)",
115 "LTE/CDMA/UMTS auto (PRL)",
116 "LTE only",
117 "LTE/WCDMA",
118 "TD-SCDMA only",
119 "TD-SCDMA/WCDMA",
120 "LTE/TD-SCDMA",
121 "TD-SCDMA/GSM",
122 "TD-SCDMA/UMTS",
123 "LTE/TD-SCDMA/WCDMA",
124 "LTE/TD-SCDMA/UMTS",
125 "TD-SCDMA/CDMA/UMTS",
126 "Global/TD-SCDMA",
127 "Unknown"
128 };
129
130
131 private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE;
132 private static final int CELL_INFO_LIST_RATE_MAX = 0;
133
Nathan Harold12e1f552016-06-17 13:55:38 -0700134
135 private static final int IMS_VOLTE_PROVISIONED_CONFIG_ID =
136 ImsConfig.ConfigConstants.VLT_SETTING_ENABLED;
137
138 private static final int IMS_VT_PROVISIONED_CONFIG_ID =
139 ImsConfig.ConfigConstants.LVC_SETTING_ENABLED;
140
141 private static final int IMS_WFC_PROVISIONED_CONFIG_ID =
142 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED;
143
Meng Wang586741c2017-04-26 15:02:51 -0700144 private static final int EAB_PROVISIONED_CONFIG_ID =
145 ImsConfig.ConfigConstants.EAB_SETTING_ENABLED;
146
Nathan Harold2b77d742016-03-19 13:22:10 -0700147 //Values in must match mCellInfoRefreshRates
148 private static final String[] mCellInfoRefreshRateLabels = {
149 "Disabled",
150 "Immediate",
151 "Min 5s",
152 "Min 10s",
153 "Min 60s"
154 };
155
156 //Values in seconds, must match mCellInfoRefreshRateLabels
157 private static final int mCellInfoRefreshRates[] = {
158 CELL_INFO_LIST_RATE_DISABLED,
159 CELL_INFO_LIST_RATE_MAX,
160 5000,
161 10000,
162 60000
163 };
164
165 private void log(String s) {
166 Log.d(TAG, s);
167 }
168
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800169 private static final int EVENT_CFI_CHANGED = 302;
170
171 private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000;
172 private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800173 private static final int EVENT_QUERY_SMSC_DONE = 1005;
174 private static final int EVENT_UPDATE_SMSC_DONE = 1006;
175
176 private static final int MENU_ITEM_SELECT_BAND = 0;
177 private static final int MENU_ITEM_VIEW_ADN = 1;
178 private static final int MENU_ITEM_VIEW_FDN = 2;
179 private static final int MENU_ITEM_VIEW_SDN = 3;
Nathan Harolde272c202016-10-27 13:45:00 -0700180 private static final int MENU_ITEM_GET_IMS_STATUS = 4;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800181 private static final int MENU_ITEM_TOGGLE_DATA = 5;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800182
Wink Savillec3886682009-04-02 11:00:56 -0700183 private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800184 private TextView number;
Meng Wang9053f172017-06-23 16:02:14 -0700185 private TextView mSubscriberId;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800186 private TextView callState;
187 private TextView operatorName;
188 private TextView roamingState;
189 private TextView gsmState;
190 private TextView gprsState;
Nathan Harold2b77d742016-03-19 13:22:10 -0700191 private TextView voiceNetwork;
192 private TextView dataNetwork;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800193 private TextView dBm;
194 private TextView mMwi;
195 private TextView mCfi;
196 private TextView mLocation;
Wink Saville79bff2a2012-06-01 14:37:21 -0700197 private TextView mCellInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800198 private TextView sent;
199 private TextView received;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800200 private TextView mPingHostnameV4;
201 private TextView mPingHostnameV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800202 private TextView mHttpClientTest;
Nathan Harold433ca442018-04-23 18:20:43 -0700203 private TextView mPhyChanConfig;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800204 private TextView dnsCheckState;
Nathan Haroldf10ea322018-04-24 13:31:07 -0700205 private TextView mDownlinkKbps;
206 private TextView mUplinkKbps;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800207 private EditText smsc;
Nathan Harold2b77d742016-03-19 13:22:10 -0700208 private Switch radioPowerOnSwitch;
209 private Button cellInfoRefreshRateButton;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800210 private Button dnsCheckToggleButton;
211 private Button pingTestButton;
212 private Button updateSmscButton;
213 private Button refreshSmscButton;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800214 private Button oemInfoButton;
Youhan Wangfd781e92016-12-16 15:53:16 -0800215 private Button carrierProvisioningButton;
216 private Button triggercarrierProvisioningButton;
Nathan Harold12e1f552016-06-17 13:55:38 -0700217 private Switch imsVolteProvisionedSwitch;
218 private Switch imsVtProvisionedSwitch;
219 private Switch imsWfcProvisionedSwitch;
Meng Wang586741c2017-04-26 15:02:51 -0700220 private Switch eabProvisionedSwitch;
Naina Nallurid1b57f62019-01-08 15:19:58 -0800221 private Switch cbrsDataSwitch;
Pengquan Meng7f602c72019-01-28 19:12:18 -0800222 private Switch dsdsSwitch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800223 private Spinner preferredNetworkType;
Nathan Harold2b77d742016-03-19 13:22:10 -0700224 private Spinner cellInfoRefreshRateSpinner;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800225
Nathan Haroldf10ea322018-04-24 13:31:07 -0700226 private ConnectivityManager mConnectivityManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800227 private TelephonyManager mTelephonyManager;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800228 private ImsManager mImsManager = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800229 private Phone phone = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800230
Nathan Haroldcea413a2015-11-23 15:48:10 -0800231 private String mPingHostnameResultV4;
232 private String mPingHostnameResultV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800233 private String mHttpClientTestResult;
234 private boolean mMwiValue = false;
235 private boolean mCfiValue = false;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800236
237 private List<CellInfo> mCellInfoResult = null;
238 private CellLocation mCellLocationResult = null;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800239
240 private int mPreferredNetworkTypeResult;
Nathan Harold2b77d742016-03-19 13:22:10 -0700241 private int mCellInfoRefreshRateIndex;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800242
Nathan Haroldf10ea322018-04-24 13:31:07 -0700243 private final NetworkRequest mDefaultNetworkRequest = new NetworkRequest.Builder()
244 .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
245 .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
246 .build();
247
248 private final NetworkCallback mNetworkCallback = new NetworkCallback() {
249 public void onCapabilitiesChanged(Network n, NetworkCapabilities nc) {
250 int dlbw = nc.getLinkDownstreamBandwidthKbps();
251 int ulbw = nc.getLinkUpstreamBandwidthKbps();
252 updateBandwidths(dlbw, ulbw);
253 }
254 };
255
Nathan Harold2b77d742016-03-19 13:22:10 -0700256 private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800257 @Override
258 public void onDataConnectionStateChanged(int state) {
259 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800260 updateNetworkType();
261 }
262
263 @Override
264 public void onDataActivity(int direction) {
265 updateDataStats2();
266 }
267
268 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700269 public void onCallStateChanged(int state, String incomingNumber) {
270 updateNetworkType();
271 updatePhoneState(state);
272 }
273
274 @Override
275 public void onPreciseCallStateChanged(PreciseCallState preciseState) {
276 updateNetworkType();
277 }
278
279 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800280 public void onCellLocationChanged(CellLocation location) {
281 updateLocation(location);
282 }
283
284 @Override
285 public void onMessageWaitingIndicatorChanged(boolean mwi) {
286 mMwiValue = mwi;
287 updateMessageWaiting();
288 }
289
290 @Override
291 public void onCallForwardingIndicatorChanged(boolean cfi) {
292 mCfiValue = cfi;
293 updateCallRedirect();
294 }
Wink Saville79bff2a2012-06-01 14:37:21 -0700295
296 @Override
297 public void onCellInfoChanged(List<CellInfo> arrayCi) {
Wink Savillebf471282013-04-05 15:04:05 -0700298 log("onCellInfoChanged: arrayCi=" + arrayCi);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800299 mCellInfoResult = arrayCi;
300 updateCellInfo(mCellInfoResult);
Wink Saville79bff2a2012-06-01 14:37:21 -0700301 }
Wink Saville4f0d8812014-04-15 22:05:24 -0700302
303 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700304 public void onSignalStrengthsChanged(SignalStrength signalStrength) {
305 log("onSignalStrengthChanged: SignalStrength=" +signalStrength);
306 updateSignalStrength(signalStrength);
307 }
308
309 @Override
310 public void onServiceStateChanged(ServiceState serviceState) {
311 log("onServiceStateChanged: ServiceState=" + serviceState);
312 updateServiceState(serviceState);
313 updateRadioPowerState();
314 updateNetworkType();
Nathan Harold12e1f552016-06-17 13:55:38 -0700315 updateImsProvisionedState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700316 }
Nathan Harold433ca442018-04-23 18:20:43 -0700317
318 @Override
319 public void onPhysicalChannelConfigurationChanged(
320 List<PhysicalChannelConfig> configs) {
321 updatePhysicalChannelConfiguration(configs);
322 }
323
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800324 };
325
Nathan Harold433ca442018-04-23 18:20:43 -0700326 private void updatePhysicalChannelConfiguration(List<PhysicalChannelConfig> configs) {
327 StringBuilder sb = new StringBuilder();
328 String div = "";
329 sb.append("{");
330 if (configs != null) {
331 for(PhysicalChannelConfig c : configs) {
332 sb.append(div).append(c);
333 div = ",";
334 }
335 }
336 sb.append("}");
337 mPhyChanConfig.setText(sb.toString());
338 }
339
Nathan Haroldcea413a2015-11-23 15:48:10 -0800340 private void updatePreferredNetworkType(int type) {
341 if (type >= mPreferredNetworkLabels.length || type < 0) {
342 log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
343 "type=" + type);
344 type = mPreferredNetworkLabels.length - 1; //set to Unknown
345 }
346 mPreferredNetworkTypeResult = type;
347
348 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
349 }
350
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800351 private Handler mHandler = new Handler() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800352 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800353 public void handleMessage(Message msg) {
354 AsyncResult ar;
355 switch (msg.what) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800356 case EVENT_QUERY_PREFERRED_TYPE_DONE:
357 ar= (AsyncResult) msg.obj;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800358 if (ar.exception == null && ar.result != null) {
359 updatePreferredNetworkType(((int[])ar.result)[0]);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800360 } else {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800361 //In case of an exception, we will set this to unknown
362 updatePreferredNetworkType(mPreferredNetworkLabels.length-1);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800363 }
364 break;
365 case EVENT_SET_PREFERRED_TYPE_DONE:
366 ar= (AsyncResult) msg.obj;
367 if (ar.exception != null) {
Nathan Harolded38afa2016-04-13 00:29:30 -0700368 log("Set preferred network type failed.");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800369 }
370 break;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800371 case EVENT_QUERY_SMSC_DONE:
372 ar= (AsyncResult) msg.obj;
373 if (ar.exception != null) {
374 smsc.setText("refresh error");
375 } else {
jsh21dd4072009-05-12 11:26:55 -0700376 smsc.setText((String)ar.result);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800377 }
378 break;
379 case EVENT_UPDATE_SMSC_DONE:
380 updateSmscButton.setEnabled(true);
381 ar= (AsyncResult) msg.obj;
382 if (ar.exception != null) {
383 smsc.setText("update error");
384 }
385 break;
386 default:
Nathan Haroldcea413a2015-11-23 15:48:10 -0800387 super.handleMessage(msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800388 break;
389
390 }
391 }
392 };
393
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800394 @Override
395 public void onCreate(Bundle icicle) {
396 super.onCreate(icicle);
fionaxub54cb2d2016-09-22 15:01:05 -0700397 if (!android.os.Process.myUserHandle().isSystem()) {
398 Log.e(TAG, "Not run from system user, don't do anything.");
399 finish();
400 return;
401 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800402
403 setContentView(R.layout.radio_info);
404
Nathan Haroldcea413a2015-11-23 15:48:10 -0800405 log("Started onCreate");
406
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800407 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
Nathan Haroldf10ea322018-04-24 13:31:07 -0700408 mConnectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800409 phone = PhoneFactory.getDefaultPhone();
410
Nathan Haroldcea413a2015-11-23 15:48:10 -0800411 //TODO: Need to update this if the default phoneId changes?
412 // Better to have an instance per phone?
413 mImsManager = ImsManager.getInstance(getApplicationContext(),
414 SubscriptionManager.getDefaultVoicePhoneId());
415
Meng Wang9053f172017-06-23 16:02:14 -0700416 mDeviceId = (TextView) findViewById(R.id.imei);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800417 number = (TextView) findViewById(R.id.number);
Meng Wang9053f172017-06-23 16:02:14 -0700418 mSubscriberId = (TextView) findViewById(R.id.imsi);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800419 callState = (TextView) findViewById(R.id.call);
420 operatorName = (TextView) findViewById(R.id.operator);
421 roamingState = (TextView) findViewById(R.id.roaming);
422 gsmState = (TextView) findViewById(R.id.gsm);
423 gprsState = (TextView) findViewById(R.id.gprs);
Nathan Harold2b77d742016-03-19 13:22:10 -0700424 voiceNetwork = (TextView) findViewById(R.id.voice_network);
425 dataNetwork = (TextView) findViewById(R.id.data_network);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800426 dBm = (TextView) findViewById(R.id.dbm);
427 mMwi = (TextView) findViewById(R.id.mwi);
428 mCfi = (TextView) findViewById(R.id.cfi);
429 mLocation = (TextView) findViewById(R.id.location);
Wink Saville79bff2a2012-06-01 14:37:21 -0700430 mCellInfo = (TextView) findViewById(R.id.cellinfo);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800431 mCellInfo.setTypeface(Typeface.MONOSPACE);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800432
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800433 sent = (TextView) findViewById(R.id.sent);
434 received = (TextView) findViewById(R.id.received);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800435 smsc = (EditText) findViewById(R.id.smsc);
436 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800437 mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4);
438 mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800439 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
440
Nathan Harold433ca442018-04-23 18:20:43 -0700441 mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config);
442
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800443 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
444 ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
445 android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
johnwang342101a2009-09-23 16:22:34 -0700446 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800447 preferredNetworkType.setAdapter(adapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800448
Nathan Harold2b77d742016-03-19 13:22:10 -0700449 cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select);
450 ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this,
451 android.R.layout.simple_spinner_item, mCellInfoRefreshRateLabels);
452 cellInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
453 cellInfoRefreshRateSpinner.setAdapter(cellInfoAdapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800454
Nathan Harold12e1f552016-06-17 13:55:38 -0700455 imsVolteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch);
456 imsVtProvisionedSwitch = (Switch) findViewById(R.id.vt_provisioned_switch);
457 imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
Meng Wang69439b52017-05-01 08:31:14 -0700458 eabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch);
Wink Savillebf471282013-04-05 15:04:05 -0700459
Brad Ebinger5dfe7f82019-03-11 17:33:53 -0700460 if (!ImsManager.isImsSupportedOnDevice(phone.getContext())) {
461 imsVolteProvisionedSwitch.setVisibility(View.GONE);
462 imsVtProvisionedSwitch.setVisibility(View.GONE);
463 imsWfcProvisionedSwitch.setVisibility(View.GONE);
464 eabProvisionedSwitch.setVisibility(View.GONE);
465 }
466
Naina Nallurid1b57f62019-01-08 15:19:58 -0800467 cbrsDataSwitch = (Switch) findViewById(R.id.cbrs_data_switch);
468 cbrsDataSwitch.setVisibility(isCbrsSupported() ? View.VISIBLE : View.GONE);
469
Pengquan Meng7f602c72019-01-28 19:12:18 -0800470 dsdsSwitch = findViewById(R.id.dsds_switch);
471 if (isDsdsSupported()) {
472 dsdsSwitch.setVisibility(View.VISIBLE);
473 dsdsSwitch.setOnClickListener(v -> {
474 if (mTelephonyManager.isRebootRequiredForModemConfigChange()) {
475 // Undo the click action until user clicks the confirm dialog.
476 dsdsSwitch.toggle();
477 showDsdsChangeDialog();
478 } else {
479 performDsdsSwitch();
480 }
481 });
482 dsdsSwitch.setChecked(isDsdsEnabled());
483 } else {
484 dsdsSwitch.setVisibility(View.GONE);
485 }
486
Nathan Harold2b77d742016-03-19 13:22:10 -0700487 radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
Wink Saville426fc662011-09-25 14:39:02 -0700488
Nathan Haroldf10ea322018-04-24 13:31:07 -0700489 mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
490 mUplinkKbps = (TextView) findViewById(R.id.ul_kbps);
491 updateBandwidths(0, 0);
492
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800493 pingTestButton = (Button) findViewById(R.id.ping_test);
494 pingTestButton.setOnClickListener(mPingButtonHandler);
495 updateSmscButton = (Button) findViewById(R.id.update_smsc);
496 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
497 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
498 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
499 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
500 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
Youhan Wangfd781e92016-12-16 15:53:16 -0800501 carrierProvisioningButton = (Button) findViewById(R.id.carrier_provisioning);
502 carrierProvisioningButton.setOnClickListener(mCarrierProvisioningButtonHandler);
503 triggercarrierProvisioningButton = (Button) findViewById(R.id.trigger_carrier_provisioning);
504 triggercarrierProvisioningButton.setOnClickListener(
505 mTriggerCarrierProvisioningButtonHandler);
johnwang342101a2009-09-23 16:22:34 -0700506
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800507 oemInfoButton = (Button) findViewById(R.id.oem_info);
508 oemInfoButton.setOnClickListener(mOemInfoButtonHandler);
509 PackageManager pm = getPackageManager();
510 Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO");
511 List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0);
512 if (oemInfoIntentList.size() == 0) {
513 oemInfoButton.setEnabled(false);
514 }
515
Nathan Harolded38afa2016-04-13 00:29:30 -0700516 mCellInfoRefreshRateIndex = 0; //disabled
Nathan Haroldcea413a2015-11-23 15:48:10 -0800517 mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown
518
519 //FIXME: Replace with TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800520 phone.getPreferredNetworkType(
521 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800522
Nathan Haroldcea413a2015-11-23 15:48:10 -0800523 restoreFromBundle(icicle);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800524 }
525
526 @Override
527 protected void onResume() {
528 super.onResume();
529
Nathan Haroldcea413a2015-11-23 15:48:10 -0800530 log("Started onResume");
531
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800532 updateMessageWaiting();
533 updateCallRedirect();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800534 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800535 updateDataStats2();
Nathan Harold2b77d742016-03-19 13:22:10 -0700536 updateRadioPowerState();
Nathan Harold12e1f552016-06-17 13:55:38 -0700537 updateImsProvisionedState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800538 updateProperties();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800539 updateDnsCheckState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700540 updateNetworkType();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800541
Nathan Haroldcea413a2015-11-23 15:48:10 -0800542 updateLocation(mCellLocationResult);
543 updateCellInfo(mCellInfoResult);
544
545 mPingHostnameV4.setText(mPingHostnameResultV4);
546 mPingHostnameV6.setText(mPingHostnameResultV6);
547 mHttpClientTest.setText(mHttpClientTestResult);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800548
Nathan Harold2b77d742016-03-19 13:22:10 -0700549 cellInfoRefreshRateSpinner.setOnItemSelectedListener(mCellInfoRefreshRateHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700550 //set selection after registering listener to force update
551 cellInfoRefreshRateSpinner.setSelection(mCellInfoRefreshRateIndex);
552
553 //set selection before registering to prevent update
554 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
Nathan Harold2b77d742016-03-19 13:22:10 -0700555 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700556
Nathan Harold2b77d742016-03-19 13:22:10 -0700557 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
Nathan Harold12e1f552016-06-17 13:55:38 -0700558 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
559 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
560 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Meng Wang586741c2017-04-26 15:02:51 -0700561 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
Nathan Harold2b77d742016-03-19 13:22:10 -0700562
Naina Nallurid1b57f62019-01-08 15:19:58 -0800563 if (isCbrsSupported()) {
564 cbrsDataSwitch.setChecked(getCbrsDataState());
565 cbrsDataSwitch.setOnCheckedChangeListener(mCbrsDataSwitchChangeListener);
566 }
567
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800568 mTelephonyManager.listen(mPhoneStateListener,
Nathan Harold2b77d742016-03-19 13:22:10 -0700569 PhoneStateListener.LISTEN_CALL_STATE
570 //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
571 // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
572 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800573 | PhoneStateListener.LISTEN_DATA_ACTIVITY
574 | PhoneStateListener.LISTEN_CELL_LOCATION
575 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
Wink Saville79bff2a2012-06-01 14:37:21 -0700576 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
Wink Saville4f0d8812014-04-15 22:05:24 -0700577 | PhoneStateListener.LISTEN_CELL_INFO
Nathan Harold2b77d742016-03-19 13:22:10 -0700578 | PhoneStateListener.LISTEN_SERVICE_STATE
579 | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
Nathan Harold433ca442018-04-23 18:20:43 -0700580 | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION);
Nathan Harolded38afa2016-04-13 00:29:30 -0700581
Nathan Haroldf10ea322018-04-24 13:31:07 -0700582 mConnectivityManager.registerNetworkCallback(
583 mDefaultNetworkRequest, mNetworkCallback, mHandler);
584
Nathan Harolded38afa2016-04-13 00:29:30 -0700585 smsc.clearFocus();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800586 }
587
588 @Override
Nathan Haroldcea413a2015-11-23 15:48:10 -0800589 protected void onPause() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800590 super.onPause();
591
Wink Savillebf471282013-04-05 15:04:05 -0700592 log("onPause: unregister phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800593
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800594 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -0700595 mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
Nathan Haroldf10ea322018-04-24 13:31:07 -0700596 mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
597
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800598 }
599
Nathan Haroldcea413a2015-11-23 15:48:10 -0800600 private void restoreFromBundle(Bundle b) {
Nathan Harolde272c202016-10-27 13:45:00 -0700601 if(b == null) {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800602 return;
603 }
604
605 mPingHostnameResultV4 = b.getString("mPingHostnameResultV4","");
606 mPingHostnameResultV6 = b.getString("mPingHostnameResultV6","");
607 mHttpClientTestResult = b.getString("mHttpClientTestResult","");
608
609 mPingHostnameV4.setText(mPingHostnameResultV4);
610 mPingHostnameV6.setText(mPingHostnameResultV6);
611 mHttpClientTest.setText(mHttpClientTestResult);
612
Nathan Harold2b77d742016-03-19 13:22:10 -0700613 mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult",
614 mPreferredNetworkLabels.length - 1);
615
616 mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800617 }
618
619 @Override
620 protected void onSaveInstanceState(Bundle outState) {
621 outState.putString("mPingHostnameResultV4", mPingHostnameResultV4);
622 outState.putString("mPingHostnameResultV6", mPingHostnameResultV6);
623 outState.putString("mHttpClientTestResult", mHttpClientTestResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700624
Nathan Haroldcea413a2015-11-23 15:48:10 -0800625 outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700626 outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex);
627
Nathan Haroldcea413a2015-11-23 15:48:10 -0800628 }
629
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800630 @Override
631 public boolean onCreateOptionsMenu(Menu menu) {
Wink Savillec3886682009-04-02 11:00:56 -0700632 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
633 .setOnMenuItemClickListener(mSelectBandCallback)
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800634 .setAlphabeticShortcut('b');
635 menu.add(1, MENU_ITEM_VIEW_ADN, 0,
636 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
637 menu.add(1, MENU_ITEM_VIEW_FDN, 0,
638 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
639 menu.add(1, MENU_ITEM_VIEW_SDN, 0,
640 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
Brad Ebinger5dfe7f82019-03-11 17:33:53 -0700641 if (ImsManager.isImsSupportedOnDevice(phone.getContext())) {
642 menu.add(1, MENU_ITEM_GET_IMS_STATUS,
643 0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus);
644 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800645 menu.add(1, MENU_ITEM_TOGGLE_DATA,
Nathan Harold2b77d742016-03-19 13:22:10 -0700646 0, R.string.radio_info_data_connection_disable).setOnMenuItemClickListener(mToggleData);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800647 return true;
648 }
649
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800650 @Override
Wink Savillec3886682009-04-02 11:00:56 -0700651 public boolean onPrepareOptionsMenu(Menu menu) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800652 // Get the TOGGLE DATA menu item in the right state.
653 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
654 int state = mTelephonyManager.getDataState();
655 boolean visible = true;
656
657 switch (state) {
658 case TelephonyManager.DATA_CONNECTED:
659 case TelephonyManager.DATA_SUSPENDED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700660 item.setTitle(R.string.radio_info_data_connection_disable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800661 break;
662 case TelephonyManager.DATA_DISCONNECTED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700663 item.setTitle(R.string.radio_info_data_connection_enable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800664 break;
665 default:
666 visible = false;
667 break;
668 }
669 item.setVisible(visible);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800670 return true;
671 }
672
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800673 private void updateDnsCheckState() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800674 //FIXME: Replace with a TelephonyManager call
Mike Lockwood5304c7e2009-04-05 11:37:45 -0700675 dnsCheckState.setText(phone.isDnsCheckDisabled() ?
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800676 "0.0.0.0 allowed" :"0.0.0.0 not allowed");
677 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700678
Nathan Haroldf10ea322018-04-24 13:31:07 -0700679 private void updateBandwidths(int dlbw, int ulbw) {
680 dlbw = (dlbw < 0 || dlbw == Integer.MAX_VALUE) ? -1 : dlbw;
681 ulbw = (ulbw < 0 || ulbw == Integer.MAX_VALUE) ? -1 : ulbw;
682 mDownlinkKbps.setText(String.format("%-5d", dlbw));
683 mUplinkKbps.setText(String.format("%-5d", ulbw));
684 }
685
686
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800687 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700688 updateSignalStrength(SignalStrength signalStrength) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800689 Resources r = getResources();
690
Nathan Harold2b77d742016-03-19 13:22:10 -0700691 int signalDbm = signalStrength.getDbm();
Wink Savillee2a14e32009-05-29 14:06:30 -0700692
Nathan Harold2b77d742016-03-19 13:22:10 -0700693 int signalAsu = signalStrength.getAsuLevel();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800694
695 if (-1 == signalAsu) signalAsu = 0;
696
697 dBm.setText(String.valueOf(signalDbm) + " "
698 + r.getString(R.string.radioInfo_display_dbm) + " "
699 + String.valueOf(signalAsu) + " "
700 + r.getString(R.string.radioInfo_display_asu));
701 }
702
703 private final void updateLocation(CellLocation location) {
jsh534f5ae2009-09-24 09:19:22 -0700704 Resources r = getResources();
Wink Savillec3886682009-04-02 11:00:56 -0700705 if (location instanceof GsmCellLocation) {
706 GsmCellLocation loc = (GsmCellLocation)location;
jsh534f5ae2009-09-24 09:19:22 -0700707 int lac = loc.getLac();
708 int cid = loc.getCid();
709 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
710 + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
711 + " "
712 + r.getString(R.string.radioInfo_cid) + " = "
713 + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
714 } else if (location instanceof CdmaCellLocation) {
715 CdmaCellLocation loc = (CdmaCellLocation)location;
716 int bid = loc.getBaseStationId();
717 int sid = loc.getSystemId();
718 int nid = loc.getNetworkId();
719 int lat = loc.getBaseStationLatitude();
720 int lon = loc.getBaseStationLongitude();
721 mLocation.setText("BID = "
722 + ((bid == -1) ? "unknown" : Integer.toHexString(bid))
723 + " "
724 + "SID = "
725 + ((sid == -1) ? "unknown" : Integer.toHexString(sid))
726 + " "
727 + "NID = "
728 + ((nid == -1) ? "unknown" : Integer.toHexString(nid))
729 + "\n"
730 + "LAT = "
731 + ((lat == -1) ? "unknown" : Integer.toHexString(lat))
732 + " "
733 + "LONG = "
734 + ((lon == -1) ? "unknown" : Integer.toHexString(lon)));
735 } else {
736 mLocation.setText("unknown");
Wink Savillec3886682009-04-02 11:00:56 -0700737 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800738
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800739
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800740 }
741
Nathan Haroldcea413a2015-11-23 15:48:10 -0800742 private final String getCellInfoDisplayString(int i) {
743 return (i != Integer.MAX_VALUE) ? Integer.toString(i) : "";
744 }
745
746 private final String getCellInfoDisplayString(long i) {
747 return (i != Long.MAX_VALUE) ? Long.toString(i) : "";
748 }
749
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700750 private final String getConnectionStatusString(CellInfo ci) {
751 String regStr = "";
752 String connStatStr = "";
753 String connector = "";
754
755 if (ci.isRegistered()) {
756 regStr = "R";
757 }
758 switch (ci.getCellConnectionStatus()) {
759 case CellInfo.CONNECTION_PRIMARY_SERVING: connStatStr = "P"; break;
760 case CellInfo.CONNECTION_SECONDARY_SERVING: connStatStr = "S"; break;
761 case CellInfo.CONNECTION_NONE: connStatStr = "N"; break;
762 case CellInfo.CONNECTION_UNKNOWN: /* Field is unsupported */ break;
763 default: break;
764 }
765 if (!TextUtils.isEmpty(regStr) && !TextUtils.isEmpty(connStatStr)) {
766 connector = "+";
767 }
768
769 return regStr + connector + connStatStr;
770 }
771
Nathan Haroldcea413a2015-11-23 15:48:10 -0800772 private final String buildCdmaInfoString(CellInfoCdma ci) {
773 CellIdentityCdma cidCdma = ci.getCellIdentity();
774 CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
775
776 return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s",
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700777 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800778 getCellInfoDisplayString(cidCdma.getSystemId()),
779 getCellInfoDisplayString(cidCdma.getNetworkId()),
780 getCellInfoDisplayString(cidCdma.getBasestationId()),
781 getCellInfoDisplayString(ssCdma.getCdmaDbm()),
782 getCellInfoDisplayString(ssCdma.getCdmaEcio()),
783 getCellInfoDisplayString(ssCdma.getEvdoDbm()),
784 getCellInfoDisplayString(ssCdma.getEvdoEcio()),
785 getCellInfoDisplayString(ssCdma.getEvdoSnr()));
786 }
787
788 private final String buildGsmInfoString(CellInfoGsm ci) {
789 CellIdentityGsm cidGsm = ci.getCellIdentity();
790 CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
791
Nathan Harold2b77d742016-03-19 13:22:10 -0700792 return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700793 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800794 getCellInfoDisplayString(cidGsm.getMcc()),
795 getCellInfoDisplayString(cidGsm.getMnc()),
796 getCellInfoDisplayString(cidGsm.getLac()),
797 getCellInfoDisplayString(cidGsm.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700798 getCellInfoDisplayString(cidGsm.getArfcn()),
799 getCellInfoDisplayString(cidGsm.getBsic()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800800 getCellInfoDisplayString(ssGsm.getDbm()));
801 }
802
803 private final String buildLteInfoString(CellInfoLte ci) {
804 CellIdentityLte cidLte = ci.getCellIdentity();
805 CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
806
807 return String.format(
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700808 "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
809 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800810 getCellInfoDisplayString(cidLte.getMcc()),
811 getCellInfoDisplayString(cidLte.getMnc()),
812 getCellInfoDisplayString(cidLte.getTac()),
813 getCellInfoDisplayString(cidLte.getCi()),
814 getCellInfoDisplayString(cidLte.getPci()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700815 getCellInfoDisplayString(cidLte.getEarfcn()),
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700816 getCellInfoDisplayString(cidLte.getBandwidth()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800817 getCellInfoDisplayString(ssLte.getDbm()),
818 getCellInfoDisplayString(ssLte.getRsrq()),
819 getCellInfoDisplayString(ssLte.getTimingAdvance()));
820 }
821
822 private final String buildWcdmaInfoString(CellInfoWcdma ci) {
823 CellIdentityWcdma cidWcdma = ci.getCellIdentity();
824 CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength();
825
Nathan Harold2b77d742016-03-19 13:22:10 -0700826 return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700827 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800828 getCellInfoDisplayString(cidWcdma.getMcc()),
829 getCellInfoDisplayString(cidWcdma.getMnc()),
830 getCellInfoDisplayString(cidWcdma.getLac()),
831 getCellInfoDisplayString(cidWcdma.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700832 getCellInfoDisplayString(cidWcdma.getUarfcn()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800833 getCellInfoDisplayString(cidWcdma.getPsc()),
834 getCellInfoDisplayString(ssWcdma.getDbm()));
835 }
836
837 private final String buildCellInfoString(List<CellInfo> arrayCi) {
838 String value = new String();
839 StringBuilder cdmaCells = new StringBuilder(),
840 gsmCells = new StringBuilder(),
841 lteCells = new StringBuilder(),
842 wcdmaCells = new StringBuilder();
843
844 if (arrayCi != null) {
845 for (CellInfo ci : arrayCi) {
846
847 if (ci instanceof CellInfoLte) {
848 lteCells.append(buildLteInfoString((CellInfoLte) ci));
849 } else if (ci instanceof CellInfoWcdma) {
850 wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
851 } else if (ci instanceof CellInfoGsm) {
852 gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
853 } else if (ci instanceof CellInfoCdma) {
854 cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
Wink Saville79bff2a2012-06-01 14:37:21 -0700855 }
856 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800857 if (lteCells.length() != 0) {
858 value += String.format(
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700859 "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s"
860 + " %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
861 "SRV", "MCC", "MNC", "TAC", "CID", "PCI",
862 "EARFCN", "BW", "RSRP", "RSRQ", "TA");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800863 value += lteCells.toString();
864 }
865 if (wcdmaCells.length() != 0) {
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700866 value += String.format(
867 "WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n",
Nathan Harold2b77d742016-03-19 13:22:10 -0700868 "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800869 value += wcdmaCells.toString();
870 }
871 if (gsmCells.length() != 0) {
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700872 value += String.format(
873 "GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n",
Nathan Harold2b77d742016-03-19 13:22:10 -0700874 "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800875 value += gsmCells.toString();
876 }
877 if (cdmaCells.length() != 0) {
878 value += String.format(
879 "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n",
880 "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
881 value += cdmaCells.toString();
882 }
883 } else {
884 value ="unknown";
Wink Saville79bff2a2012-06-01 14:37:21 -0700885 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800886
887 return value.toString();
888 }
889
890 private final void updateCellInfo(List<CellInfo> arrayCi) {
891 mCellInfo.setText(buildCellInfoString(arrayCi));
Wink Saville79bff2a2012-06-01 14:37:21 -0700892 }
893
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800894 private final void
895 updateMessageWaiting() {
896 mMwi.setText(String.valueOf(mMwiValue));
897 }
898
899 private final void
900 updateCallRedirect() {
901 mCfi.setText(String.valueOf(mCfiValue));
902 }
903
904
905 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700906 updateServiceState(ServiceState serviceState) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800907 int state = serviceState.getState();
908 Resources r = getResources();
909 String display = r.getString(R.string.radioInfo_unknown);
johnwang342101a2009-09-23 16:22:34 -0700910
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800911 switch (state) {
912 case ServiceState.STATE_IN_SERVICE:
913 display = r.getString(R.string.radioInfo_service_in);
914 break;
915 case ServiceState.STATE_OUT_OF_SERVICE:
916 case ServiceState.STATE_EMERGENCY_ONLY:
917 display = r.getString(R.string.radioInfo_service_emergency);
918 break;
919 case ServiceState.STATE_POWER_OFF:
920 display = r.getString(R.string.radioInfo_service_off);
921 break;
922 }
johnwang342101a2009-09-23 16:22:34 -0700923
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800924 gsmState.setText(display);
johnwang342101a2009-09-23 16:22:34 -0700925
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800926 if (serviceState.getRoaming()) {
927 roamingState.setText(R.string.radioInfo_roaming_in);
928 } else {
929 roamingState.setText(R.string.radioInfo_roaming_not);
930 }
931
932 operatorName.setText(serviceState.getOperatorAlphaLong());
933 }
934
935 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700936 updatePhoneState(int state) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800937 Resources r = getResources();
938 String display = r.getString(R.string.radioInfo_unknown);
939
940 switch (state) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700941 case TelephonyManager.CALL_STATE_IDLE:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800942 display = r.getString(R.string.radioInfo_phone_idle);
943 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700944 case TelephonyManager.CALL_STATE_RINGING:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800945 display = r.getString(R.string.radioInfo_phone_ringing);
946 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700947 case TelephonyManager.CALL_STATE_OFFHOOK:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800948 display = r.getString(R.string.radioInfo_phone_offhook);
949 break;
950 }
951
952 callState.setText(display);
953 }
954
955 private final void
956 updateDataState() {
957 int state = mTelephonyManager.getDataState();
958 Resources r = getResources();
959 String display = r.getString(R.string.radioInfo_unknown);
960
961 switch (state) {
962 case TelephonyManager.DATA_CONNECTED:
963 display = r.getString(R.string.radioInfo_data_connected);
964 break;
965 case TelephonyManager.DATA_CONNECTING:
966 display = r.getString(R.string.radioInfo_data_connecting);
967 break;
968 case TelephonyManager.DATA_DISCONNECTED:
969 display = r.getString(R.string.radioInfo_data_disconnected);
970 break;
971 case TelephonyManager.DATA_SUSPENDED:
972 display = r.getString(R.string.radioInfo_data_suspended);
973 break;
974 }
johnwang342101a2009-09-23 16:22:34 -0700975
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800976 gprsState.setText(display);
977 }
978
979 private final void updateNetworkType() {
Nathan Harolde272c202016-10-27 13:45:00 -0700980 if(phone != null) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700981 ServiceState ss = phone.getServiceState();
982 dataNetwork.setText(ServiceState.rilRadioTechnologyToString(
983 phone.getServiceState().getRilDataRadioTechnology()));
984 voiceNetwork.setText(ServiceState.rilRadioTechnologyToString(
985 phone.getServiceState().getRilVoiceRadioTechnology()));
986 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800987 }
988
989 private final void
990 updateProperties() {
991 String s;
992 Resources r = getResources();
993
994 s = phone.getDeviceId();
johnwang342101a2009-09-23 16:22:34 -0700995 if (s == null) s = r.getString(R.string.radioInfo_unknown);
Wink Savillec3886682009-04-02 11:00:56 -0700996 mDeviceId.setText(s);
johnwang342101a2009-09-23 16:22:34 -0700997
Meng Wang9053f172017-06-23 16:02:14 -0700998 s = phone.getSubscriberId();
999 if (s == null) s = r.getString(R.string.radioInfo_unknown);
1000 mSubscriberId.setText(s);
1001
Nathan Haroldcea413a2015-11-23 15:48:10 -08001002 //FIXME: Replace with a TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001003 s = phone.getLine1Number();
johnwang342101a2009-09-23 16:22:34 -07001004 if (s == null) s = r.getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001005 number.setText(s);
1006 }
1007
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001008 private final void updateDataStats2() {
1009 Resources r = getResources();
1010
Jeff Sharkey93029862011-05-27 18:26:15 -07001011 long txPackets = TrafficStats.getMobileTxPackets();
1012 long rxPackets = TrafficStats.getMobileRxPackets();
1013 long txBytes = TrafficStats.getMobileTxBytes();
1014 long rxBytes = TrafficStats.getMobileRxBytes();
johnwang342101a2009-09-23 16:22:34 -07001015
Jeff Sharkey93029862011-05-27 18:26:15 -07001016 String packets = r.getString(R.string.radioInfo_display_packets);
1017 String bytes = r.getString(R.string.radioInfo_display_bytes);
johnwang342101a2009-09-23 16:22:34 -07001018
Jeff Sharkey93029862011-05-27 18:26:15 -07001019 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
1020 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001021 }
1022
1023 /**
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001024 * Ping a host name
1025 */
1026 private final void pingHostname() {
1027 try {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001028 try {
1029 Process p4 = Runtime.getRuntime().exec("ping -c 1 www.google.com");
1030 int status4 = p4.waitFor();
1031 if (status4 == 0) {
1032 mPingHostnameResultV4 = "Pass";
1033 } else {
1034 mPingHostnameResultV4 = String.format("Fail(%d)", status4);
1035 }
1036 } catch (IOException e) {
1037 mPingHostnameResultV4 = "Fail: IOException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001038 }
Nathan Haroldcea413a2015-11-23 15:48:10 -08001039 try {
1040 Process p6 = Runtime.getRuntime().exec("ping6 -c 1 www.google.com");
1041 int status6 = p6.waitFor();
1042 if (status6 == 0) {
1043 mPingHostnameResultV6 = "Pass";
1044 } else {
1045 mPingHostnameResultV6 = String.format("Fail(%d)", status6);
1046 }
1047 } catch (IOException e) {
1048 mPingHostnameResultV6 = "Fail: IOException";
1049 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001050 } catch (InterruptedException e) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001051 mPingHostnameResultV4 = mPingHostnameResultV6 = "Fail: InterruptedException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001052 }
1053 }
1054
1055 /**
1056 * This function checks for basic functionality of HTTP Client.
1057 */
1058 private void httpClientTest() {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001059 HttpURLConnection urlConnection = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001060 try {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001061 // TODO: Hardcoded for now, make it UI configurable
Alex Klyubinb0090232015-04-02 11:08:51 -07001062 URL url = new URL("https://www.google.com");
Narayan Kamathf25627c2014-12-12 13:53:28 +00001063 urlConnection = (HttpURLConnection) url.openConnection();
1064 if (urlConnection.getResponseCode() == 200) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001065 mHttpClientTestResult = "Pass";
1066 } else {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001067 mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001068 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001069 } catch (IOException e) {
1070 mHttpClientTestResult = "Fail: IOException";
Narayan Kamathf25627c2014-12-12 13:53:28 +00001071 } finally {
1072 if (urlConnection != null) {
1073 urlConnection.disconnect();
1074 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001075 }
1076 }
1077
1078 private void refreshSmsc() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001079 //FIXME: Replace with a TelephonyManager call
jsh21dd4072009-05-12 11:26:55 -07001080 phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001081 }
1082
Nathan Haroldcea413a2015-11-23 15:48:10 -08001083 private final void updateAllCellInfo() {
1084
1085 mCellInfo.setText("");
Nathan Haroldcea413a2015-11-23 15:48:10 -08001086 mLocation.setText("");
1087
1088 final Runnable updateAllCellInfoResults = new Runnable() {
1089 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001090 updateLocation(mCellLocationResult);
1091 updateCellInfo(mCellInfoResult);
1092 }
1093 };
1094
1095 Thread locThread = new Thread() {
1096 @Override
1097 public void run() {
1098 mCellInfoResult = mTelephonyManager.getAllCellInfo();
1099 mCellLocationResult = mTelephonyManager.getCellLocation();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001100
1101 mHandler.post(updateAllCellInfoResults);
1102 }
1103 };
1104 locThread.start();
1105 }
1106
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001107 private final void updatePingState() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001108 // Set all to unknown since the threads will take a few secs to update.
Nathan Haroldcea413a2015-11-23 15:48:10 -08001109 mPingHostnameResultV4 = getResources().getString(R.string.radioInfo_unknown);
1110 mPingHostnameResultV6 = getResources().getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001111 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
1112
Nathan Haroldcea413a2015-11-23 15:48:10 -08001113 mPingHostnameV4.setText(mPingHostnameResultV4);
1114 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001115 mHttpClientTest.setText(mHttpClientTestResult);
1116
1117 final Runnable updatePingResults = new Runnable() {
1118 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001119 mPingHostnameV4.setText(mPingHostnameResultV4);
1120 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001121 mHttpClientTest.setText(mHttpClientTestResult);
1122 }
1123 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001124
1125 Thread hostname = new Thread() {
1126 @Override
1127 public void run() {
1128 pingHostname();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001129 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001130 }
1131 };
1132 hostname.start();
1133
1134 Thread httpClient = new Thread() {
1135 @Override
1136 public void run() {
1137 httpClientTest();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001138 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001139 }
1140 };
1141 httpClient.start();
1142 }
1143
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001144 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
1145 public boolean onMenuItemClick(MenuItem item) {
1146 Intent intent = new Intent(Intent.ACTION_VIEW);
1147 // XXX We need to specify the component here because if we don't
1148 // the activity manager will try to resolve the type by calling
1149 // the content provider, which causes it to be loaded in a process
1150 // other than the Dialer process, which causes a lot of stuff to
1151 // break.
1152 intent.setClassName("com.android.phone",
1153 "com.android.phone.SimContacts");
1154 startActivity(intent);
1155 return true;
1156 }
1157 };
1158
1159 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
1160 public boolean onMenuItemClick(MenuItem item) {
1161 Intent intent = new Intent(Intent.ACTION_VIEW);
1162 // XXX We need to specify the component here because if we don't
1163 // the activity manager will try to resolve the type by calling
1164 // the content provider, which causes it to be loaded in a process
1165 // other than the Dialer process, which causes a lot of stuff to
1166 // break.
1167 intent.setClassName("com.android.phone",
Andrew Leeda90d682014-10-31 13:12:20 -07001168 "com.android.phone.settings.fdn.FdnList");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001169 startActivity(intent);
1170 return true;
1171 }
1172 };
1173
1174 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
1175 public boolean onMenuItemClick(MenuItem item) {
1176 Intent intent = new Intent(
Wink Savillec3886682009-04-02 11:00:56 -07001177 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001178 // XXX We need to specify the component here because if we don't
1179 // the activity manager will try to resolve the type by calling
1180 // the content provider, which causes it to be loaded in a process
1181 // other than the Dialer process, which causes a lot of stuff to
1182 // break.
1183 intent.setClassName("com.android.phone",
1184 "com.android.phone.ADNList");
1185 startActivity(intent);
1186 return true;
1187 }
1188 };
1189
Nathan Harolde272c202016-10-27 13:45:00 -07001190 private MenuItem.OnMenuItemClickListener mGetImsStatus = new MenuItem.OnMenuItemClickListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001191 public boolean onMenuItemClick(MenuItem item) {
Nathan Harolde272c202016-10-27 13:45:00 -07001192 boolean isImsRegistered = phone.isImsRegistered();
1193 boolean availableVolte = phone.isVolteEnabled();
1194 boolean availableWfc = phone.isWifiCallingEnabled();
1195 boolean availableVt = phone.isVideoEnabled();
1196 boolean availableUt = phone.isUtEnabled();
1197
1198 final String imsRegString = isImsRegistered ?
1199 getString(R.string.radio_info_ims_reg_status_registered) :
1200 getString(R.string.radio_info_ims_reg_status_not_registered);
1201
1202 final String available = getString(R.string.radio_info_ims_feature_status_available);
1203 final String unavailable = getString(
1204 R.string.radio_info_ims_feature_status_unavailable);
1205
1206 String imsStatus = getString(R.string.radio_info_ims_reg_status,
1207 imsRegString,
1208 availableVolte ? available : unavailable,
1209 availableWfc ? available : unavailable,
1210 availableVt ? available : unavailable,
1211 availableUt ? available : unavailable);
1212
1213 AlertDialog imsDialog = new AlertDialog.Builder(RadioInfo.this)
1214 .setMessage(imsStatus)
1215 .setTitle(getString(R.string.radio_info_ims_reg_status_title))
1216 .create();
1217
1218 imsDialog.show();
1219
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001220 return true;
1221 }
1222 };
1223
1224 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
1225 public boolean onMenuItemClick(MenuItem item) {
1226 Intent intent = new Intent();
1227 intent.setClass(RadioInfo.this, BandMode.class);
1228 startActivity(intent);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001229 return true;
1230 }
1231 };
johnwang342101a2009-09-23 16:22:34 -07001232
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001233 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
1234 public boolean onMenuItemClick(MenuItem item) {
1235 int state = mTelephonyManager.getDataState();
1236 switch (state) {
1237 case TelephonyManager.DATA_CONNECTED:
Jack Yu50972ed2018-12-13 11:51:20 -08001238 mTelephonyManager.setDataEnabled(false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001239 break;
1240 case TelephonyManager.DATA_DISCONNECTED:
Jack Yu50972ed2018-12-13 11:51:20 -08001241 mTelephonyManager.setDataEnabled(true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001242 break;
1243 default:
1244 // do nothing
1245 break;
1246 }
1247 return true;
1248 }
1249 };
1250
Nathan Harold2b77d742016-03-19 13:22:10 -07001251 private boolean isRadioOn() {
1252 //FIXME: Replace with a TelephonyManager call
1253 return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
1254 }
1255
1256 private void updateRadioPowerState() {
1257 //delightful hack to prevent on-checked-changed calls from
1258 //actually forcing the radio preference to its transient/current value.
1259 radioPowerOnSwitch.setOnCheckedChangeListener(null);
1260 radioPowerOnSwitch.setChecked(isRadioOn());
1261 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
1262 }
1263
Nathan Harolde272c202016-10-27 13:45:00 -07001264 void setImsVolteProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001265 Log.d(TAG, "setImsVolteProvisioned state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001266 setImsConfigProvisionedState(IMS_VOLTE_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001267 }
1268
Nathan Harolde272c202016-10-27 13:45:00 -07001269 void setImsVtProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001270 Log.d(TAG, "setImsVtProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001271 setImsConfigProvisionedState(IMS_VT_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001272 }
1273
Nathan Harolde272c202016-10-27 13:45:00 -07001274 void setImsWfcProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001275 Log.d(TAG, "setImsWfcProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001276 setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001277 }
1278
Meng Wang586741c2017-04-26 15:02:51 -07001279 void setEabProvisionedState(boolean state) {
1280 Log.d(TAG, "setEabProvisioned() state: " + ((state)? "on":"off"));
1281 setImsConfigProvisionedState(EAB_PROVISIONED_CONFIG_ID, state);
1282 }
1283
Nathan Harolde272c202016-10-27 13:45:00 -07001284 void setImsConfigProvisionedState(int configItem, boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001285 if (phone != null && mImsManager != null) {
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001286 QueuedWork.queue(new Runnable() {
Nathan Harold12e1f552016-06-17 13:55:38 -07001287 public void run() {
1288 try {
1289 mImsManager.getConfigInterface().setProvisionedValue(
1290 configItem,
1291 state? 1 : 0);
1292 } catch (ImsException e) {
1293 Log.e(TAG, "setImsConfigProvisioned() exception:", e);
1294 }
1295 }
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001296 }, false);
Nathan Harold12e1f552016-06-17 13:55:38 -07001297 }
1298 }
1299
Nathan Harold2b77d742016-03-19 13:22:10 -07001300 OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() {
1301 @Override
1302 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1303 log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
1304 phone.setRadioPower(isChecked);
1305 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001306 };
1307
Nathan Harold12e1f552016-06-17 13:55:38 -07001308 private boolean isImsVolteProvisioned() {
Nathan Harold2b77d742016-03-19 13:22:10 -07001309 if (phone != null && mImsManager != null) {
1310 return mImsManager.isVolteEnabledByPlatform(phone.getContext())
1311 && mImsManager.isVolteProvisionedOnDevice(phone.getContext());
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -08001312 }
1313 return false;
1314 }
1315
Nathan Harold12e1f552016-06-17 13:55:38 -07001316 OnCheckedChangeListener mImsVolteCheckedChangeListener = new OnCheckedChangeListener() {
Wink Saville426fc662011-09-25 14:39:02 -07001317 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -07001318 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001319 setImsVolteProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001320 }
Wink Saville426fc662011-09-25 14:39:02 -07001321 };
1322
Nathan Harold12e1f552016-06-17 13:55:38 -07001323 private boolean isImsVtProvisioned() {
1324 if (phone != null && mImsManager != null) {
1325 return mImsManager.isVtEnabledByPlatform(phone.getContext())
1326 && mImsManager.isVtProvisionedOnDevice(phone.getContext());
1327 }
1328 return false;
1329 }
1330
1331 OnCheckedChangeListener mImsVtCheckedChangeListener = new OnCheckedChangeListener() {
1332 @Override
1333 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1334 setImsVtProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001335 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001336 };
1337
1338 private boolean isImsWfcProvisioned() {
1339 if (phone != null && mImsManager != null) {
1340 return mImsManager.isWfcEnabledByPlatform(phone.getContext())
1341 && mImsManager.isWfcProvisionedOnDevice(phone.getContext());
1342 }
1343 return false;
1344 }
1345
1346 OnCheckedChangeListener mImsWfcCheckedChangeListener = new OnCheckedChangeListener() {
1347 @Override
1348 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1349 setImsWfcProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001350 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001351 };
1352
Meng Wang586741c2017-04-26 15:02:51 -07001353 private boolean isEabProvisioned() {
1354 return isFeatureProvisioned(EAB_PROVISIONED_CONFIG_ID, false);
1355 }
1356
1357 OnCheckedChangeListener mEabCheckedChangeListener = new OnCheckedChangeListener() {
1358 @Override
1359 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1360 setEabProvisionedState(isChecked);
1361 }
1362 };
1363
1364 private boolean isFeatureProvisioned(int featureId, boolean defaultValue) {
1365 boolean provisioned = defaultValue;
1366 if (mImsManager != null) {
1367 try {
1368 ImsConfig imsConfig = mImsManager.getConfigInterface();
1369 if (imsConfig != null) {
1370 provisioned =
1371 (imsConfig.getProvisionedValue(featureId)
1372 == ImsConfig.FeatureValueConstants.ON);
1373 }
1374 } catch (ImsException ex) {
1375 Log.e(TAG, "isFeatureProvisioned() exception:", ex);
1376 }
1377 }
1378
1379 log("isFeatureProvisioned() featureId=" + featureId + " provisioned=" + provisioned);
1380 return provisioned;
1381 }
1382
1383 private static boolean isEabEnabledByPlatform(Context context) {
1384 if (context != null) {
1385 CarrierConfigManager configManager = (CarrierConfigManager)
1386 context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
1387 if (configManager != null && configManager.getConfig().getBoolean(
1388 CarrierConfigManager.KEY_USE_RCS_PRESENCE_BOOL)) {
1389 return true;
1390 }
1391 }
1392 return false;
1393 }
1394
Nathan Harold12e1f552016-06-17 13:55:38 -07001395 private void updateImsProvisionedState() {
Brad Ebinger5dfe7f82019-03-11 17:33:53 -07001396 if (!ImsManager.isImsSupportedOnDevice(phone.getContext())) {
1397 return;
1398 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001399 log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
Nathan Harold2b77d742016-03-19 13:22:10 -07001400 //delightful hack to prevent on-checked-changed calls from
1401 //actually forcing the ims provisioning to its transient/current value.
Nathan Harold12e1f552016-06-17 13:55:38 -07001402 imsVolteProvisionedSwitch.setOnCheckedChangeListener(null);
1403 imsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned());
1404 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001405 imsVolteProvisionedSwitch.setEnabled(!Build.IS_USER
1406 && mImsManager.isVolteEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001407
1408 imsVtProvisionedSwitch.setOnCheckedChangeListener(null);
1409 imsVtProvisionedSwitch.setChecked(isImsVtProvisioned());
1410 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001411 imsVtProvisionedSwitch.setEnabled(!Build.IS_USER
1412 && mImsManager.isVtEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001413
1414 imsWfcProvisionedSwitch.setOnCheckedChangeListener(null);
1415 imsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned());
1416 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001417 imsWfcProvisionedSwitch.setEnabled(!Build.IS_USER
1418 && mImsManager.isWfcEnabledByPlatform(phone.getContext()));
Meng Wang586741c2017-04-26 15:02:51 -07001419
1420 eabProvisionedSwitch.setOnCheckedChangeListener(null);
1421 eabProvisionedSwitch.setChecked(isEabProvisioned());
1422 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001423 eabProvisionedSwitch.setEnabled(!Build.IS_USER
1424 && isEabEnabledByPlatform(phone.getContext()));
Wink Saville426fc662011-09-25 14:39:02 -07001425 }
1426
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001427 OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
1428 public void onClick(View v) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001429 //FIXME: Replace with a TelephonyManager call
Wink Savillec3886682009-04-02 11:00:56 -07001430 phone.disableDnsCheck(!phone.isDnsCheckDisabled());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001431 updateDnsCheckState();
1432 }
1433 };
johnwang342101a2009-09-23 16:22:34 -07001434
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001435 OnClickListener mOemInfoButtonHandler = new OnClickListener() {
1436 public void onClick(View v) {
1437 Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO");
1438 try {
1439 startActivity(intent);
1440 } catch (android.content.ActivityNotFoundException ex) {
Wink Savillebf471282013-04-05 15:04:05 -07001441 log("OEM-specific Info/Settings Activity Not Found : " + ex);
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001442 // If the activity does not exist, there are no OEM
1443 // settings, and so we can just do nothing...
1444 }
1445 }
1446 };
1447
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001448 OnClickListener mPingButtonHandler = new OnClickListener() {
1449 public void onClick(View v) {
1450 updatePingState();
1451 }
1452 };
1453
1454 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
1455 public void onClick(View v) {
1456 updateSmscButton.setEnabled(false);
jsh21dd4072009-05-12 11:26:55 -07001457 phone.setSmscAddress(smsc.getText().toString(),
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001458 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
1459 }
1460 };
1461
1462 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
1463 public void onClick(View v) {
1464 refreshSmsc();
1465 }
1466 };
1467
Youhan Wangfd781e92016-12-16 15:53:16 -08001468 OnClickListener mCarrierProvisioningButtonHandler = new OnClickListener() {
1469 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001470 final Intent intent = new Intent("com.android.settings.CARRIER_PROVISIONING");
1471 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1472 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001473 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001474 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001475 }
1476 };
1477
1478 OnClickListener mTriggerCarrierProvisioningButtonHandler = new OnClickListener() {
1479 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001480 final Intent intent = new Intent("com.android.settings.TRIGGER_CARRIER_PROVISIONING");
1481 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1482 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001483 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001484 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001485 }
1486 };
1487
Nathan Haroldcea413a2015-11-23 15:48:10 -08001488 AdapterView.OnItemSelectedListener mPreferredNetworkHandler =
1489 new AdapterView.OnItemSelectedListener() {
1490
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001491 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001492 if (mPreferredNetworkTypeResult != pos && pos >= 0
1493 && pos <= mPreferredNetworkLabels.length - 2) {
1494 mPreferredNetworkTypeResult = pos;
Nathan Harolddaea8be2018-06-05 14:02:35 -07001495
1496 // TODO: Possibly migrate this to TelephonyManager.setPreferredNetworkType()
1497 // which today still has some issues (mostly that the "set" is conditional
1498 // on a successful modem call, which is not what we want). Instead we always
1499 // want this setting to be set, so that if the radio hiccups and this setting
1500 // is for some reason unsuccessful, future calls to the radio will reflect
1501 // the users's preference which is set here.
1502 final int subId = phone.getSubId();
1503 if (SubscriptionManager.isUsableSubIdValue(subId)) {
1504 Settings.Global.putInt(phone.getContext().getContentResolver(),
1505 PREFERRED_NETWORK_MODE + subId, mPreferredNetworkTypeResult);
1506 }
1507 log("Calling setPreferredNetworkType(" + mPreferredNetworkTypeResult + ")");
Nathan Haroldcea413a2015-11-23 15:48:10 -08001508 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
1509 phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001510 }
1511 }
1512
1513 public void onNothingSelected(AdapterView parent) {
1514 }
1515 };
1516
Nathan Harold2b77d742016-03-19 13:22:10 -07001517 AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler =
1518 new AdapterView.OnItemSelectedListener() {
Wink Savillebf471282013-04-05 15:04:05 -07001519
Nathan Harold2b77d742016-03-19 13:22:10 -07001520 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1521 mCellInfoRefreshRateIndex = pos;
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -07001522 mTelephonyManager.setCellInfoListRate(mCellInfoRefreshRates[pos]);
Nathan Harold2b77d742016-03-19 13:22:10 -07001523 updateAllCellInfo();
1524 }
1525
1526 public void onNothingSelected(AdapterView parent) {
1527 }
1528 };
1529
Naina Nallurid1b57f62019-01-08 15:19:58 -08001530 boolean isCbrsSupported() {
1531 return getResources().getBoolean(
1532 com.android.internal.R.bool.config_cbrs_supported);
1533 }
1534
1535 void updateCbrsDataState(boolean state) {
1536 Log.d(TAG, "setCbrsDataSwitchState() state:" + ((state)? "on":"off"));
1537 if (mTelephonyManager != null) {
1538 QueuedWork.queue(new Runnable() {
1539 public void run() {
1540 mTelephonyManager.setOpportunisticNetworkState(state);
1541 cbrsDataSwitch.setChecked(getCbrsDataState());
1542 }
1543 }, false);
1544 }
1545 }
1546
1547 boolean getCbrsDataState() {
1548 boolean state = false;
1549 if (mTelephonyManager != null) {
1550 state = mTelephonyManager.isOpportunisticNetworkEnabled();
1551 }
1552 Log.d(TAG, "getCbrsDataState() state:" +((state)? "on":"off"));
1553 return state;
1554 }
1555
1556 OnCheckedChangeListener mCbrsDataSwitchChangeListener = new OnCheckedChangeListener() {
1557 @Override
1558 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1559 updateCbrsDataState(isChecked);
1560 }
1561 };
1562
Pengquan Meng7f602c72019-01-28 19:12:18 -08001563 private void showDsdsChangeDialog() {
1564 final AlertDialog confirmDialog = new Builder(RadioInfo.this)
1565 .setTitle(R.string.dsds_dialog_title)
1566 .setMessage(R.string.dsds_dialog_message)
1567 .setPositiveButton(R.string.dsds_dialog_confirm, mOnDsdsDialogConfirmedListener)
1568 .setNegativeButton(R.string.dsds_dialog_cancel, mOnDsdsDialogConfirmedListener)
1569 .create();
1570 confirmDialog.show();
1571 }
Naina Nallurid1b57f62019-01-08 15:19:58 -08001572
Pengquan Meng7f602c72019-01-28 19:12:18 -08001573 private static boolean isDsdsSupported() {
Michele3dafea22019-03-19 15:53:45 -07001574 return (TelephonyManager.getDefault().isMultiSimSupported()
1575 == TelephonyManager.MULTISIM_ALLOWED);
Pengquan Meng7f602c72019-01-28 19:12:18 -08001576 }
1577
1578 private static boolean isDsdsEnabled() {
1579 return TelephonyManager.getDefault().getPhoneCount() > 1;
1580 }
1581
1582 private void performDsdsSwitch() {
1583 mTelephonyManager.switchMultiSimConfig(dsdsSwitch.isChecked() ? 2 : 1);
1584 }
1585
1586 DialogInterface.OnClickListener mOnDsdsDialogConfirmedListener =
1587 new DialogInterface.OnClickListener() {
1588 @Override
1589 public void onClick(DialogInterface dialog, int which) {
1590 if (which == DialogInterface.BUTTON_POSITIVE) {
1591 dsdsSwitch.toggle();
1592 performDsdsSwitch();
1593 }
1594 }
1595 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001596}