Fix usb menu not switch to "File Transfer/Android Auto" right after connected to car unit
- This CL before usb receiver didn't check the extra information of the accessory. It will cause the usb menu not to be aware that the usb port is switched to accessory mode. This CL usb receiver will check intent whether to have accessory extra. If the usb port is switched to accessory mode the usb menu will switch to "File Transfer/Android Auto". - Update test case Bug: 162451162 Test: make -j42 RunSettingsRoboTests Change-Id: I0eca89a23670c674b74753fc526256cc1d52e759
This commit is contained in:
@@ -72,6 +72,9 @@ public class UsbConnectionBroadcastReceiver extends BroadcastReceiver implements
|
|||||||
if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_RNDIS)) {
|
if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_RNDIS)) {
|
||||||
functions |= UsbManager.FUNCTION_RNDIS;
|
functions |= UsbManager.FUNCTION_RNDIS;
|
||||||
}
|
}
|
||||||
|
if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_ACCESSORY)) {
|
||||||
|
functions |= UsbManager.FUNCTION_ACCESSORY;
|
||||||
|
}
|
||||||
mFunctions = functions;
|
mFunctions = functions;
|
||||||
mDataRole = mUsbBackend.getDataRole();
|
mDataRole = mUsbBackend.getDataRole();
|
||||||
mPowerRole = mUsbBackend.getPowerRole();
|
mPowerRole = mUsbBackend.getPowerRole();
|
||||||
|
@@ -100,7 +100,11 @@ public class UsbDetailsFunctionsController extends UsbDetailsController
|
|||||||
pref = getProfilePreference(UsbBackend.usbFunctionsToString(option), title);
|
pref = getProfilePreference(UsbBackend.usbFunctionsToString(option), title);
|
||||||
// Only show supported options
|
// Only show supported options
|
||||||
if (mUsbBackend.areFunctionsSupported(option)) {
|
if (mUsbBackend.areFunctionsSupported(option)) {
|
||||||
|
if (functions == UsbManager.FUNCTION_ACCESSORY) {
|
||||||
|
pref.setChecked(UsbManager.FUNCTION_MTP == option);
|
||||||
|
} else {
|
||||||
pref.setChecked(functions == option);
|
pref.setChecked(functions == option);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mProfilesContainer.removePreference(pref);
|
mProfilesContainer.removePreference(pref);
|
||||||
}
|
}
|
||||||
|
@@ -153,6 +153,19 @@ public class UsbDetailsFunctionsControllerTest {
|
|||||||
assertThat(prefs.get(0).isChecked()).isTrue();
|
assertThat(prefs.get(0).isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void displayRefresh_accessoryEnabled_shouldCheckSwitches() {
|
||||||
|
when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
|
||||||
|
|
||||||
|
mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_ACCESSORY, POWER_ROLE_SINK,
|
||||||
|
DATA_ROLE_DEVICE);
|
||||||
|
List<RadioButtonPreference> prefs = getRadioPreferences();
|
||||||
|
|
||||||
|
assertThat(prefs.get(0).getKey())
|
||||||
|
.isEqualTo(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_MTP));
|
||||||
|
assertThat(prefs.get(0).isChecked()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onClickMtp_noneEnabled_shouldEnableMtp() {
|
public void onClickMtp_noneEnabled_shouldEnableMtp() {
|
||||||
when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
|
when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);
|
||||||
|
Reference in New Issue
Block a user