Merge "Revert "Stop usb tethering when user cancel it"" into rvc-dev am: 74755ac915 am: d3d9b3d462

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/11708185

Change-Id: I7abcc9e2109bf66e00b14bd8d72457622e392643
This commit is contained in:
TreeHugger Robot
2020-06-04 04:48:36 +00:00
committed by Automerger Merge Worker
2 changed files with 0 additions and 44 deletions

View File

@@ -89,9 +89,6 @@ public class UsbDetailsFunctionsController extends UsbDetailsController
@Override @Override
protected void refresh(boolean connected, long functions, int powerRole, int dataRole) { protected void refresh(boolean connected, long functions, int powerRole, int dataRole) {
if (!connected || dataRole != DATA_ROLE_DEVICE) { if (!connected || dataRole != DATA_ROLE_DEVICE) {
if (mPreviousFunction == UsbManager.FUNCTION_RNDIS) {
mConnectivityManager.stopTethering(TETHERING_USB);
}
mProfilesContainer.setEnabled(false); mProfilesContainer.setEnabled(false);
} else { } else {
// Functions are only available in device mode // Functions are only available in device mode
@@ -132,9 +129,6 @@ public class UsbDetailsFunctionsController extends UsbDetailsController
mConnectivityManager.startTethering(TETHERING_USB, true /* showProvisioningUi */, mConnectivityManager.startTethering(TETHERING_USB, true /* showProvisioningUi */,
mOnStartTetheringCallback); mOnStartTetheringCallback);
} else { } else {
if (mPreviousFunction == UsbManager.FUNCTION_RNDIS) {
mConnectivityManager.stopTethering(TETHERING_USB);
}
mUsbBackend.setCurrentFunctions(function); mUsbBackend.setCurrentFunctions(function);
} }
} }

View File

@@ -270,42 +270,4 @@ public class UsbDetailsFunctionsControllerTest {
verify(mUsbBackend).setCurrentFunctions(UsbManager.FUNCTION_PTP); verify(mUsbBackend).setCurrentFunctions(UsbManager.FUNCTION_PTP);
} }
@Test
public void refresh_previousFunctionIsRndis_stopTethering() {
mDetailsFunctionsController.mPreviousFunction = UsbManager.FUNCTION_RNDIS;
mDetailsFunctionsController.refresh(false, 0, 0, 0);
verify(mConnectivityManager).stopTethering(TETHERING_USB);
}
@Test
public void refresh_previousFunctionIsNotRndis_doNothing() {
mDetailsFunctionsController.mPreviousFunction = UsbManager.FUNCTION_MIDI;
mDetailsFunctionsController.refresh(false, 0, 0, 0);
verify(mConnectivityManager, never()).stopTethering(TETHERING_USB);
}
@Test
public void onRadioButtonClicked_previousFunctionIsRndis_stopTethering() {
mRadioButtonPreference.setKey(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_PTP));
doReturn(UsbManager.FUNCTION_RNDIS).when(mUsbBackend).getCurrentFunctions();
mDetailsFunctionsController.onRadioButtonClicked(mRadioButtonPreference);
verify(mConnectivityManager).stopTethering(TETHERING_USB);
}
@Test
public void onRadioButtonClicked_previousFunctionIsNotRndis_doNothing() {
mRadioButtonPreference.setKey(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_PTP));
doReturn(UsbManager.FUNCTION_MIDI).when(mUsbBackend).getCurrentFunctions();
mDetailsFunctionsController.onRadioButtonClicked(mRadioButtonPreference);
verify(mConnectivityManager, never()).stopTethering(TETHERING_USB);
}
} }