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; |
Robert Greenwalt | 99be500 | 2010-11-24 17:20:59 -0800 | [diff] [blame] | 20 | import android.content.Context; |
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; |
Robert Greenwalt | 99be500 | 2010-11-24 17:20:59 -0800 | [diff] [blame] | 25 | import android.net.ConnectivityManager; |
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; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 34 | import android.telephony.CellLocation; |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame^] | 35 | import android.telephony.DataConnectionRealTimeInfo; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 36 | import android.telephony.PhoneStateListener; |
| 37 | import android.telephony.ServiceState; |
| 38 | import android.telephony.TelephonyManager; |
| 39 | import android.telephony.NeighboringCellInfo; |
jsh | 534f5ae | 2009-09-24 09:19:22 -0700 | [diff] [blame] | 40 | import android.telephony.cdma.CdmaCellLocation; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 41 | import android.telephony.gsm.GsmCellLocation; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 42 | import android.util.Log; |
| 43 | import android.view.Menu; |
| 44 | import android.view.MenuItem; |
| 45 | import android.view.View; |
| 46 | import android.view.View.OnClickListener; |
| 47 | import android.widget.AdapterView; |
| 48 | import android.widget.ArrayAdapter; |
| 49 | import android.widget.Button; |
| 50 | import android.widget.Spinner; |
| 51 | import android.widget.TextView; |
| 52 | import android.widget.EditText; |
| 53 | |
| 54 | import com.android.internal.telephony.Phone; |
Wink Saville | 5543404 | 2012-06-14 12:33:43 -0700 | [diff] [blame] | 55 | import com.android.internal.telephony.PhoneConstants; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 56 | import com.android.internal.telephony.PhoneFactory; |
| 57 | import com.android.internal.telephony.PhoneStateIntentReceiver; |
| 58 | import com.android.internal.telephony.TelephonyProperties; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 59 | import org.apache.http.HttpResponse; |
| 60 | import org.apache.http.client.HttpClient; |
| 61 | import org.apache.http.client.methods.HttpGet; |
| 62 | import org.apache.http.impl.client.DefaultHttpClient; |
| 63 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 64 | import java.io.IOException; |
| 65 | import java.net.UnknownHostException; |
| 66 | import java.util.ArrayList; |
| 67 | import java.util.List; |
| 68 | |
| 69 | public class RadioInfo extends Activity { |
| 70 | private final String TAG = "phone"; |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 71 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 72 | private static final int EVENT_PHONE_STATE_CHANGED = 100; |
| 73 | private static final int EVENT_SIGNAL_STRENGTH_CHANGED = 200; |
| 74 | private static final int EVENT_SERVICE_STATE_CHANGED = 300; |
| 75 | private static final int EVENT_CFI_CHANGED = 302; |
| 76 | |
| 77 | private static final int EVENT_QUERY_PREFERRED_TYPE_DONE = 1000; |
| 78 | private static final int EVENT_SET_PREFERRED_TYPE_DONE = 1001; |
| 79 | private static final int EVENT_QUERY_NEIGHBORING_CIDS_DONE = 1002; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 80 | private static final int EVENT_QUERY_SMSC_DONE = 1005; |
| 81 | private static final int EVENT_UPDATE_SMSC_DONE = 1006; |
| 82 | |
| 83 | private static final int MENU_ITEM_SELECT_BAND = 0; |
| 84 | private static final int MENU_ITEM_VIEW_ADN = 1; |
| 85 | private static final int MENU_ITEM_VIEW_FDN = 2; |
| 86 | private static final int MENU_ITEM_VIEW_SDN = 3; |
| 87 | private static final int MENU_ITEM_GET_PDP_LIST = 4; |
| 88 | private static final int MENU_ITEM_TOGGLE_DATA = 5; |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 89 | |
| 90 | static final String ENABLE_DATA_STR = "Enable data connection"; |
| 91 | static final String DISABLE_DATA_STR = "Disable data connection"; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 92 | |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 93 | 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] | 94 | private TextView number; |
| 95 | private TextView callState; |
| 96 | private TextView operatorName; |
| 97 | private TextView roamingState; |
| 98 | private TextView gsmState; |
| 99 | private TextView gprsState; |
| 100 | private TextView network; |
| 101 | private TextView dBm; |
| 102 | private TextView mMwi; |
| 103 | private TextView mCfi; |
| 104 | private TextView mLocation; |
| 105 | private TextView mNeighboringCids; |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 106 | private TextView mCellInfo; |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame^] | 107 | private TextView mDcRtInfoTv; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 108 | private TextView resets; |
| 109 | private TextView attempts; |
| 110 | private TextView successes; |
| 111 | private TextView disconnects; |
| 112 | private TextView sentSinceReceived; |
| 113 | private TextView sent; |
| 114 | private TextView received; |
| 115 | private TextView mPingIpAddr; |
| 116 | private TextView mPingHostname; |
| 117 | private TextView mHttpClientTest; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 118 | private TextView dnsCheckState; |
| 119 | private EditText smsc; |
| 120 | private Button radioPowerButton; |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 121 | private Button cellInfoListRateButton; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 122 | private Button dnsCheckToggleButton; |
| 123 | private Button pingTestButton; |
| 124 | private Button updateSmscButton; |
| 125 | private Button refreshSmscButton; |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 126 | private Button oemInfoButton; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 127 | private Spinner preferredNetworkType; |
| 128 | |
| 129 | private TelephonyManager mTelephonyManager; |
| 130 | private Phone phone = null; |
| 131 | private PhoneStateIntentReceiver mPhoneStateReceiver; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 132 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 133 | private String mPingIpAddrResult; |
| 134 | private String mPingHostnameResult; |
| 135 | private String mHttpClientTestResult; |
| 136 | private boolean mMwiValue = false; |
| 137 | private boolean mCfiValue = false; |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 138 | private List<CellInfo> mCellInfoValue; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 139 | |
| 140 | private PhoneStateListener mPhoneStateListener = new PhoneStateListener() { |
| 141 | @Override |
| 142 | public void onDataConnectionStateChanged(int state) { |
| 143 | updateDataState(); |
| 144 | updateDataStats(); |
| 145 | updatePdpList(); |
| 146 | updateNetworkType(); |
| 147 | } |
| 148 | |
| 149 | @Override |
| 150 | public void onDataActivity(int direction) { |
| 151 | updateDataStats2(); |
| 152 | } |
| 153 | |
| 154 | @Override |
| 155 | public void onCellLocationChanged(CellLocation location) { |
| 156 | updateLocation(location); |
| 157 | } |
| 158 | |
| 159 | @Override |
| 160 | public void onMessageWaitingIndicatorChanged(boolean mwi) { |
| 161 | mMwiValue = mwi; |
| 162 | updateMessageWaiting(); |
| 163 | } |
| 164 | |
| 165 | @Override |
| 166 | public void onCallForwardingIndicatorChanged(boolean cfi) { |
| 167 | mCfiValue = cfi; |
| 168 | updateCallRedirect(); |
| 169 | } |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 170 | |
| 171 | @Override |
| 172 | public void onCellInfoChanged(List<CellInfo> arrayCi) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 173 | log("onCellInfoChanged: arrayCi=" + arrayCi); |
| 174 | updateCellInfoTv(arrayCi); |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 175 | } |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame^] | 176 | |
| 177 | @Override |
| 178 | public void onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo) { |
| 179 | log("onDataConnectionRealTimeInfoChanged: dcRtInfo=" + dcRtInfo); |
| 180 | updateDcRtInfoTv(dcRtInfo); |
| 181 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 182 | }; |
| 183 | |
| 184 | private Handler mHandler = new Handler() { |
| 185 | public void handleMessage(Message msg) { |
| 186 | AsyncResult ar; |
| 187 | switch (msg.what) { |
| 188 | case EVENT_PHONE_STATE_CHANGED: |
| 189 | updatePhoneState(); |
| 190 | break; |
| 191 | |
| 192 | case EVENT_SIGNAL_STRENGTH_CHANGED: |
| 193 | updateSignalStrength(); |
| 194 | break; |
| 195 | |
| 196 | case EVENT_SERVICE_STATE_CHANGED: |
| 197 | updateServiceState(); |
| 198 | updatePowerState(); |
| 199 | break; |
| 200 | |
| 201 | case EVENT_QUERY_PREFERRED_TYPE_DONE: |
| 202 | ar= (AsyncResult) msg.obj; |
| 203 | if (ar.exception == null) { |
| 204 | int type = ((int[])ar.result)[0]; |
Ricardo Cerqueira | 32310ee | 2012-04-12 23:34:38 +0100 | [diff] [blame] | 205 | if (type >= mPreferredNetworkLabels.length) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 206 | log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " + |
Ricardo Cerqueira | 32310ee | 2012-04-12 23:34:38 +0100 | [diff] [blame] | 207 | "type=" + type); |
| 208 | type = mPreferredNetworkLabels.length - 1; |
| 209 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 210 | preferredNetworkType.setSelection(type, true); |
| 211 | } else { |
Ricardo Cerqueira | 32310ee | 2012-04-12 23:34:38 +0100 | [diff] [blame] | 212 | preferredNetworkType.setSelection(mPreferredNetworkLabels.length - 1, true); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 213 | } |
| 214 | break; |
| 215 | case EVENT_SET_PREFERRED_TYPE_DONE: |
| 216 | ar= (AsyncResult) msg.obj; |
| 217 | if (ar.exception != null) { |
| 218 | phone.getPreferredNetworkType( |
| 219 | obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE)); |
| 220 | } |
| 221 | break; |
| 222 | case EVENT_QUERY_NEIGHBORING_CIDS_DONE: |
| 223 | ar= (AsyncResult) msg.obj; |
| 224 | if (ar.exception == null) { |
| 225 | updateNeighboringCids((ArrayList<NeighboringCellInfo>)ar.result); |
| 226 | } else { |
| 227 | mNeighboringCids.setText("unknown"); |
| 228 | } |
| 229 | break; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 230 | case EVENT_QUERY_SMSC_DONE: |
| 231 | ar= (AsyncResult) msg.obj; |
| 232 | if (ar.exception != null) { |
| 233 | smsc.setText("refresh error"); |
| 234 | } else { |
jsh | 21dd407 | 2009-05-12 11:26:55 -0700 | [diff] [blame] | 235 | smsc.setText((String)ar.result); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 236 | } |
| 237 | break; |
| 238 | case EVENT_UPDATE_SMSC_DONE: |
| 239 | updateSmscButton.setEnabled(true); |
| 240 | ar= (AsyncResult) msg.obj; |
| 241 | if (ar.exception != null) { |
| 242 | smsc.setText("update error"); |
| 243 | } |
| 244 | break; |
| 245 | default: |
| 246 | break; |
| 247 | |
| 248 | } |
| 249 | } |
| 250 | }; |
| 251 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 252 | @Override |
| 253 | public void onCreate(Bundle icicle) { |
| 254 | super.onCreate(icicle); |
| 255 | |
| 256 | setContentView(R.layout.radio_info); |
| 257 | |
| 258 | mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); |
| 259 | phone = PhoneFactory.getDefaultPhone(); |
| 260 | |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 261 | mDeviceId= (TextView) findViewById(R.id.imei); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 262 | number = (TextView) findViewById(R.id.number); |
| 263 | callState = (TextView) findViewById(R.id.call); |
| 264 | operatorName = (TextView) findViewById(R.id.operator); |
| 265 | roamingState = (TextView) findViewById(R.id.roaming); |
| 266 | gsmState = (TextView) findViewById(R.id.gsm); |
| 267 | gprsState = (TextView) findViewById(R.id.gprs); |
| 268 | network = (TextView) findViewById(R.id.network); |
| 269 | dBm = (TextView) findViewById(R.id.dbm); |
| 270 | mMwi = (TextView) findViewById(R.id.mwi); |
| 271 | mCfi = (TextView) findViewById(R.id.cfi); |
| 272 | mLocation = (TextView) findViewById(R.id.location); |
| 273 | mNeighboringCids = (TextView) findViewById(R.id.neighboring); |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 274 | mCellInfo = (TextView) findViewById(R.id.cellinfo); |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame^] | 275 | mDcRtInfoTv = (TextView) findViewById(R.id.dcrtinfo); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 276 | |
| 277 | resets = (TextView) findViewById(R.id.resets); |
| 278 | attempts = (TextView) findViewById(R.id.attempts); |
| 279 | successes = (TextView) findViewById(R.id.successes); |
| 280 | disconnects = (TextView) findViewById(R.id.disconnects); |
| 281 | sentSinceReceived = (TextView) findViewById(R.id.sentSinceReceived); |
| 282 | sent = (TextView) findViewById(R.id.sent); |
| 283 | received = (TextView) findViewById(R.id.received); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 284 | smsc = (EditText) findViewById(R.id.smsc); |
| 285 | dnsCheckState = (TextView) findViewById(R.id.dnsCheckState); |
| 286 | |
| 287 | mPingIpAddr = (TextView) findViewById(R.id.pingIpAddr); |
| 288 | mPingHostname = (TextView) findViewById(R.id.pingHostname); |
| 289 | mHttpClientTest = (TextView) findViewById(R.id.httpClientTest); |
| 290 | |
| 291 | preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType); |
| 292 | ArrayAdapter<String> adapter = new ArrayAdapter<String> (this, |
| 293 | android.R.layout.simple_spinner_item, mPreferredNetworkLabels); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 294 | adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 295 | preferredNetworkType.setAdapter(adapter); |
| 296 | preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler); |
| 297 | |
| 298 | radioPowerButton = (Button) findViewById(R.id.radio_power); |
| 299 | radioPowerButton.setOnClickListener(mPowerButtonHandler); |
| 300 | |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 301 | cellInfoListRateButton = (Button) findViewById(R.id.cell_info_list_rate); |
| 302 | cellInfoListRateButton.setOnClickListener(mCellInfoListRateHandler); |
| 303 | |
Wink Saville | 1e596f3 | 2011-09-19 14:24:39 -0700 | [diff] [blame] | 304 | imsRegRequiredButton = (Button) findViewById(R.id.ims_reg_required); |
| 305 | imsRegRequiredButton.setOnClickListener(mImsRegRequiredHandler); |
| 306 | |
Wink Saville | 382a75b | 2011-09-22 15:17:00 -0700 | [diff] [blame] | 307 | smsOverImsButton = (Button) findViewById(R.id.sms_over_ims); |
| 308 | smsOverImsButton.setOnClickListener(mSmsOverImsHandler); |
| 309 | |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 310 | lteRamDumpButton = (Button) findViewById(R.id.lte_ram_dump); |
| 311 | lteRamDumpButton.setOnClickListener(mLteRamDumpHandler); |
| 312 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 313 | pingTestButton = (Button) findViewById(R.id.ping_test); |
| 314 | pingTestButton.setOnClickListener(mPingButtonHandler); |
| 315 | updateSmscButton = (Button) findViewById(R.id.update_smsc); |
| 316 | updateSmscButton.setOnClickListener(mUpdateSmscButtonHandler); |
| 317 | refreshSmscButton = (Button) findViewById(R.id.refresh_smsc); |
| 318 | refreshSmscButton.setOnClickListener(mRefreshSmscButtonHandler); |
| 319 | dnsCheckToggleButton = (Button) findViewById(R.id.dns_check_toggle); |
| 320 | dnsCheckToggleButton.setOnClickListener(mDnsCheckButtonHandler); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 321 | |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 322 | oemInfoButton = (Button) findViewById(R.id.oem_info); |
| 323 | oemInfoButton.setOnClickListener(mOemInfoButtonHandler); |
| 324 | PackageManager pm = getPackageManager(); |
| 325 | Intent oemInfoIntent = new Intent("com.android.settings.OEM_RADIO_INFO"); |
| 326 | List<ResolveInfo> oemInfoIntentList = pm.queryIntentActivities(oemInfoIntent, 0); |
| 327 | if (oemInfoIntentList.size() == 0) { |
| 328 | oemInfoButton.setEnabled(false); |
| 329 | } |
| 330 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 331 | mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler); |
| 332 | mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED); |
| 333 | mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED); |
| 334 | mPhoneStateReceiver.notifyPhoneCallState(EVENT_PHONE_STATE_CHANGED); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 335 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 336 | phone.getPreferredNetworkType( |
| 337 | mHandler.obtainMessage(EVENT_QUERY_PREFERRED_TYPE_DONE)); |
| 338 | phone.getNeighboringCids( |
| 339 | mHandler.obtainMessage(EVENT_QUERY_NEIGHBORING_CIDS_DONE)); |
| 340 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 341 | CellLocation.requestLocationUpdate(); |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 342 | |
| 343 | // Get current cell info |
| 344 | mCellInfoValue = mTelephonyManager.getAllCellInfo(); |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 345 | log("onCreate: mCellInfoValue=" + mCellInfoValue); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | @Override |
| 349 | protected void onResume() { |
| 350 | super.onResume(); |
| 351 | |
| 352 | updatePhoneState(); |
| 353 | updateSignalStrength(); |
| 354 | updateMessageWaiting(); |
| 355 | updateCallRedirect(); |
| 356 | updateServiceState(); |
| 357 | updateLocation(mTelephonyManager.getCellLocation()); |
| 358 | updateDataState(); |
| 359 | updateDataStats(); |
| 360 | updateDataStats2(); |
| 361 | updatePowerState(); |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 362 | updateCellInfoListRate(); |
Wink Saville | 1e596f3 | 2011-09-19 14:24:39 -0700 | [diff] [blame] | 363 | updateImsRegRequiredState(); |
Wink Saville | 382a75b | 2011-09-22 15:17:00 -0700 | [diff] [blame] | 364 | updateSmsOverImsState(); |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 365 | updateLteRamDumpState(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 366 | updateProperties(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 367 | updateDnsCheckState(); |
| 368 | |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 369 | log("onResume: register phone & data intents"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 370 | |
| 371 | mPhoneStateReceiver.registerIntent(); |
| 372 | mTelephonyManager.listen(mPhoneStateListener, |
| 373 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE |
| 374 | | PhoneStateListener.LISTEN_DATA_ACTIVITY |
| 375 | | PhoneStateListener.LISTEN_CELL_LOCATION |
| 376 | | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 377 | | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame^] | 378 | | PhoneStateListener.LISTEN_CELL_INFO |
| 379 | | PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | @Override |
| 383 | public void onPause() { |
| 384 | super.onPause(); |
| 385 | |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 386 | log("onPause: unregister phone & data intents"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 387 | |
| 388 | mPhoneStateReceiver.unregisterIntent(); |
| 389 | mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); |
| 390 | } |
| 391 | |
| 392 | @Override |
| 393 | public boolean onCreateOptionsMenu(Menu menu) { |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 394 | menu.add(0, MENU_ITEM_SELECT_BAND, 0, R.string.radio_info_band_mode_label) |
| 395 | .setOnMenuItemClickListener(mSelectBandCallback) |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 396 | .setAlphabeticShortcut('b'); |
| 397 | menu.add(1, MENU_ITEM_VIEW_ADN, 0, |
| 398 | R.string.radioInfo_menu_viewADN).setOnMenuItemClickListener(mViewADNCallback); |
| 399 | menu.add(1, MENU_ITEM_VIEW_FDN, 0, |
| 400 | R.string.radioInfo_menu_viewFDN).setOnMenuItemClickListener(mViewFDNCallback); |
| 401 | menu.add(1, MENU_ITEM_VIEW_SDN, 0, |
| 402 | R.string.radioInfo_menu_viewSDN).setOnMenuItemClickListener(mViewSDNCallback); |
| 403 | menu.add(1, MENU_ITEM_GET_PDP_LIST, |
| 404 | 0, R.string.radioInfo_menu_getPDP).setOnMenuItemClickListener(mGetPdpList); |
| 405 | menu.add(1, MENU_ITEM_TOGGLE_DATA, |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 406 | 0, DISABLE_DATA_STR).setOnMenuItemClickListener(mToggleData); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 407 | return true; |
| 408 | } |
| 409 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 410 | @Override |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 411 | public boolean onPrepareOptionsMenu(Menu menu) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 412 | // Get the TOGGLE DATA menu item in the right state. |
| 413 | MenuItem item = menu.findItem(MENU_ITEM_TOGGLE_DATA); |
| 414 | int state = mTelephonyManager.getDataState(); |
| 415 | boolean visible = true; |
| 416 | |
| 417 | switch (state) { |
| 418 | case TelephonyManager.DATA_CONNECTED: |
| 419 | case TelephonyManager.DATA_SUSPENDED: |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 420 | item.setTitle(DISABLE_DATA_STR); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 421 | break; |
| 422 | case TelephonyManager.DATA_DISCONNECTED: |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 423 | item.setTitle(ENABLE_DATA_STR); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 424 | break; |
| 425 | default: |
| 426 | visible = false; |
| 427 | break; |
| 428 | } |
| 429 | item.setVisible(visible); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 430 | return true; |
| 431 | } |
| 432 | |
| 433 | private boolean isRadioOn() { |
| 434 | return phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF; |
| 435 | } |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 436 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 437 | private void updatePowerState() { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 438 | String buttonText = isRadioOn() ? |
| 439 | getString(R.string.turn_off_radio) : |
| 440 | getString(R.string.turn_on_radio); |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 441 | radioPowerButton.setText(buttonText); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 442 | } |
| 443 | |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 444 | private void updateCellInfoListRate() { |
| 445 | cellInfoListRateButton.setText("CellInfoListRate " + mCellInfoListRateHandler.getRate()); |
| 446 | updateCellInfoTv(mTelephonyManager.getAllCellInfo()); |
| 447 | } |
| 448 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 449 | private void updateDnsCheckState() { |
Mike Lockwood | 5304c7e | 2009-04-05 11:37:45 -0700 | [diff] [blame] | 450 | dnsCheckState.setText(phone.isDnsCheckDisabled() ? |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 451 | "0.0.0.0 allowed" :"0.0.0.0 not allowed"); |
| 452 | } |
Wink Saville | e2a14e3 | 2009-05-29 14:06:30 -0700 | [diff] [blame] | 453 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 454 | private final void |
| 455 | updateSignalStrength() { |
Wink Saville | e2a14e3 | 2009-05-29 14:06:30 -0700 | [diff] [blame] | 456 | // TODO PhoneStateIntentReceiver is deprecated and PhoneStateListener |
| 457 | // should probably used instead. |
| 458 | int state = mPhoneStateReceiver.getServiceState().getState(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 459 | Resources r = getResources(); |
| 460 | |
| 461 | if ((ServiceState.STATE_OUT_OF_SERVICE == state) || |
| 462 | (ServiceState.STATE_POWER_OFF == state)) { |
| 463 | dBm.setText("0"); |
| 464 | } |
Wink Saville | e2a14e3 | 2009-05-29 14:06:30 -0700 | [diff] [blame] | 465 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 466 | int signalDbm = mPhoneStateReceiver.getSignalStrengthDbm(); |
Wink Saville | e2a14e3 | 2009-05-29 14:06:30 -0700 | [diff] [blame] | 467 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 468 | if (-1 == signalDbm) signalDbm = 0; |
| 469 | |
Wink Saville | 882c74a | 2011-02-17 12:00:03 -0800 | [diff] [blame] | 470 | int signalAsu = mPhoneStateReceiver.getSignalStrengthLevelAsu(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 471 | |
| 472 | if (-1 == signalAsu) signalAsu = 0; |
| 473 | |
| 474 | dBm.setText(String.valueOf(signalDbm) + " " |
| 475 | + r.getString(R.string.radioInfo_display_dbm) + " " |
| 476 | + String.valueOf(signalAsu) + " " |
| 477 | + r.getString(R.string.radioInfo_display_asu)); |
| 478 | } |
| 479 | |
| 480 | private final void updateLocation(CellLocation location) { |
jsh | 534f5ae | 2009-09-24 09:19:22 -0700 | [diff] [blame] | 481 | Resources r = getResources(); |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 482 | if (location instanceof GsmCellLocation) { |
| 483 | GsmCellLocation loc = (GsmCellLocation)location; |
jsh | 534f5ae | 2009-09-24 09:19:22 -0700 | [diff] [blame] | 484 | int lac = loc.getLac(); |
| 485 | int cid = loc.getCid(); |
| 486 | mLocation.setText(r.getString(R.string.radioInfo_lac) + " = " |
| 487 | + ((lac == -1) ? "unknown" : Integer.toHexString(lac)) |
| 488 | + " " |
| 489 | + r.getString(R.string.radioInfo_cid) + " = " |
| 490 | + ((cid == -1) ? "unknown" : Integer.toHexString(cid))); |
| 491 | } else if (location instanceof CdmaCellLocation) { |
| 492 | CdmaCellLocation loc = (CdmaCellLocation)location; |
| 493 | int bid = loc.getBaseStationId(); |
| 494 | int sid = loc.getSystemId(); |
| 495 | int nid = loc.getNetworkId(); |
| 496 | int lat = loc.getBaseStationLatitude(); |
| 497 | int lon = loc.getBaseStationLongitude(); |
| 498 | mLocation.setText("BID = " |
| 499 | + ((bid == -1) ? "unknown" : Integer.toHexString(bid)) |
| 500 | + " " |
| 501 | + "SID = " |
| 502 | + ((sid == -1) ? "unknown" : Integer.toHexString(sid)) |
| 503 | + " " |
| 504 | + "NID = " |
| 505 | + ((nid == -1) ? "unknown" : Integer.toHexString(nid)) |
| 506 | + "\n" |
| 507 | + "LAT = " |
| 508 | + ((lat == -1) ? "unknown" : Integer.toHexString(lat)) |
| 509 | + " " |
| 510 | + "LONG = " |
| 511 | + ((lon == -1) ? "unknown" : Integer.toHexString(lon))); |
| 512 | } else { |
| 513 | mLocation.setText("unknown"); |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 514 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 515 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 516 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | private final void updateNeighboringCids(ArrayList<NeighboringCellInfo> cids) { |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 520 | StringBuilder sb = new StringBuilder(); |
| 521 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 522 | if (cids != null) { |
| 523 | if ( cids.isEmpty() ) { |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 524 | sb.append("no neighboring cells"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 525 | } else { |
| 526 | for (NeighboringCellInfo cell : cids) { |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 527 | sb.append(cell.toString()).append(" "); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 528 | } |
| 529 | } |
| 530 | } else { |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 531 | sb.append("unknown"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 532 | } |
johnwang | f02c65f | 2009-09-25 17:26:54 -0700 | [diff] [blame] | 533 | mNeighboringCids.setText(sb.toString()); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 534 | } |
| 535 | |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 536 | private final void updateCellInfoTv(List<CellInfo> arrayCi) { |
| 537 | mCellInfoValue = arrayCi; |
Wink Saville | 79bff2a | 2012-06-01 14:37:21 -0700 | [diff] [blame] | 538 | StringBuilder value = new StringBuilder(); |
| 539 | if (mCellInfoValue != null) { |
| 540 | int index = 0; |
| 541 | for (CellInfo ci : mCellInfoValue) { |
| 542 | value.append('['); |
| 543 | value.append(index); |
| 544 | value.append("]="); |
| 545 | value.append(ci.toString()); |
| 546 | if (++index < mCellInfoValue.size()) { |
| 547 | value.append("\n"); |
| 548 | } |
| 549 | } |
| 550 | } |
| 551 | mCellInfo.setText(value.toString()); |
| 552 | } |
| 553 | |
Wink Saville | 4f0d881 | 2014-04-15 22:05:24 -0700 | [diff] [blame^] | 554 | private final void updateDcRtInfoTv(DataConnectionRealTimeInfo dcRtInfo) { |
| 555 | mDcRtInfoTv.setText(dcRtInfo.toString()); |
| 556 | } |
| 557 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 558 | private final void |
| 559 | updateMessageWaiting() { |
| 560 | mMwi.setText(String.valueOf(mMwiValue)); |
| 561 | } |
| 562 | |
| 563 | private final void |
| 564 | updateCallRedirect() { |
| 565 | mCfi.setText(String.valueOf(mCfiValue)); |
| 566 | } |
| 567 | |
| 568 | |
| 569 | private final void |
| 570 | updateServiceState() { |
| 571 | ServiceState serviceState = mPhoneStateReceiver.getServiceState(); |
| 572 | int state = serviceState.getState(); |
| 573 | Resources r = getResources(); |
| 574 | String display = r.getString(R.string.radioInfo_unknown); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 575 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 576 | switch (state) { |
| 577 | case ServiceState.STATE_IN_SERVICE: |
| 578 | display = r.getString(R.string.radioInfo_service_in); |
| 579 | break; |
| 580 | case ServiceState.STATE_OUT_OF_SERVICE: |
| 581 | case ServiceState.STATE_EMERGENCY_ONLY: |
| 582 | display = r.getString(R.string.radioInfo_service_emergency); |
| 583 | break; |
| 584 | case ServiceState.STATE_POWER_OFF: |
| 585 | display = r.getString(R.string.radioInfo_service_off); |
| 586 | break; |
| 587 | } |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 588 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 589 | gsmState.setText(display); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 590 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 591 | if (serviceState.getRoaming()) { |
| 592 | roamingState.setText(R.string.radioInfo_roaming_in); |
| 593 | } else { |
| 594 | roamingState.setText(R.string.radioInfo_roaming_not); |
| 595 | } |
| 596 | |
| 597 | operatorName.setText(serviceState.getOperatorAlphaLong()); |
| 598 | } |
| 599 | |
| 600 | private final void |
| 601 | updatePhoneState() { |
Wink Saville | 5543404 | 2012-06-14 12:33:43 -0700 | [diff] [blame] | 602 | PhoneConstants.State state = mPhoneStateReceiver.getPhoneState(); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 603 | Resources r = getResources(); |
| 604 | String display = r.getString(R.string.radioInfo_unknown); |
| 605 | |
| 606 | switch (state) { |
| 607 | case IDLE: |
| 608 | display = r.getString(R.string.radioInfo_phone_idle); |
| 609 | break; |
| 610 | case RINGING: |
| 611 | display = r.getString(R.string.radioInfo_phone_ringing); |
| 612 | break; |
| 613 | case OFFHOOK: |
| 614 | display = r.getString(R.string.radioInfo_phone_offhook); |
| 615 | break; |
| 616 | } |
| 617 | |
| 618 | callState.setText(display); |
| 619 | } |
| 620 | |
| 621 | private final void |
| 622 | updateDataState() { |
| 623 | int state = mTelephonyManager.getDataState(); |
| 624 | Resources r = getResources(); |
| 625 | String display = r.getString(R.string.radioInfo_unknown); |
| 626 | |
| 627 | switch (state) { |
| 628 | case TelephonyManager.DATA_CONNECTED: |
| 629 | display = r.getString(R.string.radioInfo_data_connected); |
| 630 | break; |
| 631 | case TelephonyManager.DATA_CONNECTING: |
| 632 | display = r.getString(R.string.radioInfo_data_connecting); |
| 633 | break; |
| 634 | case TelephonyManager.DATA_DISCONNECTED: |
| 635 | display = r.getString(R.string.radioInfo_data_disconnected); |
| 636 | break; |
| 637 | case TelephonyManager.DATA_SUSPENDED: |
| 638 | display = r.getString(R.string.radioInfo_data_suspended); |
| 639 | break; |
| 640 | } |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 641 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 642 | gprsState.setText(display); |
| 643 | } |
| 644 | |
| 645 | private final void updateNetworkType() { |
| 646 | Resources r = getResources(); |
| 647 | String display = SystemProperties.get(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, |
| 648 | r.getString(R.string.radioInfo_unknown)); |
| 649 | |
| 650 | network.setText(display); |
| 651 | } |
| 652 | |
| 653 | private final void |
| 654 | updateProperties() { |
| 655 | String s; |
| 656 | Resources r = getResources(); |
| 657 | |
| 658 | s = phone.getDeviceId(); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 659 | if (s == null) s = r.getString(R.string.radioInfo_unknown); |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 660 | mDeviceId.setText(s); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 661 | |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 662 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 663 | s = phone.getLine1Number(); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 664 | 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] | 665 | number.setText(s); |
| 666 | } |
| 667 | |
| 668 | private final void updateDataStats() { |
| 669 | String s; |
| 670 | |
| 671 | s = SystemProperties.get("net.gsm.radio-reset", "0"); |
| 672 | resets.setText(s); |
| 673 | |
| 674 | s = SystemProperties.get("net.gsm.attempt-gprs", "0"); |
| 675 | attempts.setText(s); |
| 676 | |
| 677 | s = SystemProperties.get("net.gsm.succeed-gprs", "0"); |
| 678 | successes.setText(s); |
| 679 | |
| 680 | //s = SystemProperties.get("net.gsm.disconnect", "0"); |
| 681 | //disconnects.setText(s); |
| 682 | |
| 683 | s = SystemProperties.get("net.ppp.reset-by-timeout", "0"); |
| 684 | sentSinceReceived.setText(s); |
| 685 | } |
| 686 | |
| 687 | private final void updateDataStats2() { |
| 688 | Resources r = getResources(); |
| 689 | |
Jeff Sharkey | 9302986 | 2011-05-27 18:26:15 -0700 | [diff] [blame] | 690 | long txPackets = TrafficStats.getMobileTxPackets(); |
| 691 | long rxPackets = TrafficStats.getMobileRxPackets(); |
| 692 | long txBytes = TrafficStats.getMobileTxBytes(); |
| 693 | long rxBytes = TrafficStats.getMobileRxBytes(); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 694 | |
Jeff Sharkey | 9302986 | 2011-05-27 18:26:15 -0700 | [diff] [blame] | 695 | String packets = r.getString(R.string.radioInfo_display_packets); |
| 696 | String bytes = r.getString(R.string.radioInfo_display_bytes); |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 697 | |
Jeff Sharkey | 9302986 | 2011-05-27 18:26:15 -0700 | [diff] [blame] | 698 | sent.setText(txPackets + " " + packets + ", " + txBytes + " " + bytes); |
| 699 | received.setText(rxPackets + " " + packets + ", " + rxBytes + " " + bytes); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | /** |
| 703 | * Ping a IP address. |
| 704 | */ |
| 705 | private final void pingIpAddr() { |
| 706 | try { |
| 707 | // This is hardcoded IP addr. This is for testing purposes. |
| 708 | // We would need to get rid of this before release. |
| 709 | String ipAddress = "74.125.47.104"; |
| 710 | Process p = Runtime.getRuntime().exec("ping -c 1 " + ipAddress); |
| 711 | int status = p.waitFor(); |
| 712 | if (status == 0) { |
| 713 | mPingIpAddrResult = "Pass"; |
| 714 | } else { |
| 715 | mPingIpAddrResult = "Fail: IP addr not reachable"; |
| 716 | } |
| 717 | } catch (IOException e) { |
| 718 | mPingIpAddrResult = "Fail: IOException"; |
| 719 | } catch (InterruptedException e) { |
| 720 | mPingIpAddrResult = "Fail: InterruptedException"; |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | /** |
| 725 | * Ping a host name |
| 726 | */ |
| 727 | private final void pingHostname() { |
| 728 | try { |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 729 | Process p = Runtime.getRuntime().exec("ping -c 1 www.google.com"); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 730 | int status = p.waitFor(); |
| 731 | if (status == 0) { |
| 732 | mPingHostnameResult = "Pass"; |
| 733 | } else { |
| 734 | mPingHostnameResult = "Fail: Host unreachable"; |
| 735 | } |
| 736 | } catch (UnknownHostException e) { |
| 737 | mPingHostnameResult = "Fail: Unknown Host"; |
| 738 | } catch (IOException e) { |
| 739 | mPingHostnameResult= "Fail: IOException"; |
| 740 | } catch (InterruptedException e) { |
| 741 | mPingHostnameResult = "Fail: InterruptedException"; |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | /** |
| 746 | * This function checks for basic functionality of HTTP Client. |
| 747 | */ |
| 748 | private void httpClientTest() { |
| 749 | HttpClient client = new DefaultHttpClient(); |
| 750 | try { |
| 751 | HttpGet request = new HttpGet("http://www.google.com"); |
| 752 | HttpResponse response = client.execute(request); |
| 753 | if (response.getStatusLine().getStatusCode() == 200) { |
| 754 | mHttpClientTestResult = "Pass"; |
| 755 | } else { |
| 756 | mHttpClientTestResult = "Fail: Code: " + String.valueOf(response); |
| 757 | } |
| 758 | request.abort(); |
| 759 | } catch (IOException e) { |
| 760 | mHttpClientTestResult = "Fail: IOException"; |
| 761 | } |
| 762 | } |
| 763 | |
| 764 | private void refreshSmsc() { |
jsh | 21dd407 | 2009-05-12 11:26:55 -0700 | [diff] [blame] | 765 | phone.getSmscAddress(mHandler.obtainMessage(EVENT_QUERY_SMSC_DONE)); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | private final void updatePingState() { |
| 769 | final Handler handler = new Handler(); |
| 770 | // Set all to unknown since the threads will take a few secs to update. |
| 771 | mPingIpAddrResult = getResources().getString(R.string.radioInfo_unknown); |
| 772 | mPingHostnameResult = getResources().getString(R.string.radioInfo_unknown); |
| 773 | mHttpClientTestResult = getResources().getString(R.string.radioInfo_unknown); |
| 774 | |
| 775 | mPingIpAddr.setText(mPingIpAddrResult); |
| 776 | mPingHostname.setText(mPingHostnameResult); |
| 777 | mHttpClientTest.setText(mHttpClientTestResult); |
| 778 | |
| 779 | final Runnable updatePingResults = new Runnable() { |
| 780 | public void run() { |
| 781 | mPingIpAddr.setText(mPingIpAddrResult); |
| 782 | mPingHostname.setText(mPingHostnameResult); |
| 783 | mHttpClientTest.setText(mHttpClientTestResult); |
| 784 | } |
| 785 | }; |
| 786 | Thread ipAddr = new Thread() { |
| 787 | @Override |
| 788 | public void run() { |
| 789 | pingIpAddr(); |
| 790 | handler.post(updatePingResults); |
| 791 | } |
| 792 | }; |
| 793 | ipAddr.start(); |
| 794 | |
| 795 | Thread hostname = new Thread() { |
| 796 | @Override |
| 797 | public void run() { |
| 798 | pingHostname(); |
| 799 | handler.post(updatePingResults); |
| 800 | } |
| 801 | }; |
| 802 | hostname.start(); |
| 803 | |
| 804 | Thread httpClient = new Thread() { |
| 805 | @Override |
| 806 | public void run() { |
| 807 | httpClientTest(); |
| 808 | handler.post(updatePingResults); |
| 809 | } |
| 810 | }; |
| 811 | httpClient.start(); |
| 812 | } |
| 813 | |
| 814 | private final void updatePdpList() { |
| 815 | StringBuilder sb = new StringBuilder("========DATA=======\n"); |
| 816 | |
Wink Saville | 2c3ec09 | 2011-04-20 10:24:36 -0700 | [diff] [blame] | 817 | // List<DataConnection> dcs = phone.getCurrentDataConnectionList(); |
| 818 | // |
| 819 | // for (DataConnection dc : dcs) { |
| 820 | // sb.append(" State=").append(dc.getStateAsString()).append("\n"); |
| 821 | // if (dc.isActive()) { |
| 822 | // long timeElapsed = |
| 823 | // (System.currentTimeMillis() - dc.getConnectionTime())/1000; |
| 824 | // sb.append(" connected at ") |
| 825 | // .append(DateUtils.timeString(dc.getConnectionTime())) |
| 826 | // .append(" and elapsed ") |
| 827 | // .append(DateUtils.formatElapsedTime(timeElapsed)); |
| 828 | // |
| 829 | // if (dc instanceof GsmDataConnection) { |
| 830 | // GsmDataConnection pdp = (GsmDataConnection)dc; |
| 831 | // sb.append("\n to ") |
| 832 | // .append(pdp.getApn().toString()); |
| 833 | // } |
| 834 | // sb.append("\nLinkProperties: "); |
| 835 | // sb.append(phone.getLinkProperties(phone.getActiveApnTypes()[0]).toString()); |
| 836 | // } else if (dc.isInactive()) { |
| 837 | // sb.append(" disconnected with last try at ") |
| 838 | // .append(DateUtils.timeString(dc.getLastFailTime())) |
| 839 | // .append("\n fail because ") |
| 840 | // .append(dc.getLastFailCause().toString()); |
| 841 | // } else { |
| 842 | // if (dc instanceof GsmDataConnection) { |
| 843 | // GsmDataConnection pdp = (GsmDataConnection)dc; |
| 844 | // sb.append(" is connecting to ") |
| 845 | // .append(pdp.getApn().toString()); |
| 846 | // } else { |
| 847 | // sb.append(" is connecting"); |
| 848 | // } |
| 849 | // } |
| 850 | // sb.append("\n==================="); |
| 851 | // } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 852 | |
| 853 | disconnects.setText(sb.toString()); |
| 854 | } |
| 855 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 856 | private MenuItem.OnMenuItemClickListener mViewADNCallback = new MenuItem.OnMenuItemClickListener() { |
| 857 | public boolean onMenuItemClick(MenuItem item) { |
| 858 | Intent intent = new Intent(Intent.ACTION_VIEW); |
| 859 | // XXX We need to specify the component here because if we don't |
| 860 | // the activity manager will try to resolve the type by calling |
| 861 | // the content provider, which causes it to be loaded in a process |
| 862 | // other than the Dialer process, which causes a lot of stuff to |
| 863 | // break. |
| 864 | intent.setClassName("com.android.phone", |
| 865 | "com.android.phone.SimContacts"); |
| 866 | startActivity(intent); |
| 867 | return true; |
| 868 | } |
| 869 | }; |
| 870 | |
| 871 | private MenuItem.OnMenuItemClickListener mViewFDNCallback = new MenuItem.OnMenuItemClickListener() { |
| 872 | public boolean onMenuItemClick(MenuItem item) { |
| 873 | Intent intent = new Intent(Intent.ACTION_VIEW); |
| 874 | // XXX We need to specify the component here because if we don't |
| 875 | // the activity manager will try to resolve the type by calling |
| 876 | // the content provider, which causes it to be loaded in a process |
| 877 | // other than the Dialer process, which causes a lot of stuff to |
| 878 | // break. |
| 879 | intent.setClassName("com.android.phone", |
| 880 | "com.android.phone.FdnList"); |
| 881 | startActivity(intent); |
| 882 | return true; |
| 883 | } |
| 884 | }; |
| 885 | |
| 886 | private MenuItem.OnMenuItemClickListener mViewSDNCallback = new MenuItem.OnMenuItemClickListener() { |
| 887 | public boolean onMenuItemClick(MenuItem item) { |
| 888 | Intent intent = new Intent( |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 889 | Intent.ACTION_VIEW, Uri.parse("content://icc/sdn")); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 890 | // XXX We need to specify the component here because if we don't |
| 891 | // the activity manager will try to resolve the type by calling |
| 892 | // the content provider, which causes it to be loaded in a process |
| 893 | // other than the Dialer process, which causes a lot of stuff to |
| 894 | // break. |
| 895 | intent.setClassName("com.android.phone", |
| 896 | "com.android.phone.ADNList"); |
| 897 | startActivity(intent); |
| 898 | return true; |
| 899 | } |
| 900 | }; |
| 901 | |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 902 | private MenuItem.OnMenuItemClickListener mGetPdpList = new MenuItem.OnMenuItemClickListener() { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 903 | public boolean onMenuItemClick(MenuItem item) { |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 904 | phone.getDataCallList(null); |
| 905 | return true; |
| 906 | } |
| 907 | }; |
| 908 | |
| 909 | private MenuItem.OnMenuItemClickListener mSelectBandCallback = new MenuItem.OnMenuItemClickListener() { |
| 910 | public boolean onMenuItemClick(MenuItem item) { |
| 911 | Intent intent = new Intent(); |
| 912 | intent.setClass(RadioInfo.this, BandMode.class); |
| 913 | startActivity(intent); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 914 | return true; |
| 915 | } |
| 916 | }; |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 917 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 918 | private MenuItem.OnMenuItemClickListener mToggleData = new MenuItem.OnMenuItemClickListener() { |
| 919 | public boolean onMenuItemClick(MenuItem item) { |
Robert Greenwalt | 99be500 | 2010-11-24 17:20:59 -0800 | [diff] [blame] | 920 | ConnectivityManager cm = |
| 921 | (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 922 | int state = mTelephonyManager.getDataState(); |
| 923 | switch (state) { |
| 924 | case TelephonyManager.DATA_CONNECTED: |
Robert Greenwalt | 99be500 | 2010-11-24 17:20:59 -0800 | [diff] [blame] | 925 | cm.setMobileDataEnabled(false); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 926 | break; |
| 927 | case TelephonyManager.DATA_DISCONNECTED: |
Robert Greenwalt | 99be500 | 2010-11-24 17:20:59 -0800 | [diff] [blame] | 928 | cm.setMobileDataEnabled(true); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 929 | break; |
| 930 | default: |
| 931 | // do nothing |
| 932 | break; |
| 933 | } |
| 934 | return true; |
| 935 | } |
| 936 | }; |
| 937 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 938 | OnClickListener mPowerButtonHandler = new OnClickListener() { |
| 939 | public void onClick(View v) { |
| 940 | //log("toggle radio power: currently " + (isRadioOn()?"on":"off")); |
| 941 | phone.setRadioPower(!isRadioOn()); |
| 942 | } |
| 943 | }; |
| 944 | |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 945 | class CellInfoListRateHandler implements OnClickListener { |
| 946 | int rates[] = {Integer.MAX_VALUE, 0, 1000}; |
| 947 | int index = 0; |
| 948 | |
| 949 | public int getRate() { |
| 950 | return rates[index]; |
| 951 | } |
| 952 | |
| 953 | @Override |
| 954 | public void onClick(View v) { |
| 955 | index += 1; |
| 956 | if (index >= rates.length) { |
| 957 | index = 0; |
| 958 | } |
| 959 | phone.setCellInfoListRate(rates[index]); |
| 960 | updateCellInfoListRate(); |
| 961 | } |
| 962 | } |
| 963 | CellInfoListRateHandler mCellInfoListRateHandler = new CellInfoListRateHandler(); |
| 964 | |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 965 | private Button imsRegRequiredButton; |
| 966 | static final String PROPERTY_IMS_REG_REQUIRED = "persist.radio.imsregrequired"; |
Wink Saville | 1e596f3 | 2011-09-19 14:24:39 -0700 | [diff] [blame] | 967 | OnClickListener mImsRegRequiredHandler = new OnClickListener() { |
| 968 | @Override |
| 969 | public void onClick(View v) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 970 | log(String.format("toggle %s: currently %s", |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 971 | PROPERTY_IMS_REG_REQUIRED, (isImsRegRequired() ? "on":"off"))); |
Wink Saville | 1e596f3 | 2011-09-19 14:24:39 -0700 | [diff] [blame] | 972 | boolean newValue = !isImsRegRequired(); |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 973 | SystemProperties.set(PROPERTY_IMS_REG_REQUIRED, |
Wink Saville | 1e596f3 | 2011-09-19 14:24:39 -0700 | [diff] [blame] | 974 | newValue ? "1":"0"); |
| 975 | updateImsRegRequiredState(); |
| 976 | } |
| 977 | }; |
| 978 | |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 979 | private boolean isImsRegRequired() { |
| 980 | return SystemProperties.getBoolean(PROPERTY_IMS_REG_REQUIRED, false); |
| 981 | } |
| 982 | |
| 983 | private void updateImsRegRequiredState() { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 984 | log("updateImsRegRequiredState isImsRegRequired()=" + isImsRegRequired()); |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 985 | String buttonText = isImsRegRequired() ? |
| 986 | getString(R.string.ims_reg_required_off) : |
| 987 | getString(R.string.ims_reg_required_on); |
| 988 | imsRegRequiredButton.setText(buttonText); |
| 989 | } |
| 990 | |
| 991 | private Button smsOverImsButton; |
Wink Saville | 382a75b | 2011-09-22 15:17:00 -0700 | [diff] [blame] | 992 | static final String PROPERTY_SMS_OVER_IMS = "persist.radio.imsallowmtsms"; |
| 993 | OnClickListener mSmsOverImsHandler = new OnClickListener() { |
| 994 | @Override |
| 995 | public void onClick(View v) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 996 | log(String.format("toggle %s: currently %s", |
Wink Saville | 382a75b | 2011-09-22 15:17:00 -0700 | [diff] [blame] | 997 | PROPERTY_SMS_OVER_IMS, (isSmsOverImsEnabled() ? "on":"off"))); |
| 998 | boolean newValue = !isSmsOverImsEnabled(); |
| 999 | SystemProperties.set(PROPERTY_SMS_OVER_IMS, newValue ? "1":"0"); |
| 1000 | updateSmsOverImsState(); |
| 1001 | } |
| 1002 | }; |
| 1003 | |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1004 | private boolean isSmsOverImsEnabled() { |
| 1005 | return SystemProperties.getBoolean(PROPERTY_SMS_OVER_IMS, false); |
| 1006 | } |
| 1007 | |
| 1008 | private void updateSmsOverImsState() { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1009 | log("updateSmsOverImsState isSmsOverImsEnabled()=" + isSmsOverImsEnabled()); |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1010 | String buttonText = isSmsOverImsEnabled() ? |
| 1011 | getString(R.string.sms_over_ims_off) : |
| 1012 | getString(R.string.sms_over_ims_on); |
| 1013 | smsOverImsButton.setText(buttonText); |
| 1014 | } |
| 1015 | |
| 1016 | private Button lteRamDumpButton; |
| 1017 | static final String PROPERTY_LTE_RAM_DUMP = "persist.radio.ramdump"; |
| 1018 | OnClickListener mLteRamDumpHandler = new OnClickListener() { |
| 1019 | @Override |
| 1020 | public void onClick(View v) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1021 | log(String.format("toggle %s: currently %s", |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1022 | PROPERTY_LTE_RAM_DUMP, (isSmsOverImsEnabled() ? "on":"off"))); |
| 1023 | boolean newValue = !isLteRamDumpEnabled(); |
| 1024 | SystemProperties.set(PROPERTY_LTE_RAM_DUMP, newValue ? "1":"0"); |
| 1025 | updateLteRamDumpState(); |
| 1026 | } |
| 1027 | }; |
| 1028 | |
| 1029 | private boolean isLteRamDumpEnabled() { |
| 1030 | return SystemProperties.getBoolean(PROPERTY_LTE_RAM_DUMP, false); |
| 1031 | } |
| 1032 | |
| 1033 | private void updateLteRamDumpState() { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1034 | log("updateLteRamDumpState isLteRamDumpEnabled()=" + isLteRamDumpEnabled()); |
Wink Saville | 426fc66 | 2011-09-25 14:39:02 -0700 | [diff] [blame] | 1035 | String buttonText = isLteRamDumpEnabled() ? |
| 1036 | getString(R.string.lte_ram_dump_off) : |
| 1037 | getString(R.string.lte_ram_dump_on); |
| 1038 | lteRamDumpButton.setText(buttonText); |
| 1039 | } |
| 1040 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1041 | OnClickListener mDnsCheckButtonHandler = new OnClickListener() { |
| 1042 | public void onClick(View v) { |
Wink Saville | c388668 | 2009-04-02 11:00:56 -0700 | [diff] [blame] | 1043 | phone.disableDnsCheck(!phone.isDnsCheckDisabled()); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1044 | updateDnsCheckState(); |
| 1045 | } |
| 1046 | }; |
johnwang | 342101a | 2009-09-23 16:22:34 -0700 | [diff] [blame] | 1047 | |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 1048 | OnClickListener mOemInfoButtonHandler = new OnClickListener() { |
| 1049 | public void onClick(View v) { |
| 1050 | Intent intent = new Intent("com.android.settings.OEM_RADIO_INFO"); |
| 1051 | try { |
| 1052 | startActivity(intent); |
| 1053 | } catch (android.content.ActivityNotFoundException ex) { |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1054 | log("OEM-specific Info/Settings Activity Not Found : " + ex); |
Tammo Spalink | a5f4c8f | 2009-10-15 20:08:58 +0800 | [diff] [blame] | 1055 | // If the activity does not exist, there are no OEM |
| 1056 | // settings, and so we can just do nothing... |
| 1057 | } |
| 1058 | } |
| 1059 | }; |
| 1060 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1061 | OnClickListener mPingButtonHandler = new OnClickListener() { |
| 1062 | public void onClick(View v) { |
| 1063 | updatePingState(); |
| 1064 | } |
| 1065 | }; |
| 1066 | |
| 1067 | OnClickListener mUpdateSmscButtonHandler = new OnClickListener() { |
| 1068 | public void onClick(View v) { |
| 1069 | updateSmscButton.setEnabled(false); |
jsh | 21dd407 | 2009-05-12 11:26:55 -0700 | [diff] [blame] | 1070 | phone.setSmscAddress(smsc.getText().toString(), |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1071 | mHandler.obtainMessage(EVENT_UPDATE_SMSC_DONE)); |
| 1072 | } |
| 1073 | }; |
| 1074 | |
| 1075 | OnClickListener mRefreshSmscButtonHandler = new OnClickListener() { |
| 1076 | public void onClick(View v) { |
| 1077 | refreshSmsc(); |
| 1078 | } |
| 1079 | }; |
| 1080 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1081 | AdapterView.OnItemSelectedListener |
| 1082 | mPreferredNetworkHandler = new AdapterView.OnItemSelectedListener() { |
| 1083 | public void onItemSelected(AdapterView parent, View v, int pos, long id) { |
| 1084 | Message msg = mHandler.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE); |
Ricardo Cerqueira | 32310ee | 2012-04-12 23:34:38 +0100 | [diff] [blame] | 1085 | if (pos>=0 && pos<=(mPreferredNetworkLabels.length - 2)) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1086 | phone.setPreferredNetworkType(pos, msg); |
| 1087 | } |
| 1088 | } |
| 1089 | |
| 1090 | public void onNothingSelected(AdapterView parent) { |
| 1091 | } |
| 1092 | }; |
| 1093 | |
| 1094 | private String[] mPreferredNetworkLabels = { |
jsh | 87fa11b | 2009-08-18 18:00:15 -0700 | [diff] [blame] | 1095 | "WCDMA preferred", |
| 1096 | "GSM only", |
| 1097 | "WCDMA only", |
| 1098 | "GSM auto (PRL)", |
| 1099 | "CDMA auto (PRL)", |
| 1100 | "CDMA only", |
| 1101 | "EvDo only", |
| 1102 | "GSM/CDMA auto (PRL)", |
Ricardo Cerqueira | 32310ee | 2012-04-12 23:34:38 +0100 | [diff] [blame] | 1103 | "LTE/CDMA auto (PRL)", |
| 1104 | "LTE/GSM auto (PRL)", |
| 1105 | "LTE/GSM/CDMA auto (PRL)", |
| 1106 | "LTE only", |
jsh | 87fa11b | 2009-08-18 18:00:15 -0700 | [diff] [blame] | 1107 | "Unknown"}; |
Wink Saville | bf47128 | 2013-04-05 15:04:05 -0700 | [diff] [blame] | 1108 | |
| 1109 | private void log(String s) { |
| 1110 | Log.d(TAG, "[RadioInfo] " + s); |
| 1111 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1112 | } |