From 02acba607a87c760a6a84f6cf1817eb6e319dd18 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Mon, 19 Mar 2018 18:21:40 -0700 Subject: [PATCH] Move the setActiveDevice logic from Settings to SettingsLib (2/2) Currently the Settings app handles the logic of setting active device; however, this should be handled by SettingsLib so the logic can be shared. Bug: 75984255 Test: robolectric test Change-Id: I5742de1463d156ff29708ea2aecfc3fd00795e9e --- .../settings/bluetooth/BluetoothDeviceUpdater.java | 23 +--------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java index 63763472a8..993ff474c2 100644 --- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java +++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java @@ -88,29 +88,8 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback { public boolean onPreferenceClick(Preference preference) { final CachedBluetoothDevice device = ((BluetoothDevicePreference) preference).getBluetoothDevice(); - if (device == null) { - return false; - } - - // Set the device as active per profile only if the device supports that profile - // TODO: The active device selector location might change in the future Log.i(TAG, "OnPreferenceClickListener: device=" + device); - boolean result = false; - A2dpProfile a2dpProfile = mLocalManager.getProfileManager().getA2dpProfile(); - if ((a2dpProfile != null) && device.isConnectedProfile(a2dpProfile)) { - if (a2dpProfile.setActiveDevice(device.getDevice())) { - Log.i(TAG, "OnPreferenceClickListener: A2DP active device=" + device); - result = true; - } - } - HeadsetProfile headsetProfile = mLocalManager.getProfileManager().getHeadsetProfile(); - if ((headsetProfile != null) && device.isConnectedProfile(headsetProfile)) { - if (headsetProfile.setActiveDevice(device.getDevice())) { - Log.i(TAG, "OnPreferenceClickListener: Headset active device=" + device); - result = true; - } - } - return result; + return device.setActive(); } } -- 2.11.0