blob: 96bf49b288c9673d3a0b9fada50322324bcd20cd [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
33import org.mockito.invocation.InvocationOnMock;
Bryce Leeaf691c02017-03-20 14:20:22 -070034
Bryce Lee0bd8d422018-01-09 09:45:57 -080035import android.app.IApplicationThread;
Bryce Leeaf691c02017-03-20 14:20:22 -070036import android.content.ComponentName;
37import android.content.Context;
38import android.content.Intent;
39import android.content.pm.ActivityInfo;
40import android.content.pm.ApplicationInfo;
Bryce Leeba8f4422017-11-20 12:35:57 -080041import android.content.pm.IPackageManager;
Bryce Leeaf691c02017-03-20 14:20:22 -070042import android.content.res.Configuration;
43import android.graphics.Rect;
Wale Ogunwale9dcf9462017-09-19 15:13:01 -070044import android.hardware.display.DisplayManager;
Bryce Lee3115bdf2017-04-05 08:39:40 -070045import android.os.HandlerThread;
Bryce Leeaf691c02017-03-20 14:20:22 -070046import android.os.Looper;
Bryce Lee93e7f792017-10-25 15:54:55 -070047import android.service.voice.IVoiceInteractionSession;
Bryce Leeaf691c02017-03-20 14:20:22 -070048import android.support.test.InstrumentationRegistry;
49import com.android.server.AttributeCache;
50import com.android.server.wm.AppWindowContainerController;
Bryce Lee4e4a3ec2017-09-27 08:25:03 -070051import com.android.server.wm.PinnedStackWindowController;
Bryce Leeaf691c02017-03-20 14:20:22 -070052import com.android.server.wm.StackWindowController;
Bryce Lee04ab3462017-04-10 15:06:33 -070053import com.android.server.wm.TaskWindowContainerController;
Bryce Leeaf691c02017-03-20 14:20:22 -070054import com.android.server.wm.WindowManagerService;
55import com.android.server.wm.WindowTestUtils;
Bryce Lee3115bdf2017-04-05 08:39:40 -070056import org.junit.After;
Bryce Leeaf691c02017-03-20 14:20:22 -070057import org.junit.Before;
58import org.mockito.MockitoAnnotations;
59
60/**
61 * A base class to handle common operations in activity related unit tests.
62 */
63public class ActivityTestsBase {
Bryce Lee939a9a32017-10-23 10:01:21 -070064 private static boolean sOneTimeSetupDone = false;
65
Bryce Leeaf691c02017-03-20 14:20:22 -070066 private final Context mContext = InstrumentationRegistry.getContext();
Bryce Lee3115bdf2017-04-05 08:39:40 -070067 private HandlerThread mHandlerThread;
Bryce Leeaf691c02017-03-20 14:20:22 -070068
Bryce Leeaf691c02017-03-20 14:20:22 -070069 @Before
70 public void setUp() throws Exception {
Bryce Lee939a9a32017-10-23 10:01:21 -070071 if (!sOneTimeSetupDone) {
72 sOneTimeSetupDone = true;
73
74 // Allows to mock package local classes and methods
75 System.setProperty("dexmaker.share_classloader", "true");
76 MockitoAnnotations.initMocks(this);
77 }
Bryce Lee3115bdf2017-04-05 08:39:40 -070078 mHandlerThread = new HandlerThread("ActivityTestsBaseThread");
79 mHandlerThread.start();
80 }
Bryce Leeaf691c02017-03-20 14:20:22 -070081
Bryce Lee3115bdf2017-04-05 08:39:40 -070082 @After
83 public void tearDown() {
84 mHandlerThread.quitSafely();
Bryce Leeaf691c02017-03-20 14:20:22 -070085 }
86
87 protected ActivityManagerService createActivityManagerService() {
Bryce Lee93e7f792017-10-25 15:54:55 -070088 final ActivityManagerService service =
89 setupActivityManagerService(new TestActivityManagerService(mContext));
90 AttributeCache.init(mContext);
91 return service;
Winson Chung3f0e59a2017-10-25 10:19:05 -070092 }
93
94 protected ActivityManagerService setupActivityManagerService(ActivityManagerService service) {
95 service = spy(service);
Bryce Leeba8f4422017-11-20 12:35:57 -080096 doReturn(mock(IPackageManager.class)).when(service).getPackageManager();
Bryce Lee4e4a3ec2017-09-27 08:25:03 -070097 service.mWindowManager = prepareMockWindowManager();
Bryce Lee840c5662017-04-13 10:02:51 -070098 return service;
Bryce Leeaf691c02017-03-20 14:20:22 -070099 }
100
Bryce Lee18d51592017-10-25 10:22:19 -0700101 /**
102 * Builder for creating new activities.
103 */
104 protected static class ActivityBuilder {
105 // An id appended to the end of the component name to make it unique
106 private static int sCurrentActivityId = 0;
Bryce Lee9f6affd2017-09-01 09:18:35 -0700107
Bryce Lee18d51592017-10-25 10:22:19 -0700108 // Default package name
Bryce Lee93e7f792017-10-25 15:54:55 -0700109 static final String DEFAULT_PACKAGE = "com.foo";
Bryce Leeaf691c02017-03-20 14:20:22 -0700110
Bryce Lee18d51592017-10-25 10:22:19 -0700111 // Default base activity name
112 private static final String DEFAULT_BASE_ACTIVITY_NAME = ".BarActivity";
113
114 private final ActivityManagerService mService;
115
116 private ComponentName mComponent;
117 private TaskRecord mTaskRecord;
118 private int mUid;
119 private boolean mCreateTask;
120 private ActivityStack mStack;
121
122 ActivityBuilder(ActivityManagerService service) {
123 mService = service;
Bryce Leeaf691c02017-03-20 14:20:22 -0700124 }
125
Bryce Lee18d51592017-10-25 10:22:19 -0700126 ActivityBuilder setComponent(ComponentName component) {
127 mComponent = component;
128 return this;
129 }
130
131 ActivityBuilder setTask(TaskRecord task) {
132 mTaskRecord = task;
133 return this;
134 }
135
136 ActivityBuilder setStack(ActivityStack stack) {
137 mStack = stack;
138 return this;
139 }
140
141 ActivityBuilder setCreateTask(boolean createTask) {
142 mCreateTask = createTask;
143 return this;
144 }
145
146 ActivityBuilder setUid(int uid) {
147 mUid = uid;
148 return this;
149 }
150
151 ActivityRecord build() {
152 if (mComponent == null) {
153 final int id = sCurrentActivityId++;
154 mComponent = ComponentName.createRelative(DEFAULT_PACKAGE,
155 DEFAULT_BASE_ACTIVITY_NAME + id);
156 }
157
158 if (mCreateTask) {
159 mTaskRecord = new TaskBuilder(mService.mStackSupervisor)
160 .setComponent(mComponent)
161 .setStack(mStack).build();
162 }
163
164 Intent intent = new Intent();
165 intent.setComponent(mComponent);
166 final ActivityInfo aInfo = new ActivityInfo();
167 aInfo.applicationInfo = new ApplicationInfo();
168 aInfo.applicationInfo.packageName = mComponent.getPackageName();
169 aInfo.applicationInfo.uid = mUid;
Bryce Lee18d51592017-10-25 10:22:19 -0700170 final ActivityRecord activity = new ActivityRecord(mService, null /* caller */,
171 0 /* launchedFromPid */, 0, null, intent, null,
172 aInfo /*aInfo*/, new Configuration(), null /* resultTo */, null /* resultWho */,
173 0 /* reqCode */, false /*componentSpecified*/, false /* rootVoiceInteraction */,
174 mService.mStackSupervisor, null /* options */, null /* sourceRecord */);
175 activity.mWindowContainerController = mock(AppWindowContainerController.class);
176
177 if (mTaskRecord != null) {
178 mTaskRecord.addActivityToTop(activity);
179 }
180
Bryce Lee0bd8d422018-01-09 09:45:57 -0800181 activity.setProcess(new ProcessRecord(null, mService.mContext.getApplicationInfo(),
182 "name", 12345));
183 activity.app.thread = mock(IApplicationThread.class);
184
Bryce Lee18d51592017-10-25 10:22:19 -0700185 return activity;
186 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700187 }
188
Bryce Lee18d51592017-10-25 10:22:19 -0700189 /**
190 * Builder for creating new tasks.
191 */
192 protected static class TaskBuilder {
193 private final ActivityStackSupervisor mSupervisor;
Winson Chung1dbc8112017-09-28 18:05:31 -0700194
Bryce Lee18d51592017-10-25 10:22:19 -0700195 private ComponentName mComponent;
196 private String mPackage;
197 private int mFlags = 0;
198 private int mTaskId = 0;
Winson Chung0ec2a352017-10-26 11:38:30 -0700199 private int mUserId = 0;
Bryce Lee93e7f792017-10-25 15:54:55 -0700200 private IVoiceInteractionSession mVoiceSession;
Bryce Leeaf691c02017-03-20 14:20:22 -0700201
Bryce Lee18d51592017-10-25 10:22:19 -0700202 private ActivityStack mStack;
Bryce Leeaf691c02017-03-20 14:20:22 -0700203
Bryce Lee18d51592017-10-25 10:22:19 -0700204 TaskBuilder(ActivityStackSupervisor supervisor) {
205 mSupervisor = supervisor;
206 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700207
Bryce Lee18d51592017-10-25 10:22:19 -0700208 TaskBuilder setComponent(ComponentName component) {
209 mComponent = component;
210 return this;
211 }
212
213 TaskBuilder setPackage(String packageName) {
214 mPackage = packageName;
215 return this;
216 }
217
Bryce Lee93e7f792017-10-25 15:54:55 -0700218 TaskBuilder setVoiceSession(IVoiceInteractionSession session) {
219 mVoiceSession = session;
220 return this;
221 }
222
Bryce Lee18d51592017-10-25 10:22:19 -0700223 TaskBuilder setFlags(int flags) {
224 mFlags = flags;
225 return this;
226 }
227
228 TaskBuilder setTaskId(int taskId) {
229 mTaskId = taskId;
230 return this;
231 }
232
Winson Chung0ec2a352017-10-26 11:38:30 -0700233 TaskBuilder setUserId(int userId) {
234 mUserId = userId;
235 return this;
236 }
237
Bryce Lee18d51592017-10-25 10:22:19 -0700238 TaskBuilder setStack(ActivityStack stack) {
239 mStack = stack;
240 return this;
241 }
242
243 TaskRecord build() {
244 if (mStack == null) {
245 mStack = mSupervisor.getDefaultDisplay().createStack(
246 WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
247 }
248
249 final ActivityInfo aInfo = new ActivityInfo();
250 aInfo.applicationInfo = new ApplicationInfo();
251 aInfo.applicationInfo.packageName = mPackage;
252
253 Intent intent = new Intent();
254 intent.setComponent(mComponent);
255 intent.setFlags(mFlags);
256
257 final TaskRecord task = new TaskRecord(mSupervisor.mService, mTaskId, aInfo,
Bryce Lee93e7f792017-10-25 15:54:55 -0700258 intent /*intent*/, mVoiceSession, null /*_voiceInteractor*/);
Winson Chung0ec2a352017-10-26 11:38:30 -0700259 task.userId = mUserId;
Bryce Lee18d51592017-10-25 10:22:19 -0700260 mSupervisor.setFocusStackUnchecked("test", mStack);
261 mStack.addTask(task, true, "creating test task");
262 task.setStack(mStack);
263 task.setWindowContainerController(mock(TaskWindowContainerController.class));
Winson Chung0ec2a352017-10-26 11:38:30 -0700264 task.touchActiveTime();
Bryce Lee18d51592017-10-25 10:22:19 -0700265
266 return task;
267 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700268 }
269
270 /**
271 * An {@link ActivityManagerService} subclass which provides a test
272 * {@link ActivityStackSupervisor}.
273 */
274 protected static class TestActivityManagerService extends ActivityManagerService {
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700275 TestActivityManagerService(Context context) {
Bryce Leeaf691c02017-03-20 14:20:22 -0700276 super(context);
Bryce Lee04ab3462017-04-10 15:06:33 -0700277 mSupportsMultiWindow = true;
278 mSupportsMultiDisplay = true;
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700279 mSupportsSplitScreenMultiWindow = true;
280 mSupportsFreeformWindowManagement = true;
281 mSupportsPictureInPicture = true;
Bryce Lee6a0754a2017-10-10 17:53:50 -0700282 mWindowManager = WindowTestUtils.getMockWindowManagerService();
Bryce Leeaf691c02017-03-20 14:20:22 -0700283 }
284
285 @Override
Bryce Lee2a3cc462017-10-27 10:57:35 -0700286 final protected ActivityStackSupervisor createStackSupervisor() {
287 final ActivityStackSupervisor supervisor = spy(createTestSupervisor());
288
289 // No home stack is set.
290 doNothing().when(supervisor).moveHomeStackToFront(any());
291 doReturn(true).when(supervisor).moveHomeStackTaskToTop(any());
292 // Invoked during {@link ActivityStack} creation.
293 doNothing().when(supervisor).updateUIDsPresentOnDisplay();
294 // Always keep things awake.
295 doReturn(true).when(supervisor).hasAwakeDisplay();
296 // Called when moving activity to pinned stack.
297 doNothing().when(supervisor).ensureActivitiesVisibleLocked(any(), anyInt(), anyBoolean());
298 // Do not schedule idle timeouts
299 doNothing().when(supervisor).scheduleIdleTimeoutLocked(any());
300
301 supervisor.initialize();
302
303 return supervisor;
304 }
305
306 protected ActivityStackSupervisor createTestSupervisor() {
Bryce Lee3115bdf2017-04-05 08:39:40 -0700307 return new TestActivityStackSupervisor(this, mHandlerThread.getLooper());
Bryce Leeaf691c02017-03-20 14:20:22 -0700308 }
Bryce Lee29a649d2017-08-18 13:52:31 -0700309
310 @Override
311 void updateUsageStats(ActivityRecord component, boolean resumed) {
312 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700313 }
314
315 /**
316 * An {@link ActivityStackSupervisor} which stubs out certain methods that depend on
317 * setup not available in the test environment. Also specifies an injector for
318 */
319 protected static class TestActivityStackSupervisor extends ActivityStackSupervisor {
Bryce Lee2a3cc462017-10-27 10:57:35 -0700320 private ActivityDisplay mDisplay;
Bryce Lee943ebe72017-05-04 10:19:07 -0700321
Bryce Leeaf691c02017-03-20 14:20:22 -0700322 public TestActivityStackSupervisor(ActivityManagerService service, Looper looper) {
323 super(service, looper);
Wale Ogunwale9dcf9462017-09-19 15:13:01 -0700324 mDisplayManager =
325 (DisplayManager) mService.mContext.getSystemService(Context.DISPLAY_SERVICE);
Bryce Lee04ab3462017-04-10 15:06:33 -0700326 mWindowManager = prepareMockWindowManager();
Bryce Lee2a3cc462017-10-27 10:57:35 -0700327 }
328
329 @Override
330 public void initialize() {
331 super.initialize();
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700332 mDisplay = new TestActivityDisplay(this, DEFAULT_DISPLAY);
Wale Ogunwale9dcf9462017-09-19 15:13:01 -0700333 attachDisplay(mDisplay);
Bryce Lee04ab3462017-04-10 15:06:33 -0700334 }
335
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700336 @Override
337 ActivityDisplay getDefaultDisplay() {
338 return mDisplay;
339 }
340
Bryce Lee2a3cc462017-10-27 10:57:35 -0700341 // 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 -0700342 @Override
343 ActivityStack getNextFocusableStackLocked(ActivityStack currentFocus) {
344 return mFocusedStack;
345 }
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700346 }
347
348 private static class TestActivityDisplay extends ActivityDisplay {
349
350 private final ActivityStackSupervisor mSupervisor;
351 TestActivityDisplay(ActivityStackSupervisor supervisor, int displayId) {
352 super(supervisor, displayId);
353 mSupervisor = supervisor;
Andrii Kulianb1cdb102017-07-13 15:33:06 -0700354 }
355
356 @Override
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700357 <T extends ActivityStack> T createStackUnchecked(int windowingMode, int activityType,
358 int stackId, boolean onTop) {
359 if (windowingMode == WINDOWING_MODE_PINNED) {
360 return (T) new PinnedActivityStack(this, stackId, mSupervisor, onTop) {
Andrii Kulianb1cdb102017-07-13 15:33:06 -0700361 @Override
362 Rect getDefaultPictureInPictureBounds(float aspectRatio) {
363 return new Rect(50, 50, 100, 100);
364 }
Bryce Lee4e4a3ec2017-09-27 08:25:03 -0700365
366 @Override
367 PinnedStackWindowController createStackWindowController(int displayId,
368 boolean onTop, Rect outBounds) {
369 return mock(PinnedStackWindowController.class);
370 }
Andrii Kulianb1cdb102017-07-13 15:33:06 -0700371 };
372 } else {
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700373 return (T) new TestActivityStack(
374 this, stackId, mSupervisor, windowingMode, activityType, onTop);
Andrii Kulianb1cdb102017-07-13 15:33:06 -0700375 }
Bryce Lee04ab3462017-04-10 15:06:33 -0700376 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700377 }
378
Bryce Lee04ab3462017-04-10 15:06:33 -0700379 private static WindowManagerService prepareMockWindowManager() {
Bryce Lee4e4a3ec2017-09-27 08:25:03 -0700380 final WindowManagerService service = WindowTestUtils.getMockWindowManagerService();
Bryce Lee04ab3462017-04-10 15:06:33 -0700381
382 doAnswer((InvocationOnMock invocationOnMock) -> {
383 final Runnable runnable = invocationOnMock.<Runnable>getArgument(0);
384 if (runnable != null) {
385 runnable.run();
386 }
387 return null;
388 }).when(service).inSurfaceTransaction(any());
389
390 return service;
391 }
392
Bryce Leeaf691c02017-03-20 14:20:22 -0700393 /**
Bryce Lee4e4a3ec2017-09-27 08:25:03 -0700394 * Overrided of {@link ActivityStack} that tracks test metrics, such as the number of times a
Bryce Leeaf691c02017-03-20 14:20:22 -0700395 * method is called. Note that its functionality depends on the implementations of the
396 * construction arguments.
397 */
398 protected static class TestActivityStack<T extends StackWindowController>
Wale Ogunwale7e1f5f52017-10-18 15:19:59 -0700399 extends ActivityStack<T> {
Bryce Leeaf691c02017-03-20 14:20:22 -0700400 private int mOnActivityRemovedFromStackCount = 0;
401 private T mContainerController;
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700402
Wale Ogunwale7e1f5f52017-10-18 15:19:59 -0700403 static final int IS_TRANSLUCENT_UNSET = 0;
404 static final int IS_TRANSLUCENT_FALSE = 1;
405 static final int IS_TRANSLUCENT_TRUE = 2;
406 private int mIsTranslucent = IS_TRANSLUCENT_UNSET;
407
Wale Ogunwale30e441d2017-11-09 08:28:45 -0800408 static final int SUPPORTS_SPLIT_SCREEN_UNSET = 0;
409 static final int SUPPORTS_SPLIT_SCREEN_FALSE = 1;
410 static final int SUPPORTS_SPLIT_SCREEN_TRUE = 2;
411 private int mSupportsSplitScreen = SUPPORTS_SPLIT_SCREEN_UNSET;
412
Wale Ogunwale9dcf9462017-09-19 15:13:01 -0700413 TestActivityStack(ActivityDisplay display, int stackId, ActivityStackSupervisor supervisor,
Wale Ogunwale04a05ac2017-09-17 21:35:02 -0700414 int windowingMode, int activityType, boolean onTop) {
415 super(display, stackId, supervisor, windowingMode, activityType, onTop);
Bryce Leeaf691c02017-03-20 14:20:22 -0700416 }
417
418 @Override
419 void onActivityRemovedFromStack(ActivityRecord r) {
420 mOnActivityRemovedFromStackCount++;
421 super.onActivityRemovedFromStack(r);
422 }
423
424 // Returns the number of times {@link #onActivityRemovedFromStack} has been called
Wale Ogunwale7e1f5f52017-10-18 15:19:59 -0700425 int onActivityRemovedFromStackInvocationCount() {
Bryce Leeaf691c02017-03-20 14:20:22 -0700426 return mOnActivityRemovedFromStackCount;
427 }
428
429 @Override
Wale Ogunwale034a8ec2017-09-02 17:14:40 -0700430 protected T createStackWindowController(int displayId, boolean onTop, Rect outBounds) {
Bryce Leeaf691c02017-03-20 14:20:22 -0700431 mContainerController = (T) WindowTestUtils.createMockStackWindowContainerController();
Bryce Leef3c6a472017-11-14 14:53:06 -0800432
433 // Primary pinned stacks require a non-empty out bounds to be set or else all tasks
434 // will be moved to the full screen stack.
435 if (getWindowingMode() == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) {
436 outBounds.set(0, 0, 100, 100);
437 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700438 return mContainerController;
439 }
440
441 @Override
442 T getWindowContainerController() {
443 return mContainerController;
444 }
Wale Ogunwale7e1f5f52017-10-18 15:19:59 -0700445
446 void setIsTranslucent(boolean isTranslucent) {
447 mIsTranslucent = isTranslucent ? IS_TRANSLUCENT_TRUE : IS_TRANSLUCENT_FALSE;
448 }
449
450 @Override
Wale Ogunwale66e16852017-10-19 13:35:52 -0700451 boolean isStackTranslucent(ActivityRecord starting) {
Wale Ogunwale7e1f5f52017-10-18 15:19:59 -0700452 switch (mIsTranslucent) {
453 case IS_TRANSLUCENT_TRUE:
454 return true;
455 case IS_TRANSLUCENT_FALSE:
456 return false;
457 case IS_TRANSLUCENT_UNSET:
458 default:
Wale Ogunwale66e16852017-10-19 13:35:52 -0700459 return super.isStackTranslucent(starting);
Wale Ogunwale7e1f5f52017-10-18 15:19:59 -0700460 }
461 }
Wale Ogunwale30e441d2017-11-09 08:28:45 -0800462
463 void setSupportsSplitScreen(boolean supportsSplitScreen) {
464 mSupportsSplitScreen = supportsSplitScreen
465 ? SUPPORTS_SPLIT_SCREEN_TRUE : SUPPORTS_SPLIT_SCREEN_FALSE;
466 }
467
468 @Override
469 public boolean supportsSplitScreenWindowingMode() {
470 switch (mSupportsSplitScreen) {
471 case SUPPORTS_SPLIT_SCREEN_TRUE:
472 return true;
473 case SUPPORTS_SPLIT_SCREEN_FALSE:
474 return false;
475 case SUPPORTS_SPLIT_SCREEN_UNSET:
476 default:
477 return super.supportsSplitScreenWindowingMode();
478 }
479 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700480 }
Bryce Leeaf691c02017-03-20 14:20:22 -0700481}