Antony Sargent | 374d259 | 2017-04-20 11:23:34 -0700 | [diff] [blame] | 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 | |
Doris Ling | f16ea68 | 2017-09-15 14:44:34 -0700 | [diff] [blame] | 17 | package com.android.settingslib.wrapper; |
Antony Sargent | 374d259 | 2017-04-20 11:23:34 -0700 | [diff] [blame] | 18 | |
| 19 | import android.bluetooth.BluetoothA2dp; |
| 20 | import android.bluetooth.BluetoothCodecStatus; |
| 21 | import android.bluetooth.BluetoothDevice; |
| 22 | |
Doris Ling | f16ea68 | 2017-09-15 14:44:34 -0700 | [diff] [blame] | 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 { |
Antony Sargent | 374d259 | 2017-04-20 11:23:34 -0700 | [diff] [blame] | 29 | |
| 30 | private BluetoothA2dp mService; |
| 31 | |
Doris Ling | f16ea68 | 2017-09-15 14:44:34 -0700 | [diff] [blame] | 32 | public BluetoothA2dpWrapper(BluetoothA2dp service) { |
Antony Sargent | 374d259 | 2017-04-20 11:23:34 -0700 | [diff] [blame] | 33 | mService = service; |
| 34 | } |
| 35 | |
Doris Ling | f16ea68 | 2017-09-15 14:44:34 -0700 | [diff] [blame] | 36 | /** |
| 37 | * @return the real {@code BluetoothA2dp} object |
| 38 | */ |
Antony Sargent | 374d259 | 2017-04-20 11:23:34 -0700 | [diff] [blame] | 39 | public BluetoothA2dp getService() { |
| 40 | return mService; |
| 41 | } |
| 42 | |
Doris Ling | f16ea68 | 2017-09-15 14:44:34 -0700 | [diff] [blame] | 43 | /** |
| 44 | * Wraps {@code BluetoothA2dp.getCodecStatus} |
| 45 | */ |
Antony Sargent | 374d259 | 2017-04-20 11:23:34 -0700 | [diff] [blame] | 46 | public BluetoothCodecStatus getCodecStatus() { |
| 47 | return mService.getCodecStatus(); |
| 48 | } |
| 49 | |
Doris Ling | f16ea68 | 2017-09-15 14:44:34 -0700 | [diff] [blame] | 50 | /** |
| 51 | * Wraps {@code BluetoothA2dp.supportsOptionalCodecs} |
| 52 | */ |
Antony Sargent | 374d259 | 2017-04-20 11:23:34 -0700 | [diff] [blame] | 53 | public int supportsOptionalCodecs(BluetoothDevice device) { |
| 54 | return mService.supportsOptionalCodecs(device); |
| 55 | } |
| 56 | |
Doris Ling | f16ea68 | 2017-09-15 14:44:34 -0700 | [diff] [blame] | 57 | /** |
| 58 | * Wraps {@code BluetoothA2dp.getOptionalCodecsEnabled} |
| 59 | */ |
Antony Sargent | 374d259 | 2017-04-20 11:23:34 -0700 | [diff] [blame] | 60 | public int getOptionalCodecsEnabled(BluetoothDevice device) { |
| 61 | return mService.getOptionalCodecsEnabled(device); |
| 62 | } |
| 63 | |
Doris Ling | f16ea68 | 2017-09-15 14:44:34 -0700 | [diff] [blame] | 64 | /** |
| 65 | * Wraps {@code BluetoothA2dp.setOptionalCodecsEnabled} |
| 66 | */ |
Antony Sargent | 374d259 | 2017-04-20 11:23:34 -0700 | [diff] [blame] | 67 | public void setOptionalCodecsEnabled(BluetoothDevice device, int value) { |
| 68 | mService.setOptionalCodecsEnabled(device, value); |
| 69 | } |
| 70 | } |