blob: ff7b1d0644ba33bd38681f273cdca2a318d03aeb [file] [log] [blame]
Bryce Leeaf691c02017-03-20 14:20:22 -07001/*
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
17package com.android.server.am;
18
Bryce Lee18d51592017-10-25 10:22:19 -070019import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
20import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
Wale Ogunwale04a05ac2017-09-17 21:35:02 -070021import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
Bryce Leef3c6a472017-11-14 14:53:06 -080022import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
Wale Ogunwale9dcf9462017-09-19 15:13:01 -070023import static android.view.Display.DEFAULT_DISPLAY;
Bryce Leeaf691c02017-03-20 14:20:22 -070024import static org.mockito.Mockito.mock;
Bryce Lee2a3cc462017-10-27 10:57:35 -070025import static org.mockito.Mockito.doNothing;
Bryce Lee04ab3462017-04-10 15:06:33 -070026import static org.mockito.Mockito.doReturn;
27import static org.mockito.Mockito.any;
Bryce Lee2a3cc462017-10-27 10:57:35 -070028import static org.mockito.Mockito.anyBoolean;
29import static org.mockito.Mockito.anyInt;
Bryce Lee04ab3462017-04-10 15:06:33 -070030import static org.mockito.Mockito.doAnswer;
Bryce Lee4e4a3ec2017-09-27 08:25:03 -070031import static org.mockito.Mockito.spy;
Bryce Lee04ab3462017-04-10 15:06:33 -070032
Winson Chung59a47ded2018-01-25 17:46:06 +000033import com.android.server.wm.DisplayWindowController;
Bryce Lee04ab3462017-04-10 15:06:33 -070034import org.mockito.invocation.InvocationOnMock;
Bryce Leeaf691c02017-03-20 14:20:22 -070035
Bryce Lee0bd8d422018-01-09 09:45:57 -080036import android.app.IApplicationThread;
Bryce Leeaf691c02017-03-20 14:20:22 -070037import android.content.ComponentName;
38import android.content.Context;
39import android.content.Intent;
40import android.content.pm.ActivityInfo;
41import android.content.pm.ApplicationInfo;
Bryce Leeba8f4422017-11-20 12:35:57 -080042import android.content.pm.IPackageManager;
Bryce Leeaf691c02017-03-20 14:20:22 -070043import android.content.res.Configuration;
44import android.graphics.Rect;
Wale Ogunwale9dcf9462017-09-19 15:13:01 -070045import android.hardware.display.DisplayManager;
Bryce Lee3115bdf2017-04-05 08:39:40 -070046import android.os.HandlerThread;
Bryce Leeaf691c02017-03-20 14:20:22 -070047import android.os.Looper;
Bryce Lee93e7f792017-10-25 15:54:55 -070048import android.service.voice.IVoiceInteractionSession;
Bryce Leeaf691c02017-03-20 14:20:22 -070049import android.support.test.InstrumentationRegistry;
50import com.android.server.AttributeCache;
51import com.android.server.wm.AppWindowContainerController;
Bryce Lee4e4a3ec2017-09-27 08:25:03 -070052import com.android.server.wm.PinnedStackWindowController;
Bryce Leeaf691c02017-03-20 14:20:22 -070053import com.android.server.wm.StackWindowController;
Bryce Lee04ab3462017-04-10 15:06:33 -070054import com.android.server.wm.TaskWindowContainerController;
Bryce Leeaf691c02017-03-20 14:20:22 -070055import com.android.server.wm.WindowManagerService;
56import com.android.server.wm.WindowTestUtils;
Bryce Lee3115bdf2017-04-05 08:39:40 -070057import org.junit.After;
Bryce Leeaf691c02017-03-20 14:20:22 -070058import org.junit.Before;
59import org.mockito.MockitoAnnotations;
60
61/**
62 * A base class to handle common operations in activity related unit tests.
63 */
64public class ActivityTestsBase {
Bryce Lee939a9a32017-10-23 10:01:21 -070065 private static boolean sOneTimeSetupDone = false;
66
Bryce Leeaf691c02017-03-20 14:20:22 -070067 private final Context mContext = InstrumentationRegistry.getContext();
Bryce Lee3115bdf2017-04-05 08:39:40 -070068 private HandlerThread mHandlerThread;
Bryce Leeaf691c02017-03-20 14:20:22 -070069
Bryce Leeaf691c02017-03-20 14:20:22 -070070 @Before
71 public void setUp() throws Exception {
Bryce Lee939a9a32017-10-23 10:01:21 -070072 if (!sOneTimeSetupDone) {
73 sOneTimeSetupDone = true;
74
75 // Allows to mock package local classes and methods
76 System.setProperty("dexmaker.share_classloader", "true");
77 MockitoAnnotations.initMocks(this);
78 }
Bryce Lee3115bdf2017-04-05 08:39:40 -070079 mHandlerThread = new HandlerThread("ActivityTestsBaseThread");
80 mHandlerThread.start();
81 }
Bryce Leeaf691c02017-03-20 14:20:22 -070082
Bryce Lee3115bdf2017-04-05 08:39:40 -070083 @After
84 public void tearDown() {
85 mHandlerThread.quitSafely();
Bryce Leeaf691c02017-03-20 14:20:22 -070086 }
87
88 protected ActivityManagerService createActivityManagerService() {
Bryce Lee93e7f792017-10-25 15:54:55 -070089 final ActivityManagerService service =
90 setupActivityManagerService(new TestActivityManagerService(mContext));
91 AttributeCache.init(mContext);
92 return service;
Winson Chung3f0e59a2017-10-25 10:19:05 -070093 }
94
95 protected ActivityManagerService setupActivityManagerService(ActivityManagerService service) {
96 service = spy(service);
Bryce Leeba8f4422017-11-20 12:35:57 -080097 doReturn(mock(IPackageManager.class)).when(service).getPackageManager();
Bryce Lee4e4a3ec2017-09-27 08:25:03 -070098 service.mWindowManager = prepareMockWindowManager();
Bryce Lee840c5662017-04-13 10:02:51 -070099 return service;
Bryce Leeaf691c02017-03-20 14:20:22 -0700100 }
101
Bryce Lee18d51592017-10-25 10:22:19 -0700102 /**
103 * Builder for creating new activities.
104 */
105 protected static class ActivityBuilder {
106 // An id appended to the end of the component name to make it unique
107 private static int sCurrentActivityId = 0;
Bryce Lee9f6affd2017-09-01 09:18:35 -0700108
Bryce Lee18d51592017-10-25 10:22:19 -0700109 // Default package name
Bryce Lee93e7f792017-10-25 15:54:55 -0700110 static final String DEFAULT_PACKAGE = "com.foo";
Bryce Leeaf691c02017-03-20 14:20:22 -0700111
Bryce Lee18d51592017-10-25 10:22:19 -0700112 // Default base activity name
113 private static final String DEFAULT_BASE_ACTIVITY_NAME = ".BarActivity";
114
115 private final ActivityManagerService mService;
116
117 private ComponentName mComponent;
118 private TaskRecord mTaskRecord;
119 private int mUid;
120 private boolean mCreateTask;
121 private ActivityStack mStack;
122
123 ActivityBuilder(ActivityManagerService service) {
124 mService = service;
Bryce Leeaf691c02017-03-20 14:20:22 -0700125 }
126
Bryce Lee18d51592017-10-25 10:22:19 -0700127 ActivityBuilder setComponent(ComponentName component) {
128 mComponent = component;
129 return this;
130 }
131
132 ActivityBuilder setTask(TaskRecord task) {
133 mTaskRecord = task;
134 return this;
135 }
136
137 ActivityBuilder setStack(ActivityStack stack) {
138 mStack = stack;
139 return this;
140 }
141
142 ActivityBuilder setCreateTask(boolean createTask) {
143 mCreateTask = createTask;
144 return this;
145 }
146
147 ActivityBuilder setUid(int uid) {
148 mUid = uid;
149 return this;
150 }
151
152 ActivityRecord build() {
153 if (mComponent == null) {
154 final int id = sCurrentActivityId++;
155 mComponent = ComponentName.createRelative(DEFAULT_PACKAGE,
156 DEFAULT_BASE_ACTIVITY_NAME + id);
157 }
158
159 if (mCreateTask) {
160 mTaskRecord = new TaskBuilder(mService.mStackSupervisor)
161 .setComponent(mComponent)
162 .setStack(mStack).build();
163 }
164
165 Intent intent = new Intent();
166 intent.setComponent(mComponent);
167 final ActivityInfo aInfo = new ActivityInfo();
168 aInfo.applicationInfo = new ApplicationInfo();
169 aInfo.applicationInfo.packageName = mComponent.getPackageName();
170 aInfo.applicationInfo.uid = mUid;
Bryce Lee18d51592017-10-25 10:22:19 -0700171 final ActivityRecord activity = new ActivityRecord(mService, null /* caller */,
172 0 /* launchedFromPid */, 0, null, intent, null,
173 aInfo /*aInfo*/, new Configuration(), null /* resultTo */, null /* resultWho */,
174 0 /* reqCode */, false /*componentSpecified*/, false /* rootVoiceInteraction */,
175 mService.mStackSupervisor, null /* options */, null /* sourceRecord */);
176 activity.mWindowContainerController = mock(AppWindowContainerController.class);
177
178 if (mTaskRecord != null) {
179 mTaskRecord.addActivityToTop(activity);
180 }
181
Bryce Lee0bd8d422018-01-09 09:45:57 -0800182 activity.setProcess(new ProcessRecord(null, mService.mContext.getApplicationInfo(),
183 "name", 12345));
184 activity.app.thread = mock(IApplicationThread.class);
185
Bryce Lee18d51592017-10-25 10:22:19 -0700186 return activity;
187 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700188 }
189
Bryce Lee18d51592017-10-25 10:22:19 -0700190 /**
191 * Builder for creating new tasks.
192 */
193 protected static class TaskBuilder {
194 private final ActivityStackSupervisor mSupervisor;
Winson Chung1dbc8112017-09-28 18:05:31 -0700195
Bryce Lee18d51592017-10-25 10:22:19 -0700196 private ComponentName mComponent;
197 private String mPackage;
198 private int mFlags = 0;
199 private int mTaskId = 0;
Winson Chung0ec2a352017-10-26 11:38:30 -0700200 private int mUserId = 0;
Bryce Lee93e7f792017-10-25 15:54:55 -0700201 private IVoiceInteractionSession mVoiceSession;
Bryce Leeaf691c02017-03-20 14:20:22 -0700202
Bryce Lee18d51592017-10-25 10:22:19 -0700203 private ActivityStack mStack;
Bryce Leeaf691c02017-03-20 14:20:22 -0700204
Bryce Lee18d51592017-10-25 10:22:19 -0700205 TaskBuilder(ActivityStackSupervisor supervisor) {
206 mSupervisor = supervisor;
207 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700208
Bryce Lee18d51592017-10-25 10:22:19 -0700209 TaskBuilder setComponent(ComponentName component) {
210 mComponent = component;
211 return this;
212 }
213
214 TaskBuilder setPackage(String packageName) {
215 mPackage = packageName;
216 return this;
217 }
218
Bryce Lee93e7f792017-10-25 15:54:55 -0700219 TaskBuilder setVoiceSession(IVoiceInteractionSession session) {
220 mVoiceSession = session;
221 return this;
222 }
223
Bryce Lee18d51592017-10-25 10:22:19 -0700224 TaskBuilder setFlags(int flags) {
225 mFlags = flags;
226 return this;
227 }
228
229 TaskBuilder setTaskId(int taskId) {
230 mTaskId = taskId;
231 return this;
232 }
233
Winson Chung0ec2a352017-10-26 11:38:30 -0700234 TaskBuilder setUserId(int userId) {
235 mUserId = userId;
236 return this;
237 }
238
Bryce Lee18d51592017-10-25 10:22:19 -0700239 TaskBuilder setStack(ActivityStack stack) {
240 mStack = stack;
241 return this;
242 }
243
244 TaskRecord build() {
245 if (mStack == null) {
246 mStack = mSupervisor.getDefaultDisplay().createStack(
247 WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
248 }
249
250 final ActivityInfo aInfo = new ActivityInfo();
251 aInfo.applicationInfo = new ApplicationInfo();
252 aInfo.applicationInfo.packageName = mPackage;
253
254 Intent intent = new Intent();
255 intent.setComponent(mComponent);
256 intent.setFlags(mFlags);
257
258 final TaskRecord task = new TaskRecord(mSupervisor.mService, mTaskId, aInfo,
Bryce Lee93e7f792017-10-25 15:54:55 -0700259 intent /*intent*/, mVoiceSession, null /*_voiceInteractor*/);
Winson Chung0ec2a352017-10-26 11:38:30 -0700260 task.userId = mUserId;
Bryce Lee18d51592017-10-25 10:22:19 -0700261 mSupervisor.setFocusStackUnchecked("test", mStack);
262 mStack.addTask(task, true, "creating test task");
263 task.setStack(mStack);
264 task.setWindowContainerController(mock(TaskWindowContainerController.class));
Winson Chung0ec2a352017-10-26 11:38:30 -0700265 task.touchActiveTime();
Bryce Lee18d51592017-10-25 10:22:19 -0700266
267 return task;
268 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700269 }
270
271 /**
272 * An {@link ActivityManagerService} subclass which provides a test
273 * {@link ActivityStackSupervisor}.
274 */
275 protected static class TestActivityManagerService extends ActivityManagerService {
Bryce Leeb0f993f2018-03-02 15:38:01 -0800276 private ClientLifecycleManager mLifecycleManager;
277
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700278 TestActivityManagerService(Context context) {
Bryce Leeaf691c02017-03-20 14:20:22 -0700279 super(context);
Bryce Lee04ab3462017-04-10 15:06:33 -0700280 mSupportsMultiWindow = true;
281 mSupportsMultiDisplay = true;
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700282 mSupportsSplitScreenMultiWindow = true;
283 mSupportsFreeformWindowManagement = true;
284 mSupportsPictureInPicture = true;
Bryce Lee6a0754a2017-10-10 17:53:50 -0700285 mWindowManager = WindowTestUtils.getMockWindowManagerService();
Bryce Leeaf691c02017-03-20 14:20:22 -0700286 }
287
288 @Override
Bryce Leeb0f993f2018-03-02 15:38:01 -0800289 public ClientLifecycleManager getLifecycleManager() {
290 if (mLifecycleManager == null) {
291 return super.getLifecycleManager();
292 }
293 return mLifecycleManager;
294 }
295
296 void setLifecycleManager(ClientLifecycleManager manager) {
297 mLifecycleManager = manager;
298 }
299
300 @Override
Bryce Lee2a3cc462017-10-27 10:57:35 -0700301 final protected ActivityStackSupervisor createStackSupervisor() {
302 final ActivityStackSupervisor supervisor = spy(createTestSupervisor());
303
304 // No home stack is set.
305 doNothing().when(supervisor).moveHomeStackToFront(any());
306 doReturn(true).when(supervisor).moveHomeStackTaskToTop(any());
307 // Invoked during {@link ActivityStack} creation.
308 doNothing().when(supervisor).updateUIDsPresentOnDisplay();
309 // Always keep things awake.
310 doReturn(true).when(supervisor).hasAwakeDisplay();
311 // Called when moving activity to pinned stack.
312 doNothing().when(supervisor).ensureActivitiesVisibleLocked(any(), anyInt(), anyBoolean());
313 // Do not schedule idle timeouts
314 doNothing().when(supervisor).scheduleIdleTimeoutLocked(any());
315
316 supervisor.initialize();
317
318 return supervisor;
319 }
320
321 protected ActivityStackSupervisor createTestSupervisor() {
Bryce Lee3115bdf2017-04-05 08:39:40 -0700322 return new TestActivityStackSupervisor(this, mHandlerThread.getLooper());
Bryce Leeaf691c02017-03-20 14:20:22 -0700323 }
Bryce Lee29a649d2017-08-18 13:52:31 -0700324
325 @Override
326 void updateUsageStats(ActivityRecord component, boolean resumed) {
327 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700328 }
329
330 /**
331 * An {@link ActivityStackSupervisor} which stubs out certain methods that depend on
332 * setup not available in the test environment. Also specifies an injector for
333 */
334 protected static class TestActivityStackSupervisor extends ActivityStackSupervisor {
Bryce Lee2a3cc462017-10-27 10:57:35 -0700335 private ActivityDisplay mDisplay;
Bryce Lee943ebe72017-05-04 10:19:07 -0700336
Bryce Leeaf691c02017-03-20 14:20:22 -0700337 public TestActivityStackSupervisor(ActivityManagerService service, Looper looper) {
338 super(service, looper);
Wale Ogunwale9dcf9462017-09-19 15:13:01 -0700339 mDisplayManager =
340 (DisplayManager) mService.mContext.getSystemService(Context.DISPLAY_SERVICE);
Bryce Lee04ab3462017-04-10 15:06:33 -0700341 mWindowManager = prepareMockWindowManager();
Bryce Lee2a3cc462017-10-27 10:57:35 -0700342 }
343
344 @Override
345 public void initialize() {
346 super.initialize();
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700347 mDisplay = new TestActivityDisplay(this, DEFAULT_DISPLAY);
Wale Ogunwale9dcf9462017-09-19 15:13:01 -0700348 attachDisplay(mDisplay);
Bryce Lee04ab3462017-04-10 15:06:33 -0700349 }
350
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700351 @Override
352 ActivityDisplay getDefaultDisplay() {
353 return mDisplay;
354 }
355
Bryce Lee2a3cc462017-10-27 10:57:35 -0700356 // Just return the current front task. This is called internally so we cannot use spy to mock this out.
Bryce Lee04ab3462017-04-10 15:06:33 -0700357 @Override
358 ActivityStack getNextFocusableStackLocked(ActivityStack currentFocus) {
359 return mFocusedStack;
360 }
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700361 }
362
Winson Chung59a47ded2018-01-25 17:46:06 +0000363 protected static class TestActivityDisplay extends ActivityDisplay {
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700364
365 private final ActivityStackSupervisor mSupervisor;
366 TestActivityDisplay(ActivityStackSupervisor supervisor, int displayId) {
367 super(supervisor, displayId);
368 mSupervisor = supervisor;
Andrii Kulianb1cdb102017-07-13 15:33:06 -0700369 }
370
371 @Override
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700372 <T extends ActivityStack> T createStackUnchecked(int windowingMode, int activityType,
373 int stackId, boolean onTop) {
374 if (windowingMode == WINDOWING_MODE_PINNED) {
375 return (T) new PinnedActivityStack(this, stackId, mSupervisor, onTop) {
Andrii Kulianb1cdb102017-07-13 15:33:06 -0700376 @Override
377 Rect getDefaultPictureInPictureBounds(float aspectRatio) {
378 return new Rect(50, 50, 100, 100);
379 }
Bryce Lee4e4a3ec2017-09-27 08:25:03 -0700380
381 @Override
382 PinnedStackWindowController createStackWindowController(int displayId,
383 boolean onTop, Rect outBounds) {
384 return mock(PinnedStackWindowController.class);
385 }
Andrii Kulianb1cdb102017-07-13 15:33:06 -0700386 };
387 } else {
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700388 return (T) new TestActivityStack(
389 this, stackId, mSupervisor, windowingMode, activityType, onTop);
Andrii Kulianb1cdb102017-07-13 15:33:06 -0700390 }
Bryce Lee04ab3462017-04-10 15:06:33 -0700391 }
Winson Chung59a47ded2018-01-25 17:46:06 +0000392
393 @Override
394 protected DisplayWindowController createWindowContainerController() {
395 return mock(DisplayWindowController.class);
396 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700397 }
398
Bryce Lee04ab3462017-04-10 15:06:33 -0700399 private static WindowManagerService prepareMockWindowManager() {
Bryce Lee4e4a3ec2017-09-27 08:25:03 -0700400 final WindowManagerService service = WindowTestUtils.getMockWindowManagerService();
Bryce Lee04ab3462017-04-10 15:06:33 -0700401
402 doAnswer((InvocationOnMock invocationOnMock) -> {
403 final Runnable runnable = invocationOnMock.<Runnable>getArgument(0);
404 if (runnable != null) {
405 runnable.run();
406 }
407 return null;
408 }).when(service).inSurfaceTransaction(any());
409
410 return service;
411 }
412
Bryce Leeaf691c02017-03-20 14:20:22 -0700413 /**
Bryce Lee4e4a3ec2017-09-27 08:25:03 -0700414 * Overrided of {@link ActivityStack} that tracks test metrics, such as the number of times a
Bryce Leeaf691c02017-03-20 14:20:22 -0700415 * method is called. Note that its functionality depends on the implementations of the
416 * construction arguments.
417 */
418 protected static class TestActivityStack<T extends StackWindowController>
Wale Ogunwale7e1f5f52017-10-18 15:19:59 -0700419 extends ActivityStack<T> {
Bryce Leeaf691c02017-03-20 14:20:22 -0700420 private int mOnActivityRemovedFromStackCount = 0;
421 private T mContainerController;
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700422
Wale Ogunwale7e1f5f52017-10-18 15:19:59 -0700423 static final int IS_TRANSLUCENT_UNSET = 0;
424 static final int IS_TRANSLUCENT_FALSE = 1;
425 static final int IS_TRANSLUCENT_TRUE = 2;
426 private int mIsTranslucent = IS_TRANSLUCENT_UNSET;
427
Wale Ogunwale30e441d2017-11-09 08:28:45 -0800428 static final int SUPPORTS_SPLIT_SCREEN_UNSET = 0;
429 static final int SUPPORTS_SPLIT_SCREEN_FALSE = 1;
430 static final int SUPPORTS_SPLIT_SCREEN_TRUE = 2;
431 private int mSupportsSplitScreen = SUPPORTS_SPLIT_SCREEN_UNSET;
432
Wale Ogunwale9dcf9462017-09-19 15:13:01 -0700433 TestActivityStack(ActivityDisplay display, int stackId, ActivityStackSupervisor supervisor,
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700434 int windowingMode, int activityType, boolean onTop) {
435 super(display, stackId, supervisor, windowingMode, activityType, onTop);
Bryce Leeaf691c02017-03-20 14:20:22 -0700436 }
437
438 @Override
439 void onActivityRemovedFromStack(ActivityRecord r) {
440 mOnActivityRemovedFromStackCount++;
441 super.onActivityRemovedFromStack(r);
442 }
443
444 // Returns the number of times {@link #onActivityRemovedFromStack} has been called
Wale Ogunwale7e1f5f52017-10-18 15:19:59 -0700445 int onActivityRemovedFromStackInvocationCount() {
Bryce Leeaf691c02017-03-20 14:20:22 -0700446 return mOnActivityRemovedFromStackCount;
447 }
448
449 @Override
Wale Ogunwale034a8ec2017-09-02 17:14:40 -0700450 protected T createStackWindowController(int displayId, boolean onTop, Rect outBounds) {
Bryce Leeaf691c02017-03-20 14:20:22 -0700451 mContainerController = (T) WindowTestUtils.createMockStackWindowContainerController();
Bryce Leef3c6a472017-11-14 14:53:06 -0800452
453 // Primary pinned stacks require a non-empty out bounds to be set or else all tasks
454 // will be moved to the full screen stack.
455 if (getWindowingMode() == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) {
456 outBounds.set(0, 0, 100, 100);
457 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700458 return mContainerController;
459 }
460
461 @Override
462 T getWindowContainerController() {
463 return mContainerController;
464 }
Wale Ogunwale7e1f5f52017-10-18 15:19:59 -0700465
466 void setIsTranslucent(boolean isTranslucent) {
467 mIsTranslucent = isTranslucent ? IS_TRANSLUCENT_TRUE : IS_TRANSLUCENT_FALSE;
468 }
469
470 @Override
Wale Ogunwale66e16852017-10-19 13:35:52 -0700471 boolean isStackTranslucent(ActivityRecord starting) {
Wale Ogunwale7e1f5f52017-10-18 15:19:59 -0700472 switch (mIsTranslucent) {
473 case IS_TRANSLUCENT_TRUE:
474 return true;
475 case IS_TRANSLUCENT_FALSE:
476 return false;
477 case IS_TRANSLUCENT_UNSET:
478 default:
Wale Ogunwale66e16852017-10-19 13:35:52 -0700479 return super.isStackTranslucent(starting);
Wale Ogunwale7e1f5f52017-10-18 15:19:59 -0700480 }
481 }
Wale Ogunwale30e441d2017-11-09 08:28:45 -0800482
483 void setSupportsSplitScreen(boolean supportsSplitScreen) {
484 mSupportsSplitScreen = supportsSplitScreen
485 ? SUPPORTS_SPLIT_SCREEN_TRUE : SUPPORTS_SPLIT_SCREEN_FALSE;
486 }
487
488 @Override
489 public boolean supportsSplitScreenWindowingMode() {
490 switch (mSupportsSplitScreen) {
491 case SUPPORTS_SPLIT_SCREEN_TRUE:
492 return true;
493 case SUPPORTS_SPLIT_SCREEN_FALSE:
494 return false;
495 case SUPPORTS_SPLIT_SCREEN_UNSET:
496 default:
497 return super.supportsSplitScreenWindowingMode();
498 }
499 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700500 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700501}