blob: 0166022abeb852818a0beb3a4a9b0e9974726308 [file] [log] [blame]
Thomas Stuart6e418b32023-02-06 08:22:08 -08001/*
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
17package android.telecom;
18
19import android.annotation.NonNull;
20
21import java.util.function.Consumer;
22
23/**
24 * CallControlCallback relays call updates (that require a response) from the Telecom framework out
25 * to the application.This can include operations which the app must implement on a Call due to the
26 * presence of other calls on the device, requests relayed from a Bluetooth device, or from another
27 * calling surface.
28 *
29 * <p>
30 * All CallControlCallbacks are transactional, meaning that a client must
31 * complete the {@link Consumer} via {@link Consumer#accept(Object)} in order to complete the
32 * CallControlCallbacks. If a CallControlCallbacks can be completed, the
33 * {@link Consumer#accept(Object)} should be called with {@link Boolean#TRUE}. Otherwise,
34 * {@link Consumer#accept(Object)} should be called with {@link Boolean#FALSE} to represent the
35 * CallControlCallbacks cannot be completed on the client side.
36 *
37 * <p>
38 * Note: Each CallEventCallback has a timeout of 5000 milliseconds. Failing to complete the
39 * {@link Consumer} before the timeout will result in a failed transaction.
40 */
41public interface CallControlCallback {
42 /**
43 * Telecom is informing the client to set the call active
44 *
45 * @param wasCompleted The {@link Consumer} to be completed. If the client can set the call
46 * active on their end, the {@link Consumer#accept(Object)} should be
Thomas Stuart7c0864d2023-05-02 15:31:09 -070047 * called with {@link Boolean#TRUE}.
48 *
49 * Otherwise, {@link Consumer#accept(Object)} should be called with
50 * {@link Boolean#FALSE}. Telecom will effectively ignore the remote
51 * setActive request and the call will remain in whatever state it is in.
Thomas Stuart6e418b32023-02-06 08:22:08 -080052 */
53 void onSetActive(@NonNull Consumer<Boolean> wasCompleted);
54
55 /**
56 * Telecom is informing the client to set the call inactive. This is the same as holding a call
57 * for two endpoints but can be extended to setting a meeting inactive.
58 *
59 * @param wasCompleted The {@link Consumer} to be completed. If the client can set the call
60 * inactive on their end, the {@link Consumer#accept(Object)} should be
Thomas Stuart7c0864d2023-05-02 15:31:09 -070061 * called with {@link Boolean#TRUE}.
62 *
63 * Otherwise, {@link Consumer#accept(Object)} should be called with
64 * {@link Boolean#FALSE}. Telecom will effectively ignore the remote
65 * setInactive request and the call will remain in whatever state it is in.
Thomas Stuart6e418b32023-02-06 08:22:08 -080066 */
67 void onSetInactive(@NonNull Consumer<Boolean> wasCompleted);
68
69 /**
70 * Telecom is informing the client to answer an incoming call and set it to active.
71 *
Anton Hansson84d6d752023-10-05 09:46:37 +000072 * @param videoState the video state
Thomas Stuart6e418b32023-02-06 08:22:08 -080073 * @param wasCompleted The {@link Consumer} to be completed. If the client can answer the call
74 * on their end, {@link Consumer#accept(Object)} should be called with
Thomas Stuart7c0864d2023-05-02 15:31:09 -070075 * {@link Boolean#TRUE}.
76 *
77 * Otherwise,{@link Consumer#accept(Object)} should be called with
78 * {@link Boolean#FALSE}. However, Telecom will still disconnect
79 * the call and remove it from tracking.
Thomas Stuart6e418b32023-02-06 08:22:08 -080080 */
81 void onAnswer(@android.telecom.CallAttributes.CallType int videoState,
82 @NonNull Consumer<Boolean> wasCompleted);
83
84 /**
Thomas Stuart6e418b32023-02-06 08:22:08 -080085 * Telecom is informing the client to disconnect the call
86 *
Thomas Stuartb6b7e852023-02-06 15:32:35 -080087 * @param disconnectCause represents the cause for disconnecting the call.
88 * @param wasCompleted The {@link Consumer} to be completed. If the client can disconnect
89 * the call on their end, {@link Consumer#accept(Object)} should be
Thomas Stuart7c0864d2023-05-02 15:31:09 -070090 * called with {@link Boolean#TRUE}.
91 *
92 * Otherwise,{@link Consumer#accept(Object)} should be called with
93 * {@link Boolean#FALSE}. However, Telecom will still disconnect
94 * the call and remove it from tracking.
Thomas Stuart6e418b32023-02-06 08:22:08 -080095 */
Thomas Stuartb6b7e852023-02-06 15:32:35 -080096 void onDisconnect(@NonNull DisconnectCause disconnectCause,
97 @NonNull Consumer<Boolean> wasCompleted);
Thomas Stuart6e418b32023-02-06 08:22:08 -080098
99 /**
100 * Telecom is informing the client to set the call in streaming.
101 *
102 * @param wasCompleted The {@link Consumer} to be completed. If the client can stream the
103 * call on their end, {@link Consumer#accept(Object)} should be called with
104 * {@link Boolean#TRUE}. Otherwise, {@link Consumer#accept(Object)}
105 * should be called with {@link Boolean#FALSE}.
106 */
107 void onCallStreamingStarted(@NonNull Consumer<Boolean> wasCompleted);
108}