blob: 806febd1de563549afdb8523836d97cd69c315e4 [file] [log] [blame]
Thomas Stuart9bfb2432022-09-27 15:02:07 -07001/*
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
17package android.telecom;
18
19
20import android.annotation.NonNull;
21
Thomas Stuart7aeccde2022-12-21 14:47:21 -080022import java.util.List;
Thomas Stuart9bfb2432022-09-27 15:02:07 -070023import java.util.function.Consumer;
24
25/**
26 * CallEventCallback relays updates to a call from the Telecom framework.
27 * This can include operations which the app must implement on a Call due to the presence of other
28 * calls on the device, requests relayed from a Bluetooth device, or from another calling surface.
29 *
30 * <p>
31 * CallEventCallbacks with {@link Consumer}s are transactional, meaning that a client must
32 * complete the {@link Consumer} via {@link Consumer#accept(Object)} in order to complete the
33 * CallEventCallback. If a CallEventCallback can be completed, the
34 * {@link Consumer#accept(Object)} should be called with {@link Boolean#TRUE}. Otherwise,
35 * {@link Consumer#accept(Object)} should be called with {@link Boolean#FALSE} to represent the
36 * CallEventCallback cannot be completed on the client side.
37 *
38 * <p>
39 * Note: Each CallEventCallback has a timeout of 5000 milliseconds. Failing to complete the
40 * {@link Consumer} before the timeout will result in a failed transaction.
41 */
42public interface CallEventCallback {
43 /**
44 * Telecom is informing the client to set the call active
45 *
46 * @param wasCompleted The {@link Consumer} to be completed. If the client can set the call
47 * active on their end, the {@link Consumer#accept(Object)} should be
48 * called with {@link Boolean#TRUE}. Otherwise,
49 * {@link Consumer#accept(Object)} should be called with
50 * {@link Boolean#FALSE}.
51 */
52 void onSetActive(@NonNull Consumer<Boolean> wasCompleted);
53
54 /**
55 * Telecom is informing the client to set the call inactive. This is the same as holding a call
56 * for two endpoints but can be extended to setting a meeting inactive.
57 *
58 * @param wasCompleted The {@link Consumer} to be completed. If the client can set the call
59 * inactive on their end, the {@link Consumer#accept(Object)} should be
60 * called with {@link Boolean#TRUE}. Otherwise,
61 * {@link Consumer#accept(Object)} should be called with
62 * {@link Boolean#FALSE}.
63 */
64 void onSetInactive(@NonNull Consumer<Boolean> wasCompleted);
65
66 /**
67 * Telecom is informing the client to answer an incoming call and set it to active.
68 *
69 * @param videoState see {@link android.telecom.CallAttributes.CallType} for valid states
70 * @param wasCompleted The {@link Consumer} to be completed. If the client can answer the call
71 * on their end, {@link Consumer#accept(Object)} should be called with
72 * {@link Boolean#TRUE}. Otherwise, {@link Consumer#accept(Object)} should
73 * be called with {@link Boolean#FALSE}.
74 */
75 void onAnswer(@android.telecom.CallAttributes.CallType int videoState,
76 @NonNull Consumer<Boolean> wasCompleted);
77
78 /**
79 * Telecom is informing the client to reject the incoming call
80 *
81 * @param wasCompleted The {@link Consumer} to be completed. If the client can reject the
82 * incoming call, {@link Consumer#accept(Object)} should be called with
83 * {@link Boolean#TRUE}. Otherwise, {@link Consumer#accept(Object)}
84 * should be called with {@link Boolean#FALSE}.
85 */
86 void onReject(@NonNull Consumer<Boolean> wasCompleted);
87
88 /**
89 * Telecom is informing the client to disconnect the call
90 *
91 * @param wasCompleted The {@link Consumer} to be completed. If the client can disconnect the
92 * call on their end, {@link Consumer#accept(Object)} should be called with
93 * {@link Boolean#TRUE}. Otherwise, {@link Consumer#accept(Object)}
94 * should be called with {@link Boolean#FALSE}.
95 */
96 void onDisconnect(@NonNull Consumer<Boolean> wasCompleted);
97
98 /**
Grace Jiaef5a4cc2022-12-13 11:08:55 -080099 * Telecom is informing the client to set the call in streaming.
100 *
101 * @param wasCompleted The {@link Consumer} to be completed. If the client can stream the
102 * call on their end, {@link Consumer#accept(Object)} should be called with
103 * {@link Boolean#TRUE}. Otherwise, {@link Consumer#accept(Object)}
104 * should be called with {@link Boolean#FALSE}.
105 */
106 void onCallStreamingStarted(@NonNull Consumer<Boolean> wasCompleted);
107
108 /**
109 * Telecom is informing the client user requested call streaming but the stream can't be
110 * started.
111 *
112 * @param reason Code to indicate the reason of this failure
113 */
114 void onCallStreamingFailed(@CallStreamingService.StreamingFailedReason int reason);
Thomas Stuart7aeccde2022-12-21 14:47:21 -0800115
116 /**
117 * Telecom is informing the client the current {@link CallEndpoint} changed.
118 *
119 * @param newCallEndpoint The new {@link CallEndpoint} through which call media flows
120 * (i.e. speaker, bluetooth, etc.).
121 */
122 void onCallEndpointChanged(@NonNull CallEndpoint newCallEndpoint);
123
124 /**
125 * Telecom is informing the client that the available {@link CallEndpoint}s have changed.
126 *
127 * @param availableEndpoints The set of available {@link CallEndpoint}s reported by Telecom.
128 */
129 void onAvailableCallEndpointsChanged(@NonNull List<CallEndpoint> availableEndpoints);
130
131 /**
132 * Called when the mute state changes.
133 *
134 * @param isMuted The current mute state.
135 */
136 void onMuteStateChanged(boolean isMuted);
Thomas Stuart9bfb2432022-09-27 15:02:07 -0700137}