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; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 49 | import android.telephony.PhoneStateListener; |
| 50 | import android.telephony.ServiceState; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 51 | import android.telephony.SubscriptionManager; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 52 | import android.telephony.TelephonyManager; |
jsh | 534f5ae | 2009-09-24 09:19:22 -0700 | [diff] [blame] | 53 | import android.telephony.cdma.CdmaCellLocation; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 54 | import android.telephony.gsm.GsmCellLocation; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 55 | import android.util.Log; |
| 56 | import android.view.Menu; |
| 57 | import android.view.MenuItem; |
| 58 | import android.view.View; |
| 59 | import android.view.View.OnClickListener; |
| 60 | import android.widget.AdapterView; |
| 61 | import android.widget.ArrayAdapter; |
| 62 | import android.widget.Button; |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 63 | import android.widget.EditText; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 64 | import android.widget.Spinner; |
| 65 | import android.widget.TextView; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 66 | |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 67 | import com.android.ims.ImsConfig; |
| 68 | import com.android.ims.ImsException; |
| 69 | import com.android.ims.ImsManager; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 70 | import com.android.internal.telephony.Phone; |
Wink Saville | 5543404 | 2012-06-14 12:33:43 -0700 | [diff] [blame] | 71 | import com.android.internal.telephony.PhoneConstants; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 72 | import com.android.internal.telephony.PhoneFactory; |
| 73 | import com.android.internal.telephony.PhoneStateIntentReceiver; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 74 | import com.android.internal.telephony.RILConstants; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 75 | import com.android.internal.telephony.TelephonyProperties; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 76 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 77 | import java.io.IOException; |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 78 | import java.net.HttpURLConnection; |
| 79 | import java.net.URL; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 80 | import java.net.UnknownHostException; |
| 81 | import java.util.ArrayList; |
| 82 | import java.util.List; |
| 83 | |
| 84 | public class RadioInfo extends Activity { |
| 85 | private final String TAG = "phone"; |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 86 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 87 | private static final int EVENT_PHONE_STATE_CHANGED = 100; |
| 88 | private static final int EVENT_SIGNAL_STRENGTH_CHANGED = 200; |
| 89 | private static final int EVENT_SERVICE_STATE_CHANGED = 300; |
| 90 | private static final int EVENT_CFI_CHANGED = 302; |
| 91 | |
| 92 | private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000; |
| 93 | 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] | 94 | private static final int EVENT_QUERY_SMSC_DONE = 1005; |
| 95 | private static final int EVENT_UPDATE_SMSC_DONE = 1006; |
| 96 | |
| 97 | private static final int MENU_ITEM_SELECT_BAND = 0; |
| 98 | private static final int MENU_ITEM_VIEW_ADN = 1; |
| 99 | private static final int MENU_ITEM_VIEW_FDN = 2; |
| 100 | private static final int MENU_ITEM_VIEW_SDN = 3; |
| 101 | private static final int MENU_ITEM_GET_PDP_LIST = 4; |
| 102 | private static final int MENU_ITEM_TOGGLE_DATA = 5; |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 103 | |
| 104 | static final String ENABLE_DATA_STR = "Enable data connection"; |
| 105 | static final String DISABLE_DATA_STR = "Disable data connection"; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 106 | |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 107 | 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] | 108 | private TextView number; |
| 109 | private TextView callState; |
| 110 | private TextView operatorName; |
| 111 | private TextView roamingState; |
| 112 | private TextView gsmState; |
| 113 | private TextView gprsState; |
| 114 | private TextView network; |
| 115 | private TextView dBm; |
| 116 | private TextView mMwi; |
| 117 | private TextView mCfi; |
| 118 | private TextView mLocation; |
| 119 | private TextView mNeighboringCids; |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 120 | private TextView mCellInfo; |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame] | 121 | private TextView mDcRtInfoTv; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 122 | private TextView resets; |
| 123 | private TextView attempts; |
| 124 | private TextView successes; |
| 125 | private TextView disconnects; |
| 126 | private TextView sentSinceReceived; |
| 127 | private TextView sent; |
| 128 | private TextView received; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 129 | private TextView mPingHostnameV4; |
| 130 | private TextView mPingHostnameV6; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 131 | private TextView mHttpClientTest; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 132 | private TextView dnsCheckState; |
| 133 | private EditText smsc; |
| 134 | private Button radioPowerButton; |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 135 | private Button cellInfoListRateButton; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 136 | private Button dnsCheckToggleButton; |
| 137 | private Button pingTestButton; |
| 138 | private Button updateSmscButton; |
| 139 | private Button refreshSmscButton; |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 140 | private Button oemInfoButton; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 141 | private Spinner preferredNetworkType; |
| 142 | |
| 143 | private TelephonyManager mTelephonyManager; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 144 | private ImsManager mImsManager = null; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 145 | private Phone phone = null; |
| 146 | private PhoneStateIntentReceiver mPhoneStateReceiver; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 147 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 148 | private String mPingHostnameResultV4; |
| 149 | private String mPingHostnameResultV6; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 150 | private String mHttpClientTestResult; |
| 151 | private boolean mMwiValue = false; |
| 152 | private boolean mCfiValue = false; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 153 | |
| 154 | private List<CellInfo> mCellInfoResult = null; |
| 155 | private CellLocation mCellLocationResult = null; |
| 156 | private List<NeighboringCellInfo> mNeighboringCellResult = null; |
| 157 | |
| 158 | private int mPreferredNetworkTypeResult; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 159 | |
| 160 | private PhoneStateListener mPhoneStateListener = new PhoneStateListener() { |
| 161 | @Override |
| 162 | public void onDataConnectionStateChanged(int state) { |
| 163 | updateDataState(); |
| 164 | updateDataStats(); |
| 165 | updatePdpList(); |
| 166 | updateNetworkType(); |
| 167 | } |
| 168 | |
| 169 | @Override |
| 170 | public void onDataActivity(int direction) { |
| 171 | updateDataStats2(); |
| 172 | } |
| 173 | |
| 174 | @Override |
| 175 | public void onCellLocationChanged(CellLocation location) { |
| 176 | updateLocation(location); |
| 177 | } |
| 178 | |
| 179 | @Override |
| 180 | public void onMessageWaitingIndicatorChanged(boolean mwi) { |
| 181 | mMwiValue = mwi; |
| 182 | updateMessageWaiting(); |
| 183 | } |
| 184 | |
| 185 | @Override |
| 186 | public void onCallForwardingIndicatorChanged(boolean cfi) { |
| 187 | mCfiValue = cfi; |
| 188 | updateCallRedirect(); |
| 189 | } |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 190 | |
| 191 | @Override |
| 192 | public void onCellInfoChanged(List<CellInfo> arrayCi) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 193 | log("onCellInfoChanged: arrayCi=" + arrayCi); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 194 | mCellInfoResult = arrayCi; |
| 195 | updateCellInfo(mCellInfoResult); |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 196 | } |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame] | 197 | |
| 198 | @Override |
| 199 | public void onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo) { |
| 200 | log("onDataConnectionRealTimeInfoChanged: dcRtInfo=" + dcRtInfo); |
| 201 | updateDcRtInfoTv(dcRtInfo); |
| 202 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 203 | }; |
| 204 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 205 | private void updatePreferredNetworkType(int type) { |
| 206 | if (type >= mPreferredNetworkLabels.length || type < 0) { |
| 207 | log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " + |
| 208 | "type=" + type); |
| 209 | type = mPreferredNetworkLabels.length - 1; //set to Unknown |
| 210 | } |
| 211 | mPreferredNetworkTypeResult = type; |
| 212 | |
| 213 | preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true); |
| 214 | } |
| 215 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 216 | private Handler mHandler = new Handler() { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 217 | @Override |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 218 | public void handleMessage(Message msg) { |
| 219 | AsyncResult ar; |
| 220 | switch (msg.what) { |
| 221 | case EVENT_PHONE_STATE_CHANGED: |
| 222 | updatePhoneState(); |
| 223 | break; |
| 224 | |
| 225 | case EVENT_SIGNAL_STRENGTH_CHANGED: |
| 226 | updateSignalStrength(); |
| 227 | break; |
| 228 | |
| 229 | case EVENT_SERVICE_STATE_CHANGED: |
| 230 | updateServiceState(); |
| 231 | updatePowerState(); |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 232 | updateImsVoLteProvisionedState(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 233 | break; |
| 234 | |
| 235 | case EVENT_QUERY_PREFERRED_TYPE_DONE: |
| 236 | ar= (AsyncResult) msg.obj; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 237 | if (ar.exception == null && ar.result != null) { |
| 238 | updatePreferredNetworkType(((int[])ar.result)[0]); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 239 | } else { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 240 | //In case of an exception, we will set this to unknown |
| 241 | updatePreferredNetworkType(mPreferredNetworkLabels.length-1); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 242 | } |
| 243 | break; |
| 244 | case EVENT_SET_PREFERRED_TYPE_DONE: |
| 245 | ar= (AsyncResult) msg.obj; |
| 246 | if (ar.exception != null) { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 247 | log("Set preferred network type success."); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 248 | } |
| 249 | break; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 250 | case EVENT_QUERY_SMSC_DONE: |
| 251 | ar= (AsyncResult) msg.obj; |
| 252 | if (ar.exception != null) { |
| 253 | smsc.setText("refresh error"); |
| 254 | } else { |
jsh | 21dd407 | 2009-05-12 11:26:55 -0700 | [diff] [blame] | 255 | smsc.setText((String)ar.result); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 256 | } |
| 257 | break; |
| 258 | case EVENT_UPDATE_SMSC_DONE: |
| 259 | updateSmscButton.setEnabled(true); |
| 260 | ar= (AsyncResult) msg.obj; |
| 261 | if (ar.exception != null) { |
| 262 | smsc.setText("update error"); |
| 263 | } |
| 264 | break; |
| 265 | default: |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 266 | super.handleMessage(msg); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 267 | break; |
| 268 | |
| 269 | } |
| 270 | } |
| 271 | }; |
| 272 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 273 | @Override |
| 274 | public void onCreate(Bundle icicle) { |
| 275 | super.onCreate(icicle); |
| 276 | |
| 277 | setContentView(R.layout.radio_info); |
| 278 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 279 | log("Started onCreate"); |
| 280 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 281 | mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); |
| 282 | phone = PhoneFactory.getDefaultPhone(); |
| 283 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 284 | //TODO: Need to update this if the default phoneId changes? |
| 285 | // Better to have an instance per phone? |
| 286 | mImsManager = ImsManager.getInstance(getApplicationContext(), |
| 287 | SubscriptionManager.getDefaultVoicePhoneId()); |
| 288 | |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 289 | mDeviceId= (TextView) findViewById(R.id.imei); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 290 | number = (TextView) findViewById(R.id.number); |
| 291 | callState = (TextView) findViewById(R.id.call); |
| 292 | operatorName = (TextView) findViewById(R.id.operator); |
| 293 | roamingState = (TextView) findViewById(R.id.roaming); |
| 294 | gsmState = (TextView) findViewById(R.id.gsm); |
| 295 | gprsState = (TextView) findViewById(R.id.gprs); |
| 296 | network = (TextView) findViewById(R.id.network); |
| 297 | dBm = (TextView) findViewById(R.id.dbm); |
| 298 | mMwi = (TextView) findViewById(R.id.mwi); |
| 299 | mCfi = (TextView) findViewById(R.id.cfi); |
| 300 | mLocation = (TextView) findViewById(R.id.location); |
| 301 | mNeighboringCids = (TextView) findViewById(R.id.neighboring); |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 302 | mCellInfo = (TextView) findViewById(R.id.cellinfo); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 303 | mCellInfo.setTypeface(Typeface.MONOSPACE); |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame] | 304 | mDcRtInfoTv = (TextView) findViewById(R.id.dcrtinfo); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 305 | |
| 306 | resets = (TextView) findViewById(R.id.resets); |
| 307 | attempts = (TextView) findViewById(R.id.attempts); |
| 308 | successes = (TextView) findViewById(R.id.successes); |
| 309 | disconnects = (TextView) findViewById(R.id.disconnects); |
| 310 | sentSinceReceived = (TextView) findViewById(R.id.sentSinceReceived); |
| 311 | sent = (TextView) findViewById(R.id.sent); |
| 312 | received = (TextView) findViewById(R.id.received); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 313 | smsc = (EditText) findViewById(R.id.smsc); |
| 314 | dnsCheckState = (TextView) findViewById(R.id.dnsCheckState); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 315 | mPingHostnameV4 = (TextView) findViewById(R.id.pingHostnameV4); |
| 316 | mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 317 | mHttpClientTest = (TextView) findViewById(R.id.httpClientTest); |
| 318 | |
| 319 | preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType); |
| 320 | ArrayAdapter<String> adapter = new ArrayAdapter<String> (this, |
| 321 | android.R.layout.simple_spinner_item, mPreferredNetworkLabels); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 322 | adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 323 | preferredNetworkType.setAdapter(adapter); |
| 324 | preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler); |
| 325 | |
| 326 | radioPowerButton = (Button) findViewById(R.id.radio_power); |
| 327 | radioPowerButton.setOnClickListener(mPowerButtonHandler); |
| 328 | |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 329 | cellInfoListRateButton = (Button) findViewById(R.id.cell_info_list_rate); |
| 330 | cellInfoListRateButton.setOnClickListener(mCellInfoListRateHandler); |
| 331 | |
Wink Saville | 1e596f3 | 2011-09-19 14:24:39 -0700 | [diff] [blame] | 332 | imsRegRequiredButton = (Button) findViewById(R.id.ims_reg_required); |
| 333 | imsRegRequiredButton.setOnClickListener(mImsRegRequiredHandler); |
| 334 | |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 335 | imsVoLteProvisionedButton = (Button) findViewById(R.id.volte_provisioned_flag); |
| 336 | imsVoLteProvisionedButton.setOnClickListener(mImsVoLteProvisionedHandler); |
| 337 | |
Wink Saville | 382a75b | 2011-09-22 15:17:00 -0700 | [diff] [blame] | 338 | smsOverImsButton = (Button) findViewById(R.id.sms_over_ims); |
| 339 | smsOverImsButton.setOnClickListener(mSmsOverImsHandler); |
| 340 | |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 341 | lteRamDumpButton = (Button) findViewById(R.id.lte_ram_dump); |
| 342 | lteRamDumpButton.setOnClickListener(mLteRamDumpHandler); |
| 343 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 344 | pingTestButton = (Button) findViewById(R.id.ping_test); |
| 345 | pingTestButton.setOnClickListener(mPingButtonHandler); |
| 346 | updateSmscButton = (Button) findViewById(R.id.update_smsc); |
| 347 | updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler); |
| 348 | refreshSmscButton = (Button) findViewById(R.id.refresh_smsc); |
| 349 | refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler); |
| 350 | dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle); |
| 351 | dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 352 | |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 353 | oemInfoButton = (Button) findViewById(R.id.oem_info); |
| 354 | oemInfoButton.setOnClickListener(mOemInfoButtonHandler); |
| 355 | PackageManager pm = getPackageManager(); |
| 356 | Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO"); |
| 357 | List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0); |
| 358 | if (oemInfoIntentList.size() == 0) { |
| 359 | oemInfoButton.setEnabled(false); |
| 360 | } |
| 361 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 362 | mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler); |
| 363 | mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED); |
| 364 | mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED); |
| 365 | mPhoneStateReceiver.notifyPhoneCallState(EVENT_PHONE_STATE_CHANGED); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 366 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 367 | mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown |
| 368 | |
| 369 | //FIXME: Replace with TelephonyManager call |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 370 | phone.getPreferredNetworkType( |
| 371 | mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE)); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 372 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 373 | restoreFromBundle(icicle); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | @Override |
| 377 | protected void onResume() { |
| 378 | super.onResume(); |
| 379 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 380 | log("Started onResume"); |
| 381 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 382 | updatePhoneState(); |
| 383 | updateSignalStrength(); |
| 384 | updateMessageWaiting(); |
| 385 | updateCallRedirect(); |
| 386 | updateServiceState(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 387 | updateDataState(); |
| 388 | updateDataStats(); |
| 389 | updateDataStats2(); |
| 390 | updatePowerState(); |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 391 | updateCellInfoListRate(); |
Wink Saville | 1e596f3 | 2011-09-19 14:24:39 -0700 | [diff] [blame] | 392 | updateImsRegRequiredState(); |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 393 | updateImsVoLteProvisionedState(); |
Wink Saville | 382a75b | 2011-09-22 15:17:00 -0700 | [diff] [blame] | 394 | updateSmsOverImsState(); |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 395 | updateLteRamDumpState(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 396 | updateProperties(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 397 | updateDnsCheckState(); |
| 398 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 399 | updateNeighboringCids(mNeighboringCellResult); |
| 400 | updateLocation(mCellLocationResult); |
| 401 | updateCellInfo(mCellInfoResult); |
| 402 | |
| 403 | mPingHostnameV4.setText(mPingHostnameResultV4); |
| 404 | mPingHostnameV6.setText(mPingHostnameResultV6); |
| 405 | mHttpClientTest.setText(mHttpClientTestResult); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 406 | |
| 407 | mPhoneStateReceiver.registerIntent(); |
| 408 | mTelephonyManager.listen(mPhoneStateListener, |
| 409 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE |
| 410 | | PhoneStateListener.LISTEN_DATA_ACTIVITY |
| 411 | | PhoneStateListener.LISTEN_CELL_LOCATION |
| 412 | | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 413 | | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame] | 414 | | PhoneStateListener.LISTEN_CELL_INFO |
| 415 | | PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | @Override |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 419 | protected void onPause() { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 420 | super.onPause(); |
| 421 | |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 422 | log("onPause: unregister phone & data intents"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 423 | |
| 424 | mPhoneStateReceiver.unregisterIntent(); |
| 425 | mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); |
| 426 | } |
| 427 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 428 | private void restoreFromBundle(Bundle b) { |
| 429 | if( b == null) { |
| 430 | return; |
| 431 | } |
| 432 | |
| 433 | mPingHostnameResultV4 = b.getString("mPingHostnameResultV4",""); |
| 434 | mPingHostnameResultV6 = b.getString("mPingHostnameResultV6",""); |
| 435 | mHttpClientTestResult = b.getString("mHttpClientTestResult",""); |
| 436 | |
| 437 | mPingHostnameV4.setText(mPingHostnameResultV4); |
| 438 | mPingHostnameV6.setText(mPingHostnameResultV6); |
| 439 | mHttpClientTest.setText(mHttpClientTestResult); |
| 440 | |
| 441 | mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult", 0); |
| 442 | } |
| 443 | |
| 444 | @Override |
| 445 | protected void onSaveInstanceState(Bundle outState) { |
| 446 | outState.putString("mPingHostnameResultV4", mPingHostnameResultV4); |
| 447 | outState.putString("mPingHostnameResultV6", mPingHostnameResultV6); |
| 448 | outState.putString("mHttpClientTestResult", mHttpClientTestResult); |
| 449 | outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult); |
| 450 | } |
| 451 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 452 | @Override |
| 453 | public boolean onCreateOptionsMenu(Menu menu) { |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 454 | menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label) |
| 455 | .setOnMenuItemClickListener(mSelectBandCallback) |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 456 | .setAlphabeticShortcut('b'); |
| 457 | menu.add(1, MENU_ITEM_VIEW_ADN, 0, |
| 458 | R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback); |
| 459 | menu.add(1, MENU_ITEM_VIEW_FDN, 0, |
| 460 | R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback); |
| 461 | menu.add(1, MENU_ITEM_VIEW_SDN, 0, |
| 462 | R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback); |
| 463 | menu.add(1, MENU_ITEM_GET_PDP_LIST, |
| 464 | 0, R.string.radioInfo_menu_getPDP).setOnMenuItemClickListener(mGetPdpList); |
| 465 | menu.add(1, MENU_ITEM_TOGGLE_DATA, |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 466 | 0, DISABLE_DATA_STR).setOnMenuItemClickListener(mToggleData); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 467 | return true; |
| 468 | } |
| 469 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 470 | @Override |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 471 | public boolean onPrepareOptionsMenu(Menu menu) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 472 | // Get the TOGGLE DATA menu item in the right state. |
| 473 | MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA); |
| 474 | int state = mTelephonyManager.getDataState(); |
| 475 | boolean visible = true; |
| 476 | |
| 477 | switch (state) { |
| 478 | case TelephonyManager.DATA_CONNECTED: |
| 479 | case TelephonyManager.DATA_SUSPENDED: |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 480 | item.setTitle(DISABLE_DATA_STR); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 481 | break; |
| 482 | case TelephonyManager.DATA_DISCONNECTED: |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 483 | item.setTitle(ENABLE_DATA_STR); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 484 | break; |
| 485 | default: |
| 486 | visible = false; |
| 487 | break; |
| 488 | } |
| 489 | item.setVisible(visible); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 490 | return true; |
| 491 | } |
| 492 | |
| 493 | private boolean isRadioOn() { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 494 | //FIXME: Replace with a TelephonyManager call |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 495 | return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF; |
| 496 | } |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 497 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 498 | private void updatePowerState() { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 499 | String buttonText = isRadioOn() ? |
| 500 | getString(R.string.turn_off_radio) : |
| 501 | getString(R.string.turn_on_radio); |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 502 | radioPowerButton.setText(buttonText); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 503 | } |
| 504 | |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 505 | private void updateCellInfoListRate() { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 506 | int rate = mCellInfoListRateHandler.getRate(); |
| 507 | String rateStr; |
| 508 | switch(rate) { |
| 509 | case Integer.MAX_VALUE: |
| 510 | rateStr = "Off"; |
| 511 | break; |
| 512 | case 0: |
| 513 | rateStr = "Immediate"; |
| 514 | break; |
| 515 | default: |
| 516 | rateStr = (new Integer(rate)).toString() + "ms"; |
| 517 | break; |
| 518 | } |
| 519 | cellInfoListRateButton.setText("CellInfoListRate "+ rateStr); |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 520 | } |
| 521 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 522 | private void updateDnsCheckState() { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 523 | //FIXME: Replace with a TelephonyManager call |
Mike Lockwood | 5304c7e | 2009-04-05 11:37:45 -0700 | [diff] [blame] | 524 | dnsCheckState.setText(phone.isDnsCheckDisabled() ? |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 525 | "0.0.0.0 allowed" :"0.0.0.0 not allowed"); |
| 526 | } |
Wink Saville | e2a14e3 | 2009-05-29 14:06:30 -0700 | [diff] [blame] | 527 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 528 | private final void |
| 529 | updateSignalStrength() { |
Wink Saville | e2a14e3 | 2009-05-29 14:06:30 -0700 | [diff] [blame] | 530 | // TODO PhoneStateIntentReceiver is deprecated and PhoneStateListener |
| 531 | // should probably used instead. |
| 532 | int state = mPhoneStateReceiver.getServiceState().getState(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 533 | Resources r = getResources(); |
| 534 | |
| 535 | if ((ServiceState.STATE_OUT_OF_SERVICE == state) || |
| 536 | (ServiceState.STATE_POWER_OFF == state)) { |
| 537 | dBm.setText("0"); |
| 538 | } |
Wink Saville | e2a14e3 | 2009-05-29 14:06:30 -0700 | [diff] [blame] | 539 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 540 | int signalDbm = mPhoneStateReceiver.getSignalStrengthDbm(); |
Wink Saville | e2a14e3 | 2009-05-29 14:06:30 -0700 | [diff] [blame] | 541 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 542 | if (-1 == signalDbm) signalDbm = 0; |
| 543 | |
Wink Saville | 882c74a | 2011-02-17 12:00:03 -0800 | [diff] [blame] | 544 | int signalAsu = mPhoneStateReceiver.getSignalStrengthLevelAsu(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 545 | |
| 546 | if (-1 == signalAsu) signalAsu = 0; |
| 547 | |
| 548 | dBm.setText(String.valueOf(signalDbm) + " " |
| 549 | + r.getString(R.string.radioInfo_display_dbm) + " " |
| 550 | + String.valueOf(signalAsu) + " " |
| 551 | + r.getString(R.string.radioInfo_display_asu)); |
| 552 | } |
| 553 | |
| 554 | private final void updateLocation(CellLocation location) { |
jsh | 534f5ae | 2009-09-24 09:19:22 -0700 | [diff] [blame] | 555 | Resources r = getResources(); |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 556 | if (location instanceof GsmCellLocation) { |
| 557 | GsmCellLocation loc = (GsmCellLocation)location; |
jsh | 534f5ae | 2009-09-24 09:19:22 -0700 | [diff] [blame] | 558 | int lac = loc.getLac(); |
| 559 | int cid = loc.getCid(); |
| 560 | mLocation.setText(r.getString(R.string.radioInfo_lac) + " = " |
| 561 | + ((lac == -1) ? "unknown" : Integer.toHexString(lac)) |
| 562 | + " " |
| 563 | + r.getString(R.string.radioInfo_cid) + " = " |
| 564 | + ((cid == -1) ? "unknown" : Integer.toHexString(cid))); |
| 565 | } else if (location instanceof CdmaCellLocation) { |
| 566 | CdmaCellLocation loc = (CdmaCellLocation)location; |
| 567 | int bid = loc.getBaseStationId(); |
| 568 | int sid = loc.getSystemId(); |
| 569 | int nid = loc.getNetworkId(); |
| 570 | int lat = loc.getBaseStationLatitude(); |
| 571 | int lon = loc.getBaseStationLongitude(); |
| 572 | mLocation.setText("BID = " |
| 573 | + ((bid == -1) ? "unknown" : Integer.toHexString(bid)) |
| 574 | + " " |
| 575 | + "SID = " |
| 576 | + ((sid == -1) ? "unknown" : Integer.toHexString(sid)) |
| 577 | + " " |
| 578 | + "NID = " |
| 579 | + ((nid == -1) ? "unknown" : Integer.toHexString(nid)) |
| 580 | + "\n" |
| 581 | + "LAT = " |
| 582 | + ((lat == -1) ? "unknown" : Integer.toHexString(lat)) |
| 583 | + " " |
| 584 | + "LONG = " |
| 585 | + ((lon == -1) ? "unknown" : Integer.toHexString(lon))); |
| 586 | } else { |
| 587 | mLocation.setText("unknown"); |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 588 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 589 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 590 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 591 | } |
| 592 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 593 | private final void updateNeighboringCids(List<NeighboringCellInfo> cids) { |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 594 | StringBuilder sb = new StringBuilder(); |
| 595 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 596 | if (cids != null) { |
| 597 | if ( cids.isEmpty() ) { |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 598 | sb.append("no neighboring cells"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 599 | } else { |
| 600 | for (NeighboringCellInfo cell : cids) { |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 601 | sb.append(cell.toString()).append(" "); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 602 | } |
| 603 | } |
| 604 | } else { |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 605 | sb.append("unknown"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 606 | } |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 607 | mNeighboringCids.setText(sb.toString()); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 608 | } |
| 609 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 610 | private final String getCellInfoDisplayString(int i) { |
| 611 | return (i != Integer.MAX_VALUE) ? Integer.toString(i) : ""; |
| 612 | } |
| 613 | |
| 614 | private final String getCellInfoDisplayString(long i) { |
| 615 | return (i != Long.MAX_VALUE) ? Long.toString(i) : ""; |
| 616 | } |
| 617 | |
| 618 | private final String buildCdmaInfoString(CellInfoCdma ci) { |
| 619 | CellIdentityCdma cidCdma = ci.getCellIdentity(); |
| 620 | CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength(); |
| 621 | |
| 622 | return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s", |
| 623 | ci.isRegistered() ? "S " : " ", |
| 624 | getCellInfoDisplayString(cidCdma.getSystemId()), |
| 625 | getCellInfoDisplayString(cidCdma.getNetworkId()), |
| 626 | getCellInfoDisplayString(cidCdma.getBasestationId()), |
| 627 | getCellInfoDisplayString(ssCdma.getCdmaDbm()), |
| 628 | getCellInfoDisplayString(ssCdma.getCdmaEcio()), |
| 629 | getCellInfoDisplayString(ssCdma.getEvdoDbm()), |
| 630 | getCellInfoDisplayString(ssCdma.getEvdoEcio()), |
| 631 | getCellInfoDisplayString(ssCdma.getEvdoSnr())); |
| 632 | } |
| 633 | |
| 634 | private final String buildGsmInfoString(CellInfoGsm ci) { |
| 635 | CellIdentityGsm cidGsm = ci.getCellIdentity(); |
| 636 | CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength(); |
| 637 | |
| 638 | return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-4.4s %-4.4s\n", |
| 639 | ci.isRegistered() ? "S " : " ", |
| 640 | getCellInfoDisplayString(cidGsm.getMcc()), |
| 641 | getCellInfoDisplayString(cidGsm.getMnc()), |
| 642 | getCellInfoDisplayString(cidGsm.getLac()), |
| 643 | getCellInfoDisplayString(cidGsm.getCid()), |
| 644 | // TODO: Add BSIC support once integrated |
| 645 | // getCellInfoDisplayString(cidGsm.getBsic()), |
| 646 | " ", |
| 647 | getCellInfoDisplayString(ssGsm.getDbm())); |
| 648 | } |
| 649 | |
| 650 | private final String buildLteInfoString(CellInfoLte ci) { |
| 651 | CellIdentityLte cidLte = ci.getCellIdentity(); |
| 652 | CellSignalStrengthLte ssLte = ci.getCellSignalStrength(); |
| 653 | |
| 654 | return String.format( |
| 655 | "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-4.4s %-4.4s %-2.2s\n", |
| 656 | ci.isRegistered() ? "S " : " ", |
| 657 | getCellInfoDisplayString(cidLte.getMcc()), |
| 658 | getCellInfoDisplayString(cidLte.getMnc()), |
| 659 | getCellInfoDisplayString(cidLte.getTac()), |
| 660 | getCellInfoDisplayString(cidLte.getCi()), |
| 661 | getCellInfoDisplayString(cidLte.getPci()), |
| 662 | getCellInfoDisplayString(ssLte.getDbm()), |
| 663 | getCellInfoDisplayString(ssLte.getRsrq()), |
| 664 | getCellInfoDisplayString(ssLte.getTimingAdvance())); |
| 665 | } |
| 666 | |
| 667 | private final String buildWcdmaInfoString(CellInfoWcdma ci) { |
| 668 | CellIdentityWcdma cidWcdma = ci.getCellIdentity(); |
| 669 | CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength(); |
| 670 | |
| 671 | return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-5.5s %-4.4s\n", |
| 672 | ci.isRegistered() ? "S " : " ", |
| 673 | getCellInfoDisplayString(cidWcdma.getMcc()), |
| 674 | getCellInfoDisplayString(cidWcdma.getMnc()), |
| 675 | getCellInfoDisplayString(cidWcdma.getLac()), |
| 676 | getCellInfoDisplayString(cidWcdma.getCid()), |
| 677 | getCellInfoDisplayString(cidWcdma.getPsc()), |
| 678 | getCellInfoDisplayString(ssWcdma.getDbm())); |
| 679 | } |
| 680 | |
| 681 | private final String buildCellInfoString(List<CellInfo> arrayCi) { |
| 682 | String value = new String(); |
| 683 | StringBuilder cdmaCells = new StringBuilder(), |
| 684 | gsmCells = new StringBuilder(), |
| 685 | lteCells = new StringBuilder(), |
| 686 | wcdmaCells = new StringBuilder(); |
| 687 | |
| 688 | if (arrayCi != null) { |
| 689 | for (CellInfo ci : arrayCi) { |
| 690 | |
| 691 | if (ci instanceof CellInfoLte) { |
| 692 | lteCells.append(buildLteInfoString((CellInfoLte) ci)); |
| 693 | } else if (ci instanceof CellInfoWcdma) { |
| 694 | wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci)); |
| 695 | } else if (ci instanceof CellInfoGsm) { |
| 696 | gsmCells.append(buildGsmInfoString((CellInfoGsm) ci)); |
| 697 | } else if (ci instanceof CellInfoCdma) { |
| 698 | cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci)); |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 699 | } |
| 700 | } |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 701 | if (lteCells.length() != 0) { |
| 702 | value += String.format( |
| 703 | "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-4.4s %-4.4s %-2.2s\n", |
| 704 | "SRV", "MCC", "MNC", "TAC", "CID", "PCI", "RSRP", "RSRQ", "TA"); |
| 705 | value += lteCells.toString(); |
| 706 | } |
| 707 | if (wcdmaCells.length() != 0) { |
| 708 | value += String.format("WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-5.5s %-4.4s\n", |
| 709 | "SRV", "MCC", "MNC", "LAC", "CID", "PSC", "RSCP"); |
| 710 | value += wcdmaCells.toString(); |
| 711 | } |
| 712 | if (gsmCells.length() != 0) { |
| 713 | value += String.format("GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-4.4s %-4.4s\n", |
| 714 | "SRV", "MCC", "MNC", "LAC", "CID", "BSIC", "RSSI"); |
| 715 | value += gsmCells.toString(); |
| 716 | } |
| 717 | if (cdmaCells.length() != 0) { |
| 718 | value += String.format( |
| 719 | "CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n", |
| 720 | "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR"); |
| 721 | value += cdmaCells.toString(); |
| 722 | } |
| 723 | } else { |
| 724 | value ="unknown"; |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 725 | } |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 726 | |
| 727 | return value.toString(); |
| 728 | } |
| 729 | |
| 730 | private final void updateCellInfo(List<CellInfo> arrayCi) { |
| 731 | mCellInfo.setText(buildCellInfoString(arrayCi)); |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 732 | } |
| 733 | |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame] | 734 | private final void updateDcRtInfoTv(DataConnectionRealTimeInfo dcRtInfo) { |
| 735 | mDcRtInfoTv.setText(dcRtInfo.toString()); |
| 736 | } |
| 737 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 738 | private final void |
| 739 | updateMessageWaiting() { |
| 740 | mMwi.setText(String.valueOf(mMwiValue)); |
| 741 | } |
| 742 | |
| 743 | private final void |
| 744 | updateCallRedirect() { |
| 745 | mCfi.setText(String.valueOf(mCfiValue)); |
| 746 | } |
| 747 | |
| 748 | |
| 749 | private final void |
| 750 | updateServiceState() { |
| 751 | ServiceState serviceState = mPhoneStateReceiver.getServiceState(); |
| 752 | int state = serviceState.getState(); |
| 753 | Resources r = getResources(); |
| 754 | String display = r.getString(R.string.radioInfo_unknown); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 755 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 756 | switch (state) { |
| 757 | case ServiceState.STATE_IN_SERVICE: |
| 758 | display = r.getString(R.string.radioInfo_service_in); |
| 759 | break; |
| 760 | case ServiceState.STATE_OUT_OF_SERVICE: |
| 761 | case ServiceState.STATE_EMERGENCY_ONLY: |
| 762 | display = r.getString(R.string.radioInfo_service_emergency); |
| 763 | break; |
| 764 | case ServiceState.STATE_POWER_OFF: |
| 765 | display = r.getString(R.string.radioInfo_service_off); |
| 766 | break; |
| 767 | } |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 768 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 769 | gsmState.setText(display); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 770 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 771 | if (serviceState.getRoaming()) { |
| 772 | roamingState.setText(R.string.radioInfo_roaming_in); |
| 773 | } else { |
| 774 | roamingState.setText(R.string.radioInfo_roaming_not); |
| 775 | } |
| 776 | |
| 777 | operatorName.setText(serviceState.getOperatorAlphaLong()); |
| 778 | } |
| 779 | |
| 780 | private final void |
| 781 | updatePhoneState() { |
Wink Saville | 5543404 | 2012-06-14 12:33:43 -0700 | [diff] [blame] | 782 | PhoneConstants.State state = mPhoneStateReceiver.getPhoneState(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 783 | Resources r = getResources(); |
| 784 | String display = r.getString(R.string.radioInfo_unknown); |
| 785 | |
| 786 | switch (state) { |
| 787 | case IDLE: |
| 788 | display = r.getString(R.string.radioInfo_phone_idle); |
| 789 | break; |
| 790 | case RINGING: |
| 791 | display = r.getString(R.string.radioInfo_phone_ringing); |
| 792 | break; |
| 793 | case OFFHOOK: |
| 794 | display = r.getString(R.string.radioInfo_phone_offhook); |
| 795 | break; |
| 796 | } |
| 797 | |
| 798 | callState.setText(display); |
| 799 | } |
| 800 | |
| 801 | private final void |
| 802 | updateDataState() { |
| 803 | int state = mTelephonyManager.getDataState(); |
| 804 | Resources r = getResources(); |
| 805 | String display = r.getString(R.string.radioInfo_unknown); |
| 806 | |
| 807 | switch (state) { |
| 808 | case TelephonyManager.DATA_CONNECTED: |
| 809 | display = r.getString(R.string.radioInfo_data_connected); |
| 810 | break; |
| 811 | case TelephonyManager.DATA_CONNECTING: |
| 812 | display = r.getString(R.string.radioInfo_data_connecting); |
| 813 | break; |
| 814 | case TelephonyManager.DATA_DISCONNECTED: |
| 815 | display = r.getString(R.string.radioInfo_data_disconnected); |
| 816 | break; |
| 817 | case TelephonyManager.DATA_SUSPENDED: |
| 818 | display = r.getString(R.string.radioInfo_data_suspended); |
| 819 | break; |
| 820 | } |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 821 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 822 | gprsState.setText(display); |
| 823 | } |
| 824 | |
| 825 | private final void updateNetworkType() { |
| 826 | Resources r = getResources(); |
| 827 | String display = SystemProperties.get(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, |
| 828 | r.getString(R.string.radioInfo_unknown)); |
| 829 | |
| 830 | network.setText(display); |
| 831 | } |
| 832 | |
| 833 | private final void |
| 834 | updateProperties() { |
| 835 | String s; |
| 836 | Resources r = getResources(); |
| 837 | |
| 838 | s = phone.getDeviceId(); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 839 | if (s == null) s = r.getString(R.string.radioInfo_unknown); |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 840 | mDeviceId.setText(s); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 841 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 842 | //FIXME: Replace with a TelephonyManager call |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 843 | s = phone.getLine1Number(); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 844 | 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] | 845 | number.setText(s); |
| 846 | } |
| 847 | |
| 848 | private final void updateDataStats() { |
| 849 | String s; |
| 850 | |
| 851 | s = SystemProperties.get("net.gsm.radio-reset", "0"); |
| 852 | resets.setText(s); |
| 853 | |
| 854 | s = SystemProperties.get("net.gsm.attempt-gprs", "0"); |
| 855 | attempts.setText(s); |
| 856 | |
| 857 | s = SystemProperties.get("net.gsm.succeed-gprs", "0"); |
| 858 | successes.setText(s); |
| 859 | |
| 860 | //s = SystemProperties.get("net.gsm.disconnect", "0"); |
| 861 | //disconnects.setText(s); |
| 862 | |
| 863 | s = SystemProperties.get("net.ppp.reset-by-timeout", "0"); |
| 864 | sentSinceReceived.setText(s); |
| 865 | } |
| 866 | |
| 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 | |
| 1006 | private final void updatePdpList() { |
| 1007 | StringBuilder sb = new StringBuilder("========DATA=======\n"); |
| 1008 | |
Wink Saville | 2c3ec09 | 2011-04-20 10:24:36 -0700 | [diff] [blame] | 1009 | // List<DataConnection> dcs = phone.getCurrentDataConnectionList(); |
| 1010 | // |
| 1011 | // for (DataConnection dc : dcs) { |
| 1012 | // sb.append(" State=").append(dc.getStateAsString()).append("\n"); |
| 1013 | // if (dc.isActive()) { |
| 1014 | // long timeElapsed = |
| 1015 | // (System.currentTimeMillis() - dc.getConnectionTime())/1000; |
| 1016 | // sb.append(" connected at ") |
| 1017 | // .append(DateUtils.timeString(dc.getConnectionTime())) |
| 1018 | // .append(" and elapsed ") |
| 1019 | // .append(DateUtils.formatElapsedTime(timeElapsed)); |
| 1020 | // |
| 1021 | // if (dc instanceof GsmDataConnection) { |
| 1022 | // GsmDataConnection pdp = (GsmDataConnection)dc; |
| 1023 | // sb.append("\n to ") |
| 1024 | // .append(pdp.getApn().toString()); |
| 1025 | // } |
| 1026 | // sb.append("\nLinkProperties: "); |
| 1027 | // sb.append(phone.getLinkProperties(phone.getActiveApnTypes()[0]).toString()); |
| 1028 | // } else if (dc.isInactive()) { |
| 1029 | // sb.append(" disconnected with last try at ") |
| 1030 | // .append(DateUtils.timeString(dc.getLastFailTime())) |
| 1031 | // .append("\n fail because ") |
| 1032 | // .append(dc.getLastFailCause().toString()); |
| 1033 | // } else { |
| 1034 | // if (dc instanceof GsmDataConnection) { |
| 1035 | // GsmDataConnection pdp = (GsmDataConnection)dc; |
| 1036 | // sb.append(" is connecting to ") |
| 1037 | // .append(pdp.getApn().toString()); |
| 1038 | // } else { |
| 1039 | // sb.append(" is connecting"); |
| 1040 | // } |
| 1041 | // } |
| 1042 | // sb.append("\n==================="); |
| 1043 | // } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1044 | |
| 1045 | disconnects.setText(sb.toString()); |
| 1046 | } |
| 1047 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1048 | private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() { |
| 1049 | public boolean onMenuItemClick(MenuItem item) { |
| 1050 | Intent intent = new Intent(Intent.ACTION_VIEW); |
| 1051 | // XXX We need to specify the component here because if we don't |
| 1052 | // the activity manager will try to resolve the type by calling |
| 1053 | // the content provider, which causes it to be loaded in a process |
| 1054 | // other than the Dialer process, which causes a lot of stuff to |
| 1055 | // break. |
| 1056 | intent.setClassName("com.android.phone", |
| 1057 | "com.android.phone.SimContacts"); |
| 1058 | startActivity(intent); |
| 1059 | return true; |
| 1060 | } |
| 1061 | }; |
| 1062 | |
| 1063 | private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() { |
| 1064 | public boolean onMenuItemClick(MenuItem item) { |
| 1065 | Intent intent = new Intent(Intent.ACTION_VIEW); |
| 1066 | // XXX We need to specify the component here because if we don't |
| 1067 | // the activity manager will try to resolve the type by calling |
| 1068 | // the content provider, which causes it to be loaded in a process |
| 1069 | // other than the Dialer process, which causes a lot of stuff to |
| 1070 | // break. |
| 1071 | intent.setClassName("com.android.phone", |
Andrew Lee | da90d68 | 2014-10-31 13:12:20 -0700 | [diff] [blame] | 1072 | "com.android.phone.settings.fdn.FdnList"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1073 | startActivity(intent); |
| 1074 | return true; |
| 1075 | } |
| 1076 | }; |
| 1077 | |
| 1078 | private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() { |
| 1079 | public boolean onMenuItemClick(MenuItem item) { |
| 1080 | Intent intent = new Intent( |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 1081 | Intent.ACTION_VIEW, Uri.parse("content://icc/sdn")); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1082 | // XXX We need to specify the component here because if we don't |
| 1083 | // the activity manager will try to resolve the type by calling |
| 1084 | // the content provider, which causes it to be loaded in a process |
| 1085 | // other than the Dialer process, which causes a lot of stuff to |
| 1086 | // break. |
| 1087 | intent.setClassName("com.android.phone", |
| 1088 | "com.android.phone.ADNList"); |
| 1089 | startActivity(intent); |
| 1090 | return true; |
| 1091 | } |
| 1092 | }; |
| 1093 | |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 1094 | private MenuItem.OnMenuItemClickListener mGetPdpList = new MenuItem.OnMenuItemClickListener() { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1095 | public boolean onMenuItemClick(MenuItem item) { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1096 | //FIXME: Replace with a TelephonyManager call |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 1097 | phone.getDataCallList(null); |
| 1098 | return true; |
| 1099 | } |
| 1100 | }; |
| 1101 | |
| 1102 | private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() { |
| 1103 | public boolean onMenuItemClick(MenuItem item) { |
| 1104 | Intent intent = new Intent(); |
| 1105 | intent.setClass(RadioInfo.this, BandMode.class); |
| 1106 | startActivity(intent); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1107 | return true; |
| 1108 | } |
| 1109 | }; |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 1110 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1111 | private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() { |
| 1112 | public boolean onMenuItemClick(MenuItem item) { |
| 1113 | int state = mTelephonyManager.getDataState(); |
| 1114 | switch (state) { |
| 1115 | case TelephonyManager.DATA_CONNECTED: |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1116 | //FIXME: Replace with a TelephonyManager call |
Robert Greenwalt | 0d4c500 | 2014-05-21 20:02:32 -0700 | [diff] [blame] | 1117 | phone.setDataEnabled(false); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1118 | break; |
| 1119 | case TelephonyManager.DATA_DISCONNECTED: |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1120 | //FIXME: Replace with a TelephonyManager call |
Robert Greenwalt | 0d4c500 | 2014-05-21 20:02:32 -0700 | [diff] [blame] | 1121 | phone.setDataEnabled(true); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1122 | break; |
| 1123 | default: |
| 1124 | // do nothing |
| 1125 | break; |
| 1126 | } |
| 1127 | return true; |
| 1128 | } |
| 1129 | }; |
| 1130 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1131 | OnClickListener mPowerButtonHandler = new OnClickListener() { |
| 1132 | public void onClick(View v) { |
| 1133 | //log("toggle radio power: currently " + (isRadioOn()?"on":"off")); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1134 | //FIXME: Replace with a TelephonyManager call |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1135 | phone.setRadioPower(!isRadioOn()); |
| 1136 | } |
| 1137 | }; |
| 1138 | |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1139 | class CellInfoListRateHandler implements OnClickListener { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1140 | int rates[] = {Integer.MAX_VALUE, 0, 5000}; |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1141 | int index = 0; |
| 1142 | |
| 1143 | public int getRate() { |
| 1144 | return rates[index]; |
| 1145 | } |
| 1146 | |
| 1147 | @Override |
| 1148 | public void onClick(View v) { |
| 1149 | index += 1; |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1150 | index %= rates.length; |
| 1151 | |
| 1152 | // FIXME: Replace with a TelephonyManager call |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1153 | phone.setCellInfoListRate(rates[index]); |
| 1154 | updateCellInfoListRate(); |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1155 | |
| 1156 | updateAllCellInfo(); |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1157 | } |
| 1158 | } |
| 1159 | CellInfoListRateHandler mCellInfoListRateHandler = new CellInfoListRateHandler(); |
| 1160 | |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1161 | private Button imsRegRequiredButton; |
| 1162 | static final String PROPERTY_IMS_REG_REQUIRED = "persist.radio.imsregrequired"; |
Wink Saville | 1e596f3 | 2011-09-19 14:24:39 -0700 | [diff] [blame] | 1163 | OnClickListener mImsRegRequiredHandler = new OnClickListener() { |
| 1164 | @Override |
| 1165 | public void onClick(View v) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1166 | log(String.format("toggle %s: currently %s", |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1167 | PROPERTY_IMS_REG_REQUIRED, (isImsRegRequired() ? "on":"off"))); |
Wink Saville | 1e596f3 | 2011-09-19 14:24:39 -0700 | [diff] [blame] | 1168 | boolean newValue = !isImsRegRequired(); |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1169 | SystemProperties.set(PROPERTY_IMS_REG_REQUIRED, |
Wink Saville | 1e596f3 | 2011-09-19 14:24:39 -0700 | [diff] [blame] | 1170 | newValue ? "1":"0"); |
| 1171 | updateImsRegRequiredState(); |
| 1172 | } |
| 1173 | }; |
| 1174 | |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1175 | private boolean isImsRegRequired() { |
| 1176 | return SystemProperties.getBoolean(PROPERTY_IMS_REG_REQUIRED, false); |
| 1177 | } |
| 1178 | |
| 1179 | private void updateImsRegRequiredState() { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1180 | log("updateImsRegRequiredState isImsRegRequired()=" + isImsRegRequired()); |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1181 | String buttonText = isImsRegRequired() ? |
| 1182 | getString(R.string.ims_reg_required_off) : |
| 1183 | getString(R.string.ims_reg_required_on); |
| 1184 | imsRegRequiredButton.setText(buttonText); |
| 1185 | } |
| 1186 | |
| 1187 | private Button smsOverImsButton; |
Wink Saville | 382a75b | 2011-09-22 15:17:00 -0700 | [diff] [blame] | 1188 | static final String PROPERTY_SMS_OVER_IMS = "persist.radio.imsallowmtsms"; |
| 1189 | OnClickListener mSmsOverImsHandler = new OnClickListener() { |
| 1190 | @Override |
| 1191 | public void onClick(View v) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1192 | log(String.format("toggle %s: currently %s", |
Wink Saville | 382a75b | 2011-09-22 15:17:00 -0700 | [diff] [blame] | 1193 | PROPERTY_SMS_OVER_IMS, (isSmsOverImsEnabled() ? "on":"off"))); |
| 1194 | boolean newValue = !isSmsOverImsEnabled(); |
| 1195 | SystemProperties.set(PROPERTY_SMS_OVER_IMS, newValue ? "1":"0"); |
| 1196 | updateSmsOverImsState(); |
| 1197 | } |
| 1198 | }; |
| 1199 | |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1200 | private boolean isSmsOverImsEnabled() { |
| 1201 | return SystemProperties.getBoolean(PROPERTY_SMS_OVER_IMS, false); |
| 1202 | } |
| 1203 | |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 1204 | private Button imsVoLteProvisionedButton; |
| 1205 | OnClickListener mImsVoLteProvisionedHandler = new OnClickListener() { |
| 1206 | @Override |
| 1207 | public void onClick(View v) { |
| 1208 | log(String.format("toggle VoLTE provisioned: currently %s", |
| 1209 | (isImsVoLteProvisioned() ? "on":"off"))); |
| 1210 | final boolean newValue = !isImsVoLteProvisioned(); |
| 1211 | if (phone != null) { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1212 | //TODO: Why does this have to be called within the phone's context? |
| 1213 | if (mImsManager != null) { |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 1214 | QueuedWork.singleThreadExecutor().submit(new Runnable() { |
| 1215 | public void run() { |
| 1216 | try { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1217 | mImsManager.getConfigInterface().setProvisionedValue( |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 1218 | ImsConfig.ConfigConstants.VLT_SETTING_ENABLED, |
| 1219 | newValue? 1 : 0); |
| 1220 | } catch (ImsException e) { |
| 1221 | Log.e(TAG, "setImsVoLteProvisioned() exception:", e); |
| 1222 | } |
| 1223 | } |
| 1224 | }); |
| 1225 | } |
| 1226 | } |
| 1227 | updateImsVoLteProvisionedState(); |
| 1228 | } |
| 1229 | }; |
| 1230 | |
| 1231 | private boolean isImsVoLteProvisioned() { |
| 1232 | if (phone != null) { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1233 | //TODO: Why does this have to be called within the phone's context? |
| 1234 | if(mImsManager != null ) { |
| 1235 | return mImsManager.isVolteProvisionedOnDevice(phone.getContext()); |
| 1236 | } |
Pavel Zhamaitsiak | cb267a6 | 2015-01-21 18:25:14 -0800 | [diff] [blame] | 1237 | } |
| 1238 | return false; |
| 1239 | } |
| 1240 | |
| 1241 | private void updateImsVoLteProvisionedState() { |
| 1242 | log("updateImsVoLteProvisionedState isImsVoLteProvisioned()=" + isImsVoLteProvisioned()); |
| 1243 | String buttonText = isImsVoLteProvisioned() ? |
| 1244 | getString(R.string.volte_provisioned_flag_off) : |
| 1245 | getString(R.string.volte_provisioned_flag_on); |
| 1246 | imsVoLteProvisionedButton.setText(buttonText); |
| 1247 | } |
| 1248 | |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1249 | private void updateSmsOverImsState() { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1250 | log("updateSmsOverImsState isSmsOverImsEnabled()=" + isSmsOverImsEnabled()); |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1251 | String buttonText = isSmsOverImsEnabled() ? |
| 1252 | getString(R.string.sms_over_ims_off) : |
| 1253 | getString(R.string.sms_over_ims_on); |
| 1254 | smsOverImsButton.setText(buttonText); |
| 1255 | } |
| 1256 | |
| 1257 | private Button lteRamDumpButton; |
| 1258 | static final String PROPERTY_LTE_RAM_DUMP = "persist.radio.ramdump"; |
| 1259 | OnClickListener mLteRamDumpHandler = new OnClickListener() { |
| 1260 | @Override |
| 1261 | public void onClick(View v) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1262 | log(String.format("toggle %s: currently %s", |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1263 | PROPERTY_LTE_RAM_DUMP, (isSmsOverImsEnabled() ? "on":"off"))); |
| 1264 | boolean newValue = !isLteRamDumpEnabled(); |
| 1265 | SystemProperties.set(PROPERTY_LTE_RAM_DUMP, newValue ? "1":"0"); |
| 1266 | updateLteRamDumpState(); |
| 1267 | } |
| 1268 | }; |
| 1269 | |
| 1270 | private boolean isLteRamDumpEnabled() { |
| 1271 | return SystemProperties.getBoolean(PROPERTY_LTE_RAM_DUMP, false); |
| 1272 | } |
| 1273 | |
| 1274 | private void updateLteRamDumpState() { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1275 | log("updateLteRamDumpState isLteRamDumpEnabled()=" + isLteRamDumpEnabled()); |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1276 | String buttonText = isLteRamDumpEnabled() ? |
| 1277 | getString(R.string.lte_ram_dump_off) : |
| 1278 | getString(R.string.lte_ram_dump_on); |
| 1279 | lteRamDumpButton.setText(buttonText); |
| 1280 | } |
| 1281 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1282 | OnClickListener mDnsCheckButtonHandler = new OnClickListener() { |
| 1283 | public void onClick(View v) { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1284 | //FIXME: Replace with a TelephonyManager call |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 1285 | phone.disableDnsCheck(!phone.isDnsCheckDisabled()); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1286 | updateDnsCheckState(); |
| 1287 | } |
| 1288 | }; |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 1289 | |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 1290 | OnClickListener mOemInfoButtonHandler = new OnClickListener() { |
| 1291 | public void onClick(View v) { |
| 1292 | Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO"); |
| 1293 | try { |
| 1294 | startActivity(intent); |
| 1295 | } catch (android.content.ActivityNotFoundException ex) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1296 | log("OEM-specific Info/Settings Activity Not Found : " + ex); |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 1297 | // If the activity does not exist, there are no OEM |
| 1298 | // settings, and so we can just do nothing... |
| 1299 | } |
| 1300 | } |
| 1301 | }; |
| 1302 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1303 | OnClickListener mPingButtonHandler = new OnClickListener() { |
| 1304 | public void onClick(View v) { |
| 1305 | updatePingState(); |
| 1306 | } |
| 1307 | }; |
| 1308 | |
| 1309 | OnClickListener mUpdateSmscButtonHandler = new OnClickListener() { |
| 1310 | public void onClick(View v) { |
| 1311 | updateSmscButton.setEnabled(false); |
jsh | 21dd407 | 2009-05-12 11:26:55 -0700 | [diff] [blame] | 1312 | phone.setSmscAddress(smsc.getText().toString(), |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1313 | mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE)); |
| 1314 | } |
| 1315 | }; |
| 1316 | |
| 1317 | OnClickListener mRefreshSmscButtonHandler = new OnClickListener() { |
| 1318 | public void onClick(View v) { |
| 1319 | refreshSmsc(); |
| 1320 | } |
| 1321 | }; |
| 1322 | |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1323 | AdapterView.OnItemSelectedListener mPreferredNetworkHandler = |
| 1324 | new AdapterView.OnItemSelectedListener() { |
| 1325 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1326 | public void onItemSelected(AdapterView parent, View v, int pos, long id) { |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1327 | if (mPreferredNetworkTypeResult != pos && pos >= 0 |
| 1328 | && pos <= mPreferredNetworkLabels.length - 2) { |
| 1329 | mPreferredNetworkTypeResult = pos; |
| 1330 | Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE); |
| 1331 | phone.setPreferredNetworkType(mPreferredNetworkTypeResult, msg); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1332 | } |
| 1333 | } |
| 1334 | |
| 1335 | public void onNothingSelected(AdapterView parent) { |
| 1336 | } |
| 1337 | }; |
| 1338 | |
| 1339 | private String[] mPreferredNetworkLabels = { |
jsh | 87fa11b | 2009-08-18 18:00:15 -0700 | [diff] [blame] | 1340 | "WCDMA preferred", |
| 1341 | "GSM only", |
| 1342 | "WCDMA only", |
| 1343 | "GSM auto (PRL)", |
| 1344 | "CDMA auto (PRL)", |
| 1345 | "CDMA only", |
| 1346 | "EvDo only", |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1347 | "Global auto (PRL)", |
Ricardo Cerqueira | 32310ee | 2012-04-12 23:34:38 +0100 | [diff] [blame] | 1348 | "LTE/CDMA auto (PRL)", |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1349 | "LTE/UMTS auto (PRL)", |
| 1350 | "LTE/CDMA/UMTS auto (PRL)", |
Ricardo Cerqueira | 32310ee | 2012-04-12 23:34:38 +0100 | [diff] [blame] | 1351 | "LTE only", |
Nathan Harold | cea413a | 2015-11-23 15:48:10 -0800 | [diff] [blame^] | 1352 | "LTE/WCDMA", |
| 1353 | "TD-SCDMA only", |
| 1354 | "TD-SCDMA/WCDMA", |
| 1355 | "LTE/TD-SCDMA", |
| 1356 | "TD-SCDMA/GSM", |
| 1357 | "TD-SCDMA/UMTS", |
| 1358 | "LTE/TD-SCDMA/WCDMA", |
| 1359 | "LTE/TD-SCDMA/UMTS", |
| 1360 | "TD-SCDMA/CDMA/UMTS", |
| 1361 | "Global/TD-SCDMA", |
jsh | 87fa11b | 2009-08-18 18:00:15 -0700 | [diff] [blame] | 1362 | "Unknown"}; |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1363 | |
| 1364 | private void log(String s) { |
| 1365 | Log.d(TAG, "[RadioInfo] " + s); |
| 1366 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1367 | } |