Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 14 | * limitations under the License. |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | package com.android.server.wm; |
| 18 | |
| 19 | import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; |
| 20 | import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; |
| 21 | import static android.view.Display.DEFAULT_DISPLAY; |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 22 | import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 23 | import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 24 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 25 | |
Tadashi G. Takaoka | bf0d57b | 2018-11-19 16:09:58 +0900 | [diff] [blame] | 26 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.atLeast; |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 27 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 28 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 29 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.spy; |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 30 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 31 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.times; |
Tadashi G. Takaoka | bf0d57b | 2018-11-19 16:09:58 +0900 | [diff] [blame] | 32 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; |
| 33 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.verifyNoMoreInteractions; |
| 34 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.when; |
Winson Chung | 7906b3e | 2018-05-10 10:32:39 -0700 | [diff] [blame] | 35 | import static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE; |
| 36 | import static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_ORIGINAL_POSITION; |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 37 | import static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_TOP; |
Issei Suzuki | 8b995df | 2020-01-08 12:23:04 +0100 | [diff] [blame] | 38 | import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_RECENTS; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 39 | |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 40 | import static org.junit.Assert.assertEquals; |
Winson Chung | 732446a | 2018-09-19 13:15:17 -0700 | [diff] [blame] | 41 | import static org.junit.Assert.assertFalse; |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 42 | import static org.junit.Assert.assertNotNull; |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 43 | import static org.junit.Assert.assertNull; |
Winson Chung | 732446a | 2018-09-19 13:15:17 -0700 | [diff] [blame] | 44 | import static org.junit.Assert.assertTrue; |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 45 | import static org.junit.Assert.fail; |
lumark | f6f3494 | 2019-04-29 16:56:50 +0800 | [diff] [blame] | 46 | import static org.mockito.ArgumentMatchers.any; |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 47 | import static org.mockito.ArgumentMatchers.anyBoolean; |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 48 | import static org.mockito.ArgumentMatchers.anyInt; |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 49 | import static org.mockito.ArgumentMatchers.eq; |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 50 | import static org.mockito.Mockito.clearInvocations; |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 51 | import static org.mockito.Mockito.mock; |
| 52 | import static org.mockito.Mockito.never; |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 53 | |
Tracy Zhou | 8089ffa | 2019-07-30 17:30:43 -0700 | [diff] [blame] | 54 | import android.app.ActivityManager.TaskSnapshot; |
Vadim Caen | a0fa966 | 2020-01-27 15:00:01 +0100 | [diff] [blame] | 55 | import android.content.pm.ActivityInfo; |
| 56 | import android.content.res.Configuration; |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 57 | import android.os.Binder; |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 58 | import android.os.IBinder; |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 59 | import android.os.IInterface; |
| 60 | import android.platform.test.annotations.Presubmit; |
Winson Chung | 732446a | 2018-09-19 13:15:17 -0700 | [diff] [blame] | 61 | import android.util.SparseBooleanArray; |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 62 | import android.view.IRecentsAnimationRunner; |
| 63 | import android.view.SurfaceControl; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 64 | |
| 65 | import androidx.test.filters.SmallTest; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 66 | |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 67 | import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 68 | |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 69 | import com.google.common.truth.Truth; |
| 70 | |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 71 | import org.junit.Before; |
| 72 | import org.junit.Test; |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 73 | import org.junit.runner.RunWith; |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 74 | import org.mockito.Mock; |
| 75 | import org.mockito.MockitoAnnotations; |
| 76 | |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 77 | import java.util.ArrayList; |
| 78 | |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 79 | /** |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 80 | * Build/Install/Run: |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 81 | * atest WmTests:RecentsAnimationControllerTest |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 82 | */ |
| 83 | @SmallTest |
| 84 | @Presubmit |
Riddle Hsu | 73f5357 | 2019-09-23 23:13:01 +0800 | [diff] [blame] | 85 | @RunWith(WindowTestRunner.class) |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 86 | public class RecentsAnimationControllerTest extends WindowTestsBase { |
| 87 | |
| 88 | @Mock SurfaceControl mMockLeash; |
| 89 | @Mock SurfaceControl.Transaction mMockTransaction; |
| 90 | @Mock OnAnimationFinishedCallback mFinishedCallback; |
| 91 | @Mock IRecentsAnimationRunner mMockRunner; |
| 92 | @Mock RecentsAnimationController.RecentsAnimationCallbacks mAnimationCallbacks; |
Tracy Zhou | 8089ffa | 2019-07-30 17:30:43 -0700 | [diff] [blame] | 93 | @Mock TaskSnapshot mMockTaskSnapshot; |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 94 | private RecentsAnimationController mController; |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 95 | private DisplayContent mDefaultDisplay; |
| 96 | private ActivityStack mRootHomeTask; |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 97 | |
| 98 | @Before |
| 99 | public void setUp() throws Exception { |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 100 | MockitoAnnotations.initMocks(this); |
Riddle Hsu | 72d6dc3 | 2020-03-25 22:58:00 +0800 | [diff] [blame] | 101 | doNothing().when(mWm.mRoot).performSurfacePlacement(); |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 102 | when(mMockRunner.asBinder()).thenReturn(new Binder()); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 103 | mDefaultDisplay = mWm.mRoot.getDefaultDisplay(); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 104 | mController = spy(new RecentsAnimationController(mWm, mMockRunner, mAnimationCallbacks, |
| 105 | DEFAULT_DISPLAY)); |
Andrii Kulian | 4c0fd0d | 2020-03-29 13:32:14 -0700 | [diff] [blame] | 106 | mRootHomeTask = mDefaultDisplay.getDefaultTaskDisplayArea().getRootHomeTask(); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 107 | assertNotNull(mRootHomeTask); |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | @Test |
| 111 | public void testRemovedBeforeStarted_expectCanceled() throws Exception { |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 112 | final ActivityRecord activity = createActivityRecord(mDefaultDisplay, |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 113 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 114 | AnimationAdapter adapter = mController.addAnimation(activity.getTask(), |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 115 | false /* isRecentTaskInvisible */); |
Issei Suzuki | 8b995df | 2020-01-08 12:23:04 +0100 | [diff] [blame] | 116 | adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_RECENTS, |
| 117 | mFinishedCallback); |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 118 | |
| 119 | // Remove the app window so that the animation target can not be created |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 120 | activity.removeImmediately(); |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 121 | mController.startAnimation(); |
| 122 | |
| 123 | // Verify that the finish callback to reparent the leash is called |
Issei Suzuki | 8b995df | 2020-01-08 12:23:04 +0100 | [diff] [blame] | 124 | verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_RECENTS), eq(adapter)); |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 125 | // Verify the animation canceled callback to the app was made |
Tracy Zhou | 8089ffa | 2019-07-30 17:30:43 -0700 | [diff] [blame] | 126 | verify(mMockRunner).onAnimationCanceled(null /* taskSnapshot */); |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 127 | verifyNoMoreInteractionsExceptAsBinder(mMockRunner); |
| 128 | } |
| 129 | |
Winson Chung | 7906b3e | 2018-05-10 10:32:39 -0700 | [diff] [blame] | 130 | @Test |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 131 | public void testCancelAfterRemove_expectIgnored() { |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 132 | final ActivityRecord activity = createActivityRecord(mDefaultDisplay, |
Winson Chung | 7906b3e | 2018-05-10 10:32:39 -0700 | [diff] [blame] | 133 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 134 | AnimationAdapter adapter = mController.addAnimation(activity.getTask(), |
Winson Chung | 7906b3e | 2018-05-10 10:32:39 -0700 | [diff] [blame] | 135 | false /* isRecentTaskInvisible */); |
Issei Suzuki | 8b995df | 2020-01-08 12:23:04 +0100 | [diff] [blame] | 136 | adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_RECENTS, |
| 137 | mFinishedCallback); |
Winson Chung | 7906b3e | 2018-05-10 10:32:39 -0700 | [diff] [blame] | 138 | |
| 139 | // Remove the app window so that the animation target can not be created |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 140 | activity.removeImmediately(); |
Winson Chung | 7906b3e | 2018-05-10 10:32:39 -0700 | [diff] [blame] | 141 | mController.startAnimation(); |
| 142 | mController.cleanupAnimation(REORDER_KEEP_IN_PLACE); |
| 143 | try { |
| 144 | mController.cancelAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION, "test"); |
| 145 | } catch (Exception e) { |
| 146 | fail("Unexpected failure when canceling animation after finishing it"); |
| 147 | } |
| 148 | } |
| 149 | |
Tadashi G. Takaoka | b6e148c | 2018-11-03 02:59:06 -0700 | [diff] [blame] | 150 | @Test |
| 151 | public void testIncludedApps_expectTargetAndVisible() { |
| 152 | mWm.setRecentsAnimationController(mController); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 153 | final ActivityRecord homeActivity = createHomeActivity(); |
| 154 | final ActivityRecord activity = createActivityRecord(mDefaultDisplay, |
Winson Chung | 732446a | 2018-09-19 13:15:17 -0700 | [diff] [blame] | 155 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 156 | final ActivityRecord hiddenActivity = createActivityRecord(mDefaultDisplay, |
Winson Chung | 732446a | 2018-09-19 13:15:17 -0700 | [diff] [blame] | 157 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
Issei Suzuki | f2f6c91 | 2019-11-08 11:24:18 +0100 | [diff] [blame] | 158 | hiddenActivity.setVisible(false); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 159 | mDefaultDisplay.getConfiguration().windowConfiguration.setRotation( |
| 160 | mDefaultDisplay.getRotation()); |
Riddle Hsu | 70a920c | 2020-05-05 17:20:32 +0800 | [diff] [blame] | 161 | initializeRecentsAnimationController(mController, homeActivity); |
Winson Chung | 732446a | 2018-09-19 13:15:17 -0700 | [diff] [blame] | 162 | |
| 163 | // Ensure that we are animating the target activity as well |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 164 | assertTrue(mController.isAnimatingTask(homeActivity.getTask())); |
| 165 | assertTrue(mController.isAnimatingTask(activity.getTask())); |
| 166 | assertFalse(mController.isAnimatingTask(hiddenActivity.getTask())); |
Winson Chung | 732446a | 2018-09-19 13:15:17 -0700 | [diff] [blame] | 167 | } |
| 168 | |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 169 | @Test |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 170 | public void testWallpaperIncluded_expectTarget() throws Exception { |
| 171 | mWm.setRecentsAnimationController(mController); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 172 | final ActivityRecord homeActivity = createHomeActivity(); |
| 173 | final ActivityRecord activity = createActivityRecord(mDefaultDisplay, |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 174 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 175 | final WindowState win1 = createWindow(null, TYPE_BASE_APPLICATION, activity, "win1"); |
| 176 | activity.addWindow(win1); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 177 | final WallpaperWindowToken wallpaperWindowToken = new WallpaperWindowToken(mWm, |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 178 | mock(IBinder.class), true, mDefaultDisplay, true /* ownerCanManageAppTokens */); |
| 179 | spyOn(mDefaultDisplay.mWallpaperController); |
| 180 | doReturn(true).when(mDefaultDisplay.mWallpaperController).isWallpaperVisible(); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 181 | |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 182 | mDefaultDisplay.getConfiguration().windowConfiguration.setRotation( |
| 183 | mDefaultDisplay.getRotation()); |
Riddle Hsu | 70a920c | 2020-05-05 17:20:32 +0800 | [diff] [blame] | 184 | initializeRecentsAnimationController(mController, homeActivity); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 185 | mController.startAnimation(); |
| 186 | |
| 187 | // Ensure that we are animating the app and wallpaper target |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 188 | assertTrue(mController.isAnimatingTask(activity.getTask())); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 189 | assertTrue(mController.isAnimatingWallpaper(wallpaperWindowToken)); |
| 190 | } |
| 191 | |
| 192 | @Test |
| 193 | public void testWallpaperAnimatorCanceled_expectAnimationKeepsRunning() throws Exception { |
| 194 | mWm.setRecentsAnimationController(mController); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 195 | final ActivityRecord homeActivity = createHomeActivity(); |
| 196 | final ActivityRecord activity = createActivityRecord(mDefaultDisplay, |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 197 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 198 | final WindowState win1 = createWindow(null, TYPE_BASE_APPLICATION, activity, "win1"); |
| 199 | activity.addWindow(win1); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 200 | final WallpaperWindowToken wallpaperWindowToken = new WallpaperWindowToken(mWm, |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 201 | mock(IBinder.class), true, mDefaultDisplay, true /* ownerCanManageAppTokens */); |
| 202 | spyOn(mDefaultDisplay.mWallpaperController); |
| 203 | doReturn(true).when(mDefaultDisplay.mWallpaperController).isWallpaperVisible(); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 204 | |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 205 | mDefaultDisplay.getConfiguration().windowConfiguration.setRotation( |
| 206 | mDefaultDisplay.getRotation()); |
Riddle Hsu | 70a920c | 2020-05-05 17:20:32 +0800 | [diff] [blame] | 207 | initializeRecentsAnimationController(mController, homeActivity); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 208 | mController.startAnimation(); |
| 209 | |
| 210 | // Cancel the animation and ensure the controller is still running |
| 211 | wallpaperWindowToken.cancelAnimation(); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 212 | assertTrue(mController.isAnimatingTask(activity.getTask())); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 213 | assertFalse(mController.isAnimatingWallpaper(wallpaperWindowToken)); |
| 214 | verify(mMockRunner, never()).onAnimationCanceled(null /* taskSnapshot */); |
| 215 | } |
| 216 | |
| 217 | @Test |
| 218 | public void testFinish_expectTargetAndWallpaperAdaptersRemoved() { |
| 219 | mWm.setRecentsAnimationController(mController); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 220 | final ActivityRecord homeActivity = createHomeActivity(); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 221 | final WindowState hwin1 = createWindow(null, TYPE_BASE_APPLICATION, homeActivity, "hwin1"); |
| 222 | homeActivity.addWindow(hwin1); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 223 | final ActivityRecord activity = createActivityRecord(mDefaultDisplay, |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 224 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 225 | final WindowState win1 = createWindow(null, TYPE_BASE_APPLICATION, activity, "win1"); |
| 226 | activity.addWindow(win1); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 227 | final WallpaperWindowToken wallpaperWindowToken = new WallpaperWindowToken(mWm, |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 228 | mock(IBinder.class), true, mDefaultDisplay, true /* ownerCanManageAppTokens */); |
| 229 | spyOn(mDefaultDisplay.mWallpaperController); |
| 230 | doReturn(true).when(mDefaultDisplay.mWallpaperController).isWallpaperVisible(); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 231 | |
| 232 | // Start and finish the animation |
Riddle Hsu | 70a920c | 2020-05-05 17:20:32 +0800 | [diff] [blame] | 233 | initializeRecentsAnimationController(mController, homeActivity); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 234 | mController.startAnimation(); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 235 | |
| 236 | assertTrue(mController.isAnimatingTask(homeActivity.getTask())); |
| 237 | assertTrue(mController.isAnimatingTask(activity.getTask())); |
| 238 | |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 239 | // Reset at this point since we may remove adapters that couldn't be created |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 240 | clearInvocations(mController); |
Winson Chung | d585219 | 2019-09-06 17:20:28 -0700 | [diff] [blame] | 241 | mController.cleanupAnimation(REORDER_MOVE_TO_TOP); |
| 242 | |
| 243 | // Ensure that we remove the task (home & app) and wallpaper adapters |
| 244 | verify(mController, times(2)).removeAnimation(any()); |
| 245 | verify(mController, times(1)).removeWallpaperAnimation(any()); |
| 246 | } |
| 247 | |
| 248 | @Test |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 249 | public void testDeferCancelAnimation() throws Exception { |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 250 | mWm.setRecentsAnimationController(mController); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 251 | final ActivityRecord activity = createActivityRecord(mDefaultDisplay, |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 252 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 253 | final WindowState win1 = createWindow(null, TYPE_BASE_APPLICATION, activity, "win1"); |
| 254 | activity.addWindow(win1); |
| 255 | assertEquals(activity.getTask().getTopVisibleActivity(), activity); |
| 256 | assertEquals(activity.findMainWindow(), win1); |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 257 | |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 258 | mController.addAnimation(activity.getTask(), false /* isRecentTaskInvisible */); |
| 259 | assertTrue(mController.isAnimatingTask(activity.getTask())); |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 260 | |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 261 | mController.setDeferredCancel(true /* deferred */, false /* screenshot */); |
| 262 | mController.cancelAnimationWithScreenshot(false /* screenshot */); |
Tracy Zhou | 8089ffa | 2019-07-30 17:30:43 -0700 | [diff] [blame] | 263 | verify(mMockRunner).onAnimationCanceled(null /* taskSnapshot */); |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 264 | assertNull(mController.mRecentScreenshotAnimator); |
| 265 | |
| 266 | // Simulate the app transition finishing |
| 267 | mController.mAppTransitionListener.onAppTransitionStartingLocked(0, 0, 0, 0); |
Wale Ogunwale | a441b92 | 2019-06-27 19:21:44 -0700 | [diff] [blame] | 268 | verify(mAnimationCallbacks).onAnimationFinished(REORDER_KEEP_IN_PLACE, false); |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | @Test |
| 272 | public void testDeferCancelAnimationWithScreenShot() throws Exception { |
| 273 | mWm.setRecentsAnimationController(mController); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 274 | final ActivityRecord activity = createActivityRecord(mDefaultDisplay, |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 275 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 276 | final WindowState win1 = createWindow(null, TYPE_BASE_APPLICATION, activity, "win1"); |
| 277 | activity.addWindow(win1); |
| 278 | assertEquals(activity.getTask().getTopVisibleActivity(), activity); |
| 279 | assertEquals(activity.findMainWindow(), win1); |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 280 | |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 281 | mController.addAnimation(activity.getTask(), false /* isRecentTaskInvisible */); |
| 282 | assertTrue(mController.isAnimatingTask(activity.getTask())); |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 283 | |
Tracy Zhou | 8089ffa | 2019-07-30 17:30:43 -0700 | [diff] [blame] | 284 | spyOn(mWm.mTaskSnapshotController); |
| 285 | doNothing().when(mWm.mTaskSnapshotController).notifyAppVisibilityChanged(any(), |
| 286 | anyBoolean()); |
| 287 | doReturn(mMockTaskSnapshot).when(mWm.mTaskSnapshotController).getSnapshot(anyInt(), |
Peter Kalauskas | 4dc0460 | 2020-02-12 18:49:03 -0800 | [diff] [blame] | 288 | anyInt(), eq(false) /* restoreFromDisk */, eq(false) /* isLowResolution */); |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 289 | mController.setDeferredCancel(true /* deferred */, true /* screenshot */); |
| 290 | mController.cancelAnimationWithScreenshot(true /* screenshot */); |
Tracy Zhou | 8089ffa | 2019-07-30 17:30:43 -0700 | [diff] [blame] | 291 | verify(mMockRunner).onAnimationCanceled(mMockTaskSnapshot /* taskSnapshot */); |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 292 | assertNotNull(mController.mRecentScreenshotAnimator); |
| 293 | assertTrue(mController.mRecentScreenshotAnimator.isAnimating()); |
| 294 | |
| 295 | // Assume IRecentsAnimationController#cleanupScreenshot called to finish screenshot |
| 296 | // animation. |
lumark | f6f3494 | 2019-04-29 16:56:50 +0800 | [diff] [blame] | 297 | spyOn(mController.mRecentScreenshotAnimator.mAnimatable); |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 298 | mController.mRecentScreenshotAnimator.cancelAnimation(); |
lumark | f6f3494 | 2019-04-29 16:56:50 +0800 | [diff] [blame] | 299 | verify(mController.mRecentScreenshotAnimator.mAnimatable).onAnimationLeashLost(any()); |
Wale Ogunwale | a441b92 | 2019-06-27 19:21:44 -0700 | [diff] [blame] | 300 | verify(mAnimationCallbacks).onAnimationFinished(REORDER_KEEP_IN_PLACE, false); |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 301 | } |
| 302 | |
lumark | b5a78b3 | 2019-04-25 20:31:30 +0800 | [diff] [blame] | 303 | @Test |
| 304 | public void testShouldAnimateWhenNoCancelWithDeferredScreenshot() { |
| 305 | mWm.setRecentsAnimationController(mController); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 306 | final ActivityRecord activity = createActivityRecord(mDefaultDisplay, |
lumark | b5a78b3 | 2019-04-25 20:31:30 +0800 | [diff] [blame] | 307 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 308 | final WindowState win1 = createWindow(null, TYPE_BASE_APPLICATION, activity, "win1"); |
| 309 | activity.addWindow(win1); |
| 310 | assertEquals(activity.getTask().getTopVisibleActivity(), activity); |
| 311 | assertEquals(activity.findMainWindow(), win1); |
lumark | b5a78b3 | 2019-04-25 20:31:30 +0800 | [diff] [blame] | 312 | |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 313 | mController.addAnimation(activity.getTask(), false /* isRecentTaskInvisible */); |
| 314 | assertTrue(mController.isAnimatingTask(activity.getTask())); |
lumark | b5a78b3 | 2019-04-25 20:31:30 +0800 | [diff] [blame] | 315 | |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 316 | // Assume activity transition should animate when no |
Hongwei Wang | 85cf41f | 2020-01-15 15:14:47 -0800 | [diff] [blame] | 317 | // IRecentsAnimationController#setDeferCancelUntilNextTransition called. |
Winson Chung | 7a545ae | 2019-07-16 14:52:13 -0700 | [diff] [blame] | 318 | assertFalse(mController.shouldDeferCancelWithScreenshot()); |
Evan Rosky | 50ea8c1 | 2020-04-02 20:49:05 -0700 | [diff] [blame] | 319 | assertTrue(activity.shouldAnimate()); |
lumark | b5a78b3 | 2019-04-25 20:31:30 +0800 | [diff] [blame] | 320 | } |
| 321 | |
Vadim Caen | a0fa966 | 2020-01-27 15:00:01 +0100 | [diff] [blame] | 322 | @Test |
| 323 | public void testRecentViewInFixedPortraitWhenTopAppInLandscape() { |
Vadim Caen | a0fa966 | 2020-01-27 15:00:01 +0100 | [diff] [blame] | 324 | mWm.setRecentsAnimationController(mController); |
| 325 | |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 326 | final ActivityRecord homeActivity = createHomeActivity(); |
| 327 | homeActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
Vadim Caen | a0fa966 | 2020-01-27 15:00:01 +0100 | [diff] [blame] | 328 | |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 329 | final ActivityRecord landActivity = createActivityRecord(mDefaultDisplay, |
Vadim Caen | a0fa966 | 2020-01-27 15:00:01 +0100 | [diff] [blame] | 330 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
| 331 | landActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); |
| 332 | final WindowState win1 = createWindow(null, TYPE_BASE_APPLICATION, landActivity, "win1"); |
| 333 | landActivity.addWindow(win1); |
| 334 | |
| 335 | assertEquals(landActivity.getTask().getTopVisibleActivity(), landActivity); |
| 336 | assertEquals(landActivity.findMainWindow(), win1); |
| 337 | |
| 338 | // Ensure that the display is in Landscape |
| 339 | landActivity.onDescendantOrientationChanged(landActivity.token, landActivity); |
| 340 | assertEquals(Configuration.ORIENTATION_LANDSCAPE, |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 341 | mDefaultDisplay.getConfiguration().orientation); |
Vadim Caen | a0fa966 | 2020-01-27 15:00:01 +0100 | [diff] [blame] | 342 | |
Riddle Hsu | 70a920c | 2020-05-05 17:20:32 +0800 | [diff] [blame] | 343 | initializeRecentsAnimationController(mController, homeActivity); |
Vadim Caen | a0fa966 | 2020-01-27 15:00:01 +0100 | [diff] [blame] | 344 | |
Riddle Hsu | 08bc4ed | 2020-05-26 18:32:18 +0800 | [diff] [blame] | 345 | assertTrue(mDefaultDisplay.isFixedRotationLaunchingApp(homeActivity)); |
Riddle Hsu | cbc5d27 | 2020-04-24 23:26:46 +0800 | [diff] [blame] | 346 | |
Vadim Caen | a0fa966 | 2020-01-27 15:00:01 +0100 | [diff] [blame] | 347 | // Check that the home app is in portrait |
| 348 | assertEquals(Configuration.ORIENTATION_PORTRAIT, |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 349 | homeActivity.getConfiguration().orientation); |
Riddle Hsu | cbc5d27 | 2020-04-24 23:26:46 +0800 | [diff] [blame] | 350 | |
Riddle Hsu | e291c7d | 2020-06-10 22:58:20 +0800 | [diff] [blame] | 351 | // Home activity won't become top (return to landActivity), so the top rotated record should |
| 352 | // be cleared. |
Riddle Hsu | cbc5d27 | 2020-04-24 23:26:46 +0800 | [diff] [blame] | 353 | mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION); |
Riddle Hsu | e291c7d | 2020-06-10 22:58:20 +0800 | [diff] [blame] | 354 | assertFalse(mDefaultDisplay.isFixedRotationLaunchingApp(homeActivity)); |
Riddle Hsu | 08bc4ed | 2020-05-26 18:32:18 +0800 | [diff] [blame] | 355 | assertFalse(mDefaultDisplay.hasTopFixedRotationLaunchingApp()); |
Riddle Hsu | e291c7d | 2020-06-10 22:58:20 +0800 | [diff] [blame] | 356 | // The transform should keep until the transition is done, so the restored configuration |
| 357 | // won't be sent to activity and cause unnecessary configuration change. |
| 358 | assertTrue(homeActivity.hasFixedRotationTransform()); |
| 359 | |
| 360 | // In real case the transition will be executed from RecentsAnimation#finishAnimation. |
| 361 | mDefaultDisplay.mFixedRotationTransitionListener.onAppTransitionFinishedLocked( |
| 362 | homeActivity.token); |
| 363 | assertFalse(homeActivity.hasFixedRotationTransform()); |
Vadim Caen | a0fa966 | 2020-01-27 15:00:01 +0100 | [diff] [blame] | 364 | } |
| 365 | |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 366 | @Test |
Riddle Hsu | 70a920c | 2020-05-05 17:20:32 +0800 | [diff] [blame] | 367 | public void testClearFixedRotationLaunchingAppAfterCleanupAnimation() { |
| 368 | final ActivityRecord homeActivity = createHomeActivity(); |
| 369 | homeActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| 370 | final ActivityRecord activity = createActivityRecord(mDefaultDisplay, |
| 371 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
| 372 | // Assume an activity is launching to different rotation. |
| 373 | mDefaultDisplay.setFixedRotationLaunchingApp(activity, |
| 374 | (mDefaultDisplay.getRotation() + 1) % 4); |
| 375 | |
| 376 | assertTrue(activity.hasFixedRotationTransform()); |
Riddle Hsu | 08bc4ed | 2020-05-26 18:32:18 +0800 | [diff] [blame] | 377 | assertTrue(mDefaultDisplay.isFixedRotationLaunchingApp(activity)); |
Riddle Hsu | 70a920c | 2020-05-05 17:20:32 +0800 | [diff] [blame] | 378 | |
| 379 | // Before the transition is done, the recents animation is triggered. |
| 380 | initializeRecentsAnimationController(mController, homeActivity); |
| 381 | assertFalse(homeActivity.hasFixedRotationTransform()); |
| 382 | |
| 383 | // Simulate giving up the swipe up gesture to keep the original activity as top. |
| 384 | mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION); |
| 385 | // The rotation transform should be cleared after updating orientation with display. |
| 386 | assertFalse(activity.hasFixedRotationTransform()); |
Riddle Hsu | 08bc4ed | 2020-05-26 18:32:18 +0800 | [diff] [blame] | 387 | assertFalse(mDefaultDisplay.hasTopFixedRotationLaunchingApp()); |
Riddle Hsu | 70a920c | 2020-05-05 17:20:32 +0800 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | @Test |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 391 | public void testWallpaperHasFixedRotationApplied() { |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 392 | mWm.setRecentsAnimationController(mController); |
| 393 | |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 394 | // Create a portrait home activity, a wallpaper and a landscape activity displayed on top. |
| 395 | final ActivityRecord homeActivity = createHomeActivity(); |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 396 | homeActivity.setOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| 397 | |
| 398 | final WindowState homeWindow = createWindow(null, TYPE_BASE_APPLICATION, homeActivity, |
| 399 | "homeWindow"); |
| 400 | homeActivity.addWindow(homeWindow); |
| 401 | homeWindow.getAttrs().flags |= FLAG_SHOW_WALLPAPER; |
| 402 | |
| 403 | // Landscape application |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 404 | final ActivityRecord activity = createActivityRecord(mDefaultDisplay, |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 405 | WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD); |
| 406 | final WindowState applicationWindow = createWindow(null, TYPE_BASE_APPLICATION, activity, |
| 407 | "applicationWindow"); |
| 408 | activity.addWindow(applicationWindow); |
| 409 | activity.setOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); |
| 410 | |
| 411 | // Wallpaper |
| 412 | final WallpaperWindowToken wallpaperWindowToken = new WallpaperWindowToken(mWm, |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 413 | mock(IBinder.class), true, mDefaultDisplay, true /* ownerCanManageAppTokens */); |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 414 | final WindowState wallpaperWindow = createWindow(null, TYPE_WALLPAPER, wallpaperWindowToken, |
| 415 | "wallpaperWindow"); |
| 416 | |
| 417 | // Make sure the landscape activity is on top and the display is in landscape |
| 418 | activity.moveFocusableActivityToTop("test"); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 419 | mDefaultDisplay.getConfiguration().windowConfiguration.setRotation( |
| 420 | mDefaultDisplay.getRotation()); |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 421 | |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 422 | spyOn(mDefaultDisplay.mWallpaperController); |
| 423 | doReturn(true).when(mDefaultDisplay.mWallpaperController).isWallpaperVisible(); |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 424 | |
| 425 | // Start the recents animation |
Riddle Hsu | 70a920c | 2020-05-05 17:20:32 +0800 | [diff] [blame] | 426 | initializeRecentsAnimationController(mController, homeActivity); |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 427 | |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 428 | mDefaultDisplay.mWallpaperController.adjustWallpaperWindows(); |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 429 | |
| 430 | // Check preconditions |
| 431 | ArrayList<WallpaperWindowToken> wallpapers = new ArrayList<>(1); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 432 | mDefaultDisplay.forAllWallpaperWindows(wallpapers::add); |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 433 | |
| 434 | Truth.assertThat(wallpapers).hasSize(1); |
| 435 | Truth.assertThat(wallpapers.get(0).getTopChild()).isEqualTo(wallpaperWindow); |
| 436 | |
| 437 | // Actual check |
| 438 | assertEquals(Configuration.ORIENTATION_PORTRAIT, |
| 439 | wallpapers.get(0).getConfiguration().orientation); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 440 | |
Riddle Hsu | cbc5d27 | 2020-04-24 23:26:46 +0800 | [diff] [blame] | 441 | mController.cleanupAnimation(REORDER_MOVE_TO_TOP); |
| 442 | // The transform state should keep because we expect to listen the signal from the |
| 443 | // transition executed by moving the task to front. |
| 444 | assertTrue(homeActivity.hasFixedRotationTransform()); |
Riddle Hsu | 08bc4ed | 2020-05-26 18:32:18 +0800 | [diff] [blame] | 445 | assertTrue(mDefaultDisplay.isFixedRotationLaunchingApp(homeActivity)); |
Riddle Hsu | cbc5d27 | 2020-04-24 23:26:46 +0800 | [diff] [blame] | 446 | |
| 447 | mDefaultDisplay.mFixedRotationTransitionListener.onAppTransitionFinishedLocked( |
| 448 | homeActivity.token); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 449 | // Wallpaper's transform state should be cleared with home. |
Riddle Hsu | cbc5d27 | 2020-04-24 23:26:46 +0800 | [diff] [blame] | 450 | assertFalse(homeActivity.hasFixedRotationTransform()); |
Riddle Hsu | 6393ad1 | 2020-03-02 23:56:32 +0800 | [diff] [blame] | 451 | assertFalse(wallpaperWindowToken.hasFixedRotationTransform()); |
| 452 | } |
| 453 | |
| 454 | private ActivityRecord createHomeActivity() { |
| 455 | final ActivityRecord homeActivity = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService) |
| 456 | .setStack(mRootHomeTask) |
| 457 | .setCreateTask(true) |
| 458 | .build(); |
| 459 | // Avoid {@link RecentsAnimationController.TaskAnimationAdapter#createRemoteAnimationTarget} |
| 460 | // returning null when calling {@link RecentsAnimationController#createAppAnimations}. |
| 461 | homeActivity.setVisibility(true); |
| 462 | return homeActivity; |
Vadim Caen | 2a9ccc9 | 2020-01-29 12:21:41 +0100 | [diff] [blame] | 463 | } |
| 464 | |
Riddle Hsu | 70a920c | 2020-05-05 17:20:32 +0800 | [diff] [blame] | 465 | private static void initializeRecentsAnimationController(RecentsAnimationController controller, |
| 466 | ActivityRecord activity) { |
| 467 | controller.initialize(activity.getActivityType(), new SparseBooleanArray(), activity); |
| 468 | } |
| 469 | |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 470 | private static void verifyNoMoreInteractionsExceptAsBinder(IInterface binder) { |
| 471 | verify(binder, atLeast(0)).asBinder(); |
| 472 | verifyNoMoreInteractions(binder); |
| 473 | } |
| 474 | } |