The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 17 | package com.android.systemui.statusbar.phone; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 19 | import android.app.StatusBarManager; |
Nick Pelly | bd022f4 | 2009-08-14 18:33:38 -0700 | [diff] [blame] | 20 | import android.bluetooth.BluetoothAdapter; |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 21 | import android.bluetooth.BluetoothProfile; |
Jiafa Liu | 3f41673 | 2009-07-02 16:36:02 +0800 | [diff] [blame] | 22 | import android.bluetooth.BluetoothPbap; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | import android.content.BroadcastReceiver; |
| 24 | import android.content.Context; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.content.Intent; |
| 26 | import android.content.IntentFilter; |
| 27 | import android.content.res.TypedArray; |
| 28 | import android.graphics.PixelFormat; |
Daniel Sandler | 2c195f7 | 2010-05-21 15:42:06 -0400 | [diff] [blame] | 29 | import android.graphics.Typeface; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | import android.graphics.drawable.Drawable; |
Mike Lockwood | 00b7427 | 2010-03-26 10:41:48 -0400 | [diff] [blame] | 31 | import android.location.LocationManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import android.media.AudioManager; |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 33 | import android.net.ConnectivityManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | import android.net.NetworkInfo; |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 35 | import android.net.Uri; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | import android.net.wifi.WifiManager; |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 37 | import android.os.Binder; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | import android.os.Handler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | import android.os.Message; |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 40 | import android.os.RemoteException; |
San Mehat | 4154c07 | 2010-02-09 18:37:54 -0800 | [diff] [blame] | 41 | import android.os.storage.StorageManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | import android.provider.Settings; |
| 43 | import android.telephony.PhoneStateListener; |
| 44 | import android.telephony.ServiceState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 45 | import android.telephony.SignalStrength; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | import android.telephony.TelephonyManager; |
| 47 | import android.text.format.DateFormat; |
Daniel Sandler | 2c195f7 | 2010-05-21 15:42:06 -0400 | [diff] [blame] | 48 | import android.text.style.CharacterStyle; |
Eric Fischer | 36e136c | 2010-01-14 17:42:48 -0800 | [diff] [blame] | 49 | import android.text.style.RelativeSizeSpan; |
Daniel Sandler | 2c195f7 | 2010-05-21 15:42:06 -0400 | [diff] [blame] | 50 | import android.text.style.ForegroundColorSpan; |
| 51 | import android.text.style.StyleSpan; |
Eric Fischer | 36e136c | 2010-01-14 17:42:48 -0800 | [diff] [blame] | 52 | import android.text.Spannable; |
| 53 | import android.text.SpannableStringBuilder; |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 54 | import android.util.Slog; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | import android.view.View; |
| 56 | import android.view.ViewGroup; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | import android.widget.ImageView; |
| 58 | import android.widget.LinearLayout; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 60 | import com.android.internal.app.IBatteryStats; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 61 | import com.android.internal.telephony.IccCard; |
| 62 | import com.android.internal.telephony.TelephonyIntents; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 63 | import com.android.internal.telephony.cdma.EriInfo; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 64 | import com.android.internal.telephony.cdma.TtyIntent; |
| 65 | import com.android.server.am.BatteryStatsService; |
| 66 | |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 67 | import com.android.systemui.R; |
| 68 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | /** |
| 70 | * This class contains all of the policy about which icons are installed in the status |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 71 | * bar at boot time. It goes through the normal API for icons, even though it probably |
| 72 | * strictly doesn't need to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | */ |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 74 | public class PhoneStatusBarPolicy { |
| 75 | private static final String TAG = "PhoneStatusBarPolicy"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | // message codes for the handler |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | private static final int EVENT_BATTERY_CLOSE = 4; |
| 79 | |
Daniel Sandler | 2c195f7 | 2010-05-21 15:42:06 -0400 | [diff] [blame] | 80 | private static final int AM_PM_STYLE_NORMAL = 0; |
| 81 | private static final int AM_PM_STYLE_SMALL = 1; |
| 82 | private static final int AM_PM_STYLE_GONE = 2; |
| 83 | |
| 84 | private static final int AM_PM_STYLE = AM_PM_STYLE_GONE; |
| 85 | |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 86 | private static final int INET_CONDITION_THRESHOLD = 50; |
| 87 | |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 88 | private final Context mContext; |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 89 | private final StatusBarManager mService; |
Joe Onorato | 10523b4d | 2010-10-25 10:42:46 -0700 | [diff] [blame] | 90 | private final Handler mHandler = new Handler(); |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 91 | private final IBatteryStats mBatteryStats; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | |
San Mehat | 4154c07 | 2010-02-09 18:37:54 -0800 | [diff] [blame] | 93 | // storage |
| 94 | private StorageManager mStorageManager; |
| 95 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | // phone |
| 97 | private TelephonyManager mPhone; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 98 | private int mPhoneSignalIconId; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 99 | |
| 100 | //***** Signal strength icons |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 101 | //GSM/UMTS |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 102 | private static final int[][] sSignalImages = { |
| 103 | { R.drawable.stat_sys_signal_0, |
| 104 | R.drawable.stat_sys_signal_1, |
| 105 | R.drawable.stat_sys_signal_2, |
| 106 | R.drawable.stat_sys_signal_3, |
| 107 | R.drawable.stat_sys_signal_4 }, |
| 108 | { R.drawable.stat_sys_signal_0_fully, |
| 109 | R.drawable.stat_sys_signal_1_fully, |
| 110 | R.drawable.stat_sys_signal_2_fully, |
| 111 | R.drawable.stat_sys_signal_3_fully, |
| 112 | R.drawable.stat_sys_signal_4_fully } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 113 | }; |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 114 | private static final int[][] sSignalImages_r = { |
| 115 | { R.drawable.stat_sys_r_signal_0, |
| 116 | R.drawable.stat_sys_r_signal_1, |
| 117 | R.drawable.stat_sys_r_signal_2, |
| 118 | R.drawable.stat_sys_r_signal_3, |
| 119 | R.drawable.stat_sys_r_signal_4 }, |
| 120 | { R.drawable.stat_sys_r_signal_0_fully, |
| 121 | R.drawable.stat_sys_r_signal_1_fully, |
| 122 | R.drawable.stat_sys_r_signal_2_fully, |
| 123 | R.drawable.stat_sys_r_signal_3_fully, |
| 124 | R.drawable.stat_sys_r_signal_4_fully } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 125 | }; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 126 | private static final int[] sRoamingIndicatorImages_cdma = new int[] { |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 127 | R.drawable.stat_sys_roaming_cdma_0, //Standard Roaming Indicator |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 128 | // 1 is Standard Roaming Indicator OFF |
| 129 | // TODO T: image never used, remove and put 0 instead? |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 130 | R.drawable.stat_sys_roaming_cdma_0, |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 131 | |
| 132 | // 2 is Standard Roaming Indicator FLASHING |
| 133 | // TODO T: image never used, remove and put 0 instead? |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 134 | R.drawable.stat_sys_roaming_cdma_0, |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 135 | |
| 136 | // 3-12 Standard ERI |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 137 | R.drawable.stat_sys_roaming_cdma_0, //3 |
| 138 | R.drawable.stat_sys_roaming_cdma_0, |
| 139 | R.drawable.stat_sys_roaming_cdma_0, |
| 140 | R.drawable.stat_sys_roaming_cdma_0, |
| 141 | R.drawable.stat_sys_roaming_cdma_0, |
| 142 | R.drawable.stat_sys_roaming_cdma_0, |
| 143 | R.drawable.stat_sys_roaming_cdma_0, |
| 144 | R.drawable.stat_sys_roaming_cdma_0, |
| 145 | R.drawable.stat_sys_roaming_cdma_0, |
| 146 | R.drawable.stat_sys_roaming_cdma_0, |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 147 | |
| 148 | // 13-63 Reserved for Standard ERI |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 149 | R.drawable.stat_sys_roaming_cdma_0, //13 |
| 150 | R.drawable.stat_sys_roaming_cdma_0, |
| 151 | R.drawable.stat_sys_roaming_cdma_0, |
| 152 | R.drawable.stat_sys_roaming_cdma_0, |
| 153 | R.drawable.stat_sys_roaming_cdma_0, |
| 154 | R.drawable.stat_sys_roaming_cdma_0, |
| 155 | R.drawable.stat_sys_roaming_cdma_0, |
| 156 | R.drawable.stat_sys_roaming_cdma_0, |
| 157 | R.drawable.stat_sys_roaming_cdma_0, |
| 158 | R.drawable.stat_sys_roaming_cdma_0, |
| 159 | R.drawable.stat_sys_roaming_cdma_0, |
| 160 | R.drawable.stat_sys_roaming_cdma_0, |
| 161 | R.drawable.stat_sys_roaming_cdma_0, |
| 162 | R.drawable.stat_sys_roaming_cdma_0, |
| 163 | R.drawable.stat_sys_roaming_cdma_0, |
| 164 | R.drawable.stat_sys_roaming_cdma_0, |
| 165 | R.drawable.stat_sys_roaming_cdma_0, |
| 166 | R.drawable.stat_sys_roaming_cdma_0, |
| 167 | R.drawable.stat_sys_roaming_cdma_0, |
| 168 | R.drawable.stat_sys_roaming_cdma_0, |
| 169 | R.drawable.stat_sys_roaming_cdma_0, |
| 170 | R.drawable.stat_sys_roaming_cdma_0, |
| 171 | R.drawable.stat_sys_roaming_cdma_0, |
| 172 | R.drawable.stat_sys_roaming_cdma_0, |
| 173 | R.drawable.stat_sys_roaming_cdma_0, |
| 174 | R.drawable.stat_sys_roaming_cdma_0, |
| 175 | R.drawable.stat_sys_roaming_cdma_0, |
| 176 | R.drawable.stat_sys_roaming_cdma_0, |
| 177 | R.drawable.stat_sys_roaming_cdma_0, |
| 178 | R.drawable.stat_sys_roaming_cdma_0, |
| 179 | R.drawable.stat_sys_roaming_cdma_0, |
| 180 | R.drawable.stat_sys_roaming_cdma_0, |
| 181 | R.drawable.stat_sys_roaming_cdma_0, |
| 182 | R.drawable.stat_sys_roaming_cdma_0, |
| 183 | R.drawable.stat_sys_roaming_cdma_0, |
| 184 | R.drawable.stat_sys_roaming_cdma_0, |
| 185 | R.drawable.stat_sys_roaming_cdma_0, |
| 186 | R.drawable.stat_sys_roaming_cdma_0, |
| 187 | R.drawable.stat_sys_roaming_cdma_0, |
| 188 | R.drawable.stat_sys_roaming_cdma_0, |
| 189 | R.drawable.stat_sys_roaming_cdma_0, |
| 190 | R.drawable.stat_sys_roaming_cdma_0, |
| 191 | R.drawable.stat_sys_roaming_cdma_0, |
| 192 | R.drawable.stat_sys_roaming_cdma_0, |
| 193 | R.drawable.stat_sys_roaming_cdma_0, |
| 194 | R.drawable.stat_sys_roaming_cdma_0, |
| 195 | R.drawable.stat_sys_roaming_cdma_0, |
| 196 | R.drawable.stat_sys_roaming_cdma_0, |
| 197 | R.drawable.stat_sys_roaming_cdma_0, |
| 198 | R.drawable.stat_sys_roaming_cdma_0, |
| 199 | R.drawable.stat_sys_roaming_cdma_0, |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 200 | |
| 201 | // 64-127 Reserved for Non Standard (Operator Specific) ERI |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 202 | R.drawable.stat_sys_roaming_cdma_0, //64 |
| 203 | R.drawable.stat_sys_roaming_cdma_0, |
| 204 | R.drawable.stat_sys_roaming_cdma_0, |
| 205 | R.drawable.stat_sys_roaming_cdma_0, |
| 206 | R.drawable.stat_sys_roaming_cdma_0, |
| 207 | R.drawable.stat_sys_roaming_cdma_0, |
| 208 | R.drawable.stat_sys_roaming_cdma_0, |
| 209 | R.drawable.stat_sys_roaming_cdma_0, |
| 210 | R.drawable.stat_sys_roaming_cdma_0, |
| 211 | R.drawable.stat_sys_roaming_cdma_0, |
| 212 | R.drawable.stat_sys_roaming_cdma_0, |
| 213 | R.drawable.stat_sys_roaming_cdma_0, |
| 214 | R.drawable.stat_sys_roaming_cdma_0, |
| 215 | R.drawable.stat_sys_roaming_cdma_0, |
| 216 | R.drawable.stat_sys_roaming_cdma_0, |
| 217 | R.drawable.stat_sys_roaming_cdma_0, |
| 218 | R.drawable.stat_sys_roaming_cdma_0, |
| 219 | R.drawable.stat_sys_roaming_cdma_0, |
| 220 | R.drawable.stat_sys_roaming_cdma_0, |
Todor Kalaydjiev | a0c229d | 2011-07-18 17:55:24 -0700 | [diff] [blame] | 221 | R.drawable.stat_sys_roaming_cdma_0, //83 |
| 222 | R.drawable.stat_sys_roaming_cdma_0, |
| 223 | R.drawable.stat_sys_roaming_cdma_0, |
| 224 | R.drawable.stat_sys_roaming_cdma_0, |
| 225 | R.drawable.stat_sys_roaming_cdma_0, |
| 226 | R.drawable.stat_sys_roaming_cdma_0, |
| 227 | R.drawable.stat_sys_roaming_cdma_0, |
| 228 | R.drawable.stat_sys_roaming_cdma_0, |
| 229 | R.drawable.stat_sys_roaming_cdma_0, |
| 230 | R.drawable.stat_sys_roaming_cdma_0, |
| 231 | R.drawable.stat_sys_roaming_cdma_0, |
| 232 | R.drawable.stat_sys_roaming_cdma_0, |
| 233 | R.drawable.stat_sys_roaming_cdma_0, |
| 234 | R.drawable.stat_sys_roaming_cdma_0, |
| 235 | R.drawable.stat_sys_roaming_cdma_0, |
| 236 | R.drawable.stat_sys_roaming_cdma_0, |
| 237 | R.drawable.stat_sys_roaming_cdma_0, |
| 238 | R.drawable.stat_sys_roaming_cdma_0, |
| 239 | R.drawable.stat_sys_roaming_cdma_0, |
| 240 | R.drawable.stat_sys_roaming_cdma_0, |
| 241 | R.drawable.stat_sys_roaming_cdma_0, |
| 242 | R.drawable.stat_sys_roaming_cdma_0, |
| 243 | R.drawable.stat_sys_roaming_cdma_0, |
| 244 | R.drawable.stat_sys_roaming_cdma_0, |
| 245 | R.drawable.stat_sys_roaming_cdma_0, |
| 246 | R.drawable.stat_sys_roaming_cdma_0, |
| 247 | R.drawable.stat_sys_roaming_cdma_0, |
| 248 | R.drawable.stat_sys_roaming_cdma_0, |
| 249 | R.drawable.stat_sys_roaming_cdma_0, |
| 250 | R.drawable.stat_sys_roaming_cdma_0, |
| 251 | R.drawable.stat_sys_roaming_cdma_0, |
| 252 | R.drawable.stat_sys_roaming_cdma_0, |
| 253 | R.drawable.stat_sys_roaming_cdma_0, |
| 254 | R.drawable.stat_sys_roaming_cdma_0, |
| 255 | R.drawable.stat_sys_roaming_cdma_0, |
| 256 | R.drawable.stat_sys_roaming_cdma_0, |
| 257 | R.drawable.stat_sys_roaming_cdma_0, |
| 258 | R.drawable.stat_sys_roaming_cdma_0, |
| 259 | R.drawable.stat_sys_roaming_cdma_0, |
| 260 | R.drawable.stat_sys_roaming_cdma_0, |
| 261 | R.drawable.stat_sys_roaming_cdma_0, |
| 262 | R.drawable.stat_sys_roaming_cdma_0, |
| 263 | R.drawable.stat_sys_roaming_cdma_0, |
| 264 | R.drawable.stat_sys_roaming_cdma_0, |
| 265 | R.drawable.stat_sys_roaming_cdma_0, |
| 266 | R.drawable.stat_sys_roaming_cdma_0, |
| 267 | R.drawable.stat_sys_roaming_cdma_0, |
| 268 | R.drawable.stat_sys_roaming_cdma_0, |
| 269 | R.drawable.stat_sys_roaming_cdma_0, |
| 270 | R.drawable.stat_sys_roaming_cdma_0, |
| 271 | R.drawable.stat_sys_roaming_cdma_0, |
| 272 | R.drawable.stat_sys_roaming_cdma_0, |
| 273 | R.drawable.stat_sys_roaming_cdma_0, |
| 274 | R.drawable.stat_sys_roaming_cdma_0, |
| 275 | R.drawable.stat_sys_roaming_cdma_0, |
| 276 | R.drawable.stat_sys_roaming_cdma_0, |
| 277 | R.drawable.stat_sys_roaming_cdma_0, |
| 278 | R.drawable.stat_sys_roaming_cdma_0, |
| 279 | R.drawable.stat_sys_roaming_cdma_0, |
| 280 | R.drawable.stat_sys_roaming_cdma_0, |
| 281 | R.drawable.stat_sys_roaming_cdma_0, |
| 282 | R.drawable.stat_sys_roaming_cdma_0, |
| 283 | R.drawable.stat_sys_roaming_cdma_0, |
| 284 | R.drawable.stat_sys_roaming_cdma_0, |
| 285 | R.drawable.stat_sys_roaming_cdma_0, |
| 286 | R.drawable.stat_sys_roaming_cdma_0, |
| 287 | R.drawable.stat_sys_roaming_cdma_0, |
| 288 | R.drawable.stat_sys_roaming_cdma_0, |
| 289 | R.drawable.stat_sys_roaming_cdma_0, |
| 290 | R.drawable.stat_sys_roaming_cdma_0, |
| 291 | R.drawable.stat_sys_roaming_cdma_0, |
| 292 | R.drawable.stat_sys_roaming_cdma_0, |
| 293 | R.drawable.stat_sys_roaming_cdma_0, |
| 294 | R.drawable.stat_sys_roaming_cdma_0, |
| 295 | R.drawable.stat_sys_roaming_cdma_0, |
| 296 | R.drawable.stat_sys_roaming_cdma_0, |
| 297 | R.drawable.stat_sys_roaming_cdma_0, |
| 298 | R.drawable.stat_sys_roaming_cdma_0, |
| 299 | R.drawable.stat_sys_roaming_cdma_0, |
| 300 | R.drawable.stat_sys_roaming_cdma_0, |
| 301 | R.drawable.stat_sys_roaming_cdma_0, |
| 302 | R.drawable.stat_sys_roaming_cdma_0, |
| 303 | R.drawable.stat_sys_roaming_cdma_0, |
| 304 | R.drawable.stat_sys_roaming_cdma_0, |
| 305 | R.drawable.stat_sys_roaming_cdma_0, |
| 306 | R.drawable.stat_sys_roaming_cdma_0, |
| 307 | R.drawable.stat_sys_roaming_cdma_0, |
| 308 | R.drawable.stat_sys_roaming_cdma_0, |
| 309 | R.drawable.stat_sys_roaming_cdma_0, |
| 310 | R.drawable.stat_sys_roaming_cdma_0, |
| 311 | R.drawable.stat_sys_roaming_cdma_0, |
| 312 | R.drawable.stat_sys_roaming_cdma_0, |
| 313 | R.drawable.stat_sys_roaming_cdma_0, |
| 314 | R.drawable.stat_sys_roaming_cdma_0, |
| 315 | R.drawable.stat_sys_roaming_cdma_0, |
| 316 | R.drawable.stat_sys_roaming_cdma_0, |
| 317 | R.drawable.stat_sys_roaming_cdma_0, |
| 318 | R.drawable.stat_sys_roaming_cdma_0, |
| 319 | R.drawable.stat_sys_roaming_cdma_0, |
| 320 | R.drawable.stat_sys_roaming_cdma_0, |
| 321 | R.drawable.stat_sys_roaming_cdma_0, |
| 322 | R.drawable.stat_sys_roaming_cdma_0, |
| 323 | R.drawable.stat_sys_roaming_cdma_0, |
| 324 | R.drawable.stat_sys_roaming_cdma_0, |
| 325 | R.drawable.stat_sys_roaming_cdma_0, |
| 326 | R.drawable.stat_sys_roaming_cdma_0, |
| 327 | R.drawable.stat_sys_roaming_cdma_0, |
| 328 | R.drawable.stat_sys_roaming_cdma_0, |
| 329 | R.drawable.stat_sys_roaming_cdma_0, |
| 330 | R.drawable.stat_sys_roaming_cdma_0, |
| 331 | R.drawable.stat_sys_roaming_cdma_0, |
| 332 | R.drawable.stat_sys_roaming_cdma_0, |
| 333 | R.drawable.stat_sys_roaming_cdma_0, |
| 334 | R.drawable.stat_sys_roaming_cdma_0, |
| 335 | R.drawable.stat_sys_roaming_cdma_0, |
| 336 | R.drawable.stat_sys_roaming_cdma_0, |
| 337 | R.drawable.stat_sys_roaming_cdma_0, |
| 338 | R.drawable.stat_sys_roaming_cdma_0, |
| 339 | R.drawable.stat_sys_roaming_cdma_0, |
| 340 | R.drawable.stat_sys_roaming_cdma_0, |
| 341 | R.drawable.stat_sys_roaming_cdma_0, |
| 342 | R.drawable.stat_sys_roaming_cdma_0, |
| 343 | R.drawable.stat_sys_roaming_cdma_0, |
| 344 | R.drawable.stat_sys_roaming_cdma_0, |
| 345 | R.drawable.stat_sys_roaming_cdma_0, |
| 346 | R.drawable.stat_sys_roaming_cdma_0, |
| 347 | R.drawable.stat_sys_roaming_cdma_0, |
| 348 | R.drawable.stat_sys_roaming_cdma_0, |
| 349 | R.drawable.stat_sys_roaming_cdma_0, |
| 350 | R.drawable.stat_sys_roaming_cdma_0, |
| 351 | R.drawable.stat_sys_roaming_cdma_0, |
| 352 | R.drawable.stat_sys_roaming_cdma_0, |
| 353 | R.drawable.stat_sys_roaming_cdma_0, |
| 354 | R.drawable.stat_sys_roaming_cdma_0, |
| 355 | R.drawable.stat_sys_roaming_cdma_0, |
| 356 | R.drawable.stat_sys_roaming_cdma_0, |
| 357 | R.drawable.stat_sys_roaming_cdma_0, |
| 358 | R.drawable.stat_sys_roaming_cdma_0, |
| 359 | R.drawable.stat_sys_roaming_cdma_0, |
| 360 | R.drawable.stat_sys_roaming_cdma_0, |
| 361 | R.drawable.stat_sys_roaming_cdma_0, |
| 362 | R.drawable.stat_sys_roaming_cdma_0, |
| 363 | R.drawable.stat_sys_roaming_cdma_0, |
| 364 | R.drawable.stat_sys_roaming_cdma_0, |
| 365 | R.drawable.stat_sys_roaming_cdma_0, |
| 366 | R.drawable.stat_sys_roaming_cdma_0, |
| 367 | R.drawable.stat_sys_roaming_cdma_0, |
| 368 | R.drawable.stat_sys_roaming_cdma_0, |
| 369 | R.drawable.stat_sys_roaming_cdma_0, |
| 370 | R.drawable.stat_sys_roaming_cdma_0, |
| 371 | R.drawable.stat_sys_roaming_cdma_0, |
| 372 | R.drawable.stat_sys_roaming_cdma_0, |
| 373 | R.drawable.stat_sys_roaming_cdma_0, |
| 374 | R.drawable.stat_sys_roaming_cdma_0, |
| 375 | R.drawable.stat_sys_roaming_cdma_0, |
| 376 | R.drawable.stat_sys_roaming_cdma_0, |
| 377 | R.drawable.stat_sys_roaming_cdma_0 //239 |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 378 | |
Todor Kalaydjiev | a0c229d | 2011-07-18 17:55:24 -0700 | [diff] [blame] | 379 | // 240-255 Reserved |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 380 | }; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 381 | |
| 382 | //***** Data connection icons |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 383 | private int[] mDataIconList = sDataNetType_g[0]; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 384 | //GSM/UMTS |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 385 | private static final int[][] sDataNetType_g = { |
| 386 | { R.drawable.stat_sys_data_connected_g, |
| 387 | R.drawable.stat_sys_data_in_g, |
| 388 | R.drawable.stat_sys_data_out_g, |
| 389 | R.drawable.stat_sys_data_inandout_g }, |
Robert Greenwalt | 26faee3 | 2010-09-10 09:36:43 -0700 | [diff] [blame] | 390 | { R.drawable.stat_sys_data_fully_connected_g, |
| 391 | R.drawable.stat_sys_data_fully_in_g, |
| 392 | R.drawable.stat_sys_data_fully_out_g, |
| 393 | R.drawable.stat_sys_data_fully_inandout_g } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 394 | }; |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 395 | private static final int[][] sDataNetType_3g = { |
| 396 | { R.drawable.stat_sys_data_connected_3g, |
| 397 | R.drawable.stat_sys_data_in_3g, |
| 398 | R.drawable.stat_sys_data_out_3g, |
| 399 | R.drawable.stat_sys_data_inandout_3g }, |
Robert Greenwalt | 26faee3 | 2010-09-10 09:36:43 -0700 | [diff] [blame] | 400 | { R.drawable.stat_sys_data_fully_connected_3g, |
| 401 | R.drawable.stat_sys_data_fully_in_3g, |
| 402 | R.drawable.stat_sys_data_fully_out_3g, |
| 403 | R.drawable.stat_sys_data_fully_inandout_3g } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 404 | }; |
Wink Saville | 2b8bcfe | 2011-02-24 17:58:51 -0800 | [diff] [blame] | 405 | private static final int[][] sDataNetType_4g = { |
| 406 | { R.drawable.stat_sys_data_connected_4g, |
| 407 | R.drawable.stat_sys_data_in_4g, |
| 408 | R.drawable.stat_sys_data_out_4g, |
| 409 | R.drawable.stat_sys_data_inandout_4g }, |
| 410 | { R.drawable.stat_sys_data_fully_connected_4g, |
| 411 | R.drawable.stat_sys_data_fully_in_4g, |
| 412 | R.drawable.stat_sys_data_fully_out_4g, |
| 413 | R.drawable.stat_sys_data_fully_inandout_4g } |
| 414 | }; |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 415 | private static final int[][] sDataNetType_e = { |
| 416 | { R.drawable.stat_sys_data_connected_e, |
| 417 | R.drawable.stat_sys_data_in_e, |
| 418 | R.drawable.stat_sys_data_out_e, |
| 419 | R.drawable.stat_sys_data_inandout_e }, |
Robert Greenwalt | 26faee3 | 2010-09-10 09:36:43 -0700 | [diff] [blame] | 420 | { R.drawable.stat_sys_data_fully_connected_e, |
| 421 | R.drawable.stat_sys_data_fully_in_e, |
| 422 | R.drawable.stat_sys_data_fully_out_e, |
| 423 | R.drawable.stat_sys_data_fully_inandout_e } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 424 | }; |
Li Zhe | ebe6634 | 2009-08-14 19:22:16 +0800 | [diff] [blame] | 425 | //3.5G |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 426 | private static final int[][] sDataNetType_h = { |
| 427 | { R.drawable.stat_sys_data_connected_h, |
| 428 | R.drawable.stat_sys_data_in_h, |
| 429 | R.drawable.stat_sys_data_out_h, |
| 430 | R.drawable.stat_sys_data_inandout_h }, |
Robert Greenwalt | 26faee3 | 2010-09-10 09:36:43 -0700 | [diff] [blame] | 431 | { R.drawable.stat_sys_data_fully_connected_h, |
| 432 | R.drawable.stat_sys_data_fully_in_h, |
| 433 | R.drawable.stat_sys_data_fully_out_h, |
| 434 | R.drawable.stat_sys_data_fully_inandout_h } |
Li Zhe | ebe6634 | 2009-08-14 19:22:16 +0800 | [diff] [blame] | 435 | }; |
| 436 | |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 437 | //CDMA |
johnwang | 9f87cb2 | 2009-08-25 15:25:37 -0700 | [diff] [blame] | 438 | // Use 3G icons for EVDO data and 1x icons for 1XRTT data |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 439 | private static final int[][] sDataNetType_1x = { |
| 440 | { R.drawable.stat_sys_data_connected_1x, |
| 441 | R.drawable.stat_sys_data_in_1x, |
| 442 | R.drawable.stat_sys_data_out_1x, |
| 443 | R.drawable.stat_sys_data_inandout_1x }, |
Robert Greenwalt | 26faee3 | 2010-09-10 09:36:43 -0700 | [diff] [blame] | 444 | { R.drawable.stat_sys_data_fully_connected_1x, |
| 445 | R.drawable.stat_sys_data_fully_in_1x, |
| 446 | R.drawable.stat_sys_data_fully_out_1x, |
| 447 | R.drawable.stat_sys_data_fully_inandout_1x } |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 448 | }; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 449 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 450 | // Assume it's all good unless we hear otherwise. We don't always seem |
| 451 | // to get broadcasts that it *is* there. |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 452 | IccCard.State mSimState = IccCard.State.READY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 453 | int mPhoneState = TelephonyManager.CALL_STATE_IDLE; |
| 454 | int mDataState = TelephonyManager.DATA_DISCONNECTED; |
| 455 | int mDataActivity = TelephonyManager.DATA_ACTIVITY_NONE; |
| 456 | ServiceState mServiceState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 457 | SignalStrength mSignalStrength; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 458 | |
| 459 | // data connection |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 460 | private boolean mDataIconVisible; |
John Wang | 33e21fc | 2009-10-08 10:35:27 -0700 | [diff] [blame] | 461 | private boolean mHspaDataDistinguishable; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 462 | |
| 463 | // ringer volume |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 464 | private boolean mVolumeVisible; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 465 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 466 | // bluetooth device status |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 467 | private boolean mBluetoothEnabled; |
| 468 | |
| 469 | // wifi |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 470 | private static final int[][] sWifiSignalImages = { |
| 471 | { R.drawable.stat_sys_wifi_signal_1, |
| 472 | R.drawable.stat_sys_wifi_signal_2, |
| 473 | R.drawable.stat_sys_wifi_signal_3, |
| 474 | R.drawable.stat_sys_wifi_signal_4 }, |
Robert Greenwalt | 26faee3 | 2010-09-10 09:36:43 -0700 | [diff] [blame] | 475 | { R.drawable.stat_sys_wifi_signal_1_fully, |
| 476 | R.drawable.stat_sys_wifi_signal_2_fully, |
| 477 | R.drawable.stat_sys_wifi_signal_3_fully, |
| 478 | R.drawable.stat_sys_wifi_signal_4_fully } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 479 | }; |
| 480 | private static final int sWifiTemporarilyNotConnectedImage = |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 481 | R.drawable.stat_sys_wifi_signal_0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 482 | |
| 483 | private int mLastWifiSignalLevel = -1; |
| 484 | private boolean mIsWifiConnected = false; |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 485 | |
| 486 | // state of inet connection - 0 not connected, 100 connected |
| 487 | private int mInetCondition = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 488 | |
| 489 | // sync state |
| 490 | // If sync is active the SyncActive icon is displayed. If sync is not active but |
| 491 | // sync is failing the SyncFailing icon is displayed. Otherwise neither are displayed. |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 492 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 493 | private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { |
| 494 | @Override |
| 495 | public void onReceive(Context context, Intent intent) { |
| 496 | String action = intent.getAction(); |
Joe Onorato | 263700d | 2010-05-14 11:54:53 -0700 | [diff] [blame] | 497 | if (action.equals(Intent.ACTION_BATTERY_CHANGED)) { |
Dianne Hackborn | 8ec5b83 | 2009-07-01 21:19:35 -0700 | [diff] [blame] | 498 | updateBattery(intent); |
| 499 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 500 | else if (action.equals(Intent.ACTION_ALARM_CHANGED)) { |
| 501 | updateAlarm(intent); |
| 502 | } |
| 503 | else if (action.equals(Intent.ACTION_SYNC_STATE_CHANGED)) { |
| 504 | updateSyncState(intent); |
| 505 | } |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 506 | else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) || |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 507 | action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 508 | updateBluetooth(intent); |
| 509 | } |
| 510 | else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION) || |
| 511 | action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION) || |
| 512 | action.equals(WifiManager.RSSI_CHANGED_ACTION)) { |
| 513 | updateWifi(intent); |
| 514 | } |
Mike Lockwood | 00b7427 | 2010-03-26 10:41:48 -0400 | [diff] [blame] | 515 | else if (action.equals(LocationManager.GPS_ENABLED_CHANGE_ACTION) || |
| 516 | action.equals(LocationManager.GPS_FIX_CHANGE_ACTION)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 517 | updateGps(intent); |
| 518 | } |
| 519 | else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) || |
| 520 | action.equals(AudioManager.VIBRATE_SETTING_CHANGED_ACTION)) { |
| 521 | updateVolume(); |
| 522 | } |
| 523 | else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { |
| 524 | updateSimState(intent); |
| 525 | } |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 526 | else if (action.equals(TtyIntent.TTY_ENABLED_CHANGE_ACTION)) { |
| 527 | updateTTY(intent); |
| 528 | } |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 529 | else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION) || |
| 530 | action.equals(ConnectivityManager.INET_CONDITION_ACTION)) { |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 531 | // TODO - stop using other means to get wifi/mobile info |
| 532 | updateConnectivity(intent); |
| 533 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 534 | } |
| 535 | }; |
| 536 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 537 | public PhoneStatusBarPolicy(Context context) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 538 | mContext = context; |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 539 | mService = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 540 | mSignalStrength = new SignalStrength(); |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 541 | mBatteryStats = BatteryStatsService.getService(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 542 | |
San Mehat | 4154c07 | 2010-02-09 18:37:54 -0800 | [diff] [blame] | 543 | // storage |
| 544 | mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); |
| 545 | mStorageManager.registerListener( |
Joe Onorato | fe4f3ae | 2010-06-04 11:25:26 -0700 | [diff] [blame] | 546 | new com.android.systemui.usb.StorageNotification(context)); |
San Mehat | 4154c07 | 2010-02-09 18:37:54 -0800 | [diff] [blame] | 547 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 548 | // battery |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 549 | mService.setIcon("battery", com.android.internal.R.drawable.stat_sys_battery_unknown, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 550 | |
| 551 | // phone_signal |
| 552 | mPhone = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 553 | mPhoneSignalIconId = R.drawable.stat_sys_signal_null; |
| 554 | mService.setIcon("phone_signal", mPhoneSignalIconId, 0); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 555 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 556 | // register for phone state notifications. |
| 557 | ((TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE)) |
| 558 | .listen(mPhoneStateListener, |
| 559 | PhoneStateListener.LISTEN_SERVICE_STATE |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 560 | | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 561 | | PhoneStateListener.LISTEN_CALL_STATE |
| 562 | | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE |
| 563 | | PhoneStateListener.LISTEN_DATA_ACTIVITY); |
| 564 | |
| 565 | // data_connection |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 566 | mService.setIcon("data_connection", R.drawable.stat_sys_data_connected_g, 0); |
| 567 | mService.setIconVisibility("data_connection", false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 568 | |
| 569 | // wifi |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 570 | mService.setIcon("wifi", sWifiSignalImages[0][0], 0); |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 571 | mService.setIconVisibility("wifi", false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 572 | // wifi will get updated by the sticky intents |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 573 | |
| 574 | // TTY status |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 575 | mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0); |
| 576 | mService.setIconVisibility("tty", false); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 577 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 578 | // Cdma Roaming Indicator, ERI |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 579 | mService.setIcon("cdma_eri", R.drawable.stat_sys_roaming_cdma_0, 0); |
| 580 | mService.setIconVisibility("cdma_eri", false); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 581 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 582 | // bluetooth status |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 583 | mService.setIcon("bluetooth", R.drawable.stat_sys_data_bluetooth, 0); |
Nick Pelly | f242b7b | 2009-10-08 00:12:45 +0200 | [diff] [blame] | 584 | BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); |
Nick Pelly | bd022f4 | 2009-08-14 18:33:38 -0700 | [diff] [blame] | 585 | if (adapter != null) { |
| 586 | mBluetoothEnabled = adapter.isEnabled(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 587 | } else { |
| 588 | mBluetoothEnabled = false; |
| 589 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 590 | mService.setIconVisibility("bluetooth", mBluetoothEnabled); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 591 | |
| 592 | // Gps status |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 593 | mService.setIcon("gps", R.drawable.stat_sys_gps_acquiring_anim, 0); |
| 594 | mService.setIconVisibility("gps", false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 595 | |
| 596 | // Alarm clock |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 597 | mService.setIcon("alarm_clock", R.drawable.stat_notify_alarm, 0); |
| 598 | mService.setIconVisibility("alarm_clock", false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 599 | |
| 600 | // Sync state |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 601 | mService.setIcon("sync_active", com.android.internal.R.drawable.stat_notify_sync_anim0, 0); |
| 602 | mService.setIcon("sync_failing", com.android.internal.R.drawable.stat_notify_sync_error, 0); |
| 603 | mService.setIconVisibility("sync_active", false); |
| 604 | mService.setIconVisibility("sync_failing", false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 605 | |
| 606 | // volume |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 607 | mService.setIcon("volume", R.drawable.stat_sys_ringer_silent, 0); |
| 608 | mService.setIconVisibility("volume", false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 609 | updateVolume(); |
johnwang | 347c5a2 | 2009-08-24 22:11:11 -0700 | [diff] [blame] | 610 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 611 | IntentFilter filter = new IntentFilter(); |
| 612 | |
| 613 | // Register for Intent broadcasts for... |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 614 | filter.addAction(Intent.ACTION_BATTERY_CHANGED); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 615 | filter.addAction(Intent.ACTION_ALARM_CHANGED); |
| 616 | filter.addAction(Intent.ACTION_SYNC_STATE_CHANGED); |
| 617 | filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); |
| 618 | filter.addAction(AudioManager.VIBRATE_SETTING_CHANGED_ACTION); |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 619 | filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 620 | filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 621 | filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); |
| 622 | filter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); |
| 623 | filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); |
| 624 | filter.addAction(WifiManager.RSSI_CHANGED_ACTION); |
Mike Lockwood | 00b7427 | 2010-03-26 10:41:48 -0400 | [diff] [blame] | 625 | filter.addAction(LocationManager.GPS_ENABLED_CHANGE_ACTION); |
| 626 | filter.addAction(LocationManager.GPS_FIX_CHANGE_ACTION); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 627 | filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 628 | filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION); |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 629 | filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 630 | filter.addAction(ConnectivityManager.INET_CONDITION_ACTION); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 631 | mContext.registerReceiver(mIntentReceiver, filter, null, mHandler); |
John Wang | 33e21fc | 2009-10-08 10:35:27 -0700 | [diff] [blame] | 632 | |
| 633 | // load config to determine if to distinguish Hspa data icon |
| 634 | try { |
| 635 | mHspaDataDistinguishable = mContext.getResources().getBoolean( |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 636 | R.bool.config_hspa_data_distinguishable); |
John Wang | 33e21fc | 2009-10-08 10:35:27 -0700 | [diff] [blame] | 637 | } catch (Exception e) { |
| 638 | mHspaDataDistinguishable = false; |
| 639 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 640 | } |
| 641 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 642 | private final void updateAlarm(Intent intent) { |
| 643 | boolean alarmSet = intent.getBooleanExtra("alarmSet", false); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 644 | mService.setIconVisibility("alarm_clock", alarmSet); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | private final void updateSyncState(Intent intent) { |
| 648 | boolean isActive = intent.getBooleanExtra("active", false); |
| 649 | boolean isFailing = intent.getBooleanExtra("failing", false); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 650 | mService.setIconVisibility("sync_active", isActive); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 651 | // Don't display sync failing icon: BUG 1297963 Set sync error timeout to "never" |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 652 | //mService.setIconVisibility("sync_failing", isFailing && !isActive); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 653 | } |
| 654 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 655 | private final void updateBattery(Intent intent) { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 656 | final int id = intent.getIntExtra("icon-small", 0); |
| 657 | int level = intent.getIntExtra("level", 0); |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 658 | mService.setIcon("battery", id, level); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 659 | } |
| 660 | |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 661 | private void updateConnectivity(Intent intent) { |
| 662 | NetworkInfo info = (NetworkInfo)(intent.getParcelableExtra( |
| 663 | ConnectivityManager.EXTRA_NETWORK_INFO)); |
| 664 | int connectionStatus = intent.getIntExtra(ConnectivityManager.EXTRA_INET_CONDITION, 0); |
Robert Greenwalt | 029be81 | 2010-09-20 18:01:43 -0700 | [diff] [blame] | 665 | |
| 666 | int inetCondition = (connectionStatus > INET_CONDITION_THRESHOLD ? 1 : 0); |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 667 | |
| 668 | switch (info.getType()) { |
| 669 | case ConnectivityManager.TYPE_MOBILE: |
Robert Greenwalt | 029be81 | 2010-09-20 18:01:43 -0700 | [diff] [blame] | 670 | mInetCondition = inetCondition; |
| 671 | updateDataNetType(info.getSubtype()); |
| 672 | updateDataIcon(); |
| 673 | updateSignalStrength(); // apply any change in connectionStatus |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 674 | break; |
| 675 | case ConnectivityManager.TYPE_WIFI: |
Robert Greenwalt | 029be81 | 2010-09-20 18:01:43 -0700 | [diff] [blame] | 676 | mInetCondition = inetCondition; |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 677 | if (info.isConnected()) { |
| 678 | mIsWifiConnected = true; |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 679 | int iconId; |
| 680 | if (mLastWifiSignalLevel == -1) { |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 681 | iconId = sWifiSignalImages[mInetCondition][0]; |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 682 | } else { |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 683 | iconId = sWifiSignalImages[mInetCondition][mLastWifiSignalLevel]; |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 684 | } |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 685 | mService.setIcon("wifi", iconId, 0); |
| 686 | // Show the icon since wi-fi is connected |
| 687 | mService.setIconVisibility("wifi", true); |
| 688 | } else { |
| 689 | mLastWifiSignalLevel = -1; |
| 690 | mIsWifiConnected = false; |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 691 | int iconId = sWifiSignalImages[0][0]; |
| 692 | |
| 693 | mService.setIcon("wifi", iconId, 0); |
| 694 | // Hide the icon since we're not connected |
| 695 | mService.setIconVisibility("wifi", false); |
| 696 | } |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 697 | updateSignalStrength(); // apply any change in mInetCondition |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 698 | break; |
| 699 | } |
| 700 | } |
| 701 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 702 | private PhoneStateListener mPhoneStateListener = new PhoneStateListener() { |
| 703 | @Override |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 704 | public void onSignalStrengthsChanged(SignalStrength signalStrength) { |
| 705 | mSignalStrength = signalStrength; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 706 | updateSignalStrength(); |
| 707 | } |
| 708 | |
| 709 | @Override |
| 710 | public void onServiceStateChanged(ServiceState state) { |
| 711 | mServiceState = state; |
| 712 | updateSignalStrength(); |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 713 | updateCdmaRoamingIcon(state); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 714 | updateDataIcon(); |
| 715 | } |
| 716 | |
| 717 | @Override |
| 718 | public void onCallStateChanged(int state, String incomingNumber) { |
johnwang | 347c5a2 | 2009-08-24 22:11:11 -0700 | [diff] [blame] | 719 | // In cdma, if a voice call is made, RSSI should switch to 1x. |
| 720 | if (isCdma()) { |
| 721 | updateSignalStrength(); |
| 722 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | @Override |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 726 | public void onDataConnectionStateChanged(int state, int networkType) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 727 | mDataState = state; |
Robert Greenwalt | 029be81 | 2010-09-20 18:01:43 -0700 | [diff] [blame] | 728 | updateDataNetType(networkType); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 729 | updateDataIcon(); |
| 730 | } |
| 731 | |
| 732 | @Override |
| 733 | public void onDataActivity(int direction) { |
| 734 | mDataActivity = direction; |
| 735 | updateDataIcon(); |
| 736 | } |
| 737 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 738 | |
| 739 | private final void updateSimState(Intent intent) { |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 740 | String stateExtra = intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE); |
| 741 | if (IccCard.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) { |
| 742 | mSimState = IccCard.State.ABSENT; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 743 | } |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 744 | else if (IccCard.INTENT_VALUE_ICC_READY.equals(stateExtra)) { |
| 745 | mSimState = IccCard.State.READY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 746 | } |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 747 | else if (IccCard.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) { |
| 748 | final String lockedReason = intent.getStringExtra(IccCard.INTENT_KEY_LOCKED_REASON); |
| 749 | if (IccCard.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) { |
| 750 | mSimState = IccCard.State.PIN_REQUIRED; |
johnwang | 347c5a2 | 2009-08-24 22:11:11 -0700 | [diff] [blame] | 751 | } |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 752 | else if (IccCard.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) { |
| 753 | mSimState = IccCard.State.PUK_REQUIRED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 754 | } |
| 755 | else { |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 756 | mSimState = IccCard.State.NETWORK_LOCKED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 757 | } |
| 758 | } else { |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 759 | mSimState = IccCard.State.UNKNOWN; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 760 | } |
| 761 | updateDataIcon(); |
| 762 | } |
| 763 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 764 | private boolean isCdma() { |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 765 | return (mSignalStrength != null) && !mSignalStrength.isGsm(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 766 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 767 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 768 | private boolean hasService() { |
| 769 | if (mServiceState != null) { |
| 770 | switch (mServiceState.getState()) { |
| 771 | case ServiceState.STATE_OUT_OF_SERVICE: |
| 772 | case ServiceState.STATE_POWER_OFF: |
| 773 | return false; |
| 774 | default: |
| 775 | return true; |
| 776 | } |
| 777 | } else { |
| 778 | return false; |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | private final void updateSignalStrength() { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 783 | int[] iconList; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 784 | |
John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 785 | // Display signal strength while in "emergency calls only" mode |
Joe Onorato | 49a8bbf | 2010-09-23 09:50:04 -0700 | [diff] [blame] | 786 | if (mServiceState == null || (!hasService() && !mServiceState.isEmergencyOnly())) { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 787 | //Slog.d(TAG, "updateSignalStrength: no service"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 788 | if (Settings.System.getInt(mContext.getContentResolver(), |
| 789 | Settings.System.AIRPLANE_MODE_ON, 0) == 1) { |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 790 | mPhoneSignalIconId = R.drawable.stat_sys_signal_flightmode; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 791 | } else { |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 792 | mPhoneSignalIconId = R.drawable.stat_sys_signal_null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 793 | } |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 794 | mService.setIcon("phone_signal", mPhoneSignalIconId, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 795 | return; |
| 796 | } |
| 797 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 798 | if (!isCdma()) { |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 799 | // Though mPhone is a Manager, this call is not an IPC |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 800 | if (mPhone.isNetworkRoaming()) { |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 801 | iconList = sSignalImages_r[mInetCondition]; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 802 | } else { |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 803 | iconList = sSignalImages[mInetCondition]; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 804 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 805 | } else { |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 806 | iconList = sSignalImages[mInetCondition]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 807 | } |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 808 | mPhoneSignalIconId = iconList[mSignalStrength.getLevel()]; |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 809 | mService.setIcon("phone_signal", mPhoneSignalIconId, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 810 | } |
| 811 | |
Robert Greenwalt | 029be81 | 2010-09-20 18:01:43 -0700 | [diff] [blame] | 812 | private final void updateDataNetType(int net) { |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 813 | switch (net) { |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 814 | case TelephonyManager.NETWORK_TYPE_EDGE: |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 815 | mDataIconList = sDataNetType_e[mInetCondition]; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 816 | break; |
| 817 | case TelephonyManager.NETWORK_TYPE_UMTS: |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 818 | mDataIconList = sDataNetType_3g[mInetCondition]; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 819 | break; |
Li Zhe | ebe6634 | 2009-08-14 19:22:16 +0800 | [diff] [blame] | 820 | case TelephonyManager.NETWORK_TYPE_HSDPA: |
| 821 | case TelephonyManager.NETWORK_TYPE_HSUPA: |
| 822 | case TelephonyManager.NETWORK_TYPE_HSPA: |
John Wang | 33e21fc | 2009-10-08 10:35:27 -0700 | [diff] [blame] | 823 | if (mHspaDataDistinguishable) { |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 824 | mDataIconList = sDataNetType_h[mInetCondition]; |
John Wang | 33e21fc | 2009-10-08 10:35:27 -0700 | [diff] [blame] | 825 | } else { |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 826 | mDataIconList = sDataNetType_3g[mInetCondition]; |
John Wang | 33e21fc | 2009-10-08 10:35:27 -0700 | [diff] [blame] | 827 | } |
Li Zhe | ebe6634 | 2009-08-14 19:22:16 +0800 | [diff] [blame] | 828 | break; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 829 | case TelephonyManager.NETWORK_TYPE_CDMA: |
| 830 | // display 1xRTT for IS95A/B |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 831 | mDataIconList = sDataNetType_1x[mInetCondition]; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 832 | break; |
| 833 | case TelephonyManager.NETWORK_TYPE_1xRTT: |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 834 | mDataIconList = sDataNetType_1x[mInetCondition]; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 835 | break; |
| 836 | case TelephonyManager.NETWORK_TYPE_EVDO_0: //fall through |
| 837 | case TelephonyManager.NETWORK_TYPE_EVDO_A: |
Naveen Kalla | 0a5174a | 2010-04-21 14:48:03 -0700 | [diff] [blame] | 838 | case TelephonyManager.NETWORK_TYPE_EVDO_B: |
Wink Saville | 2b8bcfe | 2011-02-24 17:58:51 -0800 | [diff] [blame] | 839 | case TelephonyManager.NETWORK_TYPE_EHRPD: |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 840 | mDataIconList = sDataNetType_3g[mInetCondition]; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 841 | break; |
Wink Saville | 2b8bcfe | 2011-02-24 17:58:51 -0800 | [diff] [blame] | 842 | case TelephonyManager.NETWORK_TYPE_LTE: |
| 843 | mDataIconList = sDataNetType_4g[mInetCondition]; |
| 844 | break; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 845 | default: |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 846 | mDataIconList = sDataNetType_g[mInetCondition]; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 847 | break; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 848 | } |
| 849 | } |
| 850 | |
| 851 | private final void updateDataIcon() { |
| 852 | int iconId; |
| 853 | boolean visible = true; |
| 854 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 855 | if (!isCdma()) { |
| 856 | // GSM case, we have to check also the sim state |
| 857 | if (mSimState == IccCard.State.READY || mSimState == IccCard.State.UNKNOWN) { |
| 858 | if (hasService() && mDataState == TelephonyManager.DATA_CONNECTED) { |
| 859 | switch (mDataActivity) { |
| 860 | case TelephonyManager.DATA_ACTIVITY_IN: |
| 861 | iconId = mDataIconList[1]; |
| 862 | break; |
| 863 | case TelephonyManager.DATA_ACTIVITY_OUT: |
| 864 | iconId = mDataIconList[2]; |
| 865 | break; |
| 866 | case TelephonyManager.DATA_ACTIVITY_INOUT: |
| 867 | iconId = mDataIconList[3]; |
| 868 | break; |
| 869 | default: |
| 870 | iconId = mDataIconList[0]; |
| 871 | break; |
| 872 | } |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 873 | mService.setIcon("data_connection", iconId, 0); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 874 | } else { |
| 875 | visible = false; |
| 876 | } |
| 877 | } else { |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 878 | iconId = R.drawable.stat_sys_no_sim; |
| 879 | mService.setIcon("data_connection", iconId, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 880 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 881 | } else { |
| 882 | // CDMA case, mDataActivity can be also DATA_ACTIVITY_DORMANT |
| 883 | if (hasService() && mDataState == TelephonyManager.DATA_CONNECTED) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 884 | switch (mDataActivity) { |
| 885 | case TelephonyManager.DATA_ACTIVITY_IN: |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 886 | iconId = mDataIconList[1]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 887 | break; |
| 888 | case TelephonyManager.DATA_ACTIVITY_OUT: |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 889 | iconId = mDataIconList[2]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 890 | break; |
| 891 | case TelephonyManager.DATA_ACTIVITY_INOUT: |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 892 | iconId = mDataIconList[3]; |
| 893 | break; |
| 894 | case TelephonyManager.DATA_ACTIVITY_DORMANT: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 895 | default: |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 896 | iconId = mDataIconList[0]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 897 | break; |
| 898 | } |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 899 | mService.setIcon("data_connection", iconId, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 900 | } else { |
| 901 | visible = false; |
| 902 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 903 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 904 | |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 905 | long ident = Binder.clearCallingIdentity(); |
| 906 | try { |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 907 | mBatteryStats.notePhoneDataConnectionState(mPhone.getNetworkType(), visible); |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 908 | } catch (RemoteException e) { |
| 909 | } finally { |
| 910 | Binder.restoreCallingIdentity(ident); |
| 911 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 912 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 913 | if (mDataIconVisible != visible) { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 914 | mService.setIconVisibility("data_connection", visible); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 915 | mDataIconVisible = visible; |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | private final void updateVolume() { |
| 920 | AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); |
| 921 | final int ringerMode = audioManager.getRingerMode(); |
| 922 | final boolean visible = ringerMode == AudioManager.RINGER_MODE_SILENT || |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 923 | ringerMode == AudioManager.RINGER_MODE_VIBRATE; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 924 | final int iconId = audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER) |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 925 | ? R.drawable.stat_sys_ringer_vibrate |
| 926 | : R.drawable.stat_sys_ringer_silent; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 927 | |
| 928 | if (visible) { |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 929 | mService.setIcon("volume", iconId, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 930 | } |
| 931 | if (visible != mVolumeVisible) { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 932 | mService.setIconVisibility("volume", visible); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 933 | mVolumeVisible = visible; |
| 934 | } |
| 935 | } |
| 936 | |
| 937 | private final void updateBluetooth(Intent intent) { |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 938 | int iconId = R.drawable.stat_sys_data_bluetooth; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 939 | String action = intent.getAction(); |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 940 | if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { |
Nick Pelly | b24e11b | 2009-09-08 17:40:43 -0700 | [diff] [blame] | 941 | int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR); |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 942 | mBluetoothEnabled = state == BluetoothAdapter.STATE_ON; |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 943 | } else if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) { |
Jaikumar Ganesh | 0b63a6a | 2011-07-11 14:34:34 -0700 | [diff] [blame] | 944 | int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 945 | BluetoothAdapter.STATE_DISCONNECTED); |
| 946 | if (state == BluetoothAdapter.STATE_CONNECTED) { |
| 947 | iconId = R.drawable.stat_sys_data_bluetooth_connected; |
Jaikumar Ganesh | 084c665 | 2009-12-07 10:58:18 -0800 | [diff] [blame] | 948 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 949 | } else { |
| 950 | return; |
| 951 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 952 | |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 953 | mService.setIcon("bluetooth", iconId, 0); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 954 | mService.setIconVisibility("bluetooth", mBluetoothEnabled); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 955 | } |
| 956 | |
| 957 | private final void updateWifi(Intent intent) { |
| 958 | final String action = intent.getAction(); |
| 959 | if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 960 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 961 | final boolean enabled = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, |
| 962 | WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_ENABLED; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 963 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 964 | if (!enabled) { |
| 965 | // If disabled, hide the icon. (We show icon when connected.) |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 966 | mService.setIconVisibility("wifi", false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 967 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 968 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 969 | } else if (action.equals(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)) { |
| 970 | final boolean enabled = intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, |
| 971 | false); |
| 972 | if (!enabled) { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 973 | mService.setIconVisibility("wifi", false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 974 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 975 | } else if (action.equals(WifiManager.RSSI_CHANGED_ACTION)) { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 976 | int iconId; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 977 | final int newRssi = intent.getIntExtra(WifiManager.EXTRA_NEW_RSSI, -200); |
| 978 | int newSignalLevel = WifiManager.calculateSignalLevel(newRssi, |
Robert Greenwalt | fa974c5 | 2010-09-13 15:53:26 -0700 | [diff] [blame] | 979 | sWifiSignalImages[0].length); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 980 | if (newSignalLevel != mLastWifiSignalLevel) { |
| 981 | mLastWifiSignalLevel = newSignalLevel; |
| 982 | if (mIsWifiConnected) { |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 983 | iconId = sWifiSignalImages[mInetCondition][newSignalLevel]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 984 | } else { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 985 | iconId = sWifiTemporarilyNotConnectedImage; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 986 | } |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 987 | mService.setIcon("wifi", iconId, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 988 | } |
| 989 | } |
| 990 | } |
| 991 | |
| 992 | private final void updateGps(Intent intent) { |
| 993 | final String action = intent.getAction(); |
Mike Lockwood | 00b7427 | 2010-03-26 10:41:48 -0400 | [diff] [blame] | 994 | final boolean enabled = intent.getBooleanExtra(LocationManager.EXTRA_GPS_ENABLED, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 995 | |
Mike Lockwood | 00b7427 | 2010-03-26 10:41:48 -0400 | [diff] [blame] | 996 | if (action.equals(LocationManager.GPS_FIX_CHANGE_ACTION) && enabled) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 997 | // GPS is getting fixes |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 998 | mService.setIcon("gps", com.android.internal.R.drawable.stat_sys_gps_on, 0); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 999 | mService.setIconVisibility("gps", true); |
Mike Lockwood | 00b7427 | 2010-03-26 10:41:48 -0400 | [diff] [blame] | 1000 | } else if (action.equals(LocationManager.GPS_ENABLED_CHANGE_ACTION) && !enabled) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1001 | // GPS is off |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1002 | mService.setIconVisibility("gps", false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1003 | } else { |
| 1004 | // GPS is on, but not receiving fixes |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 1005 | mService.setIcon("gps", R.drawable.stat_sys_gps_acquiring_anim, 0); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1006 | mService.setIconVisibility("gps", true); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1007 | } |
| 1008 | } |
| 1009 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1010 | private final void updateTTY(Intent intent) { |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 1011 | final String action = intent.getAction(); |
| 1012 | final boolean enabled = intent.getBooleanExtra(TtyIntent.TTY_ENABLED, false); |
| 1013 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 1014 | if (false) Slog.v(TAG, "updateTTY: enabled: " + enabled); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 1015 | |
| 1016 | if (enabled) { |
| 1017 | // TTY is on |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 1018 | if (false) Slog.v(TAG, "updateTTY: set TTY on"); |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 1019 | mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1020 | mService.setIconVisibility("tty", true); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 1021 | } else { |
| 1022 | // TTY is off |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 1023 | if (false) Slog.v(TAG, "updateTTY: set TTY off"); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1024 | mService.setIconVisibility("tty", false); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 1025 | } |
| 1026 | } |
| 1027 | |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 1028 | private final void updateCdmaRoamingIcon(ServiceState state) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1029 | if (!hasService()) { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1030 | mService.setIconVisibility("cdma_eri", false); |
Wink Saville | f315238 | 2009-06-01 14:39:20 -0700 | [diff] [blame] | 1031 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | if (!isCdma()) { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1035 | mService.setIconVisibility("cdma_eri", false); |
Wink Saville | f315238 | 2009-06-01 14:39:20 -0700 | [diff] [blame] | 1036 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1037 | } |
| 1038 | |
| 1039 | int[] iconList = sRoamingIndicatorImages_cdma; |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 1040 | int iconIndex = state.getCdmaEriIconIndex(); |
| 1041 | int iconMode = state.getCdmaEriIconMode(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1042 | |
| 1043 | if (iconIndex == -1) { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 1044 | Slog.e(TAG, "getCdmaEriIconIndex returned null, skipping ERI icon update"); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1045 | return; |
| 1046 | } |
| 1047 | |
| 1048 | if (iconMode == -1) { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 1049 | Slog.e(TAG, "getCdmeEriIconMode returned null, skipping ERI icon update"); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1050 | return; |
| 1051 | } |
| 1052 | |
| 1053 | if (iconIndex == EriInfo.ROAMING_INDICATOR_OFF) { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 1054 | if (false) Slog.v(TAG, "Cdma ROAMING_INDICATOR_OFF, removing ERI icon"); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1055 | mService.setIconVisibility("cdma_eri", false); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1056 | return; |
| 1057 | } |
| 1058 | |
| 1059 | switch (iconMode) { |
| 1060 | case EriInfo.ROAMING_ICON_MODE_NORMAL: |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 1061 | mService.setIcon("cdma_eri", iconList[iconIndex], 0); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1062 | mService.setIconVisibility("cdma_eri", true); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1063 | break; |
| 1064 | case EriInfo.ROAMING_ICON_MODE_FLASH: |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 1065 | mService.setIcon("cdma_eri", R.drawable.stat_sys_roaming_cdma_flash, 0); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1066 | mService.setIconVisibility("cdma_eri", true); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1067 | break; |
| 1068 | |
| 1069 | } |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 1070 | mService.setIcon("phone_signal", mPhoneSignalIconId, 0); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1071 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1072 | } |