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 | a2759b2 | 2019-01-24 13:21:40 +0100 | [diff] [blame] | 22 | import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; |
| 23 | import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME; |
Jorim Jaggi | 73f3e8a | 2019-01-14 13:06:23 +0100 | [diff] [blame] | 24 | import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE; |
Jorim Jaggi | a2759b2 | 2019-01-24 13:21:40 +0100 | [diff] [blame] | 25 | import static android.view.ViewRootImpl.sNewInsetsMode; |
Jorim Jaggi | 73f3e8a | 2019-01-14 13:06:23 +0100 | [diff] [blame] | 26 | |
Tiger Huang | 3f38f26 | 2019-12-18 21:08:40 +0800 | [diff] [blame] | 27 | import static com.android.server.wm.WindowManagerService.H.LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED; |
| 28 | |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 29 | import android.annotation.NonNull; |
| 30 | import android.annotation.Nullable; |
Tarandeep Singh | 215929b | 2019-01-11 18:24:37 -0800 | [diff] [blame] | 31 | import android.graphics.Point; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 32 | import android.graphics.Rect; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 33 | import android.util.proto.ProtoOutputStream; |
chaviw | 15ad49f | 2019-04-24 15:05:39 -0700 | [diff] [blame] | 34 | import android.view.InsetsSource; |
| 35 | import android.view.InsetsSourceControl; |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 36 | import android.view.InsetsState; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 37 | import android.view.SurfaceControl; |
| 38 | import android.view.SurfaceControl.Transaction; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 39 | |
| 40 | import com.android.internal.util.function.TriConsumer; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 41 | import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback; |
| 42 | |
| 43 | import java.io.PrintWriter; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | * Controller for a specific inset source on the server. It's called provider as it provides the |
| 47 | * {@link InsetsSource} to the client that uses it in {@link InsetsSourceConsumer}. |
| 48 | */ |
| 49 | class InsetsSourceProvider { |
| 50 | |
Tarandeep Singh | 500a38f | 2019-09-26 13:36:40 -0700 | [diff] [blame] | 51 | protected final DisplayContent mDisplayContent; |
| 52 | protected final @NonNull InsetsSource mSource; |
| 53 | protected WindowState mWin; |
| 54 | |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 55 | private final Rect mTmpRect = new Rect(); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 56 | private final InsetsStateController mStateController; |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 57 | private final InsetsSourceControl mFakeControl; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 58 | private @Nullable InsetsSourceControl mControl; |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 59 | private @Nullable InsetsControlTarget mControlTarget; |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 60 | private @Nullable InsetsControlTarget mFakeControlTarget; |
| 61 | |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 62 | private @Nullable ControlAdapter mAdapter; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 63 | private TriConsumer<DisplayFrames, WindowState, Rect> mFrameProvider; |
| 64 | |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 65 | /** The visibility override from the current controlling window. */ |
| 66 | private boolean mClientVisible; |
| 67 | |
| 68 | /** |
| 69 | * Whether the window is available and considered visible as in {@link WindowState#isVisible}. |
| 70 | */ |
| 71 | private boolean mServerVisible; |
| 72 | |
Tiger Huang | 969c608 | 2019-12-24 20:08:57 +0800 | [diff] [blame] | 73 | private boolean mSeamlessRotating; |
| 74 | private long mFinishSeamlessRotateFrameNumber = -1; |
| 75 | |
Jorim Jaggi | a2759b2 | 2019-01-24 13:21:40 +0100 | [diff] [blame] | 76 | private final boolean mControllable; |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 77 | |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 78 | InsetsSourceProvider(InsetsSource source, InsetsStateController stateController, |
| 79 | DisplayContent displayContent) { |
Jorim Jaggi | d89efeb | 2019-01-22 17:48:34 +0100 | [diff] [blame] | 80 | mClientVisible = InsetsState.getDefaultVisibility(source.getType()); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 81 | mSource = source; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 82 | mDisplayContent = displayContent; |
| 83 | mStateController = stateController; |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 84 | mFakeControl = new InsetsSourceControl(source.getType(), null /* leash */, |
| 85 | new Point()); |
Jorim Jaggi | a2759b2 | 2019-01-24 13:21:40 +0100 | [diff] [blame] | 86 | |
| 87 | final int type = source.getType(); |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 88 | if (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR) { |
Jorim Jaggi | a2759b2 | 2019-01-24 13:21:40 +0100 | [diff] [blame] | 89 | mControllable = sNewInsetsMode == NEW_INSETS_MODE_FULL; |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 90 | } else if (type == ITYPE_IME) { |
Jorim Jaggi | a2759b2 | 2019-01-24 13:21:40 +0100 | [diff] [blame] | 91 | mControllable = sNewInsetsMode >= NEW_INSETS_MODE_IME; |
| 92 | } else { |
| 93 | mControllable = false; |
| 94 | } |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | InsetsSource getSource() { |
| 98 | return mSource; |
| 99 | } |
| 100 | |
| 101 | /** |
Jorim Jaggi | a2759b2 | 2019-01-24 13:21:40 +0100 | [diff] [blame] | 102 | * @return Whether the current flag configuration allows to control this source. |
| 103 | */ |
| 104 | boolean isControllable() { |
| 105 | return mControllable; |
| 106 | } |
| 107 | |
| 108 | /** |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 109 | * Updates the window that currently backs this source. |
| 110 | * |
| 111 | * @param win The window that links to this source. |
| 112 | * @param frameProvider Based on display frame state and the window, calculates the resulting |
| 113 | * frame that should be reported to clients. |
| 114 | */ |
| 115 | void setWindow(@Nullable WindowState win, |
| 116 | @Nullable TriConsumer<DisplayFrames, WindowState, Rect> frameProvider) { |
| 117 | if (mWin != null) { |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 118 | if (mControllable) { |
| 119 | mWin.setControllableInsetProvider(null); |
| 120 | } |
Tarandeep Singh | 5d54e72 | 2019-08-15 13:33:12 -0700 | [diff] [blame] | 121 | // The window may be animating such that we can hand out the leash to the control |
| 122 | // target. Revoke the leash by cancelling the animation to correct the state. |
| 123 | // TODO: Ideally, we should wait for the animation to finish so previous window can |
| 124 | // animate-out as new one animates-in. |
| 125 | mWin.cancelAnimation(); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 126 | } |
| 127 | mWin = win; |
| 128 | mFrameProvider = frameProvider; |
| 129 | if (win == null) { |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 130 | setServerVisible(false); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 131 | mSource.setFrame(new Rect()); |
Jorim Jaggi | 4e04eb2 | 2020-01-09 16:42:14 +0100 | [diff] [blame] | 132 | mSource.setVisibleFrame(null); |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 133 | } else if (mControllable) { |
| 134 | mWin.setControllableInsetProvider(this); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 135 | if (mControlTarget != null) { |
| 136 | updateControlForTarget(mControlTarget, true /* force */); |
Jorim Jaggi | a2759b2 | 2019-01-24 13:21:40 +0100 | [diff] [blame] | 137 | } |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 138 | } |
| 139 | } |
| 140 | |
| 141 | /** |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 142 | * @return Whether there is a window which backs this source. |
| 143 | */ |
| 144 | boolean hasWindow() { |
| 145 | return mWin != null; |
| 146 | } |
| 147 | |
| 148 | /** |
Tiger Huang | 4a7835f | 2019-11-06 00:07:56 +0800 | [diff] [blame] | 149 | * The source frame can affect the layout of other windows, so this should be called once the |
| 150 | * window gets laid out. |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 151 | */ |
Tiger Huang | 4a7835f | 2019-11-06 00:07:56 +0800 | [diff] [blame] | 152 | void updateSourceFrame() { |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 153 | if (mWin == null) { |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | mTmpRect.set(mWin.getFrameLw()); |
| 158 | if (mFrameProvider != null) { |
| 159 | mFrameProvider.accept(mWin.getDisplayContent().mDisplayFrames, mWin, mTmpRect); |
| 160 | } else { |
| 161 | mTmpRect.inset(mWin.mGivenContentInsets); |
| 162 | } |
| 163 | mSource.setFrame(mTmpRect); |
Jorim Jaggi | 4e04eb2 | 2020-01-09 16:42:14 +0100 | [diff] [blame] | 164 | |
| 165 | if (mWin.mGivenVisibleInsets.left != 0 || mWin.mGivenVisibleInsets.top != 0 |
| 166 | || mWin.mGivenVisibleInsets.right != 0 || mWin.mGivenVisibleInsets.bottom != 0) { |
| 167 | mTmpRect.set(mWin.getFrameLw()); |
| 168 | mTmpRect.inset(mWin.mGivenVisibleInsets); |
| 169 | mSource.setVisibleFrame(mTmpRect); |
| 170 | } else { |
| 171 | mSource.setVisibleFrame(null); |
| 172 | } |
Tiger Huang | 4a7835f | 2019-11-06 00:07:56 +0800 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | /** |
| 176 | * Called when a layout pass has occurred. |
| 177 | */ |
| 178 | void onPostLayout() { |
| 179 | if (mWin == null) { |
| 180 | return; |
| 181 | } |
| 182 | |
| 183 | updateSourceFrame(); |
Tarandeep Singh | 215929b | 2019-01-11 18:24:37 -0800 | [diff] [blame] | 184 | if (mControl != null) { |
| 185 | final Rect frame = mWin.getWindowFrames().mFrame; |
Tiger Huang | 969c608 | 2019-12-24 20:08:57 +0800 | [diff] [blame] | 186 | if (mControl.setSurfacePosition(frame.left, frame.top) && mControlTarget != null) { |
| 187 | // The leash has been stale, we need to create a new one for the client. |
| 188 | updateControlForTarget(mControlTarget, true /* force */); |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 189 | mStateController.notifyControlChanged(mControlTarget); |
Tarandeep Singh | 215929b | 2019-01-11 18:24:37 -0800 | [diff] [blame] | 190 | } |
| 191 | } |
chaviw | 15ad49f | 2019-04-24 15:05:39 -0700 | [diff] [blame] | 192 | setServerVisible(mWin.wouldBeVisibleIfPolicyIgnored() && mWin.isVisibleByPolicy() |
Jorim Jaggi | cfd6f3b | 2018-11-07 15:30:18 +0100 | [diff] [blame] | 193 | && !mWin.mGivenInsetsPending); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 194 | } |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 195 | |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 196 | /** |
| 197 | * @see InsetsStateController#onControlFakeTargetChanged(int, InsetsControlTarget) |
| 198 | */ |
| 199 | void updateControlForFakeTarget(@Nullable InsetsControlTarget fakeTarget) { |
| 200 | if (fakeTarget == mFakeControlTarget) { |
| 201 | return; |
| 202 | } |
| 203 | mFakeControlTarget = fakeTarget; |
| 204 | } |
| 205 | |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 206 | void updateControlForTarget(@Nullable InsetsControlTarget target, boolean force) { |
Tiger Huang | 969c608 | 2019-12-24 20:08:57 +0800 | [diff] [blame] | 207 | if (mSeamlessRotating) { |
| 208 | // We are un-rotating the window against the display rotation. We don't want the target |
| 209 | // to control the window for now. |
| 210 | return; |
| 211 | } |
Jorim Jaggi | a2759b2 | 2019-01-24 13:21:40 +0100 | [diff] [blame] | 212 | if (mWin == null) { |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 213 | mControlTarget = target; |
Jorim Jaggi | a2759b2 | 2019-01-24 13:21:40 +0100 | [diff] [blame] | 214 | return; |
| 215 | } |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 216 | if (target == mControlTarget && !force) { |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 217 | return; |
| 218 | } |
| 219 | if (target == null) { |
Jorim Jaggi | cfd6f3b | 2018-11-07 15:30:18 +0100 | [diff] [blame] | 220 | // Cancelling the animation will invoke onAnimationCancelled, resetting all the fields. |
| 221 | mWin.cancelAnimation(); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 222 | return; |
| 223 | } |
| 224 | mAdapter = new ControlAdapter(); |
Jorim Jaggi | d89efeb | 2019-01-22 17:48:34 +0100 | [diff] [blame] | 225 | setClientVisible(InsetsState.getDefaultVisibility(mSource.getType())); |
Tiger Huang | 969c608 | 2019-12-24 20:08:57 +0800 | [diff] [blame] | 226 | final Transaction t = mDisplayContent.getPendingTransaction(); |
| 227 | mWin.startAnimation(t, mAdapter, !mClientVisible /* hidden */); |
| 228 | final SurfaceControl leash = mAdapter.mCapturedLeash; |
| 229 | final long frameNumber = mFinishSeamlessRotateFrameNumber; |
| 230 | mFinishSeamlessRotateFrameNumber = -1; |
| 231 | if (frameNumber >= 0 && mWin.mHasSurface && leash != null) { |
| 232 | // We just finished the seamless rotation. We don't want to change the position or the |
| 233 | // window crop of the surface controls (including the leash) until the client finishes |
| 234 | // drawing the new frame of the new orientation. Although we cannot defer the reparent |
| 235 | // operation, it is fine, because reparent won't cause any visual effect. |
Robert Carr | 2e20bcd | 2020-01-22 13:32:38 -0800 | [diff] [blame] | 236 | final SurfaceControl barrier = mWin.getDeferTransactionBarrier(); |
Tiger Huang | 969c608 | 2019-12-24 20:08:57 +0800 | [diff] [blame] | 237 | t.deferTransactionUntil(mWin.getSurfaceControl(), barrier, frameNumber); |
| 238 | t.deferTransactionUntil(leash, barrier, frameNumber); |
| 239 | } |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 240 | mControlTarget = target; |
Tiger Huang | 969c608 | 2019-12-24 20:08:57 +0800 | [diff] [blame] | 241 | mControl = new InsetsSourceControl(mSource.getType(), leash, |
Tarandeep Singh | 215929b | 2019-01-11 18:24:37 -0800 | [diff] [blame] | 242 | new Point(mWin.getWindowFrames().mFrame.left, mWin.getWindowFrames().mFrame.top)); |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 243 | } |
| 244 | |
Tiger Huang | 969c608 | 2019-12-24 20:08:57 +0800 | [diff] [blame] | 245 | void startSeamlessRotation() { |
| 246 | if (!mSeamlessRotating) { |
| 247 | mSeamlessRotating = true; |
| 248 | |
| 249 | // This will revoke the leash and clear the control target. |
| 250 | mWin.cancelAnimation(); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | void finishSeamlessRotation(boolean timeout) { |
| 255 | if (mSeamlessRotating) { |
| 256 | mSeamlessRotating = false; |
| 257 | mFinishSeamlessRotateFrameNumber = timeout ? -1 : mWin.getFrameNumber(); |
| 258 | } |
| 259 | } |
| 260 | |
Evan Rosky | 8d782e0 | 2019-10-14 15:43:53 -0700 | [diff] [blame] | 261 | boolean onInsetsModified(InsetsControlTarget caller, InsetsSource modifiedSource) { |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 262 | if (mControlTarget != caller || modifiedSource.isVisible() == mClientVisible) { |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 263 | return false; |
| 264 | } |
| 265 | setClientVisible(modifiedSource.isVisible()); |
| 266 | return true; |
| 267 | } |
| 268 | |
| 269 | private void setClientVisible(boolean clientVisible) { |
Jorim Jaggi | cfd6f3b | 2018-11-07 15:30:18 +0100 | [diff] [blame] | 270 | if (mClientVisible == clientVisible) { |
| 271 | return; |
| 272 | } |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 273 | mClientVisible = clientVisible; |
Tiger Huang | 3f38f26 | 2019-12-18 21:08:40 +0800 | [diff] [blame] | 274 | mDisplayContent.mWmService.mH.obtainMessage( |
| 275 | LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED, mDisplayContent).sendToTarget(); |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 276 | updateVisibility(); |
| 277 | } |
| 278 | |
| 279 | private void setServerVisible(boolean serverVisible) { |
| 280 | mServerVisible = serverVisible; |
| 281 | updateVisibility(); |
| 282 | } |
| 283 | |
| 284 | private void updateVisibility() { |
| 285 | mSource.setVisible(mServerVisible && mClientVisible); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 286 | } |
| 287 | |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 288 | InsetsSourceControl getControl(InsetsControlTarget target) { |
| 289 | if (target == mControlTarget) { |
| 290 | return mControl; |
| 291 | } |
| 292 | if (target == mFakeControlTarget) { |
| 293 | return mFakeControl; |
| 294 | } |
| 295 | return null; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 296 | } |
| 297 | |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 298 | InsetsControlTarget getControlTarget() { |
| 299 | return mControlTarget; |
| 300 | } |
| 301 | |
Jorim Jaggi | cfd6f3b | 2018-11-07 15:30:18 +0100 | [diff] [blame] | 302 | boolean isClientVisible() { |
Jorim Jaggi | a2759b2 | 2019-01-24 13:21:40 +0100 | [diff] [blame] | 303 | return sNewInsetsMode == NEW_INSETS_MODE_NONE || mClientVisible; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | private class ControlAdapter implements AnimationAdapter { |
| 307 | |
| 308 | private SurfaceControl mCapturedLeash; |
| 309 | |
| 310 | @Override |
| 311 | public boolean getShowWallpaper() { |
| 312 | return false; |
| 313 | } |
| 314 | |
| 315 | @Override |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 316 | public void startAnimation(SurfaceControl animationLeash, Transaction t, |
| 317 | OnAnimationFinishedCallback finishCallback) { |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 318 | // TODO(b/118118435): We can remove the type check when implementing the transient bar |
| 319 | // animation. |
Tiger Huang | 332793b | 2019-10-29 23:21:27 +0800 | [diff] [blame] | 320 | if (mSource.getType() == ITYPE_IME) { |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 321 | // TODO: use 0 alpha and remove t.hide() once b/138459974 is fixed. |
| 322 | t.setAlpha(animationLeash, 1 /* alpha */); |
| 323 | t.hide(animationLeash); |
| 324 | } |
Taran Singh | fd0e586 | 2019-10-10 15:15:16 +0200 | [diff] [blame] | 325 | |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 326 | mCapturedLeash = animationLeash; |
Tarandeep Singh | 215929b | 2019-01-11 18:24:37 -0800 | [diff] [blame] | 327 | final Rect frame = mWin.getWindowFrames().mFrame; |
| 328 | t.setPosition(mCapturedLeash, frame.left, frame.top); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | @Override |
| 332 | public void onAnimationCancelled(SurfaceControl animationLeash) { |
| 333 | if (mAdapter == this) { |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 334 | mStateController.notifyControlRevoked(mControlTarget, InsetsSourceProvider.this); |
Jorim Jaggi | d89efeb | 2019-01-22 17:48:34 +0100 | [diff] [blame] | 335 | setClientVisible(InsetsState.getDefaultVisibility(mSource.getType())); |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 336 | mControl = null; |
Jorim Jaggi | 2862047 | 2019-01-02 23:21:49 +0100 | [diff] [blame] | 337 | mControlTarget = null; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 338 | mAdapter = null; |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | @Override |
| 343 | public long getDurationHint() { |
| 344 | return 0; |
| 345 | } |
| 346 | |
| 347 | @Override |
| 348 | public long getStatusBarTransitionsStartTime() { |
| 349 | return 0; |
| 350 | } |
| 351 | |
| 352 | @Override |
| 353 | public void dump(PrintWriter pw, String prefix) { |
| 354 | } |
| 355 | |
| 356 | @Override |
Jeffrey Huang | cb78285 | 2019-12-05 11:28:11 -0800 | [diff] [blame] | 357 | public void dumpDebug(ProtoOutputStream proto) { |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 358 | } |
Jorim Jaggi | a12ea56 | 2019-01-07 17:47:47 +0100 | [diff] [blame] | 359 | } |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 360 | } |