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 | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 22 | import static android.os.Build.VERSION_CODES.P; |
| 23 | import static android.os.Build.VERSION_CODES.Q; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 24 | import static android.view.Display.DEFAULT_DISPLAY; |
Issei Suzuki | 43190bd | 2018-08-20 17:28:41 +0200 | [diff] [blame] | 25 | import static android.view.DisplayCutout.BOUNDS_POSITION_LEFT; |
| 26 | import static android.view.DisplayCutout.BOUNDS_POSITION_TOP; |
Adrian Roos | 2426421 | 2018-02-19 16:26:15 +0100 | [diff] [blame] | 27 | import static android.view.DisplayCutout.fromBoundingRect; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 28 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; |
| 29 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; |
| 30 | import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 31 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 32 | import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 33 | |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 34 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.any; |
| 35 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyBoolean; |
Tadashi G. Takaoka | bf0d57b | 2018-11-19 16:09:58 +0900 | [diff] [blame] | 36 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; |
Riddle Hsu | 6d6f67c | 2019-03-14 16:54:26 +0800 | [diff] [blame^] | 37 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 38 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock; |
| 39 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.never; |
| 40 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.same; |
Tadashi G. Takaoka | bf0d57b | 2018-11-19 16:09:58 +0900 | [diff] [blame] | 41 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.spy; |
Riddle Hsu | 6d6f67c | 2019-03-14 16:54:26 +0800 | [diff] [blame^] | 42 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; |
Tadashi G. Takaoka | bf0d57b | 2018-11-19 16:09:58 +0900 | [diff] [blame] | 43 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.times; |
| 44 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 45 | import static com.android.server.wm.WindowContainer.POSITION_TOP; |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 46 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL; |
chaviw | ebcbc34 | 2018-02-07 13:19:00 -0800 | [diff] [blame] | 47 | |
Adrian Roos | 5251b1d | 2018-03-23 18:57:43 +0100 | [diff] [blame] | 48 | import static org.hamcrest.Matchers.is; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 49 | import static org.junit.Assert.assertEquals; |
Andrii Kulian | f0379de | 2018-03-14 16:24:07 -0700 | [diff] [blame] | 50 | import static org.junit.Assert.assertFalse; |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 51 | import static org.junit.Assert.assertNotNull; |
lumark | ff0ab69 | 2018-11-05 20:32:30 +0800 | [diff] [blame] | 52 | import static org.junit.Assert.assertNull; |
Adrian Roos | 5251b1d | 2018-03-23 18:57:43 +0100 | [diff] [blame] | 53 | import static org.junit.Assert.assertThat; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 54 | import static org.junit.Assert.assertTrue; |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 55 | import static org.mockito.ArgumentMatchers.eq; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 56 | |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 57 | import android.annotation.SuppressLint; |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 58 | import android.app.WindowConfiguration; |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 59 | import android.content.res.Configuration; |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 60 | import android.graphics.Rect; |
Susi Kharraz-Post | 9893b8c | 2019-02-12 14:21:29 -0500 | [diff] [blame] | 61 | import android.metrics.LogMaker; |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 62 | import android.os.SystemClock; |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 63 | import android.platform.test.annotations.Presubmit; |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 64 | import android.util.DisplayMetrics; |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 65 | import android.view.DisplayCutout; |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 66 | import android.view.Gravity; |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 67 | import android.view.MotionEvent; |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 68 | import android.view.Surface; |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 69 | import android.view.ViewRootImpl; |
| 70 | import android.view.test.InsetsModeSession; |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 71 | |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 72 | import androidx.test.filters.SmallTest; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 73 | |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 74 | import com.android.dx.mockito.inline.extended.ExtendedMockito; |
Susi Kharraz-Post | 9893b8c | 2019-02-12 14:21:29 -0500 | [diff] [blame] | 75 | import com.android.internal.logging.MetricsLogger; |
| 76 | import com.android.internal.logging.nano.MetricsProto; |
Adrian Roos | 6a4fa0e | 2018-03-05 19:50:16 +0100 | [diff] [blame] | 77 | import com.android.server.wm.utils.WmDisplayCutout; |
| 78 | |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 79 | import org.junit.Test; |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 80 | import org.mockito.ArgumentCaptor; |
Susi Kharraz-Post | 9893b8c | 2019-02-12 14:21:29 -0500 | [diff] [blame] | 81 | import org.mockito.Mockito; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 82 | |
Adrian Roos | 0f9368c | 2018-04-08 10:59:08 -0700 | [diff] [blame] | 83 | import java.util.ArrayList; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 84 | import java.util.Arrays; |
Adrian Roos | 0f9368c | 2018-04-08 10:59:08 -0700 | [diff] [blame] | 85 | import java.util.Collections; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 86 | import java.util.LinkedList; |
| 87 | import java.util.List; |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 88 | |
| 89 | /** |
| 90 | * Tests for the {@link DisplayContent} class. |
| 91 | * |
| 92 | * Build/Install/Run: |
Yunfan Chen | 6dd9a62 | 2019-02-18 15:12:33 +0900 | [diff] [blame] | 93 | * atest WmTests:DisplayContentTests |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 94 | */ |
| 95 | @SmallTest |
| 96 | @Presubmit |
Wale Ogunwale | 44fbdf5 | 2016-11-16 10:18:45 -0800 | [diff] [blame] | 97 | public class DisplayContentTests extends WindowTestsBase { |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 98 | |
| 99 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 100 | public void testForAllWindows() { |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 101 | final WindowState exitingAppWindow = createWindow(null, TYPE_BASE_APPLICATION, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 102 | mDisplayContent, "exiting app"); |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 103 | final AppWindowToken exitingAppToken = exitingAppWindow.mAppToken; |
Yunfan Chen | 6dd9a62 | 2019-02-18 15:12:33 +0900 | [diff] [blame] | 104 | // Wait until everything in animation handler get executed to prevent the exiting window |
| 105 | // from being removed during WindowSurfacePlacer Traversal. |
| 106 | waitUntilHandlersIdle(); |
| 107 | |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 108 | exitingAppToken.mIsExiting = true; |
Bryce Lee | 6d41026 | 2017-02-28 15:30:17 -0800 | [diff] [blame] | 109 | exitingAppToken.getTask().mStack.mExitingAppTokens.add(exitingAppToken); |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 110 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 111 | assertForAllWindowsOrder(Arrays.asList( |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 112 | mWallpaperWindow, |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 113 | exitingAppWindow, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 114 | mChildAppWindowBelow, |
| 115 | mAppWindow, |
| 116 | mChildAppWindowAbove, |
| 117 | mDockedDividerWindow, |
| 118 | mStatusBarWindow, |
| 119 | mNavBarWindow, |
| 120 | mImeWindow, |
| 121 | mImeDialogWindow)); |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 125 | public void testForAllWindows_WithAppImeTarget() { |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 126 | final WindowState imeAppTarget = |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 127 | createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "imeAppTarget"); |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 128 | |
lumark | ff0ab69 | 2018-11-05 20:32:30 +0800 | [diff] [blame] | 129 | mDisplayContent.mInputMethodTarget = imeAppTarget; |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 130 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 131 | assertForAllWindowsOrder(Arrays.asList( |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 132 | mWallpaperWindow, |
| 133 | mChildAppWindowBelow, |
| 134 | mAppWindow, |
| 135 | mChildAppWindowAbove, |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 136 | imeAppTarget, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 137 | mImeWindow, |
| 138 | mImeDialogWindow, |
| 139 | mDockedDividerWindow, |
| 140 | mStatusBarWindow, |
| 141 | mNavBarWindow)); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 142 | } |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 143 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 144 | @Test |
lumark | ff0ab69 | 2018-11-05 20:32:30 +0800 | [diff] [blame] | 145 | public void testForAllWindows_WithChildWindowImeTarget() throws Exception { |
| 146 | mDisplayContent.mInputMethodTarget = mChildAppWindowAbove; |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 147 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 148 | assertForAllWindowsOrder(Arrays.asList( |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 149 | mWallpaperWindow, |
| 150 | mChildAppWindowBelow, |
| 151 | mAppWindow, |
| 152 | mChildAppWindowAbove, |
| 153 | mImeWindow, |
| 154 | mImeDialogWindow, |
| 155 | mDockedDividerWindow, |
| 156 | mStatusBarWindow, |
| 157 | mNavBarWindow)); |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 158 | } |
Wale Ogunwale | 5d7e7f1 | 2016-12-12 14:47:05 -0800 | [diff] [blame] | 159 | |
| 160 | @Test |
lumark | ff0ab69 | 2018-11-05 20:32:30 +0800 | [diff] [blame] | 161 | public void testForAllWindows_WithStatusBarImeTarget() throws Exception { |
| 162 | mDisplayContent.mInputMethodTarget = mStatusBarWindow; |
Wale Ogunwale | 6ce0fb8 | 2016-12-13 14:24:00 -0800 | [diff] [blame] | 163 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 164 | assertForAllWindowsOrder(Arrays.asList( |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 165 | mWallpaperWindow, |
| 166 | mChildAppWindowBelow, |
| 167 | mAppWindow, |
| 168 | mChildAppWindowAbove, |
| 169 | mDockedDividerWindow, |
| 170 | mStatusBarWindow, |
| 171 | mImeWindow, |
| 172 | mImeDialogWindow, |
| 173 | mNavBarWindow)); |
Wale Ogunwale | 6ce0fb8 | 2016-12-13 14:24:00 -0800 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 177 | public void testForAllWindows_WithInBetweenWindowToken() { |
Wale Ogunwale | 5d7e7f1 | 2016-12-12 14:47:05 -0800 | [diff] [blame] | 178 | // This window is set-up to be z-ordered between some windows that go in the same token like |
| 179 | // the nav bar and status bar. |
| 180 | final WindowState voiceInteractionWindow = createWindow(null, TYPE_VOICE_INTERACTION, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 181 | mDisplayContent, "voiceInteractionWindow"); |
Wale Ogunwale | 5d7e7f1 | 2016-12-12 14:47:05 -0800 | [diff] [blame] | 182 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 183 | assertForAllWindowsOrder(Arrays.asList( |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 184 | mWallpaperWindow, |
| 185 | mChildAppWindowBelow, |
| 186 | mAppWindow, |
| 187 | mChildAppWindowAbove, |
| 188 | mDockedDividerWindow, |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 189 | voiceInteractionWindow, |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 190 | mStatusBarWindow, |
| 191 | mNavBarWindow, |
| 192 | mImeWindow, |
| 193 | mImeDialogWindow)); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 194 | } |
Wale Ogunwale | 5d7e7f1 | 2016-12-12 14:47:05 -0800 | [diff] [blame] | 195 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 196 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 197 | public void testComputeImeTarget() { |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 198 | // Verify that an app window can be an ime target. |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 199 | final WindowState appWin = createWindow(null, TYPE_APPLICATION, mDisplayContent, "appWin"); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 200 | appWin.setHasSurface(true); |
| 201 | assertTrue(appWin.canBeImeTarget()); |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 202 | WindowState imeTarget = mDisplayContent.computeImeTarget(false /* updateImeTarget */); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 203 | assertEquals(appWin, imeTarget); |
chaviw | ebcbc34 | 2018-02-07 13:19:00 -0800 | [diff] [blame] | 204 | appWin.mHidden = false; |
Wale Ogunwale | 5d7e7f1 | 2016-12-12 14:47:05 -0800 | [diff] [blame] | 205 | |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 206 | // Verify that an child window can be an ime target. |
| 207 | final WindowState childWin = createWindow(appWin, |
| 208 | TYPE_APPLICATION_ATTACHED_DIALOG, "childWin"); |
| 209 | childWin.setHasSurface(true); |
| 210 | assertTrue(childWin.canBeImeTarget()); |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 211 | imeTarget = mDisplayContent.computeImeTarget(false /* updateImeTarget */); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 212 | assertEquals(childWin, imeTarget); |
Wale Ogunwale | 5d7e7f1 | 2016-12-12 14:47:05 -0800 | [diff] [blame] | 213 | } |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 214 | |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 215 | /** |
| 216 | * This tests stack movement between displays and proper stack's, task's and app token's display |
| 217 | * container references updates. |
| 218 | */ |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 219 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 220 | public void testMoveStackBetweenDisplays() { |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 221 | // Create a second display. |
| 222 | final DisplayContent dc = createNewDisplay(); |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 223 | |
| 224 | // Add stack with activity. |
| 225 | final TaskStack stack = createTaskStackOnDisplay(dc); |
| 226 | assertEquals(dc.getDisplayId(), stack.getDisplayContent().getDisplayId()); |
| 227 | assertEquals(dc, stack.getParent().getParent()); |
| 228 | assertEquals(dc, stack.getDisplayContent()); |
| 229 | |
| 230 | final Task task = createTaskInStack(stack, 0 /* userId */); |
chaviw | 97d2820 | 2018-02-27 16:23:53 -0800 | [diff] [blame] | 231 | final WindowTestUtils.TestAppWindowToken token = WindowTestUtils.createTestAppWindowToken( |
| 232 | dc); |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 233 | task.addChild(token, 0); |
| 234 | assertEquals(dc, task.getDisplayContent()); |
| 235 | assertEquals(dc, token.getDisplayContent()); |
| 236 | |
| 237 | // Move stack to first display. |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 238 | mDisplayContent.moveStackToDisplay(stack, true /* onTop */); |
| 239 | assertEquals(mDisplayContent.getDisplayId(), stack.getDisplayContent().getDisplayId()); |
| 240 | assertEquals(mDisplayContent, stack.getParent().getParent()); |
| 241 | assertEquals(mDisplayContent, stack.getDisplayContent()); |
| 242 | assertEquals(mDisplayContent, task.getDisplayContent()); |
| 243 | assertEquals(mDisplayContent, token.getDisplayContent()); |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 244 | } |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 245 | |
| 246 | /** |
| 247 | * This tests override configuration updates for display content. |
| 248 | */ |
| 249 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 250 | public void testDisplayOverrideConfigUpdate() { |
Evan Rosky | dfe3da7 | 2018-10-26 17:21:06 -0700 | [diff] [blame] | 251 | final Configuration currentOverrideConfig = |
| 252 | mDisplayContent.getRequestedOverrideConfiguration(); |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 253 | |
| 254 | // Create new, slightly changed override configuration and apply it to the display. |
| 255 | final Configuration newOverrideConfig = new Configuration(currentOverrideConfig); |
| 256 | newOverrideConfig.densityDpi += 120; |
| 257 | newOverrideConfig.fontScale += 0.3; |
| 258 | |
Evan Rosky | e747c3e | 2018-10-30 20:06:41 -0700 | [diff] [blame] | 259 | mWm.setNewDisplayOverrideConfiguration(newOverrideConfig, mDisplayContent); |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 260 | |
| 261 | // Check that override config is applied. |
Evan Rosky | dfe3da7 | 2018-10-26 17:21:06 -0700 | [diff] [blame] | 262 | assertEquals(newOverrideConfig, mDisplayContent.getRequestedOverrideConfiguration()); |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | /** |
| 266 | * This tests global configuration updates when default display config is updated. |
| 267 | */ |
| 268 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 269 | public void testDefaultDisplayOverrideConfigUpdate() { |
Evan Rosky | e747c3e | 2018-10-30 20:06:41 -0700 | [diff] [blame] | 270 | DisplayContent defaultDisplay = mWm.mRoot.getDisplayContent(DEFAULT_DISPLAY); |
| 271 | final Configuration currentConfig = defaultDisplay.getConfiguration(); |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 272 | |
| 273 | // Create new, slightly changed override configuration and apply it to the display. |
Andrii Kulian | a95bfff | 2017-03-30 19:00:41 -0700 | [diff] [blame] | 274 | final Configuration newOverrideConfig = new Configuration(currentConfig); |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 275 | newOverrideConfig.densityDpi += 120; |
| 276 | newOverrideConfig.fontScale += 0.3; |
| 277 | |
Evan Rosky | e747c3e | 2018-10-30 20:06:41 -0700 | [diff] [blame] | 278 | mWm.setNewDisplayOverrideConfiguration(newOverrideConfig, defaultDisplay); |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 279 | |
| 280 | // 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] | 281 | Configuration globalConfig = mWm.mRoot.getConfiguration(); |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 282 | assertEquals(newOverrideConfig.densityDpi, globalConfig.densityDpi); |
| 283 | assertEquals(newOverrideConfig.fontScale, globalConfig.fontScale, 0.1 /* delta */); |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 284 | |
| 285 | // Return back to original values. |
Evan Rosky | e747c3e | 2018-10-30 20:06:41 -0700 | [diff] [blame] | 286 | mWm.setNewDisplayOverrideConfiguration(currentConfig, defaultDisplay); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 287 | globalConfig = mWm.mRoot.getConfiguration(); |
Andrii Kulian | a95bfff | 2017-03-30 19:00:41 -0700 | [diff] [blame] | 288 | assertEquals(currentConfig.densityDpi, globalConfig.densityDpi); |
| 289 | assertEquals(currentConfig.fontScale, globalConfig.fontScale, 0.1 /* delta */); |
Andrii Kulian | d68501e | 2017-01-10 22:57:27 -0800 | [diff] [blame] | 290 | } |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 291 | |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 292 | /** |
| 293 | * Tests tapping on a stack in different display results in window gaining focus. |
| 294 | */ |
| 295 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 296 | public void testInputEventBringsCorrectDisplayInFocus() { |
| 297 | DisplayContent dc0 = mWm.getDefaultDisplayContentLocked(); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 298 | // Create a second display |
| 299 | final DisplayContent dc1 = createNewDisplay(); |
| 300 | |
| 301 | // Add stack with activity. |
| 302 | final TaskStack stack0 = createTaskStackOnDisplay(dc0); |
| 303 | final Task task0 = createTaskInStack(stack0, 0 /* userId */); |
| 304 | final WindowTestUtils.TestAppWindowToken token = |
chaviw | 97d2820 | 2018-02-27 16:23:53 -0800 | [diff] [blame] | 305 | WindowTestUtils.createTestAppWindowToken(dc0); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 306 | task0.addChild(token, 0); |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 307 | dc0.configureDisplayPolicy(); |
| 308 | assertNotNull(dc0.mTapDetector); |
| 309 | |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 310 | final TaskStack stack1 = createTaskStackOnDisplay(dc1); |
| 311 | final Task task1 = createTaskInStack(stack1, 0 /* userId */); |
| 312 | final WindowTestUtils.TestAppWindowToken token1 = |
chaviw | 97d2820 | 2018-02-27 16:23:53 -0800 | [diff] [blame] | 313 | WindowTestUtils.createTestAppWindowToken(dc0); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 314 | task1.addChild(token1, 0); |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 315 | dc1.configureDisplayPolicy(); |
| 316 | assertNotNull(dc1.mTapDetector); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 317 | |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 318 | // tap on primary display. |
| 319 | tapOnDisplay(dc0); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 320 | // Check focus is on primary display. |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 321 | assertEquals(mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus, |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 322 | dc0.findFocusedWindow()); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 323 | |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 324 | // Tap on secondary display. |
| 325 | tapOnDisplay(dc1); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 326 | // Check focus is on secondary. |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 327 | assertEquals(mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus, |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 328 | dc1.findFocusedWindow()); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 329 | } |
| 330 | |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 331 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 332 | public void testFocusedWindowMultipleDisplays() { |
Tiger Huang | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 333 | doTestFocusedWindowMultipleDisplays(false /* perDisplayFocusEnabled */, Q); |
| 334 | } |
| 335 | |
| 336 | @Test |
| 337 | public void testFocusedWindowMultipleDisplaysPerDisplayFocusEnabled() { |
| 338 | doTestFocusedWindowMultipleDisplays(true /* perDisplayFocusEnabled */, Q); |
| 339 | } |
| 340 | |
| 341 | @Test |
| 342 | public void testFocusedWindowMultipleDisplaysPerDisplayFocusEnabledLegacyApp() { |
| 343 | doTestFocusedWindowMultipleDisplays(true /* perDisplayFocusEnabled */, P); |
| 344 | } |
| 345 | |
| 346 | private void doTestFocusedWindowMultipleDisplays(boolean perDisplayFocusEnabled, |
| 347 | int targetSdk) { |
| 348 | mWm.mPerDisplayFocusEnabled = perDisplayFocusEnabled; |
| 349 | |
Andrii Kulian | 0214ed9 | 2017-05-16 13:44:05 -0700 | [diff] [blame] | 350 | // Create a focusable window and check that focus is calculated correctly |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 351 | final WindowState window1 = |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 352 | createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "window1"); |
Tiger Huang | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 353 | window1.mAppToken.mTargetSdk = targetSdk; |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 354 | updateFocusedWindow(); |
| 355 | assertTrue(window1.isFocused()); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 356 | assertEquals(window1, mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus); |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 357 | |
| 358 | // Check that a new display doesn't affect focus |
| 359 | final DisplayContent dc = createNewDisplay(); |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 360 | updateFocusedWindow(); |
| 361 | assertTrue(window1.isFocused()); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 362 | assertEquals(window1, mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus); |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 363 | |
| 364 | // Add a window to the second display, and it should be focused |
| 365 | final WindowState window2 = createWindow(null, TYPE_BASE_APPLICATION, dc, "window2"); |
Tiger Huang | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 366 | window2.mAppToken.mTargetSdk = targetSdk; |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 367 | updateFocusedWindow(); |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 368 | assertTrue(window2.isFocused()); |
Tiger Huang | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 369 | assertEquals(perDisplayFocusEnabled && targetSdk >= Q, window1.isFocused()); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 370 | assertEquals(window2, mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus); |
David Stevens | 4693956 | 2017-03-24 13:04:00 -0700 | [diff] [blame] | 371 | |
Tiger Huang | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 372 | // 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] | 373 | window1.getParent().positionChildAt(POSITION_TOP, window1, true); |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 374 | updateFocusedWindow(); |
| 375 | assertTrue(window1.isFocused()); |
Tiger Huang | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 376 | assertEquals(perDisplayFocusEnabled && targetSdk >= Q, window2.isFocused()); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 377 | assertEquals(window1, mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus); |
Adrian Roos | 4163d62 | 2018-05-22 16:56:35 +0200 | [diff] [blame] | 378 | } |
| 379 | |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 380 | /** |
| 381 | * This tests setting the maximum ui width on a display. |
| 382 | */ |
| 383 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 384 | public void testMaxUiWidth() { |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 385 | // Prevent base display metrics for test from being updated to the value of real display. |
| 386 | final DisplayContent displayContent = createDisplayNoUpdateDisplayInfo(); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 387 | final int baseWidth = 1440; |
| 388 | final int baseHeight = 2560; |
| 389 | final int baseDensity = 300; |
| 390 | |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 391 | displayContent.updateBaseDisplayMetrics(baseWidth, baseHeight, baseDensity); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 392 | |
| 393 | final int maxWidth = 300; |
| 394 | final int resultingHeight = (maxWidth * baseHeight) / baseWidth; |
| 395 | final int resultingDensity = (maxWidth * baseDensity) / baseWidth; |
| 396 | |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 397 | displayContent.setMaxUiWidth(maxWidth); |
| 398 | verifySizes(displayContent, maxWidth, resultingHeight, resultingDensity); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 399 | |
| 400 | // Assert setting values again does not change; |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 401 | displayContent.updateBaseDisplayMetrics(baseWidth, baseHeight, baseDensity); |
| 402 | verifySizes(displayContent, maxWidth, resultingHeight, resultingDensity); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 403 | |
| 404 | final int smallerWidth = 200; |
| 405 | final int smallerHeight = 400; |
| 406 | final int smallerDensity = 100; |
| 407 | |
| 408 | // Specify smaller dimension, verify that it is honored |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 409 | displayContent.updateBaseDisplayMetrics(smallerWidth, smallerHeight, smallerDensity); |
| 410 | verifySizes(displayContent, smallerWidth, smallerHeight, smallerDensity); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 411 | |
| 412 | // 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] | 413 | displayContent.setMaxUiWidth(maxWidth); |
| 414 | verifySizes(displayContent, smallerWidth, smallerHeight, smallerDensity); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 415 | } |
| 416 | |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 417 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 418 | public void testDisplayCutout_rot0() { |
| 419 | synchronized (mWm.getWindowManagerLock()) { |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 420 | final DisplayContent dc = createNewDisplay(); |
| 421 | dc.mInitialDisplayWidth = 200; |
| 422 | dc.mInitialDisplayHeight = 400; |
Adrian Roos | 2426421 | 2018-02-19 16:26:15 +0100 | [diff] [blame] | 423 | Rect r = new Rect(80, 0, 120, 10); |
Adrian Roos | 6a4fa0e | 2018-03-05 19:50:16 +0100 | [diff] [blame] | 424 | final DisplayCutout cutout = new WmDisplayCutout( |
Issei Suzuki | 43190bd | 2018-08-20 17:28:41 +0200 | [diff] [blame] | 425 | fromBoundingRect(r.left, r.top, r.right, r.bottom, BOUNDS_POSITION_TOP), null) |
Adrian Roos | 6a4fa0e | 2018-03-05 19:50:16 +0100 | [diff] [blame] | 426 | .computeSafeInsets(200, 400).getDisplayCutout(); |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 427 | |
| 428 | dc.mInitialDisplayCutout = cutout; |
| 429 | dc.setRotation(Surface.ROTATION_0); |
| 430 | dc.computeScreenConfiguration(new Configuration()); // recomputes dc.mDisplayInfo. |
| 431 | |
| 432 | assertEquals(cutout, dc.getDisplayInfo().displayCutout); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 437 | public void testDisplayCutout_rot90() { |
| 438 | synchronized (mWm.getWindowManagerLock()) { |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 439 | // Prevent mInitialDisplayCutout from being updated from real display (e.g. null |
| 440 | // if the device has no cutout). |
| 441 | final DisplayContent dc = createDisplayNoUpdateDisplayInfo(); |
| 442 | // Rotation may use real display info to compute bound, so here also uses the |
| 443 | // same width and height. |
| 444 | final int displayWidth = dc.mInitialDisplayWidth; |
| 445 | final int displayHeight = dc.mInitialDisplayHeight; |
| 446 | final int cutoutWidth = 40; |
| 447 | final int cutoutHeight = 10; |
| 448 | final int left = (displayWidth - cutoutWidth) / 2; |
| 449 | final int top = 0; |
| 450 | final int right = (displayWidth + cutoutWidth) / 2; |
| 451 | final int bottom = cutoutHeight; |
| 452 | |
| 453 | final Rect r1 = new Rect(left, top, right, bottom); |
Adrian Roos | 6a4fa0e | 2018-03-05 19:50:16 +0100 | [diff] [blame] | 454 | final DisplayCutout cutout = new WmDisplayCutout( |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 455 | fromBoundingRect(r1.left, r1.top, r1.right, r1.bottom, BOUNDS_POSITION_TOP), |
| 456 | null) |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 457 | .computeSafeInsets(displayWidth, displayHeight).getDisplayCutout(); |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 458 | |
| 459 | dc.mInitialDisplayCutout = cutout; |
| 460 | dc.setRotation(Surface.ROTATION_90); |
| 461 | dc.computeScreenConfiguration(new Configuration()); // recomputes dc.mDisplayInfo. |
| 462 | |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 463 | // ----o---------- ------------- |
| 464 | // | | | | | |
| 465 | // | ------o | o--- |
| 466 | // | | | | |
| 467 | // | | -> | | |
| 468 | // | | ---o |
| 469 | // | | | |
| 470 | // | | ------------- |
| 471 | final Rect r = new Rect(top, left, bottom, right); |
Adrian Roos | 6a4fa0e | 2018-03-05 19:50:16 +0100 | [diff] [blame] | 472 | assertEquals(new WmDisplayCutout( |
Issei Suzuki | 43190bd | 2018-08-20 17:28:41 +0200 | [diff] [blame] | 473 | fromBoundingRect(r.left, r.top, r.right, r.bottom, BOUNDS_POSITION_LEFT), null) |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 474 | .computeSafeInsets(displayHeight, displayWidth) |
| 475 | .getDisplayCutout(), dc.getDisplayInfo().displayCutout); |
Adrian Roos | 1cf58505 | 2018-01-03 18:43:27 +0100 | [diff] [blame] | 476 | } |
| 477 | } |
| 478 | |
| 479 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 480 | public void testLayoutSeq_assignedDuringLayout() { |
| 481 | synchronized (mWm.getWindowManagerLock()) { |
Adrian Roos | 5251b1d | 2018-03-23 18:57:43 +0100 | [diff] [blame] | 482 | |
| 483 | final DisplayContent dc = createNewDisplay(); |
| 484 | final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, dc, "w"); |
| 485 | |
| 486 | dc.setLayoutNeeded(); |
| 487 | dc.performLayout(true /* initial */, false /* updateImeWindows */); |
| 488 | |
| 489 | assertThat(win.mLayoutSeq, is(dc.mLayoutSeq)); |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | @Test |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 494 | @SuppressLint("InlinedApi") |
| 495 | public void testOrientationDefinedByKeyguard() { |
| 496 | final DisplayContent dc = createNewDisplay(); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 497 | |
| 498 | // When display content is created its configuration is not yet initialized, which could |
| 499 | // cause unnecessary configuration propagation, so initialize it here. |
| 500 | final Configuration config = new Configuration(); |
| 501 | dc.computeScreenConfiguration(config); |
| 502 | dc.onRequestedOverrideConfigurationChanged(config); |
| 503 | |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 504 | // Create a window that requests landscape orientation. It will define device orientation |
| 505 | // by default. |
| 506 | final WindowState window = createWindow(null /* parent */, TYPE_BASE_APPLICATION, dc, "w"); |
| 507 | window.mAppToken.setOrientation(SCREEN_ORIENTATION_LANDSCAPE); |
| 508 | |
| 509 | final WindowState keyguard = createWindow(null, TYPE_STATUS_BAR, dc, "keyguard"); |
| 510 | keyguard.mHasSurface = true; |
| 511 | keyguard.mAttrs.screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED; |
| 512 | |
| 513 | assertEquals("Screen orientation must be defined by the app window by default", |
| 514 | SCREEN_ORIENTATION_LANDSCAPE, dc.getOrientation()); |
| 515 | |
| 516 | keyguard.mAttrs.screenOrientation = SCREEN_ORIENTATION_PORTRAIT; |
| 517 | assertEquals("Visible keyguard must influence device orientation", |
| 518 | SCREEN_ORIENTATION_PORTRAIT, dc.getOrientation()); |
| 519 | |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 520 | mWm.setKeyguardGoingAway(true); |
Andrii Kulian | 92c9a94 | 2017-10-10 00:41:41 -0700 | [diff] [blame] | 521 | assertEquals("Keyguard that is going away must not influence device orientation", |
| 522 | SCREEN_ORIENTATION_LANDSCAPE, dc.getOrientation()); |
| 523 | } |
| 524 | |
Andrii Kulian | f0379de | 2018-03-14 16:24:07 -0700 | [diff] [blame] | 525 | @Test |
| 526 | public void testDisableDisplayInfoOverrideFromWindowManager() { |
| 527 | final DisplayContent dc = createNewDisplay(); |
| 528 | |
| 529 | assertTrue(dc.mShouldOverrideDisplayConfiguration); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 530 | mWm.dontOverrideDisplayInfo(dc.getDisplayId()); |
Andrii Kulian | f0379de | 2018-03-14 16:24:07 -0700 | [diff] [blame] | 531 | |
| 532 | assertFalse(dc.mShouldOverrideDisplayConfiguration); |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 533 | verify(mWm.mDisplayManagerInternal, times(1)) |
Andrii Kulian | f0379de | 2018-03-14 16:24:07 -0700 | [diff] [blame] | 534 | .setDisplayInfoOverrideFromWindowManager(dc.getDisplayId(), null); |
| 535 | } |
| 536 | |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 537 | @Test |
Riddle Hsu | 85bd04b | 2018-11-17 00:34:36 +0800 | [diff] [blame] | 538 | public void testClearLastFocusWhenReparentingFocusedWindow() { |
| 539 | final DisplayContent defaultDisplay = mWm.getDefaultDisplayContentLocked(); |
| 540 | final WindowState window = createWindow(null /* parent */, TYPE_BASE_APPLICATION, |
| 541 | defaultDisplay, "window"); |
| 542 | defaultDisplay.mLastFocus = window; |
| 543 | mDisplayContent.mCurrentFocus = window; |
| 544 | mDisplayContent.reParentWindowToken(window.mToken); |
| 545 | |
| 546 | assertNull(defaultDisplay.mLastFocus); |
| 547 | } |
| 548 | |
| 549 | @Test |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 550 | public void testGetPreferredOptionsPanelGravityFromDifferentDisplays() { |
| 551 | final DisplayContent portraitDisplay = createNewDisplay(); |
| 552 | portraitDisplay.mInitialDisplayHeight = 2000; |
| 553 | portraitDisplay.mInitialDisplayWidth = 1000; |
| 554 | |
| 555 | portraitDisplay.setRotation(Surface.ROTATION_0); |
| 556 | assertFalse(isOptionsPanelAtRight(portraitDisplay.getDisplayId())); |
| 557 | portraitDisplay.setRotation(Surface.ROTATION_90); |
| 558 | assertTrue(isOptionsPanelAtRight(portraitDisplay.getDisplayId())); |
| 559 | |
| 560 | final DisplayContent landscapeDisplay = createNewDisplay(); |
| 561 | landscapeDisplay.mInitialDisplayHeight = 1000; |
| 562 | landscapeDisplay.mInitialDisplayWidth = 2000; |
| 563 | |
| 564 | landscapeDisplay.setRotation(Surface.ROTATION_0); |
| 565 | assertTrue(isOptionsPanelAtRight(landscapeDisplay.getDisplayId())); |
| 566 | landscapeDisplay.setRotation(Surface.ROTATION_90); |
| 567 | assertFalse(isOptionsPanelAtRight(landscapeDisplay.getDisplayId())); |
| 568 | } |
| 569 | |
lumark | ff0ab69 | 2018-11-05 20:32:30 +0800 | [diff] [blame] | 570 | @Test |
| 571 | public void testInputMethodTargetUpdateWhenSwitchingOnDisplays() { |
| 572 | final DisplayContent newDisplay = createNewDisplay(); |
| 573 | |
| 574 | final WindowState appWin = createWindow(null, TYPE_APPLICATION, mDisplayContent, "appWin"); |
| 575 | final WindowState appWin1 = createWindow(null, TYPE_APPLICATION, newDisplay, "appWin1"); |
| 576 | appWin.setHasSurface(true); |
| 577 | appWin1.setHasSurface(true); |
| 578 | |
| 579 | // Set current input method window on default display, make sure the input method target |
| 580 | // is appWin & null on the other display. |
| 581 | mDisplayContent.setInputMethodWindowLocked(mImeWindow); |
| 582 | newDisplay.setInputMethodWindowLocked(null); |
| 583 | assertTrue("appWin should be IME target window", |
| 584 | appWin.equals(mDisplayContent.mInputMethodTarget)); |
| 585 | assertNull("newDisplay Ime target: ", newDisplay.mInputMethodTarget); |
| 586 | |
| 587 | // Switch input method window on new display & make sure the input method target also |
| 588 | // switched as expected. |
| 589 | newDisplay.setInputMethodWindowLocked(mImeWindow); |
| 590 | mDisplayContent.setInputMethodWindowLocked(null); |
| 591 | assertTrue("appWin1 should be IME target window", |
| 592 | appWin1.equals(newDisplay.mInputMethodTarget)); |
| 593 | assertNull("default display Ime target: ", mDisplayContent.mInputMethodTarget); |
| 594 | } |
| 595 | |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 596 | @Test |
| 597 | public void testOnDescendantOrientationRequestChanged() { |
Garfield Tan | 49dae10 | 2019-02-04 09:51:59 -0800 | [diff] [blame] | 598 | final DisplayContent dc = createNewDisplay(); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 599 | mWm.mAtmService.mRootActivityContainer = mock(RootActivityContainer.class); |
Garfield Tan | 49dae10 | 2019-02-04 09:51:59 -0800 | [diff] [blame] | 600 | final int newOrientation = dc.getLastOrientation() == SCREEN_ORIENTATION_LANDSCAPE |
| 601 | ? SCREEN_ORIENTATION_PORTRAIT |
| 602 | : SCREEN_ORIENTATION_LANDSCAPE; |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 603 | |
| 604 | final WindowState window = createWindow(null /* parent */, TYPE_BASE_APPLICATION, dc, "w"); |
| 605 | window.getTask().mTaskRecord = mock(TaskRecord.class, ExtendedMockito.RETURNS_DEEP_STUBS); |
Garfield Tan | 49dae10 | 2019-02-04 09:51:59 -0800 | [diff] [blame] | 606 | window.mAppToken.setOrientation(newOrientation); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 607 | |
| 608 | ActivityRecord activityRecord = mock(ActivityRecord.class); |
| 609 | |
| 610 | assertTrue("Display should rotate to handle orientation request by default.", |
| 611 | dc.onDescendantOrientationChanged(window.mToken.token, activityRecord)); |
| 612 | |
| 613 | final ArgumentCaptor<Configuration> captor = ArgumentCaptor.forClass(Configuration.class); |
| 614 | verify(mWm.mAtmService).updateDisplayOverrideConfigurationLocked(captor.capture(), |
| 615 | same(activityRecord), anyBoolean(), eq(dc.getDisplayId())); |
| 616 | final Configuration newDisplayConfig = captor.getValue(); |
Garfield Tan | 49dae10 | 2019-02-04 09:51:59 -0800 | [diff] [blame] | 617 | assertEquals(Configuration.ORIENTATION_PORTRAIT, newDisplayConfig.orientation); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | @Test |
| 621 | public void testOnDescendantOrientationRequestChanged_FrozenToUserRotation() { |
Garfield Tan | 49dae10 | 2019-02-04 09:51:59 -0800 | [diff] [blame] | 622 | final DisplayContent dc = createNewDisplay(); |
Garfield Tan | 7fbca05 | 2019-02-19 10:45:35 -0800 | [diff] [blame] | 623 | dc.getDisplayRotation().setFixedToUserRotation( |
| 624 | DisplayRotation.FIXED_TO_USER_ROTATION_ENABLED); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 625 | mWm.mAtmService.mRootActivityContainer = mock(RootActivityContainer.class); |
Garfield Tan | 49dae10 | 2019-02-04 09:51:59 -0800 | [diff] [blame] | 626 | final int newOrientation = dc.getLastOrientation() == SCREEN_ORIENTATION_LANDSCAPE |
| 627 | ? SCREEN_ORIENTATION_PORTRAIT |
| 628 | : SCREEN_ORIENTATION_LANDSCAPE; |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 629 | |
| 630 | final WindowState window = createWindow(null /* parent */, TYPE_BASE_APPLICATION, dc, "w"); |
| 631 | window.getTask().mTaskRecord = mock(TaskRecord.class, ExtendedMockito.RETURNS_DEEP_STUBS); |
Garfield Tan | 49dae10 | 2019-02-04 09:51:59 -0800 | [diff] [blame] | 632 | window.mAppToken.setOrientation(newOrientation); |
Garfield Tan | 90b0428 | 2018-12-11 14:04:42 -0800 | [diff] [blame] | 633 | |
| 634 | ActivityRecord activityRecord = mock(ActivityRecord.class); |
| 635 | |
| 636 | assertFalse("Display shouldn't rotate to handle orientation request if fixed to" |
| 637 | + " user rotation.", |
| 638 | dc.onDescendantOrientationChanged(window.mToken.token, activityRecord)); |
| 639 | verify(mWm.mAtmService, never()).updateDisplayOverrideConfigurationLocked(any(), |
| 640 | eq(activityRecord), anyBoolean(), eq(dc.getDisplayId())); |
| 641 | } |
| 642 | |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 643 | @Test |
| 644 | public void testComputeImeParent_app() throws Exception { |
| 645 | try (final InsetsModeSession session = |
| 646 | new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) { |
| 647 | final DisplayContent dc = createNewDisplay(); |
| 648 | dc.mInputMethodTarget = createWindow(null, TYPE_BASE_APPLICATION, "app"); |
| 649 | assertEquals(dc.mInputMethodTarget.mAppToken.getSurfaceControl(), |
| 650 | dc.computeImeParent()); |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | @Test |
| 655 | public void testComputeImeParent_app_notFullscreen() throws Exception { |
| 656 | try (final InsetsModeSession session = |
| 657 | new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) { |
| 658 | final DisplayContent dc = createNewDisplay(); |
| 659 | dc.mInputMethodTarget = createWindow(null, TYPE_STATUS_BAR, "app"); |
| 660 | dc.mInputMethodTarget.setWindowingMode( |
| 661 | WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY); |
| 662 | assertEquals(dc.getWindowingLayer(), dc.computeImeParent()); |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | @Test |
Riddle Hsu | 6d6f67c | 2019-03-14 16:54:26 +0800 | [diff] [blame^] | 667 | public void testComputeImeParent_app_notMatchParentBounds() { |
| 668 | spyOn(mAppWindow.mAppToken); |
| 669 | doReturn(false).when(mAppWindow.mAppToken).matchParentBounds(); |
| 670 | mDisplayContent.mInputMethodTarget = mAppWindow; |
| 671 | // The surface parent of IME should be the display instead of app window. |
| 672 | assertEquals(mDisplayContent.getWindowingLayer(), mDisplayContent.computeImeParent()); |
| 673 | } |
| 674 | |
| 675 | @Test |
Tarandeep Singh | a6f3561 | 2019-01-11 19:50:46 -0800 | [diff] [blame] | 676 | public void testComputeImeParent_noApp() throws Exception { |
| 677 | try (final InsetsModeSession session = |
| 678 | new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) { |
| 679 | final DisplayContent dc = createNewDisplay(); |
| 680 | dc.mInputMethodTarget = createWindow(null, TYPE_STATUS_BAR, "statusBar"); |
| 681 | assertEquals(dc.getWindowingLayer(), dc.computeImeParent()); |
| 682 | } |
| 683 | } |
| 684 | |
Susi Kharraz-Post | 9893b8c | 2019-02-12 14:21:29 -0500 | [diff] [blame] | 685 | @Test |
| 686 | public void testOrientationChangeLogging() { |
| 687 | MetricsLogger mockLogger = mock(MetricsLogger.class); |
| 688 | Configuration oldConfig = new Configuration(); |
| 689 | oldConfig.orientation = Configuration.ORIENTATION_LANDSCAPE; |
| 690 | |
| 691 | Configuration newConfig = new Configuration(); |
| 692 | newConfig.orientation = Configuration.ORIENTATION_PORTRAIT; |
| 693 | final DisplayContent displayContent = spy(createNewDisplay()); |
| 694 | Mockito.doReturn(mockLogger).when(displayContent).getMetricsLogger(); |
| 695 | Mockito.doReturn(oldConfig).doReturn(newConfig).when(displayContent).getConfiguration(); |
| 696 | |
| 697 | displayContent.onConfigurationChanged(newConfig); |
| 698 | |
| 699 | ArgumentCaptor<LogMaker> logMakerCaptor = ArgumentCaptor.forClass(LogMaker.class); |
| 700 | verify(mockLogger).write(logMakerCaptor.capture()); |
| 701 | assertThat(logMakerCaptor.getValue().getCategory(), |
| 702 | is(MetricsProto.MetricsEvent.ACTION_PHONE_ORIENTATION_CHANGED)); |
| 703 | assertThat(logMakerCaptor.getValue().getSubtype(), |
| 704 | is(Configuration.ORIENTATION_PORTRAIT)); |
| 705 | } |
| 706 | |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 707 | private boolean isOptionsPanelAtRight(int displayId) { |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 708 | return (mWm.getPreferredOptionsPanelGravity(displayId) & Gravity.RIGHT) == Gravity.RIGHT; |
Riddle Hsu | a4d6fa2 | 2018-08-11 00:50:39 +0800 | [diff] [blame] | 709 | } |
| 710 | |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 711 | private static void verifySizes(DisplayContent displayContent, int expectedBaseWidth, |
| 712 | int expectedBaseHeight, int expectedBaseDensity) { |
| 713 | assertEquals(displayContent.mBaseDisplayWidth, expectedBaseWidth); |
| 714 | assertEquals(displayContent.mBaseDisplayHeight, expectedBaseHeight); |
| 715 | assertEquals(displayContent.mBaseDisplayDensity, expectedBaseDensity); |
| 716 | } |
| 717 | |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 718 | private void updateFocusedWindow() { |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 719 | synchronized (mWm.mGlobalLock) { |
| 720 | mWm.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false); |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 721 | } |
| 722 | } |
| 723 | |
Riddle Hsu | 654a6f9 | 2018-07-13 22:59:36 +0800 | [diff] [blame] | 724 | /** |
| 725 | * Create DisplayContent that does not update display base/initial values from device to keep |
| 726 | * the values set by test. |
| 727 | */ |
| 728 | private DisplayContent createDisplayNoUpdateDisplayInfo() { |
| 729 | final DisplayContent displayContent = spy(createNewDisplay()); |
| 730 | doNothing().when(displayContent).updateDisplayInfo(); |
| 731 | return displayContent; |
| 732 | } |
| 733 | |
Adrian Roos | 0f9368c | 2018-04-08 10:59:08 -0700 | [diff] [blame] | 734 | private void assertForAllWindowsOrder(List<WindowState> expectedWindowsBottomToTop) { |
| 735 | final LinkedList<WindowState> actualWindows = new LinkedList<>(); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 736 | |
| 737 | // Test forward traversal. |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 738 | mDisplayContent.forAllWindows(actualWindows::addLast, false /* traverseTopToBottom */); |
Adrian Roos | 0f9368c | 2018-04-08 10:59:08 -0700 | [diff] [blame] | 739 | assertThat("bottomToTop", actualWindows, is(expectedWindowsBottomToTop)); |
| 740 | |
| 741 | actualWindows.clear(); |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 742 | |
| 743 | // Test backward traversal. |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame] | 744 | mDisplayContent.forAllWindows(actualWindows::addLast, true /* traverseTopToBottom */); |
Adrian Roos | 0f9368c | 2018-04-08 10:59:08 -0700 | [diff] [blame] | 745 | assertThat("topToBottom", actualWindows, is(reverseList(expectedWindowsBottomToTop))); |
| 746 | } |
| 747 | |
| 748 | private static List<WindowState> reverseList(List<WindowState> list) { |
| 749 | final ArrayList<WindowState> result = new ArrayList<>(list); |
| 750 | Collections.reverse(result); |
| 751 | return result; |
Wale Ogunwale | 3424795 | 2017-02-19 11:57:53 -0800 | [diff] [blame] | 752 | } |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 753 | |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 754 | private void tapOnDisplay(final DisplayContent dc) { |
| 755 | final DisplayMetrics dm = dc.getDisplayMetrics(); |
| 756 | final float x = dm.widthPixels / 2; |
| 757 | final float y = dm.heightPixels / 2; |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 758 | final long downTime = SystemClock.uptimeMillis(); |
| 759 | final long eventTime = SystemClock.uptimeMillis() + 100; |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 760 | // sending ACTION_DOWN |
| 761 | final MotionEvent downEvent = MotionEvent.obtain( |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 762 | downTime, |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 763 | downTime, |
| 764 | MotionEvent.ACTION_DOWN, |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 765 | x, |
| 766 | y, |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 767 | 0 /*metaState*/); |
| 768 | downEvent.setDisplayId(dc.getDisplayId()); |
| 769 | dc.mTapDetector.onPointerEvent(downEvent); |
| 770 | |
| 771 | // sending ACTION_UP |
| 772 | final MotionEvent upEvent = MotionEvent.obtain( |
| 773 | downTime, |
| 774 | eventTime, |
| 775 | MotionEvent.ACTION_UP, |
| 776 | x, |
| 777 | y, |
| 778 | 0 /*metaState*/); |
| 779 | upEvent.setDisplayId(dc.getDisplayId()); |
| 780 | dc.mTapDetector.onPointerEvent(upEvent); |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 781 | } |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 782 | } |