OSDN Git Service

Only re-enable contaminant detection when port is present
authorBadhri Jagan Sridharan <badhri@google.com>
Mon, 1 Apr 2019 19:12:13 +0000 (12:12 -0700)
committerBadhri Jagan Sridharan <badhri@google.com>
Mon, 1 Apr 2019 19:17:03 +0000 (12:17 -0700)
Contaminant detection is re-enabled when the disconnected port's
portStatus has contaminant detection disabled. During port removal,
there is no reason why contamiant detection has to re-enabled since
the port is anyways being teared down.

Bug: 129696344
Test: dumpsys usb add-port "matrix" ufp;
dumpsys usb remove-port "matrix" ufp

Change-Id: Ie146db82d93414e90ee99b4d17ec0ba5ada2ce83

services/usb/java/com/android/server/usb/UsbPortManager.java

index 96e12ce..749258e 100644 (file)
@@ -965,7 +965,6 @@ public class UsbPortManager {
 
     private void handlePortLocked(PortInfo portInfo, IndentingPrintWriter pw) {
         sendPortChangedBroadcastLocked(portInfo);
-        enableContaminantDetectionIfNeeded(portInfo, pw);
         logToStatsd(portInfo, pw);
         updateContaminantNotification();
     }
@@ -977,6 +976,7 @@ public class UsbPortManager {
 
     private void handlePortChangedLocked(PortInfo portInfo, IndentingPrintWriter pw) {
         logAndPrint(Log.INFO, pw, "USB port changed: " + portInfo);
+        enableContaminantDetectionIfNeeded(portInfo, pw);
         handlePortLocked(portInfo, pw);
     }