Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | 79de0c5 | 2010-05-26 17:03:26 -0400 | [diff] [blame] | 17 | package com.android.systemui.statusbar; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 18 | |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 19 | import android.os.Bundle; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 20 | import android.os.Handler; |
Joe Onorato | a0c56fe | 2010-05-20 10:21:52 -0700 | [diff] [blame] | 21 | import android.os.IBinder; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 22 | import android.os.Message; |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 23 | import android.util.Pair; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 24 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 25 | import com.android.internal.statusbar.IStatusBar; |
| 26 | import com.android.internal.statusbar.StatusBarIcon; |
| 27 | import com.android.internal.statusbar.StatusBarIconList; |
| 28 | |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 29 | /** |
| 30 | * This class takes the functions from IStatusBar that come in on |
| 31 | * binder pool threads and posts messages to get them onto the main |
| 32 | * thread, and calls onto Callbacks. It also takes care of |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 33 | * coalescing these calls so they don't stack up. For the calls |
| 34 | * are coalesced, note that they are all idempotent. |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 35 | */ |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 36 | public class CommandQueue extends IStatusBar.Stub { |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 37 | private static final int INDEX_MASK = 0xffff; |
| 38 | private static final int MSG_SHIFT = 16; |
| 39 | private static final int MSG_MASK = 0xffff << MSG_SHIFT; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 40 | |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 41 | private static final int OP_SET_ICON = 1; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 42 | private static final int OP_REMOVE_ICON = 2; |
| 43 | |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 44 | private static final int MSG_ICON = 1 << MSG_SHIFT; |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 45 | private static final int MSG_DISABLE = 2 << MSG_SHIFT; |
| 46 | private static final int MSG_EXPAND_NOTIFICATIONS = 3 << MSG_SHIFT; |
| 47 | private static final int MSG_COLLAPSE_PANELS = 4 << MSG_SHIFT; |
| 48 | private static final int MSG_EXPAND_SETTINGS = 5 << MSG_SHIFT; |
| 49 | private static final int MSG_SET_SYSTEMUI_VISIBILITY = 6 << MSG_SHIFT; |
| 50 | private static final int MSG_TOP_APP_WINDOW_CHANGED = 7 << MSG_SHIFT; |
| 51 | private static final int MSG_SHOW_IME_BUTTON = 8 << MSG_SHIFT; |
Michael Wright | 665366a | 2014-08-07 15:44:40 -0700 | [diff] [blame] | 52 | private static final int MSG_TOGGLE_RECENT_APPS = 9 << MSG_SHIFT; |
| 53 | private static final int MSG_PRELOAD_RECENT_APPS = 10 << MSG_SHIFT; |
| 54 | private static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 11 << MSG_SHIFT; |
| 55 | private static final int MSG_SET_WINDOW_STATE = 12 << MSG_SHIFT; |
| 56 | private static final int MSG_SHOW_RECENT_APPS = 13 << MSG_SHIFT; |
| 57 | private static final int MSG_HIDE_RECENT_APPS = 14 << MSG_SHIFT; |
| 58 | private static final int MSG_BUZZ_BEEP_BLINKED = 15 << MSG_SHIFT; |
| 59 | private static final int MSG_NOTIFICATION_LIGHT_OFF = 16 << MSG_SHIFT; |
| 60 | private static final int MSG_NOTIFICATION_LIGHT_PULSE = 17 << MSG_SHIFT; |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 61 | private static final int MSG_SHOW_SCREEN_PIN_REQUEST = 18 << MSG_SHIFT; |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 62 | private static final int MSG_APP_TRANSITION_PENDING = 19 << MSG_SHIFT; |
| 63 | private static final int MSG_APP_TRANSITION_CANCELLED = 20 << MSG_SHIFT; |
| 64 | private static final int MSG_APP_TRANSITION_STARTING = 21 << MSG_SHIFT; |
Adrian Roos | 4f43dc0 | 2015-06-17 16:43:38 -0700 | [diff] [blame] | 65 | private static final int MSG_ASSIST_DISCLOSURE = 22 << MSG_SHIFT; |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 66 | private static final int MSG_START_ASSIST = 23 << MSG_SHIFT; |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame^] | 67 | private static final int MSG_SHOW_KEYBOARD_SHORTCUTS = 24 << MSG_SHIFT; |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 68 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 69 | public static final int FLAG_EXCLUDE_NONE = 0; |
| 70 | public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0; |
| 71 | public static final int FLAG_EXCLUDE_RECENTS_PANEL = 1 << 1; |
| 72 | public static final int FLAG_EXCLUDE_NOTIFICATION_PANEL = 1 << 2; |
| 73 | public static final int FLAG_EXCLUDE_INPUT_METHODS_PANEL = 1 << 3; |
| 74 | public static final int FLAG_EXCLUDE_COMPAT_MODE_PANEL = 1 << 4; |
| 75 | |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 76 | private static final String SHOW_IME_SWITCHER_KEY = "showImeSwitcherKey"; |
| 77 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 78 | private StatusBarIconList mList; |
| 79 | private Callbacks mCallbacks; |
| 80 | private Handler mHandler = new H(); |
| 81 | |
| 82 | /** |
| 83 | * These methods are called back on the main thread. |
| 84 | */ |
| 85 | public interface Callbacks { |
| 86 | public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon); |
| 87 | public void updateIcon(String slot, int index, int viewIndex, |
| 88 | StatusBarIcon old, StatusBarIcon icon); |
| 89 | public void removeIcon(String slot, int index, int viewIndex); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 90 | public void disable(int state1, int state2, boolean animate); |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 91 | public void animateExpandNotificationsPanel(); |
| 92 | public void animateCollapsePanels(int flags); |
| 93 | public void animateExpandSettingsPanel(); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 94 | public void setSystemUiVisibility(int vis, int mask); |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 95 | public void topAppWindowChanged(boolean visible); |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 96 | public void setImeWindowStatus(IBinder token, int vis, int backDisposition, |
| 97 | boolean showImeSwitcher); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 98 | public void showRecentApps(boolean triggeredFromAltTab); |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 99 | public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 100 | public void toggleRecentApps(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 101 | public void preloadRecentApps(); |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame^] | 102 | public void showKeyboardShortcutsMenu(); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 103 | public void cancelPreloadRecentApps(); |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 104 | public void setWindowState(int window, int state); |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 105 | public void buzzBeepBlinked(); |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 106 | public void notificationLightOff(); |
| 107 | public void notificationLightPulse(int argb, int onMillis, int offMillis); |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 108 | public void showScreenPinningRequest(); |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 109 | public void appTransitionPending(); |
| 110 | public void appTransitionCancelled(); |
| 111 | public void appTransitionStarting(long startTime, long duration); |
Adrian Roos | 4f43dc0 | 2015-06-17 16:43:38 -0700 | [diff] [blame] | 112 | public void showAssistDisclosure(); |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 113 | public void startAssist(Bundle args); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | public CommandQueue(Callbacks callbacks, StatusBarIconList list) { |
| 117 | mCallbacks = callbacks; |
| 118 | mList = list; |
| 119 | } |
| 120 | |
| 121 | public void setIcon(int index, StatusBarIcon icon) { |
| 122 | synchronized (mList) { |
| 123 | int what = MSG_ICON | index; |
| 124 | mHandler.removeMessages(what); |
| 125 | mHandler.obtainMessage(what, OP_SET_ICON, 0, icon.clone()).sendToTarget(); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | public void removeIcon(int index) { |
| 130 | synchronized (mList) { |
| 131 | int what = MSG_ICON | index; |
| 132 | mHandler.removeMessages(what); |
| 133 | mHandler.obtainMessage(what, OP_REMOVE_ICON, 0, null).sendToTarget(); |
| 134 | } |
| 135 | } |
| 136 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 137 | public void disable(int state1, int state2) { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 138 | synchronized (mList) { |
| 139 | mHandler.removeMessages(MSG_DISABLE); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 140 | mHandler.obtainMessage(MSG_DISABLE, state1, state2, null).sendToTarget(); |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 144 | public void animateExpandNotificationsPanel() { |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 145 | synchronized (mList) { |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 146 | mHandler.removeMessages(MSG_EXPAND_NOTIFICATIONS); |
| 147 | mHandler.sendEmptyMessage(MSG_EXPAND_NOTIFICATIONS); |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 148 | } |
| 149 | } |
| 150 | |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 151 | public void animateCollapsePanels() { |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 152 | synchronized (mList) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 153 | mHandler.removeMessages(MSG_COLLAPSE_PANELS); |
| 154 | mHandler.sendEmptyMessage(MSG_COLLAPSE_PANELS); |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 155 | } |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 156 | } |
| 157 | |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 158 | public void animateExpandSettingsPanel() { |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 159 | synchronized (mList) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 160 | mHandler.removeMessages(MSG_EXPAND_SETTINGS); |
| 161 | mHandler.sendEmptyMessage(MSG_EXPAND_SETTINGS); |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 165 | public void setSystemUiVisibility(int vis, int mask) { |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 166 | synchronized (mList) { |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 167 | // Don't coalesce these, since it might have one time flags set such as |
| 168 | // STATUS_BAR_UNHIDE which might get lost. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 169 | mHandler.obtainMessage(MSG_SET_SYSTEMUI_VISIBILITY, vis, mask, null).sendToTarget(); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 170 | } |
| 171 | } |
| 172 | |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 173 | public void topAppWindowChanged(boolean menuVisible) { |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 174 | synchronized (mList) { |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 175 | mHandler.removeMessages(MSG_TOP_APP_WINDOW_CHANGED); |
| 176 | mHandler.obtainMessage(MSG_TOP_APP_WINDOW_CHANGED, menuVisible ? 1 : 0, 0, |
| 177 | null).sendToTarget(); |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 178 | } |
| 179 | } |
| 180 | |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 181 | public void setImeWindowStatus(IBinder token, int vis, int backDisposition, |
| 182 | boolean showImeSwitcher) { |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 183 | synchronized (mList) { |
| 184 | mHandler.removeMessages(MSG_SHOW_IME_BUTTON); |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 185 | Message m = mHandler.obtainMessage(MSG_SHOW_IME_BUTTON, vis, backDisposition, token); |
| 186 | m.getData().putBoolean(SHOW_IME_SWITCHER_KEY, showImeSwitcher); |
| 187 | m.sendToTarget(); |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 188 | } |
| 189 | } |
| 190 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 191 | public void showRecentApps(boolean triggeredFromAltTab) { |
| 192 | synchronized (mList) { |
| 193 | mHandler.removeMessages(MSG_SHOW_RECENT_APPS); |
| 194 | mHandler.obtainMessage(MSG_SHOW_RECENT_APPS, |
| 195 | triggeredFromAltTab ? 1 : 0, 0, null).sendToTarget(); |
| 196 | } |
| 197 | } |
| 198 | |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 199 | public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 200 | synchronized (mList) { |
| 201 | mHandler.removeMessages(MSG_HIDE_RECENT_APPS); |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 202 | mHandler.obtainMessage(MSG_HIDE_RECENT_APPS, |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 203 | triggeredFromAltTab ? 1 : 0, triggeredFromHomeKey ? 1 : 0, |
| 204 | null).sendToTarget(); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 208 | public void toggleRecentApps() { |
| 209 | synchronized (mList) { |
| 210 | mHandler.removeMessages(MSG_TOGGLE_RECENT_APPS); |
| 211 | mHandler.obtainMessage(MSG_TOGGLE_RECENT_APPS, 0, 0, null).sendToTarget(); |
| 212 | } |
| 213 | } |
| 214 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 215 | public void preloadRecentApps() { |
| 216 | synchronized (mList) { |
| 217 | mHandler.removeMessages(MSG_PRELOAD_RECENT_APPS); |
| 218 | mHandler.obtainMessage(MSG_PRELOAD_RECENT_APPS, 0, 0, null).sendToTarget(); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | public void cancelPreloadRecentApps() { |
| 223 | synchronized (mList) { |
| 224 | mHandler.removeMessages(MSG_CANCEL_PRELOAD_RECENT_APPS); |
| 225 | mHandler.obtainMessage(MSG_CANCEL_PRELOAD_RECENT_APPS, 0, 0, null).sendToTarget(); |
| 226 | } |
| 227 | } |
| 228 | |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame^] | 229 | @Override |
| 230 | public void showKeyboardShortcutsMenu() { |
| 231 | synchronized (mList) { |
| 232 | mHandler.removeMessages(MSG_SHOW_KEYBOARD_SHORTCUTS); |
| 233 | mHandler.obtainMessage(MSG_SHOW_KEYBOARD_SHORTCUTS).sendToTarget(); |
| 234 | } |
| 235 | } |
| 236 | |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 237 | public void setWindowState(int window, int state) { |
| 238 | synchronized (mList) { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 239 | // don't coalesce these |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 240 | mHandler.obtainMessage(MSG_SET_WINDOW_STATE, window, state, null).sendToTarget(); |
| 241 | } |
| 242 | } |
| 243 | |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 244 | public void buzzBeepBlinked() { |
| 245 | synchronized (mList) { |
| 246 | mHandler.removeMessages(MSG_BUZZ_BEEP_BLINKED); |
| 247 | mHandler.sendEmptyMessage(MSG_BUZZ_BEEP_BLINKED); |
| 248 | } |
| 249 | } |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 250 | |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 251 | public void notificationLightOff() { |
| 252 | synchronized (mList) { |
| 253 | mHandler.sendEmptyMessage(MSG_NOTIFICATION_LIGHT_OFF); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | public void notificationLightPulse(int argb, int onMillis, int offMillis) { |
| 258 | synchronized (mList) { |
| 259 | mHandler.obtainMessage(MSG_NOTIFICATION_LIGHT_PULSE, onMillis, offMillis, argb) |
| 260 | .sendToTarget(); |
| 261 | } |
| 262 | } |
| 263 | |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 264 | public void showScreenPinningRequest() { |
| 265 | synchronized (mList) { |
| 266 | mHandler.sendEmptyMessage(MSG_SHOW_SCREEN_PIN_REQUEST); |
| 267 | } |
| 268 | } |
| 269 | |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 270 | public void appTransitionPending() { |
| 271 | synchronized (mList) { |
| 272 | mHandler.removeMessages(MSG_APP_TRANSITION_PENDING); |
| 273 | mHandler.sendEmptyMessage(MSG_APP_TRANSITION_PENDING); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | public void appTransitionCancelled() { |
| 278 | synchronized (mList) { |
| 279 | mHandler.removeMessages(MSG_APP_TRANSITION_PENDING); |
| 280 | mHandler.sendEmptyMessage(MSG_APP_TRANSITION_PENDING); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | public void appTransitionStarting(long startTime, long duration) { |
| 285 | synchronized (mList) { |
| 286 | mHandler.removeMessages(MSG_APP_TRANSITION_STARTING); |
| 287 | mHandler.obtainMessage(MSG_APP_TRANSITION_STARTING, Pair.create(startTime, duration)) |
| 288 | .sendToTarget(); |
| 289 | } |
| 290 | } |
| 291 | |
Adrian Roos | 4f43dc0 | 2015-06-17 16:43:38 -0700 | [diff] [blame] | 292 | public void showAssistDisclosure() { |
| 293 | synchronized (mList) { |
| 294 | mHandler.removeMessages(MSG_ASSIST_DISCLOSURE); |
| 295 | mHandler.obtainMessage(MSG_ASSIST_DISCLOSURE).sendToTarget(); |
| 296 | } |
| 297 | } |
| 298 | |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 299 | public void startAssist(Bundle args) { |
| 300 | synchronized (mList) { |
| 301 | mHandler.removeMessages(MSG_START_ASSIST); |
| 302 | mHandler.obtainMessage(MSG_START_ASSIST, args).sendToTarget(); |
| 303 | } |
| 304 | } |
| 305 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 306 | private final class H extends Handler { |
| 307 | public void handleMessage(Message msg) { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 308 | final int what = msg.what & MSG_MASK; |
Joe Onorato | 66d7d01 | 2010-05-14 10:05:10 -0700 | [diff] [blame] | 309 | switch (what) { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 310 | case MSG_ICON: { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 311 | final int index = msg.what & INDEX_MASK; |
| 312 | final int viewIndex = mList.getViewIndex(index); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 313 | switch (msg.arg1) { |
| 314 | case OP_SET_ICON: { |
| 315 | StatusBarIcon icon = (StatusBarIcon)msg.obj; |
| 316 | StatusBarIcon old = mList.getIcon(index); |
| 317 | if (old == null) { |
| 318 | mList.setIcon(index, icon); |
| 319 | mCallbacks.addIcon(mList.getSlot(index), index, viewIndex, icon); |
| 320 | } else { |
| 321 | mList.setIcon(index, icon); |
| 322 | mCallbacks.updateIcon(mList.getSlot(index), index, viewIndex, |
| 323 | old, icon); |
| 324 | } |
| 325 | break; |
| 326 | } |
| 327 | case OP_REMOVE_ICON: |
Joe Onorato | 795f284 | 2010-09-27 11:34:46 -0700 | [diff] [blame] | 328 | if (mList.getIcon(index) != null) { |
| 329 | mList.removeIcon(index); |
| 330 | mCallbacks.removeIcon(mList.getSlot(index), index, viewIndex); |
| 331 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 332 | break; |
| 333 | } |
| 334 | break; |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 335 | } |
| 336 | case MSG_DISABLE: |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 337 | mCallbacks.disable(msg.arg1, msg.arg2, true /* animate */); |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 338 | break; |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 339 | case MSG_EXPAND_NOTIFICATIONS: |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 340 | mCallbacks.animateExpandNotificationsPanel(); |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 341 | break; |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 342 | case MSG_COLLAPSE_PANELS: |
| 343 | mCallbacks.animateCollapsePanels(0); |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 344 | break; |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 345 | case MSG_EXPAND_SETTINGS: |
| 346 | mCallbacks.animateExpandSettingsPanel(); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 347 | break; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 348 | case MSG_SET_SYSTEMUI_VISIBILITY: |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 349 | mCallbacks.setSystemUiVisibility(msg.arg1, msg.arg2); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 350 | break; |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 351 | case MSG_TOP_APP_WINDOW_CHANGED: |
| 352 | mCallbacks.topAppWindowChanged(msg.arg1 != 0); |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 353 | break; |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 354 | case MSG_SHOW_IME_BUTTON: |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 355 | mCallbacks.setImeWindowStatus((IBinder) msg.obj, msg.arg1, msg.arg2, |
| 356 | msg.getData().getBoolean(SHOW_IME_SWITCHER_KEY, false)); |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 357 | break; |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 358 | case MSG_SHOW_RECENT_APPS: |
| 359 | mCallbacks.showRecentApps(msg.arg1 != 0); |
| 360 | break; |
| 361 | case MSG_HIDE_RECENT_APPS: |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 362 | mCallbacks.hideRecentApps(msg.arg1 != 0, msg.arg2 != 0); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 363 | break; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 364 | case MSG_TOGGLE_RECENT_APPS: |
| 365 | mCallbacks.toggleRecentApps(); |
| 366 | break; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 367 | case MSG_PRELOAD_RECENT_APPS: |
| 368 | mCallbacks.preloadRecentApps(); |
| 369 | break; |
| 370 | case MSG_CANCEL_PRELOAD_RECENT_APPS: |
| 371 | mCallbacks.cancelPreloadRecentApps(); |
| 372 | break; |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame^] | 373 | case MSG_SHOW_KEYBOARD_SHORTCUTS: |
| 374 | mCallbacks.showKeyboardShortcutsMenu(); |
| 375 | break; |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 376 | case MSG_SET_WINDOW_STATE: |
| 377 | mCallbacks.setWindowState(msg.arg1, msg.arg2); |
| 378 | break; |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 379 | case MSG_BUZZ_BEEP_BLINKED: |
| 380 | mCallbacks.buzzBeepBlinked(); |
| 381 | break; |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 382 | case MSG_NOTIFICATION_LIGHT_OFF: |
| 383 | mCallbacks.notificationLightOff(); |
| 384 | break; |
| 385 | case MSG_NOTIFICATION_LIGHT_PULSE: |
| 386 | mCallbacks.notificationLightPulse((Integer) msg.obj, msg.arg1, msg.arg2); |
| 387 | break; |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 388 | case MSG_SHOW_SCREEN_PIN_REQUEST: |
| 389 | mCallbacks.showScreenPinningRequest(); |
| 390 | break; |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 391 | case MSG_APP_TRANSITION_PENDING: |
| 392 | mCallbacks.appTransitionPending(); |
| 393 | break; |
| 394 | case MSG_APP_TRANSITION_CANCELLED: |
| 395 | mCallbacks.appTransitionCancelled(); |
| 396 | break; |
| 397 | case MSG_APP_TRANSITION_STARTING: |
| 398 | Pair<Long, Long> data = (Pair<Long, Long>) msg.obj; |
| 399 | mCallbacks.appTransitionStarting(data.first, data.second); |
| 400 | break; |
Adrian Roos | 4f43dc0 | 2015-06-17 16:43:38 -0700 | [diff] [blame] | 401 | case MSG_ASSIST_DISCLOSURE: |
| 402 | mCallbacks.showAssistDisclosure(); |
| 403 | break; |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 404 | case MSG_START_ASSIST: |
| 405 | mCallbacks.startAssist((Bundle) msg.obj); |
| 406 | break; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 407 | } |
| 408 | } |
| 409 | } |
| 410 | } |
| 411 | |