blob: 0346329eccd47a987c18905de3beadac1f08d098 [file] [log] [blame]
Wale Ogunwaleb699ce02016-07-18 12:05:30 -07001/*
2 * Copyright (C) 2016 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
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -070014 * limitations under the License.
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070015 */
16
17package com.android.server.wm;
18
chaviwb28de1f2018-03-02 10:42:36 -080019import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
20import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
lumarkf948afe2019-05-23 21:22:36 +080021import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
Adrian Roos0e7b70a2018-06-07 15:29:34 +020022import static android.hardware.camera2.params.OutputConfiguration.ROTATION_90;
Tiger Huang332793b2019-10-29 23:21:27 +080023import static android.view.InsetsState.ITYPE_STATUS_BAR;
Adrian Roos0e7b70a2018-06-07 15:29:34 +020024import static android.view.Surface.ROTATION_0;
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070025import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
Wale Ogunwale805d9ec2016-12-07 12:22:08 -080026import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
27import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070028import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
Wale Ogunwale34247952017-02-19 11:57:53 -080029import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL;
30import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
31import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA;
32import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY;
Suprabh Shukla69c71422018-04-02 18:39:01 -070033import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
Riddle Hsu5df3b752019-12-16 13:27:37 -060034import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
Wale Ogunwale34247952017-02-19 11:57:53 -080035import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;
Riddle Hsu5df3b752019-12-16 13:27:37 -060036import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
Wale Ogunwale805d9ec2016-12-07 12:22:08 -080037import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
Jorim Jaggicfd6f3b2018-11-07 15:30:18 +010038import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
chaviwebcbc342018-02-07 13:19:00 -080039
Yunfan Chend6c85a42019-02-18 15:52:17 +090040import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
lumarkf948afe2019-05-23 21:22:36 +080041import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
Riddle Hsu839b5f52020-03-31 21:41:18 +080042import static com.android.dx.mockito.inline.extended.ExtendedMockito.doThrow;
Tadashi G. Takaokabf0d57b2018-11-19 16:09:58 +090043import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
44import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;
45import static com.android.dx.mockito.inline.extended.ExtendedMockito.reset;
46import static com.android.dx.mockito.inline.extended.ExtendedMockito.spy;
Yunfan Chendb39c162019-02-08 16:14:14 +090047import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
Tadashi G. Takaokabf0d57b2018-11-19 16:09:58 +090048import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
49
Riddle Hsu839b5f52020-03-31 21:41:18 +080050import static com.google.common.truth.Truth.assertThat;
51
Adrian Roos5251b1d2018-03-23 18:57:43 +010052import static org.hamcrest.Matchers.is;
53import static org.hamcrest.Matchers.not;
Wale Ogunwalea7e3b642016-08-29 10:15:34 -070054import static org.junit.Assert.assertEquals;
55import static org.junit.Assert.assertFalse;
56import static org.junit.Assert.assertNull;
Adrian Roos5251b1d2018-03-23 18:57:43 +010057import static org.junit.Assert.assertThat;
Wale Ogunwalea7e3b642016-08-29 10:15:34 -070058import static org.junit.Assert.assertTrue;
Vishnu Nairddd80742018-08-21 14:12:46 -070059import static org.mockito.ArgumentMatchers.any;
Riddle Hsu839b5f52020-03-31 21:41:18 +080060import static org.mockito.ArgumentMatchers.anyBoolean;
Michael Wrighte3001042019-02-05 00:13:14 +000061import static org.mockito.ArgumentMatchers.anyInt;
chaviw40234662018-02-07 09:37:16 -080062import static org.mockito.ArgumentMatchers.anyLong;
63import static org.mockito.ArgumentMatchers.anyString;
Vishnu Nairddd80742018-08-21 14:12:46 -070064import static org.mockito.ArgumentMatchers.eq;
Vinit Nayak8009e922019-09-05 11:49:53 -070065import static org.mockito.Mockito.when;
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070066
Issei Suzuki43190bd2018-08-20 17:28:41 +020067import android.graphics.Insets;
Vishnu Nairddd80742018-08-21 14:12:46 -070068import android.graphics.Matrix;
Tarandeep Singhbcba88c2019-12-06 10:36:55 -080069import android.graphics.PixelFormat;
Adrian Roos49c27ff2018-08-31 13:07:33 -070070import android.graphics.Rect;
Riddle Hsu839b5f52020-03-31 21:41:18 +080071import android.os.RemoteException;
Brett Chabota26eda92018-07-23 13:08:30 -070072import android.platform.test.annotations.Presubmit;
Adrian Roos49c27ff2018-08-31 13:07:33 -070073import android.util.Size;
74import android.view.DisplayCutout;
Jorim Jaggicfd6f3b2018-11-07 15:30:18 +010075import android.view.InsetsSource;
Brett Chabota26eda92018-07-23 13:08:30 -070076import android.view.SurfaceControl;
77import android.view.WindowManager;
78
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -070079import androidx.test.filters.SmallTest;
80
Adrian Roos49c27ff2018-08-31 13:07:33 -070081import com.android.server.wm.utils.WmDisplayCutout;
82
Yunfan Chendb39c162019-02-08 16:14:14 +090083import org.junit.Before;
Brett Chabota26eda92018-07-23 13:08:30 -070084import org.junit.Test;
Riddle Hsu2da2d032019-08-28 21:08:58 +080085import org.junit.runner.RunWith;
Brett Chabota26eda92018-07-23 13:08:30 -070086
Riddle Hsu5df3b752019-12-16 13:27:37 -060087import java.util.Arrays;
Brett Chabota26eda92018-07-23 13:08:30 -070088import java.util.LinkedList;
Riddle Hsu5df3b752019-12-16 13:27:37 -060089import java.util.List;
Brett Chabota26eda92018-07-23 13:08:30 -070090
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070091/**
92 * Tests for the {@link WindowState} class.
93 *
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -070094 * Build/Install/Run:
Andrii Kulianf5d14112019-10-31 17:37:54 -070095 * atest WmTests:WindowStateTests
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070096 */
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -070097@SmallTest
98@Presubmit
Riddle Hsu2da2d032019-08-28 21:08:58 +080099@RunWith(WindowTestRunner.class)
Wale Ogunwale44fbdf52016-11-16 10:18:45 -0800100public class WindowStateTests extends WindowTestsBase {
Wale Ogunwaleb699ce02016-07-18 12:05:30 -0700101
Yunfan Chendb39c162019-02-08 16:14:14 +0900102 @Before
103 public void setUp() {
104 // TODO: Let the insets source with new mode keep the visibility control, and remove this
105 // setup code. Now mTopFullscreenOpaqueWindowState will take back the control of insets
106 // visibility.
Riddle Hsu2da2d032019-08-28 21:08:58 +0800107 spyOn(mDisplayContent);
108 doNothing().when(mDisplayContent).layoutAndAssignWindowLayersIfNeeded();
Yunfan Chendb39c162019-02-08 16:14:14 +0900109 }
110
Wale Ogunwalea7e3b642016-08-29 10:15:34 -0700111 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700112 public void testIsParentWindowHidden() {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800113 final WindowState parentWindow = createWindow(null, TYPE_APPLICATION, "parentWindow");
114 final WindowState child1 = createWindow(parentWindow, FIRST_SUB_WINDOW, "child1");
115 final WindowState child2 = createWindow(parentWindow, FIRST_SUB_WINDOW, "child2");
Wale Ogunwale9d147902016-07-16 11:58:55 -0700116
chaviwebcbc342018-02-07 13:19:00 -0800117 // parentWindow is initially set to hidden.
118 assertTrue(parentWindow.mHidden);
119 assertFalse(parentWindow.isParentWindowHidden());
120 assertTrue(child1.isParentWindowHidden());
121 assertTrue(child2.isParentWindowHidden());
122
123 parentWindow.mHidden = false;
Wale Ogunwale9d147902016-07-16 11:58:55 -0700124 assertFalse(parentWindow.isParentWindowHidden());
125 assertFalse(child1.isParentWindowHidden());
126 assertFalse(child2.isParentWindowHidden());
Wale Ogunwale9d147902016-07-16 11:58:55 -0700127 }
128
Wale Ogunwalea7e3b642016-08-29 10:15:34 -0700129 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700130 public void testIsChildWindow() {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800131 final WindowState parentWindow = createWindow(null, TYPE_APPLICATION, "parentWindow");
132 final WindowState child1 = createWindow(parentWindow, FIRST_SUB_WINDOW, "child1");
133 final WindowState child2 = createWindow(parentWindow, FIRST_SUB_WINDOW, "child2");
134 final WindowState randomWindow = createWindow(null, TYPE_APPLICATION, "randomWindow");
Wale Ogunwaleadde52e2016-07-16 13:11:55 -0700135
136 assertFalse(parentWindow.isChildWindow());
137 assertTrue(child1.isChildWindow());
138 assertTrue(child2.isChildWindow());
139 assertFalse(randomWindow.isChildWindow());
140 }
141
Wale Ogunwalea7e3b642016-08-29 10:15:34 -0700142 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700143 public void testHasChild() {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800144 final WindowState win1 = createWindow(null, TYPE_APPLICATION, "win1");
145 final WindowState win11 = createWindow(win1, FIRST_SUB_WINDOW, "win11");
146 final WindowState win12 = createWindow(win1, FIRST_SUB_WINDOW, "win12");
147 final WindowState win2 = createWindow(null, TYPE_APPLICATION, "win2");
148 final WindowState win21 = createWindow(win2, FIRST_SUB_WINDOW, "win21");
149 final WindowState randomWindow = createWindow(null, TYPE_APPLICATION, "randomWindow");
Wale Ogunwaleadde52e2016-07-16 13:11:55 -0700150
151 assertTrue(win1.hasChild(win11));
152 assertTrue(win1.hasChild(win12));
153 assertTrue(win2.hasChild(win21));
154
155 assertFalse(win1.hasChild(win21));
156 assertFalse(win1.hasChild(randomWindow));
157
158 assertFalse(win2.hasChild(win11));
159 assertFalse(win2.hasChild(win12));
160 assertFalse(win2.hasChild(randomWindow));
161 }
162
Wale Ogunwalea7e3b642016-08-29 10:15:34 -0700163 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700164 public void testGetParentWindow() {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800165 final WindowState parentWindow = createWindow(null, TYPE_APPLICATION, "parentWindow");
166 final WindowState child1 = createWindow(parentWindow, FIRST_SUB_WINDOW, "child1");
167 final WindowState child2 = createWindow(parentWindow, FIRST_SUB_WINDOW, "child2");
Wale Ogunwalecaa53af2016-07-17 14:50:26 -0700168
169 assertNull(parentWindow.getParentWindow());
170 assertEquals(parentWindow, child1.getParentWindow());
171 assertEquals(parentWindow, child2.getParentWindow());
172 }
173
Wale Ogunwalea7e3b642016-08-29 10:15:34 -0700174 @Test
Suprabh Shukla69c71422018-04-02 18:39:01 -0700175 public void testOverlayWindowHiddenWhenSuspended() {
176 final WindowState overlayWindow = spy(createWindow(null, TYPE_APPLICATION_OVERLAY,
177 "overlayWindow"));
178 overlayWindow.setHiddenWhileSuspended(true);
179 verify(overlayWindow).hideLw(true, true);
180 overlayWindow.setHiddenWhileSuspended(false);
181 verify(overlayWindow).showLw(true, true);
182 }
183
184 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700185 public void testGetTopParentWindow() {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800186 final WindowState root = createWindow(null, TYPE_APPLICATION, "root");
187 final WindowState child1 = createWindow(root, FIRST_SUB_WINDOW, "child1");
188 final WindowState child2 = createWindow(child1, FIRST_SUB_WINDOW, "child2");
Wale Ogunwalecaa53af2016-07-17 14:50:26 -0700189
190 assertEquals(root, root.getTopParentWindow());
191 assertEquals(root, child1.getTopParentWindow());
192 assertEquals(child1, child2.getParentWindow());
193 assertEquals(root, child2.getTopParentWindow());
Wale Ogunwaleea92d972016-12-08 07:33:13 -0800194
195 // Test case were child is detached from parent.
196 root.removeChild(child1);
197 assertEquals(child1, child1.getTopParentWindow());
198 assertEquals(child1, child2.getParentWindow());
Wale Ogunwalecaa53af2016-07-17 14:50:26 -0700199 }
200
Jorim Jaggiaf221d12016-11-15 14:59:57 -0800201 @Test
202 public void testIsOnScreen_hiddenByPolicy() {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800203 final WindowState window = createWindow(null, TYPE_APPLICATION, "window");
Jorim Jaggiaf221d12016-11-15 14:59:57 -0800204 window.setHasSurface(true);
205 assertTrue(window.isOnScreen());
206 window.hideLw(false /* doAnimation */);
207 assertFalse(window.isOnScreen());
208 }
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800209
210 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700211 public void testCanBeImeTarget() {
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800212 final WindowState appWindow = createWindow(null, TYPE_APPLICATION, "appWindow");
213 final WindowState imeWindow = createWindow(null, TYPE_INPUT_METHOD, "imeWindow");
214
Tarandeep Singhbcba88c2019-12-06 10:36:55 -0800215 // Setting FLAG_NOT_FOCUSABLE prevents the window from being an IME target.
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800216 appWindow.mAttrs.flags |= FLAG_NOT_FOCUSABLE;
217 imeWindow.mAttrs.flags |= FLAG_NOT_FOCUSABLE;
218
219 // Make windows visible
220 appWindow.setHasSurface(true);
221 imeWindow.setHasSurface(true);
222
Tarandeep Singhbcba88c2019-12-06 10:36:55 -0800223 // Windows with FLAG_NOT_FOCUSABLE can't be IME targets
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800224 assertFalse(appWindow.canBeImeTarget());
225 assertFalse(imeWindow.canBeImeTarget());
226
227 // Add IME target flags
228 appWindow.mAttrs.flags |= (FLAG_NOT_FOCUSABLE | FLAG_ALT_FOCUSABLE_IM);
229 imeWindow.mAttrs.flags |= (FLAG_NOT_FOCUSABLE | FLAG_ALT_FOCUSABLE_IM);
230
Tarandeep Singhbcba88c2019-12-06 10:36:55 -0800231 // Visible app window with flags FLAG_NOT_FOCUSABLE or FLAG_ALT_FOCUSABLE_IM can't be IME
232 // target while an IME window can never be an IME target regardless of its visibility
233 // or flags.
234 assertFalse(appWindow.canBeImeTarget());
Andrew Chant17c896e2019-12-05 22:39:02 +0000235 assertFalse(imeWindow.canBeImeTarget());
Tarandeep Singh0ffa15a2019-11-04 13:40:15 -0800236
Tarandeep Singhbcba88c2019-12-06 10:36:55 -0800237 // b/145812508: special legacy use-case for transparent/translucent windows.
238 appWindow.mAttrs.format = PixelFormat.TRANSPARENT;
239 assertTrue(appWindow.canBeImeTarget());
240
241 appWindow.mAttrs.format = PixelFormat.OPAQUE;
242 appWindow.mAttrs.flags &= ~FLAG_ALT_FOCUSABLE_IM;
243 assertFalse(appWindow.canBeImeTarget());
244 appWindow.mAttrs.flags &= ~FLAG_NOT_FOCUSABLE;
245 assertTrue(appWindow.canBeImeTarget());
246
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800247 // Make windows invisible
248 appWindow.hideLw(false /* doAnimation */);
249 imeWindow.hideLw(false /* doAnimation */);
250
251 // Invisible window can't be IME targets even if they have the right flags.
252 assertFalse(appWindow.canBeImeTarget());
253 assertFalse(imeWindow.canBeImeTarget());
lumarkf948afe2019-05-23 21:22:36 +0800254
255 // Simulate the window is in split screen primary stack and the current state is
256 // minimized and home stack is resizable, so that we should ignore input for the stack.
257 final DockedStackDividerController controller =
258 mDisplayContent.getDockedDividerController();
Louis Changdc077272019-11-12 16:52:56 +0800259 final ActivityStack stack = createTaskStackOnDisplay(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY,
lumarkf948afe2019-05-23 21:22:36 +0800260 ACTIVITY_TYPE_STANDARD, mDisplayContent);
261 spyOn(appWindow);
262 spyOn(controller);
263 spyOn(stack);
Evan Rosky73a7fe92019-11-18 18:28:01 -0800264 stack.setFocusable(false);
Wale Ogunwale1ebcd8e2020-01-21 11:27:03 -0800265 doReturn(stack).when(appWindow).getRootTask();
lumarkf948afe2019-05-23 21:22:36 +0800266
267 // Make sure canBeImeTarget is false due to shouldIgnoreInput is true;
268 assertFalse(appWindow.canBeImeTarget());
269 assertTrue(stack.shouldIgnoreInput());
Wale Ogunwale805d9ec2016-12-07 12:22:08 -0800270 }
Wale Ogunwale34247952017-02-19 11:57:53 -0800271
272 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700273 public void testGetWindow() {
Wale Ogunwale34247952017-02-19 11:57:53 -0800274 final WindowState root = createWindow(null, TYPE_APPLICATION, "root");
275 final WindowState mediaChild = createWindow(root, TYPE_APPLICATION_MEDIA, "mediaChild");
276 final WindowState mediaOverlayChild = createWindow(root,
277 TYPE_APPLICATION_MEDIA_OVERLAY, "mediaOverlayChild");
278 final WindowState attachedDialogChild = createWindow(root,
279 TYPE_APPLICATION_ATTACHED_DIALOG, "attachedDialogChild");
280 final WindowState subPanelChild = createWindow(root,
281 TYPE_APPLICATION_SUB_PANEL, "subPanelChild");
282 final WindowState aboveSubPanelChild = createWindow(root,
283 TYPE_APPLICATION_ABOVE_SUB_PANEL, "aboveSubPanelChild");
284
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700285 final LinkedList<WindowState> windows = new LinkedList<>();
Wale Ogunwale34247952017-02-19 11:57:53 -0800286
287 root.getWindow(w -> {
288 windows.addLast(w);
289 return false;
290 });
291
292 // getWindow should have returned candidate windows in z-order.
293 assertEquals(aboveSubPanelChild, windows.pollFirst());
294 assertEquals(subPanelChild, windows.pollFirst());
295 assertEquals(attachedDialogChild, windows.pollFirst());
296 assertEquals(root, windows.pollFirst());
297 assertEquals(mediaOverlayChild, windows.pollFirst());
298 assertEquals(mediaChild, windows.pollFirst());
299 assertTrue(windows.isEmpty());
300 }
Bryce Leeae73ba42017-05-05 09:58:25 -0700301
302 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700303 public void testPrepareWindowToDisplayDuringRelayout() {
Riddle Hsu4bb06be2019-07-02 01:03:07 +0800304 // Call prepareWindowToDisplayDuringRelayout for a window without FLAG_TURN_SCREEN_ON before
Garfield Tane8d84ab2019-10-11 09:49:40 -0700305 // calling setCurrentLaunchCanTurnScreenOn for windows with flag in the same activity.
306 final ActivityRecord activity = createActivityRecord(mDisplayContent,
chaviwb28de1f2018-03-02 10:42:36 -0800307 WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD);
Garfield Tane8d84ab2019-10-11 09:49:40 -0700308 final WindowState first = createWindow(null, TYPE_APPLICATION, activity, "first");
309 final WindowState second = createWindow(null, TYPE_APPLICATION, activity, "second");
chaviwb28de1f2018-03-02 10:42:36 -0800310
Riddle Hsu4bb06be2019-07-02 01:03:07 +0800311 testPrepareWindowToDisplayDuringRelayout(first, false /* expectedWakeupCalled */,
312 true /* expectedCurrentLaunchCanTurnScreenOn */);
Andrii Kulian46799182019-10-17 16:26:17 -0700313 testPrepareWindowToDisplayDuringRelayout(second, false /* expectedWakeupCalled */,
314 true /* expectedCurrentLaunchCanTurnScreenOn */);
315
316 // Call prepareWindowToDisplayDuringRelayout for two windows from the same activity, one of
317 // which has FLAG_TURN_SCREEN_ON. The first processed one should trigger the wakeup.
318 second.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
319 testPrepareWindowToDisplayDuringRelayout(first, true /* expectedWakeupCalled */,
320 false /* expectedCurrentLaunchCanTurnScreenOn */);
321 testPrepareWindowToDisplayDuringRelayout(second, false /* expectedWakeupCalled */,
Riddle Hsu4bb06be2019-07-02 01:03:07 +0800322 false /* expectedCurrentLaunchCanTurnScreenOn */);
chaviwb28de1f2018-03-02 10:42:36 -0800323
324 // Call prepareWindowToDisplayDuringRelayout for two window that have FLAG_TURN_SCREEN_ON
Garfield Tane8d84ab2019-10-11 09:49:40 -0700325 // from the same activity. Only one should trigger the wakeup.
326 activity.setCurrentLaunchCanTurnScreenOn(true);
chaviwb28de1f2018-03-02 10:42:36 -0800327 first.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
328 second.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
329
Riddle Hsu4bb06be2019-07-02 01:03:07 +0800330 testPrepareWindowToDisplayDuringRelayout(first, true /* expectedWakeupCalled */,
331 false /* expectedCurrentLaunchCanTurnScreenOn */);
332 testPrepareWindowToDisplayDuringRelayout(second, false /* expectedWakeupCalled */,
333 false /* expectedCurrentLaunchCanTurnScreenOn */);
chaviwb28de1f2018-03-02 10:42:36 -0800334
Riddle Hsu4bb06be2019-07-02 01:03:07 +0800335 // Without window flags, the state of ActivityRecord.canTurnScreenOn should still be able to
336 // turn on the screen.
Garfield Tane8d84ab2019-10-11 09:49:40 -0700337 activity.setCurrentLaunchCanTurnScreenOn(true);
Riddle Hsu4bb06be2019-07-02 01:03:07 +0800338 first.mAttrs.flags &= ~WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
Garfield Tane8d84ab2019-10-11 09:49:40 -0700339 doReturn(true).when(activity).canTurnScreenOn();
Riddle Hsu4bb06be2019-07-02 01:03:07 +0800340
341 testPrepareWindowToDisplayDuringRelayout(first, true /* expectedWakeupCalled */,
342 false /* expectedCurrentLaunchCanTurnScreenOn */);
chaviwb28de1f2018-03-02 10:42:36 -0800343
344 // Call prepareWindowToDisplayDuringRelayout for a windows that are not children of an
Garfield Tane8d84ab2019-10-11 09:49:40 -0700345 // activity. Both windows have the FLAG_TURNS_SCREEN_ON so both should call wakeup
chaviw97d28202018-02-27 16:23:53 -0800346 final WindowToken windowToken = WindowTestUtils.createTestWindowToken(FIRST_SUB_WINDOW,
chaviwb28de1f2018-03-02 10:42:36 -0800347 mDisplayContent);
348 final WindowState firstWindow = createWindow(null, TYPE_APPLICATION, windowToken,
349 "firstWindow");
350 final WindowState secondWindow = createWindow(null, TYPE_APPLICATION, windowToken,
351 "secondWindow");
352 firstWindow.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
353 secondWindow.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
354
Garfield Tane3d37b52019-07-23 12:43:05 -0700355 final WindowState.PowerManagerWrapper powerManagerWrapper =
356 mSystemServicesTestRule.getPowerManagerWrapper();
357 reset(powerManagerWrapper);
chaviwb28de1f2018-03-02 10:42:36 -0800358 firstWindow.prepareWindowToDisplayDuringRelayout(false /*wasVisible*/);
Garfield Tane3d37b52019-07-23 12:43:05 -0700359 verify(powerManagerWrapper).wakeUp(anyLong(), anyInt(), anyString());
chaviwb28de1f2018-03-02 10:42:36 -0800360
Garfield Tane3d37b52019-07-23 12:43:05 -0700361 reset(powerManagerWrapper);
chaviwb28de1f2018-03-02 10:42:36 -0800362 secondWindow.prepareWindowToDisplayDuringRelayout(false /*wasVisible*/);
Garfield Tane3d37b52019-07-23 12:43:05 -0700363 verify(powerManagerWrapper).wakeUp(anyLong(), anyInt(), anyString());
Bryce Leeae73ba42017-05-05 09:58:25 -0700364 }
365
Riddle Hsu4bb06be2019-07-02 01:03:07 +0800366 private void testPrepareWindowToDisplayDuringRelayout(WindowState appWindow,
367 boolean expectedWakeupCalled, boolean expectedCurrentLaunchCanTurnScreenOn) {
Garfield Tane3d37b52019-07-23 12:43:05 -0700368 final WindowState.PowerManagerWrapper powerManagerWrapper =
369 mSystemServicesTestRule.getPowerManagerWrapper();
370 reset(powerManagerWrapper);
Riddle Hsu4bb06be2019-07-02 01:03:07 +0800371 appWindow.prepareWindowToDisplayDuringRelayout(false /* wasVisible */);
372
373 if (expectedWakeupCalled) {
Garfield Tane3d37b52019-07-23 12:43:05 -0700374 verify(powerManagerWrapper).wakeUp(anyLong(), anyInt(), anyString());
Riddle Hsu4bb06be2019-07-02 01:03:07 +0800375 } else {
Garfield Tane3d37b52019-07-23 12:43:05 -0700376 verify(powerManagerWrapper, never()).wakeUp(anyLong(), anyInt(), anyString());
Riddle Hsu4bb06be2019-07-02 01:03:07 +0800377 }
378 // If wakeup is expected to be called, the currentLaunchCanTurnScreenOn should be false
379 // because the state will be consumed.
Garfield Tane8d84ab2019-10-11 09:49:40 -0700380 assertThat(appWindow.mActivityRecord.currentLaunchCanTurnScreenOn(),
Riddle Hsu4bb06be2019-07-02 01:03:07 +0800381 is(expectedCurrentLaunchCanTurnScreenOn));
382 }
383
Jorim Jaggi72207752018-01-08 13:16:59 +0100384 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700385 public void testCanAffectSystemUiFlags() {
Jorim Jaggi72207752018-01-08 13:16:59 +0100386 final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
Issei Suzukif2f6c912019-11-08 11:24:18 +0100387 app.mActivityRecord.setVisible(true);
Jorim Jaggi72207752018-01-08 13:16:59 +0100388 assertTrue(app.canAffectSystemUiFlags());
Issei Suzukif2f6c912019-11-08 11:24:18 +0100389 app.mActivityRecord.setVisible(false);
Jorim Jaggi72207752018-01-08 13:16:59 +0100390 assertFalse(app.canAffectSystemUiFlags());
Issei Suzukif2f6c912019-11-08 11:24:18 +0100391 app.mActivityRecord.setVisible(true);
Jorim Jaggi72207752018-01-08 13:16:59 +0100392 app.mAttrs.alpha = 0.0f;
393 assertFalse(app.canAffectSystemUiFlags());
Jorim Jaggi50bf59c2018-03-09 17:29:48 +0100394 }
395
396 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700397 public void testCanAffectSystemUiFlags_disallow() {
Jorim Jaggi50bf59c2018-03-09 17:29:48 +0100398 final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
Issei Suzukif2f6c912019-11-08 11:24:18 +0100399 app.mActivityRecord.setVisible(true);
Jorim Jaggi50bf59c2018-03-09 17:29:48 +0100400 assertTrue(app.canAffectSystemUiFlags());
401 app.getTask().setCanAffectSystemUiFlags(false);
402 assertFalse(app.canAffectSystemUiFlags());
Jorim Jaggi72207752018-01-08 13:16:59 +0100403 }
404
Jorim Jaggi4876b4a2018-01-11 15:43:49 +0100405 @Test
Jorim Jaggi956ca412019-01-07 14:49:14 +0100406 public void testVisibleWithInsetsProvider() {
Tiger Huang332793b2019-10-29 23:21:27 +0800407 final WindowState statusBar = createWindow(null, TYPE_STATUS_BAR, "statusBar");
Jorim Jaggicfd6f3b2018-11-07 15:30:18 +0100408 final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
Tiger Huang332793b2019-10-29 23:21:27 +0800409 statusBar.mHasSurface = true;
410 assertTrue(statusBar.isVisible());
411 mDisplayContent.getInsetsStateController().getSourceProvider(ITYPE_STATUS_BAR)
Jorim Jaggi9b4f4202020-01-28 17:05:06 +0100412 .setWindow(statusBar, null /* frameProvider */, null /* imeFrameProvider */);
Jorim Jaggi956ca412019-01-07 14:49:14 +0100413 mDisplayContent.getInsetsStateController().onBarControlTargetChanged(
414 app, null /* fakeTopControlling */, app, null /* fakeNavControlling */);
Jorim Jaggi0dd0cf92019-12-27 15:17:44 +0100415 final InsetsSource source = new InsetsSource(ITYPE_STATUS_BAR);
416 source.setVisible(false);
Tiger Huang332793b2019-10-29 23:21:27 +0800417 mDisplayContent.getInsetsStateController().getSourceProvider(ITYPE_STATUS_BAR)
Jorim Jaggi0dd0cf92019-12-27 15:17:44 +0100418 .onInsetsModified(app, source);
Yunfan Chendb39c162019-02-08 16:14:14 +0900419 waitUntilHandlersIdle();
Tiger Huang332793b2019-10-29 23:21:27 +0800420 assertFalse(statusBar.isVisible());
Jorim Jaggicfd6f3b2018-11-07 15:30:18 +0100421 }
422
423 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700424 public void testIsSelfOrAncestorWindowAnimating() {
Jorim Jaggi4876b4a2018-01-11 15:43:49 +0100425 final WindowState root = createWindow(null, TYPE_APPLICATION, "root");
426 final WindowState child1 = createWindow(root, FIRST_SUB_WINDOW, "child1");
427 final WindowState child2 = createWindow(child1, FIRST_SUB_WINDOW, "child2");
428 assertFalse(child2.isSelfOrAncestorWindowAnimatingExit());
429 child2.mAnimatingExit = true;
430 assertTrue(child2.isSelfOrAncestorWindowAnimatingExit());
431 child2.mAnimatingExit = false;
432 root.mAnimatingExit = true;
433 assertTrue(child2.isSelfOrAncestorWindowAnimatingExit());
434 }
435
Adrian Roos5251b1d2018-03-23 18:57:43 +0100436 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700437 public void testLayoutSeqResetOnReparent() {
Adrian Roos5251b1d2018-03-23 18:57:43 +0100438 final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
439 app.mLayoutSeq = 1;
440 mDisplayContent.mLayoutSeq = 1;
441
Garfield Tane223e682019-04-15 09:59:25 -0700442 DisplayContent newDisplay = createNewDisplay();
443
444 app.onDisplayChanged(newDisplay);
Adrian Roos5251b1d2018-03-23 18:57:43 +0100445
446 assertThat(app.mLayoutSeq, not(is(mDisplayContent.mLayoutSeq)));
447 }
448
Brad Stenningaf596412018-04-02 12:03:19 -0700449 @Test
Tadashi G. Takaokab6e148c2018-11-03 02:59:06 -0700450 public void testDisplayIdUpdatedOnReparent() {
Brad Stenningaf596412018-04-02 12:03:19 -0700451 final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
452 // fake a different display
453 app.mInputWindowHandle.displayId = mDisplayContent.getDisplayId() + 1;
454 app.onDisplayChanged(mDisplayContent);
455
456 assertThat(app.mInputWindowHandle.displayId, is(mDisplayContent.getDisplayId()));
457 assertThat(app.getDisplayId(), is(mDisplayContent.getDisplayId()));
458 }
459
Adrian Roos0e7b70a2018-06-07 15:29:34 +0200460 @Test
461 public void testSeamlesslyRotateWindow() {
462 final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
chaviw619da692019-06-10 15:39:40 -0700463 final SurfaceControl.Transaction t = spy(StubTransaction.class);
Adrian Roos0e7b70a2018-06-07 15:29:34 +0200464
465 app.mHasSurface = true;
Vishnu Naird8c664b2018-09-24 12:52:35 -0700466 app.mSurfaceControl = mock(SurfaceControl.class);
Adrian Roos0e7b70a2018-06-07 15:29:34 +0200467 try {
chaviw492139a2018-07-16 16:07:35 -0700468 app.getFrameLw().set(10, 20, 60, 80);
Vishnu Naird8c664b2018-09-24 12:52:35 -0700469 app.updateSurfacePosition(t);
Adrian Roos0e7b70a2018-06-07 15:29:34 +0200470
Vishnu Nairddd80742018-08-21 14:12:46 -0700471 app.seamlesslyRotateIfAllowed(t, ROTATION_0, ROTATION_90, true);
Adrian Roos0e7b70a2018-06-07 15:29:34 +0200472
473 assertTrue(app.mSeamlesslyRotated);
Vishnu Naird8c664b2018-09-24 12:52:35 -0700474
475 // Verify we un-rotate the window state surface.
Vishnu Nairddd80742018-08-21 14:12:46 -0700476 Matrix matrix = new Matrix();
477 // Un-rotate 90 deg
478 matrix.setRotate(270);
479 // Translate it back to origin
480 matrix.postTranslate(0, mDisplayInfo.logicalWidth);
Vishnu Naird8c664b2018-09-24 12:52:35 -0700481 verify(t).setMatrix(eq(app.mSurfaceControl), eq(matrix), any(float[].class));
482
483 // Verify we update the position as well.
484 float[] currentSurfacePos = {app.mLastSurfacePosition.x, app.mLastSurfacePosition.y};
485 matrix.mapPoints(currentSurfacePos);
486 verify(t).setPosition(eq(app.mSurfaceControl), eq(currentSurfacePos[0]),
487 eq(currentSurfacePos[1]));
Adrian Roos0e7b70a2018-06-07 15:29:34 +0200488 } finally {
Vishnu Naird8c664b2018-09-24 12:52:35 -0700489 app.mSurfaceControl = null;
Adrian Roos0e7b70a2018-06-07 15:29:34 +0200490 app.mHasSurface = false;
491 }
492 }
493
Adrian Roos49c27ff2018-08-31 13:07:33 -0700494 @Test
495 public void testDisplayCutoutIsCalculatedRelativeToFrame() {
496 final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
chaviw1454b392018-08-06 09:54:04 -0700497 WindowFrames wf = app.getWindowFrames();
Adrian Roos49c27ff2018-08-31 13:07:33 -0700498 wf.mParentFrame.set(7, 10, 185, 380);
499 wf.mDisplayFrame.set(wf.mParentFrame);
Issei Suzuki43190bd2018-08-20 17:28:41 +0200500 final DisplayCutout cutout = new DisplayCutout(
501 Insets.of(0, 15, 0, 22) /* safeInset */,
502 null /* boundLeft */,
503 new Rect(95, 0, 105, 15),
504 null /* boundRight */,
505 new Rect(95, 378, 105, 400));
Adrian Roos49c27ff2018-08-31 13:07:33 -0700506 wf.setDisplayCutout(new WmDisplayCutout(cutout, new Size(200, 400)));
507
chaviw1454b392018-08-06 09:54:04 -0700508 app.computeFrameLw();
Adrian Roos49c27ff2018-08-31 13:07:33 -0700509 assertThat(app.getWmDisplayCutout().getDisplayCutout(), is(cutout.inset(7, 10, 5, 20)));
510 }
511
chaviw15ad49f2019-04-24 15:05:39 -0700512 @Test
513 public void testVisibilityChangeSwitchUser() {
514 final WindowState window = createWindow(null, TYPE_APPLICATION, "app");
515 window.mHasSurface = true;
Wale Ogunwale9bb1a1e2019-12-30 11:29:52 -0800516 spyOn(window);
517 doReturn(false).when(window).showForAllUsers();
chaviw15ad49f2019-04-24 15:05:39 -0700518
519 mWm.mCurrentUserId = 1;
Wale Ogunwalebebd8cd2019-10-28 15:53:31 -0700520 window.switchUser(mWm.mCurrentUserId);
chaviw15ad49f2019-04-24 15:05:39 -0700521 assertFalse(window.isVisible());
522 assertFalse(window.isVisibleByPolicy());
523
524 mWm.mCurrentUserId = 0;
Wale Ogunwalebebd8cd2019-10-28 15:53:31 -0700525 window.switchUser(mWm.mCurrentUserId);
chaviw15ad49f2019-04-24 15:05:39 -0700526 assertTrue(window.isVisible());
527 assertTrue(window.isVisibleByPolicy());
528 }
Tiger Huangd8ec9382019-04-18 14:35:09 -0700529
530 @Test
Riddle Hsu5df3b752019-12-16 13:27:37 -0600531 public void testRequestDrawIfNeeded() {
532 final WindowState startingApp = createWindow(null /* parent */,
533 TYPE_BASE_APPLICATION, "startingApp");
534 final WindowState startingWindow = createWindow(null /* parent */,
535 TYPE_APPLICATION_STARTING, startingApp.mToken, "starting");
536 startingApp.mActivityRecord.startingWindow = startingWindow;
wilsonshihe8321942019-10-18 18:39:46 +0800537 final WindowState keyguardHostWindow = mNotificationShadeWindow;
Riddle Hsu5df3b752019-12-16 13:27:37 -0600538 final WindowState allDrawnApp = mAppWindow;
539 allDrawnApp.mActivityRecord.allDrawn = true;
540
541 // The waiting list is used to ensure the content is ready when turning on screen.
542 final List<WindowState> outWaitingForDrawn = mDisplayContent.mWaitingForDrawn;
543 final List<WindowState> visibleWindows = Arrays.asList(mChildAppWindowAbove,
544 keyguardHostWindow, allDrawnApp, startingApp, startingWindow);
545 visibleWindows.forEach(w -> {
546 w.mHasSurface = true;
547 w.requestDrawIfNeeded(outWaitingForDrawn);
548 });
549
550 // Keyguard host window should be always contained. The drawn app or app with starting
551 // window are unnecessary to draw.
552 assertEquals(Arrays.asList(keyguardHostWindow, startingWindow), outWaitingForDrawn);
553 }
554
555 @Test
Riddle Hsu839b5f52020-03-31 21:41:18 +0800556 public void testReportResizedWithRemoteException() {
557 final WindowState win = mChildAppWindowAbove;
558 makeWindowVisible(win, win.getParentWindow());
559 win.mLayoutSeq = win.getDisplayContent().mLayoutSeq;
560 win.updateResizingWindowIfNeeded();
561
562 assertThat(mWm.mResizingWindows).contains(win);
563 assertTrue(win.getOrientationChanging());
564
565 mWm.mResizingWindows.remove(win);
566 spyOn(win.mClient);
567 try {
568 doThrow(new RemoteException("test")).when(win.mClient).resized(any() /* frame */,
569 any() /* contentInsets */, any() /* visibleInsets */, any() /* stableInsets */,
570 anyBoolean() /* reportDraw */, any() /* mergedConfig */,
571 any() /* backDropFrame */, anyBoolean() /* forceLayout */,
572 anyBoolean() /* alwaysConsumeSystemBars */, anyInt() /* displayId */,
573 any() /* displayCutout */);
574 } catch (RemoteException ignored) {
575 }
576 win.reportResized();
577 win.updateResizingWindowIfNeeded();
578
579 // Even "resized" throws remote exception, it is still considered as reported. So the window
580 // shouldn't be resized again (which may block unfreeze in real case).
581 assertThat(mWm.mResizingWindows).doesNotContain(win);
582 assertFalse(win.getOrientationChanging());
583 }
584
585 @Test
Tiger Huangd8ec9382019-04-18 14:35:09 -0700586 public void testGetTransformationMatrix() {
Wale Ogunwale8a1860a2019-06-05 08:57:19 -0700587 final int PARENT_WINDOW_OFFSET = 1;
588 final int DISPLAY_IN_PARENT_WINDOW_OFFSET = 2;
589 final int WINDOW_OFFSET = 3;
590 final float OFFSET_SUM =
591 PARENT_WINDOW_OFFSET + DISPLAY_IN_PARENT_WINDOW_OFFSET + WINDOW_OFFSET;
592
Riddle Hsu2da2d032019-08-28 21:08:58 +0800593 final WindowState win0 = createWindow(null, TYPE_APPLICATION, "win0");
Tiger Huangd8ec9382019-04-18 14:35:09 -0700594
Riddle Hsu2da2d032019-08-28 21:08:58 +0800595 final DisplayContent dc = createNewDisplay();
596 win0.getFrameLw().offsetTo(PARENT_WINDOW_OFFSET, 0);
597 dc.reparentDisplayContent(win0, win0.getSurfaceControl());
598 dc.updateLocation(win0, DISPLAY_IN_PARENT_WINDOW_OFFSET, 0);
Tiger Huangd8ec9382019-04-18 14:35:09 -0700599
Riddle Hsu2da2d032019-08-28 21:08:58 +0800600 final float[] values = new float[9];
601 final Matrix matrix = new Matrix();
chaviw619da692019-06-10 15:39:40 -0700602 final SurfaceControl.Transaction t = spy(StubTransaction.class);
Riddle Hsu2da2d032019-08-28 21:08:58 +0800603 final WindowState win1 = createWindow(null, TYPE_APPLICATION, dc, "win1");
604 win1.mHasSurface = true;
605 win1.mSurfaceControl = mock(SurfaceControl.class);
606 win1.getFrameLw().offsetTo(WINDOW_OFFSET, 0);
607 win1.updateSurfacePosition(t);
608 win1.getTransformationMatrix(values, matrix);
Tiger Huangd8ec9382019-04-18 14:35:09 -0700609
Riddle Hsu2da2d032019-08-28 21:08:58 +0800610 matrix.getValues(values);
611 assertEquals(OFFSET_SUM, values[Matrix.MTRANS_X], 0f);
612 assertEquals(0f, values[Matrix.MTRANS_Y], 0f);
Tiger Huangd8ec9382019-04-18 14:35:09 -0700613 }
Vinit Nayak8009e922019-09-05 11:49:53 -0700614
615 @Test
616 public void testCantReceiveTouchDuringRecentsAnimation() {
617 final WindowState win0 = createWindow(null, TYPE_APPLICATION, "win0");
618
619 // Mock active recents animation
620 RecentsAnimationController recentsController = mock(RecentsAnimationController.class);
Winson Chungdc4edb82019-12-16 16:31:04 -0800621 when(recentsController.shouldApplyInputConsumer(win0.mActivityRecord)).thenReturn(true);
Vinit Nayak8009e922019-09-05 11:49:53 -0700622 mWm.setRecentsAnimationController(recentsController);
623 assertTrue(win0.cantReceiveTouchInput());
624 }
625
626 @Test
627 public void testCantReceiveTouchWhenAppTokenHiddenRequested() {
628 final WindowState win0 = createWindow(null, TYPE_APPLICATION, "win0");
Issei Suzuki1669ea42019-11-06 14:20:59 +0100629 win0.mActivityRecord.mVisibleRequested = false;
Vinit Nayak8009e922019-09-05 11:49:53 -0700630 assertTrue(win0.cantReceiveTouchInput());
631 }
632
633 @Test
Evan Rosky73a7fe92019-11-18 18:28:01 -0800634 public void testCantReceiveTouchWhenNotFocusable() {
Vinit Nayak8009e922019-09-05 11:49:53 -0700635 final WindowState win0 = createWindow(null, TYPE_APPLICATION, "win0");
Evan Rosky73a7fe92019-11-18 18:28:01 -0800636 win0.mActivityRecord.getStack().setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
637 win0.mActivityRecord.getStack().setFocusable(false);
Vinit Nayak8009e922019-09-05 11:49:53 -0700638 assertTrue(win0.cantReceiveTouchInput());
639 }
Jorim Jaggib895e202020-04-16 00:39:55 +0200640
641 @Test
642 public void testNeedsRelativeLayeringToIme_notAttached() {
643 WindowState sameTokenWindow = createWindow(null, TYPE_BASE_APPLICATION, mAppWindow.mToken,
644 "SameTokenWindow");
645 mDisplayContent.mInputMethodTarget = mAppWindow;
646 sameTokenWindow.mActivityRecord.getStack().setWindowingMode(
647 WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
648 assertTrue(sameTokenWindow.needsRelativeLayeringToIme());
649 sameTokenWindow.removeImmediately();
650 assertFalse(sameTokenWindow.needsRelativeLayeringToIme());
651 }
Wale Ogunwaleb699ce02016-07-18 12:05:30 -0700652}