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