blob: cd9c42c7c643847a971669f78780734c38c7a064 [file] [log] [blame]
Winson Chung55893332017-02-17 17:13:10 -08001/*
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
19import android.app.RemoteAction;
20import android.graphics.Rect;
21
22import com.android.server.am.ActivityStackSupervisor.ActivityContainer;
23import com.android.server.wm.PinnedStackWindowController;
Winson Chung3a682872017-04-10 14:38:05 -070024import com.android.server.wm.PinnedStackWindowListener;
Winson Chung55893332017-02-17 17:13:10 -080025
Winson Chung5af42fc2017-03-24 17:11:33 -070026import java.util.ArrayList;
Winson Chung55893332017-02-17 17:13:10 -080027import java.util.List;
28
29/**
30 * State and management of the pinned stack of activities.
31 */
Winson Chung3a682872017-04-10 14:38:05 -070032class PinnedActivityStack extends ActivityStack<PinnedStackWindowController>
33 implements PinnedStackWindowListener {
Winson Chung55893332017-02-17 17:13:10 -080034
35 PinnedActivityStack(ActivityContainer activityContainer,
36 RecentTasks recentTasks, boolean onTop) {
37 super(activityContainer, recentTasks, onTop);
38 }
39
40 @Override
41 PinnedStackWindowController createStackWindowController(int displayId, boolean onTop,
42 Rect outBounds) {
43 return new PinnedStackWindowController(mStackId, this, displayId, onTop, outBounds);
44 }
45
Winson Chung08f81892017-03-02 15:40:51 -080046 void animateResizePinnedStack(Rect sourceBounds, Rect destBounds, int animationDuration) {
47 getWindowContainerController().animateResizePinnedStack(sourceBounds, destBounds,
48 animationDuration);
Winson Chung55893332017-02-17 17:13:10 -080049 }
50
51 void setPictureInPictureAspectRatio(float aspectRatio) {
52 getWindowContainerController().setPictureInPictureAspectRatio(aspectRatio);
53 }
54
55 void setPictureInPictureActions(List<RemoteAction> actions) {
56 getWindowContainerController().setPictureInPictureActions(actions);
57 }
Winson Chung02e71932017-03-10 10:08:17 -080058
Winson Chung40a5f932017-04-13 16:39:36 -070059 boolean isAnimatingBoundsToFullscreen() {
60 return getWindowContainerController().isAnimatingBoundsToFullscreen();
Winson Chung02e71932017-03-10 10:08:17 -080061 }
Winson Chung5af42fc2017-03-24 17:11:33 -070062
63 @Override
64 public void updatePictureInPictureModeForPinnedStackAnimation(Rect targetStackBounds) {
65 // It is guaranteed that the activities requiring the update will be in the pinned stack at
66 // this point (either reparented before the animation into PiP, or before reparenting after
67 // the animation out of PiP)
68 synchronized(this) {
69 ArrayList<TaskRecord> tasks = getAllTasks();
70 for (int i = 0; i < tasks.size(); i++ ) {
71 mStackSupervisor.scheduleUpdatePictureInPictureModeIfNeeded(tasks.get(i),
72 targetStackBounds, true /* immediate */);
73 }
74 }
75 }
Winson Chung55893332017-02-17 17:13:10 -080076}