diff options
| author | 2017-10-27 21:57:42 +0000 | |
|---|---|---|
| committer | 2017-10-27 21:57:42 +0000 | |
| commit | c484ece9bbd4cdbb41a0cc5944e89d2cfd0c7ecd (patch) | |
| tree | a53cdb623535e3c96a3603b9a86fb37831893aae | |
| parent | 4883b34d1b2bca368fdea9b1344067ff06a862fd (diff) | |
| parent | f16ea680f5aefc6994adb9b7be6b60dbe599f323 (diff) | |
Merge "Move BluetoothA2dpWrapper to the wrapper package."
| -rwxr-xr-x | packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java | 9 | ||||
| -rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothA2dpWrapper.java | 58 | ||||
| -rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/wrapper/BluetoothA2dpWrapper.java (renamed from packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothA2dpWrapperImpl.java) | 38 | ||||
| -rw-r--r-- | packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/A2dpProfileTest.java | 3 |
4 files changed, 29 insertions, 79 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java index 0946181ab710..764c5922cc64 100755 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java @@ -30,6 +30,7 @@ import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.settingslib.R; +import com.android.settingslib.wrapper.BluetoothA2dpWrapper; import java.util.ArrayList; import java.util.Arrays; @@ -42,7 +43,6 @@ public class A2dpProfile implements LocalBluetoothProfile { private Context mContext; private BluetoothA2dp mService; - BluetoothA2dpWrapper.Factory mWrapperFactory; private BluetoothA2dpWrapper mServiceWrapper; private boolean mIsProfileReady; @@ -67,7 +67,7 @@ public class A2dpProfile implements LocalBluetoothProfile { public void onServiceConnected(int profile, BluetoothProfile proxy) { if (V) Log.d(TAG,"Bluetooth service connected"); mService = (BluetoothA2dp) proxy; - mServiceWrapper = mWrapperFactory.getInstance(mService); + mServiceWrapper = new BluetoothA2dpWrapper(mService); // We just bound to the service, so refresh the UI for any connected A2DP devices. List<BluetoothDevice> deviceList = mService.getConnectedDevices(); while (!deviceList.isEmpty()) { @@ -101,14 +101,13 @@ public class A2dpProfile implements LocalBluetoothProfile { mLocalAdapter = adapter; mDeviceManager = deviceManager; mProfileManager = profileManager; - mWrapperFactory = new BluetoothA2dpWrapperImpl.Factory(); mLocalAdapter.getProfileProxy(context, new A2dpServiceListener(), BluetoothProfile.A2DP); } @VisibleForTesting - void setWrapperFactory(BluetoothA2dpWrapper.Factory factory) { - mWrapperFactory = factory; + void setBluetoothA2dpWrapper(BluetoothA2dpWrapper wrapper) { + mServiceWrapper = wrapper; } public boolean isConnectable() { diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothA2dpWrapper.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothA2dpWrapper.java deleted file mode 100644 index aa3e8356739a..000000000000 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothA2dpWrapper.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settingslib.bluetooth; - -import android.bluetooth.BluetoothA2dp; -import android.bluetooth.BluetoothCodecStatus; -import android.bluetooth.BluetoothDevice; - -/** - * This interface replicates some methods of android.bluetooth.BluetoothA2dp that are new and not - * yet available in our current version of Robolectric. It provides a thin wrapper to call the real - * methods in production and a mock in tests. - */ -public interface BluetoothA2dpWrapper { - - static interface Factory { - BluetoothA2dpWrapper getInstance(BluetoothA2dp service); - } - - /** - * @return the real {@code BluetoothA2dp} object - */ - BluetoothA2dp getService(); - - /** - * Wraps {@code BluetoothA2dp.getCodecStatus} - */ - public BluetoothCodecStatus getCodecStatus(); - - /** - * Wraps {@code BluetoothA2dp.supportsOptionalCodecs} - */ - int supportsOptionalCodecs(BluetoothDevice device); - - /** - * Wraps {@code BluetoothA2dp.getOptionalCodecsEnabled} - */ - int getOptionalCodecsEnabled(BluetoothDevice device); - - /** - * Wraps {@code BluetoothA2dp.setOptionalCodecsEnabled} - */ - void setOptionalCodecsEnabled(BluetoothDevice device, int value); -} diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothA2dpWrapperImpl.java b/packages/SettingsLib/src/com/android/settingslib/wrapper/BluetoothA2dpWrapper.java index 14fa7966eab1..4c52a9f8d3ce 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothA2dpWrapperImpl.java +++ b/packages/SettingsLib/src/com/android/settingslib/wrapper/BluetoothA2dpWrapper.java @@ -14,48 +14,56 @@ * limitations under the License. */ -package com.android.settingslib.bluetooth; +package com.android.settingslib.wrapper; import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothCodecStatus; import android.bluetooth.BluetoothDevice; -public class BluetoothA2dpWrapperImpl implements BluetoothA2dpWrapper { - - public static class Factory implements BluetoothA2dpWrapper.Factory { - @Override - public BluetoothA2dpWrapper getInstance(BluetoothA2dp service) { - return new BluetoothA2dpWrapperImpl(service); - } - } +/** + * This class replicates some methods of android.bluetooth.BluetoothA2dp that are new and not + * yet available in our current version of Robolectric. It provides a thin wrapper to call the real + * methods in production and a mock in tests. + */ +public class BluetoothA2dpWrapper { private BluetoothA2dp mService; - public BluetoothA2dpWrapperImpl(BluetoothA2dp service) { + public BluetoothA2dpWrapper(BluetoothA2dp service) { mService = service; } - @Override + /** + * @return the real {@code BluetoothA2dp} object + */ public BluetoothA2dp getService() { return mService; } - @Override + /** + * Wraps {@code BluetoothA2dp.getCodecStatus} + */ public BluetoothCodecStatus getCodecStatus() { return mService.getCodecStatus(); } - @Override + /** + * Wraps {@code BluetoothA2dp.supportsOptionalCodecs} + */ public int supportsOptionalCodecs(BluetoothDevice device) { return mService.supportsOptionalCodecs(device); } - @Override + /** + * Wraps {@code BluetoothA2dp.getOptionalCodecsEnabled} + */ public int getOptionalCodecsEnabled(BluetoothDevice device) { return mService.getOptionalCodecsEnabled(device); } - @Override + /** + * Wraps {@code BluetoothA2dp.setOptionalCodecsEnabled} + */ public void setOptionalCodecsEnabled(BluetoothDevice device, int value) { mService.setOptionalCodecsEnabled(device, value); } diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/A2dpProfileTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/A2dpProfileTest.java index 4a73c1bb61aa..ece0d51e2b66 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/A2dpProfileTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/A2dpProfileTest.java @@ -25,6 +25,7 @@ import android.content.res.Resources; import com.android.settingslib.R; import com.android.settingslib.TestConfig; +import com.android.settingslib.wrapper.BluetoothA2dpWrapper; import org.junit.Before; import org.junit.Test; @@ -73,8 +74,8 @@ public class A2dpProfileTest { }).when(mAdapter).getProfileProxy(any(Context.class), any(), eq(BluetoothProfile.A2DP)); mProfile = new A2dpProfile(mContext, mAdapter, mDeviceManager, mProfileManager); - mProfile.setWrapperFactory((service) -> { return mBluetoothA2dpWrapper; }); mServiceListener.onServiceConnected(BluetoothProfile.A2DP, mBluetoothA2dp); + mProfile.setBluetoothA2dpWrapper(mBluetoothA2dpWrapper); } @Test |