1 /*
2  * Copyright (C) 2018 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.telephony.mbms;
18 
19 import android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.content.Context;
23 import android.telephony.MbmsGroupCallSession;
24 
25 import java.lang.annotation.Retention;
26 import java.lang.annotation.RetentionPolicy;
27 import java.util.List;
28 import java.util.concurrent.Executor;
29 
30 /**
31  * A callback class that is used to receive information from the middleware on MBMS group-call
32  * services. An instance of this object should be passed into
33  * {@link MbmsGroupCallSession#create(Context, int, Executor, MbmsGroupCallSessionCallback)}.
34  */
35 public interface MbmsGroupCallSessionCallback {
36     /** @hide */
37     @Retention(RetentionPolicy.SOURCE)
38     @IntDef(value = {
39             MbmsErrors.ERROR_NO_UNIQUE_MIDDLEWARE,
40             MbmsErrors.ERROR_MIDDLEWARE_LOST,
41             MbmsErrors.ERROR_MIDDLEWARE_NOT_BOUND,
42             MbmsErrors.InitializationErrors.ERROR_APP_PERMISSIONS_NOT_GRANTED,
43             MbmsErrors.InitializationErrors.ERROR_DUPLICATE_INITIALIZE,
44             MbmsErrors.InitializationErrors.ERROR_UNABLE_TO_INITIALIZE,
45             MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_NOT_YET_READY,
46             MbmsErrors.GeneralErrors.ERROR_OUT_OF_MEMORY,
47             MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_TEMPORARILY_UNAVAILABLE,
48             MbmsErrors.GeneralErrors.ERROR_IN_E911,
49             MbmsErrors.GeneralErrors.ERROR_NOT_CONNECTED_TO_HOME_CARRIER_LTE,
50             MbmsErrors.GeneralErrors.ERROR_UNABLE_TO_READ_SIM,
51             MbmsErrors.GeneralErrors.ERROR_CARRIER_CHANGE_NOT_ALLOWED}, prefix = { "ERROR_" })
52     @interface GroupCallError{}
53 
54     /**
55      * Called by the middleware when it has detected an error condition. The possible error codes
56      * are listed in {@link MbmsErrors}.
57      * @param errorCode The error code.
58      * @param message A human-readable message generated by the middleware for debugging purposes.
59      */
onError(@roupCallError int errorCode, @Nullable String message)60     default void onError(@GroupCallError int errorCode, @Nullable String message) {}
61 
62     /**
63      * Indicates that the list of currently available SAIs has been updated. The app may use this
64      * information to filter the list of group calls when displaying available group calls to
65      * the user by matching the SAIs with a list of group calls separately negotiated with the
66      * carrier. The app may also report the aggregate list of SAIs to the group call application
67      * server so that a network entity can determine when, and where to activate the broadcast of
68      * particular group calls.
69      * @param currentSais The available SAIs on the current cell.
70      * @param availableSais A list of lists of available SAIS in neighboring cells, where each list
71      *                      contains the available SAIs in an individual cell.
72      */
onAvailableSaisUpdated(@onNull List<Integer> currentSais, @NonNull List<List<Integer>> availableSais)73     default void onAvailableSaisUpdated(@NonNull List<Integer> currentSais,
74             @NonNull List<List<Integer>> availableSais) {}
75 
76     /**
77      * Called soon after the app calls {@link MbmsGroupCallSession#create}. The information supplied
78      * via this callback may be used to establish a data-link interface with the modem.
79      *
80      * In order to establish the data-link interface, the multicast IP and port must be obtained
81      * out-of-band from the carrier. A {@link java.net.MulticastSocket} may then be constructed
82      * using a {@link java.net.NetworkInterface} with the name and interface supplied by this
83      * callback.
84      *
85      * @param interfaceName The interface name for the data link.
86      * @param index The index for the data link.
87      */
onServiceInterfaceAvailable(@onNull String interfaceName, int index)88     default void onServiceInterfaceAvailable(@NonNull String interfaceName, int index) {}
89 
90     /**
91      * Called to indicate that the middleware has been initialized and is ready.
92      *
93      * Before this method is called, calling any method on an instance of
94      * {@link MbmsGroupCallSession} will result in an {@link IllegalStateException} or an error
95      * delivered via {@link #onError(int, String)} with error code
96      * {@link MbmsErrors.GeneralErrors#ERROR_MIDDLEWARE_NOT_YET_READY}.
97      */
onMiddlewareReady()98     default void onMiddlewareReady() {}
99 }
100