| Thomas Stuart | 9bfb243 | 2022-09-27 15:02:07 -0700 | [diff] [blame^] | 1 | /* |
| 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 | |
| 17 | package android.telecom; |
| 18 | |
| 19 | |
| 20 | import android.annotation.NonNull; |
| 21 | |
| 22 | import java.util.function.Consumer; |
| 23 | |
| 24 | /** |
| 25 | * CallEventCallback relays updates to a call from the Telecom framework. |
| 26 | * This can include operations which the app must implement on a Call due to the presence of other |
| 27 | * calls on the device, requests relayed from a Bluetooth device, or from another calling surface. |
| 28 | * |
| 29 | * <p> |
| 30 | * CallEventCallbacks with {@link Consumer}s are transactional, meaning that a client must |
| 31 | * complete the {@link Consumer} via {@link Consumer#accept(Object)} in order to complete the |
| 32 | * CallEventCallback. If a CallEventCallback 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 | * CallEventCallback 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 | */ |
| 41 | public interface CallEventCallback { |
| 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 | * update the client on the new {@link CallAudioState} |
| 99 | * |
| 100 | * @param callAudioState that is currently being used |
| 101 | */ |
| 102 | void onCallAudioStateChanged(@NonNull CallAudioState callAudioState); |
| 103 | } |