• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 HIMSA II K/S - www.himsa.com.
3  * Represented by EHIMA - www.ehima.com
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 package com.android.bluetooth.tbs;
19 
20 import android.bluetooth.BluetoothLeCall;
21 import android.bluetooth.BluetoothLeCallControl;
22 import android.bluetooth.BluetoothManager;
23 import android.bluetooth.BluetoothProfile;
24 import android.content.Context;
25 
26 import java.util.List;
27 import java.util.UUID;
28 import java.util.concurrent.Executor;
29 
30 /*
31  * A proxy class that facilitates testing of the BluetoothInCallService class.
32  *
33  * This is necessary due to the "final" attribute of the BluetoothLeCallControl class. In order to test the
34  * correct functioning of the BluetoothInCallService class, the final class must be put into a
35  * container that can be mocked correctly.
36  */
37 public class BluetoothLeCallControlProxy {
38 
39     private BluetoothLeCallControl mBluetoothLeCallControl;
40 
41     public static final int BEARER_TECHNOLOGY_3G = 0x01;
42     public static final int BEARER_TECHNOLOGY_4G = 0x02;
43     public static final int BEARER_TECHNOLOGY_LTE = 0x03;
44     public static final int BEARER_TECHNOLOGY_WIFI = 0x04;
45     public static final int BEARER_TECHNOLOGY_5G = 0x05;
46     public static final int BEARER_TECHNOLOGY_GSM = 0x06;
47     public static final int BEARER_TECHNOLOGY_CDMA = 0x07;
48     public static final int BEARER_TECHNOLOGY_2G = 0x08;
49     public static final int BEARER_TECHNOLOGY_WCDMA = 0x09;
50 
BluetoothLeCallControlProxy(BluetoothLeCallControl tbs)51     public BluetoothLeCallControlProxy(BluetoothLeCallControl tbs) {
52         mBluetoothLeCallControl = tbs;
53     }
54 
closeBluetoothLeCallControlProxy(Context context)55     public void closeBluetoothLeCallControlProxy(Context context) {
56         final BluetoothManager btManager =
57                 context.getSystemService(BluetoothManager.class);
58         if (btManager != null) {
59             btManager.getAdapter().closeProfileProxy(BluetoothProfile.LE_CALL_CONTROL,
60                     mBluetoothLeCallControl);
61         }
62     }
63 
registerBearer(String uci, List<String> uriSchemes, int featureFlags, String provider, int technology, Executor executor, BluetoothLeCallControl.Callback callback)64     public boolean registerBearer(String uci, List<String> uriSchemes, int featureFlags,
65             String provider, int technology, Executor executor, BluetoothLeCallControl.Callback callback) {
66         return mBluetoothLeCallControl.registerBearer(uci, uriSchemes, featureFlags, provider, technology,
67                 executor, callback);
68     }
69 
unregisterBearer()70     public void unregisterBearer() {
71         mBluetoothLeCallControl.unregisterBearer();
72     }
73 
getContentControlId()74     public int getContentControlId() {
75         return mBluetoothLeCallControl.getContentControlId();
76     }
77 
requestResult(int requestId, int result)78     public void requestResult(int requestId, int result) {
79         mBluetoothLeCallControl.requestResult(requestId, result);
80     }
81 
onCallAdded(BluetoothLeCall call)82     public void onCallAdded(BluetoothLeCall call) {
83         mBluetoothLeCallControl.onCallAdded(call);
84     }
85 
onCallRemoved(UUID callId, int reason)86     public void onCallRemoved(UUID callId, int reason) {
87         mBluetoothLeCallControl.onCallRemoved(callId, reason);
88     }
89 
onCallStateChanged(UUID callId, int state)90     public void onCallStateChanged(UUID callId, int state) {
91         mBluetoothLeCallControl.onCallStateChanged(callId, state);
92     }
93 
currentCallsList(List<BluetoothLeCall> calls)94     public void currentCallsList(List<BluetoothLeCall> calls) {
95         mBluetoothLeCallControl.currentCallsList(calls);
96     }
97 
networkStateChanged(String providerName, int technology)98     public void networkStateChanged(String providerName, int technology) {
99         mBluetoothLeCallControl.networkStateChanged(providerName, technology);
100     }
101 }
102