blob: aadf3370597cc23f8d2778e21e02bff119bbeb01 [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 /**
78 * Telecom is informing the client to reject the incoming call
79 *
80 * @param wasCompleted The {@link Consumer} to be completed. If the client can reject the
81 * incoming call, {@link Consumer#accept(Object)} should be called with
82 * {@link Boolean#TRUE}. Otherwise, {@link Consumer#accept(Object)}
83 * should be called with {@link Boolean#FALSE}.
84 */
85 void onReject(@NonNull Consumer<Boolean> wasCompleted);
86
87 /**
88 * Telecom is informing the client to disconnect the call
89 *
90 * @param wasCompleted The {@link Consumer} to be completed. If the client can disconnect the
91 * call on their end, {@link Consumer#accept(Object)} should be called with
92 * {@link Boolean#TRUE}. Otherwise, {@link Consumer#accept(Object)}
93 * should be called with {@link Boolean#FALSE}.
94 */
95 void onDisconnect(@NonNull Consumer<Boolean> wasCompleted);
96
97 /**
98 * Telecom is informing the client to set the call in streaming.
99 *
100 * @param wasCompleted The {@link Consumer} to be completed. If the client can stream the
101 * call on their end, {@link Consumer#accept(Object)} should be called with
102 * {@link Boolean#TRUE}. Otherwise, {@link Consumer#accept(Object)}
103 * should be called with {@link Boolean#FALSE}.
104 */
105 void onCallStreamingStarted(@NonNull Consumer<Boolean> wasCompleted);
106}