Fix can't select the [USB Tethering] item in [Developer Options]

- This CL is using 'USB_CONFIGURED' to check whether the USB enumeration
  is completed from the intent. If 'USB_CONFIGURED' is true then update
  the UI.

Bug: 229200265
Test: make -j65 RunSettingsRoboTests
Change-Id: Icab05e37ae3fcc9f1bf404a610fc97c368c453f5
This commit is contained in:
Hugh Chen
2022-04-29 08:40:21 +00:00
parent aadc44ae26
commit ec0c171735
7 changed files with 92 additions and 37 deletions

View File

@@ -69,22 +69,23 @@ public class UsbDefaultFragment extends RadioButtonPickerFragment {
@VisibleForTesting
UsbConnectionBroadcastReceiver.UsbConnectionListener mUsbConnectionListener =
(connected, functions, powerRole, dataRole) -> {
(connected, functions, powerRole, dataRole, isUsbConfigured) -> {
final long defaultFunctions = mUsbBackend.getDefaultUsbFunctions();
Log.d(TAG, "UsbConnectionListener() connected : " + connected + ", functions : "
+ functions + ", defaultFunctions : " + defaultFunctions
+ ", mIsStartTethering : " + mIsStartTethering);
if (connected && !mIsConnected && (defaultFunctions == UsbManager.FUNCTION_RNDIS
+ ", mIsStartTethering : " + mIsStartTethering
+ ", isUsbConfigured : " + isUsbConfigured);
if (connected && !mIsConnected && ((defaultFunctions == UsbManager.FUNCTION_RNDIS
|| defaultFunctions == UsbManager.FUNCTION_NCM)
&& defaultFunctions == functions)
&& !mIsStartTethering) {
mCurrentFunctions = defaultFunctions;
startTethering();
}
if (mIsStartTethering && connected) {
if ((mIsStartTethering || isUsbConfigured) && connected) {
mCurrentFunctions = functions;
refresh(functions);
mUsbBackend.setDefaultUsbFunctions(functions);
mIsStartTethering = false;
}
mIsConnected = connected;