Stop usb tethering when user cancel it

- Call stop tethering to clear entitlement result when user do not want
  using USB tethering on USB menu.
- Add test case

Bug: 154933817
Test: make -j42 RunSettingsRoboTests
Change-Id: Idaaba8df2052f45e710c7959251817e8947a544f
This commit is contained in:
hughchen
2020-05-06 16:02:35 +08:00
parent 6e68e34f2a
commit 9546b7fdcb
2 changed files with 44 additions and 0 deletions

View File

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