The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.settings; |
| 18 | |
| 19 | import android.app.Activity; |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 20 | import android.app.QueuedWork; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 21 | import android.content.Intent; |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 22 | import android.content.pm.PackageManager; |
| 23 | import android.content.pm.ResolveInfo; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 24 | import android.content.res.Resources; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 25 | import android.graphics.Typeface; |
Jeff Sharkey | 9302986 | 2011-05-27 18:26:15 -0700 | [diff] [blame] | 26 | import android.net.TrafficStats; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 27 | import android.net.Uri; |
| 28 | import android.os.AsyncResult; |
| 29 | import android.os.Bundle; |
| 30 | import android.os.Handler; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 31 | import android.os.Message; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 32 | import android.os.SystemProperties; |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 33 | import android.telephony.CellInfo; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 34 | import android.telephony.CellInfoCdma; |
| 35 | import android.telephony.CellInfoGsm; |
| 36 | import android.telephony.CellInfoLte; |
| 37 | import android.telephony.CellInfoWcdma; |
| 38 | import android.telephony.CellIdentityCdma; |
| 39 | import android.telephony.CellIdentityGsm; |
| 40 | import android.telephony.CellIdentityLte; |
| 41 | import android.telephony.CellIdentityWcdma; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 42 | import android.telephony.CellLocation; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 43 | import android.telephony.CellSignalStrengthCdma; |
| 44 | import android.telephony.CellSignalStrengthGsm; |
| 45 | import android.telephony.CellSignalStrengthLte; |
| 46 | import android.telephony.CellSignalStrengthWcdma; |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame] | 47 | import android.telephony.DataConnectionRealTimeInfo; |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 48 | import android.telephony.NeighboringCellInfo; |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 49 | import android.telephony.PreciseCallState; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 50 | import android.telephony.PhoneStateListener; |
| 51 | import android.telephony.ServiceState; |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 52 | import android.telephony.SignalStrength; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 53 | import android.telephony.SubscriptionManager; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 54 | import android.telephony.TelephonyManager; |
jsh | 534f5ae | 2009-09-24 09:19:22 -0700 | [diff] [blame] | 55 | import android.telephony.cdma.CdmaCellLocation; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 56 | import android.telephony.gsm.GsmCellLocation; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 57 | import android.util.Log; |
| 58 | import android.view.Menu; |
| 59 | import android.view.MenuItem; |
| 60 | import android.view.View; |
| 61 | import android.view.View.OnClickListener; |
| 62 | import android.widget.AdapterView; |
| 63 | import android.widget.ArrayAdapter; |
| 64 | import android.widget.Button; |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 65 | import android.widget.CompoundButton; |
| 66 | import android.widget.CompoundButton.OnCheckedChangeListener; |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 67 | import android.widget.EditText; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 68 | import android.widget.Spinner; |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 69 | import android.widget.Switch; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 70 | import android.widget.TextView; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 71 | |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 72 | import com.android.ims.ImsConfig; |
| 73 | import com.android.ims.ImsException; |
| 74 | import com.android.ims.ImsManager; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 75 | import com.android.internal.telephony.Phone; |
Wink Saville | 5543404 | 2012-06-14 12:33:43 -0700 | [diff] [blame] | 76 | import com.android.internal.telephony.PhoneConstants; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 77 | import com.android.internal.telephony.PhoneFactory; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 78 | import com.android.internal.telephony.RILConstants; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 79 | import com.android.internal.telephony.TelephonyProperties; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 80 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 81 | import java.io.IOException; |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 82 | import java.net.HttpURLConnection; |
| 83 | import java.net.URL; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 84 | import java.net.UnknownHostException; |
| 85 | import java.util.ArrayList; |
| 86 | import java.util.List; |
| 87 | |
| 88 | public class RadioInfo extends Activity { |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 89 | private static final String TAG = "RadioInfo"; |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 90 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 91 | private static final String[] mPreferredNetworkLabels = { |
| 92 | "WCDMA preferred", |
| 93 | "GSM only", |
| 94 | "WCDMA only", |
| 95 | "GSM auto (PRL)", |
| 96 | "CDMA auto (PRL)", |
| 97 | "CDMA only", |
| 98 | "EvDo only", |
| 99 | "Global auto (PRL)", |
| 100 | "LTE/CDMA auto (PRL)", |
| 101 | "LTE/UMTS auto (PRL)", |
| 102 | "LTE/CDMA/UMTS auto (PRL)", |
| 103 | "LTE only", |
| 104 | "LTE/WCDMA", |
| 105 | "TD-SCDMA only", |
| 106 | "TD-SCDMA/WCDMA", |
| 107 | "LTE/TD-SCDMA", |
| 108 | "TD-SCDMA/GSM", |
| 109 | "TD-SCDMA/UMTS", |
| 110 | "LTE/TD-SCDMA/WCDMA", |
| 111 | "LTE/TD-SCDMA/UMTS", |
| 112 | "TD-SCDMA/CDMA/UMTS", |
| 113 | "Global/TD-SCDMA", |
| 114 | "Unknown" |
| 115 | }; |
| 116 | |
| 117 | |
| 118 | private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE; |
| 119 | private static final int CELL_INFO_LIST_RATE_MAX = 0; |
| 120 | |
| 121 | //Values in must match mCellInfoRefreshRates |
| 122 | private static final String[] mCellInfoRefreshRateLabels = { |
| 123 | "Disabled", |
| 124 | "Immediate", |
| 125 | "Min 5s", |
| 126 | "Min 10s", |
| 127 | "Min 60s" |
| 128 | }; |
| 129 | |
| 130 | //Values in seconds, must match mCellInfoRefreshRateLabels |
| 131 | private static final int mCellInfoRefreshRates[] = { |
| 132 | CELL_INFO_LIST_RATE_DISABLED, |
| 133 | CELL_INFO_LIST_RATE_MAX, |
| 134 | 5000, |
| 135 | 10000, |
| 136 | 60000 |
| 137 | }; |
| 138 | |
| 139 | private void log(String s) { |
| 140 | Log.d(TAG, s); |
| 141 | } |
| 142 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 143 | private static final int EVENT_CFI_CHANGED = 302; |
| 144 | |
| 145 | private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000; |
| 146 | private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 147 | private static final int EVENT_QUERY_SMSC_DONE = 1005; |
| 148 | private static final int EVENT_UPDATE_SMSC_DONE = 1006; |
| 149 | |
| 150 | private static final int MENU_ITEM_SELECT_BAND = 0; |
| 151 | private static final int MENU_ITEM_VIEW_ADN = 1; |
| 152 | private static final int MENU_ITEM_VIEW_FDN = 2; |
| 153 | private static final int MENU_ITEM_VIEW_SDN = 3; |
| 154 | private static final int MENU_ITEM_GET_PDP_LIST = 4; |
| 155 | private static final int MENU_ITEM_TOGGLE_DATA = 5; |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 156 | |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 157 | private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 158 | private TextView number; |
| 159 | private TextView callState; |
| 160 | private TextView operatorName; |
| 161 | private TextView roamingState; |
| 162 | private TextView gsmState; |
| 163 | private TextView gprsState; |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 164 | private TextView voiceNetwork; |
| 165 | private TextView dataNetwork; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 166 | private TextView dBm; |
| 167 | private TextView mMwi; |
| 168 | private TextView mCfi; |
| 169 | private TextView mLocation; |
| 170 | private TextView mNeighboringCids; |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 171 | private TextView mCellInfo; |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame] | 172 | private TextView mDcRtInfoTv; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 173 | private TextView sent; |
| 174 | private TextView received; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 175 | private TextView mPingHostnameV4; |
| 176 | private TextView mPingHostnameV6; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 177 | private TextView mHttpClientTest; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 178 | private TextView dnsCheckState; |
| 179 | private EditText smsc; |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 180 | private Switch radioPowerOnSwitch; |
| 181 | private Button cellInfoRefreshRateButton; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 182 | private Button dnsCheckToggleButton; |
| 183 | private Button pingTestButton; |
| 184 | private Button updateSmscButton; |
| 185 | private Button refreshSmscButton; |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 186 | private Button oemInfoButton; |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 187 | private Switch imsVoLteProvisionedSwitch; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 188 | private Spinner preferredNetworkType; |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 189 | private Spinner cellInfoRefreshRateSpinner; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 190 | |
| 191 | private TelephonyManager mTelephonyManager; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 192 | private ImsManager mImsManager = null; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 193 | private Phone phone = null; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 194 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 195 | private String mPingHostnameResultV4; |
| 196 | private String mPingHostnameResultV6; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 197 | private String mHttpClientTestResult; |
| 198 | private boolean mMwiValue = false; |
| 199 | private boolean mCfiValue = false; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 200 | |
| 201 | private List<CellInfo> mCellInfoResult = null; |
| 202 | private CellLocation mCellLocationResult = null; |
| 203 | private List<NeighboringCellInfo> mNeighboringCellResult = null; |
| 204 | |
| 205 | private int mPreferredNetworkTypeResult; |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 206 | private int mCellInfoRefreshRateIndex; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 207 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 208 | private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 209 | @Override |
| 210 | public void onDataConnectionStateChanged(int state) { |
| 211 | updateDataState(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 212 | updateNetworkType(); |
| 213 | } |
| 214 | |
| 215 | @Override |
| 216 | public void onDataActivity(int direction) { |
| 217 | updateDataStats2(); |
| 218 | } |
| 219 | |
| 220 | @Override |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 221 | public void onCallStateChanged(int state, String incomingNumber) { |
| 222 | updateNetworkType(); |
| 223 | updatePhoneState(state); |
| 224 | } |
| 225 | |
| 226 | @Override |
| 227 | public void onPreciseCallStateChanged(PreciseCallState preciseState) { |
| 228 | updateNetworkType(); |
| 229 | } |
| 230 | |
| 231 | @Override |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 232 | public void onCellLocationChanged(CellLocation location) { |
| 233 | updateLocation(location); |
| 234 | } |
| 235 | |
| 236 | @Override |
| 237 | public void onMessageWaitingIndicatorChanged(boolean mwi) { |
| 238 | mMwiValue = mwi; |
| 239 | updateMessageWaiting(); |
| 240 | } |
| 241 | |
| 242 | @Override |
| 243 | public void onCallForwardingIndicatorChanged(boolean cfi) { |
| 244 | mCfiValue = cfi; |
| 245 | updateCallRedirect(); |
| 246 | } |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 247 | |
| 248 | @Override |
| 249 | public void onCellInfoChanged(List<CellInfo> arrayCi) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 250 | log("onCellInfoChanged: arrayCi=" + arrayCi); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 251 | mCellInfoResult = arrayCi; |
| 252 | updateCellInfo(mCellInfoResult); |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 253 | } |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame] | 254 | |
| 255 | @Override |
| 256 | public void onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo) { |
| 257 | log("onDataConnectionRealTimeInfoChanged: dcRtInfo=" + dcRtInfo); |
| 258 | updateDcRtInfoTv(dcRtInfo); |
| 259 | } |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 260 | |
| 261 | @Override |
| 262 | public void onSignalStrengthsChanged(SignalStrength signalStrength) { |
| 263 | log("onSignalStrengthChanged: SignalStrength=" +signalStrength); |
| 264 | updateSignalStrength(signalStrength); |
| 265 | } |
| 266 | |
| 267 | @Override |
| 268 | public void onServiceStateChanged(ServiceState serviceState) { |
| 269 | log("onServiceStateChanged: ServiceState=" + serviceState); |
| 270 | updateServiceState(serviceState); |
| 271 | updateRadioPowerState(); |
| 272 | updateNetworkType(); |
| 273 | updateImsVoLteProvisionedState(); |
| 274 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 275 | }; |
| 276 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 277 | private void updatePreferredNetworkType(int type) { |
| 278 | if (type >= mPreferredNetworkLabels.length || type < 0) { |
| 279 | log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " + |
| 280 | "type=" + type); |
| 281 | type = mPreferredNetworkLabels.length - 1; //set to Unknown |
| 282 | } |
| 283 | mPreferredNetworkTypeResult = type; |
| 284 | |
| 285 | preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true); |
| 286 | } |
| 287 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 288 | private Handler mHandler = new Handler() { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 289 | @Override |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 290 | public void handleMessage(Message msg) { |
| 291 | AsyncResult ar; |
| 292 | switch (msg.what) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 293 | case EVENT_QUERY_PREFERRED_TYPE_DONE: |
| 294 | ar= (AsyncResult) msg.obj; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 295 | if (ar.exception == null && ar.result != null) { |
| 296 | updatePreferredNetworkType(((int[])ar.result)[0]); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 297 | } else { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 298 | //In case of an exception, we will set this to unknown |
| 299 | updatePreferredNetworkType(mPreferredNetworkLabels.length-1); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 300 | } |
| 301 | break; |
| 302 | case EVENT_SET_PREFERRED_TYPE_DONE: |
| 303 | ar= (AsyncResult) msg.obj; |
| 304 | if (ar.exception != null) { |
Nathan Harold | ed38afa | 2016-04-13 00:29:30 -0700 | [diff] [blame^] | 305 | log("Set preferred network type failed."); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 306 | } |
| 307 | break; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 308 | case EVENT_QUERY_SMSC_DONE: |
| 309 | ar= (AsyncResult) msg.obj; |
| 310 | if (ar.exception != null) { |
| 311 | smsc.setText("refresh error"); |
| 312 | } else { |
jsh | 21dd407 | 2009-05-12 11:26:55 -0700 | [diff] [blame] | 313 | smsc.setText((String)ar.result); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 314 | } |
| 315 | break; |
| 316 | case EVENT_UPDATE_SMSC_DONE: |
| 317 | updateSmscButton.setEnabled(true); |
| 318 | ar= (AsyncResult) msg.obj; |
| 319 | if (ar.exception != null) { |
| 320 | smsc.setText("update error"); |
| 321 | } |
| 322 | break; |
| 323 | default: |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 324 | super.handleMessage(msg); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 325 | break; |
| 326 | |
| 327 | } |
| 328 | } |
| 329 | }; |
| 330 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 331 | @Override |
| 332 | public void onCreate(Bundle icicle) { |
| 333 | super.onCreate(icicle); |
| 334 | |
| 335 | setContentView(R.layout.radio_info); |
| 336 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 337 | log("Started onCreate"); |
| 338 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 339 | mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); |
| 340 | phone = PhoneFactory.getDefaultPhone(); |
| 341 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 342 | //TODO: Need to update this if the default phoneId changes? |
| 343 | // Better to have an instance per phone? |
| 344 | mImsManager = ImsManager.getInstance(getApplicationContext(), |
| 345 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 346 | |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 347 | mDeviceId= (TextView) findViewById(R.id.imei); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 348 | number = (TextView) findViewById(R.id.number); |
| 349 | callState = (TextView) findViewById(R.id.call); |
| 350 | operatorName = (TextView) findViewById(R.id.operator); |
| 351 | roamingState = (TextView) findViewById(R.id.roaming); |
| 352 | gsmState = (TextView) findViewById(R.id.gsm); |
| 353 | gprsState = (TextView) findViewById(R.id.gprs); |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 354 | voiceNetwork = (TextView) findViewById(R.id.voice_network); |
| 355 | dataNetwork = (TextView) findViewById(R.id.data_network); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 356 | dBm = (TextView) findViewById(R.id.dbm); |
| 357 | mMwi = (TextView) findViewById(R.id.mwi); |
| 358 | mCfi = (TextView) findViewById(R.id.cfi); |
| 359 | mLocation = (TextView) findViewById(R.id.location); |
| 360 | mNeighboringCids = (TextView) findViewById(R.id.neighboring); |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 361 | mCellInfo = (TextView) findViewById(R.id.cellinfo); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 362 | mCellInfo.setTypeface(Typeface.MONOSPACE); |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame] | 363 | mDcRtInfoTv = (TextView) findViewById(R.id.dcrtinfo); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 364 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 365 | sent = (TextView) findViewById(R.id.sent); |
| 366 | received = (TextView) findViewById(R.id.received); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 367 | smsc = (EditText) findViewById(R.id.smsc); |
| 368 | dnsCheckState = (TextView) findViewById(R.id.dnsCheckState); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 369 | mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4); |
| 370 | mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 371 | mHttpClientTest = (TextView) findViewById(R.id.httpClientTest); |
| 372 | |
| 373 | preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType); |
| 374 | ArrayAdapter<String> adapter = new ArrayAdapter<String> (this, |
| 375 | android.R.layout.simple_spinner_item, mPreferredNetworkLabels); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 376 | adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 377 | preferredNetworkType.setAdapter(adapter); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 378 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 379 | cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select); |
| 380 | ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this, |
| 381 | android.R.layout.simple_spinner_item, mCellInfoRefreshRateLabels); |
| 382 | cellInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
| 383 | cellInfoRefreshRateSpinner.setAdapter(cellInfoAdapter); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 384 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 385 | imsVoLteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch); |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 386 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 387 | radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power); |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 388 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 389 | pingTestButton = (Button) findViewById(R.id.ping_test); |
| 390 | pingTestButton.setOnClickListener(mPingButtonHandler); |
| 391 | updateSmscButton = (Button) findViewById(R.id.update_smsc); |
| 392 | updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler); |
| 393 | refreshSmscButton = (Button) findViewById(R.id.refresh_smsc); |
| 394 | refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler); |
| 395 | dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle); |
| 396 | dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 397 | |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 398 | oemInfoButton = (Button) findViewById(R.id.oem_info); |
| 399 | oemInfoButton.setOnClickListener(mOemInfoButtonHandler); |
| 400 | PackageManager pm = getPackageManager(); |
| 401 | Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO"); |
| 402 | List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0); |
| 403 | if (oemInfoIntentList.size() == 0) { |
| 404 | oemInfoButton.setEnabled(false); |
| 405 | } |
| 406 | |
Nathan Harold | ed38afa | 2016-04-13 00:29:30 -0700 | [diff] [blame^] | 407 | mCellInfoRefreshRateIndex = 0; //disabled |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 408 | mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown |
| 409 | |
| 410 | //FIXME: Replace with TelephonyManager call |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 411 | phone.getPreferredNetworkType( |
| 412 | mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE)); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 413 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 414 | restoreFromBundle(icicle); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | @Override |
| 418 | protected void onResume() { |
| 419 | super.onResume(); |
| 420 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 421 | log("Started onResume"); |
| 422 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 423 | updateMessageWaiting(); |
| 424 | updateCallRedirect(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 425 | updateDataState(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 426 | updateDataStats2(); |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 427 | updateRadioPowerState(); |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 428 | updateImsVoLteProvisionedState(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 429 | updateProperties(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 430 | updateDnsCheckState(); |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 431 | updateNetworkType(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 432 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 433 | updateNeighboringCids(mNeighboringCellResult); |
| 434 | updateLocation(mCellLocationResult); |
| 435 | updateCellInfo(mCellInfoResult); |
| 436 | |
| 437 | mPingHostnameV4.setText(mPingHostnameResultV4); |
| 438 | mPingHostnameV6.setText(mPingHostnameResultV6); |
| 439 | mHttpClientTest.setText(mHttpClientTestResult); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 440 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 441 | cellInfoRefreshRateSpinner.setOnItemSelectedListener(mCellInfoRefreshRateHandler); |
Nathan Harold | ed38afa | 2016-04-13 00:29:30 -0700 | [diff] [blame^] | 442 | //set selection after registering listener to force update |
| 443 | cellInfoRefreshRateSpinner.setSelection(mCellInfoRefreshRateIndex); |
| 444 | |
| 445 | //set selection before registering to prevent update |
| 446 | preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true); |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 447 | preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler); |
Nathan Harold | ed38afa | 2016-04-13 00:29:30 -0700 | [diff] [blame^] | 448 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 449 | radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener); |
| 450 | imsVoLteProvisionedSwitch.setOnCheckedChangeListener(mImsVoLteCheckedChangeListener); |
| 451 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 452 | mTelephonyManager.listen(mPhoneStateListener, |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 453 | PhoneStateListener.LISTEN_CALL_STATE |
| 454 | //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE |
| 455 | // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE |
| 456 | | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 457 | | PhoneStateListener.LISTEN_DATA_ACTIVITY |
| 458 | | PhoneStateListener.LISTEN_CELL_LOCATION |
| 459 | | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 460 | | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame] | 461 | | PhoneStateListener.LISTEN_CELL_INFO |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 462 | | PhoneStateListener.LISTEN_SERVICE_STATE |
| 463 | | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame] | 464 | | PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO); |
Nathan Harold | ed38afa | 2016-04-13 00:29:30 -0700 | [diff] [blame^] | 465 | |
| 466 | smsc.clearFocus(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | @Override |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 470 | protected void onPause() { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 471 | super.onPause(); |
| 472 | |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 473 | log("onPause: unregister phone & data intents"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 474 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 475 | mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); |
Nathan Harold | ed38afa | 2016-04-13 00:29:30 -0700 | [diff] [blame^] | 476 | phone.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 477 | } |
| 478 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 479 | private void restoreFromBundle(Bundle b) { |
| 480 | if( b == null) { |
| 481 | return; |
| 482 | } |
| 483 | |
| 484 | mPingHostnameResultV4 = b.getString("mPingHostnameResultV4",""); |
| 485 | mPingHostnameResultV6 = b.getString("mPingHostnameResultV6",""); |
| 486 | mHttpClientTestResult = b.getString("mHttpClientTestResult",""); |
| 487 | |
| 488 | mPingHostnameV4.setText(mPingHostnameResultV4); |
| 489 | mPingHostnameV6.setText(mPingHostnameResultV6); |
| 490 | mHttpClientTest.setText(mHttpClientTestResult); |
| 491 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 492 | mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult", |
| 493 | mPreferredNetworkLabels.length - 1); |
| 494 | |
| 495 | mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | @Override |
| 499 | protected void onSaveInstanceState(Bundle outState) { |
| 500 | outState.putString("mPingHostnameResultV4", mPingHostnameResultV4); |
| 501 | outState.putString("mPingHostnameResultV6", mPingHostnameResultV6); |
| 502 | outState.putString("mHttpClientTestResult", mHttpClientTestResult); |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 503 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 504 | outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult); |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 505 | outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex); |
| 506 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 507 | } |
| 508 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 509 | @Override |
| 510 | public boolean onCreateOptionsMenu(Menu menu) { |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 511 | menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label) |
| 512 | .setOnMenuItemClickListener(mSelectBandCallback) |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 513 | .setAlphabeticShortcut('b'); |
| 514 | menu.add(1, MENU_ITEM_VIEW_ADN, 0, |
| 515 | R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback); |
| 516 | menu.add(1, MENU_ITEM_VIEW_FDN, 0, |
| 517 | R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback); |
| 518 | menu.add(1, MENU_ITEM_VIEW_SDN, 0, |
| 519 | R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback); |
| 520 | menu.add(1, MENU_ITEM_GET_PDP_LIST, |
| 521 | 0, R.string.radioInfo_menu_getPDP).setOnMenuItemClickListener(mGetPdpList); |
| 522 | menu.add(1, MENU_ITEM_TOGGLE_DATA, |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 523 | 0, R.string.radio_info_data_connection_disable).setOnMenuItemClickListener(mToggleData); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 524 | return true; |
| 525 | } |
| 526 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 527 | @Override |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 528 | public boolean onPrepareOptionsMenu(Menu menu) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 529 | // Get the TOGGLE DATA menu item in the right state. |
| 530 | MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA); |
| 531 | int state = mTelephonyManager.getDataState(); |
| 532 | boolean visible = true; |
| 533 | |
| 534 | switch (state) { |
| 535 | case TelephonyManager.DATA_CONNECTED: |
| 536 | case TelephonyManager.DATA_SUSPENDED: |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 537 | item.setTitle(R.string.radio_info_data_connection_disable); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 538 | break; |
| 539 | case TelephonyManager.DATA_DISCONNECTED: |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 540 | item.setTitle(R.string.radio_info_data_connection_enable); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 541 | break; |
| 542 | default: |
| 543 | visible = false; |
| 544 | break; |
| 545 | } |
| 546 | item.setVisible(visible); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 547 | return true; |
| 548 | } |
| 549 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 550 | private void updateDnsCheckState() { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 551 | //FIXME: Replace with a TelephonyManager call |
Mike Lockwood | 5304c7e | 2009-04-05 11:37:45 -0700 | [diff] [blame] | 552 | dnsCheckState.setText(phone.isDnsCheckDisabled() ? |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 553 | "0.0.0.0 allowed" :"0.0.0.0 not allowed"); |
| 554 | } |
Wink Saville | e2a14e3 | 2009-05-29 14:06:30 -0700 | [diff] [blame] | 555 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 556 | private final void |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 557 | updateSignalStrength(SignalStrength signalStrength) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 558 | Resources r = getResources(); |
| 559 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 560 | int signalDbm = signalStrength.getDbm(); |
Wink Saville | e2a14e3 | 2009-05-29 14:06:30 -0700 | [diff] [blame] | 561 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 562 | int signalAsu = signalStrength.getAsuLevel(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 563 | |
| 564 | if (-1 == signalAsu) signalAsu = 0; |
| 565 | |
| 566 | dBm.setText(String.valueOf(signalDbm) + " " |
| 567 | + r.getString(R.string.radioInfo_display_dbm) + " " |
| 568 | + String.valueOf(signalAsu) + " " |
| 569 | + r.getString(R.string.radioInfo_display_asu)); |
| 570 | } |
| 571 | |
| 572 | private final void updateLocation(CellLocation location) { |
jsh | 534f5ae | 2009-09-24 09:19:22 -0700 | [diff] [blame] | 573 | Resources r = getResources(); |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 574 | if (location instanceof GsmCellLocation) { |
| 575 | GsmCellLocation loc = (GsmCellLocation)location; |
jsh | 534f5ae | 2009-09-24 09:19:22 -0700 | [diff] [blame] | 576 | int lac = loc.getLac(); |
| 577 | int cid = loc.getCid(); |
| 578 | mLocation.setText(r.getString(R.string.radioInfo_lac) + " = " |
| 579 | + ((lac == -1) ? "unknown" : Integer.toHexString(lac)) |
| 580 | + " " |
| 581 | + r.getString(R.string.radioInfo_cid) + " = " |
| 582 | + ((cid == -1) ? "unknown" : Integer.toHexString(cid))); |
| 583 | } else if (location instanceof CdmaCellLocation) { |
| 584 | CdmaCellLocation loc = (CdmaCellLocation)location; |
| 585 | int bid = loc.getBaseStationId(); |
| 586 | int sid = loc.getSystemId(); |
| 587 | int nid = loc.getNetworkId(); |
| 588 | int lat = loc.getBaseStationLatitude(); |
| 589 | int lon = loc.getBaseStationLongitude(); |
| 590 | mLocation.setText("BID = " |
| 591 | + ((bid == -1) ? "unknown" : Integer.toHexString(bid)) |
| 592 | + " " |
| 593 | + "SID = " |
| 594 | + ((sid == -1) ? "unknown" : Integer.toHexString(sid)) |
| 595 | + " " |
| 596 | + "NID = " |
| 597 | + ((nid == -1) ? "unknown" : Integer.toHexString(nid)) |
| 598 | + "\n" |
| 599 | + "LAT = " |
| 600 | + ((lat == -1) ? "unknown" : Integer.toHexString(lat)) |
| 601 | + " " |
| 602 | + "LONG = " |
| 603 | + ((lon == -1) ? "unknown" : Integer.toHexString(lon))); |
| 604 | } else { |
| 605 | mLocation.setText("unknown"); |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 606 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 607 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 608 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 609 | } |
| 610 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 611 | private final void updateNeighboringCids(List<NeighboringCellInfo> cids) { |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 612 | StringBuilder sb = new StringBuilder(); |
| 613 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 614 | if (cids != null) { |
| 615 | if ( cids.isEmpty() ) { |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 616 | sb.append("no neighboring cells"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 617 | } else { |
| 618 | for (NeighboringCellInfo cell : cids) { |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 619 | sb.append(cell.toString()).append(" "); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 620 | } |
| 621 | } |
| 622 | } else { |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 623 | sb.append("unknown"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 624 | } |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 625 | mNeighboringCids.setText(sb.toString()); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 626 | } |
| 627 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 628 | private final String getCellInfoDisplayString(int i) { |
| 629 | return (i != Integer.MAX_VALUE) ? Integer.toString(i) : ""; |
| 630 | } |
| 631 | |
| 632 | private final String getCellInfoDisplayString(long i) { |
| 633 | return (i != Long.MAX_VALUE) ? Long.toString(i) : ""; |
| 634 | } |
| 635 | |
| 636 | private final String buildCdmaInfoString(CellInfoCdma ci) { |
| 637 | CellIdentityCdma cidCdma = ci.getCellIdentity(); |
| 638 | CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength(); |
| 639 | |
| 640 | return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s", |
| 641 | ci.isRegistered() ? "S " : " ", |
| 642 | getCellInfoDisplayString(cidCdma.getSystemId()), |
| 643 | getCellInfoDisplayString(cidCdma.getNetworkId()), |
| 644 | getCellInfoDisplayString(cidCdma.getBasestationId()), |
| 645 | getCellInfoDisplayString(ssCdma.getCdmaDbm()), |
| 646 | getCellInfoDisplayString(ssCdma.getCdmaEcio()), |
| 647 | getCellInfoDisplayString(ssCdma.getEvdoDbm()), |
| 648 | getCellInfoDisplayString(ssCdma.getEvdoEcio()), |
| 649 | getCellInfoDisplayString(ssCdma.getEvdoSnr())); |
| 650 | } |
| 651 | |
| 652 | private final String buildGsmInfoString(CellInfoGsm ci) { |
| 653 | CellIdentityGsm cidGsm = ci.getCellIdentity(); |
| 654 | CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength(); |
| 655 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 656 | return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 657 | ci.isRegistered() ? "S " : " ", |
| 658 | getCellInfoDisplayString(cidGsm.getMcc()), |
| 659 | getCellInfoDisplayString(cidGsm.getMnc()), |
| 660 | getCellInfoDisplayString(cidGsm.getLac()), |
| 661 | getCellInfoDisplayString(cidGsm.getCid()), |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 662 | getCellInfoDisplayString(cidGsm.getArfcn()), |
| 663 | getCellInfoDisplayString(cidGsm.getBsic()), |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 664 | getCellInfoDisplayString(ssGsm.getDbm())); |
| 665 | } |
| 666 | |
| 667 | private final String buildLteInfoString(CellInfoLte ci) { |
| 668 | CellIdentityLte cidLte = ci.getCellIdentity(); |
| 669 | CellSignalStrengthLte ssLte = ci.getCellSignalStrength(); |
| 670 | |
| 671 | return String.format( |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 672 | "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n", |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 673 | ci.isRegistered() ? "S " : " ", |
| 674 | getCellInfoDisplayString(cidLte.getMcc()), |
| 675 | getCellInfoDisplayString(cidLte.getMnc()), |
| 676 | getCellInfoDisplayString(cidLte.getTac()), |
| 677 | getCellInfoDisplayString(cidLte.getCi()), |
| 678 | getCellInfoDisplayString(cidLte.getPci()), |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 679 | getCellInfoDisplayString(cidLte.getEarfcn()), |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 680 | getCellInfoDisplayString(ssLte.getDbm()), |
| 681 | getCellInfoDisplayString(ssLte.getRsrq()), |
| 682 | getCellInfoDisplayString(ssLte.getTimingAdvance())); |
| 683 | } |
| 684 | |
| 685 | private final String buildWcdmaInfoString(CellInfoWcdma ci) { |
| 686 | CellIdentityWcdma cidWcdma = ci.getCellIdentity(); |
| 687 | CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength(); |
| 688 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 689 | return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n", |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 690 | ci.isRegistered() ? "S " : " ", |
| 691 | getCellInfoDisplayString(cidWcdma.getMcc()), |
| 692 | getCellInfoDisplayString(cidWcdma.getMnc()), |
| 693 | getCellInfoDisplayString(cidWcdma.getLac()), |
| 694 | getCellInfoDisplayString(cidWcdma.getCid()), |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 695 | getCellInfoDisplayString(cidWcdma.getUarfcn()), |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 696 | getCellInfoDisplayString(cidWcdma.getPsc()), |
| 697 | getCellInfoDisplayString(ssWcdma.getDbm())); |
| 698 | } |
| 699 | |
| 700 | private final String buildCellInfoString(List<CellInfo> arrayCi) { |
| 701 | String value = new String(); |
| 702 | StringBuilder cdmaCells = new StringBuilder(), |
| 703 | gsmCells = new StringBuilder(), |
| 704 | lteCells = new StringBuilder(), |
| 705 | wcdmaCells = new StringBuilder(); |
| 706 | |
| 707 | if (arrayCi != null) { |
| 708 | for (CellInfo ci : arrayCi) { |
| 709 | |
| 710 | if (ci instanceof CellInfoLte) { |
| 711 | lteCells.append(buildLteInfoString((CellInfoLte) ci)); |
| 712 | } else if (ci instanceof CellInfoWcdma) { |
| 713 | wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci)); |
| 714 | } else if (ci instanceof CellInfoGsm) { |
| 715 | gsmCells.append(buildGsmInfoString((CellInfoGsm) ci)); |
| 716 | } else if (ci instanceof CellInfoCdma) { |
| 717 | cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci)); |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 718 | } |
| 719 | } |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 720 | if (lteCells.length() != 0) { |
| 721 | value += String.format( |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 722 | "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n", |
| 723 | "SRV", "MCC", "MNC", "TAC", "CID", "PCI", "EARFCN", "RSRP", "RSRQ", "TA"); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 724 | value += lteCells.toString(); |
| 725 | } |
| 726 | if (wcdmaCells.length() != 0) { |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 727 | value += String.format("WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n", |
| 728 | "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP"); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 729 | value += wcdmaCells.toString(); |
| 730 | } |
| 731 | if (gsmCells.length() != 0) { |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 732 | value += String.format("GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", |
| 733 | "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI"); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 734 | value += gsmCells.toString(); |
| 735 | } |
| 736 | if (cdmaCells.length() != 0) { |
| 737 | value += String.format( |
| 738 | "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n", |
| 739 | "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR"); |
| 740 | value += cdmaCells.toString(); |
| 741 | } |
| 742 | } else { |
| 743 | value ="unknown"; |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 744 | } |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 745 | |
| 746 | return value.toString(); |
| 747 | } |
| 748 | |
| 749 | private final void updateCellInfo(List<CellInfo> arrayCi) { |
| 750 | mCellInfo.setText(buildCellInfoString(arrayCi)); |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 751 | } |
| 752 | |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame] | 753 | private final void updateDcRtInfoTv(DataConnectionRealTimeInfo dcRtInfo) { |
| 754 | mDcRtInfoTv.setText(dcRtInfo.toString()); |
| 755 | } |
| 756 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 757 | private final void |
| 758 | updateMessageWaiting() { |
| 759 | mMwi.setText(String.valueOf(mMwiValue)); |
| 760 | } |
| 761 | |
| 762 | private final void |
| 763 | updateCallRedirect() { |
| 764 | mCfi.setText(String.valueOf(mCfiValue)); |
| 765 | } |
| 766 | |
| 767 | |
| 768 | private final void |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 769 | updateServiceState(ServiceState serviceState) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 770 | int state = serviceState.getState(); |
| 771 | Resources r = getResources(); |
| 772 | String display = r.getString(R.string.radioInfo_unknown); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 773 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 774 | switch (state) { |
| 775 | case ServiceState.STATE_IN_SERVICE: |
| 776 | display = r.getString(R.string.radioInfo_service_in); |
| 777 | break; |
| 778 | case ServiceState.STATE_OUT_OF_SERVICE: |
| 779 | case ServiceState.STATE_EMERGENCY_ONLY: |
| 780 | display = r.getString(R.string.radioInfo_service_emergency); |
| 781 | break; |
| 782 | case ServiceState.STATE_POWER_OFF: |
| 783 | display = r.getString(R.string.radioInfo_service_off); |
| 784 | break; |
| 785 | } |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 786 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 787 | gsmState.setText(display); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 788 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 789 | if (serviceState.getRoaming()) { |
| 790 | roamingState.setText(R.string.radioInfo_roaming_in); |
| 791 | } else { |
| 792 | roamingState.setText(R.string.radioInfo_roaming_not); |
| 793 | } |
| 794 | |
| 795 | operatorName.setText(serviceState.getOperatorAlphaLong()); |
| 796 | } |
| 797 | |
| 798 | private final void |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 799 | updatePhoneState(int state) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 800 | Resources r = getResources(); |
| 801 | String display = r.getString(R.string.radioInfo_unknown); |
| 802 | |
| 803 | switch (state) { |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 804 | case TelephonyManager.CALL_STATE_IDLE: |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 805 | display = r.getString(R.string.radioInfo_phone_idle); |
| 806 | break; |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 807 | case TelephonyManager.CALL_STATE_RINGING: |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 808 | display = r.getString(R.string.radioInfo_phone_ringing); |
| 809 | break; |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 810 | case TelephonyManager.CALL_STATE_OFFHOOK: |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 811 | display = r.getString(R.string.radioInfo_phone_offhook); |
| 812 | break; |
| 813 | } |
| 814 | |
| 815 | callState.setText(display); |
| 816 | } |
| 817 | |
| 818 | private final void |
| 819 | updateDataState() { |
| 820 | int state = mTelephonyManager.getDataState(); |
| 821 | Resources r = getResources(); |
| 822 | String display = r.getString(R.string.radioInfo_unknown); |
| 823 | |
| 824 | switch (state) { |
| 825 | case TelephonyManager.DATA_CONNECTED: |
| 826 | display = r.getString(R.string.radioInfo_data_connected); |
| 827 | break; |
| 828 | case TelephonyManager.DATA_CONNECTING: |
| 829 | display = r.getString(R.string.radioInfo_data_connecting); |
| 830 | break; |
| 831 | case TelephonyManager.DATA_DISCONNECTED: |
| 832 | display = r.getString(R.string.radioInfo_data_disconnected); |
| 833 | break; |
| 834 | case TelephonyManager.DATA_SUSPENDED: |
| 835 | display = r.getString(R.string.radioInfo_data_suspended); |
| 836 | break; |
| 837 | } |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 838 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 839 | gprsState.setText(display); |
| 840 | } |
| 841 | |
| 842 | private final void updateNetworkType() { |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 843 | if( phone != null ) { |
| 844 | ServiceState ss = phone.getServiceState(); |
| 845 | dataNetwork.setText(ServiceState.rilRadioTechnologyToString( |
| 846 | phone.getServiceState().getRilDataRadioTechnology())); |
| 847 | voiceNetwork.setText(ServiceState.rilRadioTechnologyToString( |
| 848 | phone.getServiceState().getRilVoiceRadioTechnology())); |
| 849 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | private final void |
| 853 | updateProperties() { |
| 854 | String s; |
| 855 | Resources r = getResources(); |
| 856 | |
| 857 | s = phone.getDeviceId(); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 858 | if (s == null) s = r.getString(R.string.radioInfo_unknown); |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 859 | mDeviceId.setText(s); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 860 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 861 | //FIXME: Replace with a TelephonyManager call |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 862 | s = phone.getLine1Number(); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 863 | if (s == null) s = r.getString(R.string.radioInfo_unknown); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 864 | number.setText(s); |
| 865 | } |
| 866 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 867 | private final void updateDataStats2() { |
| 868 | Resources r = getResources(); |
| 869 | |
Jeff Sharkey | 9302986 | 2011-05-27 18:26:15 -0700 | [diff] [blame] | 870 | long txPackets = TrafficStats.getMobileTxPackets(); |
| 871 | long rxPackets = TrafficStats.getMobileRxPackets(); |
| 872 | long txBytes = TrafficStats.getMobileTxBytes(); |
| 873 | long rxBytes = TrafficStats.getMobileRxBytes(); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 874 | |
Jeff Sharkey | 9302986 | 2011-05-27 18:26:15 -0700 | [diff] [blame] | 875 | String packets = r.getString(R.string.radioInfo_display_packets); |
| 876 | String bytes = r.getString(R.string.radioInfo_display_bytes); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 877 | |
Jeff Sharkey | 9302986 | 2011-05-27 18:26:15 -0700 | [diff] [blame] | 878 | sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes); |
| 879 | received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | /** |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 883 | * Ping a host name |
| 884 | */ |
| 885 | private final void pingHostname() { |
| 886 | try { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 887 | try { |
| 888 | Process p4 = Runtime.getRuntime().exec("ping -c 1 www.google.com"); |
| 889 | int status4 = p4.waitFor(); |
| 890 | if (status4 == 0) { |
| 891 | mPingHostnameResultV4 = "Pass"; |
| 892 | } else { |
| 893 | mPingHostnameResultV4 = String.format("Fail(%d)", status4); |
| 894 | } |
| 895 | } catch (IOException e) { |
| 896 | mPingHostnameResultV4 = "Fail: IOException"; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 897 | } |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 898 | try { |
| 899 | Process p6 = Runtime.getRuntime().exec("ping6 -c 1 www.google.com"); |
| 900 | int status6 = p6.waitFor(); |
| 901 | if (status6 == 0) { |
| 902 | mPingHostnameResultV6 = "Pass"; |
| 903 | } else { |
| 904 | mPingHostnameResultV6 = String.format("Fail(%d)", status6); |
| 905 | } |
| 906 | } catch (IOException e) { |
| 907 | mPingHostnameResultV6 = "Fail: IOException"; |
| 908 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 909 | } catch (InterruptedException e) { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 910 | mPingHostnameResultV4 = mPingHostnameResultV6 = "Fail: InterruptedException"; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 911 | } |
| 912 | } |
| 913 | |
| 914 | /** |
| 915 | * This function checks for basic functionality of HTTP Client. |
| 916 | */ |
| 917 | private void httpClientTest() { |
Narayan Kamath | f25627c | 2014-12-12 13:53:28 +0000 | [diff] [blame] | 918 | HttpURLConnection urlConnection = null; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 919 | try { |
Narayan Kamath | f25627c | 2014-12-12 13:53:28 +0000 | [diff] [blame] | 920 | // TODO: Hardcoded for now, make it UI configurable |
Alex Klyubin | b009023 | 2015-04-02 11:08:51 -0700 | [diff] [blame] | 921 | URL url = new URL("https://www.google.com"); |
Narayan Kamath | f25627c | 2014-12-12 13:53:28 +0000 | [diff] [blame] | 922 | urlConnection = (HttpURLConnection) url.openConnection(); |
| 923 | if (urlConnection.getResponseCode() == 200) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 924 | mHttpClientTestResult = "Pass"; |
| 925 | } else { |
Narayan Kamath | f25627c | 2014-12-12 13:53:28 +0000 | [diff] [blame] | 926 | mHttpClientTestResult = "Fail: Code: " + urlConnection.getResponseMessage(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 927 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 928 | } catch (IOException e) { |
| 929 | mHttpClientTestResult = "Fail: IOException"; |
Narayan Kamath | f25627c | 2014-12-12 13:53:28 +0000 | [diff] [blame] | 930 | } finally { |
| 931 | if (urlConnection != null) { |
| 932 | urlConnection.disconnect(); |
| 933 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 934 | } |
| 935 | } |
| 936 | |
| 937 | private void refreshSmsc() { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 938 | //FIXME: Replace with a TelephonyManager call |
jsh | 21dd407 | 2009-05-12 11:26:55 -0700 | [diff] [blame] | 939 | phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE)); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 940 | } |
| 941 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 942 | private final void updateAllCellInfo() { |
| 943 | |
| 944 | mCellInfo.setText(""); |
| 945 | mNeighboringCids.setText(""); |
| 946 | mLocation.setText(""); |
| 947 | |
| 948 | final Runnable updateAllCellInfoResults = new Runnable() { |
| 949 | public void run() { |
| 950 | updateNeighboringCids(mNeighboringCellResult); |
| 951 | updateLocation(mCellLocationResult); |
| 952 | updateCellInfo(mCellInfoResult); |
| 953 | } |
| 954 | }; |
| 955 | |
| 956 | Thread locThread = new Thread() { |
| 957 | @Override |
| 958 | public void run() { |
| 959 | mCellInfoResult = mTelephonyManager.getAllCellInfo(); |
| 960 | mCellLocationResult = mTelephonyManager.getCellLocation(); |
| 961 | mNeighboringCellResult = mTelephonyManager.getNeighboringCellInfo(); |
| 962 | |
| 963 | mHandler.post(updateAllCellInfoResults); |
| 964 | } |
| 965 | }; |
| 966 | locThread.start(); |
| 967 | } |
| 968 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 969 | private final void updatePingState() { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 970 | // Set all to unknown since the threads will take a few secs to update. |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 971 | mPingHostnameResultV4 = getResources().getString(R.string.radioInfo_unknown); |
| 972 | mPingHostnameResultV6 = getResources().getString(R.string.radioInfo_unknown); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 973 | mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown); |
| 974 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 975 | mPingHostnameV4.setText(mPingHostnameResultV4); |
| 976 | mPingHostnameV6.setText(mPingHostnameResultV6); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 977 | mHttpClientTest.setText(mHttpClientTestResult); |
| 978 | |
| 979 | final Runnable updatePingResults = new Runnable() { |
| 980 | public void run() { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 981 | mPingHostnameV4.setText(mPingHostnameResultV4); |
| 982 | mPingHostnameV6.setText(mPingHostnameResultV6); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 983 | mHttpClientTest.setText(mHttpClientTestResult); |
| 984 | } |
| 985 | }; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 986 | |
| 987 | Thread hostname = new Thread() { |
| 988 | @Override |
| 989 | public void run() { |
| 990 | pingHostname(); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 991 | mHandler.post(updatePingResults); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 992 | } |
| 993 | }; |
| 994 | hostname.start(); |
| 995 | |
| 996 | Thread httpClient = new Thread() { |
| 997 | @Override |
| 998 | public void run() { |
| 999 | httpClientTest(); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 1000 | mHandler.post(updatePingResults); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1001 | } |
| 1002 | }; |
| 1003 | httpClient.start(); |
| 1004 | } |
| 1005 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1006 | private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() { |
| 1007 | public boolean onMenuItemClick(MenuItem item) { |
| 1008 | Intent intent = new Intent(Intent.ACTION_VIEW); |
| 1009 | // XXX We need to specify the component here because if we don't |
| 1010 | // the activity manager will try to resolve the type by calling |
| 1011 | // the content provider, which causes it to be loaded in a process |
| 1012 | // other than the Dialer process, which causes a lot of stuff to |
| 1013 | // break. |
| 1014 | intent.setClassName("com.android.phone", |
| 1015 | "com.android.phone.SimContacts"); |
| 1016 | startActivity(intent); |
| 1017 | return true; |
| 1018 | } |
| 1019 | }; |
| 1020 | |
| 1021 | private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() { |
| 1022 | public boolean onMenuItemClick(MenuItem item) { |
| 1023 | Intent intent = new Intent(Intent.ACTION_VIEW); |
| 1024 | // XXX We need to specify the component here because if we don't |
| 1025 | // the activity manager will try to resolve the type by calling |
| 1026 | // the content provider, which causes it to be loaded in a process |
| 1027 | // other than the Dialer process, which causes a lot of stuff to |
| 1028 | // break. |
| 1029 | intent.setClassName("com.android.phone", |
Andrew Lee | da90d68 | 2014-10-31 13:12:20 -0700 | [diff] [blame] | 1030 | "com.android.phone.settings.fdn.FdnList"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1031 | startActivity(intent); |
| 1032 | return true; |
| 1033 | } |
| 1034 | }; |
| 1035 | |
| 1036 | private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() { |
| 1037 | public boolean onMenuItemClick(MenuItem item) { |
| 1038 | Intent intent = new Intent( |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 1039 | Intent.ACTION_VIEW, Uri.parse("content://icc/sdn")); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1040 | // XXX We need to specify the component here because if we don't |
| 1041 | // the activity manager will try to resolve the type by calling |
| 1042 | // the content provider, which causes it to be loaded in a process |
| 1043 | // other than the Dialer process, which causes a lot of stuff to |
| 1044 | // break. |
| 1045 | intent.setClassName("com.android.phone", |
| 1046 | "com.android.phone.ADNList"); |
| 1047 | startActivity(intent); |
| 1048 | return true; |
| 1049 | } |
| 1050 | }; |
| 1051 | |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 1052 | private MenuItem.OnMenuItemClickListener mGetPdpList = new MenuItem.OnMenuItemClickListener() { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1053 | public boolean onMenuItemClick(MenuItem item) { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 1054 | //FIXME: Replace with a TelephonyManager call |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 1055 | phone.getDataCallList(null); |
| 1056 | return true; |
| 1057 | } |
| 1058 | }; |
| 1059 | |
| 1060 | private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() { |
| 1061 | public boolean onMenuItemClick(MenuItem item) { |
| 1062 | Intent intent = new Intent(); |
| 1063 | intent.setClass(RadioInfo.this, BandMode.class); |
| 1064 | startActivity(intent); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1065 | return true; |
| 1066 | } |
| 1067 | }; |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 1068 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1069 | private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() { |
| 1070 | public boolean onMenuItemClick(MenuItem item) { |
| 1071 | int state = mTelephonyManager.getDataState(); |
| 1072 | switch (state) { |
| 1073 | case TelephonyManager.DATA_CONNECTED: |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 1074 | //FIXME: Replace with a TelephonyManager call |
Robert Greenwalt | 0d4c500 | 2014-05-21 20:02:32 -0700 | [diff] [blame] | 1075 | phone.setDataEnabled(false); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1076 | break; |
| 1077 | case TelephonyManager.DATA_DISCONNECTED: |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 1078 | //FIXME: Replace with a TelephonyManager call |
Robert Greenwalt | 0d4c500 | 2014-05-21 20:02:32 -0700 | [diff] [blame] | 1079 | phone.setDataEnabled(true); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1080 | break; |
| 1081 | default: |
| 1082 | // do nothing |
| 1083 | break; |
| 1084 | } |
| 1085 | return true; |
| 1086 | } |
| 1087 | }; |
| 1088 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 1089 | private boolean isRadioOn() { |
| 1090 | //FIXME: Replace with a TelephonyManager call |
| 1091 | return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF; |
| 1092 | } |
| 1093 | |
| 1094 | private void updateRadioPowerState() { |
| 1095 | //delightful hack to prevent on-checked-changed calls from |
| 1096 | //actually forcing the radio preference to its transient/current value. |
| 1097 | radioPowerOnSwitch.setOnCheckedChangeListener(null); |
| 1098 | radioPowerOnSwitch.setChecked(isRadioOn()); |
| 1099 | radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener); |
| 1100 | } |
| 1101 | |
| 1102 | OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() { |
| 1103 | @Override |
| 1104 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
| 1105 | log("toggle radio power: currently " + (isRadioOn()?"on":"off")); |
| 1106 | phone.setRadioPower(isChecked); |
| 1107 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1108 | }; |
| 1109 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 1110 | void setImsVoLteProvisionedState( boolean state ) { |
| 1111 | log(String.format("toggle VoLTE provisioned: %s", ((state) ? "on":"off"))); |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1112 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 1113 | if (phone != null && mImsManager != null) { |
| 1114 | QueuedWork.singleThreadExecutor().submit(new Runnable() { |
| 1115 | public void run() { |
| 1116 | try { |
| 1117 | mImsManager.getConfigInterface().setProvisionedValue( |
| 1118 | ImsConfig.ConfigConstants.VLT_SETTING_ENABLED, |
| 1119 | state? 1 : 0); |
| 1120 | } catch (ImsException e) { |
| 1121 | Log.e(TAG, "setImsVoLteProvisioned() exception:", e); |
| 1122 | } |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 1123 | } |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 1124 | }); |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 1125 | } |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 1126 | } |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 1127 | |
| 1128 | private boolean isImsVoLteProvisioned() { |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 1129 | if (phone != null && mImsManager != null) { |
| 1130 | return mImsManager.isVolteEnabledByPlatform(phone.getContext()) |
| 1131 | && mImsManager.isVolteProvisionedOnDevice(phone.getContext()); |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 1132 | } |
| 1133 | return false; |
| 1134 | } |
| 1135 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 1136 | OnCheckedChangeListener mImsVoLteCheckedChangeListener = new OnCheckedChangeListener() { |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1137 | @Override |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 1138 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
| 1139 | setImsVoLteProvisionedState(isChecked); |
| 1140 | } |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1141 | }; |
| 1142 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 1143 | private void updateImsVoLteProvisionedState() { |
| 1144 | log("updateImsVoLteProvisionedState isImsVoLteProvisioned()=" + isImsVoLteProvisioned()); |
| 1145 | //delightful hack to prevent on-checked-changed calls from |
| 1146 | //actually forcing the ims provisioning to its transient/current value. |
| 1147 | imsVoLteProvisionedSwitch.setOnCheckedChangeListener(null); |
| 1148 | imsVoLteProvisionedSwitch.setChecked(isImsVoLteProvisioned()); |
| 1149 | imsVoLteProvisionedSwitch.setOnCheckedChangeListener(mImsVoLteCheckedChangeListener); |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1150 | } |
| 1151 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1152 | OnClickListener mDnsCheckButtonHandler = new OnClickListener() { |
| 1153 | public void onClick(View v) { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 1154 | //FIXME: Replace with a TelephonyManager call |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 1155 | phone.disableDnsCheck(!phone.isDnsCheckDisabled()); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1156 | updateDnsCheckState(); |
| 1157 | } |
| 1158 | }; |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 1159 | |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 1160 | OnClickListener mOemInfoButtonHandler = new OnClickListener() { |
| 1161 | public void onClick(View v) { |
| 1162 | Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO"); |
| 1163 | try { |
| 1164 | startActivity(intent); |
| 1165 | } catch (android.content.ActivityNotFoundException ex) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1166 | log("OEM-specific Info/Settings Activity Not Found : " + ex); |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 1167 | // If the activity does not exist, there are no OEM |
| 1168 | // settings, and so we can just do nothing... |
| 1169 | } |
| 1170 | } |
| 1171 | }; |
| 1172 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1173 | OnClickListener mPingButtonHandler = new OnClickListener() { |
| 1174 | public void onClick(View v) { |
| 1175 | updatePingState(); |
| 1176 | } |
| 1177 | }; |
| 1178 | |
| 1179 | OnClickListener mUpdateSmscButtonHandler = new OnClickListener() { |
| 1180 | public void onClick(View v) { |
| 1181 | updateSmscButton.setEnabled(false); |
jsh | 21dd407 | 2009-05-12 11:26:55 -0700 | [diff] [blame] | 1182 | phone.setSmscAddress(smsc.getText().toString(), |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1183 | mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE)); |
| 1184 | } |
| 1185 | }; |
| 1186 | |
| 1187 | OnClickListener mRefreshSmscButtonHandler = new OnClickListener() { |
| 1188 | public void onClick(View v) { |
| 1189 | refreshSmsc(); |
| 1190 | } |
| 1191 | }; |
| 1192 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 1193 | AdapterView.OnItemSelectedListener mPreferredNetworkHandler = |
| 1194 | new AdapterView.OnItemSelectedListener() { |
| 1195 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1196 | public void onItemSelected(AdapterView parent, View v, int pos, long id) { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame] | 1197 | if (mPreferredNetworkTypeResult != pos && pos >= 0 |
| 1198 | && pos <= mPreferredNetworkLabels.length - 2) { |
| 1199 | mPreferredNetworkTypeResult = pos; |
| 1200 | Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE); |
| 1201 | phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1202 | } |
| 1203 | } |
| 1204 | |
| 1205 | public void onNothingSelected(AdapterView parent) { |
| 1206 | } |
| 1207 | }; |
| 1208 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 1209 | AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler = |
| 1210 | new AdapterView.OnItemSelectedListener() { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1211 | |
Nathan Harold | 2b77d74 | 2016-03-19 13:22:10 -0700 | [diff] [blame] | 1212 | public void onItemSelected(AdapterView parent, View v, int pos, long id) { |
| 1213 | mCellInfoRefreshRateIndex = pos; |
| 1214 | phone.setCellInfoListRate(mCellInfoRefreshRates[pos]); |
| 1215 | updateAllCellInfo(); |
| 1216 | } |
| 1217 | |
| 1218 | public void onNothingSelected(AdapterView parent) { |
| 1219 | } |
| 1220 | }; |
| 1221 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1222 | } |