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; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import android.content.BroadcastReceiver; |
| 22 | import android.content.Context; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | import android.content.Intent; |
| 24 | import android.content.IntentFilter; |
Mike Lockwood | 00b7427 | 2010-03-26 10:41:48 -0400 | [diff] [blame] | 25 | import android.location.LocationManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.media.AudioManager; |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 27 | import android.net.ConnectivityManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | import android.net.NetworkInfo; |
| 29 | import android.net.wifi.WifiManager; |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 30 | import android.os.Binder; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | import android.os.Handler; |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 32 | import android.os.RemoteException; |
San Mehat | 4154c07 | 2010-02-09 18:37:54 -0800 | [diff] [blame] | 33 | import android.os.storage.StorageManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | import android.provider.Settings; |
| 35 | import android.telephony.PhoneStateListener; |
| 36 | import android.telephony.ServiceState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 37 | import android.telephony.SignalStrength; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | import android.telephony.TelephonyManager; |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 39 | import android.util.Slog; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 41 | import com.android.internal.telephony.IccCard; |
| 42 | import com.android.internal.telephony.TelephonyIntents; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 43 | import com.android.internal.telephony.cdma.EriInfo; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 44 | import com.android.internal.telephony.cdma.TtyIntent; |
| 45 | import com.android.server.am.BatteryStatsService; |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 46 | import com.android.systemui.R; |
| 47 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | /** |
| 49 | * 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] | 50 | * bar at boot time. It goes through the normal API for icons, even though it probably |
| 51 | * strictly doesn't need to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | */ |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 53 | public class PhoneStatusBarPolicy { |
| 54 | private static final String TAG = "PhoneStatusBarPolicy"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | // message codes for the handler |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | private static final int EVENT_BATTERY_CLOSE = 4; |
| 58 | |
Daniel Sandler | 2c195f7 | 2010-05-21 15:42:06 -0400 | [diff] [blame] | 59 | private static final int AM_PM_STYLE_NORMAL = 0; |
| 60 | private static final int AM_PM_STYLE_SMALL = 1; |
| 61 | private static final int AM_PM_STYLE_GONE = 2; |
| 62 | |
| 63 | private static final int AM_PM_STYLE = AM_PM_STYLE_GONE; |
| 64 | |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 65 | private static final int INET_CONDITION_THRESHOLD = 50; |
| 66 | |
Daniel Sandler | b1e8dab | 2011-09-26 20:06:19 -0400 | [diff] [blame] | 67 | private static final boolean SHOW_SYNC_ICON = false; |
| 68 | |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 69 | private final Context mContext; |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 70 | private final StatusBarManager mService; |
Joe Onorato | 10523b4d | 2010-10-25 10:42:46 -0700 | [diff] [blame] | 71 | private final Handler mHandler = new Handler(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | |
San Mehat | 4154c07 | 2010-02-09 18:37:54 -0800 | [diff] [blame] | 73 | // storage |
| 74 | private StorageManager mStorageManager; |
| 75 | |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 76 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | // Assume it's all good unless we hear otherwise. We don't always seem |
| 78 | // to get broadcasts that it *is* there. |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 79 | IccCard.State mSimState = IccCard.State.READY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | |
| 81 | // ringer volume |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | private boolean mVolumeVisible; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 83 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | // bluetooth device status |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 85 | private boolean mBluetoothEnabled; |
| 86 | |
| 87 | // wifi |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 88 | private static final int[][] sWifiSignalImages = { |
| 89 | { R.drawable.stat_sys_wifi_signal_1, |
| 90 | R.drawable.stat_sys_wifi_signal_2, |
| 91 | R.drawable.stat_sys_wifi_signal_3, |
| 92 | R.drawable.stat_sys_wifi_signal_4 }, |
Robert Greenwalt | 26faee3 | 2010-09-10 09:36:43 -0700 | [diff] [blame] | 93 | { R.drawable.stat_sys_wifi_signal_1_fully, |
| 94 | R.drawable.stat_sys_wifi_signal_2_fully, |
| 95 | R.drawable.stat_sys_wifi_signal_3_fully, |
| 96 | R.drawable.stat_sys_wifi_signal_4_fully } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 97 | }; |
| 98 | private static final int sWifiTemporarilyNotConnectedImage = |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 99 | R.drawable.stat_sys_wifi_signal_0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | |
| 101 | private int mLastWifiSignalLevel = -1; |
| 102 | private boolean mIsWifiConnected = false; |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 103 | |
| 104 | // state of inet connection - 0 not connected, 100 connected |
| 105 | private int mInetCondition = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 106 | |
| 107 | // sync state |
| 108 | // If sync is active the SyncActive icon is displayed. If sync is not active but |
| 109 | // sync is failing the SyncFailing icon is displayed. Otherwise neither are displayed. |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 110 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 111 | private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { |
| 112 | @Override |
| 113 | public void onReceive(Context context, Intent intent) { |
| 114 | String action = intent.getAction(); |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 115 | if (action.equals(Intent.ACTION_ALARM_CHANGED)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | updateAlarm(intent); |
| 117 | } |
| 118 | else if (action.equals(Intent.ACTION_SYNC_STATE_CHANGED)) { |
| 119 | updateSyncState(intent); |
| 120 | } |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 121 | else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) || |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 122 | action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 123 | updateBluetooth(intent); |
| 124 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 125 | else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) || |
| 126 | action.equals(AudioManager.VIBRATE_SETTING_CHANGED_ACTION)) { |
| 127 | updateVolume(); |
| 128 | } |
| 129 | else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { |
| 130 | updateSimState(intent); |
| 131 | } |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 132 | else if (action.equals(TtyIntent.TTY_ENABLED_CHANGE_ACTION)) { |
| 133 | updateTTY(intent); |
| 134 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 135 | } |
| 136 | }; |
| 137 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 138 | public PhoneStatusBarPolicy(Context context) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 139 | mContext = context; |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 140 | mService = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 141 | |
San Mehat | 4154c07 | 2010-02-09 18:37:54 -0800 | [diff] [blame] | 142 | // storage |
| 143 | mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); |
| 144 | mStorageManager.registerListener( |
Joe Onorato | fe4f3ae | 2010-06-04 11:25:26 -0700 | [diff] [blame] | 145 | new com.android.systemui.usb.StorageNotification(context)); |
San Mehat | 4154c07 | 2010-02-09 18:37:54 -0800 | [diff] [blame] | 146 | |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 147 | // TTY status |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 148 | mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0, null); |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 149 | mService.setIconVisibility("tty", false); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 150 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 151 | // Cdma Roaming Indicator, ERI |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 152 | mService.setIcon("cdma_eri", R.drawable.stat_sys_roaming_cdma_0, 0, null); |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 153 | mService.setIconVisibility("cdma_eri", false); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 154 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 155 | // bluetooth status |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 156 | mService.setIcon("bluetooth", R.drawable.stat_sys_data_bluetooth, 0, null); |
Nick Pelly | f242b7b | 2009-10-08 00:12:45 +0200 | [diff] [blame] | 157 | BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); |
Nick Pelly | bd022f4 | 2009-08-14 18:33:38 -0700 | [diff] [blame] | 158 | if (adapter != null) { |
| 159 | mBluetoothEnabled = adapter.isEnabled(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 160 | } else { |
| 161 | mBluetoothEnabled = false; |
| 162 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 163 | mService.setIconVisibility("bluetooth", mBluetoothEnabled); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 164 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 165 | // Alarm clock |
Justin Ho | fdfbbf6 | 2011-08-26 08:51:27 -0700 | [diff] [blame] | 166 | mService.setIcon("alarm_clock", R.drawable.stat_sys_alarm, 0, null); |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 167 | mService.setIconVisibility("alarm_clock", false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 168 | |
| 169 | // Sync state |
Justin Ho | 9f17658 | 2011-09-20 18:16:48 -0700 | [diff] [blame] | 170 | mService.setIcon("sync_active", R.drawable.stat_sys_sync, 0, null); |
| 171 | mService.setIcon("sync_failing", R.drawable.stat_sys_sync_error, 0, null); |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 172 | mService.setIconVisibility("sync_active", false); |
| 173 | mService.setIconVisibility("sync_failing", false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 174 | |
| 175 | // volume |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 176 | mService.setIcon("volume", R.drawable.stat_sys_ringer_silent, 0, null); |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 177 | mService.setIconVisibility("volume", false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 178 | updateVolume(); |
johnwang | 347c5a2 | 2009-08-24 22:11:11 -0700 | [diff] [blame] | 179 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 180 | IntentFilter filter = new IntentFilter(); |
| 181 | |
| 182 | // Register for Intent broadcasts for... |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 183 | filter.addAction(Intent.ACTION_ALARM_CHANGED); |
| 184 | filter.addAction(Intent.ACTION_SYNC_STATE_CHANGED); |
| 185 | filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); |
| 186 | filter.addAction(AudioManager.VIBRATE_SETTING_CHANGED_ACTION); |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 187 | filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 188 | filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 189 | filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 190 | filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 191 | mContext.registerReceiver(mIntentReceiver, filter, null, mHandler); |
| 192 | } |
| 193 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | private final void updateAlarm(Intent intent) { |
| 195 | boolean alarmSet = intent.getBooleanExtra("alarmSet", false); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 196 | mService.setIconVisibility("alarm_clock", alarmSet); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | private final void updateSyncState(Intent intent) { |
Daniel Sandler | b1e8dab | 2011-09-26 20:06:19 -0400 | [diff] [blame] | 200 | if (!SHOW_SYNC_ICON) return; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 201 | boolean isActive = intent.getBooleanExtra("active", false); |
| 202 | boolean isFailing = intent.getBooleanExtra("failing", false); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 203 | mService.setIconVisibility("sync_active", isActive); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 204 | // 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] | 205 | //mService.setIconVisibility("sync_failing", isFailing && !isActive); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 206 | } |
| 207 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 208 | private final void updateSimState(Intent intent) { |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 209 | String stateExtra = intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE); |
| 210 | if (IccCard.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) { |
| 211 | mSimState = IccCard.State.ABSENT; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 212 | } |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 213 | else if (IccCard.INTENT_VALUE_ICC_READY.equals(stateExtra)) { |
| 214 | mSimState = IccCard.State.READY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 215 | } |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 216 | else if (IccCard.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) { |
| 217 | final String lockedReason = intent.getStringExtra(IccCard.INTENT_KEY_LOCKED_REASON); |
| 218 | if (IccCard.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) { |
| 219 | mSimState = IccCard.State.PIN_REQUIRED; |
johnwang | 347c5a2 | 2009-08-24 22:11:11 -0700 | [diff] [blame] | 220 | } |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 221 | else if (IccCard.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) { |
| 222 | mSimState = IccCard.State.PUK_REQUIRED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 223 | } |
| 224 | else { |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 225 | mSimState = IccCard.State.NETWORK_LOCKED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 226 | } |
| 227 | } else { |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 228 | mSimState = IccCard.State.UNKNOWN; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 229 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | private final void updateVolume() { |
| 233 | AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); |
| 234 | final int ringerMode = audioManager.getRingerMode(); |
| 235 | final boolean visible = ringerMode == AudioManager.RINGER_MODE_SILENT || |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 236 | ringerMode == AudioManager.RINGER_MODE_VIBRATE; |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 237 | |
| 238 | final int iconId; |
| 239 | String contentDescription = null; |
| 240 | if (audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER)) { |
| 241 | iconId = R.drawable.stat_sys_ringer_vibrate; |
| 242 | contentDescription = mContext.getString(R.string.accessibility_ringer_vibrate); |
| 243 | } else { |
| 244 | iconId = R.drawable.stat_sys_ringer_silent; |
| 245 | contentDescription = mContext.getString(R.string.accessibility_ringer_silent); |
| 246 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 247 | |
| 248 | if (visible) { |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 249 | mService.setIcon("volume", iconId, 0, contentDescription); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 250 | } |
| 251 | if (visible != mVolumeVisible) { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 252 | mService.setIconVisibility("volume", visible); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 253 | mVolumeVisible = visible; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | private final void updateBluetooth(Intent intent) { |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 258 | int iconId = R.drawable.stat_sys_data_bluetooth; |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 259 | String contentDescription = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 260 | String action = intent.getAction(); |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 261 | if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { |
Nick Pelly | b24e11b | 2009-09-08 17:40:43 -0700 | [diff] [blame] | 262 | int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR); |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 263 | mBluetoothEnabled = state == BluetoothAdapter.STATE_ON; |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 264 | } else if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) { |
Jaikumar Ganesh | 0b63a6a | 2011-07-11 14:34:34 -0700 | [diff] [blame] | 265 | int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 266 | BluetoothAdapter.STATE_DISCONNECTED); |
| 267 | if (state == BluetoothAdapter.STATE_CONNECTED) { |
| 268 | iconId = R.drawable.stat_sys_data_bluetooth_connected; |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 269 | contentDescription = mContext.getString(R.string.accessibility_bluetooth_connected); |
| 270 | } else { |
| 271 | contentDescription = mContext.getString( |
| 272 | R.string.accessibility_bluetooth_disconnected); |
Jaikumar Ganesh | 084c665 | 2009-12-07 10:58:18 -0800 | [diff] [blame] | 273 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 274 | } else { |
| 275 | return; |
| 276 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 277 | |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 278 | mService.setIcon("bluetooth", iconId, 0, contentDescription); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 279 | mService.setIconVisibility("bluetooth", mBluetoothEnabled); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 280 | } |
| 281 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 282 | private final void updateTTY(Intent intent) { |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 283 | final String action = intent.getAction(); |
| 284 | final boolean enabled = intent.getBooleanExtra(TtyIntent.TTY_ENABLED, false); |
| 285 | |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 286 | if (false) Slog.v(TAG, "updateTTY: enabled: " + enabled); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 287 | |
| 288 | if (enabled) { |
| 289 | // TTY is on |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 290 | if (false) Slog.v(TAG, "updateTTY: set TTY on"); |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 291 | mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0, |
| 292 | mContext.getString(R.string.accessibility_tty_enabled)); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 293 | mService.setIconVisibility("tty", true); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 294 | } else { |
| 295 | // TTY is off |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 296 | if (false) Slog.v(TAG, "updateTTY: set TTY off"); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 297 | mService.setIconVisibility("tty", false); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 298 | } |
| 299 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 300 | } |