Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | |
| 17 | package com.android.server.wm; |
| 18 | |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 19 | import static android.view.InsetsState.ITYPE_IME; |
| 20 | import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; |
| 21 | import static android.view.InsetsState.ITYPE_STATUS_BAR; |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 22 | import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; |
| 23 | import static android.view.ViewRootImpl.sNewInsetsMode; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 24 | |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 25 | import android.annotation.NonNull; |
| 26 | import android.annotation.Nullable; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 27 | import android.util.ArrayMap; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 28 | import android.util.ArraySet; |
| 29 | import android.util.SparseArray; |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 30 | import android.view.InsetsSource; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 31 | import android.view.InsetsSourceControl; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 32 | import android.view.InsetsState; |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 33 | import android.view.InsetsState.InternalInsetsType; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 34 | |
| 35 | import java.io.PrintWriter; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 36 | import java.util.ArrayList; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 37 | import java.util.function.Consumer; |
| 38 | |
| 39 | /** |
| 40 | * Manages global window inset state in the system represented by {@link InsetsState}. |
| 41 | */ |
| 42 | class InsetsStateController { |
| 43 | |
| 44 | private final InsetsState mLastState = new InsetsState(); |
| 45 | private final InsetsState mState = new InsetsState(); |
| 46 | private final DisplayContent mDisplayContent; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 47 | |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 48 | private final ArrayMap<Integer, InsetsSourceProvider> mProviders = new ArrayMap<>(); |
| 49 | private final ArrayMap<InsetsControlTarget, ArrayList<Integer>> mControlTargetTypeMap = |
| 50 | new ArrayMap<>(); |
| 51 | private final SparseArray<InsetsControlTarget> mTypeControlTargetMap = new SparseArray<>(); |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 52 | |
| 53 | /** @see #onControlFakeTargetChanged */ |
| 54 | private final SparseArray<InsetsControlTarget> mTypeFakeControlTargetMap = new SparseArray<>(); |
| 55 | |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 56 | private final ArraySet<InsetsControlTarget> mPendingControlChanged = new ArraySet<>(); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 57 | |
| 58 | private final Consumer<WindowState> mDispatchInsetsChanged = w -> { |
| 59 | if (w.isVisible()) { |
| 60 | w.notifyInsetsChanged(); |
| 61 | } |
| 62 | }; |
| 63 | |
| 64 | InsetsStateController(DisplayContent displayContent) { |
| 65 | mDisplayContent = displayContent; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * When dispatching window state to the client, we'll need to exclude the source that represents |
| 70 | * the window that is being dispatched. |
| 71 | * |
| 72 | * @param target The client we dispatch the state to. |
| 73 | * @return The state stripped of the necessary information. |
| 74 | */ |
| 75 | InsetsState getInsetsForDispatch(WindowState target) { |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 76 | final InsetsSourceProvider provider = target.getControllableInsetProvider(); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 77 | if (provider == null) { |
| 78 | return mState; |
| 79 | } |
| 80 | |
| 81 | final InsetsState state = new InsetsState(); |
| 82 | state.set(mState); |
| 83 | final int type = provider.getSource().getType(); |
| 84 | state.removeSource(type); |
| 85 | |
| 86 | // Navigation bar doesn't get influenced by anything else |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 87 | if (type == ITYPE_NAVIGATION_BAR) { |
| 88 | state.removeSource(ITYPE_IME); |
| 89 | state.removeSource(ITYPE_STATUS_BAR); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 90 | } |
| 91 | return state; |
| 92 | } |
| 93 | |
Evan Rosky | 8d782e0 | 2019-10-14 15:43:53 -0700 | [diff] [blame] | 94 | InsetsState getRawInsetsState() { |
| 95 | return mState; |
| 96 | } |
| 97 | |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 98 | @Nullable InsetsSourceControl[] getControlsForDispatch(InsetsControlTarget target) { |
| 99 | ArrayList<Integer> controlled = mControlTargetTypeMap.get(target); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 100 | if (controlled == null) { |
| 101 | return null; |
| 102 | } |
| 103 | final int size = controlled.size(); |
| 104 | final InsetsSourceControl[] result = new InsetsSourceControl[size]; |
| 105 | for (int i = 0; i < size; i++) { |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 106 | result[i] = mProviders.get(controlled.get(i)).getControl(target); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 107 | } |
| 108 | return result; |
| 109 | } |
| 110 | |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 111 | /** |
| 112 | * @return The provider of a specific type. |
| 113 | */ |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 114 | InsetsSourceProvider getSourceProvider(@InternalInsetsType int type) { |
| 115 | if (type == ITYPE_IME) { |
Tarandeep Singh | 500a38f | 2019-09-26 13:36:40 -0700 | [diff] [blame] | 116 | return mProviders.computeIfAbsent(type, |
| 117 | key -> new ImeInsetsSourceProvider( |
| 118 | mState.getSource(key), this, mDisplayContent)); |
| 119 | } else { |
| 120 | return mProviders.computeIfAbsent(type, |
| 121 | key -> new InsetsSourceProvider(mState.getSource(key), this, mDisplayContent)); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | ImeInsetsSourceProvider getImeSourceProvider() { |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 126 | return (ImeInsetsSourceProvider) getSourceProvider(ITYPE_IME); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | /** |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 130 | * @return The provider of a specific type or null if we don't have it. |
| 131 | */ |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 132 | @Nullable InsetsSourceProvider peekSourceProvider(@InternalInsetsType int type) { |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 133 | return mProviders.get(type); |
| 134 | } |
| 135 | |
| 136 | /** |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 137 | * Called when a layout pass has occurred. |
| 138 | */ |
| 139 | void onPostLayout() { |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 140 | mState.setDisplayFrame(mDisplayContent.getBounds()); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 141 | for (int i = mProviders.size() - 1; i >= 0; i--) { |
| 142 | mProviders.valueAt(i).onPostLayout(); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 143 | } |
| 144 | if (!mLastState.equals(mState)) { |
| 145 | mLastState.set(mState, true /* copySources */); |
| 146 | notifyInsetsChanged(); |
| 147 | } |
Tarandeep Singh | 500a38f | 2019-09-26 13:36:40 -0700 | [diff] [blame] | 148 | getImeSourceProvider().onPostInsetsDispatched(); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 149 | } |
| 150 | |
Evan Rosky | 8d782e0 | 2019-10-14 15:43:53 -0700 | [diff] [blame] | 151 | void onInsetsModified(InsetsControlTarget windowState, InsetsState state) { |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 152 | boolean changed = false; |
| 153 | for (int i = state.getSourcesCount() - 1; i >= 0; i--) { |
| 154 | final InsetsSource source = state.sourceAt(i); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 155 | final InsetsSourceProvider provider = mProviders.get(source.getType()); |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 156 | if (provider == null) { |
| 157 | continue; |
| 158 | } |
| 159 | changed |= provider.onInsetsModified(windowState, source); |
| 160 | } |
| 161 | if (changed) { |
| 162 | notifyInsetsChanged(); |
| 163 | } |
| 164 | } |
| 165 | |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 166 | boolean isFakeTarget(@InternalInsetsType int type, InsetsControlTarget target) { |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 167 | return mTypeFakeControlTargetMap.get(type) == target; |
| 168 | } |
| 169 | |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 170 | void onImeTargetChanged(@Nullable InsetsControlTarget imeTarget) { |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 171 | onControlChanged(ITYPE_IME, imeTarget); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 172 | notifyPendingInsetsControlChanged(); |
| 173 | } |
| 174 | |
| 175 | /** |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 176 | * Called when the focused window that is able to control the system bars changes. |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 177 | * |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 178 | * @param topControlling The target that is now able to control the top bar appearance |
| 179 | * and visibility. |
| 180 | * @param navControlling The target that is now able to control the nav bar appearance |
| 181 | * and visibility. |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 182 | */ |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 183 | void onBarControlTargetChanged(@Nullable InsetsControlTarget topControlling, |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 184 | @Nullable InsetsControlTarget fakeTopControlling, |
| 185 | @Nullable InsetsControlTarget navControlling, |
| 186 | @Nullable InsetsControlTarget fakeNavControlling) { |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 187 | onControlChanged(ITYPE_STATUS_BAR, topControlling); |
| 188 | onControlChanged(ITYPE_NAVIGATION_BAR, navControlling); |
| 189 | onControlFakeTargetChanged(ITYPE_STATUS_BAR, fakeTopControlling); |
| 190 | onControlFakeTargetChanged(ITYPE_NAVIGATION_BAR, fakeNavControlling); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 191 | notifyPendingInsetsControlChanged(); |
| 192 | } |
| 193 | |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 194 | void notifyControlRevoked(@NonNull InsetsControlTarget previousControlTarget, |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 195 | InsetsSourceProvider provider) { |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 196 | removeFromControlMaps(previousControlTarget, provider.getSource().getType(), |
| 197 | false /* fake */); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 198 | } |
| 199 | |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 200 | private void onControlChanged(@InternalInsetsType int type, |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 201 | @Nullable InsetsControlTarget target) { |
| 202 | final InsetsControlTarget previous = mTypeControlTargetMap.get(type); |
| 203 | if (target == previous) { |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 204 | return; |
| 205 | } |
Tiger Huang | 969c608 | 2019-12-24 20:08:57 +0800 | [diff] [blame] | 206 | final InsetsSourceProvider provider = mProviders.get(type); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 207 | if (provider == null) { |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 208 | return; |
| 209 | } |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 210 | if (!provider.isControllable()) { |
Jorim Jaggi | a2759b2 | 2019-01-24 13:21:40 +0100 | [diff] [blame] | 211 | return; |
| 212 | } |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 213 | provider.updateControlForTarget(target, false /* force */); |
Tiger Huang | 969c608 | 2019-12-24 20:08:57 +0800 | [diff] [blame] | 214 | target = provider.getControlTarget(); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 215 | if (previous != null) { |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 216 | removeFromControlMaps(previous, type, false /* fake */); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 217 | mPendingControlChanged.add(previous); |
| 218 | } |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 219 | if (target != null) { |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 220 | addToControlMaps(target, type, false /* fake */); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 221 | mPendingControlChanged.add(target); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 222 | } |
| 223 | } |
| 224 | |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 225 | /** |
| 226 | * The fake target saved here will be used to pretend to the app that it's still under control |
| 227 | * of the bars while it's not really, but we still need to find out the apps intentions around |
| 228 | * showing/hiding. For example, when the transient bars are showing, and the fake target |
| 229 | * requests to show system bars, the transient state will be aborted. |
| 230 | */ |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 231 | void onControlFakeTargetChanged(@InternalInsetsType int type, |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 232 | @Nullable InsetsControlTarget fakeTarget) { |
| 233 | if (sNewInsetsMode != NEW_INSETS_MODE_FULL) { |
| 234 | return; |
| 235 | } |
| 236 | final InsetsControlTarget previous = mTypeFakeControlTargetMap.get(type); |
| 237 | if (fakeTarget == previous) { |
| 238 | return; |
| 239 | } |
| 240 | final InsetsSourceProvider provider = mProviders.get(type); |
| 241 | if (provider == null) { |
| 242 | return; |
| 243 | } |
| 244 | provider.updateControlForFakeTarget(fakeTarget); |
| 245 | if (previous != null) { |
| 246 | removeFromControlMaps(previous, type, true /* fake */); |
| 247 | mPendingControlChanged.add(previous); |
| 248 | } |
| 249 | if (fakeTarget != null) { |
| 250 | addToControlMaps(fakeTarget, type, true /* fake */); |
| 251 | mPendingControlChanged.add(fakeTarget); |
| 252 | } |
| 253 | } |
| 254 | |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 255 | private void removeFromControlMaps(@NonNull InsetsControlTarget target, |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 256 | @InternalInsetsType int type, boolean fake) { |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 257 | final ArrayList<Integer> array = mControlTargetTypeMap.get(target); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 258 | if (array == null) { |
| 259 | return; |
| 260 | } |
| 261 | array.remove((Integer) type); |
| 262 | if (array.isEmpty()) { |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 263 | mControlTargetTypeMap.remove(target); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 264 | } |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 265 | if (fake) { |
| 266 | mTypeFakeControlTargetMap.remove(type); |
| 267 | } else { |
| 268 | mTypeControlTargetMap.remove(type); |
| 269 | } |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 270 | } |
| 271 | |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 272 | private void addToControlMaps(@NonNull InsetsControlTarget target, |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 273 | @InternalInsetsType int type, boolean fake) { |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 274 | final ArrayList<Integer> array = mControlTargetTypeMap.computeIfAbsent(target, |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 275 | key -> new ArrayList<>()); |
| 276 | array.add(type); |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 277 | if (fake) { |
| 278 | mTypeFakeControlTargetMap.put(type, target); |
| 279 | } else { |
| 280 | mTypeControlTargetMap.put(type, target); |
| 281 | } |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 282 | } |
| 283 | |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 284 | void notifyControlChanged(InsetsControlTarget target) { |
Tarandeep Singh | 215929b | 2019-01-11 18:24:37 -0800 | [diff] [blame] | 285 | mPendingControlChanged.add(target); |
| 286 | notifyPendingInsetsControlChanged(); |
| 287 | } |
| 288 | |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 289 | private void notifyPendingInsetsControlChanged() { |
Jorim Jaggi | f86eb49 | 2019-01-09 17:37:08 +0100 | [diff] [blame] | 290 | if (mPendingControlChanged.isEmpty()) { |
| 291 | return; |
| 292 | } |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 293 | mDisplayContent.mWmService.mAnimator.addAfterPrepareSurfacesRunnable(() -> { |
| 294 | for (int i = mPendingControlChanged.size() - 1; i >= 0; i--) { |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 295 | final InsetsControlTarget controlTarget = mPendingControlChanged.valueAt(i); |
| 296 | controlTarget.notifyInsetsControlChanged(); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 297 | } |
| 298 | mPendingControlChanged.clear(); |
| 299 | }); |
| 300 | } |
| 301 | |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 302 | void notifyInsetsChanged() { |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 303 | mDisplayContent.forAllWindows(mDispatchInsetsChanged, true /* traverseTopToBottom */); |
Evan Rosky | 8d782e0 | 2019-10-14 15:43:53 -0700 | [diff] [blame] | 304 | if (mDisplayContent.mRemoteInsetsControlTarget != null) { |
| 305 | mDisplayContent.mRemoteInsetsControlTarget.notifyInsetsChanged(); |
| 306 | } |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | void dump(String prefix, PrintWriter pw) { |
| 310 | pw.println(prefix + "WindowInsetsStateController"); |
| 311 | mState.dump(prefix + " ", pw); |
Jorim Jaggi | cfd6f3b | 2018-11-07 15:30:18 +0100 | [diff] [blame] | 312 | pw.println(prefix + " " + "Control map:"); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 313 | for (int i = mTypeControlTargetMap.size() - 1; i >= 0; i--) { |
Jorim Jaggi | cfd6f3b | 2018-11-07 15:30:18 +0100 | [diff] [blame] | 314 | pw.print(prefix + " "); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 315 | pw.println(InsetsState.typeToString(mTypeControlTargetMap.keyAt(i)) + " -> " |
| 316 | + mTypeControlTargetMap.valueAt(i)); |
Jorim Jaggi | cfd6f3b | 2018-11-07 15:30:18 +0100 | [diff] [blame] | 317 | } |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 318 | } |
| 319 | } |