Add supportsComplianceWarnings() new checking condition
Add supportsComplianceWarnings() new checking condition based on the https://b.corp.google.com/issues/246960554#comment19 (updated from the Usb firmware) ADB command: ``` adb shell dumpsys usb add-port "matrix" dual --compliance-warnings; adb shell dumpsys usb connect-port "matrix" ufp? sink? device?; adb shell dumpsys usb set-compliance-reasons "matrix" 4 ``` Bug: 246960554 Test: make test RunSettingsLibRoboTests -j40 Change-Id: Idea8f2ba2d79fbb8838e9a1abeee0ddd78d01ba8
This commit is contained in:
@@ -653,6 +653,9 @@ public class Utils {
|
||||
}
|
||||
for (UsbPort usbPort : usbPortList) {
|
||||
Log.d(tag, "usbPort: " + usbPort);
|
||||
if (!usbPort.supportsComplianceWarnings()) {
|
||||
continue;
|
||||
}
|
||||
final UsbPortStatus usbStatus = usbPort.getStatus();
|
||||
if (usbStatus == null || !usbStatus.isConnected()) {
|
||||
continue;
|
||||
|
||||
@@ -448,25 +448,41 @@ public class UtilsTest {
|
||||
|
||||
@Test
|
||||
public void containsIncompatibleChargers_returnTrue() {
|
||||
final List<UsbPort> usbPorts = new ArrayList<>();
|
||||
usbPorts.add(mUsbPort);
|
||||
when(mUsbManager.getPorts()).thenReturn(usbPorts);
|
||||
when(mUsbPort.getStatus()).thenReturn(mUsbPortStatus);
|
||||
when(mUsbPortStatus.isConnected()).thenReturn(true);
|
||||
when(mUsbPortStatus.getComplianceWarnings()).thenReturn(new int[]{1});
|
||||
|
||||
setupIncompatibleCharging();
|
||||
assertThat(Utils.containsIncompatibleChargers(mContext, "tag")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsIncompatibleChargers_emptyComplianceWarnings_returnFalse() {
|
||||
final List<UsbPort> usbPorts = new ArrayList<>();
|
||||
usbPorts.add(mUsbPort);
|
||||
when(mUsbManager.getPorts()).thenReturn(usbPorts);
|
||||
when(mUsbPort.getStatus()).thenReturn(mUsbPortStatus);
|
||||
when(mUsbPortStatus.isConnected()).thenReturn(true);
|
||||
setupIncompatibleCharging();
|
||||
when(mUsbPortStatus.getComplianceWarnings()).thenReturn(new int[1]);
|
||||
|
||||
assertThat(Utils.containsIncompatibleChargers(mContext, "tag")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsIncompatibleChargers_notSupportComplianceWarnings_returnFalse() {
|
||||
setupIncompatibleCharging();
|
||||
when(mUsbPort.supportsComplianceWarnings()).thenReturn(false);
|
||||
|
||||
assertThat(Utils.containsIncompatibleChargers(mContext, "tag")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsIncompatibleChargers_usbNotConnected_returnFalse() {
|
||||
setupIncompatibleCharging();
|
||||
when(mUsbPortStatus.isConnected()).thenReturn(false);
|
||||
|
||||
assertThat(Utils.containsIncompatibleChargers(mContext, "tag")).isFalse();
|
||||
}
|
||||
|
||||
private void setupIncompatibleCharging() {
|
||||
final List<UsbPort> usbPorts = new ArrayList<>();
|
||||
usbPorts.add(mUsbPort);
|
||||
when(mUsbManager.getPorts()).thenReturn(usbPorts);
|
||||
when(mUsbPort.getStatus()).thenReturn(mUsbPortStatus);
|
||||
when(mUsbPort.supportsComplianceWarnings()).thenReturn(true);
|
||||
when(mUsbPortStatus.isConnected()).thenReturn(true);
|
||||
when(mUsbPortStatus.getComplianceWarnings()).thenReturn(new int[]{1});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user