1 /*
2  * Copyright (C) 2023 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 android.car.app;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.SystemApi;
22 import android.app.ActivityOptions;
23 import android.app.PendingIntent;
24 import android.content.Intent;
25 import android.graphics.Rect;
26 import android.os.Bundle;
27 import android.view.SurfaceControl;
28 
29 /**
30  * This is a blueprint to implement the host part of {@link CarTaskViewClient}.
31  *
32  * @hide
33  */
34 @SystemApi
35 public interface CarTaskViewHost {
36     /** Releases the resources held by this task view's host side. */
release()37     void release();
38 
39     /**
40      * See {@link TaskView#startActivity(PendingIntent, Intent,
41      * ActivityOptions, Rect)}
42      */
startActivity( @onNull PendingIntent pendingIntent, @Nullable Intent intent, @NonNull Bundle options, @Nullable Rect launchBounds)43     void startActivity(
44             @NonNull PendingIntent pendingIntent, @Nullable Intent intent, @NonNull Bundle options,
45             @Nullable Rect launchBounds);
46 
47     /**
48      * Creates the root task, which will be embedded inside this task view.
49      *
50      * @hide
51      */
createRootTask(int displayId)52     void createRootTask(int displayId);
53 
54     /**
55      * Creates the launch root task, which will be embedded inside this task view.
56      *
57      * @hide
58      */
createLaunchRootTask(int displayId, boolean embedHomeTask, boolean embedRecentsTask, boolean embedAssistantTask)59     void createLaunchRootTask(int displayId, boolean embedHomeTask,
60             boolean embedRecentsTask, boolean embedAssistantTask);
61 
62     /**
63      * Notifies the host side that the client surface has been created.
64      *
65      * @param control the {@link SurfaceControl} of the surface that has been created.
66      */
notifySurfaceCreated(@onNull SurfaceControl control)67     void notifySurfaceCreated(@NonNull SurfaceControl control);
68 
69     /**
70      * Sets the bounds of the window for the underlying Task.
71      *
72      * @param windowBoundsOnScreen the new bounds in screen coordinates.
73      */
setWindowBounds(@onNull Rect windowBoundsOnScreen)74     void setWindowBounds(@NonNull Rect windowBoundsOnScreen);
75 
76     /** Notifies the host side that the client surface has been destroyed. */
notifySurfaceDestroyed()77     void notifySurfaceDestroyed();
78 
79     /** Brings the embedded Task to the front in the WM Hierarchy. */
showEmbeddedTask()80     void showEmbeddedTask();
81 
82     /**
83      * Sets the visibility of the embedded task.
84      *
85      * @hide
86      */
setTaskVisibility(boolean visibility)87     void setTaskVisibility(boolean visibility);
88 
89     /**
90      * Reorders the embedded task to top when {@code onTop} is {@code true} and to bottom when
91      * its {@code false}.
92      *
93      * @hide
94      */
reorderTask(boolean onTop)95     void reorderTask(boolean onTop);
96     /**
97      * Adds the given {@code insets} on the Task.
98      *
99      * <p>
100      * The given rectangle for the given insets type is applied to the underlying task right
101      * away.
102      * If a rectangle for an insets type was added previously, it will be replaced with the
103      * new value.
104      * If a rectangle for an insets type was already added, but is not specified currently in
105      * {@code insets}, it will remain applied to the task. Clients should explicitly call
106      * {@link #removeInsets(int, int)} to remove the rectangle for that insets type from
107      * the underlying task.
108      *
109      * @param index An owner might add multiple insets sources with the same type.
110      *              This identifies them.
111      * @param type  The insets type of the insets source. This doesn't accept the composite types.
112      * @param frame The rectangle area of the insets source.
113      */
addInsets(int index, int type, @NonNull Rect frame)114     void addInsets(int index, int type, @NonNull Rect frame);
115 
116     /**
117      * Removes the insets for the given @code index}, and {@code type} that were added via
118      * {@link #addInsets(int, int, Rect)}
119      */
removeInsets(int index, int type)120     void removeInsets(int index, int type);
121 }
122