Dianne Hackborn | f56e102 | 2011-02-22 10:47:13 -0800 | [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. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 15 | */ |
Dianne Hackborn | f56e102 | 2011-02-22 10:47:13 -0800 | [diff] [blame] | 16 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 17 | package com.android.server.wm; |
| 18 | |
Jorim Jaggi | 4981f15 | 2019-03-26 18:58:45 +0100 | [diff] [blame] | 19 | import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 20 | import static android.view.WindowManager.INPUT_CONSUMER_NAVIGATION; |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 21 | import static android.view.WindowManager.INPUT_CONSUMER_PIP; |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 22 | import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION; |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 23 | import static android.view.WindowManager.INPUT_CONSUMER_WALLPAPER; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 24 | import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 25 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS; |
| 26 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 27 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
Winson Chung | 6463c36 | 2017-09-25 16:23:26 -0700 | [diff] [blame] | 28 | |
Adrian Roos | b125e0b | 2019-10-02 14:55:14 +0200 | [diff] [blame] | 29 | import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 30 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_INPUT; |
| 31 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_POSITIONING; |
| 32 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Filip Gruszczynski | 9cac3b4 | 2015-10-30 14:20:37 -0700 | [diff] [blame] | 33 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 34 | import android.graphics.Rect; |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 35 | import android.os.Handler; |
Winson Chung | 6463c36 | 2017-09-25 16:23:26 -0700 | [diff] [blame] | 36 | import android.os.IBinder; |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 37 | import android.os.Looper; |
Winson Chung | 6463c36 | 2017-09-25 16:23:26 -0700 | [diff] [blame] | 38 | import android.os.Process; |
Jorim Jaggi | 6064051 | 2018-06-29 01:14:31 +0200 | [diff] [blame] | 39 | import android.os.Trace; |
Winson Chung | 6463c36 | 2017-09-25 16:23:26 -0700 | [diff] [blame] | 40 | import android.os.UserHandle; |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 41 | import android.util.ArrayMap; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 42 | import android.util.Log; |
| 43 | import android.util.Slog; |
wilsonshih | c32538e | 2018-11-07 17:27:34 +0800 | [diff] [blame] | 44 | import android.view.InputApplicationHandle; |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 45 | import android.view.InputChannel; |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 46 | import android.view.InputEventReceiver; |
Robert Carr | 788f574 | 2018-07-30 17:46:45 -0700 | [diff] [blame] | 47 | import android.view.InputWindowHandle; |
Robert Carr | 679ccb0 | 2018-08-08 15:32:35 -0700 | [diff] [blame] | 48 | import android.view.SurfaceControl; |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 49 | |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 50 | import com.android.server.policy.WindowManagerPolicy; |
Adrian Roos | b125e0b | 2019-10-02 14:55:14 +0200 | [diff] [blame] | 51 | import com.android.server.protolog.common.ProtoLog; |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 52 | |
Wale Ogunwale | e89eeac | 2016-03-12 11:07:58 -0800 | [diff] [blame] | 53 | import java.io.PrintWriter; |
Winson Chung | 853c99a | 2017-03-21 22:16:42 -0700 | [diff] [blame] | 54 | import java.util.Set; |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 55 | import java.util.function.Consumer; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 56 | |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 57 | final class InputMonitor { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 58 | private final WindowManagerService mService; |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 59 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 60 | // Current window with input focus for keys and other non-touch events. May be null. |
| 61 | private WindowState mInputFocus; |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 62 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 63 | // When true, need to call updateInputWindowsLw(). |
| 64 | private boolean mUpdateInputWindowsNeeded = true; |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 65 | private boolean mUpdateInputWindowsPending; |
chaviw | 86dc82e | 2019-04-01 16:53:30 -0700 | [diff] [blame] | 66 | private boolean mApplyImmediately; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 67 | |
Robert Carr | b600bc2 | 2018-08-21 15:05:16 -0700 | [diff] [blame] | 68 | // Currently focused input window handle. |
| 69 | private InputWindowHandle mFocusedInputWindowHandle; |
Vladislav Kaznacheev | 3787de1 | 2016-12-21 10:36:35 -0800 | [diff] [blame] | 70 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 71 | private boolean mDisableWallpaperTouchEvents; |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 72 | private final Rect mTmpRect = new Rect(); |
Arthur Hung | 678024f | 2019-01-16 20:58:51 +0800 | [diff] [blame] | 73 | private final UpdateInputForAllWindowsConsumer mUpdateInputForAllWindowsConsumer; |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 74 | |
Vishnu Nair | 9e7dbc8 | 2018-12-20 08:45:28 -0800 | [diff] [blame] | 75 | private final int mDisplayId; |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 76 | private final DisplayContent mDisplayContent; |
| 77 | private boolean mDisplayRemoved; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 78 | |
Vishnu Nair | 9e7dbc8 | 2018-12-20 08:45:28 -0800 | [diff] [blame] | 79 | private final SurfaceControl.Transaction mInputTransaction; |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 80 | private final Handler mHandler; |
Robert Carr | 679ccb0 | 2018-08-08 15:32:35 -0700 | [diff] [blame] | 81 | |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 82 | /** |
| 83 | * The set of input consumer added to the window manager by name, which consumes input events |
| 84 | * for the windows below it. |
| 85 | */ |
| 86 | private final ArrayMap<String, InputConsumerImpl> mInputConsumers = new ArrayMap(); |
| 87 | |
| 88 | private static final class EventReceiverInputConsumer extends InputConsumerImpl |
| 89 | implements WindowManagerPolicy.InputConsumer { |
| 90 | private InputMonitor mInputMonitor; |
| 91 | private final InputEventReceiver mInputEventReceiver; |
| 92 | |
| 93 | EventReceiverInputConsumer(WindowManagerService service, InputMonitor monitor, |
| 94 | Looper looper, String name, |
Winson Chung | 6463c36 | 2017-09-25 16:23:26 -0700 | [diff] [blame] | 95 | InputEventReceiver.Factory inputEventReceiverFactory, |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 96 | int clientPid, UserHandle clientUser, int displayId) { |
| 97 | super(service, null /* token */, name, null /* inputChannel */, clientPid, clientUser, |
| 98 | displayId); |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 99 | mInputMonitor = monitor; |
| 100 | mInputEventReceiver = inputEventReceiverFactory.createInputEventReceiver( |
| 101 | mClientChannel, looper); |
| 102 | } |
| 103 | |
| 104 | @Override |
| 105 | public void dismiss() { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 106 | synchronized (mService.mGlobalLock) { |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 107 | if (mInputMonitor.destroyInputConsumer(mWindowHandle.name)) { |
| 108 | mInputEventReceiver.dispose(); |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
Riddle Hsu | 2ca561b | 2019-10-08 21:58:58 +0800 | [diff] [blame] | 114 | private class UpdateInputWindows implements Runnable { |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 115 | @Override |
| 116 | public void run() { |
| 117 | synchronized (mService.mGlobalLock) { |
| 118 | mUpdateInputWindowsPending = false; |
| 119 | mUpdateInputWindowsNeeded = false; |
| 120 | |
| 121 | if (mDisplayRemoved) { |
| 122 | return; |
| 123 | } |
| 124 | |
| 125 | // Populate the input window list with information about all of the windows that |
| 126 | // could potentially receive input. |
| 127 | // As an optimization, we could try to prune the list of windows but this turns |
| 128 | // out to be difficult because only the native code knows for sure which window |
| 129 | // currently has touch focus. |
| 130 | |
| 131 | // If there's a drag in flight, provide a pseudo-window to catch drag input |
| 132 | final boolean inDrag = mService.mDragDropController.dragDropActiveLocked(); |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 133 | final boolean inPositioning = |
| 134 | mService.mTaskPositioningController.isPositioningLocked(); |
| 135 | if (inPositioning) { |
| 136 | if (DEBUG_TASK_POSITIONING) { |
| 137 | Log.d(TAG_WM, "Inserting window handle for repositioning"); |
| 138 | } |
| 139 | mService.mTaskPositioningController.showInputSurface(mInputTransaction, |
| 140 | mDisplayId); |
| 141 | } else { |
| 142 | mService.mTaskPositioningController.hideInputSurface(mInputTransaction, |
| 143 | mDisplayId); |
| 144 | } |
| 145 | |
| 146 | // Add all windows on the default display. |
| 147 | mUpdateInputForAllWindowsConsumer.updateInputWindows(inDrag); |
| 148 | } |
| 149 | } |
Riddle Hsu | 2ca561b | 2019-10-08 21:58:58 +0800 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | private final UpdateInputWindows mUpdateInputWindows = new UpdateInputWindows(); |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 153 | |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 154 | public InputMonitor(WindowManagerService service, int displayId) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 155 | mService = service; |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 156 | mDisplayContent = mService.mRoot.getDisplayContent(displayId); |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 157 | mDisplayId = displayId; |
Vishnu Nair | 3319739 | 2019-08-30 10:29:37 -0700 | [diff] [blame] | 158 | mInputTransaction = mService.mTransactionFactory.get(); |
Riddle Hsu | e459c63 | 2020-01-03 22:37:47 +0800 | [diff] [blame] | 159 | mHandler = mService.mAnimationHandler; |
Arthur Hung | 678024f | 2019-01-16 20:58:51 +0800 | [diff] [blame] | 160 | mUpdateInputForAllWindowsConsumer = new UpdateInputForAllWindowsConsumer(); |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | void onDisplayRemoved() { |
| 164 | mHandler.removeCallbacks(mUpdateInputWindows); |
Riddle Hsu | 3f2de74 | 2019-02-25 15:21:38 +0800 | [diff] [blame] | 165 | mService.mInputManager.onDisplayRemoved(mDisplayId); |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 166 | mDisplayRemoved = true; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 167 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 168 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 169 | private void addInputConsumer(String name, InputConsumerImpl consumer) { |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 170 | mInputConsumers.put(name, consumer); |
Winson Chung | 6463c36 | 2017-09-25 16:23:26 -0700 | [diff] [blame] | 171 | consumer.linkToDeathRecipient(); |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 172 | updateInputWindowsLw(true /* force */); |
| 173 | } |
| 174 | |
| 175 | boolean destroyInputConsumer(String name) { |
| 176 | if (disposeInputConsumer(mInputConsumers.remove(name))) { |
| 177 | updateInputWindowsLw(true /* force */); |
| 178 | return true; |
| 179 | } |
| 180 | return false; |
| 181 | } |
| 182 | |
| 183 | private boolean disposeInputConsumer(InputConsumerImpl consumer) { |
| 184 | if (consumer != null) { |
| 185 | consumer.disposeChannelsLw(); |
Robert Carr | a80ad04 | 2018-08-14 12:54:20 -0700 | [diff] [blame] | 186 | consumer.hide(mInputTransaction); |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 187 | return true; |
| 188 | } |
| 189 | return false; |
| 190 | } |
| 191 | |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 192 | InputConsumerImpl getInputConsumer(String name) { |
| 193 | return mInputConsumers.get(name); |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | void layoutInputConsumers(int dw, int dh) { |
Jorim Jaggi | 4981f15 | 2019-03-26 18:58:45 +0100 | [diff] [blame] | 197 | try { |
| 198 | Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "layoutInputConsumer"); |
| 199 | for (int i = mInputConsumers.size() - 1; i >= 0; i--) { |
| 200 | mInputConsumers.valueAt(i).layout(mInputTransaction, dw, dh); |
| 201 | } |
| 202 | } finally { |
| 203 | Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); |
Robert Carr | a80ad04 | 2018-08-14 12:54:20 -0700 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
| 207 | // The visibility of the input consumers is recomputed each time we |
| 208 | // update the input windows. We use a model where consumers begin invisible |
| 209 | // (set so by this function) and must meet some condition for visibility on each update. |
| 210 | void resetInputConsumers(SurfaceControl.Transaction t) { |
| 211 | for (int i = mInputConsumers.size() - 1; i >= 0; i--) { |
| 212 | mInputConsumers.valueAt(i).hide(t); |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 213 | } |
| 214 | } |
| 215 | |
| 216 | WindowManagerPolicy.InputConsumer createInputConsumer(Looper looper, String name, |
| 217 | InputEventReceiver.Factory inputEventReceiverFactory) { |
| 218 | if (mInputConsumers.containsKey(name)) { |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 219 | throw new IllegalStateException("Existing input consumer found with name: " + name |
| 220 | + ", display: " + mDisplayId); |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 221 | } |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 222 | final EventReceiverInputConsumer consumer = new EventReceiverInputConsumer(mService, |
Winson Chung | 6463c36 | 2017-09-25 16:23:26 -0700 | [diff] [blame] | 223 | this, looper, name, inputEventReceiverFactory, Process.myPid(), |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 224 | UserHandle.SYSTEM, mDisplayId); |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 225 | addInputConsumer(name, consumer); |
| 226 | return consumer; |
| 227 | } |
| 228 | |
Winson Chung | 6463c36 | 2017-09-25 16:23:26 -0700 | [diff] [blame] | 229 | void createInputConsumer(IBinder token, String name, InputChannel inputChannel, int clientPid, |
| 230 | UserHandle clientUser) { |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 231 | if (mInputConsumers.containsKey(name)) { |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 232 | throw new IllegalStateException("Existing input consumer found with name: " + name |
| 233 | + ", display: " + mDisplayId); |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 234 | } |
| 235 | |
Winson Chung | 6463c36 | 2017-09-25 16:23:26 -0700 | [diff] [blame] | 236 | final InputConsumerImpl consumer = new InputConsumerImpl(mService, token, name, |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 237 | inputChannel, clientPid, clientUser, mDisplayId); |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 238 | switch (name) { |
| 239 | case INPUT_CONSUMER_WALLPAPER: |
| 240 | consumer.mWindowHandle.hasWallpaper = true; |
| 241 | break; |
| 242 | case INPUT_CONSUMER_PIP: |
| 243 | // The touchable region of the Pip input window is cropped to the bounds of the |
| 244 | // stack, and we need FLAG_NOT_TOUCH_MODAL to ensure other events fall through |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 245 | consumer.mWindowHandle.layoutParamsFlags |= FLAG_NOT_TOUCH_MODAL; |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 246 | break; |
| 247 | } |
| 248 | addInputConsumer(name, consumer); |
| 249 | } |
| 250 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 251 | |
Robert Carr | b600bc2 | 2018-08-21 15:05:16 -0700 | [diff] [blame] | 252 | void populateInputWindowHandle(final InputWindowHandle inputWindowHandle, |
Craig Mautner | c08eab8 | 2014-11-11 09:03:59 -0800 | [diff] [blame] | 253 | final WindowState child, int flags, final int type, final boolean isVisible, |
Wale Ogunwale | 053c8e4 | 2015-11-16 14:27:21 -0800 | [diff] [blame] | 254 | final boolean hasFocus, final boolean hasWallpaper) { |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 255 | // Add a window to our list of input windows. |
| 256 | inputWindowHandle.name = child.toString(); |
Vishnu Nair | 93d68c2 | 2019-03-22 13:45:31 -0700 | [diff] [blame] | 257 | flags = child.getSurfaceTouchableRegion(inputWindowHandle, flags); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 258 | inputWindowHandle.layoutParamsFlags = flags; |
| 259 | inputWindowHandle.layoutParamsType = type; |
| 260 | inputWindowHandle.dispatchingTimeoutNanos = child.getInputDispatchingTimeoutNanos(); |
| 261 | inputWindowHandle.visible = isVisible; |
| 262 | inputWindowHandle.canReceiveKeys = child.canReceiveKeys(); |
| 263 | inputWindowHandle.hasFocus = hasFocus; |
| 264 | inputWindowHandle.hasWallpaper = hasWallpaper; |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 265 | inputWindowHandle.paused = child.mActivityRecord != null ? child.mActivityRecord.paused : false; |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 266 | inputWindowHandle.ownerPid = child.mSession.mPid; |
| 267 | inputWindowHandle.ownerUid = child.mSession.mUid; |
| 268 | inputWindowHandle.inputFeatures = child.mAttrs.inputFeatures; |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 269 | inputWindowHandle.displayId = child.getDisplayId(); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 270 | |
chaviw | 492139a | 2018-07-16 16:07:35 -0700 | [diff] [blame] | 271 | final Rect frame = child.getFrameLw(); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 272 | inputWindowHandle.frameLeft = frame.left; |
| 273 | inputWindowHandle.frameTop = frame.top; |
| 274 | inputWindowHandle.frameRight = frame.right; |
| 275 | inputWindowHandle.frameBottom = frame.bottom; |
| 276 | |
Robert Carr | fcc0852 | 2018-11-14 14:02:52 -0800 | [diff] [blame] | 277 | // Surface insets are hardcoded to be the same in all directions |
| 278 | // and we could probably deprecate the "left/right/top/bottom" concept. |
| 279 | // we avoid reintroducing this concept by just choosing one of them here. |
| 280 | inputWindowHandle.surfaceInset = child.getAttrs().surfaceInsets.left; |
| 281 | |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 282 | if (child.mGlobalScale != 1) { |
| 283 | // If we are scaling the window, input coordinates need |
| 284 | // to be inversely scaled to map from what is on screen |
| 285 | // to what is actually being touched in the UI. |
| 286 | inputWindowHandle.scaleFactor = 1.0f/child.mGlobalScale; |
| 287 | } else { |
| 288 | inputWindowHandle.scaleFactor = 1; |
| 289 | } |
| 290 | |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 291 | if (DEBUG_INPUT) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 292 | Slog.d(TAG_WM, "addInputWindowHandle: " |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 293 | + child + ", " + inputWindowHandle); |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 294 | } |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 295 | |
Robert Carr | b600bc2 | 2018-08-21 15:05:16 -0700 | [diff] [blame] | 296 | if (hasFocus) { |
| 297 | mFocusedInputWindowHandle = inputWindowHandle; |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 298 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 299 | } |
| 300 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 301 | void setUpdateInputWindowsNeededLw() { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 302 | mUpdateInputWindowsNeeded = true; |
| 303 | } |
| 304 | |
| 305 | /* Updates the cached window information provided to the input dispatcher. */ |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 306 | void updateInputWindowsLw(boolean force) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 307 | if (!force && !mUpdateInputWindowsNeeded) { |
| 308 | return; |
| 309 | } |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 310 | scheduleUpdateInputWindows(); |
| 311 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 312 | |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 313 | private void scheduleUpdateInputWindows() { |
| 314 | if (mDisplayRemoved) { |
| 315 | return; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 316 | } |
| 317 | |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 318 | if (!mUpdateInputWindowsPending) { |
| 319 | mUpdateInputWindowsPending = true; |
| 320 | mHandler.post(mUpdateInputWindows); |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 321 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 322 | } |
| 323 | |
chaviw | 86dc82e | 2019-04-01 16:53:30 -0700 | [diff] [blame] | 324 | void updateInputWindowsImmediately() { |
wilsonshih | 6164e01 | 2019-05-06 09:31:02 +0800 | [diff] [blame] | 325 | mHandler.removeCallbacks(mUpdateInputWindows); |
| 326 | mApplyImmediately = true; |
| 327 | mUpdateInputWindows.run(); |
| 328 | mApplyImmediately = false; |
chaviw | 86dc82e | 2019-04-01 16:53:30 -0700 | [diff] [blame] | 329 | } |
| 330 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 331 | /* Called when the current input focus changes. |
| 332 | * Layer assignment is assumed to be complete by the time this is called. |
| 333 | */ |
| 334 | public void setInputFocusLw(WindowState newWindow, boolean updateInputWindows) { |
Adrian Roos | b125e0b | 2019-10-02 14:55:14 +0200 | [diff] [blame] | 335 | ProtoLog.d(WM_DEBUG_FOCUS_LIGHT, "Input focus has changed to %s", newWindow); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 336 | |
| 337 | if (newWindow != mInputFocus) { |
| 338 | if (newWindow != null && newWindow.canReceiveKeys()) { |
| 339 | // Displaying a window implicitly causes dispatching to be unpaused. |
| 340 | // This is to protect against bugs if someone pauses dispatching but |
| 341 | // forgets to resume. |
| 342 | newWindow.mToken.paused = false; |
| 343 | } |
| 344 | |
| 345 | mInputFocus = newWindow; |
| 346 | setUpdateInputWindowsNeededLw(); |
| 347 | |
| 348 | if (updateInputWindows) { |
| 349 | updateInputWindowsLw(false /*force*/); |
| 350 | } |
| 351 | } |
| 352 | } |
Craig Mautner | 5845812 | 2013-09-14 14:59:50 -0700 | [diff] [blame] | 353 | |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 354 | public void setFocusedAppLw(ActivityRecord newApp) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 355 | // Focused app has changed. |
| 356 | if (newApp == null) { |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 357 | mService.mInputManager.setFocusedApplication(mDisplayId, null); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 358 | } else { |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 359 | final InputApplicationHandle handle = newApp.mInputApplicationHandle; |
| 360 | handle.name = newApp.toString(); |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 361 | handle.dispatchingTimeoutNanos = newApp.mInputDispatchingTimeoutNanos; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 362 | |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 363 | mService.mInputManager.setFocusedApplication(mDisplayId, handle); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 364 | } |
| 365 | } |
Craig Mautner | 5845812 | 2013-09-14 14:59:50 -0700 | [diff] [blame] | 366 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 367 | public void pauseDispatchingLw(WindowToken window) { |
| 368 | if (! window.paused) { |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 369 | if (DEBUG_INPUT) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 370 | Slog.v(TAG_WM, "Pausing WindowToken " + window); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 371 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 372 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 373 | window.paused = true; |
| 374 | updateInputWindowsLw(true /*force*/); |
| 375 | } |
| 376 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 377 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 378 | public void resumeDispatchingLw(WindowToken window) { |
| 379 | if (window.paused) { |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 380 | if (DEBUG_INPUT) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 381 | Slog.v(TAG_WM, "Resuming WindowToken " + window); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 382 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 383 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 384 | window.paused = false; |
| 385 | updateInputWindowsLw(true /*force*/); |
| 386 | } |
| 387 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 388 | |
Wale Ogunwale | e89eeac | 2016-03-12 11:07:58 -0800 | [diff] [blame] | 389 | void dump(PrintWriter pw, String prefix) { |
Winson Chung | 853c99a | 2017-03-21 22:16:42 -0700 | [diff] [blame] | 390 | final Set<String> inputConsumerKeys = mInputConsumers.keySet(); |
| 391 | if (!inputConsumerKeys.isEmpty()) { |
| 392 | pw.println(prefix + "InputConsumers:"); |
| 393 | for (String key : inputConsumerKeys) { |
Winson Chung | 6463c36 | 2017-09-25 16:23:26 -0700 | [diff] [blame] | 394 | mInputConsumers.get(key).dump(pw, key, prefix); |
Winson Chung | 853c99a | 2017-03-21 22:16:42 -0700 | [diff] [blame] | 395 | } |
| 396 | } |
Wale Ogunwale | e89eeac | 2016-03-12 11:07:58 -0800 | [diff] [blame] | 397 | } |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 398 | |
| 399 | private final class UpdateInputForAllWindowsConsumer implements Consumer<WindowState> { |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 400 | InputConsumerImpl navInputConsumer; |
| 401 | InputConsumerImpl pipInputConsumer; |
| 402 | InputConsumerImpl wallpaperInputConsumer; |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 403 | InputConsumerImpl recentsAnimationInputConsumer; |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 404 | |
| 405 | private boolean mAddInputConsumerHandle; |
| 406 | private boolean mAddPipInputConsumerHandle; |
| 407 | private boolean mAddWallpaperInputConsumerHandle; |
| 408 | private boolean mAddRecentsAnimationInputConsumerHandle; |
| 409 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 410 | boolean inDrag; |
| 411 | WallpaperController wallpaperController; |
| 412 | |
Arthur Hung | 678024f | 2019-01-16 20:58:51 +0800 | [diff] [blame] | 413 | // An invalid window handle that tells SurfaceFlinger not update the input info. |
Vishnu Nair | 1878216 | 2019-10-08 14:57:16 -0700 | [diff] [blame] | 414 | final InputWindowHandle mInvalidInputWindow = new InputWindowHandle(null, mDisplayId); |
Arthur Hung | 678024f | 2019-01-16 20:58:51 +0800 | [diff] [blame] | 415 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 416 | private void updateInputWindows(boolean inDrag) { |
Jorim Jaggi | 4981f15 | 2019-03-26 18:58:45 +0100 | [diff] [blame] | 417 | Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "updateInputWindows"); |
Jorim Jaggi | 6064051 | 2018-06-29 01:14:31 +0200 | [diff] [blame] | 418 | |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 419 | navInputConsumer = getInputConsumer(INPUT_CONSUMER_NAVIGATION); |
| 420 | pipInputConsumer = getInputConsumer(INPUT_CONSUMER_PIP); |
| 421 | wallpaperInputConsumer = getInputConsumer(INPUT_CONSUMER_WALLPAPER); |
| 422 | recentsAnimationInputConsumer = getInputConsumer(INPUT_CONSUMER_RECENTS_ANIMATION); |
| 423 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 424 | mAddInputConsumerHandle = navInputConsumer != null; |
| 425 | mAddPipInputConsumerHandle = pipInputConsumer != null; |
| 426 | mAddWallpaperInputConsumerHandle = wallpaperInputConsumer != null; |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 427 | mAddRecentsAnimationInputConsumerHandle = recentsAnimationInputConsumer != null; |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 428 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 429 | mTmpRect.setEmpty(); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 430 | mDisableWallpaperTouchEvents = false; |
| 431 | this.inDrag = inDrag; |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 432 | wallpaperController = mDisplayContent.mWallpaperController; |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 433 | |
Robert Carr | a80ad04 | 2018-08-14 12:54:20 -0700 | [diff] [blame] | 434 | resetInputConsumers(mInputTransaction); |
| 435 | |
Jorim Jaggi | ae962e6 | 2018-12-27 17:23:48 +0100 | [diff] [blame] | 436 | mDisplayContent.forAllWindows(this, |
Robert Carr | a80ad04 | 2018-08-14 12:54:20 -0700 | [diff] [blame] | 437 | true /* traverseTopToBottom */); |
| 438 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 439 | if (mAddWallpaperInputConsumerHandle) { |
Robert Carr | b600bc2 | 2018-08-21 15:05:16 -0700 | [diff] [blame] | 440 | wallpaperInputConsumer.show(mInputTransaction, 0); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 441 | } |
| 442 | |
chaviw | 86dc82e | 2019-04-01 16:53:30 -0700 | [diff] [blame] | 443 | if (mApplyImmediately) { |
| 444 | mInputTransaction.apply(); |
| 445 | } else { |
| 446 | mDisplayContent.getPendingTransaction().merge(mInputTransaction); |
| 447 | mDisplayContent.scheduleAnimation(); |
| 448 | } |
Vladislav Kaznacheev | 2e96c63 | 2016-12-13 14:31:24 -0800 | [diff] [blame] | 449 | |
Jorim Jaggi | 4981f15 | 2019-03-26 18:58:45 +0100 | [diff] [blame] | 450 | Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | @Override |
| 454 | public void accept(WindowState w) { |
| 455 | final InputChannel inputChannel = w.mInputChannel; |
| 456 | final InputWindowHandle inputWindowHandle = w.mInputWindowHandle; |
| 457 | if (inputChannel == null || inputWindowHandle == null || w.mRemoved |
Robert Carr | ebdf858 | 2018-09-04 14:50:15 -0700 | [diff] [blame] | 458 | || w.cantReceiveTouchInput()) { |
Arthur Hung | 678024f | 2019-01-16 20:58:51 +0800 | [diff] [blame] | 459 | if (w.mWinAnimator.hasSurface()) { |
| 460 | mInputTransaction.setInputWindowInfo( |
| 461 | w.mWinAnimator.mSurfaceController.mSurfaceControl, mInvalidInputWindow); |
| 462 | } |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 463 | // Skip this window because it cannot possibly receive input. |
| 464 | return; |
| 465 | } |
| 466 | |
Winson Chung | 61ecc1b | 2017-02-17 10:46:17 -0800 | [diff] [blame] | 467 | final int flags = w.mAttrs.flags; |
| 468 | final int privateFlags = w.mAttrs.privateFlags; |
| 469 | final int type = w.mAttrs.type; |
Arthur Hung | 39134b2 | 2018-08-14 11:58:28 +0800 | [diff] [blame] | 470 | final boolean hasFocus = w.isFocused(); |
Winson Chung | 61ecc1b | 2017-02-17 10:46:17 -0800 | [diff] [blame] | 471 | final boolean isVisible = w.isVisibleLw(); |
| 472 | |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 473 | if (mAddRecentsAnimationInputConsumerHandle) { |
| 474 | final RecentsAnimationController recentsAnimationController = |
| 475 | mService.getRecentsAnimationController(); |
| 476 | if (recentsAnimationController != null |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 477 | && recentsAnimationController.shouldApplyInputConsumer(w.mActivityRecord)) { |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 478 | if (recentsAnimationController.updateInputConsumerForApp( |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 479 | recentsAnimationInputConsumer.mWindowHandle, hasFocus)) { |
Robert Carr | a80ad04 | 2018-08-14 12:54:20 -0700 | [diff] [blame] | 480 | recentsAnimationInputConsumer.show(mInputTransaction, w); |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 481 | mAddRecentsAnimationInputConsumerHandle = false; |
| 482 | } |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 483 | } |
| 484 | } |
| 485 | |
Wale Ogunwale | 44f036f | 2017-09-29 05:09:09 -0700 | [diff] [blame] | 486 | if (w.inPinnedWindowingMode()) { |
Robert Carr | a80ad04 | 2018-08-14 12:54:20 -0700 | [diff] [blame] | 487 | if (mAddPipInputConsumerHandle) { |
Bryce Lee | f3c6a47 | 2017-11-14 14:53:06 -0800 | [diff] [blame] | 488 | // Update the bounds of the Pip input consumer to match the window bounds. |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 489 | w.getBounds(mTmpRect); |
Robert Carr | a80ad04 | 2018-08-14 12:54:20 -0700 | [diff] [blame] | 490 | pipInputConsumer.layout(mInputTransaction, mTmpRect); |
Robert Carr | 47ea21d | 2018-11-28 13:42:45 -0800 | [diff] [blame] | 491 | |
| 492 | // The touchable region is relative to the surface top-left |
| 493 | mTmpRect.offsetTo(0, 0); |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 494 | pipInputConsumer.mWindowHandle.touchableRegion.set(mTmpRect); |
Robert Carr | a80ad04 | 2018-08-14 12:54:20 -0700 | [diff] [blame] | 495 | pipInputConsumer.show(mInputTransaction, w); |
Winson Chung | 61ecc1b | 2017-02-17 10:46:17 -0800 | [diff] [blame] | 496 | mAddPipInputConsumerHandle = false; |
| 497 | } |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 498 | } |
| 499 | |
chaviw | 7a67d07 | 2019-12-30 14:04:08 -0800 | [diff] [blame] | 500 | if (mAddInputConsumerHandle) { |
Robert Carr | a80ad04 | 2018-08-14 12:54:20 -0700 | [diff] [blame] | 501 | navInputConsumer.show(mInputTransaction, w); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 502 | mAddInputConsumerHandle = false; |
| 503 | } |
| 504 | |
| 505 | if (mAddWallpaperInputConsumerHandle) { |
| 506 | if (w.mAttrs.type == TYPE_WALLPAPER && w.isVisibleLw()) { |
| 507 | // Add the wallpaper input consumer above the first visible wallpaper. |
Robert Carr | a80ad04 | 2018-08-14 12:54:20 -0700 | [diff] [blame] | 508 | wallpaperInputConsumer.show(mInputTransaction, w); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 509 | mAddWallpaperInputConsumerHandle = false; |
| 510 | } |
| 511 | } |
| 512 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 513 | if ((privateFlags & PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS) != 0) { |
| 514 | mDisableWallpaperTouchEvents = true; |
| 515 | } |
| 516 | final boolean hasWallpaper = wallpaperController.isWallpaperTarget(w) |
| 517 | && (privateFlags & PRIVATE_FLAG_KEYGUARD) == 0 |
| 518 | && !mDisableWallpaperTouchEvents; |
| 519 | |
| 520 | // If there's a drag in progress and 'child' is a potential drop target, |
| 521 | // make sure it's been told about the drag |
| 522 | if (inDrag && isVisible && w.getDisplayContent().isDefaultDisplay) { |
Daichi Hirono | 768012e | 2017-10-30 10:05:37 +0900 | [diff] [blame] | 523 | mService.mDragDropController.sendDragStartedIfNeededLocked(w); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 524 | } |
| 525 | |
Robert Carr | b600bc2 | 2018-08-21 15:05:16 -0700 | [diff] [blame] | 526 | populateInputWindowHandle( |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 527 | inputWindowHandle, w, flags, type, isVisible, hasFocus, hasWallpaper); |
Robert Carr | 679ccb0 | 2018-08-08 15:32:35 -0700 | [diff] [blame] | 528 | |
Vishnu Nair | 539334a | 2019-09-20 10:46:21 -0700 | [diff] [blame] | 529 | // register key interception info |
| 530 | mService.mKeyInterceptionInfoForToken.put(inputWindowHandle.token, |
| 531 | w.getKeyInterceptionInfo()); |
| 532 | |
Robert Carr | 679ccb0 | 2018-08-08 15:32:35 -0700 | [diff] [blame] | 533 | if (w.mWinAnimator.hasSurface()) { |
| 534 | mInputTransaction.setInputWindowInfo( |
| 535 | w.mWinAnimator.mSurfaceController.mSurfaceControl, inputWindowHandle); |
| 536 | } |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 537 | } |
| 538 | } |
Jeff Brown | ea42655 | 2011-07-18 16:53:48 -0700 | [diff] [blame] | 539 | } |