Update profile api am: 4f872ae7fc am: c9f417823f

Change-Id: I3d158f5b4439e4fe0692b9ba337c2dcbf49009c3
diff --git a/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilePreference.java b/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilePreference.java
index a6ac320..59f725e 100644
--- a/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilePreference.java
+++ b/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilePreference.java
@@ -77,7 +77,7 @@
             setChecked(
                     mProfile.getConnectionStatus(mCachedDevice.getDevice()) == STATE_CONNECTED);
         } else {
-            setChecked(mProfile.isPreferred(mCachedDevice.getDevice()));
+            setChecked(mProfile.isEnabled(mCachedDevice.getDevice()));
         }
     }
 }
diff --git a/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilesPreferenceController.java b/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilesPreferenceController.java
index 9df8054..930fbbf 100644
--- a/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilesPreferenceController.java
+++ b/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilesPreferenceController.java
@@ -39,12 +39,7 @@
                 BluetoothDeviceProfilePreference profilePref =
                         (BluetoothDeviceProfilePreference) preference;
                 LocalBluetoothProfile profile = profilePref.getProfile();
-                profile.setPreferred(profilePref.getCachedDevice().getDevice(), isChecked);
-                if (isChecked) {
-                    getCachedDevice().connectProfile(profile);
-                } else {
-                    getCachedDevice().disconnect(profile);
-                }
+                profile.setEnabled(profilePref.getCachedDevice().getDevice(), isChecked);
                 return true;
             };
 
diff --git a/tests/robotests/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilePreferenceTest.java b/tests/robotests/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilePreferenceTest.java
index 5d04587..b8ce10d 100644
--- a/tests/robotests/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilePreferenceTest.java
+++ b/tests/robotests/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilePreferenceTest.java
@@ -103,7 +103,7 @@
 
     @Test
     public void onAttached_preferred_setsChecked() {
-        when(mProfile.isPreferred(mDevice)).thenReturn(true);
+        when(mProfile.isEnabled(mDevice)).thenReturn(true);
 
         mPreference.onAttached();
 
@@ -112,7 +112,7 @@
 
     @Test
     public void onAttached_notPreferred_setsUnchecked() {
-        when(mProfile.isPreferred(mDevice)).thenReturn(false);
+        when(mProfile.isEnabled(mDevice)).thenReturn(false);
 
         mPreference.onAttached();
 
@@ -147,7 +147,7 @@
 
     @Test
     public void onDeviceAttributesChanged_refreshesUi() {
-        when(mProfile.isPreferred(mDevice)).thenReturn(false);
+        when(mProfile.isEnabled(mDevice)).thenReturn(false);
         when(mCachedDevice.isBusy()).thenReturn(false);
         ArgumentCaptor<CachedBluetoothDevice.Callback> callbackCaptor = ArgumentCaptor.forClass(
                 CachedBluetoothDevice.Callback.class);
@@ -157,7 +157,7 @@
         assertThat(mPreference.isEnabled()).isTrue();
         assertThat(mPreference.isChecked()).isFalse();
 
-        when(mProfile.isPreferred(mDevice)).thenReturn(true);
+        when(mProfile.isEnabled(mDevice)).thenReturn(true);
         when(mCachedDevice.isBusy()).thenReturn(true);
 
         callbackCaptor.getValue().onDeviceAttributesChanged();
diff --git a/tests/robotests/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilesPreferenceControllerTest.java b/tests/robotests/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilesPreferenceControllerTest.java
index 31ecd21..2d4532b 100644
--- a/tests/robotests/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/car/settings/bluetooth/BluetoothDeviceProfilesPreferenceControllerTest.java
@@ -170,7 +170,7 @@
         assertThat(profilePreference.isChecked()).isFalse();
         profilePreference.performClick();
 
-        verify(profile).setPreferred(mDevice, true);
+        verify(profile).setEnabled(mDevice, true);
     }
 
     @Test
@@ -185,14 +185,14 @@
         assertThat(profilePreference.isChecked()).isFalse();
         profilePreference.performClick();
 
-        verify(mCachedDevice).connectProfile(profile);
+        verify(profile).setEnabled(mDevice, true);
     }
 
     @Test
     public void profileUnchecked_setsProfileNotPreferred() {
         LocalBluetoothProfile profile = mock(LocalBluetoothProfile.class);
         when(profile.getNameResource(mDevice)).thenReturn(R.string.bt_profile_name);
-        when(profile.isPreferred(mDevice)).thenReturn(true);
+        when(profile.isEnabled(mDevice)).thenReturn(true);
         when(mCachedDevice.getProfiles()).thenReturn(Collections.singletonList(profile));
         mController.refreshUi();
         BluetoothDeviceProfilePreference profilePreference =
@@ -201,14 +201,14 @@
         assertThat(profilePreference.isChecked()).isTrue();
         profilePreference.performClick();
 
-        verify(profile).setPreferred(mDevice, false);
+        verify(profile).setEnabled(mDevice, false);
     }
 
     @Test
     public void profileUnchecked_disconnectsFromProfile() {
         LocalBluetoothProfile profile = mock(LocalBluetoothProfile.class);
         when(profile.getNameResource(mDevice)).thenReturn(R.string.bt_profile_name);
-        when(profile.isPreferred(mDevice)).thenReturn(true);
+        when(profile.isEnabled(mDevice)).thenReturn(true);
         when(mCachedDevice.getProfiles()).thenReturn(Collections.singletonList(profile));
         mController.refreshUi();
         BluetoothDeviceProfilePreference profilePreference =
@@ -217,7 +217,7 @@
         assertThat(profilePreference.isChecked()).isTrue();
         profilePreference.performClick();
 
-        verify(mCachedDevice).disconnect(profile);
+        verify(profile).setEnabled(mDevice, false);
     }
 
     private ShadowBluetoothAdapter getShadowBluetoothAdapter() {