1 /*
2  * Copyright (C) 2024 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 com.android.server.telecom;
18 
19 /**
20  * Any android.telecom.Call service (e.g. ConnectionService, TransactionalService) that declares
21  * a {@link CallSourceService} should implement this interface in order to cache the callback.
22  * The callback will be executed once the service is set.
23  */
24 public interface CachedCallback {
25     /**
26      * This method executes the callback that was cached because the service was not available
27      * at the time the callback was ready.
28      *
29      * @param service that was recently set (e.g. ConnectionService)
30      * @param call    that had a null service at the time the callback was ready. The service is now
31      *                non-null in the call and can be executed/
32      */
executeCallback(CallSourceService service, Call call)33     void executeCallback(CallSourceService service, Call call);
34 
35     /**
36      * This method is helpful for caching the callbacks.  If the callback is called multiple times
37      * while the service is not set, ONLY the last callback should be sent to the client since the
38      * last callback is the most relevant
39      *
40      * @return the callback id that is used in a map to only store the last callback value
41      */
getCallbackId()42     String getCallbackId();
43 }
44