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