Merge "Fix incorrect API invoke for BT profiles"

am: 625c1eeaa9

Change-Id: I1a7f98b25cae2695d8f5895c8f6e03072ef4600f
This commit is contained in:
Lei Yu
2018-09-21 13:13:39 -07:00
committed by android-build-merger
4 changed files with 10 additions and 10 deletions

View File

@@ -100,12 +100,9 @@ public class HandsFreeProfileOutputPreferenceController extends
if (hapProfile != null && hfpProfile != null && device == null) { if (hapProfile != null && hfpProfile != null && device == null) {
hfpProfile.setActiveDevice(null); hfpProfile.setActiveDevice(null);
hapProfile.setActiveDevice(null); hapProfile.setActiveDevice(null);
return; } else if (hapProfile != null && hapProfile.getHiSyncId(device) != HI_SYNC_ID_INVALID) {
}
if (hapProfile != null && hapProfile.getHiSyncId(device) != HI_SYNC_ID_INVALID) {
hapProfile.setActiveDevice(device); hapProfile.setActiveDevice(device);
} } else if (hfpProfile != null) {
if (hfpProfile != null) {
hfpProfile.setActiveDevice(device); hfpProfile.setActiveDevice(device);
} }
} }

View File

@@ -112,12 +112,9 @@ public class MediaOutputPreferenceController extends AudioSwitchPreferenceContro
if (hapProfile != null && a2dpProfile != null && device == null) { if (hapProfile != null && a2dpProfile != null && device == null) {
hapProfile.setActiveDevice(null); hapProfile.setActiveDevice(null);
a2dpProfile.setActiveDevice(null); a2dpProfile.setActiveDevice(null);
return; } else if (hapProfile != null && hapProfile.getHiSyncId(device) != HI_SYNC_ID_INVALID) {
}
if (hapProfile != null && hapProfile.getHiSyncId(device) != HI_SYNC_ID_INVALID) {
hapProfile.setActiveDevice(device); hapProfile.setActiveDevice(device);
} } else if (a2dpProfile != null) {
if (a2dpProfile != null) {
a2dpProfile.setActiveDevice(device); a2dpProfile.setActiveDevice(device);
} }
} }

View File

@@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@@ -179,6 +180,7 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
mController.setActiveBluetoothDevice(mLeftBluetoothHapDevice); mController.setActiveBluetoothDevice(mLeftBluetoothHapDevice);
verify(mHearingAidProfile).setActiveDevice(mLeftBluetoothHapDevice); verify(mHearingAidProfile).setActiveDevice(mLeftBluetoothHapDevice);
verify(mHeadsetProfile, never()).setActiveDevice(mLeftBluetoothHapDevice);
} }
/** /**
@@ -192,6 +194,7 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
mController.setActiveBluetoothDevice(mBluetoothDevice); mController.setActiveBluetoothDevice(mBluetoothDevice);
verify(mHeadsetProfile).setActiveDevice(mBluetoothDevice); verify(mHeadsetProfile).setActiveDevice(mBluetoothDevice);
verify(mHearingAidProfile, never()).setActiveDevice(mBluetoothDevice);
} }
/** /**

View File

@@ -26,6 +26,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@@ -181,6 +182,7 @@ public class MediaOutputPreferenceControllerTest {
mController.setActiveBluetoothDevice(mLeftBluetoothHapDevice); mController.setActiveBluetoothDevice(mLeftBluetoothHapDevice);
verify(mHearingAidProfile).setActiveDevice(mLeftBluetoothHapDevice); verify(mHearingAidProfile).setActiveDevice(mLeftBluetoothHapDevice);
verify(mA2dpProfile, never()).setActiveDevice(mLeftBluetoothHapDevice);
} }
/** /**
@@ -194,6 +196,7 @@ public class MediaOutputPreferenceControllerTest {
mController.setActiveBluetoothDevice(mBluetoothDevice); mController.setActiveBluetoothDevice(mBluetoothDevice);
verify(mA2dpProfile).setActiveDevice(mBluetoothDevice); verify(mA2dpProfile).setActiveDevice(mBluetoothDevice);
verify(mHearingAidProfile, never()).setActiveDevice(mBluetoothDevice);
} }
/** /**