blob: 35e2fd43efdd7eb110e3e66b0cb1ef3ec170d7d9 [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
47 * called with {@link Boolean#TRUE}. Otherwise,
48 * {@link Consumer#accept(Object)} should be called with
49 * {@link Boolean#FALSE}.
50 */
51 void onSetActive(@NonNull Consumer<Boolean> wasCompleted);
52
53 /**
54 * Telecom is informing the client to set the call inactive. This is the same as holding a call
55 * for two endpoints but can be extended to setting a meeting inactive.
56 *
57 * @param wasCompleted The {@link Consumer} to be completed. If the client can set the call
58 * inactive on their end, the {@link Consumer#accept(Object)} should be
59 * called with {@link Boolean#TRUE}. Otherwise,
60 * {@link Consumer#accept(Object)} should be called with
61 * {@link Boolean#FALSE}.
62 */
63 void onSetInactive(@NonNull Consumer<Boolean> wasCompleted);
64
65 /**
66 * Telecom is informing the client to answer an incoming call and set it to active.
67 *
68 * @param videoState see {@link android.telecom.CallAttributes.CallType} for valid states
69 * @param wasCompleted The {@link Consumer} to be completed. If the client can answer the call
70 * on their end, {@link Consumer#accept(Object)} should be called with
71 * {@link Boolean#TRUE}. Otherwise, {@link Consumer#accept(Object)} should
72 * be called with {@link Boolean#FALSE}.
73 */
74 void onAnswer(@android.telecom.CallAttributes.CallType int videoState,
75 @NonNull Consumer<Boolean> wasCompleted);
76
77 /**
Thomas Stuart6e418b32023-02-06 08:22:08 -080078 * Telecom is informing the client to disconnect the call
79 *
Thomas Stuartb6b7e852023-02-06 15:32:35 -080080 * @param disconnectCause represents the cause for disconnecting the call.
81 * @param wasCompleted The {@link Consumer} to be completed. If the client can disconnect
82 * the call on their end, {@link Consumer#accept(Object)} should be
83 * called with {@link Boolean#TRUE}. Otherwise,
84 * {@link Consumer#accept(Object)} should be called with
85 * {@link Boolean#FALSE}.
Thomas Stuart6e418b32023-02-06 08:22:08 -080086 */
Thomas Stuartb6b7e852023-02-06 15:32:35 -080087 void onDisconnect(@NonNull DisconnectCause disconnectCause,
88 @NonNull Consumer<Boolean> wasCompleted);
Thomas Stuart6e418b32023-02-06 08:22:08 -080089
90 /**
91 * Telecom is informing the client to set the call in streaming.
92 *
93 * @param wasCompleted The {@link Consumer} to be completed. If the client can stream the
94 * call on their end, {@link Consumer#accept(Object)} should be called with
95 * {@link Boolean#TRUE}. Otherwise, {@link Consumer#accept(Object)}
96 * should be called with {@link Boolean#FALSE}.
97 */
98 void onCallStreamingStarted(@NonNull Consumer<Boolean> wasCompleted);
99}