Fix USB tethering is not turned on with a single tap

Before this CL, the USB default settings will set default usb functions
to RNDIS when tethering is started. Because in some devices, the NCM
is used instead of RNDIS to start tethering. If RNDIS is set in the
device that uses NCM to start tethering, it will cause start
tethering failed.

This CL will use the current functions to set default usb functions
to fix this issue.

Bug: 195068679
Test: make -j42 RunSettingsRoboTests
Change-Id: Ic9353c5ac76c0cd517318a4304fa214d6b2201d2
This commit is contained in:
Hugh Chen
2021-08-03 17:32:25 +08:00
parent 279a179043
commit ba30b04cc3
2 changed files with 4 additions and 3 deletions

View File

@@ -198,8 +198,9 @@ public class UsbDefaultFragment extends RadioButtonPickerFragment {
@Override
public void onTetheringStarted() {
Log.d(TAG, "onTetheringStarted()");
// Set default usb functions again to make internal data persistent
mCurrentFunctions = mUsbBackend.getCurrentFunctions();
Log.d(TAG, "onTetheringStarted() : mCurrentFunctions " + mCurrentFunctions);
mUsbBackend.setDefaultUsbFunctions(mCurrentFunctions);
}

View File

@@ -183,7 +183,7 @@ public class UsbDefaultFragmentTest {
@Test
public void onTetheringStarted_currentFunctionsIsRndis_setsRndisAsDefaultUsbFunctions() {
mFragment.mCurrentFunctions = UsbManager.FUNCTION_RNDIS;
when(mUsbBackend.getCurrentFunctions()).thenReturn(UsbManager.FUNCTION_RNDIS);
mFragment.mOnStartTetheringCallback.onTetheringStarted();
@@ -192,7 +192,7 @@ public class UsbDefaultFragmentTest {
@Test
public void onTetheringStarted_currentFunctionsIsNcm_setsNcmAsDefaultUsbFunctions() {
mFragment.mCurrentFunctions = UsbManager.FUNCTION_NCM;
when(mUsbBackend.getCurrentFunctions()).thenReturn(UsbManager.FUNCTION_NCM);
mFragment.mOnStartTetheringCallback.onTetheringStarted();