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