Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 1 | /* |
| 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. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 14 | * limitations under the License. |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | package com.android.server.wm; |
| 18 | |
Garfield Tan | 98eead3 | 2019-11-18 13:24:53 -0800 | [diff] [blame] | 19 | import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 20 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; |
| 21 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; |
| 22 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
Tiger Huang | 86e6d07 | 2019-05-02 20:23:47 +0800 | [diff] [blame] | 23 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER; |
Tiger Huang | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 24 | import static android.os.Build.VERSION_CODES.P; |
| 25 | import static android.os.Build.VERSION_CODES.Q; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 26 | import static android.view.Display.DEFAULT_DISPLAY; |
Issei Suzuki | 43190bd | 2018-08-20 17:28:41 +0200 | [diff] [blame] | 27 | import static android.view.DisplayCutout.BOUNDS_POSITION_LEFT; |
| 28 | import static android.view.DisplayCutout.BOUNDS_POSITION_TOP; |
Adrian Roos | 2426421 | 2018-02-19 16:26:15 +0100 | [diff] [blame] | 29 | import static android.view.DisplayCutout.fromBoundingRect; |
Riddle Hsu | 9239d7c6 | 2020-02-20 01:35:56 +0800 | [diff] [blame] | 30 | import static android.view.Surface.ROTATION_0; |
Evan Rosky | 69cace4 | 2019-09-20 16:28:13 -0700 | [diff] [blame] | 31 | import static android.view.Surface.ROTATION_90; |
Adrian Roos | 019a52b | 2019-07-02 16:47:44 +0200 | [diff] [blame] | 32 | import static android.view.View.SYSTEM_UI_FLAG_FULLSCREEN; |
| 33 | import static android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
| 34 | import static android.view.View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 35 | import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR; |
| 36 | import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; |
Adrian Roos | 019a52b | 2019-07-02 16:47:44 +0200 | [diff] [blame] | 37 | import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
| 38 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 39 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; |
| 40 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; |
Tiger Huang | 86e6d07 | 2019-05-02 20:23:47 +0800 | [diff] [blame] | 41 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 42 | import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 43 | import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE; |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 44 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 45 | import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION; |
Riddle Hsu | b2297ad | 2019-07-26 23:37:25 -0600 | [diff] [blame] | 46 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 47 | |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 48 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.any; |
| 49 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyBoolean; |
Tadashi G. Takaoka | bf0d57b | 2018-11-19 16:09:58 +0900 | [diff] [blame] | 50 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; |
Riddle Hsu | 6d6f67c | 2019-03-14 16:54:26 +0800 | [diff] [blame] | 51 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 52 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock; |
| 53 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.never; |
Riddle Hsu | b2297ad | 2019-07-26 23:37:25 -0600 | [diff] [blame] | 54 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.reset; |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 55 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.same; |
Riddle Hsu | 6d6f67c | 2019-03-14 16:54:26 +0800 | [diff] [blame] | 56 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; |
Tadashi G. Takaoka | bf0d57b | 2018-11-19 16:09:58 +0900 | [diff] [blame] | 57 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.times; |
| 58 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; |
Riddle Hsu | fc246d1 | 2020-03-20 18:28:11 +0800 | [diff] [blame] | 59 | import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION; |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 60 | import static com.android.server.wm.WindowContainer.POSITION_TOP; |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 61 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL; |
chaviw | ebcbc34 | 2018-02-07 13:19:00 -0800 | [diff] [blame] | 62 | |
Riddle Hsu | 12c0545 | 2020-01-09 00:39:52 +0800 | [diff] [blame] | 63 | import static com.google.common.truth.Truth.assertThat; |
| 64 | |
Adrian Roos | 5251b1d | 2018-03-23 18:57:43 +0100 | [diff] [blame] | 65 | import static org.hamcrest.Matchers.is; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 66 | import static org.junit.Assert.assertEquals; |
Andrii Kulian | f0379de | 2018-03-14 16:24:07 -0700 | [diff] [blame] | 67 | import static org.junit.Assert.assertFalse; |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 68 | import static org.junit.Assert.assertNotNull; |
lumark | ff0ab69 | 2018-11-05 20:32:30 +0800 | [diff] [blame] | 69 | import static org.junit.Assert.assertNull; |
Adrian Roos | 5251b1d | 2018-03-23 18:57:43 +0100 | [diff] [blame] | 70 | import static org.junit.Assert.assertThat; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 71 | import static org.junit.Assert.assertTrue; |
Evan Rosky | 69cace4 | 2019-09-20 16:28:13 -0700 | [diff] [blame] | 72 | import static org.mockito.ArgumentMatchers.anyInt; |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 73 | import static org.mockito.ArgumentMatchers.eq; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 74 | |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 75 | import android.annotation.SuppressLint; |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 76 | import android.app.WindowConfiguration; |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 77 | import android.content.res.Configuration; |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 78 | import android.graphics.Rect; |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 79 | import android.graphics.Region; |
Susi Kharraz-Post | 9893b8c | 2019-02-12 14:21:29 -0500 | [diff] [blame] | 80 | import android.metrics.LogMaker; |
Evan Rosky | 69cace4 | 2019-09-20 16:28:13 -0700 | [diff] [blame] | 81 | import android.os.RemoteException; |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 82 | import android.os.SystemClock; |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 83 | import android.platform.test.annotations.Presubmit; |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 84 | import android.util.DisplayMetrics; |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 85 | import android.view.DisplayCutout; |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 86 | import android.view.Gravity; |
Evan Rosky | 69cace4 | 2019-09-20 16:28:13 -0700 | [diff] [blame] | 87 | import android.view.IDisplayWindowRotationCallback; |
| 88 | import android.view.IDisplayWindowRotationController; |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 89 | import android.view.ISystemGestureExclusionListener; |
Garfield Tan | a3f1903 | 2019-11-19 18:04:50 -0800 | [diff] [blame] | 90 | import android.view.IWindowManager; |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 91 | import android.view.MotionEvent; |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 92 | import android.view.Surface; |
Riddle Hsu | 3d0aa4f | 2020-04-09 17:58:50 +0800 | [diff] [blame^] | 93 | import android.view.SurfaceControl.Transaction; |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 94 | import android.view.ViewRootImpl; |
Riddle Hsu | 12c0545 | 2020-01-09 00:39:52 +0800 | [diff] [blame] | 95 | import android.view.WindowManager; |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 96 | import android.view.test.InsetsModeSession; |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 97 | |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 98 | import androidx.test.filters.SmallTest; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 99 | |
Susi Kharraz-Post | 9893b8c | 2019-02-12 14:21:29 -0500 | [diff] [blame] | 100 | import com.android.internal.logging.MetricsLogger; |
| 101 | import com.android.internal.logging.nano.MetricsProto; |
Adrian Roos | 6a4fa0e | 2018-03-05 19:50:16 +0100 | [diff] [blame] | 102 | import com.android.server.wm.utils.WmDisplayCutout; |
| 103 | |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 104 | import org.junit.Test; |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 105 | import org.junit.runner.RunWith; |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 106 | import org.mockito.ArgumentCaptor; |
Susi Kharraz-Post | 9893b8c | 2019-02-12 14:21:29 -0500 | [diff] [blame] | 107 | import org.mockito.Mockito; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 108 | |
Adrian Roos | 0f9368c | 2018-04-08 10:59:08 -0700 | [diff] [blame] | 109 | import java.util.ArrayList; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 110 | import java.util.Arrays; |
Adrian Roos | 0f9368c | 2018-04-08 10:59:08 -0700 | [diff] [blame] | 111 | import java.util.Collections; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 112 | import java.util.LinkedList; |
| 113 | import java.util.List; |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 114 | |
| 115 | /** |
| 116 | * Tests for the {@link DisplayContent} class. |
| 117 | * |
| 118 | * Build/Install/Run: |
Yunfan Chen | 6dd9a62 | 2019-02-18 15:12:33 +0900 | [diff] [blame] | 119 | * atest WmTests:DisplayContentTests |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 120 | */ |
| 121 | @SmallTest |
| 122 | @Presubmit |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 123 | @RunWith(WindowTestRunner.class) |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 124 | public class DisplayContentTests extends WindowTestsBase { |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 125 | |
| 126 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 127 | public void testForAllWindows() { |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 128 | final WindowState exitingAppWindow = createWindow(null, TYPE_BASE_APPLICATION, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 129 | mDisplayContent, "exiting app"); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 130 | final ActivityRecord exitingApp = exitingAppWindow.mActivityRecord; |
Yunfan Chen | 6dd9a62 | 2019-02-18 15:12:33 +0900 | [diff] [blame] | 131 | // Wait until everything in animation handler get executed to prevent the exiting window |
| 132 | // from being removed during WindowSurfacePlacer Traversal. |
| 133 | waitUntilHandlersIdle(); |
| 134 | |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 135 | exitingApp.mIsExiting = true; |
Wale Ogunwale | 0b3d292 | 2019-12-30 08:55:07 -0800 | [diff] [blame] | 136 | exitingApp.getTask().getStack().mExitingActivities.add(exitingApp); |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 137 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 138 | assertForAllWindowsOrder(Arrays.asList( |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 139 | mWallpaperWindow, |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 140 | exitingAppWindow, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 141 | mChildAppWindowBelow, |
| 142 | mAppWindow, |
| 143 | mChildAppWindowAbove, |
| 144 | mDockedDividerWindow, |
Adrian Roos | 22a20a8 | 2019-10-23 19:05:33 +0200 | [diff] [blame] | 145 | mImeWindow, |
| 146 | mImeDialogWindow, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 147 | mStatusBarWindow, |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 148 | mNotificationShadeWindow, |
Adrian Roos | 22a20a8 | 2019-10-23 19:05:33 +0200 | [diff] [blame] | 149 | mNavBarWindow)); |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 153 | public void testForAllWindows_WithAppImeTarget() { |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 154 | final WindowState imeAppTarget = |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 155 | createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "imeAppTarget"); |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 156 | |
lumark | ff0ab69 | 2018-11-05 20:32:30 +0800 | [diff] [blame] | 157 | mDisplayContent.mInputMethodTarget = imeAppTarget; |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 158 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 159 | assertForAllWindowsOrder(Arrays.asList( |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 160 | mWallpaperWindow, |
| 161 | mChildAppWindowBelow, |
| 162 | mAppWindow, |
| 163 | mChildAppWindowAbove, |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 164 | imeAppTarget, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 165 | mImeWindow, |
| 166 | mImeDialogWindow, |
| 167 | mDockedDividerWindow, |
| 168 | mStatusBarWindow, |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 169 | mNotificationShadeWindow, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 170 | mNavBarWindow)); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 171 | } |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 172 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 173 | @Test |
lumark | ff0ab69 | 2018-11-05 20:32:30 +0800 | [diff] [blame] | 174 | public void testForAllWindows_WithChildWindowImeTarget() throws Exception { |
| 175 | mDisplayContent.mInputMethodTarget = mChildAppWindowAbove; |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 176 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 177 | assertForAllWindowsOrder(Arrays.asList( |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 178 | mWallpaperWindow, |
| 179 | mChildAppWindowBelow, |
| 180 | mAppWindow, |
| 181 | mChildAppWindowAbove, |
| 182 | mImeWindow, |
| 183 | mImeDialogWindow, |
| 184 | mDockedDividerWindow, |
| 185 | mStatusBarWindow, |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 186 | mNotificationShadeWindow, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 187 | mNavBarWindow)); |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 188 | } |
Wale Ogunwale | 5d7e7f1 | 2016-12-12 14:47:05 -0800 | [diff] [blame] | 189 | |
| 190 | @Test |
lumark | ff0ab69 | 2018-11-05 20:32:30 +0800 | [diff] [blame] | 191 | public void testForAllWindows_WithStatusBarImeTarget() throws Exception { |
| 192 | mDisplayContent.mInputMethodTarget = mStatusBarWindow; |
Wale Ogunwale | 6ce0fb8 | 2016-12-13 14:24:00 -0800 | [diff] [blame] | 193 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 194 | assertForAllWindowsOrder(Arrays.asList( |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 195 | mWallpaperWindow, |
| 196 | mChildAppWindowBelow, |
| 197 | mAppWindow, |
| 198 | mChildAppWindowAbove, |
| 199 | mDockedDividerWindow, |
| 200 | mStatusBarWindow, |
| 201 | mImeWindow, |
| 202 | mImeDialogWindow, |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 203 | mNotificationShadeWindow, |
| 204 | mNavBarWindow)); |
| 205 | } |
| 206 | |
| 207 | @Test |
| 208 | public void testForAllWindows_WithNotificationShadeImeTarget() throws Exception { |
| 209 | mDisplayContent.mInputMethodTarget = mNotificationShadeWindow; |
| 210 | |
| 211 | assertForAllWindowsOrder(Arrays.asList( |
| 212 | mWallpaperWindow, |
| 213 | mChildAppWindowBelow, |
| 214 | mAppWindow, |
| 215 | mChildAppWindowAbove, |
| 216 | mDockedDividerWindow, |
| 217 | mStatusBarWindow, |
| 218 | mNotificationShadeWindow, |
| 219 | mImeWindow, |
| 220 | mImeDialogWindow, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 221 | mNavBarWindow)); |
Wale Ogunwale | 6ce0fb8 | 2016-12-13 14:24:00 -0800 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 225 | public void testForAllWindows_WithInBetweenWindowToken() { |
Wale Ogunwale | 5d7e7f1 | 2016-12-12 14:47:05 -0800 | [diff] [blame] | 226 | // This window is set-up to be z-ordered between some windows that go in the same token like |
| 227 | // the nav bar and status bar. |
| 228 | final WindowState voiceInteractionWindow = createWindow(null, TYPE_VOICE_INTERACTION, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 229 | mDisplayContent, "voiceInteractionWindow"); |
Wale Ogunwale | 5d7e7f1 | 2016-12-12 14:47:05 -0800 | [diff] [blame] | 230 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 231 | assertForAllWindowsOrder(Arrays.asList( |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 232 | mWallpaperWindow, |
| 233 | mChildAppWindowBelow, |
| 234 | mAppWindow, |
| 235 | mChildAppWindowAbove, |
| 236 | mDockedDividerWindow, |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 237 | voiceInteractionWindow, |
Adrian Roos | 22a20a8 | 2019-10-23 19:05:33 +0200 | [diff] [blame] | 238 | mImeWindow, |
| 239 | mImeDialogWindow, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 240 | mStatusBarWindow, |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 241 | mNotificationShadeWindow, |
Adrian Roos | 22a20a8 | 2019-10-23 19:05:33 +0200 | [diff] [blame] | 242 | mNavBarWindow)); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 243 | } |
Wale Ogunwale | 5d7e7f1 | 2016-12-12 14:47:05 -0800 | [diff] [blame] | 244 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 245 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 246 | public void testComputeImeTarget() { |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 247 | // Verify that an app window can be an ime target. |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 248 | final WindowState appWin = createWindow(null, TYPE_APPLICATION, mDisplayContent, "appWin"); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 249 | appWin.setHasSurface(true); |
| 250 | assertTrue(appWin.canBeImeTarget()); |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 251 | WindowState imeTarget = mDisplayContent.computeImeTarget(false /* updateImeTarget */); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 252 | assertEquals(appWin, imeTarget); |
chaviw | ebcbc34 | 2018-02-07 13:19:00 -0800 | [diff] [blame] | 253 | appWin.mHidden = false; |
Wale Ogunwale | 5d7e7f1 | 2016-12-12 14:47:05 -0800 | [diff] [blame] | 254 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 255 | // Verify that an child window can be an ime target. |
| 256 | final WindowState childWin = createWindow(appWin, |
| 257 | TYPE_APPLICATION_ATTACHED_DIALOG, "childWin"); |
| 258 | childWin.setHasSurface(true); |
| 259 | assertTrue(childWin.canBeImeTarget()); |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 260 | imeTarget = mDisplayContent.computeImeTarget(false /* updateImeTarget */); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 261 | assertEquals(childWin, imeTarget); |
Wale Ogunwale | 5d7e7f1 | 2016-12-12 14:47:05 -0800 | [diff] [blame] | 262 | } |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 263 | |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 264 | /** |
| 265 | * This tests stack movement between displays and proper stack's, task's and app token's display |
| 266 | * container references updates. |
| 267 | */ |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 268 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 269 | public void testMoveStackBetweenDisplays() { |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 270 | // Create a second display. |
| 271 | final DisplayContent dc = createNewDisplay(); |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 272 | |
| 273 | // Add stack with activity. |
Wale Ogunwale | bebd8cd | 2019-10-28 15:53:31 -0700 | [diff] [blame] | 274 | final ActivityStack stack = createTaskStackOnDisplay(dc); |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 275 | assertEquals(dc.getDisplayId(), stack.getDisplayContent().getDisplayId()); |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 276 | assertEquals(dc, stack.getDisplayContent()); |
| 277 | |
| 278 | final Task task = createTaskInStack(stack, 0 /* userId */); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 279 | final ActivityRecord activity = WindowTestUtils.createTestActivityRecord(dc); |
| 280 | task.addChild(activity, 0); |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 281 | assertEquals(dc, task.getDisplayContent()); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 282 | assertEquals(dc, activity.getDisplayContent()); |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 283 | |
| 284 | // Move stack to first display. |
Andrii Kulian | 4c0fd0d | 2020-03-29 13:32:14 -0700 | [diff] [blame] | 285 | stack.reparent(mDisplayContent.getDefaultTaskDisplayArea(), true /* onTop */); |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 286 | assertEquals(mDisplayContent.getDisplayId(), stack.getDisplayContent().getDisplayId()); |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 287 | assertEquals(mDisplayContent, stack.getDisplayContent()); |
| 288 | assertEquals(mDisplayContent, task.getDisplayContent()); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 289 | assertEquals(mDisplayContent, activity.getDisplayContent()); |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 290 | } |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 291 | |
| 292 | /** |
| 293 | * This tests override configuration updates for display content. |
| 294 | */ |
| 295 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 296 | public void testDisplayOverrideConfigUpdate() { |
Evan Rosky | dfe3da7 | 2018-10-26 17:21:06 -0700 | [diff] [blame] | 297 | final Configuration currentOverrideConfig = |
| 298 | mDisplayContent.getRequestedOverrideConfiguration(); |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 299 | |
| 300 | // Create new, slightly changed override configuration and apply it to the display. |
| 301 | final Configuration newOverrideConfig = new Configuration(currentOverrideConfig); |
| 302 | newOverrideConfig.densityDpi += 120; |
| 303 | newOverrideConfig.fontScale += 0.3; |
| 304 | |
Evan Rosky | e747c3e | 2018-10-30 20:06:41 -0700 | [diff] [blame] | 305 | mWm.setNewDisplayOverrideConfiguration(newOverrideConfig, mDisplayContent); |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 306 | |
| 307 | // Check that override config is applied. |
Evan Rosky | dfe3da7 | 2018-10-26 17:21:06 -0700 | [diff] [blame] | 308 | assertEquals(newOverrideConfig, mDisplayContent.getRequestedOverrideConfiguration()); |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | /** |
| 312 | * This tests global configuration updates when default display config is updated. |
| 313 | */ |
| 314 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 315 | public void testDefaultDisplayOverrideConfigUpdate() { |
Evan Rosky | e747c3e | 2018-10-30 20:06:41 -0700 | [diff] [blame] | 316 | DisplayContent defaultDisplay = mWm.mRoot.getDisplayContent(DEFAULT_DISPLAY); |
| 317 | final Configuration currentConfig = defaultDisplay.getConfiguration(); |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 318 | |
| 319 | // Create new, slightly changed override configuration and apply it to the display. |
Andrii Kulian | a95bfff | 2017-03-30 19:00:41 -0700 | [diff] [blame] | 320 | final Configuration newOverrideConfig = new Configuration(currentConfig); |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 321 | newOverrideConfig.densityDpi += 120; |
| 322 | newOverrideConfig.fontScale += 0.3; |
| 323 | |
Evan Rosky | e747c3e | 2018-10-30 20:06:41 -0700 | [diff] [blame] | 324 | mWm.setNewDisplayOverrideConfiguration(newOverrideConfig, defaultDisplay); |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 325 | |
| 326 | // Check that global configuration is updated, as we've updated default display's config. |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 327 | Configuration globalConfig = mWm.mRoot.getConfiguration(); |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 328 | assertEquals(newOverrideConfig.densityDpi, globalConfig.densityDpi); |
| 329 | assertEquals(newOverrideConfig.fontScale, globalConfig.fontScale, 0.1 /* delta */); |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 330 | |
| 331 | // Return back to original values. |
Evan Rosky | e747c3e | 2018-10-30 20:06:41 -0700 | [diff] [blame] | 332 | mWm.setNewDisplayOverrideConfiguration(currentConfig, defaultDisplay); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 333 | globalConfig = mWm.mRoot.getConfiguration(); |
Andrii Kulian | a95bfff | 2017-03-30 19:00:41 -0700 | [diff] [blame] | 334 | assertEquals(currentConfig.densityDpi, globalConfig.densityDpi); |
| 335 | assertEquals(currentConfig.fontScale, globalConfig.fontScale, 0.1 /* delta */); |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 336 | } |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 337 | |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 338 | /** |
| 339 | * Tests tapping on a stack in different display results in window gaining focus. |
| 340 | */ |
| 341 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 342 | public void testInputEventBringsCorrectDisplayInFocus() { |
| 343 | DisplayContent dc0 = mWm.getDefaultDisplayContentLocked(); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 344 | // Create a second display |
| 345 | final DisplayContent dc1 = createNewDisplay(); |
| 346 | |
| 347 | // Add stack with activity. |
Wale Ogunwale | bebd8cd | 2019-10-28 15:53:31 -0700 | [diff] [blame] | 348 | final ActivityStack stack0 = createTaskStackOnDisplay(dc0); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 349 | final Task task0 = createTaskInStack(stack0, 0 /* userId */); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 350 | final ActivityRecord activity = |
| 351 | WindowTestUtils.createTestActivityRecord(dc0); |
| 352 | task0.addChild(activity, 0); |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 353 | dc0.configureDisplayPolicy(); |
| 354 | assertNotNull(dc0.mTapDetector); |
| 355 | |
Wale Ogunwale | bebd8cd | 2019-10-28 15:53:31 -0700 | [diff] [blame] | 356 | final ActivityStack stack1 = createTaskStackOnDisplay(dc1); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 357 | final Task task1 = createTaskInStack(stack1, 0 /* userId */); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 358 | final ActivityRecord activity1 = |
| 359 | WindowTestUtils.createTestActivityRecord(dc0); |
| 360 | task1.addChild(activity1, 0); |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 361 | dc1.configureDisplayPolicy(); |
| 362 | assertNotNull(dc1.mTapDetector); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 363 | |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 364 | // tap on primary display. |
| 365 | tapOnDisplay(dc0); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 366 | // Check focus is on primary display. |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 367 | assertEquals(mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus, |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 368 | dc0.findFocusedWindow()); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 369 | |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 370 | // Tap on secondary display. |
| 371 | tapOnDisplay(dc1); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 372 | // Check focus is on secondary. |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 373 | assertEquals(mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus, |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 374 | dc1.findFocusedWindow()); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 375 | } |
| 376 | |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 377 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 378 | public void testFocusedWindowMultipleDisplays() { |
Tiger Huang | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 379 | doTestFocusedWindowMultipleDisplays(false /* perDisplayFocusEnabled */, Q); |
| 380 | } |
| 381 | |
| 382 | @Test |
| 383 | public void testFocusedWindowMultipleDisplaysPerDisplayFocusEnabled() { |
| 384 | doTestFocusedWindowMultipleDisplays(true /* perDisplayFocusEnabled */, Q); |
| 385 | } |
| 386 | |
| 387 | @Test |
| 388 | public void testFocusedWindowMultipleDisplaysPerDisplayFocusEnabledLegacyApp() { |
| 389 | doTestFocusedWindowMultipleDisplays(true /* perDisplayFocusEnabled */, P); |
| 390 | } |
| 391 | |
| 392 | private void doTestFocusedWindowMultipleDisplays(boolean perDisplayFocusEnabled, |
| 393 | int targetSdk) { |
| 394 | mWm.mPerDisplayFocusEnabled = perDisplayFocusEnabled; |
| 395 | |
Andrii Kulian | 0214ed9 | 2017-05-16 13:44:05 -0700 | [diff] [blame] | 396 | // Create a focusable window and check that focus is calculated correctly |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 397 | final WindowState window1 = |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 398 | createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "window1"); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 399 | window1.mActivityRecord.mTargetSdk = targetSdk; |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 400 | updateFocusedWindow(); |
| 401 | assertTrue(window1.isFocused()); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 402 | assertEquals(window1, mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus); |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 403 | |
| 404 | // Check that a new display doesn't affect focus |
| 405 | final DisplayContent dc = createNewDisplay(); |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 406 | updateFocusedWindow(); |
| 407 | assertTrue(window1.isFocused()); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 408 | assertEquals(window1, mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus); |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 409 | |
| 410 | // Add a window to the second display, and it should be focused |
| 411 | final WindowState window2 = createWindow(null, TYPE_BASE_APPLICATION, dc, "window2"); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 412 | window2.mActivityRecord.mTargetSdk = targetSdk; |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 413 | updateFocusedWindow(); |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 414 | assertTrue(window2.isFocused()); |
Tiger Huang | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 415 | assertEquals(perDisplayFocusEnabled && targetSdk >= Q, window1.isFocused()); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 416 | assertEquals(window2, mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus); |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 417 | |
Tiger Huang | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 418 | // Move the first window to top including parents, and make sure focus is updated |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 419 | window1.getParent().positionChildAt(POSITION_TOP, window1, true); |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 420 | updateFocusedWindow(); |
| 421 | assertTrue(window1.isFocused()); |
Tiger Huang | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 422 | assertEquals(perDisplayFocusEnabled && targetSdk >= Q, window2.isFocused()); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 423 | assertEquals(window1, mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus); |
Louis Chang | a9350fe | 2019-04-25 17:14:20 +0800 | [diff] [blame] | 424 | |
| 425 | // Make sure top focused display not changed if there is a focused app. |
Issei Suzuki | 1669ea4 | 2019-11-06 14:20:59 +0100 | [diff] [blame] | 426 | window1.mActivityRecord.mVisibleRequested = false; |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 427 | window1.getDisplayContent().setFocusedApp(window1.mActivityRecord); |
Louis Chang | a9350fe | 2019-04-25 17:14:20 +0800 | [diff] [blame] | 428 | updateFocusedWindow(); |
| 429 | assertTrue(!window1.isFocused()); |
| 430 | assertEquals(window1.getDisplayId(), |
| 431 | mWm.mRoot.getTopFocusedDisplayContent().getDisplayId()); |
Adrian Roos | 4163d62 | 2018-05-22 16:56:35 +0200 | [diff] [blame] | 432 | } |
| 433 | |
Riddle Hsu | b2297ad | 2019-07-26 23:37:25 -0600 | [diff] [blame] | 434 | @Test |
| 435 | public void testShouldWaitForSystemDecorWindowsOnBoot_OnDefaultDisplay() { |
| 436 | mWm.mSystemBooted = true; |
| 437 | final DisplayContent defaultDisplay = mWm.getDefaultDisplayContentLocked(); |
| 438 | final WindowState[] windows = createNotDrawnWindowsOn(defaultDisplay, |
| 439 | TYPE_WALLPAPER, TYPE_APPLICATION); |
| 440 | |
| 441 | // Verify waiting for windows to be drawn. |
| 442 | assertTrue(defaultDisplay.shouldWaitForSystemDecorWindowsOnBoot()); |
| 443 | |
| 444 | // Verify not waiting for drawn windows. |
| 445 | makeWindowsDrawn(windows); |
| 446 | assertFalse(defaultDisplay.shouldWaitForSystemDecorWindowsOnBoot()); |
| 447 | } |
| 448 | |
| 449 | @Test |
| 450 | public void testShouldWaitForSystemDecorWindowsOnBoot_OnSecondaryDisplay() { |
| 451 | mWm.mSystemBooted = true; |
| 452 | final DisplayContent secondaryDisplay = createNewDisplay(); |
| 453 | final WindowState[] windows = createNotDrawnWindowsOn(secondaryDisplay, |
| 454 | TYPE_WALLPAPER, TYPE_APPLICATION); |
| 455 | |
| 456 | // Verify not waiting for display without system decorations. |
| 457 | doReturn(false).when(secondaryDisplay).supportsSystemDecorations(); |
| 458 | assertFalse(secondaryDisplay.shouldWaitForSystemDecorWindowsOnBoot()); |
| 459 | |
| 460 | // Verify waiting for non-drawn windows on display with system decorations. |
| 461 | reset(secondaryDisplay); |
| 462 | doReturn(true).when(secondaryDisplay).supportsSystemDecorations(); |
| 463 | assertTrue(secondaryDisplay.shouldWaitForSystemDecorWindowsOnBoot()); |
| 464 | |
| 465 | // Verify not waiting for drawn windows on display with system decorations. |
| 466 | makeWindowsDrawn(windows); |
| 467 | assertFalse(secondaryDisplay.shouldWaitForSystemDecorWindowsOnBoot()); |
| 468 | } |
| 469 | |
| 470 | private WindowState[] createNotDrawnWindowsOn(DisplayContent displayContent, int... types) { |
| 471 | final WindowState[] windows = new WindowState[types.length]; |
| 472 | for (int i = 0; i < types.length; i++) { |
| 473 | final int type = types[i]; |
| 474 | windows[i] = createWindow(null /* parent */, type, displayContent, "window-" + type); |
| 475 | windows[i].mHasSurface = false; |
| 476 | } |
| 477 | return windows; |
| 478 | } |
| 479 | |
| 480 | private static void makeWindowsDrawn(WindowState[] windows) { |
| 481 | for (WindowState window : windows) { |
| 482 | window.mHasSurface = true; |
| 483 | window.mWinAnimator.mDrawState = WindowStateAnimator.HAS_DRAWN; |
| 484 | } |
| 485 | } |
| 486 | |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 487 | /** |
| 488 | * This tests setting the maximum ui width on a display. |
| 489 | */ |
| 490 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 491 | public void testMaxUiWidth() { |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 492 | // Prevent base display metrics for test from being updated to the value of real display. |
| 493 | final DisplayContent displayContent = createDisplayNoUpdateDisplayInfo(); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 494 | final int baseWidth = 1440; |
| 495 | final int baseHeight = 2560; |
| 496 | final int baseDensity = 300; |
| 497 | |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 498 | displayContent.updateBaseDisplayMetrics(baseWidth, baseHeight, baseDensity); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 499 | |
| 500 | final int maxWidth = 300; |
| 501 | final int resultingHeight = (maxWidth * baseHeight) / baseWidth; |
| 502 | final int resultingDensity = (maxWidth * baseDensity) / baseWidth; |
| 503 | |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 504 | displayContent.setMaxUiWidth(maxWidth); |
| 505 | verifySizes(displayContent, maxWidth, resultingHeight, resultingDensity); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 506 | |
| 507 | // Assert setting values again does not change; |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 508 | displayContent.updateBaseDisplayMetrics(baseWidth, baseHeight, baseDensity); |
| 509 | verifySizes(displayContent, maxWidth, resultingHeight, resultingDensity); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 510 | |
| 511 | final int smallerWidth = 200; |
| 512 | final int smallerHeight = 400; |
| 513 | final int smallerDensity = 100; |
| 514 | |
| 515 | // Specify smaller dimension, verify that it is honored |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 516 | displayContent.updateBaseDisplayMetrics(smallerWidth, smallerHeight, smallerDensity); |
| 517 | verifySizes(displayContent, smallerWidth, smallerHeight, smallerDensity); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 518 | |
| 519 | // Verify that setting the max width to a greater value than the base width has no effect |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 520 | displayContent.setMaxUiWidth(maxWidth); |
| 521 | verifySizes(displayContent, smallerWidth, smallerHeight, smallerDensity); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 522 | } |
| 523 | |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 524 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 525 | public void testDisplayCutout_rot0() { |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 526 | final DisplayContent dc = createNewDisplay(); |
| 527 | dc.mInitialDisplayWidth = 200; |
| 528 | dc.mInitialDisplayHeight = 400; |
| 529 | final Rect r = new Rect(80, 0, 120, 10); |
| 530 | final DisplayCutout cutout = new WmDisplayCutout( |
| 531 | fromBoundingRect(r.left, r.top, r.right, r.bottom, BOUNDS_POSITION_TOP), null) |
| 532 | .computeSafeInsets(200, 400).getDisplayCutout(); |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 533 | |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 534 | dc.mInitialDisplayCutout = cutout; |
| 535 | dc.getDisplayRotation().setRotation(Surface.ROTATION_0); |
| 536 | dc.computeScreenConfiguration(new Configuration()); // recomputes dc.mDisplayInfo. |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 537 | |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 538 | assertEquals(cutout, dc.getDisplayInfo().displayCutout); |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 542 | public void testDisplayCutout_rot90() { |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 543 | // Prevent mInitialDisplayCutout from being updated from real display (e.g. null |
| 544 | // if the device has no cutout). |
| 545 | final DisplayContent dc = createDisplayNoUpdateDisplayInfo(); |
Garfield Tan | 7cb3014 | 2019-12-20 16:43:06 -0800 | [diff] [blame] | 546 | // This test assumes it's a top cutout on a portrait display, so if it happens to be a |
| 547 | // landscape display let's rotate it. |
| 548 | if (dc.mInitialDisplayHeight < dc.mInitialDisplayWidth) { |
| 549 | int tmp = dc.mInitialDisplayHeight; |
| 550 | dc.mInitialDisplayHeight = dc.mInitialDisplayWidth; |
| 551 | dc.mInitialDisplayWidth = tmp; |
| 552 | } |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 553 | // Rotation may use real display info to compute bound, so here also uses the |
| 554 | // same width and height. |
| 555 | final int displayWidth = dc.mInitialDisplayWidth; |
| 556 | final int displayHeight = dc.mInitialDisplayHeight; |
| 557 | final int cutoutWidth = 40; |
| 558 | final int cutoutHeight = 10; |
| 559 | final int left = (displayWidth - cutoutWidth) / 2; |
| 560 | final int top = 0; |
| 561 | final int right = (displayWidth + cutoutWidth) / 2; |
| 562 | final int bottom = cutoutHeight; |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 563 | |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 564 | final Rect r1 = new Rect(left, top, right, bottom); |
| 565 | final DisplayCutout cutout = new WmDisplayCutout( |
| 566 | fromBoundingRect(r1.left, r1.top, r1.right, r1.bottom, BOUNDS_POSITION_TOP), null) |
| 567 | .computeSafeInsets(displayWidth, displayHeight).getDisplayCutout(); |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 568 | |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 569 | dc.mInitialDisplayCutout = cutout; |
| 570 | dc.getDisplayRotation().setRotation(Surface.ROTATION_90); |
| 571 | dc.computeScreenConfiguration(new Configuration()); // recomputes dc.mDisplayInfo. |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 572 | |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 573 | // ----o---------- ------------- |
| 574 | // | | | | | |
| 575 | // | ------o | o--- |
| 576 | // | | | | |
| 577 | // | | -> | | |
| 578 | // | | ---o |
| 579 | // | | | |
| 580 | // | | ------------- |
| 581 | final Rect r = new Rect(top, left, bottom, right); |
| 582 | assertEquals(new WmDisplayCutout( |
| 583 | fromBoundingRect(r.left, r.top, r.right, r.bottom, BOUNDS_POSITION_LEFT), null) |
| 584 | .computeSafeInsets(displayHeight, displayWidth).getDisplayCutout(), |
| 585 | dc.getDisplayInfo().displayCutout); |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 589 | public void testLayoutSeq_assignedDuringLayout() { |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 590 | final DisplayContent dc = createNewDisplay(); |
| 591 | final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, dc, "w"); |
Adrian Roos | 5251b1d | 2018-03-23 18:57:43 +0100 | [diff] [blame] | 592 | |
Riddle Hsu | 12c0545 | 2020-01-09 00:39:52 +0800 | [diff] [blame] | 593 | performLayout(dc); |
Adrian Roos | 5251b1d | 2018-03-23 18:57:43 +0100 | [diff] [blame] | 594 | |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 595 | assertThat(win.mLayoutSeq, is(dc.mLayoutSeq)); |
Adrian Roos | 5251b1d | 2018-03-23 18:57:43 +0100 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | @Test |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 599 | @SuppressLint("InlinedApi") |
| 600 | public void testOrientationDefinedByKeyguard() { |
| 601 | final DisplayContent dc = createNewDisplay(); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 602 | |
| 603 | // When display content is created its configuration is not yet initialized, which could |
| 604 | // cause unnecessary configuration propagation, so initialize it here. |
| 605 | final Configuration config = new Configuration(); |
| 606 | dc.computeScreenConfiguration(config); |
| 607 | dc.onRequestedOverrideConfigurationChanged(config); |
| 608 | |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 609 | // Create a window that requests landscape orientation. It will define device orientation |
| 610 | // by default. |
| 611 | final WindowState window = createWindow(null /* parent */, TYPE_BASE_APPLICATION, dc, "w"); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 612 | window.mActivityRecord.setOrientation(SCREEN_ORIENTATION_LANDSCAPE); |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 613 | |
wilsonshih | e832194 | 2019-10-18 18:39:46 +0800 | [diff] [blame] | 614 | final WindowState keyguard = createWindow(null, TYPE_NOTIFICATION_SHADE , dc, "keyguard"); |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 615 | keyguard.mHasSurface = true; |
| 616 | keyguard.mAttrs.screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED; |
| 617 | |
| 618 | assertEquals("Screen orientation must be defined by the app window by default", |
| 619 | SCREEN_ORIENTATION_LANDSCAPE, dc.getOrientation()); |
| 620 | |
| 621 | keyguard.mAttrs.screenOrientation = SCREEN_ORIENTATION_PORTRAIT; |
| 622 | assertEquals("Visible keyguard must influence device orientation", |
| 623 | SCREEN_ORIENTATION_PORTRAIT, dc.getOrientation()); |
| 624 | |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 625 | mWm.setKeyguardGoingAway(true); |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 626 | assertEquals("Keyguard that is going away must not influence device orientation", |
| 627 | SCREEN_ORIENTATION_LANDSCAPE, dc.getOrientation()); |
| 628 | } |
| 629 | |
Andrii Kulian | f0379de | 2018-03-14 16:24:07 -0700 | [diff] [blame] | 630 | @Test |
Tiger Huang | 86e6d07 | 2019-05-02 20:23:47 +0800 | [diff] [blame] | 631 | public void testOrientationForAspectRatio() { |
| 632 | final DisplayContent dc = createNewDisplay(); |
| 633 | |
| 634 | // When display content is created its configuration is not yet initialized, which could |
| 635 | // cause unnecessary configuration propagation, so initialize it here. |
| 636 | final Configuration config = new Configuration(); |
| 637 | dc.computeScreenConfiguration(config); |
| 638 | dc.onRequestedOverrideConfigurationChanged(config); |
| 639 | |
| 640 | // Create a window that requests a fixed orientation. It will define device orientation |
| 641 | // by default. |
| 642 | final WindowState window = createWindow(null /* parent */, TYPE_APPLICATION_OVERLAY, dc, |
| 643 | "window"); |
| 644 | window.mHasSurface = true; |
| 645 | window.mAttrs.screenOrientation = SCREEN_ORIENTATION_LANDSCAPE; |
| 646 | |
| 647 | // -------------------------------- |
| 648 | // Test non-close-to-square display |
| 649 | // -------------------------------- |
| 650 | dc.mBaseDisplayWidth = 1000; |
| 651 | dc.mBaseDisplayHeight = (int) (dc.mBaseDisplayWidth * dc.mCloseToSquareMaxAspectRatio * 2f); |
| 652 | dc.configureDisplayPolicy(); |
| 653 | |
| 654 | assertEquals("Screen orientation must be defined by the window by default.", |
| 655 | window.mAttrs.screenOrientation, dc.getOrientation()); |
| 656 | |
| 657 | // ---------------------------- |
| 658 | // Test close-to-square display |
| 659 | // ---------------------------- |
| 660 | dc.mBaseDisplayHeight = dc.mBaseDisplayWidth; |
| 661 | dc.configureDisplayPolicy(); |
| 662 | |
| 663 | assertEquals("Screen orientation must be SCREEN_ORIENTATION_USER.", |
| 664 | SCREEN_ORIENTATION_USER, dc.getOrientation()); |
| 665 | } |
| 666 | |
| 667 | @Test |
Andrii Kulian | f0379de | 2018-03-14 16:24:07 -0700 | [diff] [blame] | 668 | public void testDisableDisplayInfoOverrideFromWindowManager() { |
| 669 | final DisplayContent dc = createNewDisplay(); |
| 670 | |
| 671 | assertTrue(dc.mShouldOverrideDisplayConfiguration); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 672 | mWm.dontOverrideDisplayInfo(dc.getDisplayId()); |
Andrii Kulian | f0379de | 2018-03-14 16:24:07 -0700 | [diff] [blame] | 673 | |
| 674 | assertFalse(dc.mShouldOverrideDisplayConfiguration); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 675 | verify(mWm.mDisplayManagerInternal, times(1)) |
Andrii Kulian | f0379de | 2018-03-14 16:24:07 -0700 | [diff] [blame] | 676 | .setDisplayInfoOverrideFromWindowManager(dc.getDisplayId(), null); |
| 677 | } |
| 678 | |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 679 | @Test |
Riddle Hsu | 85bd04b | 2018-11-17 00:34:36 +0800 | [diff] [blame] | 680 | public void testClearLastFocusWhenReparentingFocusedWindow() { |
| 681 | final DisplayContent defaultDisplay = mWm.getDefaultDisplayContentLocked(); |
| 682 | final WindowState window = createWindow(null /* parent */, TYPE_BASE_APPLICATION, |
| 683 | defaultDisplay, "window"); |
| 684 | defaultDisplay.mLastFocus = window; |
| 685 | mDisplayContent.mCurrentFocus = window; |
| 686 | mDisplayContent.reParentWindowToken(window.mToken); |
| 687 | |
| 688 | assertNull(defaultDisplay.mLastFocus); |
| 689 | } |
| 690 | |
| 691 | @Test |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 692 | public void testGetPreferredOptionsPanelGravityFromDifferentDisplays() { |
| 693 | final DisplayContent portraitDisplay = createNewDisplay(); |
| 694 | portraitDisplay.mInitialDisplayHeight = 2000; |
| 695 | portraitDisplay.mInitialDisplayWidth = 1000; |
| 696 | |
Riddle Hsu | ccf0940 | 2019-08-13 00:33:06 +0800 | [diff] [blame] | 697 | portraitDisplay.getDisplayRotation().setRotation(Surface.ROTATION_0); |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 698 | assertFalse(isOptionsPanelAtRight(portraitDisplay.getDisplayId())); |
Evan Rosky | 69cace4 | 2019-09-20 16:28:13 -0700 | [diff] [blame] | 699 | portraitDisplay.getDisplayRotation().setRotation(ROTATION_90); |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 700 | assertTrue(isOptionsPanelAtRight(portraitDisplay.getDisplayId())); |
| 701 | |
| 702 | final DisplayContent landscapeDisplay = createNewDisplay(); |
| 703 | landscapeDisplay.mInitialDisplayHeight = 1000; |
| 704 | landscapeDisplay.mInitialDisplayWidth = 2000; |
| 705 | |
Riddle Hsu | ccf0940 | 2019-08-13 00:33:06 +0800 | [diff] [blame] | 706 | landscapeDisplay.getDisplayRotation().setRotation(Surface.ROTATION_0); |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 707 | assertTrue(isOptionsPanelAtRight(landscapeDisplay.getDisplayId())); |
Evan Rosky | 69cace4 | 2019-09-20 16:28:13 -0700 | [diff] [blame] | 708 | landscapeDisplay.getDisplayRotation().setRotation(ROTATION_90); |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 709 | assertFalse(isOptionsPanelAtRight(landscapeDisplay.getDisplayId())); |
| 710 | } |
| 711 | |
lumark | ff0ab69 | 2018-11-05 20:32:30 +0800 | [diff] [blame] | 712 | @Test |
| 713 | public void testInputMethodTargetUpdateWhenSwitchingOnDisplays() { |
| 714 | final DisplayContent newDisplay = createNewDisplay(); |
| 715 | |
| 716 | final WindowState appWin = createWindow(null, TYPE_APPLICATION, mDisplayContent, "appWin"); |
| 717 | final WindowState appWin1 = createWindow(null, TYPE_APPLICATION, newDisplay, "appWin1"); |
| 718 | appWin.setHasSurface(true); |
| 719 | appWin1.setHasSurface(true); |
| 720 | |
| 721 | // Set current input method window on default display, make sure the input method target |
| 722 | // is appWin & null on the other display. |
| 723 | mDisplayContent.setInputMethodWindowLocked(mImeWindow); |
| 724 | newDisplay.setInputMethodWindowLocked(null); |
Wale Ogunwale | 3198da4 | 2019-10-10 14:45:03 +0200 | [diff] [blame] | 725 | assertEquals("appWin should be IME target window", |
| 726 | appWin, mDisplayContent.mInputMethodTarget); |
lumark | ff0ab69 | 2018-11-05 20:32:30 +0800 | [diff] [blame] | 727 | assertNull("newDisplay Ime target: ", newDisplay.mInputMethodTarget); |
| 728 | |
| 729 | // Switch input method window on new display & make sure the input method target also |
| 730 | // switched as expected. |
| 731 | newDisplay.setInputMethodWindowLocked(mImeWindow); |
| 732 | mDisplayContent.setInputMethodWindowLocked(null); |
Wale Ogunwale | 3198da4 | 2019-10-10 14:45:03 +0200 | [diff] [blame] | 733 | assertEquals("appWin1 should be IME target window", appWin1, newDisplay.mInputMethodTarget); |
lumark | ff0ab69 | 2018-11-05 20:32:30 +0800 | [diff] [blame] | 734 | assertNull("default display Ime target: ", mDisplayContent.mInputMethodTarget); |
| 735 | } |
| 736 | |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 737 | @Test |
Garfield Tan | 98eead3 | 2019-11-18 13:24:53 -0800 | [diff] [blame] | 738 | public void testAllowsTopmostFullscreenOrientation() { |
| 739 | final DisplayContent dc = createNewDisplay(); |
| 740 | dc.getDisplayRotation().setFixedToUserRotation( |
Garfield Tan | a3f1903 | 2019-11-19 18:04:50 -0800 | [diff] [blame] | 741 | IWindowManager.FIXED_TO_USER_ROTATION_DISABLED); |
Garfield Tan | 98eead3 | 2019-11-18 13:24:53 -0800 | [diff] [blame] | 742 | |
| 743 | final ActivityStack stack = |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 744 | new ActivityTestsBase.StackBuilder(mWm.mAtmService.mRootWindowContainer) |
Louis Chang | 2453d06 | 2019-11-19 22:30:48 +0800 | [diff] [blame] | 745 | .setDisplay(dc) |
Garfield Tan | 98eead3 | 2019-11-18 13:24:53 -0800 | [diff] [blame] | 746 | .build(); |
| 747 | doReturn(true).when(stack).isVisible(); |
| 748 | |
| 749 | final ActivityStack freeformStack = |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 750 | new ActivityTestsBase.StackBuilder(mWm.mAtmService.mRootWindowContainer) |
Louis Chang | 2453d06 | 2019-11-19 22:30:48 +0800 | [diff] [blame] | 751 | .setDisplay(dc) |
Garfield Tan | 98eead3 | 2019-11-18 13:24:53 -0800 | [diff] [blame] | 752 | .setWindowingMode(WINDOWING_MODE_FREEFORM) |
| 753 | .build(); |
| 754 | doReturn(true).when(freeformStack).isVisible(); |
| 755 | freeformStack.getTopChild().setBounds(100, 100, 300, 400); |
| 756 | |
Andrii Kulian | 4c0fd0d | 2020-03-29 13:32:14 -0700 | [diff] [blame] | 757 | assertTrue(dc.getDefaultTaskDisplayArea().isStackVisible(WINDOWING_MODE_FREEFORM)); |
Garfield Tan | 98eead3 | 2019-11-18 13:24:53 -0800 | [diff] [blame] | 758 | |
| 759 | freeformStack.getTopNonFinishingActivity().setOrientation(SCREEN_ORIENTATION_LANDSCAPE); |
| 760 | stack.getTopNonFinishingActivity().setOrientation(SCREEN_ORIENTATION_PORTRAIT); |
| 761 | assertEquals(SCREEN_ORIENTATION_PORTRAIT, dc.getOrientation()); |
| 762 | |
| 763 | stack.getTopNonFinishingActivity().setOrientation(SCREEN_ORIENTATION_LANDSCAPE); |
| 764 | freeformStack.getTopNonFinishingActivity().setOrientation(SCREEN_ORIENTATION_PORTRAIT); |
| 765 | assertEquals(SCREEN_ORIENTATION_LANDSCAPE, dc.getOrientation()); |
| 766 | } |
| 767 | |
| 768 | @Test |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 769 | public void testOnDescendantOrientationRequestChanged() { |
Garfield Tan | 49dae10 | 2019-02-04 09:51:59 -0800 | [diff] [blame] | 770 | final DisplayContent dc = createNewDisplay(); |
Wale Ogunwale | 8a1860a | 2019-06-05 08:57:19 -0700 | [diff] [blame] | 771 | dc.getDisplayRotation().setFixedToUserRotation( |
Garfield Tan | a3f1903 | 2019-11-19 18:04:50 -0800 | [diff] [blame] | 772 | IWindowManager.FIXED_TO_USER_ROTATION_DISABLED); |
Garfield Tan | 49dae10 | 2019-02-04 09:51:59 -0800 | [diff] [blame] | 773 | final int newOrientation = dc.getLastOrientation() == SCREEN_ORIENTATION_LANDSCAPE |
| 774 | ? SCREEN_ORIENTATION_PORTRAIT |
| 775 | : SCREEN_ORIENTATION_LANDSCAPE; |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 776 | |
Wale Ogunwale | 8a1860a | 2019-06-05 08:57:19 -0700 | [diff] [blame] | 777 | final ActivityStack stack = |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 778 | new ActivityTestsBase.StackBuilder(mWm.mAtmService.mRootWindowContainer) |
Louis Chang | 2453d06 | 2019-11-19 22:30:48 +0800 | [diff] [blame] | 779 | .setDisplay(dc).build(); |
Wale Ogunwale | 85fb19a | 2019-12-05 10:41:05 +0900 | [diff] [blame] | 780 | final ActivityRecord activity = stack.getTopMostTask().getTopNonFinishingActivity(); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 781 | |
Wale Ogunwale | 8a1860a | 2019-06-05 08:57:19 -0700 | [diff] [blame] | 782 | activity.setRequestedOrientation(newOrientation); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 783 | |
Wale Ogunwale | 8a1860a | 2019-06-05 08:57:19 -0700 | [diff] [blame] | 784 | final int expectedOrientation = newOrientation == SCREEN_ORIENTATION_PORTRAIT |
| 785 | ? Configuration.ORIENTATION_PORTRAIT |
| 786 | : Configuration.ORIENTATION_LANDSCAPE; |
Evan Rosky | 0177507 | 2019-09-11 17:28:07 -0700 | [diff] [blame] | 787 | assertEquals(expectedOrientation, dc.getConfiguration().orientation); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | @Test |
| 791 | public void testOnDescendantOrientationRequestChanged_FrozenToUserRotation() { |
Garfield Tan | 49dae10 | 2019-02-04 09:51:59 -0800 | [diff] [blame] | 792 | final DisplayContent dc = createNewDisplay(); |
Garfield Tan | 7fbca05 | 2019-02-19 10:45:35 -0800 | [diff] [blame] | 793 | dc.getDisplayRotation().setFixedToUserRotation( |
Garfield Tan | a3f1903 | 2019-11-19 18:04:50 -0800 | [diff] [blame] | 794 | IWindowManager.FIXED_TO_USER_ROTATION_ENABLED); |
Garfield Tan | 49dae10 | 2019-02-04 09:51:59 -0800 | [diff] [blame] | 795 | final int newOrientation = dc.getLastOrientation() == SCREEN_ORIENTATION_LANDSCAPE |
| 796 | ? SCREEN_ORIENTATION_PORTRAIT |
| 797 | : SCREEN_ORIENTATION_LANDSCAPE; |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 798 | |
Wale Ogunwale | 8a1860a | 2019-06-05 08:57:19 -0700 | [diff] [blame] | 799 | final ActivityStack stack = |
Louis Chang | 149d5c8 | 2019-12-30 09:47:39 +0800 | [diff] [blame] | 800 | new ActivityTestsBase.StackBuilder(mWm.mAtmService.mRootWindowContainer) |
Louis Chang | 2453d06 | 2019-11-19 22:30:48 +0800 | [diff] [blame] | 801 | .setDisplay(dc).build(); |
Wale Ogunwale | 85fb19a | 2019-12-05 10:41:05 +0900 | [diff] [blame] | 802 | final ActivityRecord activity = stack.getTopMostTask().getTopNonFinishingActivity(); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 803 | |
Wale Ogunwale | 8a1860a | 2019-06-05 08:57:19 -0700 | [diff] [blame] | 804 | activity.setRequestedOrientation(newOrientation); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 805 | |
Louis Chang | 677921f | 2019-12-06 16:44:24 +0800 | [diff] [blame] | 806 | verify(dc, never()).updateDisplayOverrideConfigurationLocked(any(), eq(activity), |
| 807 | anyBoolean(), same(null)); |
Wale Ogunwale | 8a1860a | 2019-06-05 08:57:19 -0700 | [diff] [blame] | 808 | assertEquals(dc.getDisplayRotation().getUserRotation(), dc.getRotation()); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 809 | } |
| 810 | |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 811 | @Test |
| 812 | public void testComputeImeParent_app() throws Exception { |
| 813 | try (final InsetsModeSession session = |
| 814 | new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) { |
| 815 | final DisplayContent dc = createNewDisplay(); |
| 816 | dc.mInputMethodTarget = createWindow(null, TYPE_BASE_APPLICATION, "app"); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 817 | assertEquals(dc.mInputMethodTarget.mActivityRecord.getSurfaceControl(), |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 818 | dc.computeImeParent()); |
| 819 | } |
| 820 | } |
| 821 | |
| 822 | @Test |
| 823 | public void testComputeImeParent_app_notFullscreen() throws Exception { |
| 824 | try (final InsetsModeSession session = |
| 825 | new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) { |
| 826 | final DisplayContent dc = createNewDisplay(); |
| 827 | dc.mInputMethodTarget = createWindow(null, TYPE_STATUS_BAR, "app"); |
| 828 | dc.mInputMethodTarget.setWindowingMode( |
| 829 | WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY); |
Adrian Roos | 329cbd0 | 2020-04-14 15:42:41 +0200 | [diff] [blame] | 830 | assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent()); |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 831 | } |
| 832 | } |
| 833 | |
| 834 | @Test |
Riddle Hsu | 6d6f67c | 2019-03-14 16:54:26 +0800 | [diff] [blame] | 835 | public void testComputeImeParent_app_notMatchParentBounds() { |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 836 | spyOn(mAppWindow.mActivityRecord); |
| 837 | doReturn(false).when(mAppWindow.mActivityRecord).matchParentBounds(); |
Riddle Hsu | 6d6f67c | 2019-03-14 16:54:26 +0800 | [diff] [blame] | 838 | mDisplayContent.mInputMethodTarget = mAppWindow; |
| 839 | // The surface parent of IME should be the display instead of app window. |
Adrian Roos | 329cbd0 | 2020-04-14 15:42:41 +0200 | [diff] [blame] | 840 | assertEquals(mDisplayContent.getImeContainer().getParentSurfaceControl(), |
| 841 | mDisplayContent.computeImeParent()); |
Riddle Hsu | 6d6f67c | 2019-03-14 16:54:26 +0800 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | @Test |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 845 | public void testComputeImeParent_noApp() throws Exception { |
| 846 | try (final InsetsModeSession session = |
| 847 | new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) { |
| 848 | final DisplayContent dc = createNewDisplay(); |
| 849 | dc.mInputMethodTarget = createWindow(null, TYPE_STATUS_BAR, "statusBar"); |
Adrian Roos | 329cbd0 | 2020-04-14 15:42:41 +0200 | [diff] [blame] | 850 | assertEquals(dc.getImeContainer().getParentSurfaceControl(), dc.computeImeParent()); |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 851 | } |
| 852 | } |
| 853 | |
Susi Kharraz-Post | 9893b8c | 2019-02-12 14:21:29 -0500 | [diff] [blame] | 854 | @Test |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 855 | public void testUpdateSystemGestureExclusion() throws Exception { |
| 856 | final DisplayContent dc = createNewDisplay(); |
| 857 | final WindowState win = createWindow(null, TYPE_BASE_APPLICATION, dc, "win"); |
| 858 | win.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; |
| 859 | win.setSystemGestureExclusion(Collections.singletonList(new Rect(10, 20, 30, 40))); |
| 860 | |
Riddle Hsu | 12c0545 | 2020-01-09 00:39:52 +0800 | [diff] [blame] | 861 | performLayout(dc); |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 862 | |
| 863 | win.setHasSurface(true); |
| 864 | dc.updateSystemGestureExclusion(); |
| 865 | |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 866 | final boolean[] invoked = { false }; |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 867 | final ISystemGestureExclusionListener.Stub verifier = |
| 868 | new ISystemGestureExclusionListener.Stub() { |
| 869 | @Override |
Adrian Roos | 5f2c9a1 | 2019-07-03 18:31:46 +0200 | [diff] [blame] | 870 | public void onSystemGestureExclusionChanged(int displayId, Region actual, |
| 871 | Region unrestricted) { |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 872 | Region expected = Region.obtain(); |
| 873 | expected.set(10, 20, 30, 40); |
| 874 | assertEquals(expected, actual); |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 875 | invoked[0] = true; |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 876 | } |
| 877 | }; |
| 878 | try { |
| 879 | dc.registerSystemGestureExclusionListener(verifier); |
| 880 | } finally { |
| 881 | dc.unregisterSystemGestureExclusionListener(verifier); |
| 882 | } |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 883 | assertTrue("SystemGestureExclusionListener was not invoked", invoked[0]); |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 884 | } |
| 885 | |
| 886 | @Test |
| 887 | public void testCalculateSystemGestureExclusion() throws Exception { |
| 888 | final DisplayContent dc = createNewDisplay(); |
| 889 | final WindowState win = createWindow(null, TYPE_BASE_APPLICATION, dc, "win"); |
| 890 | win.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; |
| 891 | win.setSystemGestureExclusion(Collections.singletonList(new Rect(10, 20, 30, 40))); |
| 892 | |
| 893 | final WindowState win2 = createWindow(null, TYPE_APPLICATION, dc, "win2"); |
| 894 | win2.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; |
| 895 | win2.setSystemGestureExclusion(Collections.singletonList(new Rect(20, 30, 40, 50))); |
| 896 | |
Riddle Hsu | 12c0545 | 2020-01-09 00:39:52 +0800 | [diff] [blame] | 897 | performLayout(dc); |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 898 | |
| 899 | win.setHasSurface(true); |
| 900 | win2.setHasSurface(true); |
| 901 | |
| 902 | final Region expected = Region.obtain(); |
| 903 | expected.set(20, 30, 40, 50); |
Adrian Roos | 5f2c9a1 | 2019-07-03 18:31:46 +0200 | [diff] [blame] | 904 | assertEquals(expected, calculateSystemGestureExclusion(dc)); |
| 905 | } |
| 906 | |
| 907 | private Region calculateSystemGestureExclusion(DisplayContent dc) { |
| 908 | Region out = Region.obtain(); |
| 909 | Region unrestricted = Region.obtain(); |
| 910 | dc.calculateSystemGestureExclusion(out, unrestricted); |
| 911 | return out; |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 912 | } |
| 913 | |
| 914 | @Test |
Adrian Roos | b106379 | 2019-06-28 12:10:51 +0200 | [diff] [blame] | 915 | public void testCalculateSystemGestureExclusion_modal() throws Exception { |
| 916 | final DisplayContent dc = createNewDisplay(); |
| 917 | final WindowState win = createWindow(null, TYPE_BASE_APPLICATION, dc, "base"); |
| 918 | win.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; |
| 919 | win.setSystemGestureExclusion(Collections.singletonList(new Rect(0, 0, 1000, 1000))); |
| 920 | |
| 921 | final WindowState win2 = createWindow(null, TYPE_APPLICATION, dc, "modal"); |
| 922 | win2.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; |
| 923 | win2.getAttrs().privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION; |
| 924 | win2.getAttrs().width = 10; |
| 925 | win2.getAttrs().height = 10; |
| 926 | win2.setSystemGestureExclusion(Collections.emptyList()); |
| 927 | |
Riddle Hsu | 12c0545 | 2020-01-09 00:39:52 +0800 | [diff] [blame] | 928 | performLayout(dc); |
Adrian Roos | b106379 | 2019-06-28 12:10:51 +0200 | [diff] [blame] | 929 | |
| 930 | win.setHasSurface(true); |
| 931 | win2.setHasSurface(true); |
| 932 | |
| 933 | final Region expected = Region.obtain(); |
Adrian Roos | 5f2c9a1 | 2019-07-03 18:31:46 +0200 | [diff] [blame] | 934 | assertEquals(expected, calculateSystemGestureExclusion(dc)); |
Adrian Roos | b106379 | 2019-06-28 12:10:51 +0200 | [diff] [blame] | 935 | } |
| 936 | |
| 937 | @Test |
Adrian Roos | 019a52b | 2019-07-02 16:47:44 +0200 | [diff] [blame] | 938 | public void testCalculateSystemGestureExclusion_immersiveStickyLegacyWindow() throws Exception { |
Adrian Roos | 1c2e9a1 | 2019-08-20 18:23:47 +0200 | [diff] [blame] | 939 | mWm.mConstants.mSystemGestureExcludedByPreQStickyImmersive = true; |
Adrian Roos | 019a52b | 2019-07-02 16:47:44 +0200 | [diff] [blame] | 940 | |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 941 | final DisplayContent dc = createNewDisplay(); |
| 942 | final WindowState win = createWindow(null, TYPE_BASE_APPLICATION, dc, "win"); |
| 943 | win.getAttrs().flags |= FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR; |
| 944 | win.getAttrs().layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
| 945 | win.getAttrs().privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION; |
| 946 | win.getAttrs().subtreeSystemUiVisibility = win.mSystemUiVisibility = |
| 947 | SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_HIDE_NAVIGATION |
| 948 | | SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 949 | win.mActivityRecord.mTargetSdk = P; |
Adrian Roos | 019a52b | 2019-07-02 16:47:44 +0200 | [diff] [blame] | 950 | |
Riddle Hsu | 12c0545 | 2020-01-09 00:39:52 +0800 | [diff] [blame] | 951 | performLayout(dc); |
Adrian Roos | 019a52b | 2019-07-02 16:47:44 +0200 | [diff] [blame] | 952 | |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 953 | win.setHasSurface(true); |
Adrian Roos | 019a52b | 2019-07-02 16:47:44 +0200 | [diff] [blame] | 954 | |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 955 | final Region expected = Region.obtain(); |
| 956 | expected.set(dc.getBounds()); |
| 957 | assertEquals(expected, calculateSystemGestureExclusion(dc)); |
Adrian Roos | 019a52b | 2019-07-02 16:47:44 +0200 | [diff] [blame] | 958 | |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 959 | win.setHasSurface(false); |
Adrian Roos | 019a52b | 2019-07-02 16:47:44 +0200 | [diff] [blame] | 960 | } |
| 961 | |
| 962 | @Test |
Riddle Hsu | 12c0545 | 2020-01-09 00:39:52 +0800 | [diff] [blame] | 963 | public void testRequestResizeForEmptyFrames() { |
| 964 | final WindowState win = mChildAppWindowAbove; |
| 965 | makeWindowVisible(win, win.getParentWindow()); |
| 966 | win.setRequestedSize(mDisplayContent.mBaseDisplayWidth, 0 /* height */); |
| 967 | win.mAttrs.width = win.mAttrs.height = WindowManager.LayoutParams.WRAP_CONTENT; |
| 968 | win.mAttrs.gravity = Gravity.CENTER; |
| 969 | performLayout(mDisplayContent); |
| 970 | |
| 971 | // The frame is empty because the requested height is zero. |
| 972 | assertTrue(win.getFrameLw().isEmpty()); |
| 973 | // The window should be scheduled to resize then the client may report a new non-empty size. |
| 974 | win.updateResizingWindowIfNeeded(); |
| 975 | assertThat(mWm.mResizingWindows).contains(win); |
| 976 | } |
| 977 | |
| 978 | @Test |
Susi Kharraz-Post | 9893b8c | 2019-02-12 14:21:29 -0500 | [diff] [blame] | 979 | public void testOrientationChangeLogging() { |
| 980 | MetricsLogger mockLogger = mock(MetricsLogger.class); |
| 981 | Configuration oldConfig = new Configuration(); |
| 982 | oldConfig.orientation = Configuration.ORIENTATION_LANDSCAPE; |
| 983 | |
| 984 | Configuration newConfig = new Configuration(); |
| 985 | newConfig.orientation = Configuration.ORIENTATION_PORTRAIT; |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 986 | final DisplayContent displayContent = createNewDisplay(); |
Susi Kharraz-Post | 9893b8c | 2019-02-12 14:21:29 -0500 | [diff] [blame] | 987 | Mockito.doReturn(mockLogger).when(displayContent).getMetricsLogger(); |
| 988 | Mockito.doReturn(oldConfig).doReturn(newConfig).when(displayContent).getConfiguration(); |
Louis Chang | 2453d06 | 2019-11-19 22:30:48 +0800 | [diff] [blame] | 989 | doNothing().when(displayContent).preOnConfigurationChanged(); |
Susi Kharraz-Post | 9893b8c | 2019-02-12 14:21:29 -0500 | [diff] [blame] | 990 | |
| 991 | displayContent.onConfigurationChanged(newConfig); |
| 992 | |
| 993 | ArgumentCaptor<LogMaker> logMakerCaptor = ArgumentCaptor.forClass(LogMaker.class); |
| 994 | verify(mockLogger).write(logMakerCaptor.capture()); |
| 995 | assertThat(logMakerCaptor.getValue().getCategory(), |
| 996 | is(MetricsProto.MetricsEvent.ACTION_PHONE_ORIENTATION_CHANGED)); |
| 997 | assertThat(logMakerCaptor.getValue().getSubtype(), |
| 998 | is(Configuration.ORIENTATION_PORTRAIT)); |
| 999 | } |
| 1000 | |
Evan Rosky | 69cace4 | 2019-09-20 16:28:13 -0700 | [diff] [blame] | 1001 | @Test |
Riddle Hsu | 6f548e9 | 2020-01-13 13:34:09 +0800 | [diff] [blame] | 1002 | public void testApplyTopFixedRotationTransform() { |
| 1003 | mWm.mIsFixedRotationTransformEnabled = true; |
| 1004 | final Configuration config90 = new Configuration(); |
Riddle Hsu | 9239d7c6 | 2020-02-20 01:35:56 +0800 | [diff] [blame] | 1005 | mDisplayContent.computeScreenConfiguration(config90, ROTATION_90); |
Riddle Hsu | 6f548e9 | 2020-01-13 13:34:09 +0800 | [diff] [blame] | 1006 | |
| 1007 | final Configuration config = new Configuration(); |
Riddle Hsu | 9239d7c6 | 2020-02-20 01:35:56 +0800 | [diff] [blame] | 1008 | mDisplayContent.getDisplayRotation().setRotation(ROTATION_0); |
Riddle Hsu | 6f548e9 | 2020-01-13 13:34:09 +0800 | [diff] [blame] | 1009 | mDisplayContent.computeScreenConfiguration(config); |
| 1010 | mDisplayContent.onRequestedOverrideConfigurationChanged(config); |
| 1011 | |
Riddle Hsu | fc246d1 | 2020-03-20 18:28:11 +0800 | [diff] [blame] | 1012 | final ActivityRecord closingApp = new ActivityTestsBase.StackBuilder(mWm.mRoot) |
| 1013 | .setDisplay(mDisplayContent).setOnTop(false).build().getTopMostActivity(); |
| 1014 | closingApp.nowVisible = true; |
| 1015 | closingApp.startAnimation(closingApp.getPendingTransaction(), mock(AnimationAdapter.class), |
| 1016 | false /* hidden */, ANIMATION_TYPE_APP_TRANSITION); |
| 1017 | assertTrue(closingApp.isAnimating()); |
| 1018 | |
Riddle Hsu | 6f548e9 | 2020-01-13 13:34:09 +0800 | [diff] [blame] | 1019 | final ActivityRecord app = mAppWindow.mActivityRecord; |
| 1020 | mDisplayContent.prepareAppTransition(WindowManager.TRANSIT_ACTIVITY_OPEN, |
| 1021 | false /* alwaysKeepCurrent */); |
| 1022 | mDisplayContent.mOpeningApps.add(app); |
| 1023 | app.setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE); |
| 1024 | |
| 1025 | assertTrue(app.isFixedRotationTransforming()); |
Riddle Hsu | 9239d7c6 | 2020-02-20 01:35:56 +0800 | [diff] [blame] | 1026 | assertTrue(mDisplayContent.getDisplayRotation().shouldRotateSeamlessly( |
| 1027 | ROTATION_0 /* oldRotation */, ROTATION_90 /* newRotation */, |
| 1028 | false /* forceUpdate */)); |
Riddle Hsu | f41034c | 2020-03-19 13:10:46 +0800 | [diff] [blame] | 1029 | |
| 1030 | final Rect outFrame = new Rect(); |
| 1031 | final Rect outInsets = new Rect(); |
| 1032 | final Rect outStableInsets = new Rect(); |
| 1033 | final Rect outSurfaceInsets = new Rect(); |
| 1034 | mAppWindow.getAnimationFrames(outFrame, outInsets, outStableInsets, outSurfaceInsets); |
| 1035 | // The animation frames should not be rotated because display hasn't rotated. |
| 1036 | assertEquals(mDisplayContent.getBounds(), outFrame); |
| 1037 | |
Riddle Hsu | 9239d7c6 | 2020-02-20 01:35:56 +0800 | [diff] [blame] | 1038 | // The display should keep current orientation and the rotated configuration should apply |
| 1039 | // to the activity. |
Riddle Hsu | 6f548e9 | 2020-01-13 13:34:09 +0800 | [diff] [blame] | 1040 | assertEquals(config.orientation, mDisplayContent.getConfiguration().orientation); |
| 1041 | assertEquals(config90.orientation, app.getConfiguration().orientation); |
Riddle Hsu | 9239d7c6 | 2020-02-20 01:35:56 +0800 | [diff] [blame] | 1042 | assertEquals(config90.windowConfiguration.getBounds(), app.getBounds()); |
Riddle Hsu | 6f548e9 | 2020-01-13 13:34:09 +0800 | [diff] [blame] | 1043 | |
Riddle Hsu | 3d0aa4f | 2020-04-09 17:58:50 +0800 | [diff] [blame^] | 1044 | // Make wallaper laid out with the fixed rotation transform. |
| 1045 | final WindowToken wallpaperToken = mWallpaperWindow.mToken; |
| 1046 | wallpaperToken.linkFixedRotationTransform(app); |
| 1047 | mWallpaperWindow.mLayoutNeeded = true; |
| 1048 | performLayout(mDisplayContent); |
| 1049 | |
Riddle Hsu | 6da58ac | 2020-04-02 01:04:40 +0800 | [diff] [blame] | 1050 | // Force the negative offset to verify it can be updated. |
| 1051 | mWallpaperWindow.mWinAnimator.mXOffset = mWallpaperWindow.mWinAnimator.mYOffset = -1; |
| 1052 | assertTrue(mDisplayContent.mWallpaperController.updateWallpaperOffset(mWallpaperWindow, |
| 1053 | false /* sync */)); |
| 1054 | assertThat(mWallpaperWindow.mWinAnimator.mXOffset).isGreaterThan(-1); |
| 1055 | assertThat(mWallpaperWindow.mWinAnimator.mYOffset).isGreaterThan(-1); |
| 1056 | |
Riddle Hsu | 3d0aa4f | 2020-04-09 17:58:50 +0800 | [diff] [blame^] | 1057 | // The wallpaper need to animate with transformed position, so its surface position should |
| 1058 | // not be reset. |
| 1059 | final Transaction t = wallpaperToken.getPendingTransaction(); |
| 1060 | spyOn(t); |
| 1061 | mWallpaperWindow.mToken.onAnimationLeashCreated(t, null /* leash */); |
| 1062 | verify(t, never()).setPosition(any(), eq(0), eq(0)); |
| 1063 | |
Riddle Hsu | 6f548e9 | 2020-01-13 13:34:09 +0800 | [diff] [blame] | 1064 | mDisplayContent.mAppTransition.notifyAppTransitionFinishedLocked(app.token); |
| 1065 | |
Riddle Hsu | fc246d1 | 2020-03-20 18:28:11 +0800 | [diff] [blame] | 1066 | // The animation in old rotation should be cancelled. |
| 1067 | assertFalse(closingApp.isAnimating()); |
Riddle Hsu | 9239d7c6 | 2020-02-20 01:35:56 +0800 | [diff] [blame] | 1068 | // The display should be rotated after the launch is finished. |
Riddle Hsu | 6f548e9 | 2020-01-13 13:34:09 +0800 | [diff] [blame] | 1069 | assertFalse(app.hasFixedRotationTransform()); |
| 1070 | assertEquals(config90.orientation, mDisplayContent.getConfiguration().orientation); |
| 1071 | } |
| 1072 | |
| 1073 | @Test |
Evan Rosky | 69cace4 | 2019-09-20 16:28:13 -0700 | [diff] [blame] | 1074 | public void testRemoteRotation() { |
| 1075 | DisplayContent dc = createNewDisplay(); |
| 1076 | |
| 1077 | final DisplayRotation dr = dc.getDisplayRotation(); |
| 1078 | Mockito.doCallRealMethod().when(dr).updateRotationUnchecked(anyBoolean()); |
| 1079 | Mockito.doReturn(ROTATION_90).when(dr).rotationForOrientation(anyInt(), anyInt()); |
| 1080 | final boolean[] continued = new boolean[1]; |
Louis Chang | 2453d06 | 2019-11-19 22:30:48 +0800 | [diff] [blame] | 1081 | // TODO(display-merge): Remove cast |
Evan Rosky | 69cace4 | 2019-09-20 16:28:13 -0700 | [diff] [blame] | 1082 | Mockito.doAnswer( |
| 1083 | invocation -> { |
| 1084 | continued[0] = true; |
| 1085 | return true; |
Louis Chang | 677921f | 2019-12-06 16:44:24 +0800 | [diff] [blame] | 1086 | }).when(dc).updateDisplayOverrideConfigurationLocked(); |
Evan Rosky | 69cace4 | 2019-09-20 16:28:13 -0700 | [diff] [blame] | 1087 | final boolean[] called = new boolean[1]; |
| 1088 | mWm.mDisplayRotationController = |
| 1089 | new IDisplayWindowRotationController.Stub() { |
| 1090 | @Override |
| 1091 | public void onRotateDisplay(int displayId, int fromRotation, int toRotation, |
| 1092 | IDisplayWindowRotationCallback callback) { |
| 1093 | called[0] = true; |
| 1094 | |
| 1095 | try { |
| 1096 | callback.continueRotateDisplay(toRotation, null); |
| 1097 | } catch (RemoteException e) { |
| 1098 | assertTrue(false); |
| 1099 | } |
| 1100 | } |
| 1101 | }; |
| 1102 | |
| 1103 | // kill any existing rotation animation (vestigial from test setup). |
| 1104 | dc.setRotationAnimation(null); |
| 1105 | |
| 1106 | mWm.updateRotation(true /* alwaysSendConfiguration */, false /* forceRelayout */); |
| 1107 | assertTrue(called[0]); |
| 1108 | waitUntilHandlersIdle(); |
| 1109 | assertTrue(continued[0]); |
| 1110 | } |
| 1111 | |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1112 | @Test |
| 1113 | public void testGetOrCreateRootHomeTask_defaultDisplay() { |
Andrii Kulian | 4c0fd0d | 2020-03-29 13:32:14 -0700 | [diff] [blame] | 1114 | TaskDisplayArea defaultTaskDisplayArea = mWm.mRoot.getDefaultTaskDisplayArea(); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1115 | |
| 1116 | // Remove the current home stack if it exists so a new one can be created below. |
Andrii Kulian | 86d676c | 2020-03-27 19:34:54 -0700 | [diff] [blame] | 1117 | ActivityStack homeTask = defaultTaskDisplayArea.getRootHomeTask(); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1118 | if (homeTask != null) { |
Andrii Kulian | 86d676c | 2020-03-27 19:34:54 -0700 | [diff] [blame] | 1119 | defaultTaskDisplayArea.removeChild(homeTask); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1120 | } |
Andrii Kulian | 86d676c | 2020-03-27 19:34:54 -0700 | [diff] [blame] | 1121 | assertNull(defaultTaskDisplayArea.getRootHomeTask()); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1122 | |
Andrii Kulian | 86d676c | 2020-03-27 19:34:54 -0700 | [diff] [blame] | 1123 | assertNotNull(defaultTaskDisplayArea.getOrCreateRootHomeTask()); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1124 | } |
| 1125 | |
| 1126 | @Test |
| 1127 | public void testGetOrCreateRootHomeTask_supportedSecondaryDisplay() { |
| 1128 | DisplayContent display = createNewDisplay(); |
| 1129 | doReturn(true).when(display).supportsSystemDecorations(); |
| 1130 | doReturn(false).when(display).isUntrustedVirtualDisplay(); |
| 1131 | |
| 1132 | // Remove the current home stack if it exists so a new one can be created below. |
Andrii Kulian | 4c0fd0d | 2020-03-29 13:32:14 -0700 | [diff] [blame] | 1133 | TaskDisplayArea taskDisplayArea = display.getDefaultTaskDisplayArea(); |
Andrii Kulian | 86d676c | 2020-03-27 19:34:54 -0700 | [diff] [blame] | 1134 | ActivityStack homeTask = taskDisplayArea.getRootHomeTask(); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1135 | if (homeTask != null) { |
Andrii Kulian | 86d676c | 2020-03-27 19:34:54 -0700 | [diff] [blame] | 1136 | taskDisplayArea.removeChild(homeTask); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1137 | } |
Andrii Kulian | 86d676c | 2020-03-27 19:34:54 -0700 | [diff] [blame] | 1138 | assertNull(taskDisplayArea.getRootHomeTask()); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1139 | |
Andrii Kulian | 86d676c | 2020-03-27 19:34:54 -0700 | [diff] [blame] | 1140 | assertNotNull(taskDisplayArea.getOrCreateRootHomeTask()); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | @Test |
| 1144 | public void testGetOrCreateRootHomeTask_unsupportedSystemDecorations() { |
| 1145 | DisplayContent display = createNewDisplay(); |
Andrii Kulian | 4c0fd0d | 2020-03-29 13:32:14 -0700 | [diff] [blame] | 1146 | TaskDisplayArea taskDisplayArea = display.getDefaultTaskDisplayArea(); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1147 | doReturn(false).when(display).supportsSystemDecorations(); |
| 1148 | |
Andrii Kulian | 86d676c | 2020-03-27 19:34:54 -0700 | [diff] [blame] | 1149 | assertNull(taskDisplayArea.getRootHomeTask()); |
| 1150 | assertNull(taskDisplayArea.getOrCreateRootHomeTask()); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1151 | } |
| 1152 | |
| 1153 | @Test |
| 1154 | public void testGetOrCreateRootHomeTask_untrustedVirtualDisplay() { |
| 1155 | DisplayContent display = createNewDisplay(); |
Andrii Kulian | 4c0fd0d | 2020-03-29 13:32:14 -0700 | [diff] [blame] | 1156 | TaskDisplayArea taskDisplayArea = display.getDefaultTaskDisplayArea(); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1157 | doReturn(true).when(display).isUntrustedVirtualDisplay(); |
| 1158 | |
Andrii Kulian | 86d676c | 2020-03-27 19:34:54 -0700 | [diff] [blame] | 1159 | assertNull(taskDisplayArea.getRootHomeTask()); |
| 1160 | assertNull(taskDisplayArea.getOrCreateRootHomeTask()); |
Darryl L Johnson | 3388bd2 | 2019-12-19 17:38:41 -0800 | [diff] [blame] | 1161 | } |
| 1162 | |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 1163 | private boolean isOptionsPanelAtRight(int displayId) { |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 1164 | return (mWm.getPreferredOptionsPanelGravity(displayId) & Gravity.RIGHT) == Gravity.RIGHT; |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 1165 | } |
| 1166 | |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 1167 | private static void verifySizes(DisplayContent displayContent, int expectedBaseWidth, |
| 1168 | int expectedBaseHeight, int expectedBaseDensity) { |
| 1169 | assertEquals(displayContent.mBaseDisplayWidth, expectedBaseWidth); |
| 1170 | assertEquals(displayContent.mBaseDisplayHeight, expectedBaseHeight); |
| 1171 | assertEquals(displayContent.mBaseDisplayDensity, expectedBaseDensity); |
| 1172 | } |
| 1173 | |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 1174 | private void updateFocusedWindow() { |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 1175 | mWm.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false /* updateInputWindows */); |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 1176 | } |
| 1177 | |
Riddle Hsu | 12c0545 | 2020-01-09 00:39:52 +0800 | [diff] [blame] | 1178 | private void performLayout(DisplayContent dc) { |
| 1179 | dc.setLayoutNeeded(); |
| 1180 | dc.performLayout(true /* initial */, false /* updateImeWindows */); |
| 1181 | } |
| 1182 | |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 1183 | /** |
| 1184 | * Create DisplayContent that does not update display base/initial values from device to keep |
| 1185 | * the values set by test. |
| 1186 | */ |
| 1187 | private DisplayContent createDisplayNoUpdateDisplayInfo() { |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 1188 | final DisplayContent displayContent = createNewDisplay(); |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 1189 | doNothing().when(displayContent).updateDisplayInfo(); |
| 1190 | return displayContent; |
| 1191 | } |
| 1192 | |
Adrian Roos | 0f9368c | 2018-04-08 10:59:08 -0700 | [diff] [blame] | 1193 | private void assertForAllWindowsOrder(List<WindowState> expectedWindowsBottomToTop) { |
| 1194 | final LinkedList<WindowState> actualWindows = new LinkedList<>(); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 1195 | |
| 1196 | // Test forward traversal. |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 1197 | mDisplayContent.forAllWindows(actualWindows::addLast, false /* traverseTopToBottom */); |
Adrian Roos | 0f9368c | 2018-04-08 10:59:08 -0700 | [diff] [blame] | 1198 | assertThat("bottomToTop", actualWindows, is(expectedWindowsBottomToTop)); |
| 1199 | |
| 1200 | actualWindows.clear(); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 1201 | |
| 1202 | // Test backward traversal. |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 1203 | mDisplayContent.forAllWindows(actualWindows::addLast, true /* traverseTopToBottom */); |
Adrian Roos | 0f9368c | 2018-04-08 10:59:08 -0700 | [diff] [blame] | 1204 | assertThat("topToBottom", actualWindows, is(reverseList(expectedWindowsBottomToTop))); |
| 1205 | } |
| 1206 | |
| 1207 | private static List<WindowState> reverseList(List<WindowState> list) { |
| 1208 | final ArrayList<WindowState> result = new ArrayList<>(list); |
| 1209 | Collections.reverse(result); |
| 1210 | return result; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 1211 | } |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 1212 | |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 1213 | private void tapOnDisplay(final DisplayContent dc) { |
| 1214 | final DisplayMetrics dm = dc.getDisplayMetrics(); |
| 1215 | final float x = dm.widthPixels / 2; |
| 1216 | final float y = dm.heightPixels / 2; |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 1217 | final long downTime = SystemClock.uptimeMillis(); |
| 1218 | final long eventTime = SystemClock.uptimeMillis() + 100; |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 1219 | // sending ACTION_DOWN |
| 1220 | final MotionEvent downEvent = MotionEvent.obtain( |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 1221 | downTime, |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 1222 | downTime, |
| 1223 | MotionEvent.ACTION_DOWN, |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 1224 | x, |
| 1225 | y, |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 1226 | 0 /*metaState*/); |
| 1227 | downEvent.setDisplayId(dc.getDisplayId()); |
| 1228 | dc.mTapDetector.onPointerEvent(downEvent); |
| 1229 | |
| 1230 | // sending ACTION_UP |
| 1231 | final MotionEvent upEvent = MotionEvent.obtain( |
| 1232 | downTime, |
| 1233 | eventTime, |
| 1234 | MotionEvent.ACTION_UP, |
| 1235 | x, |
| 1236 | y, |
| 1237 | 0 /*metaState*/); |
| 1238 | upEvent.setDisplayId(dc.getDisplayId()); |
| 1239 | dc.mTapDetector.onPointerEvent(upEvent); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 1240 | } |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 1241 | } |