Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 737ec77c authored by Hugh Chen's avatar Hugh Chen
Browse files

Revert "Stop usb tethering when user cancel it"

This reverts commit 9546b7fd.

Reason for revert: This CL will have side effort, when switch from "USB tethering" to "MTP/PTP/Midi" mode, DUT will jump to "No data transfer".
Revert this CL and have good solution to address b/154933817

Bug: 156318036
Test: build pass
Change-Id: Ia79b7a9f5d71c15244b147f5ef26af47c1c1fc7c
parent 9546b7fd
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -89,9 +89,6 @@ 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
@@ -132,9 +129,6 @@ 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);
            }
        }
+0 −38
Original line number Diff line number Diff line
@@ -270,42 +270,4 @@ public class UsbDetailsFunctionsControllerTest {

        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);
    }
}