Debian Codegraph @

libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipMenuController.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 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.pip;
18
19 import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
20 import static android.view.WindowManager.LayoutParams.FLAG_SLIPPERY;
21 import static android.view.WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
22 import static android.view.WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
23 import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
24 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
25
26 import android.annotation.Nullable;
27 import android.app.ActivityManager.RunningTaskInfo;
28 import android.app.RemoteAction;
29 import android.graphics.PixelFormat;
30 import android.graphics.Rect;
31 import android.view.SurfaceControl;
32 import android.view.WindowManager;
33
34 import java.util.List;
35
36 /**
37 * Interface to allow {@link com.android.wm.shell.pip.PipTaskOrganizer} to call into
38 * PiP menu when certain events happen (task appear/vanish, PiP move, etc.)
39 */
40 public interface PipMenuController {
41
42 String MENU_WINDOW_TITLE = "PipMenuView";
43
44 /**
45 * Called when
46 * {@link PipTaskOrganizer#onTaskAppeared(RunningTaskInfo, SurfaceControl)}
47 * is called.
48 */
49 void attach(SurfaceControl leash);
50
51 /**
52 * Called when
53 * {@link PipTaskOrganizer#onTaskVanished(RunningTaskInfo)} is called.
54 */
55 void detach();
56
57 /**
58 * Check if menu is visible or not.
59 */
60 boolean isMenuVisible();
61
62 /**
63 * Show the PIP menu.
64 */
65 void showMenu();
66
67 /**
68 * Given a set of actions, update the menu.
69 */
70 void setAppActions(List<RemoteAction> appActions, RemoteAction closeAction);
71
72 /**
73 * Resize the PiP menu with the given bounds. The PiP SurfaceControl is given if there is a
74 * need to synchronize the movements on the same frame as PiP.
75 */
76 default void resizePipMenu(@Nullable SurfaceControl pipLeash,
77 @Nullable SurfaceControl.Transaction t,
78 Rect destinationBounds) {}
79
80 /**
81 * Move the PiP menu with the given bounds. The PiP SurfaceControl is given if there is a
82 * need to synchronize the movements on the same frame as PiP.
83 */
84 default void movePipMenu(@Nullable SurfaceControl pipLeash,
85 @Nullable SurfaceControl.Transaction t,
86 Rect destinationBounds) {}
87
88 /**
89 * Update the PiP menu with the given bounds for re-layout purposes.
90 */
91 default void updateMenuBounds(Rect destinationBounds) {}
92
93 /**
94 * Update when the current focused task changes.
95 */
96 default void onFocusTaskChanged(RunningTaskInfo taskInfo) {}
97
98 /**
99 * Returns a default LayoutParams for the PIP Menu.
100 * @param width the PIP stack width.
101 * @param height the PIP stack height.
102 */
103 default WindowManager.LayoutParams getPipMenuLayoutParams(String title, int width, int height) {
104 final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, height,
105 TYPE_APPLICATION_OVERLAY,
106 FLAG_WATCH_OUTSIDE_TOUCH | FLAG_SPLIT_TOUCH | FLAG_SLIPPERY | FLAG_NOT_TOUCHABLE,
107 PixelFormat.TRANSLUCENT);
108 lp.privateFlags |= PRIVATE_FLAG_TRUSTED_OVERLAY;
109 lp.setTitle(title);
110 return lp;
111 }
112 }