Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.am; |
| 18 | |
Wale Ogunwale | 04a05ac | 2017-09-17 21:35:02 -0700 | [diff] [blame] | 19 | import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; |
Wale Ogunwale | 9dcf946 | 2017-09-19 15:13:01 -0700 | [diff] [blame] | 20 | import static android.view.Display.DEFAULT_DISPLAY; |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 21 | import static org.mockito.Mockito.mock; |
Bryce Lee | 04ab346 | 2017-04-10 15:06:33 -0700 | [diff] [blame] | 22 | import static org.mockito.Mockito.doReturn; |
| 23 | import static org.mockito.Mockito.any; |
| 24 | import static org.mockito.Mockito.doAnswer; |
Bryce Lee | 4e4a3ec | 2017-09-27 08:25:03 -0700 | [diff] [blame] | 25 | import static org.mockito.Mockito.spy; |
Bryce Lee | 04ab346 | 2017-04-10 15:06:33 -0700 | [diff] [blame] | 26 | |
| 27 | import org.mockito.invocation.InvocationOnMock; |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 28 | |
| 29 | import android.content.ComponentName; |
| 30 | import android.content.Context; |
| 31 | import android.content.Intent; |
| 32 | import android.content.pm.ActivityInfo; |
| 33 | import android.content.pm.ApplicationInfo; |
| 34 | import android.content.res.Configuration; |
| 35 | import android.graphics.Rect; |
Wale Ogunwale | 9dcf946 | 2017-09-19 15:13:01 -0700 | [diff] [blame] | 36 | import android.hardware.display.DisplayManager; |
Bryce Lee | 3115bdf | 2017-04-05 08:39:40 -0700 | [diff] [blame] | 37 | import android.os.HandlerThread; |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 38 | import android.os.Looper; |
| 39 | import android.support.test.InstrumentationRegistry; |
| 40 | import com.android.server.AttributeCache; |
| 41 | import com.android.server.wm.AppWindowContainerController; |
Bryce Lee | 4e4a3ec | 2017-09-27 08:25:03 -0700 | [diff] [blame] | 42 | import com.android.server.wm.PinnedStackWindowController; |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 43 | import com.android.server.wm.StackWindowController; |
Bryce Lee | 04ab346 | 2017-04-10 15:06:33 -0700 | [diff] [blame] | 44 | import com.android.server.wm.TaskWindowContainerController; |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 45 | import com.android.server.wm.WindowManagerService; |
| 46 | import com.android.server.wm.WindowTestUtils; |
Bryce Lee | 3115bdf | 2017-04-05 08:39:40 -0700 | [diff] [blame] | 47 | import org.junit.After; |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 48 | import org.junit.Before; |
| 49 | import org.mockito.MockitoAnnotations; |
| 50 | |
| 51 | /** |
| 52 | * A base class to handle common operations in activity related unit tests. |
| 53 | */ |
| 54 | public class ActivityTestsBase { |
Bryce Lee | 939a9a3 | 2017-10-23 10:01:21 -0700 | [diff] [blame] | 55 | private static boolean sOneTimeSetupDone = false; |
| 56 | |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 57 | private final Context mContext = InstrumentationRegistry.getContext(); |
Bryce Lee | 3115bdf | 2017-04-05 08:39:40 -0700 | [diff] [blame] | 58 | private HandlerThread mHandlerThread; |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 59 | |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 60 | @Before |
| 61 | public void setUp() throws Exception { |
Bryce Lee | 939a9a3 | 2017-10-23 10:01:21 -0700 | [diff] [blame] | 62 | if (!sOneTimeSetupDone) { |
| 63 | sOneTimeSetupDone = true; |
| 64 | |
| 65 | // Allows to mock package local classes and methods |
| 66 | System.setProperty("dexmaker.share_classloader", "true"); |
| 67 | MockitoAnnotations.initMocks(this); |
| 68 | } |
Bryce Lee | 3115bdf | 2017-04-05 08:39:40 -0700 | [diff] [blame] | 69 | mHandlerThread = new HandlerThread("ActivityTestsBaseThread"); |
| 70 | mHandlerThread.start(); |
| 71 | } |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 72 | |
Bryce Lee | 3115bdf | 2017-04-05 08:39:40 -0700 | [diff] [blame] | 73 | @After |
| 74 | public void tearDown() { |
| 75 | mHandlerThread.quitSafely(); |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | protected ActivityManagerService createActivityManagerService() { |
Bryce Lee | 4e4a3ec | 2017-09-27 08:25:03 -0700 | [diff] [blame] | 79 | final ActivityManagerService service = spy(new TestActivityManagerService(mContext)); |
| 80 | service.mWindowManager = prepareMockWindowManager(); |
Bryce Lee | 840c566 | 2017-04-13 10:02:51 -0700 | [diff] [blame] | 81 | return service; |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 82 | } |
| 83 | |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 84 | protected static ActivityRecord createActivity(ActivityManagerService service, |
| 85 | ComponentName component, TaskRecord task) { |
Bryce Lee | 9f6affd | 2017-09-01 09:18:35 -0700 | [diff] [blame] | 86 | return createActivity(service, component, task, 0 /* userId */); |
| 87 | } |
| 88 | |
| 89 | protected static ActivityRecord createActivity(ActivityManagerService service, |
| 90 | ComponentName component, TaskRecord task, int uid) { |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 91 | Intent intent = new Intent(); |
| 92 | intent.setComponent(component); |
| 93 | final ActivityInfo aInfo = new ActivityInfo(); |
| 94 | aInfo.applicationInfo = new ApplicationInfo(); |
| 95 | aInfo.applicationInfo.packageName = component.getPackageName(); |
Bryce Lee | 9f6affd | 2017-09-01 09:18:35 -0700 | [diff] [blame] | 96 | aInfo.applicationInfo.uid = uid; |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 97 | AttributeCache.init(service.mContext); |
| 98 | final ActivityRecord activity = new ActivityRecord(service, null /* caller */, |
| 99 | 0 /* launchedFromPid */, 0, null, intent, null, |
| 100 | aInfo /*aInfo*/, new Configuration(), null /* resultTo */, null /* resultWho */, |
| 101 | 0 /* reqCode */, false /*componentSpecified*/, false /* rootVoiceInteraction */, |
Andrii Kulian | b1cdb10 | 2017-07-13 15:33:06 -0700 | [diff] [blame] | 102 | service.mStackSupervisor, null /* options */, null /* sourceRecord */); |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 103 | activity.mWindowContainerController = mock(AppWindowContainerController.class); |
| 104 | |
| 105 | if (task != null) { |
| 106 | task.addActivityToTop(activity); |
| 107 | } |
| 108 | |
| 109 | return activity; |
| 110 | } |
| 111 | |
Wale Ogunwale | 04a05ac | 2017-09-17 21:35:02 -0700 | [diff] [blame] | 112 | protected static TaskRecord createTask(ActivityStackSupervisor supervisor, |
| 113 | ComponentName component, ActivityStack stack) { |
Winson Chung | d6aa3db | 2017-10-05 17:18:43 -0700 | [diff] [blame] | 114 | return createTask(supervisor, component, 0 /* flags */, 0 /* taskId */, stack); |
Winson Chung | 1dbc811 | 2017-09-28 18:05:31 -0700 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | protected static TaskRecord createTask(ActivityStackSupervisor supervisor, |
Winson Chung | d6aa3db | 2017-10-05 17:18:43 -0700 | [diff] [blame] | 118 | ComponentName component, int flags, int taskId, ActivityStack stack) { |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 119 | final ActivityInfo aInfo = new ActivityInfo(); |
| 120 | aInfo.applicationInfo = new ApplicationInfo(); |
| 121 | aInfo.applicationInfo.packageName = component.getPackageName(); |
| 122 | |
| 123 | Intent intent = new Intent(); |
| 124 | intent.setComponent(component); |
Winson Chung | 1dbc811 | 2017-09-28 18:05:31 -0700 | [diff] [blame] | 125 | intent.setFlags(flags); |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 126 | |
Winson Chung | d6aa3db | 2017-10-05 17:18:43 -0700 | [diff] [blame] | 127 | final TaskRecord task = new TaskRecord(supervisor.mService, taskId, aInfo, |
| 128 | intent /*intent*/, null /*_taskDescription*/); |
Wale Ogunwale | 04a05ac | 2017-09-17 21:35:02 -0700 | [diff] [blame] | 129 | supervisor.setFocusStackUnchecked("test", stack); |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 130 | stack.addTask(task, true, "creating test task"); |
| 131 | task.setStack(stack); |
Bryce Lee | 04ab346 | 2017-04-10 15:06:33 -0700 | [diff] [blame] | 132 | task.setWindowContainerController(mock(TaskWindowContainerController.class)); |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 133 | |
| 134 | return task; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * An {@link ActivityManagerService} subclass which provides a test |
| 139 | * {@link ActivityStackSupervisor}. |
| 140 | */ |
| 141 | protected static class TestActivityManagerService extends ActivityManagerService { |
Wale Ogunwale | 04a05ac | 2017-09-17 21:35:02 -0700 | [diff] [blame] | 142 | TestActivityManagerService(Context context) { |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 143 | super(context); |
Bryce Lee | 04ab346 | 2017-04-10 15:06:33 -0700 | [diff] [blame] | 144 | mSupportsMultiWindow = true; |
| 145 | mSupportsMultiDisplay = true; |
Wale Ogunwale | 04a05ac | 2017-09-17 21:35:02 -0700 | [diff] [blame] | 146 | mSupportsSplitScreenMultiWindow = true; |
| 147 | mSupportsFreeformWindowManagement = true; |
| 148 | mSupportsPictureInPicture = true; |
Bryce Lee | 6a0754a | 2017-10-10 17:53:50 -0700 | [diff] [blame] | 149 | mWindowManager = WindowTestUtils.getMockWindowManagerService(); |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | @Override |
| 153 | protected ActivityStackSupervisor createStackSupervisor() { |
Bryce Lee | 3115bdf | 2017-04-05 08:39:40 -0700 | [diff] [blame] | 154 | return new TestActivityStackSupervisor(this, mHandlerThread.getLooper()); |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 155 | } |
Bryce Lee | 29a649d | 2017-08-18 13:52:31 -0700 | [diff] [blame] | 156 | |
| 157 | @Override |
| 158 | void updateUsageStats(ActivityRecord component, boolean resumed) { |
| 159 | } |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | /** |
| 163 | * An {@link ActivityStackSupervisor} which stubs out certain methods that depend on |
| 164 | * setup not available in the test environment. Also specifies an injector for |
| 165 | */ |
| 166 | protected static class TestActivityStackSupervisor extends ActivityStackSupervisor { |
Bryce Lee | 943ebe7 | 2017-05-04 10:19:07 -0700 | [diff] [blame] | 167 | private final ActivityDisplay mDisplay; |
Bryce Lee | 1533b2b | 2017-09-14 17:06:41 -0700 | [diff] [blame] | 168 | private boolean mLastResizeable; |
Bryce Lee | 943ebe7 | 2017-05-04 10:19:07 -0700 | [diff] [blame] | 169 | |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 170 | public TestActivityStackSupervisor(ActivityManagerService service, Looper looper) { |
| 171 | super(service, looper); |
Wale Ogunwale | 9dcf946 | 2017-09-19 15:13:01 -0700 | [diff] [blame] | 172 | mDisplayManager = |
| 173 | (DisplayManager) mService.mContext.getSystemService(Context.DISPLAY_SERVICE); |
Bryce Lee | 04ab346 | 2017-04-10 15:06:33 -0700 | [diff] [blame] | 174 | mWindowManager = prepareMockWindowManager(); |
Wale Ogunwale | 04a05ac | 2017-09-17 21:35:02 -0700 | [diff] [blame] | 175 | mDisplay = new TestActivityDisplay(this, DEFAULT_DISPLAY); |
Wale Ogunwale | 9dcf946 | 2017-09-19 15:13:01 -0700 | [diff] [blame] | 176 | attachDisplay(mDisplay); |
Bryce Lee | 04ab346 | 2017-04-10 15:06:33 -0700 | [diff] [blame] | 177 | } |
| 178 | |
Wale Ogunwale | 04a05ac | 2017-09-17 21:35:02 -0700 | [diff] [blame] | 179 | @Override |
| 180 | ActivityDisplay getDefaultDisplay() { |
| 181 | return mDisplay; |
| 182 | } |
| 183 | |
Bryce Lee | 1533b2b | 2017-09-14 17:06:41 -0700 | [diff] [blame] | 184 | // TODO: Use Mockito spy instead. Currently not possible due to TestActivityStackSupervisor |
| 185 | // access to ActivityDisplay |
| 186 | @Override |
| 187 | boolean canPlaceEntityOnDisplay(int displayId, boolean resizeable, int callingPid, |
| 188 | int callingUid, ActivityInfo activityInfo) { |
| 189 | mLastResizeable = resizeable; |
| 190 | return super.canPlaceEntityOnDisplay(displayId, resizeable, callingPid, callingUid, |
| 191 | activityInfo); |
| 192 | } |
| 193 | |
| 194 | // TODO: remove and use Mockito verify once {@link #canPlaceEntityOnDisplay} override is |
| 195 | // removed. |
| 196 | public boolean getLastResizeableFromCanPlaceEntityOnDisplay() { |
| 197 | return mLastResizeable; |
| 198 | } |
| 199 | |
Bryce Lee | 04ab346 | 2017-04-10 15:06:33 -0700 | [diff] [blame] | 200 | // No home stack is set. |
| 201 | @Override |
| 202 | void moveHomeStackToFront(String reason) { |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 203 | } |
| 204 | |
Bryce Lee | 3345c4e | 2017-04-25 07:40:41 -0700 | [diff] [blame] | 205 | @Override |
| 206 | boolean moveHomeStackTaskToTop(String reason) { |
| 207 | return true; |
| 208 | } |
| 209 | |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 210 | // Invoked during {@link ActivityStack} creation. |
| 211 | @Override |
| 212 | void updateUIDsPresentOnDisplay() { |
| 213 | } |
| 214 | |
Bryce Lee | 04ab346 | 2017-04-10 15:06:33 -0700 | [diff] [blame] | 215 | // Just return the current front task. |
| 216 | @Override |
| 217 | ActivityStack getNextFocusableStackLocked(ActivityStack currentFocus) { |
| 218 | return mFocusedStack; |
| 219 | } |
| 220 | |
| 221 | // Called when moving activity to pinned stack. |
| 222 | @Override |
| 223 | void ensureActivitiesVisibleLocked(ActivityRecord starting, int configChanges, |
| 224 | boolean preserveWindows) { |
| 225 | } |
| 226 | |
Wale Ogunwale | 04a05ac | 2017-09-17 21:35:02 -0700 | [diff] [blame] | 227 | // Always keep things awake |
| 228 | @Override |
| 229 | boolean hasAwakeDisplay() { |
| 230 | return true; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | private static class TestActivityDisplay extends ActivityDisplay { |
| 235 | |
| 236 | private final ActivityStackSupervisor mSupervisor; |
| 237 | TestActivityDisplay(ActivityStackSupervisor supervisor, int displayId) { |
| 238 | super(supervisor, displayId); |
| 239 | mSupervisor = supervisor; |
Andrii Kulian | b1cdb10 | 2017-07-13 15:33:06 -0700 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | @Override |
Wale Ogunwale | 04a05ac | 2017-09-17 21:35:02 -0700 | [diff] [blame] | 243 | <T extends ActivityStack> T createStackUnchecked(int windowingMode, int activityType, |
| 244 | int stackId, boolean onTop) { |
| 245 | if (windowingMode == WINDOWING_MODE_PINNED) { |
| 246 | return (T) new PinnedActivityStack(this, stackId, mSupervisor, onTop) { |
Andrii Kulian | b1cdb10 | 2017-07-13 15:33:06 -0700 | [diff] [blame] | 247 | @Override |
| 248 | Rect getDefaultPictureInPictureBounds(float aspectRatio) { |
| 249 | return new Rect(50, 50, 100, 100); |
| 250 | } |
Bryce Lee | 4e4a3ec | 2017-09-27 08:25:03 -0700 | [diff] [blame] | 251 | |
| 252 | @Override |
| 253 | PinnedStackWindowController createStackWindowController(int displayId, |
| 254 | boolean onTop, Rect outBounds) { |
| 255 | return mock(PinnedStackWindowController.class); |
| 256 | } |
Andrii Kulian | b1cdb10 | 2017-07-13 15:33:06 -0700 | [diff] [blame] | 257 | }; |
| 258 | } else { |
Wale Ogunwale | 04a05ac | 2017-09-17 21:35:02 -0700 | [diff] [blame] | 259 | return (T) new TestActivityStack( |
| 260 | this, stackId, mSupervisor, windowingMode, activityType, onTop); |
Andrii Kulian | b1cdb10 | 2017-07-13 15:33:06 -0700 | [diff] [blame] | 261 | } |
Bryce Lee | 04ab346 | 2017-04-10 15:06:33 -0700 | [diff] [blame] | 262 | } |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 263 | } |
| 264 | |
Bryce Lee | 04ab346 | 2017-04-10 15:06:33 -0700 | [diff] [blame] | 265 | private static WindowManagerService prepareMockWindowManager() { |
Bryce Lee | 4e4a3ec | 2017-09-27 08:25:03 -0700 | [diff] [blame] | 266 | final WindowManagerService service = WindowTestUtils.getMockWindowManagerService(); |
Bryce Lee | 04ab346 | 2017-04-10 15:06:33 -0700 | [diff] [blame] | 267 | |
| 268 | doAnswer((InvocationOnMock invocationOnMock) -> { |
| 269 | final Runnable runnable = invocationOnMock.<Runnable>getArgument(0); |
| 270 | if (runnable != null) { |
| 271 | runnable.run(); |
| 272 | } |
| 273 | return null; |
| 274 | }).when(service).inSurfaceTransaction(any()); |
| 275 | |
| 276 | return service; |
| 277 | } |
| 278 | |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 279 | /** |
Bryce Lee | 4e4a3ec | 2017-09-27 08:25:03 -0700 | [diff] [blame] | 280 | * Overrided of {@link ActivityStack} that tracks test metrics, such as the number of times a |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 281 | * method is called. Note that its functionality depends on the implementations of the |
| 282 | * construction arguments. |
| 283 | */ |
| 284 | protected static class TestActivityStack<T extends StackWindowController> |
Wale Ogunwale | 7e1f5f5 | 2017-10-18 15:19:59 -0700 | [diff] [blame^] | 285 | extends ActivityStack<T> { |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 286 | private int mOnActivityRemovedFromStackCount = 0; |
| 287 | private T mContainerController; |
Wale Ogunwale | 04a05ac | 2017-09-17 21:35:02 -0700 | [diff] [blame] | 288 | |
Wale Ogunwale | 7e1f5f5 | 2017-10-18 15:19:59 -0700 | [diff] [blame^] | 289 | static final int IS_TRANSLUCENT_UNSET = 0; |
| 290 | static final int IS_TRANSLUCENT_FALSE = 1; |
| 291 | static final int IS_TRANSLUCENT_TRUE = 2; |
| 292 | private int mIsTranslucent = IS_TRANSLUCENT_UNSET; |
| 293 | |
Wale Ogunwale | 9dcf946 | 2017-09-19 15:13:01 -0700 | [diff] [blame] | 294 | TestActivityStack(ActivityDisplay display, int stackId, ActivityStackSupervisor supervisor, |
Wale Ogunwale | 04a05ac | 2017-09-17 21:35:02 -0700 | [diff] [blame] | 295 | int windowingMode, int activityType, boolean onTop) { |
| 296 | super(display, stackId, supervisor, windowingMode, activityType, onTop); |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | @Override |
| 300 | void onActivityRemovedFromStack(ActivityRecord r) { |
| 301 | mOnActivityRemovedFromStackCount++; |
| 302 | super.onActivityRemovedFromStack(r); |
| 303 | } |
| 304 | |
| 305 | // Returns the number of times {@link #onActivityRemovedFromStack} has been called |
Wale Ogunwale | 7e1f5f5 | 2017-10-18 15:19:59 -0700 | [diff] [blame^] | 306 | int onActivityRemovedFromStackInvocationCount() { |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 307 | return mOnActivityRemovedFromStackCount; |
| 308 | } |
| 309 | |
| 310 | @Override |
Wale Ogunwale | 034a8ec | 2017-09-02 17:14:40 -0700 | [diff] [blame] | 311 | protected T createStackWindowController(int displayId, boolean onTop, Rect outBounds) { |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 312 | mContainerController = (T) WindowTestUtils.createMockStackWindowContainerController(); |
| 313 | return mContainerController; |
| 314 | } |
| 315 | |
| 316 | @Override |
| 317 | T getWindowContainerController() { |
| 318 | return mContainerController; |
| 319 | } |
Wale Ogunwale | 7e1f5f5 | 2017-10-18 15:19:59 -0700 | [diff] [blame^] | 320 | |
| 321 | void setIsTranslucent(boolean isTranslucent) { |
| 322 | mIsTranslucent = isTranslucent ? IS_TRANSLUCENT_TRUE : IS_TRANSLUCENT_FALSE; |
| 323 | } |
| 324 | |
| 325 | @Override |
| 326 | boolean isStackTranslucent(ActivityRecord starting, ActivityStack stackBehind) { |
| 327 | switch (mIsTranslucent) { |
| 328 | case IS_TRANSLUCENT_TRUE: |
| 329 | return true; |
| 330 | case IS_TRANSLUCENT_FALSE: |
| 331 | return false; |
| 332 | case IS_TRANSLUCENT_UNSET: |
| 333 | default: |
| 334 | return super.isStackTranslucent(starting, stackBehind); |
| 335 | } |
| 336 | } |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 337 | } |
Bryce Lee | af691c0 | 2017-03-20 14:20:22 -0700 | [diff] [blame] | 338 | } |