Loading services/usb/java/com/android/server/usb/UsbPortManager.java +42 −0 Original line number Diff line number Diff line Loading @@ -1082,6 +1082,7 @@ public class UsbPortManager { private void handlePortComplianceWarningLocked(PortInfo portInfo, IndentingPrintWriter pw) { logAndPrint(Log.INFO, pw, "USB port compliance warning changed: " + portInfo); logToStatsdComplianceWarnings(portInfo); sendComplianceWarningBroadcastLocked(portInfo); } Loading @@ -1108,6 +1109,33 @@ public class UsbPortManager { } } // Constants have to be converted to stats-log constants private static int[] toStatsLogConstant(@NonNull int[] complianceWarnings) { IntArray complianceWarningsProto = new IntArray(); for (int warning : complianceWarnings) { switch (warning) { case UsbPortStatus.COMPLIANCE_WARNING_OTHER: complianceWarningsProto.add(FrameworkStatsLog .USB_COMPLIANCE_WARNINGS_REPORTED__COMPLIANCE_WARNINGS__COMPLIANCE_WARNING_OTHER); continue; case UsbPortStatus.COMPLIANCE_WARNING_DEBUG_ACCESSORY: complianceWarningsProto.add(FrameworkStatsLog .USB_COMPLIANCE_WARNINGS_REPORTED__COMPLIANCE_WARNINGS__COMPLIANCE_WARNING_DEBUG_ACCESSORY); continue; case UsbPortStatus.COMPLIANCE_WARNING_BC_1_2: complianceWarningsProto.add(FrameworkStatsLog .USB_COMPLIANCE_WARNINGS_REPORTED__COMPLIANCE_WARNINGS__COMPLIANCE_WARNING_BC_1_2); continue; case UsbPortStatus.COMPLIANCE_WARNING_MISSING_RP: complianceWarningsProto.add(FrameworkStatsLog .USB_COMPLIANCE_WARNINGS_REPORTED__COMPLIANCE_WARNINGS__COMPLIANCE_WARNING_MISSING_RP); continue; } } return complianceWarningsProto.toArray(); } private void sendPortChangedBroadcastLocked(PortInfo portInfo) { final Intent intent = new Intent(UsbManager.ACTION_USB_PORT_CHANGED); intent.addFlags( Loading Loading @@ -1219,6 +1247,20 @@ public class UsbPortManager { } } // Need to create new version to prevent double counting existing stats due // to new broadcast private void logToStatsdComplianceWarnings(PortInfo portInfo) { if (portInfo.mUsbPortStatus == null) { FrameworkStatsLog.write(FrameworkStatsLog.USB_COMPLIANCE_WARNINGS_REPORTED, portInfo.mUsbPort.getId(), new int[0]); return; } FrameworkStatsLog.write(FrameworkStatsLog.USB_COMPLIANCE_WARNINGS_REPORTED, portInfo.mUsbPort.getId(), toStatsLogConstant(portInfo.mUsbPortStatus.getComplianceWarnings())); } public static void logAndPrint(int priority, IndentingPrintWriter pw, String msg) { Slog.println(priority, TAG, msg); if (pw != null) { Loading Loading
services/usb/java/com/android/server/usb/UsbPortManager.java +42 −0 Original line number Diff line number Diff line Loading @@ -1082,6 +1082,7 @@ public class UsbPortManager { private void handlePortComplianceWarningLocked(PortInfo portInfo, IndentingPrintWriter pw) { logAndPrint(Log.INFO, pw, "USB port compliance warning changed: " + portInfo); logToStatsdComplianceWarnings(portInfo); sendComplianceWarningBroadcastLocked(portInfo); } Loading @@ -1108,6 +1109,33 @@ public class UsbPortManager { } } // Constants have to be converted to stats-log constants private static int[] toStatsLogConstant(@NonNull int[] complianceWarnings) { IntArray complianceWarningsProto = new IntArray(); for (int warning : complianceWarnings) { switch (warning) { case UsbPortStatus.COMPLIANCE_WARNING_OTHER: complianceWarningsProto.add(FrameworkStatsLog .USB_COMPLIANCE_WARNINGS_REPORTED__COMPLIANCE_WARNINGS__COMPLIANCE_WARNING_OTHER); continue; case UsbPortStatus.COMPLIANCE_WARNING_DEBUG_ACCESSORY: complianceWarningsProto.add(FrameworkStatsLog .USB_COMPLIANCE_WARNINGS_REPORTED__COMPLIANCE_WARNINGS__COMPLIANCE_WARNING_DEBUG_ACCESSORY); continue; case UsbPortStatus.COMPLIANCE_WARNING_BC_1_2: complianceWarningsProto.add(FrameworkStatsLog .USB_COMPLIANCE_WARNINGS_REPORTED__COMPLIANCE_WARNINGS__COMPLIANCE_WARNING_BC_1_2); continue; case UsbPortStatus.COMPLIANCE_WARNING_MISSING_RP: complianceWarningsProto.add(FrameworkStatsLog .USB_COMPLIANCE_WARNINGS_REPORTED__COMPLIANCE_WARNINGS__COMPLIANCE_WARNING_MISSING_RP); continue; } } return complianceWarningsProto.toArray(); } private void sendPortChangedBroadcastLocked(PortInfo portInfo) { final Intent intent = new Intent(UsbManager.ACTION_USB_PORT_CHANGED); intent.addFlags( Loading Loading @@ -1219,6 +1247,20 @@ public class UsbPortManager { } } // Need to create new version to prevent double counting existing stats due // to new broadcast private void logToStatsdComplianceWarnings(PortInfo portInfo) { if (portInfo.mUsbPortStatus == null) { FrameworkStatsLog.write(FrameworkStatsLog.USB_COMPLIANCE_WARNINGS_REPORTED, portInfo.mUsbPort.getId(), new int[0]); return; } FrameworkStatsLog.write(FrameworkStatsLog.USB_COMPLIANCE_WARNINGS_REPORTED, portInfo.mUsbPort.getId(), toStatsLogConstant(portInfo.mUsbPortStatus.getComplianceWarnings())); } public static void logAndPrint(int priority, IndentingPrintWriter pw, String msg) { Slog.println(priority, TAG, msg); if (pw != null) { Loading