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.ims;
18 
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21 import android.annotation.TestApi;
22 import android.os.Bundle;
23 import android.os.RemoteException;
24 import android.telephony.ims.stub.ImsUtImplBase;
25 import android.util.Log;
26 
27 import com.android.ims.internal.IImsUtListener;
28 
29 /**
30  * Listener interface used to receive network responses back from UT supplementary service queries
31  * made by the framework.
32  * @hide
33  */
34 // DO NOT remove or change the existing APIs, only add new ones to this Base implementation or you
35 // will break other implementations of ImsUt maintained by other ImsServices.
36 @SystemApi
37 @TestApi
38 public class ImsUtListener {
39 
40     /**
41      * The {@link Bundle} key for a Calling Line Identification Restriction (CLIR) response. The
42      * value will be an int[] with two values:
43      * int[0] contains the 'n' parameter from TS 27.007 7.7, which is the
44      * outgoing CLIR state. See {@link ImsSsInfo#CLIR_OUTGOING_DEFAULT},
45      * {@link ImsSsInfo#CLIR_OUTGOING_INVOCATION}, and {@link ImsSsInfo#CLIR_OUTGOING_SUPPRESSION};
46      * int[1] contains the 'm' parameter from TS 27.007 7.7, which is the CLIR interrogation status.
47      * See {@link ImsSsInfo#CLIR_STATUS_NOT_PROVISIONED},
48      * {@link ImsSsInfo#CLIR_STATUS_PROVISIONED_PERMANENT}, {@link ImsSsInfo#CLIR_STATUS_UNKNOWN},
49      * {@link ImsSsInfo#CLIR_STATUS_TEMPORARILY_RESTRICTED}, and
50      * {@link ImsSsInfo#CLIR_STATUS_TEMPORARILY_ALLOWED}.
51      * @deprecated Use {@link #onLineIdentificationSupplementaryServiceResponse(int, ImsSsInfo)}
52      * instead, this key has been added for backwards compatibility with older proprietary
53      * implementations only and is being phased out.
54      */
55     @Deprecated
56     public static final String BUNDLE_KEY_CLIR = "queryClir";
57 
58     /**
59      * The {@link Bundle} key for a Calling Line Identification Presentation (CLIP), Connected Line
60      * Identification Presentation (COLP), or Connected Line Identification Restriction (COLR)
61      * response. The value will be an instance of {@link ImsSsInfo}, which contains the response to
62      * the query.
63      * @deprecated Use {@link #onLineIdentificationSupplementaryServiceResponse(int, ImsSsInfo)}
64      * instead, this key has been added for backwards compatibility with older proprietary
65      * implementations only and is being phased out.
66      */
67     @Deprecated
68     public static final String BUNDLE_KEY_SSINFO = "imsSsInfo";
69 
70     private IImsUtListener mServiceInterface;
71     private static final String LOG_TAG = "ImsUtListener";
72 
onUtConfigurationUpdated(int id)73     public void onUtConfigurationUpdated(int id) {
74         try {
75             mServiceInterface.utConfigurationUpdated(null, id);
76         } catch (RemoteException e) {
77             Log.w(LOG_TAG, "utConfigurationUpdated: remote exception");
78         }
79     }
80 
onUtConfigurationUpdateFailed(int id, ImsReasonInfo error)81     public void onUtConfigurationUpdateFailed(int id, ImsReasonInfo error) {
82         try {
83             mServiceInterface.utConfigurationUpdateFailed(null, id, error);
84         } catch (RemoteException e) {
85             Log.w(LOG_TAG, "utConfigurationUpdateFailed: remote exception");
86         }
87     }
88 
89     /**
90      * Notify the framework of a UT configuration response to a {@link ImsUtImplBase#queryClir()},
91      * {@link ImsUtImplBase#queryClip()}, {@link ImsUtImplBase#queryColp()}, or
92      * {@link ImsUtImplBase#queryColr()} query for the transaction ID specified. If the query fails,
93      * {@link #onUtConfigurationQueryFailed(int, ImsReasonInfo)} should be called.
94      * @param id The ID associated with this UT configuration transaction from the framework.
95      * @param configuration A {@link Bundle} containing the result of querying the UT configuration.
96      *                      Must contain {@link #BUNDLE_KEY_CLIR} if it is a response to
97      *                      {@link ImsUtImplBase#queryClir()} or
98      *                      {@link #BUNDLE_KEY_SSINFO} if it is a response to
99      *                      {@link ImsUtImplBase#queryClip()}, {@link ImsUtImplBase#queryColp()}, or
100      *                      {@link ImsUtImplBase#queryColr()}.
101      * @deprecated Use {@link #onLineIdentificationSupplementaryServiceResponse(int, ImsSsInfo)}
102      * instead.
103      */
104     @Deprecated
onUtConfigurationQueried(int id, Bundle configuration)105     public void onUtConfigurationQueried(int id, Bundle configuration) {
106         try {
107             mServiceInterface.utConfigurationQueried(null, id, configuration);
108         } catch (RemoteException e) {
109             Log.w(LOG_TAG, "utConfigurationQueried: remote exception");
110         }
111     }
112 
113     /**
114      * Notify the framework of a UT configuration response to a {@link ImsUtImplBase#queryClir()},
115      * {@link ImsUtImplBase#queryClip()}, {@link ImsUtImplBase#queryColp()}, or
116      * {@link ImsUtImplBase#queryColr()} query for the transaction ID specified. If the query fails,
117      * the framework should be notified via
118      * {@link #onUtConfigurationQueryFailed(int, ImsReasonInfo)}.
119      * @param id The ID associated with this UT configuration transaction from the framework.
120      * @param configuration An {@link ImsSsInfo} instance containing the configuration for the
121      *                      line identification supplementary service queried.
122      */
onLineIdentificationSupplementaryServiceResponse(int id, @NonNull ImsSsInfo configuration)123     public void onLineIdentificationSupplementaryServiceResponse(int id,
124             @NonNull ImsSsInfo configuration) {
125         try {
126             mServiceInterface.lineIdentificationSupplementaryServiceResponse(id, configuration);
127         } catch (RemoteException e) {
128             e.rethrowFromSystemServer();
129         }
130     }
131 
132     /**
133      * Notify the Framework of the line identification query failure.
134      * @param id The ID associated with the UT query transaction.
135      * @param error The query failure reason.
136      */
onUtConfigurationQueryFailed(int id, ImsReasonInfo error)137     public void onUtConfigurationQueryFailed(int id, ImsReasonInfo error) {
138         try {
139             mServiceInterface.utConfigurationQueryFailed(null, id, error);
140         } catch (RemoteException e) {
141             Log.w(LOG_TAG, "utConfigurationQueryFailed: remote exception");
142         }
143     }
144 
onUtConfigurationCallBarringQueried(int id, ImsSsInfo[] cbInfo)145     public void onUtConfigurationCallBarringQueried(int id, ImsSsInfo[] cbInfo) {
146         try {
147             mServiceInterface.utConfigurationCallBarringQueried(null, id, cbInfo);
148         } catch (RemoteException e) {
149             Log.w(LOG_TAG, "utConfigurationCallBarringQueried: remote exception");
150         }
151     }
152 
onUtConfigurationCallForwardQueried(int id, ImsCallForwardInfo[] cfInfo)153     public void onUtConfigurationCallForwardQueried(int id, ImsCallForwardInfo[] cfInfo) {
154         try {
155             mServiceInterface.utConfigurationCallForwardQueried(null, id, cfInfo);
156         } catch (RemoteException e) {
157             Log.w(LOG_TAG, "utConfigurationCallForwardQueried: remote exception");
158         }
159     }
160 
onUtConfigurationCallWaitingQueried(int id, ImsSsInfo[] cwInfo)161     public void onUtConfigurationCallWaitingQueried(int id, ImsSsInfo[] cwInfo) {
162         try {
163             mServiceInterface.utConfigurationCallWaitingQueried(null, id, cwInfo);
164         } catch (RemoteException e) {
165             Log.w(LOG_TAG, "utConfigurationCallWaitingQueried: remote exception");
166         }
167     }
168 
onSupplementaryServiceIndication(ImsSsData ssData)169     public void onSupplementaryServiceIndication(ImsSsData ssData) {
170         try {
171             mServiceInterface.onSupplementaryServiceIndication(ssData);
172         } catch (RemoteException e) {
173             Log.w(LOG_TAG, "onSupplementaryServiceIndication: remote exception");
174         }
175     }
176 
177     /**
178      * @hide
179      */
ImsUtListener(IImsUtListener serviceInterface)180     public ImsUtListener(IImsUtListener serviceInterface) {
181         mServiceInterface = serviceInterface;
182     }
183 }
184