• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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.stub;
18 
19 import android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.annotation.SystemApi;
23 import android.os.Bundle;
24 import android.os.RemoteException;
25 import android.telephony.ims.ImsUtListener;
26 import android.util.Log;
27 
28 import com.android.ims.internal.IImsUt;
29 import com.android.ims.internal.IImsUtListener;
30 
31 import java.lang.annotation.Retention;
32 import java.lang.annotation.RetentionPolicy;
33 import java.util.Objects;
34 
35 /**
36  * Base implementation of IMS UT interface, which implements stubs. Override these methods to
37  * implement functionality.
38  *
39  * @hide
40  */
41 // DO NOT remove or change the existing APIs, only add new ones to this Base implementation or you
42 // will break other implementations of ImsUt maintained by other ImsServices.
43 @SystemApi
44 public class ImsUtImplBase {
45     private static final String TAG = "ImsUtImplBase";
46     /**
47      * Bar all incoming calls. (See 3GPP TS 24.611)
48      * @hide
49      */
50     public static final int CALL_BARRING_ALL_INCOMING = 1;
51 
52     /**
53      * Bar all outgoing calls. (See 3GPP TS 24.611)
54      * @hide
55      */
56     public static final int CALL_BARRING_ALL_OUTGOING = 2;
57 
58     /**
59      * Bar all outgoing international calls. (See 3GPP TS 24.611)
60      * @hide
61      */
62     public static final int CALL_BARRING_OUTGOING_INTL = 3;
63 
64     /**
65      * Bar all outgoing international calls, excluding those to the home PLMN country
66      * (See 3GPP TS 24.611)
67      * @hide
68      */
69     public static final int CALL_BARRING_OUTGOING_INTL_EXCL_HOME = 4;
70 
71     /**
72      * Bar all incoming calls when roaming (See 3GPP TS 24.611)
73      * @hide
74      */
75     public static final int CALL_BLOCKING_INCOMING_WHEN_ROAMING = 5;
76 
77     /**
78      * Enable Anonymous Communication Rejection (See 3GPP TS 24.611)
79      * @hide
80      */
81     public static final int CALL_BARRING_ANONYMOUS_INCOMING = 6;
82 
83     /**
84      * Bar all incoming and outgoing calls. (See 3GPP TS 24.611)
85      * @hide
86      */
87     public static final int CALL_BARRING_ALL = 7;
88 
89     /**
90      * Bar all outgoing service requests, including calls. (See 3GPP TS 24.611)
91      * @hide
92      */
93     public static final int CALL_BARRING_OUTGOING_ALL_SERVICES = 8;
94 
95     /**
96      * Bar all incoming service requests, including calls. (See 3GPP TS 24.611)
97      * @hide
98      */
99     public static final int CALL_BARRING_INCOMING_ALL_SERVICES = 9;
100 
101     /**
102      * Bar specific incoming calls. (See 3GPP TS 24.611)
103      * @hide
104      */
105     public static final int CALL_BARRING_SPECIFIC_INCOMING_CALLS = 10;
106 
107     /** @hide */
108     @Retention(RetentionPolicy.SOURCE)
109     @IntDef(prefix = "CALL_BARRING_", value = {CALL_BARRING_ALL_INCOMING, CALL_BARRING_ALL_OUTGOING,
110             CALL_BARRING_OUTGOING_INTL, CALL_BARRING_OUTGOING_INTL_EXCL_HOME,
111             CALL_BLOCKING_INCOMING_WHEN_ROAMING, CALL_BARRING_ANONYMOUS_INCOMING,
112             CALL_BARRING_ALL, CALL_BARRING_OUTGOING_ALL_SERVICES,
113             CALL_BARRING_INCOMING_ALL_SERVICES, CALL_BARRING_SPECIFIC_INCOMING_CALLS})
114     public @interface CallBarringMode {}
115 
116     /**
117      * Constant used to denote an invalid return value.
118      * @hide
119      */
120     public static final int INVALID_RESULT = -1;
121 
122     private final IImsUt.Stub mServiceImpl = new IImsUt.Stub() {
123         private final Object mLock = new Object();
124         private ImsUtListener mUtListener;
125 
126         @Override
127         public void close() throws RemoteException {
128             ImsUtImplBase.this.close();
129         }
130 
131         @Override
132         public int queryCallBarring(int cbType) throws RemoteException {
133             return ImsUtImplBase.this.queryCallBarring(cbType);
134         }
135 
136         @Override
137         public int queryCallForward(int condition, String number) throws RemoteException {
138             return ImsUtImplBase.this.queryCallForward(condition, number);
139         }
140 
141         @Override
142         public int queryCallWaiting() throws RemoteException {
143             return ImsUtImplBase.this.queryCallWaiting();
144         }
145 
146         @Override
147         public int queryCLIR() throws RemoteException {
148             return ImsUtImplBase.this.queryCLIR();
149         }
150 
151         @Override
152         public int queryCLIP() throws RemoteException {
153             return ImsUtImplBase.this.queryCLIP();
154         }
155 
156         @Override
157         public int queryCOLR() throws RemoteException {
158             return ImsUtImplBase.this.queryCOLR();
159         }
160 
161         @Override
162         public int queryCOLP() throws RemoteException {
163             return ImsUtImplBase.this.queryCOLP();
164         }
165 
166         @Override
167         public int transact(Bundle ssInfo) throws RemoteException {
168             return ImsUtImplBase.this.transact(ssInfo);
169         }
170 
171         @Override
172         public int updateCallBarring(int cbType, int action, String[] barrList) throws
173                 RemoteException {
174             return ImsUtImplBase.this.updateCallBarring(cbType, action, barrList);
175         }
176 
177         @Override
178         public int updateCallForward(int action, int condition, String number, int serviceClass,
179                 int timeSeconds) throws RemoteException {
180             return ImsUtImplBase.this.updateCallForward(action, condition, number, serviceClass,
181                     timeSeconds);
182         }
183 
184         @Override
185         public int updateCallWaiting(boolean enable, int serviceClass) throws RemoteException {
186             return ImsUtImplBase.this.updateCallWaiting(enable, serviceClass);
187         }
188 
189         @Override
190         public int updateCLIR(int clirMode) throws RemoteException {
191             return ImsUtImplBase.this.updateCLIR(clirMode);
192         }
193 
194         @Override
195         public int updateCLIP(boolean enable) throws RemoteException {
196             return ImsUtImplBase.this.updateCLIP(enable);
197         }
198 
199         @Override
200         public int updateCOLR(int presentation) throws RemoteException {
201             return ImsUtImplBase.this.updateCOLR(presentation);
202         }
203 
204         @Override
205         public int updateCOLP(boolean enable) throws RemoteException {
206             return ImsUtImplBase.this.updateCOLP(enable);
207         }
208 
209         @Override
210         public void setListener(IImsUtListener listener) throws RemoteException {
211             synchronized (mLock) {
212                 if (mUtListener != null
213                         && !mUtListener.getListenerInterface().asBinder().isBinderAlive()) {
214                     Log.w(TAG, "setListener: discarding dead Binder");
215                     mUtListener = null;
216                 }
217                 if (mUtListener != null && listener != null && Objects.equals(
218                         mUtListener.getListenerInterface().asBinder(), listener.asBinder())) {
219                     return;
220                 }
221 
222                 if (listener == null) {
223                     mUtListener = null;
224                 } else if (listener != null && mUtListener == null) {
225                     mUtListener = new ImsUtListener(listener);
226                 } else {
227                     // Warn that the listener is being replaced while active
228                     Log.w(TAG, "setListener is being called when there is already an active "
229                             + "listener");
230                     mUtListener = new ImsUtListener(listener);
231                 }
232             }
233 
234             ImsUtImplBase.this.setListener(mUtListener);
235         }
236 
237         @Override
238         public int queryCallBarringForServiceClass(int cbType, int serviceClass)
239                 throws RemoteException {
240             return ImsUtImplBase.this.queryCallBarringForServiceClass(cbType, serviceClass);
241         }
242 
243         @Override
244         public int updateCallBarringForServiceClass(int cbType, int action,
245                 String[] barrList, int serviceClass) throws RemoteException {
246             return ImsUtImplBase.this.updateCallBarringForServiceClass(
247                     cbType, action, barrList, serviceClass);
248         }
249 
250         @Override
251         public int updateCallBarringWithPassword(int cbType, int action, String[] barrList,
252                 int serviceClass, String password) throws RemoteException {
253             return ImsUtImplBase.this.updateCallBarringWithPassword(
254                     cbType, action, barrList, serviceClass, password);
255         }
256     };
257 
258     /**
259      * Called when the framework no longer needs to interact with the IMS UT implementation any
260      * longer.
261      */
close()262     public void close() {
263 
264     }
265 
266     /**
267      * Retrieves the call barring configuration.
268      * @param cbType
269      */
queryCallBarring(int cbType)270     public int queryCallBarring(int cbType) {
271         return -1;
272     }
273 
274     /**
275      * Retrieves the configuration of the call barring for specified service class.
276      */
queryCallBarringForServiceClass(int cbType, int serviceClass)277     public int queryCallBarringForServiceClass(int cbType, int serviceClass) {
278         return -1;
279     }
280 
281     /**
282      * Retrieves the configuration of the call forward.
283      */
queryCallForward(int condition, String number)284     public int queryCallForward(int condition, String number) {
285         return -1;
286     }
287 
288     /**
289      * Retrieves the configuration of the call waiting.
290      */
queryCallWaiting()291     public int queryCallWaiting() {
292         return -1;
293     }
294 
295     /**
296      * Retrieves the default CLIR setting.
297      * @hide
298      */
queryCLIR()299     public int queryCLIR() {
300         return queryClir();
301     }
302 
303     /**
304      * Retrieves the CLIP call setting.
305      * @hide
306      */
queryCLIP()307     public int queryCLIP() {
308         return queryClip();
309     }
310 
311     /**
312      * Retrieves the COLR call setting.
313      * @hide
314      */
queryCOLR()315     public int queryCOLR() {
316         return queryColr();
317     }
318 
319     /**
320      * Retrieves the COLP call setting.
321      * @hide
322      */
queryCOLP()323     public int queryCOLP() {
324         return queryColp();
325     }
326 
327     /**
328      * Retrieves the default CLIR setting.
329      */
queryClir()330     public int queryClir() {
331         return -1;
332     }
333 
334     /**
335      * Retrieves the CLIP call setting.
336      */
queryClip()337     public int queryClip() {
338         return -1;
339     }
340 
341     /**
342      * Retrieves the COLR call setting.
343      */
queryColr()344     public int queryColr() {
345         return -1;
346     }
347 
348     /**
349      * Retrieves the COLP call setting.
350      */
queryColp()351     public int queryColp() {
352         return -1;
353     }
354 
355     /**
356      * Updates or retrieves the supplementary service configuration.
357      */
transact(Bundle ssInfo)358     public int transact(Bundle ssInfo) {
359         return -1;
360     }
361 
362     /**
363      * Updates the configuration of the call barring.
364      */
updateCallBarring(@allBarringMode int cbType, int action, String[] barrList)365     public int updateCallBarring(@CallBarringMode int cbType, int action, String[] barrList) {
366         return -1;
367     }
368 
369     /**
370      * Updates the configuration of the call barring for specified service class.
371      */
updateCallBarringForServiceClass(@allBarringMode int cbType, int action, String[] barrList, int serviceClass)372     public int updateCallBarringForServiceClass(@CallBarringMode int cbType, int action,
373             String[] barrList, int serviceClass) {
374         return -1;
375     }
376 
377     /**
378      * Updates the configuration of the call barring for specified service class with password.
379      * @hide
380      */
updateCallBarringWithPassword(int cbType, int action, @Nullable String[] barrList, int serviceClass, @NonNull String password)381     public int updateCallBarringWithPassword(int cbType, int action, @Nullable String[] barrList,
382             int serviceClass, @NonNull String password) {
383         return -1;
384     }
385 
386     /**
387      * Updates the configuration of the call forward.
388      */
updateCallForward(int action, int condition, String number, int serviceClass, int timeSeconds)389     public int updateCallForward(int action, int condition, String number, int serviceClass,
390             int timeSeconds) {
391         return 0;
392     }
393 
394     /**
395      * Updates the configuration of the call waiting.
396      */
updateCallWaiting(boolean enable, int serviceClass)397     public int updateCallWaiting(boolean enable, int serviceClass) {
398         return -1;
399     }
400 
401     /**
402      * Updates the configuration of the CLIR supplementary service.
403      * @hide
404      */
updateCLIR(int clirMode)405     public int updateCLIR(int clirMode) {
406         return updateClir(clirMode);
407     }
408 
409     /**
410      * Updates the configuration of the CLIP supplementary service.
411      * @hide
412      */
updateCLIP(boolean enable)413     public int updateCLIP(boolean enable) {
414         return updateClip(enable);
415     }
416 
417     /**
418      * Updates the configuration of the COLR supplementary service.
419      * @hide
420      */
updateCOLR(int presentation)421     public int updateCOLR(int presentation) {
422         return updateColr(presentation);
423     }
424 
425     /**
426      * Updates the configuration of the COLP supplementary service.
427      * @hide
428      */
updateCOLP(boolean enable)429     public int updateCOLP(boolean enable) {
430         return updateColp(enable);
431     }
432 
433     /**
434      * Updates the configuration of the CLIR supplementary service.
435      */
updateClir(int clirMode)436     public int updateClir(int clirMode) {
437         return -1;
438     }
439 
440     /**
441      * Updates the configuration of the CLIP supplementary service.
442      */
updateClip(boolean enable)443     public int updateClip(boolean enable) {
444         return -1;
445     }
446 
447     /**
448      * Updates the configuration of the COLR supplementary service.
449      */
updateColr(int presentation)450     public int updateColr(int presentation) {
451         return -1;
452     }
453 
454     /**
455      * Updates the configuration of the COLP supplementary service.
456      */
updateColp(boolean enable)457     public int updateColp(boolean enable) {
458         return -1;
459     }
460 
461     /**
462      * Sets the listener.
463      */
setListener(ImsUtListener listener)464     public void setListener(ImsUtListener listener) {
465     }
466 
467     /**
468      * @hide
469      */
getInterface()470     public IImsUt getInterface() {
471         return mServiceImpl;
472     }
473 }
474