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 = context.getSystemService(BluetoothManager.class); 57 if (btManager != null) { 58 btManager 59 .getAdapter() 60 .closeProfileProxy(BluetoothProfile.LE_CALL_CONTROL, 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( 65 String uci, 66 List<String> uriSchemes, 67 int featureFlags, 68 String provider, 69 int technology, 70 Executor executor, 71 BluetoothLeCallControl.Callback callback) { 72 return mBluetoothLeCallControl.registerBearer( 73 uci, uriSchemes, featureFlags, provider, technology, executor, callback); 74 } 75 unregisterBearer()76 public void unregisterBearer() { 77 mBluetoothLeCallControl.unregisterBearer(); 78 } 79 getContentControlId()80 public int getContentControlId() { 81 return mBluetoothLeCallControl.getContentControlId(); 82 } 83 requestResult(int requestId, int result)84 public void requestResult(int requestId, int result) { 85 mBluetoothLeCallControl.requestResult(requestId, result); 86 } 87 onCallAdded(BluetoothLeCall call)88 public void onCallAdded(BluetoothLeCall call) { 89 mBluetoothLeCallControl.onCallAdded(call); 90 } 91 onCallRemoved(UUID callId, int reason)92 public void onCallRemoved(UUID callId, int reason) { 93 mBluetoothLeCallControl.onCallRemoved(callId, reason); 94 } 95 onCallStateChanged(UUID callId, int state)96 public void onCallStateChanged(UUID callId, int state) { 97 mBluetoothLeCallControl.onCallStateChanged(callId, state); 98 } 99 currentCallsList(List<BluetoothLeCall> calls)100 public void currentCallsList(List<BluetoothLeCall> calls) { 101 mBluetoothLeCallControl.currentCallsList(calls); 102 } 103 networkStateChanged(String providerName, int technology)104 public void networkStateChanged(String providerName, int technology) { 105 mBluetoothLeCallControl.networkStateChanged(providerName, technology); 106 } 107 } 108