Settings: Hide unsupported USB modes automatically
* The roles are advertised by USB HAL so we can check for their status Change-Id: I5933d1a03f573af08b00039850173329b293448a
This commit is contained in:
@@ -165,6 +165,30 @@ public class UsbBackend {
|
||||
&& mPortStatus.isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST);
|
||||
}
|
||||
|
||||
public boolean isSingleDataRoleSupported() {
|
||||
return mPort != null && mPortStatus != null
|
||||
&& ((!mPortStatus
|
||||
.isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_HOST)
|
||||
&& !mPortStatus
|
||||
.isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST))
|
||||
|| (!mPortStatus
|
||||
.isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE)
|
||||
&& !mPortStatus
|
||||
.isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_DEVICE)));
|
||||
}
|
||||
|
||||
public boolean isSinglePowerRoleSupported() {
|
||||
return mPort != null && mPortStatus != null
|
||||
&& ((!mPortStatus
|
||||
.isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE)
|
||||
&& !mPortStatus
|
||||
.isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_HOST))
|
||||
|| (!mPortStatus
|
||||
.isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_DEVICE)
|
||||
&& !mPortStatus
|
||||
.isRoleCombinationSupported(POWER_ROLE_SOURCE, DATA_ROLE_HOST)));
|
||||
}
|
||||
|
||||
public static String usbFunctionsToString(long functions) {
|
||||
// TODO replace with UsbManager.usbFunctionsToString once supported by Roboelectric
|
||||
return Long.toBinaryString(functions);
|
||||
|
||||
@@ -115,7 +115,8 @@ public class UsbDetailsDataRoleController extends UsbDetailsController
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return !Utils.isMonkeyRunning();
|
||||
return !Utils.isMonkeyRunning()
|
||||
&& !mUsbBackend.isSingleDataRoleSupported();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -126,7 +126,8 @@ public class UsbDetailsPowerRoleController extends UsbDetailsController
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return !Utils.isMonkeyRunning();
|
||||
return !Utils.isMonkeyRunning()
|
||||
&& !mUsbBackend.isSinglePowerRoleSupported();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user