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 com.android.settingslib.wrapper; 18 19 import android.bluetooth.BluetoothA2dp; 20 import android.bluetooth.BluetoothCodecStatus; 21 import android.bluetooth.BluetoothDevice; 22 23 /** 24 * This class replicates some methods of android.bluetooth.BluetoothA2dp that are new and not 25 * yet available in our current version of Robolectric. It provides a thin wrapper to call the real 26 * methods in production and a mock in tests. 27 */ 28 public class BluetoothA2dpWrapper { 29 30 private BluetoothA2dp mService; 31 BluetoothA2dpWrapper(BluetoothA2dp service)32 public BluetoothA2dpWrapper(BluetoothA2dp service) { 33 mService = service; 34 } 35 36 /** 37 * @return the real {@code BluetoothA2dp} object 38 */ getService()39 public BluetoothA2dp getService() { 40 return mService; 41 } 42 43 /** 44 * Wraps {@code BluetoothA2dp.getCodecStatus} 45 */ getCodecStatus(BluetoothDevice device)46 public BluetoothCodecStatus getCodecStatus(BluetoothDevice device) { 47 return mService.getCodecStatus(device); 48 } 49 50 /** 51 * Wraps {@code BluetoothA2dp.supportsOptionalCodecs} 52 */ supportsOptionalCodecs(BluetoothDevice device)53 public int supportsOptionalCodecs(BluetoothDevice device) { 54 return mService.supportsOptionalCodecs(device); 55 } 56 57 /** 58 * Wraps {@code BluetoothA2dp.getOptionalCodecsEnabled} 59 */ getOptionalCodecsEnabled(BluetoothDevice device)60 public int getOptionalCodecsEnabled(BluetoothDevice device) { 61 return mService.getOptionalCodecsEnabled(device); 62 } 63 64 /** 65 * Wraps {@code BluetoothA2dp.setOptionalCodecsEnabled} 66 */ setOptionalCodecsEnabled(BluetoothDevice device, int value)67 public void setOptionalCodecsEnabled(BluetoothDevice device, int value) { 68 mService.setOptionalCodecsEnabled(device, value); 69 } 70 } 71