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