Add condition to check case of accessory combinations
Before this CL, we only compare whether the value of function is
equal to accessory to ensure usb is in accessory mode. But in some
cases there are different accessory combinations, like
"accessory,audio source". It will make the condition return false
when encountering accessory combinations.
This CL will check whether the function will include accessory mode
to fix this issue.
Bug: 162451162
Test: make -j42 RunSettingsRoboTests
Change-Id: I7c80f02de5340799e292949608e19b86b187b982
Merged-In: I7c80f02de5340799e292949608e19b86b187b982
(cherry picked from commit 7d71081d45
)
This commit is contained in:
@@ -275,6 +275,18 @@ public class UsbDetailsFunctionsControllerTest {
|
||||
UsbManager.FUNCTION_ACCESSORY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onRadioButtonClicked_functionMtp_inAccessoryCombinationsMode_doNothing() {
|
||||
final long function = UsbManager.FUNCTION_ACCESSORY | UsbManager.FUNCTION_AUDIO_SOURCE;
|
||||
mRadioButtonPreference.setKey(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_MTP));
|
||||
doReturn(UsbManager.FUNCTION_ACCESSORY).when(mUsbBackend).getCurrentFunctions();
|
||||
|
||||
mDetailsFunctionsController.mPreviousFunction = function;
|
||||
mDetailsFunctionsController.onRadioButtonClicked(mRadioButtonPreference);
|
||||
|
||||
assertThat(mDetailsFunctionsController.mPreviousFunction).isEqualTo(function);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onRadioButtonClicked_clickSameButton_doNothing() {
|
||||
mRadioButtonPreference.setKey(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_PTP));
|
||||
|
Reference in New Issue
Block a user