blob: 17e34016a53b75952d4e681113b97c1049430372 [file] [log] [blame]
Antony Sargent374d2592017-04-20 11:23:34 -07001/*
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 Lingf16ea682017-09-15 14:44:34 -070017package com.android.settingslib.wrapper;
Antony Sargent374d2592017-04-20 11:23:34 -070018
19import android.bluetooth.BluetoothA2dp;
20import android.bluetooth.BluetoothCodecStatus;
21import android.bluetooth.BluetoothDevice;
22
Doris Lingf16ea682017-09-15 14:44:34 -070023/**
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 */
28public class BluetoothA2dpWrapper {
Antony Sargent374d2592017-04-20 11:23:34 -070029
30 private BluetoothA2dp mService;
31
Doris Lingf16ea682017-09-15 14:44:34 -070032 public BluetoothA2dpWrapper(BluetoothA2dp service) {
Antony Sargent374d2592017-04-20 11:23:34 -070033 mService = service;
34 }
35
Doris Lingf16ea682017-09-15 14:44:34 -070036 /**
37 * @return the real {@code BluetoothA2dp} object
38 */
Antony Sargent374d2592017-04-20 11:23:34 -070039 public BluetoothA2dp getService() {
40 return mService;
41 }
42
Doris Lingf16ea682017-09-15 14:44:34 -070043 /**
44 * Wraps {@code BluetoothA2dp.getCodecStatus}
45 */
Pavlin Radoslavov502af212018-01-03 19:38:39 -080046 public BluetoothCodecStatus getCodecStatus(BluetoothDevice device) {
47 return mService.getCodecStatus(device);
Antony Sargent374d2592017-04-20 11:23:34 -070048 }
49
Doris Lingf16ea682017-09-15 14:44:34 -070050 /**
51 * Wraps {@code BluetoothA2dp.supportsOptionalCodecs}
52 */
Antony Sargent374d2592017-04-20 11:23:34 -070053 public int supportsOptionalCodecs(BluetoothDevice device) {
54 return mService.supportsOptionalCodecs(device);
55 }
56
Doris Lingf16ea682017-09-15 14:44:34 -070057 /**
58 * Wraps {@code BluetoothA2dp.getOptionalCodecsEnabled}
59 */
Antony Sargent374d2592017-04-20 11:23:34 -070060 public int getOptionalCodecsEnabled(BluetoothDevice device) {
61 return mService.getOptionalCodecsEnabled(device);
62 }
63
Doris Lingf16ea682017-09-15 14:44:34 -070064 /**
65 * Wraps {@code BluetoothA2dp.setOptionalCodecsEnabled}
66 */
Antony Sargent374d2592017-04-20 11:23:34 -070067 public void setOptionalCodecsEnabled(BluetoothDevice device, int value) {
68 mService.setOptionalCodecsEnabled(device, value);
69 }
70}