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.app.ActivityManager;
21 
22 /**
23  * A callback interface for the host activity that uses {@link RemoteCarTaskView} and its
24  * derivatives.
25  */
26 interface RemoteCarTaskViewCallback<T extends RemoteCarTaskView> {
27     /**
28      * Called when the underlying {@link RemoteCarTaskView} instance is created.
29      *
30      * @param taskView the new newly created {@link RemoteCarTaskView} instance.
31      */
onTaskViewCreated(@onNull T taskView)32     default void onTaskViewCreated(@NonNull T taskView) {}
33 
34     /**
35      * Called when the underlying {@link RemoteCarTaskView} is ready. A {@link RemoteCarTaskView}
36      * can be considered ready when it has completed all the set up that is required.
37      * This callback is only triggered once.
38      */
onTaskViewInitialized()39     default void onTaskViewInitialized() {}
40 
41     /**
42      * Called when the underlying {@link RemoteCarTaskView} is released.
43      * This callback is only triggered once.
44      */
onTaskViewReleased()45     default void onTaskViewReleased() {}
46 
47     /**
48      * Called when the task has appeared in the taskview.
49      *
50      * @param taskInfo the taskInfo of the task that has appeared.
51      */
onTaskAppeared(@onNull ActivityManager.RunningTaskInfo taskInfo)52     default void onTaskAppeared(@NonNull ActivityManager.RunningTaskInfo taskInfo) {}
53 
54     /**
55      * Called when the task's info has changed.
56      *
57      * @param taskInfo the taskInfo of the task that has a change in info.
58      */
onTaskInfoChanged(@onNull ActivityManager.RunningTaskInfo taskInfo)59     default void onTaskInfoChanged(@NonNull ActivityManager.RunningTaskInfo taskInfo) {}
60 
61     /**
62      * Called when the task has vanished.
63      *
64      * @param taskInfo the taskInfo of the task that has vanished.
65      */
onTaskVanished(@onNull ActivityManager.RunningTaskInfo taskInfo)66     default void onTaskVanished(@NonNull ActivityManager.RunningTaskInfo taskInfo) {}
67 }
68