1 /* 2 * Copyright (C) 2022 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.wm.shell.windowdecor; 18 19 import android.app.ActivityManager; 20 import android.view.SurfaceControl; 21 22 import com.android.wm.shell.freeform.FreeformTaskTransitionStarter; 23 import com.android.wm.shell.splitscreen.SplitScreenController; 24 25 /** 26 * The interface used by some {@link com.android.wm.shell.ShellTaskOrganizer.TaskListener} to help 27 * customize {@link WindowDecoration}. Its implementations are responsible to interpret user's 28 * interactions with UI widgets in window decorations and send corresponding requests to system 29 * servers. 30 */ 31 public interface WindowDecorViewModel { 32 /** 33 * Sets the transition starter that starts freeform task transitions. Only called when 34 * {@link com.android.wm.shell.transition.Transitions#ENABLE_SHELL_TRANSITIONS} is {@code true}. 35 * 36 * @param transitionStarter the transition starter that starts freeform task transitions 37 */ setFreeformTaskTransitionStarter(FreeformTaskTransitionStarter transitionStarter)38 void setFreeformTaskTransitionStarter(FreeformTaskTransitionStarter transitionStarter); 39 40 /** 41 * Sets the {@link SplitScreenController} if available. 42 */ setSplitScreenController(SplitScreenController splitScreenController)43 void setSplitScreenController(SplitScreenController splitScreenController); 44 45 /** 46 * Creates a window decoration for the given task. Can be {@code null} for Fullscreen tasks but 47 * not Freeform ones. 48 * 49 * @param taskInfo the initial task info of the task 50 * @param taskSurface the surface of the task 51 * @param startT the start transaction to be applied before the transition 52 * @param finishT the finish transaction to restore states after the transition 53 * @return {@code true} if window decoration was created, {@code false} otherwise 54 */ onTaskOpening( ActivityManager.RunningTaskInfo taskInfo, SurfaceControl taskSurface, SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT)55 boolean onTaskOpening( 56 ActivityManager.RunningTaskInfo taskInfo, 57 SurfaceControl taskSurface, 58 SurfaceControl.Transaction startT, 59 SurfaceControl.Transaction finishT); 60 61 /** 62 * Notifies a task info update on the given task, with the window decoration created previously 63 * for this task by {@link #onTaskOpening}. 64 * 65 * @param taskInfo the new task info of the task 66 */ onTaskInfoChanged(ActivityManager.RunningTaskInfo taskInfo)67 void onTaskInfoChanged(ActivityManager.RunningTaskInfo taskInfo); 68 69 /** 70 * Notifies a task has vanished, which can mean that the task changed windowing mode or was 71 * removed. 72 * 73 * @param taskInfo the task info of the task 74 */ onTaskVanished(ActivityManager.RunningTaskInfo taskInfo)75 void onTaskVanished(ActivityManager.RunningTaskInfo taskInfo); 76 77 /** 78 * Notifies a transition is about to start about the given task to give the window decoration a 79 * chance to prepare for this transition. Unlike {@link #onTaskInfoChanged}, this method creates 80 * a window decoration if one does not exist but is required. 81 * 82 * @param taskInfo the initial task info of the task 83 * @param taskSurface the surface of the task 84 * @param startT the start transaction to be applied before the transition 85 * @param finishT the finish transaction to restore states after the transition 86 */ onTaskChanging( ActivityManager.RunningTaskInfo taskInfo, SurfaceControl taskSurface, SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT)87 void onTaskChanging( 88 ActivityManager.RunningTaskInfo taskInfo, 89 SurfaceControl taskSurface, 90 SurfaceControl.Transaction startT, 91 SurfaceControl.Transaction finishT); 92 93 /** 94 * Notifies that the given task is about to close to give the window decoration a chance to 95 * prepare for this transition. 96 * 97 * @param taskInfo the initial task info of the task 98 * @param startT the start transaction to be applied before the transition 99 * @param finishT the finish transaction to restore states after the transition 100 */ onTaskClosing( ActivityManager.RunningTaskInfo taskInfo, SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT)101 void onTaskClosing( 102 ActivityManager.RunningTaskInfo taskInfo, 103 SurfaceControl.Transaction startT, 104 SurfaceControl.Transaction finishT); 105 106 /** 107 * Destroys the window decoration of the give task. 108 * 109 * @param taskInfo the info of the task 110 */ destroyWindowDecoration(ActivityManager.RunningTaskInfo taskInfo)111 void destroyWindowDecoration(ActivityManager.RunningTaskInfo taskInfo); 112 }