Do nothing when choosing file transfer when in accessory mode

- Before this CL, the device will be disconnected and reconnected
  to accessory mode when choosing "File transfer/Android Auto" in
  accessory mode. Because the USB menu didn't check state of
  function, it should do nothing when choosing
  "File transfer/Android Auto" in accessory mode.

  This CL add condition to check state of function, it will do
  nothing when choosing "File transfer/Android Auto" in
  accessory mode.

Bug: 162451162
Test: make -j42 RunSettingsRoboTests
Change-Id: I1749c6c43d2a192e4ce1bf1ae5343ff8deafbe48
Merged-In: I1749c6c43d2a192e4ce1bf1ae5343ff8deafbe48
(cherry picked from commit 3251a04ba3)
This commit is contained in:
Hugh Chen
2020-09-28 14:58:34 +08:00
parent 91ed63124c
commit e8dc7bc283
2 changed files with 19 additions and 1 deletions

View File

@@ -263,6 +263,18 @@ public class UsbDetailsFunctionsControllerTest {
UsbManager.FUNCTION_MTP);
}
@Test
public void onRadioButtonClicked_functionMtp_inAccessoryMode_doNothing() {
mRadioButtonPreference.setKey(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_MTP));
doReturn(UsbManager.FUNCTION_ACCESSORY).when(mUsbBackend).getCurrentFunctions();
mDetailsFunctionsController.mPreviousFunction = UsbManager.FUNCTION_ACCESSORY;
mDetailsFunctionsController.onRadioButtonClicked(mRadioButtonPreference);
assertThat(mDetailsFunctionsController.mPreviousFunction).isEqualTo(
UsbManager.FUNCTION_ACCESSORY);
}
@Test
public void onRadioButtonClicked_clickSameButton_doNothing() {
mRadioButtonPreference.setKey(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_PTP));