Winson Chung | 5589333 | 2017-02-17 17:13:10 -0800 | [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 | |
| 19 | import android.app.RemoteAction; |
| 20 | import android.graphics.Rect; |
| 21 | |
| 22 | import com.android.server.am.ActivityStackSupervisor.ActivityContainer; |
| 23 | import com.android.server.wm.PinnedStackWindowController; |
Winson Chung | 3a68287 | 2017-04-10 14:38:05 -0700 | [diff] [blame^] | 24 | import com.android.server.wm.PinnedStackWindowListener; |
Winson Chung | 5589333 | 2017-02-17 17:13:10 -0800 | [diff] [blame] | 25 | import com.android.server.wm.StackWindowController; |
| 26 | |
Winson Chung | 5af42fc | 2017-03-24 17:11:33 -0700 | [diff] [blame] | 27 | import java.util.ArrayList; |
Winson Chung | 5589333 | 2017-02-17 17:13:10 -0800 | [diff] [blame] | 28 | import java.util.List; |
| 29 | |
| 30 | /** |
| 31 | * State and management of the pinned stack of activities. |
| 32 | */ |
Winson Chung | 3a68287 | 2017-04-10 14:38:05 -0700 | [diff] [blame^] | 33 | class PinnedActivityStack extends ActivityStack<PinnedStackWindowController> |
| 34 | implements PinnedStackWindowListener { |
Winson Chung | 5589333 | 2017-02-17 17:13:10 -0800 | [diff] [blame] | 35 | |
| 36 | PinnedActivityStack(ActivityContainer activityContainer, |
| 37 | RecentTasks recentTasks, boolean onTop) { |
| 38 | super(activityContainer, recentTasks, onTop); |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | PinnedStackWindowController createStackWindowController(int displayId, boolean onTop, |
| 43 | Rect outBounds) { |
| 44 | return new PinnedStackWindowController(mStackId, this, displayId, onTop, outBounds); |
| 45 | } |
| 46 | |
Winson Chung | 08f8189 | 2017-03-02 15:40:51 -0800 | [diff] [blame] | 47 | void animateResizePinnedStack(Rect sourceBounds, Rect destBounds, int animationDuration) { |
| 48 | getWindowContainerController().animateResizePinnedStack(sourceBounds, destBounds, |
| 49 | animationDuration); |
Winson Chung | 5589333 | 2017-02-17 17:13:10 -0800 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | void setPictureInPictureAspectRatio(float aspectRatio) { |
| 53 | getWindowContainerController().setPictureInPictureAspectRatio(aspectRatio); |
| 54 | } |
| 55 | |
| 56 | void setPictureInPictureActions(List<RemoteAction> actions) { |
| 57 | getWindowContainerController().setPictureInPictureActions(actions); |
| 58 | } |
Winson Chung | 02e7193 | 2017-03-10 10:08:17 -0800 | [diff] [blame] | 59 | |
| 60 | boolean isBoundsAnimatingToFullscreen() { |
| 61 | return getWindowContainerController().isBoundsAnimatingToFullscreen(); |
| 62 | } |
Winson Chung | 5af42fc | 2017-03-24 17:11:33 -0700 | [diff] [blame] | 63 | |
| 64 | @Override |
| 65 | public void updatePictureInPictureModeForPinnedStackAnimation(Rect targetStackBounds) { |
| 66 | // It is guaranteed that the activities requiring the update will be in the pinned stack at |
| 67 | // this point (either reparented before the animation into PiP, or before reparenting after |
| 68 | // the animation out of PiP) |
| 69 | synchronized(this) { |
| 70 | ArrayList<TaskRecord> tasks = getAllTasks(); |
| 71 | for (int i = 0; i < tasks.size(); i++ ) { |
| 72 | mStackSupervisor.scheduleUpdatePictureInPictureModeIfNeeded(tasks.get(i), |
| 73 | targetStackBounds, true /* immediate */); |
| 74 | } |
| 75 | } |
| 76 | } |
Winson Chung | 5589333 | 2017-02-17 17:13:10 -0800 | [diff] [blame] | 77 | } |