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.annotation.SuppressLint; 21 import android.bluetooth.BluetoothAdapter; 22 import android.bluetooth.BluetoothLeCall; 23 import android.bluetooth.BluetoothLeCallControl; 24 import android.bluetooth.BluetoothProfile; 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 @SuppressLint("AndroidFrameworkRequiresPermission") // TODO: b/350563786 38 public class BluetoothLeCallControlProxy { 39 40 private final BluetoothLeCallControl mBluetoothLeCallControl; 41 42 public static final int BEARER_TECHNOLOGY_3G = 0x01; 43 public static final int BEARER_TECHNOLOGY_4G = 0x02; 44 public static final int BEARER_TECHNOLOGY_LTE = 0x03; 45 public static final int BEARER_TECHNOLOGY_WIFI = 0x04; 46 public static final int BEARER_TECHNOLOGY_5G = 0x05; 47 public static final int BEARER_TECHNOLOGY_GSM = 0x06; 48 public static final int BEARER_TECHNOLOGY_CDMA = 0x07; 49 public static final int BEARER_TECHNOLOGY_2G = 0x08; 50 public static final int BEARER_TECHNOLOGY_WCDMA = 0x09; 51 BluetoothLeCallControlProxy(BluetoothLeCallControl tbs)52 public BluetoothLeCallControlProxy(BluetoothLeCallControl tbs) { 53 mBluetoothLeCallControl = tbs; 54 } 55 closeBluetoothLeCallControlProxy(BluetoothAdapter adapter)56 public void closeBluetoothLeCallControlProxy(BluetoothAdapter adapter) { 57 adapter.closeProfileProxy(BluetoothProfile.LE_CALL_CONTROL, mBluetoothLeCallControl); 58 } 59 registerBearer( String uci, List<String> uriSchemes, int featureFlags, String provider, int technology, Executor executor, BluetoothLeCallControl.Callback callback)60 public boolean registerBearer( 61 String uci, 62 List<String> uriSchemes, 63 int featureFlags, 64 String provider, 65 int technology, 66 Executor executor, 67 BluetoothLeCallControl.Callback callback) { 68 return mBluetoothLeCallControl.registerBearer( 69 uci, uriSchemes, featureFlags, provider, technology, executor, callback); 70 } 71 unregisterBearer()72 public void unregisterBearer() { 73 mBluetoothLeCallControl.unregisterBearer(); 74 } 75 requestResult(int requestId, int result)76 public void requestResult(int requestId, int result) { 77 mBluetoothLeCallControl.requestResult(requestId, result); 78 } 79 onCallAdded(BluetoothLeCall call)80 public void onCallAdded(BluetoothLeCall call) { 81 mBluetoothLeCallControl.onCallAdded(call); 82 } 83 onCallRemoved(UUID callId, int reason)84 public void onCallRemoved(UUID callId, int reason) { 85 mBluetoothLeCallControl.onCallRemoved(callId, reason); 86 } 87 onCallStateChanged(UUID callId, int state)88 public void onCallStateChanged(UUID callId, int state) { 89 mBluetoothLeCallControl.onCallStateChanged(callId, state); 90 } 91 currentCallsList(List<BluetoothLeCall> calls)92 public void currentCallsList(List<BluetoothLeCall> calls) { 93 mBluetoothLeCallControl.currentCallsList(calls); 94 } 95 } 96