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