blob: 0b7d1bea241e7c827234cad9103fcb8f59b399f6 [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;
Meng Wang586741c2017-04-26 15:02:51 -070044import android.telephony.CarrierConfigManager;
Fan Zhangc7162cd2018-06-18 15:21:41 -070045import android.telephony.CellIdentityCdma;
46import android.telephony.CellIdentityGsm;
47import android.telephony.CellIdentityLte;
48import android.telephony.CellIdentityWcdma;
Wink Saville79bff2a2012-06-01 14:37:21 -070049import android.telephony.CellInfo;
Nathan Haroldcea413a2015-11-23 15:48:10 -080050import android.telephony.CellInfoCdma;
51import android.telephony.CellInfoGsm;
52import android.telephony.CellInfoLte;
53import android.telephony.CellInfoWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080054import android.telephony.CellLocation;
Nathan Haroldcea413a2015-11-23 15:48:10 -080055import android.telephony.CellSignalStrengthCdma;
56import android.telephony.CellSignalStrengthGsm;
57import android.telephony.CellSignalStrengthLte;
58import android.telephony.CellSignalStrengthWcdma;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080059import android.telephony.PhoneStateListener;
Nathan Harold433ca442018-04-23 18:20:43 -070060import android.telephony.PhysicalChannelConfig;
Fan Zhangc7162cd2018-06-18 15:21:41 -070061import android.telephony.PreciseCallState;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080062import android.telephony.ServiceState;
Nathan Harold2b77d742016-03-19 13:22:10 -070063import android.telephony.SignalStrength;
Nathan Haroldcea413a2015-11-23 15:48:10 -080064import android.telephony.SubscriptionManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080065import android.telephony.TelephonyManager;
jsh534f5ae2009-09-24 09:19:22 -070066import android.telephony.cdma.CdmaCellLocation;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080067import android.telephony.gsm.GsmCellLocation;
Nathan Harold6e16fdf2018-04-17 17:01:32 -070068import android.text.TextUtils;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080069import android.util.Log;
70import android.view.Menu;
71import android.view.MenuItem;
72import android.view.View;
73import android.view.View.OnClickListener;
74import android.widget.AdapterView;
75import android.widget.ArrayAdapter;
76import android.widget.Button;
Nathan Harold2b77d742016-03-19 13:22:10 -070077import android.widget.CompoundButton;
78import android.widget.CompoundButton.OnCheckedChangeListener;
Jason Monk39b46742015-09-10 15:52:51 -040079import android.widget.EditText;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080080import android.widget.Spinner;
Nathan Harold2b77d742016-03-19 13:22:10 -070081import android.widget.Switch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080082import android.widget.TextView;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080083
Fan Zhang23f8d592018-08-28 15:11:40 -070084import androidx.appcompat.app.AlertDialog;
Pengquan Meng7f602c72019-01-28 19:12:18 -080085import androidx.appcompat.app.AlertDialog.Builder;
Fan Zhang23f8d592018-08-28 15:11:40 -070086
Jason Monk39b46742015-09-10 15:52:51 -040087import com.android.ims.ImsConfig;
88import com.android.ims.ImsException;
89import com.android.ims.ImsManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080090import com.android.internal.telephony.Phone;
91import com.android.internal.telephony.PhoneFactory;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080092
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080093import java.io.IOException;
Jason Monk39b46742015-09-10 15:52:51 -040094import java.net.HttpURLConnection;
95import java.net.URL;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080096import java.util.List;
97
Pengquan Meng7f602c72019-01-28 19:12:18 -080098// TODO(b/123598192) consider to move this activity to telephony package.
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080099public class RadioInfo extends Activity {
Nathan Harold2b77d742016-03-19 13:22:10 -0700100 private static final String TAG = "RadioInfo";
johnwang342101a2009-09-23 16:22:34 -0700101
Nathan Harold2b77d742016-03-19 13:22:10 -0700102 private static final String[] mPreferredNetworkLabels = {
103 "WCDMA preferred",
104 "GSM only",
105 "WCDMA only",
106 "GSM auto (PRL)",
107 "CDMA auto (PRL)",
108 "CDMA only",
109 "EvDo only",
110 "Global auto (PRL)",
111 "LTE/CDMA auto (PRL)",
112 "LTE/UMTS auto (PRL)",
113 "LTE/CDMA/UMTS auto (PRL)",
114 "LTE only",
115 "LTE/WCDMA",
116 "TD-SCDMA only",
117 "TD-SCDMA/WCDMA",
118 "LTE/TD-SCDMA",
119 "TD-SCDMA/GSM",
120 "TD-SCDMA/UMTS",
121 "LTE/TD-SCDMA/WCDMA",
122 "LTE/TD-SCDMA/UMTS",
123 "TD-SCDMA/CDMA/UMTS",
124 "Global/TD-SCDMA",
125 "Unknown"
126 };
127
128
129 private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE;
130 private static final int CELL_INFO_LIST_RATE_MAX = 0;
131
Nathan Harold12e1f552016-06-17 13:55:38 -0700132
133 private static final int IMS_VOLTE_PROVISIONED_CONFIG_ID =
134 ImsConfig.ConfigConstants.VLT_SETTING_ENABLED;
135
136 private static final int IMS_VT_PROVISIONED_CONFIG_ID =
137 ImsConfig.ConfigConstants.LVC_SETTING_ENABLED;
138
139 private static final int IMS_WFC_PROVISIONED_CONFIG_ID =
140 ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED;
141
Meng Wang586741c2017-04-26 15:02:51 -0700142 private static final int EAB_PROVISIONED_CONFIG_ID =
143 ImsConfig.ConfigConstants.EAB_SETTING_ENABLED;
144
Nathan Harold2b77d742016-03-19 13:22:10 -0700145 //Values in must match mCellInfoRefreshRates
146 private static final String[] mCellInfoRefreshRateLabels = {
147 "Disabled",
148 "Immediate",
149 "Min 5s",
150 "Min 10s",
151 "Min 60s"
152 };
153
154 //Values in seconds, must match mCellInfoRefreshRateLabels
155 private static final int mCellInfoRefreshRates[] = {
156 CELL_INFO_LIST_RATE_DISABLED,
157 CELL_INFO_LIST_RATE_MAX,
158 5000,
159 10000,
160 60000
161 };
162
163 private void log(String s) {
164 Log.d(TAG, s);
165 }
166
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800167 private static final int EVENT_CFI_CHANGED = 302;
168
169 private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000;
170 private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800171 private static final int EVENT_QUERY_SMSC_DONE = 1005;
172 private static final int EVENT_UPDATE_SMSC_DONE = 1006;
173
174 private static final int MENU_ITEM_SELECT_BAND = 0;
175 private static final int MENU_ITEM_VIEW_ADN = 1;
176 private static final int MENU_ITEM_VIEW_FDN = 2;
177 private static final int MENU_ITEM_VIEW_SDN = 3;
Nathan Harolde272c202016-10-27 13:45:00 -0700178 private static final int MENU_ITEM_GET_IMS_STATUS = 4;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800179 private static final int MENU_ITEM_TOGGLE_DATA = 5;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800180
Wink Savillec3886682009-04-02 11:00:56 -0700181 private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800182 private TextView number;
Meng Wang9053f172017-06-23 16:02:14 -0700183 private TextView mSubscriberId;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800184 private TextView callState;
185 private TextView operatorName;
186 private TextView roamingState;
187 private TextView gsmState;
188 private TextView gprsState;
Nathan Harold2b77d742016-03-19 13:22:10 -0700189 private TextView voiceNetwork;
190 private TextView dataNetwork;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800191 private TextView dBm;
192 private TextView mMwi;
193 private TextView mCfi;
194 private TextView mLocation;
Wink Saville79bff2a2012-06-01 14:37:21 -0700195 private TextView mCellInfo;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800196 private TextView sent;
197 private TextView received;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800198 private TextView mPingHostnameV4;
199 private TextView mPingHostnameV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800200 private TextView mHttpClientTest;
Nathan Harold433ca442018-04-23 18:20:43 -0700201 private TextView mPhyChanConfig;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800202 private TextView dnsCheckState;
Nathan Haroldf10ea322018-04-24 13:31:07 -0700203 private TextView mDownlinkKbps;
204 private TextView mUplinkKbps;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800205 private EditText smsc;
Nathan Harold2b77d742016-03-19 13:22:10 -0700206 private Switch radioPowerOnSwitch;
207 private Button cellInfoRefreshRateButton;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800208 private Button dnsCheckToggleButton;
209 private Button pingTestButton;
210 private Button updateSmscButton;
211 private Button refreshSmscButton;
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800212 private Button oemInfoButton;
Youhan Wangfd781e92016-12-16 15:53:16 -0800213 private Button carrierProvisioningButton;
214 private Button triggercarrierProvisioningButton;
Nathan Harold12e1f552016-06-17 13:55:38 -0700215 private Switch imsVolteProvisionedSwitch;
216 private Switch imsVtProvisionedSwitch;
217 private Switch imsWfcProvisionedSwitch;
Meng Wang586741c2017-04-26 15:02:51 -0700218 private Switch eabProvisionedSwitch;
Naina Nallurid1b57f62019-01-08 15:19:58 -0800219 private Switch cbrsDataSwitch;
Pengquan Meng7f602c72019-01-28 19:12:18 -0800220 private Switch dsdsSwitch;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800221 private Spinner preferredNetworkType;
Nathan Harold2b77d742016-03-19 13:22:10 -0700222 private Spinner cellInfoRefreshRateSpinner;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800223
Nathan Haroldf10ea322018-04-24 13:31:07 -0700224 private ConnectivityManager mConnectivityManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800225 private TelephonyManager mTelephonyManager;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800226 private ImsManager mImsManager = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800227 private Phone phone = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800228
Nathan Haroldcea413a2015-11-23 15:48:10 -0800229 private String mPingHostnameResultV4;
230 private String mPingHostnameResultV6;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800231 private String mHttpClientTestResult;
232 private boolean mMwiValue = false;
233 private boolean mCfiValue = false;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800234
235 private List<CellInfo> mCellInfoResult = null;
236 private CellLocation mCellLocationResult = null;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800237
238 private int mPreferredNetworkTypeResult;
Nathan Harold2b77d742016-03-19 13:22:10 -0700239 private int mCellInfoRefreshRateIndex;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800240
Nathan Haroldf10ea322018-04-24 13:31:07 -0700241 private final NetworkRequest mDefaultNetworkRequest = new NetworkRequest.Builder()
242 .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
243 .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
244 .build();
245
246 private final NetworkCallback mNetworkCallback = new NetworkCallback() {
247 public void onCapabilitiesChanged(Network n, NetworkCapabilities nc) {
248 int dlbw = nc.getLinkDownstreamBandwidthKbps();
249 int ulbw = nc.getLinkUpstreamBandwidthKbps();
250 updateBandwidths(dlbw, ulbw);
251 }
252 };
253
Nathan Harold2b77d742016-03-19 13:22:10 -0700254 private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800255 @Override
256 public void onDataConnectionStateChanged(int state) {
257 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800258 updateNetworkType();
259 }
260
261 @Override
262 public void onDataActivity(int direction) {
263 updateDataStats2();
264 }
265
266 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700267 public void onCallStateChanged(int state, String incomingNumber) {
268 updateNetworkType();
269 updatePhoneState(state);
270 }
271
272 @Override
273 public void onPreciseCallStateChanged(PreciseCallState preciseState) {
274 updateNetworkType();
275 }
276
277 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800278 public void onCellLocationChanged(CellLocation location) {
279 updateLocation(location);
280 }
281
282 @Override
283 public void onMessageWaitingIndicatorChanged(boolean mwi) {
284 mMwiValue = mwi;
285 updateMessageWaiting();
286 }
287
288 @Override
289 public void onCallForwardingIndicatorChanged(boolean cfi) {
290 mCfiValue = cfi;
291 updateCallRedirect();
292 }
Wink Saville79bff2a2012-06-01 14:37:21 -0700293
294 @Override
295 public void onCellInfoChanged(List<CellInfo> arrayCi) {
Wink Savillebf471282013-04-05 15:04:05 -0700296 log("onCellInfoChanged: arrayCi=" + arrayCi);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800297 mCellInfoResult = arrayCi;
298 updateCellInfo(mCellInfoResult);
Wink Saville79bff2a2012-06-01 14:37:21 -0700299 }
Wink Saville4f0d8812014-04-15 22:05:24 -0700300
301 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -0700302 public void onSignalStrengthsChanged(SignalStrength signalStrength) {
303 log("onSignalStrengthChanged: SignalStrength=" +signalStrength);
304 updateSignalStrength(signalStrength);
305 }
306
307 @Override
308 public void onServiceStateChanged(ServiceState serviceState) {
309 log("onServiceStateChanged: ServiceState=" + serviceState);
310 updateServiceState(serviceState);
311 updateRadioPowerState();
312 updateNetworkType();
Nathan Harold12e1f552016-06-17 13:55:38 -0700313 updateImsProvisionedState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700314 }
Nathan Harold433ca442018-04-23 18:20:43 -0700315
316 @Override
317 public void onPhysicalChannelConfigurationChanged(
318 List<PhysicalChannelConfig> configs) {
319 updatePhysicalChannelConfiguration(configs);
320 }
321
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800322 };
323
Nathan Harold433ca442018-04-23 18:20:43 -0700324 private void updatePhysicalChannelConfiguration(List<PhysicalChannelConfig> configs) {
325 StringBuilder sb = new StringBuilder();
326 String div = "";
327 sb.append("{");
328 if (configs != null) {
329 for(PhysicalChannelConfig c : configs) {
330 sb.append(div).append(c);
331 div = ",";
332 }
333 }
334 sb.append("}");
335 mPhyChanConfig.setText(sb.toString());
336 }
337
Nathan Haroldcea413a2015-11-23 15:48:10 -0800338 private void updatePreferredNetworkType(int type) {
339 if (type >= mPreferredNetworkLabels.length || type < 0) {
340 log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " +
341 "type=" + type);
342 type = mPreferredNetworkLabels.length - 1; //set to Unknown
343 }
344 mPreferredNetworkTypeResult = type;
345
346 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
347 }
348
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800349 private Handler mHandler = new Handler() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800350 @Override
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800351 public void handleMessage(Message msg) {
352 AsyncResult ar;
353 switch (msg.what) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800354 case EVENT_QUERY_PREFERRED_TYPE_DONE:
355 ar= (AsyncResult) msg.obj;
Nathan Haroldcea413a2015-11-23 15:48:10 -0800356 if (ar.exception == null && ar.result != null) {
357 updatePreferredNetworkType(((int[])ar.result)[0]);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800358 } else {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800359 //In case of an exception, we will set this to unknown
360 updatePreferredNetworkType(mPreferredNetworkLabels.length-1);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800361 }
362 break;
363 case EVENT_SET_PREFERRED_TYPE_DONE:
364 ar= (AsyncResult) msg.obj;
365 if (ar.exception != null) {
Nathan Harolded38afa2016-04-13 00:29:30 -0700366 log("Set preferred network type failed.");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800367 }
368 break;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800369 case EVENT_QUERY_SMSC_DONE:
370 ar= (AsyncResult) msg.obj;
371 if (ar.exception != null) {
372 smsc.setText("refresh error");
373 } else {
jsh21dd4072009-05-12 11:26:55 -0700374 smsc.setText((String)ar.result);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800375 }
376 break;
377 case EVENT_UPDATE_SMSC_DONE:
378 updateSmscButton.setEnabled(true);
379 ar= (AsyncResult) msg.obj;
380 if (ar.exception != null) {
381 smsc.setText("update error");
382 }
383 break;
384 default:
Nathan Haroldcea413a2015-11-23 15:48:10 -0800385 super.handleMessage(msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800386 break;
387
388 }
389 }
390 };
391
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800392 @Override
393 public void onCreate(Bundle icicle) {
394 super.onCreate(icicle);
fionaxub54cb2d2016-09-22 15:01:05 -0700395 if (!android.os.Process.myUserHandle().isSystem()) {
396 Log.e(TAG, "Not run from system user, don't do anything.");
397 finish();
398 return;
399 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800400
401 setContentView(R.layout.radio_info);
402
Nathan Haroldcea413a2015-11-23 15:48:10 -0800403 log("Started onCreate");
404
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800405 mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
Nathan Haroldf10ea322018-04-24 13:31:07 -0700406 mConnectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800407 phone = PhoneFactory.getDefaultPhone();
408
Nathan Haroldcea413a2015-11-23 15:48:10 -0800409 //TODO: Need to update this if the default phoneId changes?
410 // Better to have an instance per phone?
411 mImsManager = ImsManager.getInstance(getApplicationContext(),
412 SubscriptionManager.getDefaultVoicePhoneId());
413
Meng Wang9053f172017-06-23 16:02:14 -0700414 mDeviceId = (TextView) findViewById(R.id.imei);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800415 number = (TextView) findViewById(R.id.number);
Meng Wang9053f172017-06-23 16:02:14 -0700416 mSubscriberId = (TextView) findViewById(R.id.imsi);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800417 callState = (TextView) findViewById(R.id.call);
418 operatorName = (TextView) findViewById(R.id.operator);
419 roamingState = (TextView) findViewById(R.id.roaming);
420 gsmState = (TextView) findViewById(R.id.gsm);
421 gprsState = (TextView) findViewById(R.id.gprs);
Nathan Harold2b77d742016-03-19 13:22:10 -0700422 voiceNetwork = (TextView) findViewById(R.id.voice_network);
423 dataNetwork = (TextView) findViewById(R.id.data_network);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800424 dBm = (TextView) findViewById(R.id.dbm);
425 mMwi = (TextView) findViewById(R.id.mwi);
426 mCfi = (TextView) findViewById(R.id.cfi);
427 mLocation = (TextView) findViewById(R.id.location);
Wink Saville79bff2a2012-06-01 14:37:21 -0700428 mCellInfo = (TextView) findViewById(R.id.cellinfo);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800429 mCellInfo.setTypeface(Typeface.MONOSPACE);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800430
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800431 sent = (TextView) findViewById(R.id.sent);
432 received = (TextView) findViewById(R.id.received);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800433 smsc = (EditText) findViewById(R.id.smsc);
434 dnsCheckState = (TextView) findViewById(R.id.dnsCheckState);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800435 mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4);
436 mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800437 mHttpClientTest = (TextView) findViewById(R.id.httpClientTest);
438
Nathan Harold433ca442018-04-23 18:20:43 -0700439 mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config);
440
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800441 preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
442 ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
443 android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
johnwang342101a2009-09-23 16:22:34 -0700444 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800445 preferredNetworkType.setAdapter(adapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800446
Nathan Harold2b77d742016-03-19 13:22:10 -0700447 cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select);
448 ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this,
449 android.R.layout.simple_spinner_item, mCellInfoRefreshRateLabels);
450 cellInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
451 cellInfoRefreshRateSpinner.setAdapter(cellInfoAdapter);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800452
Nathan Harold12e1f552016-06-17 13:55:38 -0700453 imsVolteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch);
454 imsVtProvisionedSwitch = (Switch) findViewById(R.id.vt_provisioned_switch);
455 imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
Meng Wang69439b52017-05-01 08:31:14 -0700456 eabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch);
Wink Savillebf471282013-04-05 15:04:05 -0700457
Brad Ebinger5dfe7f82019-03-11 17:33:53 -0700458 if (!ImsManager.isImsSupportedOnDevice(phone.getContext())) {
459 imsVolteProvisionedSwitch.setVisibility(View.GONE);
460 imsVtProvisionedSwitch.setVisibility(View.GONE);
461 imsWfcProvisionedSwitch.setVisibility(View.GONE);
462 eabProvisionedSwitch.setVisibility(View.GONE);
463 }
464
Naina Nallurid1b57f62019-01-08 15:19:58 -0800465 cbrsDataSwitch = (Switch) findViewById(R.id.cbrs_data_switch);
466 cbrsDataSwitch.setVisibility(isCbrsSupported() ? View.VISIBLE : View.GONE);
467
Pengquan Meng7f602c72019-01-28 19:12:18 -0800468 dsdsSwitch = findViewById(R.id.dsds_switch);
469 if (isDsdsSupported()) {
470 dsdsSwitch.setVisibility(View.VISIBLE);
471 dsdsSwitch.setOnClickListener(v -> {
chen xu4f379d22019-04-03 10:31:19 -0700472 if (mTelephonyManager.doesSwitchMultiSimConfigTriggerReboot()) {
Pengquan Meng7f602c72019-01-28 19:12:18 -0800473 // Undo the click action until user clicks the confirm dialog.
474 dsdsSwitch.toggle();
475 showDsdsChangeDialog();
476 } else {
477 performDsdsSwitch();
478 }
479 });
480 dsdsSwitch.setChecked(isDsdsEnabled());
481 } else {
482 dsdsSwitch.setVisibility(View.GONE);
483 }
484
Nathan Harold2b77d742016-03-19 13:22:10 -0700485 radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
Wink Saville426fc662011-09-25 14:39:02 -0700486
Nathan Haroldf10ea322018-04-24 13:31:07 -0700487 mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
488 mUplinkKbps = (TextView) findViewById(R.id.ul_kbps);
489 updateBandwidths(0, 0);
490
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800491 pingTestButton = (Button) findViewById(R.id.ping_test);
492 pingTestButton.setOnClickListener(mPingButtonHandler);
493 updateSmscButton = (Button) findViewById(R.id.update_smsc);
494 updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler);
495 refreshSmscButton = (Button) findViewById(R.id.refresh_smsc);
496 refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler);
497 dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle);
498 dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler);
Youhan Wangfd781e92016-12-16 15:53:16 -0800499 carrierProvisioningButton = (Button) findViewById(R.id.carrier_provisioning);
500 carrierProvisioningButton.setOnClickListener(mCarrierProvisioningButtonHandler);
501 triggercarrierProvisioningButton = (Button) findViewById(R.id.trigger_carrier_provisioning);
502 triggercarrierProvisioningButton.setOnClickListener(
503 mTriggerCarrierProvisioningButtonHandler);
johnwang342101a2009-09-23 16:22:34 -0700504
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +0800505 oemInfoButton = (Button) findViewById(R.id.oem_info);
506 oemInfoButton.setOnClickListener(mOemInfoButtonHandler);
507 PackageManager pm = getPackageManager();
508 Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO");
509 List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0);
510 if (oemInfoIntentList.size() == 0) {
511 oemInfoButton.setEnabled(false);
512 }
513
Nathan Harolded38afa2016-04-13 00:29:30 -0700514 mCellInfoRefreshRateIndex = 0; //disabled
Nathan Haroldcea413a2015-11-23 15:48:10 -0800515 mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown
516
517 //FIXME: Replace with TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800518 phone.getPreferredNetworkType(
519 mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800520
Nathan Haroldcea413a2015-11-23 15:48:10 -0800521 restoreFromBundle(icicle);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800522 }
523
524 @Override
525 protected void onResume() {
526 super.onResume();
527
Nathan Haroldcea413a2015-11-23 15:48:10 -0800528 log("Started onResume");
529
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800530 updateMessageWaiting();
531 updateCallRedirect();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800532 updateDataState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800533 updateDataStats2();
Nathan Harold2b77d742016-03-19 13:22:10 -0700534 updateRadioPowerState();
Nathan Harold12e1f552016-06-17 13:55:38 -0700535 updateImsProvisionedState();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800536 updateProperties();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800537 updateDnsCheckState();
Nathan Harold2b77d742016-03-19 13:22:10 -0700538 updateNetworkType();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800539
Nathan Haroldcea413a2015-11-23 15:48:10 -0800540 updateLocation(mCellLocationResult);
541 updateCellInfo(mCellInfoResult);
542
543 mPingHostnameV4.setText(mPingHostnameResultV4);
544 mPingHostnameV6.setText(mPingHostnameResultV6);
545 mHttpClientTest.setText(mHttpClientTestResult);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800546
Nathan Harold2b77d742016-03-19 13:22:10 -0700547 cellInfoRefreshRateSpinner.setOnItemSelectedListener(mCellInfoRefreshRateHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700548 //set selection after registering listener to force update
549 cellInfoRefreshRateSpinner.setSelection(mCellInfoRefreshRateIndex);
550
551 //set selection before registering to prevent update
552 preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
Nathan Harold2b77d742016-03-19 13:22:10 -0700553 preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
Nathan Harolded38afa2016-04-13 00:29:30 -0700554
Nathan Harold2b77d742016-03-19 13:22:10 -0700555 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
Nathan Harold12e1f552016-06-17 13:55:38 -0700556 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
557 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
558 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Meng Wang586741c2017-04-26 15:02:51 -0700559 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
Nathan Harold2b77d742016-03-19 13:22:10 -0700560
Naina Nallurid1b57f62019-01-08 15:19:58 -0800561 if (isCbrsSupported()) {
562 cbrsDataSwitch.setChecked(getCbrsDataState());
563 cbrsDataSwitch.setOnCheckedChangeListener(mCbrsDataSwitchChangeListener);
564 }
565
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800566 mTelephonyManager.listen(mPhoneStateListener,
Nathan Harold2b77d742016-03-19 13:22:10 -0700567 PhoneStateListener.LISTEN_CALL_STATE
568 //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
569 // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
570 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800571 | PhoneStateListener.LISTEN_DATA_ACTIVITY
572 | PhoneStateListener.LISTEN_CELL_LOCATION
573 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
Wink Saville79bff2a2012-06-01 14:37:21 -0700574 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
Wink Saville4f0d8812014-04-15 22:05:24 -0700575 | PhoneStateListener.LISTEN_CELL_INFO
Nathan Harold2b77d742016-03-19 13:22:10 -0700576 | PhoneStateListener.LISTEN_SERVICE_STATE
577 | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
Nathan Harold433ca442018-04-23 18:20:43 -0700578 | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION);
Nathan Harolded38afa2016-04-13 00:29:30 -0700579
Nathan Haroldf10ea322018-04-24 13:31:07 -0700580 mConnectivityManager.registerNetworkCallback(
581 mDefaultNetworkRequest, mNetworkCallback, mHandler);
582
Nathan Harolded38afa2016-04-13 00:29:30 -0700583 smsc.clearFocus();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800584 }
585
586 @Override
Nathan Haroldcea413a2015-11-23 15:48:10 -0800587 protected void onPause() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800588 super.onPause();
589
Wink Savillebf471282013-04-05 15:04:05 -0700590 log("onPause: unregister phone & data intents");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800591
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800592 mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -0700593 mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
Nathan Haroldf10ea322018-04-24 13:31:07 -0700594 mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
595
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800596 }
597
Nathan Haroldcea413a2015-11-23 15:48:10 -0800598 private void restoreFromBundle(Bundle b) {
Nathan Harolde272c202016-10-27 13:45:00 -0700599 if(b == null) {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800600 return;
601 }
602
603 mPingHostnameResultV4 = b.getString("mPingHostnameResultV4","");
604 mPingHostnameResultV6 = b.getString("mPingHostnameResultV6","");
605 mHttpClientTestResult = b.getString("mHttpClientTestResult","");
606
607 mPingHostnameV4.setText(mPingHostnameResultV4);
608 mPingHostnameV6.setText(mPingHostnameResultV6);
609 mHttpClientTest.setText(mHttpClientTestResult);
610
Nathan Harold2b77d742016-03-19 13:22:10 -0700611 mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult",
612 mPreferredNetworkLabels.length - 1);
613
614 mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0);
Nathan Haroldcea413a2015-11-23 15:48:10 -0800615 }
616
617 @Override
618 protected void onSaveInstanceState(Bundle outState) {
619 outState.putString("mPingHostnameResultV4", mPingHostnameResultV4);
620 outState.putString("mPingHostnameResultV6", mPingHostnameResultV6);
621 outState.putString("mHttpClientTestResult", mHttpClientTestResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700622
Nathan Haroldcea413a2015-11-23 15:48:10 -0800623 outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult);
Nathan Harold2b77d742016-03-19 13:22:10 -0700624 outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex);
625
Nathan Haroldcea413a2015-11-23 15:48:10 -0800626 }
627
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800628 @Override
629 public boolean onCreateOptionsMenu(Menu menu) {
Wink Savillec3886682009-04-02 11:00:56 -0700630 menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label)
631 .setOnMenuItemClickListener(mSelectBandCallback)
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800632 .setAlphabeticShortcut('b');
633 menu.add(1, MENU_ITEM_VIEW_ADN, 0,
634 R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback);
635 menu.add(1, MENU_ITEM_VIEW_FDN, 0,
636 R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback);
637 menu.add(1, MENU_ITEM_VIEW_SDN, 0,
638 R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback);
Brad Ebinger5dfe7f82019-03-11 17:33:53 -0700639 if (ImsManager.isImsSupportedOnDevice(phone.getContext())) {
640 menu.add(1, MENU_ITEM_GET_IMS_STATUS,
641 0, R.string.radioInfo_menu_getIMS).setOnMenuItemClickListener(mGetImsStatus);
642 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800643 menu.add(1, MENU_ITEM_TOGGLE_DATA,
Nathan Harold2b77d742016-03-19 13:22:10 -0700644 0, R.string.radio_info_data_connection_disable).setOnMenuItemClickListener(mToggleData);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800645 return true;
646 }
647
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800648 @Override
Wink Savillec3886682009-04-02 11:00:56 -0700649 public boolean onPrepareOptionsMenu(Menu menu) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800650 // Get the TOGGLE DATA menu item in the right state.
651 MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA);
652 int state = mTelephonyManager.getDataState();
653 boolean visible = true;
654
655 switch (state) {
656 case TelephonyManager.DATA_CONNECTED:
657 case TelephonyManager.DATA_SUSPENDED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700658 item.setTitle(R.string.radio_info_data_connection_disable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800659 break;
660 case TelephonyManager.DATA_DISCONNECTED:
Nathan Harold2b77d742016-03-19 13:22:10 -0700661 item.setTitle(R.string.radio_info_data_connection_enable);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800662 break;
663 default:
664 visible = false;
665 break;
666 }
667 item.setVisible(visible);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800668 return true;
669 }
670
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800671 private void updateDnsCheckState() {
Nathan Haroldcea413a2015-11-23 15:48:10 -0800672 //FIXME: Replace with a TelephonyManager call
Mike Lockwood5304c7e2009-04-05 11:37:45 -0700673 dnsCheckState.setText(phone.isDnsCheckDisabled() ?
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800674 "0.0.0.0 allowed" :"0.0.0.0 not allowed");
675 }
Wink Savillee2a14e32009-05-29 14:06:30 -0700676
Nathan Haroldf10ea322018-04-24 13:31:07 -0700677 private void updateBandwidths(int dlbw, int ulbw) {
678 dlbw = (dlbw < 0 || dlbw == Integer.MAX_VALUE) ? -1 : dlbw;
679 ulbw = (ulbw < 0 || ulbw == Integer.MAX_VALUE) ? -1 : ulbw;
680 mDownlinkKbps.setText(String.format("%-5d", dlbw));
681 mUplinkKbps.setText(String.format("%-5d", ulbw));
682 }
683
684
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800685 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700686 updateSignalStrength(SignalStrength signalStrength) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800687 Resources r = getResources();
688
Nathan Harold2b77d742016-03-19 13:22:10 -0700689 int signalDbm = signalStrength.getDbm();
Wink Savillee2a14e32009-05-29 14:06:30 -0700690
Nathan Harold2b77d742016-03-19 13:22:10 -0700691 int signalAsu = signalStrength.getAsuLevel();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800692
693 if (-1 == signalAsu) signalAsu = 0;
694
695 dBm.setText(String.valueOf(signalDbm) + " "
696 + r.getString(R.string.radioInfo_display_dbm) + " "
697 + String.valueOf(signalAsu) + " "
698 + r.getString(R.string.radioInfo_display_asu));
699 }
700
701 private final void updateLocation(CellLocation location) {
jsh534f5ae2009-09-24 09:19:22 -0700702 Resources r = getResources();
Wink Savillec3886682009-04-02 11:00:56 -0700703 if (location instanceof GsmCellLocation) {
704 GsmCellLocation loc = (GsmCellLocation)location;
jsh534f5ae2009-09-24 09:19:22 -0700705 int lac = loc.getLac();
706 int cid = loc.getCid();
707 mLocation.setText(r.getString(R.string.radioInfo_lac) + " = "
708 + ((lac == -1) ? "unknown" : Integer.toHexString(lac))
709 + " "
710 + r.getString(R.string.radioInfo_cid) + " = "
711 + ((cid == -1) ? "unknown" : Integer.toHexString(cid)));
712 } else if (location instanceof CdmaCellLocation) {
713 CdmaCellLocation loc = (CdmaCellLocation)location;
714 int bid = loc.getBaseStationId();
715 int sid = loc.getSystemId();
716 int nid = loc.getNetworkId();
717 int lat = loc.getBaseStationLatitude();
718 int lon = loc.getBaseStationLongitude();
719 mLocation.setText("BID = "
720 + ((bid == -1) ? "unknown" : Integer.toHexString(bid))
721 + " "
722 + "SID = "
723 + ((sid == -1) ? "unknown" : Integer.toHexString(sid))
724 + " "
725 + "NID = "
726 + ((nid == -1) ? "unknown" : Integer.toHexString(nid))
727 + "\n"
728 + "LAT = "
729 + ((lat == -1) ? "unknown" : Integer.toHexString(lat))
730 + " "
731 + "LONG = "
732 + ((lon == -1) ? "unknown" : Integer.toHexString(lon)));
733 } else {
734 mLocation.setText("unknown");
Wink Savillec3886682009-04-02 11:00:56 -0700735 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800736
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800737
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800738 }
739
Nathan Haroldcea413a2015-11-23 15:48:10 -0800740 private final String getCellInfoDisplayString(int i) {
741 return (i != Integer.MAX_VALUE) ? Integer.toString(i) : "";
742 }
743
744 private final String getCellInfoDisplayString(long i) {
745 return (i != Long.MAX_VALUE) ? Long.toString(i) : "";
746 }
747
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700748 private final String getConnectionStatusString(CellInfo ci) {
749 String regStr = "";
750 String connStatStr = "";
751 String connector = "";
752
753 if (ci.isRegistered()) {
754 regStr = "R";
755 }
756 switch (ci.getCellConnectionStatus()) {
757 case CellInfo.CONNECTION_PRIMARY_SERVING: connStatStr = "P"; break;
758 case CellInfo.CONNECTION_SECONDARY_SERVING: connStatStr = "S"; break;
759 case CellInfo.CONNECTION_NONE: connStatStr = "N"; break;
760 case CellInfo.CONNECTION_UNKNOWN: /* Field is unsupported */ break;
761 default: break;
762 }
763 if (!TextUtils.isEmpty(regStr) && !TextUtils.isEmpty(connStatStr)) {
764 connector = "+";
765 }
766
767 return regStr + connector + connStatStr;
768 }
769
Nathan Haroldcea413a2015-11-23 15:48:10 -0800770 private final String buildCdmaInfoString(CellInfoCdma ci) {
771 CellIdentityCdma cidCdma = ci.getCellIdentity();
772 CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength();
773
774 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 -0700775 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800776 getCellInfoDisplayString(cidCdma.getSystemId()),
777 getCellInfoDisplayString(cidCdma.getNetworkId()),
778 getCellInfoDisplayString(cidCdma.getBasestationId()),
779 getCellInfoDisplayString(ssCdma.getCdmaDbm()),
780 getCellInfoDisplayString(ssCdma.getCdmaEcio()),
781 getCellInfoDisplayString(ssCdma.getEvdoDbm()),
782 getCellInfoDisplayString(ssCdma.getEvdoEcio()),
783 getCellInfoDisplayString(ssCdma.getEvdoSnr()));
784 }
785
786 private final String buildGsmInfoString(CellInfoGsm ci) {
787 CellIdentityGsm cidGsm = ci.getCellIdentity();
788 CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
789
Nathan Harold2b77d742016-03-19 13:22:10 -0700790 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 -0700791 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800792 getCellInfoDisplayString(cidGsm.getMcc()),
793 getCellInfoDisplayString(cidGsm.getMnc()),
794 getCellInfoDisplayString(cidGsm.getLac()),
795 getCellInfoDisplayString(cidGsm.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700796 getCellInfoDisplayString(cidGsm.getArfcn()),
797 getCellInfoDisplayString(cidGsm.getBsic()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800798 getCellInfoDisplayString(ssGsm.getDbm()));
799 }
800
801 private final String buildLteInfoString(CellInfoLte ci) {
802 CellIdentityLte cidLte = ci.getCellIdentity();
803 CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
804
805 return String.format(
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700806 "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
807 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800808 getCellInfoDisplayString(cidLte.getMcc()),
809 getCellInfoDisplayString(cidLte.getMnc()),
810 getCellInfoDisplayString(cidLte.getTac()),
811 getCellInfoDisplayString(cidLte.getCi()),
812 getCellInfoDisplayString(cidLte.getPci()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700813 getCellInfoDisplayString(cidLte.getEarfcn()),
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700814 getCellInfoDisplayString(cidLte.getBandwidth()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800815 getCellInfoDisplayString(ssLte.getDbm()),
816 getCellInfoDisplayString(ssLte.getRsrq()),
817 getCellInfoDisplayString(ssLte.getTimingAdvance()));
818 }
819
820 private final String buildWcdmaInfoString(CellInfoWcdma ci) {
821 CellIdentityWcdma cidWcdma = ci.getCellIdentity();
822 CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength();
823
Nathan Harold2b77d742016-03-19 13:22:10 -0700824 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 -0700825 getConnectionStatusString(ci),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800826 getCellInfoDisplayString(cidWcdma.getMcc()),
827 getCellInfoDisplayString(cidWcdma.getMnc()),
828 getCellInfoDisplayString(cidWcdma.getLac()),
829 getCellInfoDisplayString(cidWcdma.getCid()),
Nathan Harold2b77d742016-03-19 13:22:10 -0700830 getCellInfoDisplayString(cidWcdma.getUarfcn()),
Nathan Haroldcea413a2015-11-23 15:48:10 -0800831 getCellInfoDisplayString(cidWcdma.getPsc()),
832 getCellInfoDisplayString(ssWcdma.getDbm()));
833 }
834
835 private final String buildCellInfoString(List<CellInfo> arrayCi) {
836 String value = new String();
837 StringBuilder cdmaCells = new StringBuilder(),
838 gsmCells = new StringBuilder(),
839 lteCells = new StringBuilder(),
840 wcdmaCells = new StringBuilder();
841
842 if (arrayCi != null) {
843 for (CellInfo ci : arrayCi) {
844
845 if (ci instanceof CellInfoLte) {
846 lteCells.append(buildLteInfoString((CellInfoLte) ci));
847 } else if (ci instanceof CellInfoWcdma) {
848 wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
849 } else if (ci instanceof CellInfoGsm) {
850 gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
851 } else if (ci instanceof CellInfoCdma) {
852 cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
Wink Saville79bff2a2012-06-01 14:37:21 -0700853 }
854 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800855 if (lteCells.length() != 0) {
856 value += String.format(
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700857 "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s"
858 + " %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n",
859 "SRV", "MCC", "MNC", "TAC", "CID", "PCI",
860 "EARFCN", "BW", "RSRP", "RSRQ", "TA");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800861 value += lteCells.toString();
862 }
863 if (wcdmaCells.length() != 0) {
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700864 value += String.format(
865 "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 -0700866 "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800867 value += wcdmaCells.toString();
868 }
869 if (gsmCells.length() != 0) {
Nathan Harold6e16fdf2018-04-17 17:01:32 -0700870 value += String.format(
871 "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 -0700872 "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
Nathan Haroldcea413a2015-11-23 15:48:10 -0800873 value += gsmCells.toString();
874 }
875 if (cdmaCells.length() != 0) {
876 value += String.format(
877 "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n",
878 "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
879 value += cdmaCells.toString();
880 }
881 } else {
882 value ="unknown";
Wink Saville79bff2a2012-06-01 14:37:21 -0700883 }
Nathan Haroldcea413a2015-11-23 15:48:10 -0800884
885 return value.toString();
886 }
887
888 private final void updateCellInfo(List<CellInfo> arrayCi) {
889 mCellInfo.setText(buildCellInfoString(arrayCi));
Wink Saville79bff2a2012-06-01 14:37:21 -0700890 }
891
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800892 private final void
893 updateMessageWaiting() {
894 mMwi.setText(String.valueOf(mMwiValue));
895 }
896
897 private final void
898 updateCallRedirect() {
899 mCfi.setText(String.valueOf(mCfiValue));
900 }
901
902
903 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700904 updateServiceState(ServiceState serviceState) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800905 int state = serviceState.getState();
906 Resources r = getResources();
907 String display = r.getString(R.string.radioInfo_unknown);
johnwang342101a2009-09-23 16:22:34 -0700908
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800909 switch (state) {
910 case ServiceState.STATE_IN_SERVICE:
911 display = r.getString(R.string.radioInfo_service_in);
912 break;
913 case ServiceState.STATE_OUT_OF_SERVICE:
914 case ServiceState.STATE_EMERGENCY_ONLY:
915 display = r.getString(R.string.radioInfo_service_emergency);
916 break;
917 case ServiceState.STATE_POWER_OFF:
918 display = r.getString(R.string.radioInfo_service_off);
919 break;
920 }
johnwang342101a2009-09-23 16:22:34 -0700921
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800922 gsmState.setText(display);
johnwang342101a2009-09-23 16:22:34 -0700923
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800924 if (serviceState.getRoaming()) {
925 roamingState.setText(R.string.radioInfo_roaming_in);
926 } else {
927 roamingState.setText(R.string.radioInfo_roaming_not);
928 }
929
930 operatorName.setText(serviceState.getOperatorAlphaLong());
931 }
932
933 private final void
Nathan Harold2b77d742016-03-19 13:22:10 -0700934 updatePhoneState(int state) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800935 Resources r = getResources();
936 String display = r.getString(R.string.radioInfo_unknown);
937
938 switch (state) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700939 case TelephonyManager.CALL_STATE_IDLE:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800940 display = r.getString(R.string.radioInfo_phone_idle);
941 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700942 case TelephonyManager.CALL_STATE_RINGING:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800943 display = r.getString(R.string.radioInfo_phone_ringing);
944 break;
Nathan Harold2b77d742016-03-19 13:22:10 -0700945 case TelephonyManager.CALL_STATE_OFFHOOK:
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800946 display = r.getString(R.string.radioInfo_phone_offhook);
947 break;
948 }
949
950 callState.setText(display);
951 }
952
953 private final void
954 updateDataState() {
955 int state = mTelephonyManager.getDataState();
956 Resources r = getResources();
957 String display = r.getString(R.string.radioInfo_unknown);
958
959 switch (state) {
960 case TelephonyManager.DATA_CONNECTED:
961 display = r.getString(R.string.radioInfo_data_connected);
962 break;
963 case TelephonyManager.DATA_CONNECTING:
964 display = r.getString(R.string.radioInfo_data_connecting);
965 break;
966 case TelephonyManager.DATA_DISCONNECTED:
967 display = r.getString(R.string.radioInfo_data_disconnected);
968 break;
969 case TelephonyManager.DATA_SUSPENDED:
970 display = r.getString(R.string.radioInfo_data_suspended);
971 break;
972 }
johnwang342101a2009-09-23 16:22:34 -0700973
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800974 gprsState.setText(display);
975 }
976
977 private final void updateNetworkType() {
Nathan Harolde272c202016-10-27 13:45:00 -0700978 if(phone != null) {
Nathan Harold2b77d742016-03-19 13:22:10 -0700979 ServiceState ss = phone.getServiceState();
980 dataNetwork.setText(ServiceState.rilRadioTechnologyToString(
981 phone.getServiceState().getRilDataRadioTechnology()));
982 voiceNetwork.setText(ServiceState.rilRadioTechnologyToString(
983 phone.getServiceState().getRilVoiceRadioTechnology()));
984 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800985 }
986
987 private final void
988 updateProperties() {
989 String s;
990 Resources r = getResources();
991
992 s = phone.getDeviceId();
johnwang342101a2009-09-23 16:22:34 -0700993 if (s == null) s = r.getString(R.string.radioInfo_unknown);
Wink Savillec3886682009-04-02 11:00:56 -0700994 mDeviceId.setText(s);
johnwang342101a2009-09-23 16:22:34 -0700995
Meng Wang9053f172017-06-23 16:02:14 -0700996 s = phone.getSubscriberId();
997 if (s == null) s = r.getString(R.string.radioInfo_unknown);
998 mSubscriberId.setText(s);
999
Nathan Haroldcea413a2015-11-23 15:48:10 -08001000 //FIXME: Replace with a TelephonyManager call
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001001 s = phone.getLine1Number();
johnwang342101a2009-09-23 16:22:34 -07001002 if (s == null) s = r.getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001003 number.setText(s);
1004 }
1005
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001006 private final void updateDataStats2() {
1007 Resources r = getResources();
1008
Jeff Sharkey93029862011-05-27 18:26:15 -07001009 long txPackets = TrafficStats.getMobileTxPackets();
1010 long rxPackets = TrafficStats.getMobileRxPackets();
1011 long txBytes = TrafficStats.getMobileTxBytes();
1012 long rxBytes = TrafficStats.getMobileRxBytes();
johnwang342101a2009-09-23 16:22:34 -07001013
Jeff Sharkey93029862011-05-27 18:26:15 -07001014 String packets = r.getString(R.string.radioInfo_display_packets);
1015 String bytes = r.getString(R.string.radioInfo_display_bytes);
johnwang342101a2009-09-23 16:22:34 -07001016
Jeff Sharkey93029862011-05-27 18:26:15 -07001017 sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes);
1018 received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001019 }
1020
1021 /**
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001022 * Ping a host name
1023 */
1024 private final void pingHostname() {
1025 try {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001026 try {
1027 Process p4 = Runtime.getRuntime().exec("ping -c 1 www.google.com");
1028 int status4 = p4.waitFor();
1029 if (status4 == 0) {
1030 mPingHostnameResultV4 = "Pass";
1031 } else {
1032 mPingHostnameResultV4 = String.format("Fail(%d)", status4);
1033 }
1034 } catch (IOException e) {
1035 mPingHostnameResultV4 = "Fail: IOException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001036 }
Nathan Haroldcea413a2015-11-23 15:48:10 -08001037 try {
1038 Process p6 = Runtime.getRuntime().exec("ping6 -c 1 www.google.com");
1039 int status6 = p6.waitFor();
1040 if (status6 == 0) {
1041 mPingHostnameResultV6 = "Pass";
1042 } else {
1043 mPingHostnameResultV6 = String.format("Fail(%d)", status6);
1044 }
1045 } catch (IOException e) {
1046 mPingHostnameResultV6 = "Fail: IOException";
1047 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001048 } catch (InterruptedException e) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001049 mPingHostnameResultV4 = mPingHostnameResultV6 = "Fail: InterruptedException";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001050 }
1051 }
1052
1053 /**
1054 * This function checks for basic functionality of HTTP Client.
1055 */
1056 private void httpClientTest() {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001057 HttpURLConnection urlConnection = null;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001058 try {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001059 // TODO: Hardcoded for now, make it UI configurable
Alex Klyubinb0090232015-04-02 11:08:51 -07001060 URL url = new URL("https://www.google.com");
Narayan Kamathf25627c2014-12-12 13:53:28 +00001061 urlConnection = (HttpURLConnection) url.openConnection();
1062 if (urlConnection.getResponseCode() == 200) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001063 mHttpClientTestResult = "Pass";
1064 } else {
Narayan Kamathf25627c2014-12-12 13:53:28 +00001065 mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage();
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001066 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001067 } catch (IOException e) {
1068 mHttpClientTestResult = "Fail: IOException";
Narayan Kamathf25627c2014-12-12 13:53:28 +00001069 } finally {
1070 if (urlConnection != null) {
1071 urlConnection.disconnect();
1072 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001073 }
1074 }
1075
1076 private void refreshSmsc() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001077 //FIXME: Replace with a TelephonyManager call
jsh21dd4072009-05-12 11:26:55 -07001078 phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001079 }
1080
Nathan Haroldcea413a2015-11-23 15:48:10 -08001081 private final void updateAllCellInfo() {
1082
1083 mCellInfo.setText("");
Nathan Haroldcea413a2015-11-23 15:48:10 -08001084 mLocation.setText("");
1085
1086 final Runnable updateAllCellInfoResults = new Runnable() {
1087 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001088 updateLocation(mCellLocationResult);
1089 updateCellInfo(mCellInfoResult);
1090 }
1091 };
1092
1093 Thread locThread = new Thread() {
1094 @Override
1095 public void run() {
1096 mCellInfoResult = mTelephonyManager.getAllCellInfo();
1097 mCellLocationResult = mTelephonyManager.getCellLocation();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001098
1099 mHandler.post(updateAllCellInfoResults);
1100 }
1101 };
1102 locThread.start();
1103 }
1104
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001105 private final void updatePingState() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001106 // Set all to unknown since the threads will take a few secs to update.
Nathan Haroldcea413a2015-11-23 15:48:10 -08001107 mPingHostnameResultV4 = getResources().getString(R.string.radioInfo_unknown);
1108 mPingHostnameResultV6 = getResources().getString(R.string.radioInfo_unknown);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001109 mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown);
1110
Nathan Haroldcea413a2015-11-23 15:48:10 -08001111 mPingHostnameV4.setText(mPingHostnameResultV4);
1112 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001113 mHttpClientTest.setText(mHttpClientTestResult);
1114
1115 final Runnable updatePingResults = new Runnable() {
1116 public void run() {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001117 mPingHostnameV4.setText(mPingHostnameResultV4);
1118 mPingHostnameV6.setText(mPingHostnameResultV6);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001119 mHttpClientTest.setText(mHttpClientTestResult);
1120 }
1121 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001122
1123 Thread hostname = new Thread() {
1124 @Override
1125 public void run() {
1126 pingHostname();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001127 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001128 }
1129 };
1130 hostname.start();
1131
1132 Thread httpClient = new Thread() {
1133 @Override
1134 public void run() {
1135 httpClientTest();
Nathan Haroldcea413a2015-11-23 15:48:10 -08001136 mHandler.post(updatePingResults);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001137 }
1138 };
1139 httpClient.start();
1140 }
1141
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001142 private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() {
1143 public boolean onMenuItemClick(MenuItem item) {
1144 Intent intent = new Intent(Intent.ACTION_VIEW);
1145 // XXX We need to specify the component here because if we don't
1146 // the activity manager will try to resolve the type by calling
1147 // the content provider, which causes it to be loaded in a process
1148 // other than the Dialer process, which causes a lot of stuff to
1149 // break.
1150 intent.setClassName("com.android.phone",
1151 "com.android.phone.SimContacts");
1152 startActivity(intent);
1153 return true;
1154 }
1155 };
1156
1157 private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() {
1158 public boolean onMenuItemClick(MenuItem item) {
1159 Intent intent = new Intent(Intent.ACTION_VIEW);
1160 // XXX We need to specify the component here because if we don't
1161 // the activity manager will try to resolve the type by calling
1162 // the content provider, which causes it to be loaded in a process
1163 // other than the Dialer process, which causes a lot of stuff to
1164 // break.
1165 intent.setClassName("com.android.phone",
Andrew Leeda90d682014-10-31 13:12:20 -07001166 "com.android.phone.settings.fdn.FdnList");
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001167 startActivity(intent);
1168 return true;
1169 }
1170 };
1171
1172 private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() {
1173 public boolean onMenuItemClick(MenuItem item) {
1174 Intent intent = new Intent(
Wink Savillec3886682009-04-02 11:00:56 -07001175 Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001176 // XXX We need to specify the component here because if we don't
1177 // the activity manager will try to resolve the type by calling
1178 // the content provider, which causes it to be loaded in a process
1179 // other than the Dialer process, which causes a lot of stuff to
1180 // break.
1181 intent.setClassName("com.android.phone",
1182 "com.android.phone.ADNList");
1183 startActivity(intent);
1184 return true;
1185 }
1186 };
1187
Nathan Harolde272c202016-10-27 13:45:00 -07001188 private MenuItem.OnMenuItemClickListener mGetImsStatus = new MenuItem.OnMenuItemClickListener() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001189 public boolean onMenuItemClick(MenuItem item) {
Nathan Harolde272c202016-10-27 13:45:00 -07001190 boolean isImsRegistered = phone.isImsRegistered();
1191 boolean availableVolte = phone.isVolteEnabled();
1192 boolean availableWfc = phone.isWifiCallingEnabled();
1193 boolean availableVt = phone.isVideoEnabled();
1194 boolean availableUt = phone.isUtEnabled();
1195
1196 final String imsRegString = isImsRegistered ?
1197 getString(R.string.radio_info_ims_reg_status_registered) :
1198 getString(R.string.radio_info_ims_reg_status_not_registered);
1199
1200 final String available = getString(R.string.radio_info_ims_feature_status_available);
1201 final String unavailable = getString(
1202 R.string.radio_info_ims_feature_status_unavailable);
1203
1204 String imsStatus = getString(R.string.radio_info_ims_reg_status,
1205 imsRegString,
1206 availableVolte ? available : unavailable,
1207 availableWfc ? available : unavailable,
1208 availableVt ? available : unavailable,
1209 availableUt ? available : unavailable);
1210
1211 AlertDialog imsDialog = new AlertDialog.Builder(RadioInfo.this)
1212 .setMessage(imsStatus)
1213 .setTitle(getString(R.string.radio_info_ims_reg_status_title))
1214 .create();
1215
1216 imsDialog.show();
1217
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001218 return true;
1219 }
1220 };
1221
1222 private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() {
1223 public boolean onMenuItemClick(MenuItem item) {
1224 Intent intent = new Intent();
1225 intent.setClass(RadioInfo.this, BandMode.class);
1226 startActivity(intent);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001227 return true;
1228 }
1229 };
johnwang342101a2009-09-23 16:22:34 -07001230
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001231 private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() {
1232 public boolean onMenuItemClick(MenuItem item) {
1233 int state = mTelephonyManager.getDataState();
1234 switch (state) {
1235 case TelephonyManager.DATA_CONNECTED:
Jack Yu50972ed2018-12-13 11:51:20 -08001236 mTelephonyManager.setDataEnabled(false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001237 break;
1238 case TelephonyManager.DATA_DISCONNECTED:
Jack Yu50972ed2018-12-13 11:51:20 -08001239 mTelephonyManager.setDataEnabled(true);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001240 break;
1241 default:
1242 // do nothing
1243 break;
1244 }
1245 return true;
1246 }
1247 };
1248
Nathan Harold2b77d742016-03-19 13:22:10 -07001249 private boolean isRadioOn() {
1250 //FIXME: Replace with a TelephonyManager call
1251 return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
1252 }
1253
1254 private void updateRadioPowerState() {
1255 //delightful hack to prevent on-checked-changed calls from
1256 //actually forcing the radio preference to its transient/current value.
1257 radioPowerOnSwitch.setOnCheckedChangeListener(null);
1258 radioPowerOnSwitch.setChecked(isRadioOn());
1259 radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
1260 }
1261
Nathan Harolde272c202016-10-27 13:45:00 -07001262 void setImsVolteProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001263 Log.d(TAG, "setImsVolteProvisioned state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001264 setImsConfigProvisionedState(IMS_VOLTE_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001265 }
1266
Nathan Harolde272c202016-10-27 13:45:00 -07001267 void setImsVtProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001268 Log.d(TAG, "setImsVtProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001269 setImsConfigProvisionedState(IMS_VT_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001270 }
1271
Nathan Harolde272c202016-10-27 13:45:00 -07001272 void setImsWfcProvisionedState(boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001273 Log.d(TAG, "setImsWfcProvisioned() state: " + ((state)? "on":"off"));
Nathan Harolde272c202016-10-27 13:45:00 -07001274 setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
Nathan Harold12e1f552016-06-17 13:55:38 -07001275 }
1276
Meng Wang586741c2017-04-26 15:02:51 -07001277 void setEabProvisionedState(boolean state) {
1278 Log.d(TAG, "setEabProvisioned() state: " + ((state)? "on":"off"));
1279 setImsConfigProvisionedState(EAB_PROVISIONED_CONFIG_ID, state);
1280 }
1281
Nathan Harolde272c202016-10-27 13:45:00 -07001282 void setImsConfigProvisionedState(int configItem, boolean state) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001283 if (phone != null && mImsManager != null) {
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001284 QueuedWork.queue(new Runnable() {
Nathan Harold12e1f552016-06-17 13:55:38 -07001285 public void run() {
1286 try {
1287 mImsManager.getConfigInterface().setProvisionedValue(
1288 configItem,
1289 state? 1 : 0);
1290 } catch (ImsException e) {
1291 Log.e(TAG, "setImsConfigProvisioned() exception:", e);
1292 }
1293 }
Philip P. Moltmann5c449ae2017-02-14 12:43:02 -08001294 }, false);
Nathan Harold12e1f552016-06-17 13:55:38 -07001295 }
1296 }
1297
Nathan Harold2b77d742016-03-19 13:22:10 -07001298 OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() {
1299 @Override
1300 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1301 log("toggle radio power: currently " + (isRadioOn()?"on":"off"));
1302 phone.setRadioPower(isChecked);
1303 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001304 };
1305
Nathan Harold12e1f552016-06-17 13:55:38 -07001306 private boolean isImsVolteProvisioned() {
Nathan Harold2b77d742016-03-19 13:22:10 -07001307 if (phone != null && mImsManager != null) {
1308 return mImsManager.isVolteEnabledByPlatform(phone.getContext())
1309 && mImsManager.isVolteProvisionedOnDevice(phone.getContext());
Pavel Zhamaitsiakcb267a62015-01-21 18:25:14 -08001310 }
1311 return false;
1312 }
1313
Nathan Harold12e1f552016-06-17 13:55:38 -07001314 OnCheckedChangeListener mImsVolteCheckedChangeListener = new OnCheckedChangeListener() {
Wink Saville426fc662011-09-25 14:39:02 -07001315 @Override
Nathan Harold2b77d742016-03-19 13:22:10 -07001316 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Nathan Harold12e1f552016-06-17 13:55:38 -07001317 setImsVolteProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001318 }
Wink Saville426fc662011-09-25 14:39:02 -07001319 };
1320
Nathan Harold12e1f552016-06-17 13:55:38 -07001321 private boolean isImsVtProvisioned() {
1322 if (phone != null && mImsManager != null) {
1323 return mImsManager.isVtEnabledByPlatform(phone.getContext())
1324 && mImsManager.isVtProvisionedOnDevice(phone.getContext());
1325 }
1326 return false;
1327 }
1328
1329 OnCheckedChangeListener mImsVtCheckedChangeListener = new OnCheckedChangeListener() {
1330 @Override
1331 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1332 setImsVtProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001333 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001334 };
1335
1336 private boolean isImsWfcProvisioned() {
1337 if (phone != null && mImsManager != null) {
1338 return mImsManager.isWfcEnabledByPlatform(phone.getContext())
1339 && mImsManager.isWfcProvisionedOnDevice(phone.getContext());
1340 }
1341 return false;
1342 }
1343
1344 OnCheckedChangeListener mImsWfcCheckedChangeListener = new OnCheckedChangeListener() {
1345 @Override
1346 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1347 setImsWfcProvisionedState(isChecked);
Nathan Harolde272c202016-10-27 13:45:00 -07001348 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001349 };
1350
Meng Wang586741c2017-04-26 15:02:51 -07001351 private boolean isEabProvisioned() {
1352 return isFeatureProvisioned(EAB_PROVISIONED_CONFIG_ID, false);
1353 }
1354
1355 OnCheckedChangeListener mEabCheckedChangeListener = new OnCheckedChangeListener() {
1356 @Override
1357 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1358 setEabProvisionedState(isChecked);
1359 }
1360 };
1361
1362 private boolean isFeatureProvisioned(int featureId, boolean defaultValue) {
1363 boolean provisioned = defaultValue;
1364 if (mImsManager != null) {
1365 try {
1366 ImsConfig imsConfig = mImsManager.getConfigInterface();
1367 if (imsConfig != null) {
1368 provisioned =
1369 (imsConfig.getProvisionedValue(featureId)
1370 == ImsConfig.FeatureValueConstants.ON);
1371 }
1372 } catch (ImsException ex) {
1373 Log.e(TAG, "isFeatureProvisioned() exception:", ex);
1374 }
1375 }
1376
1377 log("isFeatureProvisioned() featureId=" + featureId + " provisioned=" + provisioned);
1378 return provisioned;
1379 }
1380
1381 private static boolean isEabEnabledByPlatform(Context context) {
1382 if (context != null) {
1383 CarrierConfigManager configManager = (CarrierConfigManager)
1384 context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
1385 if (configManager != null && configManager.getConfig().getBoolean(
1386 CarrierConfigManager.KEY_USE_RCS_PRESENCE_BOOL)) {
1387 return true;
1388 }
1389 }
1390 return false;
1391 }
1392
Nathan Harold12e1f552016-06-17 13:55:38 -07001393 private void updateImsProvisionedState() {
Brad Ebinger5dfe7f82019-03-11 17:33:53 -07001394 if (!ImsManager.isImsSupportedOnDevice(phone.getContext())) {
1395 return;
1396 }
Nathan Harold12e1f552016-06-17 13:55:38 -07001397 log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
Nathan Harold2b77d742016-03-19 13:22:10 -07001398 //delightful hack to prevent on-checked-changed calls from
1399 //actually forcing the ims provisioning to its transient/current value.
Nathan Harold12e1f552016-06-17 13:55:38 -07001400 imsVolteProvisionedSwitch.setOnCheckedChangeListener(null);
1401 imsVolteProvisionedSwitch.setChecked(isImsVolteProvisioned());
1402 imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001403 imsVolteProvisionedSwitch.setEnabled(!Build.IS_USER
1404 && mImsManager.isVolteEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001405
1406 imsVtProvisionedSwitch.setOnCheckedChangeListener(null);
1407 imsVtProvisionedSwitch.setChecked(isImsVtProvisioned());
1408 imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001409 imsVtProvisionedSwitch.setEnabled(!Build.IS_USER
1410 && mImsManager.isVtEnabledByPlatform(phone.getContext()));
Nathan Harold12e1f552016-06-17 13:55:38 -07001411
1412 imsWfcProvisionedSwitch.setOnCheckedChangeListener(null);
1413 imsWfcProvisionedSwitch.setChecked(isImsWfcProvisioned());
1414 imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001415 imsWfcProvisionedSwitch.setEnabled(!Build.IS_USER
1416 && mImsManager.isWfcEnabledByPlatform(phone.getContext()));
Meng Wang586741c2017-04-26 15:02:51 -07001417
1418 eabProvisionedSwitch.setOnCheckedChangeListener(null);
1419 eabProvisionedSwitch.setChecked(isEabProvisioned());
1420 eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
Sreekanth Badidac888e192018-02-05 17:18:40 +01001421 eabProvisionedSwitch.setEnabled(!Build.IS_USER
1422 && isEabEnabledByPlatform(phone.getContext()));
Wink Saville426fc662011-09-25 14:39:02 -07001423 }
1424
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001425 OnClickListener mDnsCheckButtonHandler = new OnClickListener() {
1426 public void onClick(View v) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001427 //FIXME: Replace with a TelephonyManager call
Wink Savillec3886682009-04-02 11:00:56 -07001428 phone.disableDnsCheck(!phone.isDnsCheckDisabled());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001429 updateDnsCheckState();
1430 }
1431 };
johnwang342101a2009-09-23 16:22:34 -07001432
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001433 OnClickListener mOemInfoButtonHandler = new OnClickListener() {
1434 public void onClick(View v) {
1435 Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO");
1436 try {
1437 startActivity(intent);
1438 } catch (android.content.ActivityNotFoundException ex) {
Wink Savillebf471282013-04-05 15:04:05 -07001439 log("OEM-specific Info/Settings Activity Not Found : " + ex);
Tammo Spalinka5f4c8f2009-10-15 20:08:58 +08001440 // If the activity does not exist, there are no OEM
1441 // settings, and so we can just do nothing...
1442 }
1443 }
1444 };
1445
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001446 OnClickListener mPingButtonHandler = new OnClickListener() {
1447 public void onClick(View v) {
1448 updatePingState();
1449 }
1450 };
1451
1452 OnClickListener mUpdateSmscButtonHandler = new OnClickListener() {
1453 public void onClick(View v) {
1454 updateSmscButton.setEnabled(false);
jsh21dd4072009-05-12 11:26:55 -07001455 phone.setSmscAddress(smsc.getText().toString(),
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001456 mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE));
1457 }
1458 };
1459
1460 OnClickListener mRefreshSmscButtonHandler = new OnClickListener() {
1461 public void onClick(View v) {
1462 refreshSmsc();
1463 }
1464 };
1465
Youhan Wangfd781e92016-12-16 15:53:16 -08001466 OnClickListener mCarrierProvisioningButtonHandler = new OnClickListener() {
1467 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001468 final Intent intent = new Intent("com.android.settings.CARRIER_PROVISIONING");
1469 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1470 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001471 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001472 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001473 }
1474 };
1475
1476 OnClickListener mTriggerCarrierProvisioningButtonHandler = new OnClickListener() {
1477 public void onClick(View v) {
Meng Wanga04449b2017-08-03 14:34:35 -07001478 final Intent intent = new Intent("com.android.settings.TRIGGER_CARRIER_PROVISIONING");
1479 final ComponentName serviceComponent = ComponentName.unflattenFromString(
1480 "com.android.omadm.service/.DMIntentReceiver");
Youhan Wangfd781e92016-12-16 15:53:16 -08001481 intent.setComponent(serviceComponent);
Meng Wanga04449b2017-08-03 14:34:35 -07001482 sendBroadcast(intent);
Youhan Wangfd781e92016-12-16 15:53:16 -08001483 }
1484 };
1485
Nathan Haroldcea413a2015-11-23 15:48:10 -08001486 AdapterView.OnItemSelectedListener mPreferredNetworkHandler =
1487 new AdapterView.OnItemSelectedListener() {
1488
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001489 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
Nathan Haroldcea413a2015-11-23 15:48:10 -08001490 if (mPreferredNetworkTypeResult != pos && pos >= 0
1491 && pos <= mPreferredNetworkLabels.length - 2) {
1492 mPreferredNetworkTypeResult = pos;
Nathan Harolddaea8be2018-06-05 14:02:35 -07001493
1494 // TODO: Possibly migrate this to TelephonyManager.setPreferredNetworkType()
1495 // which today still has some issues (mostly that the "set" is conditional
1496 // on a successful modem call, which is not what we want). Instead we always
1497 // want this setting to be set, so that if the radio hiccups and this setting
1498 // is for some reason unsuccessful, future calls to the radio will reflect
1499 // the users's preference which is set here.
1500 final int subId = phone.getSubId();
1501 if (SubscriptionManager.isUsableSubIdValue(subId)) {
1502 Settings.Global.putInt(phone.getContext().getContentResolver(),
1503 PREFERRED_NETWORK_MODE + subId, mPreferredNetworkTypeResult);
1504 }
1505 log("Calling setPreferredNetworkType(" + mPreferredNetworkTypeResult + ")");
Nathan Haroldcea413a2015-11-23 15:48:10 -08001506 Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE);
1507 phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001508 }
1509 }
1510
1511 public void onNothingSelected(AdapterView parent) {
1512 }
1513 };
1514
Nathan Harold2b77d742016-03-19 13:22:10 -07001515 AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler =
1516 new AdapterView.OnItemSelectedListener() {
Wink Savillebf471282013-04-05 15:04:05 -07001517
Nathan Harold2b77d742016-03-19 13:22:10 -07001518 public void onItemSelected(AdapterView parent, View v, int pos, long id) {
1519 mCellInfoRefreshRateIndex = pos;
Sooraj Sasindran5cce06b2016-08-18 15:49:49 -07001520 mTelephonyManager.setCellInfoListRate(mCellInfoRefreshRates[pos]);
Nathan Harold2b77d742016-03-19 13:22:10 -07001521 updateAllCellInfo();
1522 }
1523
1524 public void onNothingSelected(AdapterView parent) {
1525 }
1526 };
1527
Naina Nallurid1b57f62019-01-08 15:19:58 -08001528 boolean isCbrsSupported() {
1529 return getResources().getBoolean(
1530 com.android.internal.R.bool.config_cbrs_supported);
1531 }
1532
1533 void updateCbrsDataState(boolean state) {
1534 Log.d(TAG, "setCbrsDataSwitchState() state:" + ((state)? "on":"off"));
1535 if (mTelephonyManager != null) {
1536 QueuedWork.queue(new Runnable() {
1537 public void run() {
1538 mTelephonyManager.setOpportunisticNetworkState(state);
1539 cbrsDataSwitch.setChecked(getCbrsDataState());
1540 }
1541 }, false);
1542 }
1543 }
1544
1545 boolean getCbrsDataState() {
1546 boolean state = false;
1547 if (mTelephonyManager != null) {
1548 state = mTelephonyManager.isOpportunisticNetworkEnabled();
1549 }
1550 Log.d(TAG, "getCbrsDataState() state:" +((state)? "on":"off"));
1551 return state;
1552 }
1553
1554 OnCheckedChangeListener mCbrsDataSwitchChangeListener = new OnCheckedChangeListener() {
1555 @Override
1556 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
1557 updateCbrsDataState(isChecked);
1558 }
1559 };
1560
Pengquan Meng7f602c72019-01-28 19:12:18 -08001561 private void showDsdsChangeDialog() {
1562 final AlertDialog confirmDialog = new Builder(RadioInfo.this)
1563 .setTitle(R.string.dsds_dialog_title)
1564 .setMessage(R.string.dsds_dialog_message)
1565 .setPositiveButton(R.string.dsds_dialog_confirm, mOnDsdsDialogConfirmedListener)
1566 .setNegativeButton(R.string.dsds_dialog_cancel, mOnDsdsDialogConfirmedListener)
1567 .create();
1568 confirmDialog.show();
1569 }
Naina Nallurid1b57f62019-01-08 15:19:58 -08001570
Pengquan Meng7f602c72019-01-28 19:12:18 -08001571 private static boolean isDsdsSupported() {
Michele3dafea22019-03-19 15:53:45 -07001572 return (TelephonyManager.getDefault().isMultiSimSupported()
1573 == TelephonyManager.MULTISIM_ALLOWED);
Pengquan Meng7f602c72019-01-28 19:12:18 -08001574 }
1575
1576 private static boolean isDsdsEnabled() {
1577 return TelephonyManager.getDefault().getPhoneCount() > 1;
1578 }
1579
1580 private void performDsdsSwitch() {
1581 mTelephonyManager.switchMultiSimConfig(dsdsSwitch.isChecked() ? 2 : 1);
1582 }
1583
1584 DialogInterface.OnClickListener mOnDsdsDialogConfirmedListener =
1585 new DialogInterface.OnClickListener() {
1586 @Override
1587 public void onClick(DialogInterface dialog, int which) {
1588 if (which == DialogInterface.BUTTON_POSITIVE) {
1589 dsdsSwitch.toggle();
1590 performDsdsSwitch();
1591 }
1592 }
1593 };
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001594}