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; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.media.AudioManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.os.Handler; |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 27 | import android.provider.Settings.Global; |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 28 | import android.util.Log; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 30 | import com.android.internal.telephony.IccCardConstants; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 31 | import com.android.internal.telephony.TelephonyIntents; |
| 32 | import com.android.internal.telephony.cdma.TtyIntent; |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 33 | import com.android.systemui.R; |
| 34 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | /** |
| 36 | * 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] | 37 | * bar at boot time. It goes through the normal API for icons, even though it probably |
| 38 | * strictly doesn't need to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | */ |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 40 | public class PhoneStatusBarPolicy { |
| 41 | private static final String TAG = "PhoneStatusBarPolicy"; |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 42 | private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 43 | |
Daniel Sandler | b1e8dab | 2011-09-26 20:06:19 -0400 | [diff] [blame] | 44 | private static final boolean SHOW_SYNC_ICON = false; |
| 45 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 46 | private static final String SLOT_SYNC_ACTIVE = "sync_active"; |
| 47 | private static final String SLOT_BLUETOOTH = "bluetooth"; |
| 48 | private static final String SLOT_TTY = "tty"; |
| 49 | private static final String SLOT_ZEN = "zen"; |
| 50 | private static final String SLOT_VOLUME = "volume"; |
| 51 | private static final String SLOT_CDMA_ERI = "cdma_eri"; |
| 52 | private static final String SLOT_ALARM_CLOCK = "alarm_clock"; |
| 53 | |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 54 | private final Context mContext; |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 55 | private final StatusBarManager mService; |
Joe Onorato | 10523b4d | 2010-10-25 10:42:46 -0700 | [diff] [blame] | 56 | private final Handler mHandler = new Handler(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | // Assume it's all good unless we hear otherwise. We don't always seem |
| 59 | // to get broadcasts that it *is* there. |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 60 | IccCardConstants.State mSimState = IccCardConstants.State.READY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 62 | private boolean mZenVisible; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | private boolean mVolumeVisible; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 64 | |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 65 | private int mZen; |
John Spurlock | ba2c6a0 | 2014-05-19 09:44:06 -0400 | [diff] [blame] | 66 | |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 67 | private boolean mBluetoothEnabled = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 69 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { |
| 71 | @Override |
| 72 | public void onReceive(Context context, Intent intent) { |
| 73 | String action = intent.getAction(); |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 74 | if (action.equals(Intent.ACTION_ALARM_CHANGED)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | updateAlarm(intent); |
| 76 | } |
| 77 | else if (action.equals(Intent.ACTION_SYNC_STATE_CHANGED)) { |
| 78 | updateSyncState(intent); |
| 79 | } |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 80 | else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) || |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 81 | action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | updateBluetooth(intent); |
| 83 | } |
Eric Laurent | bffc3d1 | 2012-05-07 17:43:49 -0700 | [diff] [blame] | 84 | else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 85 | updateVolumeZen(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | } |
| 87 | else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { |
| 88 | updateSimState(intent); |
| 89 | } |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 90 | else if (action.equals(TtyIntent.TTY_ENABLED_CHANGE_ACTION)) { |
| 91 | updateTTY(intent); |
| 92 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | } |
| 94 | }; |
| 95 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 96 | public PhoneStatusBarPolicy(Context context) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 97 | mContext = context; |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 98 | mService = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 100 | // listen for broadcasts |
| 101 | IntentFilter filter = new IntentFilter(); |
| 102 | filter.addAction(Intent.ACTION_ALARM_CHANGED); |
| 103 | filter.addAction(Intent.ACTION_SYNC_STATE_CHANGED); |
| 104 | filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 105 | filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); |
| 106 | filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); |
| 107 | filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); |
| 108 | filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION); |
| 109 | mContext.registerReceiver(mIntentReceiver, filter, null, mHandler); |
| 110 | |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 111 | // TTY status |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 112 | mService.setIcon(SLOT_TTY, R.drawable.stat_sys_tty_mode, 0, null); |
| 113 | mService.setIconVisibility(SLOT_TTY, false); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 114 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 115 | // Cdma Roaming Indicator, ERI |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 116 | mService.setIcon(SLOT_CDMA_ERI, R.drawable.stat_sys_roaming_cdma_0, 0, null); |
| 117 | mService.setIconVisibility(SLOT_CDMA_ERI, false); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 118 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | // bluetooth status |
Nick Pelly | f242b7b | 2009-10-08 00:12:45 +0200 | [diff] [blame] | 120 | BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 121 | int bluetoothIcon = R.drawable.stat_sys_data_bluetooth; |
Nick Pelly | bd022f4 | 2009-08-14 18:33:38 -0700 | [diff] [blame] | 122 | if (adapter != null) { |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 123 | mBluetoothEnabled = (adapter.getState() == BluetoothAdapter.STATE_ON); |
| 124 | if (adapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED) { |
| 125 | bluetoothIcon = R.drawable.stat_sys_data_bluetooth_connected; |
| 126 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 127 | } |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 128 | mService.setIcon(SLOT_BLUETOOTH, bluetoothIcon, 0, null); |
| 129 | mService.setIconVisibility(SLOT_BLUETOOTH, mBluetoothEnabled); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 130 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 131 | // Alarm clock |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 132 | mService.setIcon(SLOT_ALARM_CLOCK, R.drawable.stat_sys_alarm, 0, null); |
| 133 | mService.setIconVisibility(SLOT_ALARM_CLOCK, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 134 | |
| 135 | // Sync state |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 136 | mService.setIcon(SLOT_SYNC_ACTIVE, R.drawable.stat_sys_sync, 0, null); |
| 137 | mService.setIconVisibility(SLOT_SYNC_ACTIVE, false); |
John Spurlock | 3c87566 | 2013-08-31 15:07:25 -0400 | [diff] [blame] | 138 | // "sync_failing" is obsolete: b/1297963 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 139 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 140 | // zen |
| 141 | mService.setIcon(SLOT_ZEN, R.drawable.stat_sys_zen_important, 0, null); |
| 142 | mService.setIconVisibility(SLOT_ZEN, false); |
| 143 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 144 | // volume |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 145 | mService.setIcon(SLOT_VOLUME, R.drawable.stat_sys_ringer_silent, 0, null); |
| 146 | mService.setIconVisibility(SLOT_VOLUME, false); |
| 147 | updateVolumeZen(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 148 | } |
| 149 | |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 150 | public void setZenMode(int zen) { |
John Spurlock | ba2c6a0 | 2014-05-19 09:44:06 -0400 | [diff] [blame] | 151 | mZen = zen; |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 152 | updateVolumeZen(); |
John Spurlock | ba2c6a0 | 2014-05-19 09:44:06 -0400 | [diff] [blame] | 153 | } |
| 154 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 155 | private final void updateAlarm(Intent intent) { |
| 156 | boolean alarmSet = intent.getBooleanExtra("alarmSet", false); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 157 | mService.setIconVisibility(SLOT_ALARM_CLOCK, alarmSet); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | private final void updateSyncState(Intent intent) { |
Daniel Sandler | b1e8dab | 2011-09-26 20:06:19 -0400 | [diff] [blame] | 161 | if (!SHOW_SYNC_ICON) return; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 162 | boolean isActive = intent.getBooleanExtra("active", false); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 163 | mService.setIconVisibility(SLOT_SYNC_ACTIVE, isActive); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 164 | } |
| 165 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 166 | private final void updateSimState(Intent intent) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 167 | String stateExtra = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE); |
| 168 | if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) { |
| 169 | mSimState = IccCardConstants.State.ABSENT; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 170 | } |
Rakesh Pallerla | f099a5f | 2013-02-06 11:44:23 +0530 | [diff] [blame] | 171 | else if (IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR.equals(stateExtra)) { |
| 172 | mSimState = IccCardConstants.State.CARD_IO_ERROR; |
| 173 | } |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 174 | else if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(stateExtra)) { |
| 175 | mSimState = IccCardConstants.State.READY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | } |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 177 | else if (IccCardConstants.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) { |
| 178 | final String lockedReason = |
| 179 | intent.getStringExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON); |
| 180 | if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) { |
| 181 | mSimState = IccCardConstants.State.PIN_REQUIRED; |
johnwang | 347c5a2 | 2009-08-24 22:11:11 -0700 | [diff] [blame] | 182 | } |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 183 | else if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) { |
| 184 | mSimState = IccCardConstants.State.PUK_REQUIRED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 185 | } |
| 186 | else { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 187 | mSimState = IccCardConstants.State.NETWORK_LOCKED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 188 | } |
| 189 | } else { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 190 | mSimState = IccCardConstants.State.UNKNOWN; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 191 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 192 | } |
| 193 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 194 | private final void updateVolumeZen() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 195 | AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 196 | |
| 197 | boolean zenVisible = false; |
| 198 | int zenIconId = 0; |
| 199 | String zenDescription = null; |
| 200 | |
| 201 | boolean volumeVisible = false; |
| 202 | int volumeIconId = 0; |
| 203 | String volumeDescription = null; |
| 204 | |
| 205 | if (mZen == Global.ZEN_MODE_NO_INTERRUPTIONS) { |
| 206 | zenVisible = true; |
| 207 | zenIconId = R.drawable.stat_sys_zen_none; |
| 208 | zenDescription = mContext.getString(R.string.zen_no_interruptions); |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 209 | } else if (mZen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 210 | zenVisible = true; |
| 211 | zenIconId = R.drawable.stat_sys_zen_important; |
| 212 | zenDescription = mContext.getString(R.string.zen_important_interruptions); |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 213 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 214 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 215 | if (mZen != Global.ZEN_MODE_NO_INTERRUPTIONS && |
| 216 | audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) { |
| 217 | volumeVisible = true; |
| 218 | volumeIconId = R.drawable.stat_sys_ringer_vibrate; |
| 219 | volumeDescription = mContext.getString(R.string.accessibility_ringer_vibrate); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 220 | } |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 221 | |
| 222 | if (zenVisible) { |
| 223 | mService.setIcon(SLOT_ZEN, zenIconId, 0, zenDescription); |
| 224 | } |
| 225 | if (zenVisible != mZenVisible) { |
| 226 | mService.setIconVisibility(SLOT_ZEN, zenVisible); |
| 227 | mZenVisible = zenVisible; |
| 228 | } |
| 229 | |
| 230 | if (volumeVisible) { |
| 231 | mService.setIcon(SLOT_VOLUME, volumeIconId, 0, volumeDescription); |
| 232 | } |
| 233 | if (volumeVisible != mVolumeVisible) { |
| 234 | mService.setIconVisibility(SLOT_VOLUME, volumeVisible); |
| 235 | mVolumeVisible = volumeVisible; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | } |
| 237 | } |
| 238 | |
| 239 | private final void updateBluetooth(Intent intent) { |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 240 | int iconId = R.drawable.stat_sys_data_bluetooth; |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 241 | String contentDescription = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 242 | String action = intent.getAction(); |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 243 | if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { |
Nick Pelly | b24e11b | 2009-09-08 17:40:43 -0700 | [diff] [blame] | 244 | int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR); |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 245 | mBluetoothEnabled = state == BluetoothAdapter.STATE_ON; |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 246 | } else if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) { |
Jaikumar Ganesh | 0b63a6a | 2011-07-11 14:34:34 -0700 | [diff] [blame] | 247 | int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 248 | BluetoothAdapter.STATE_DISCONNECTED); |
| 249 | if (state == BluetoothAdapter.STATE_CONNECTED) { |
| 250 | iconId = R.drawable.stat_sys_data_bluetooth_connected; |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 251 | contentDescription = mContext.getString(R.string.accessibility_bluetooth_connected); |
| 252 | } else { |
| 253 | contentDescription = mContext.getString( |
| 254 | R.string.accessibility_bluetooth_disconnected); |
Jaikumar Ganesh | 084c665 | 2009-12-07 10:58:18 -0800 | [diff] [blame] | 255 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 256 | } else { |
| 257 | return; |
| 258 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 259 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 260 | mService.setIcon(SLOT_BLUETOOTH, iconId, 0, contentDescription); |
| 261 | mService.setIconVisibility(SLOT_BLUETOOTH, mBluetoothEnabled); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 262 | } |
| 263 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 264 | private final void updateTTY(Intent intent) { |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 265 | final boolean enabled = intent.getBooleanExtra(TtyIntent.TTY_ENABLED, false); |
| 266 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 267 | if (DEBUG) Log.v(TAG, "updateTTY: enabled: " + enabled); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 268 | |
| 269 | if (enabled) { |
| 270 | // TTY is on |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 271 | if (DEBUG) Log.v(TAG, "updateTTY: set TTY on"); |
| 272 | mService.setIcon(SLOT_TTY, R.drawable.stat_sys_tty_mode, 0, |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 273 | mContext.getString(R.string.accessibility_tty_enabled)); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 274 | mService.setIconVisibility(SLOT_TTY, true); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 275 | } else { |
| 276 | // TTY is off |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame^] | 277 | if (DEBUG) Log.v(TAG, "updateTTY: set TTY off"); |
| 278 | mService.setIconVisibility(SLOT_TTY, false); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 279 | } |
| 280 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 281 | } |