Log all Usb accessories

Logs when connecting/disconnect thumbdrive.

01-14 19:58:45.370   918  1009 I statsd  : { uid(1000) 1547524725000000000 338323224430 (77)0x10000->1921[I] 0x20000->21889[I] 0x30000->0[I] 0x40000->0[I] 0x50000->1[I] 0x60000->0[I] 0x70000->10724[L]  }
01-14 20:00:27.471   918  1009 I statsd  : { uid(1000) 1547524827000000000 440424268612 (77)0x10000->1921[I] 0x20000->21889[I] 0x30000->0[I] 0x40000->0[I] 0x50000->1[I] 0x60000->1[I] 0x70000->0[L]  }
01-14 20:00:36.198   918  1009 I statsd  : { uid(1000) 1547524836000000000 449151666148 (77)0x10000->1921[I] 0x20000->21889[I] 0x30000->0[I] 0x40000->0[I] 0x50000->1[I] 0x60000->0[I] 0x70000->8727[L]  }
01-14 20:00:39.401   918  1009 I statsd  : { uid(1000) 1547524839000000000 452354416467 (77)0x10000->1921[I] 0x20000->21889[I] 0x30000->0[I] 0x40000->0[I] 0x50000->1[I] 0x60000->1[I] 0x70000->0[L]  }
01-14 20:00:48.348   918  1009 I statsd  : { uid(1000) 1547524848000000000 461301290587 (77)0x10000->1921[I] 0x20000->21889[I] 0x30000->0[I] 0x40000->0[I] 0x50000->1[I] 0x60000->0[I] 0x70000->8947[L]  }

Bug: 120566491
Test: Manually tested by running: adb shell cmd stats print-logs,
    adb logcat | grep statsd | grep \(77\)
Change-Id: I172964ad592b910fcadf88c84f9cbd9d47f44131
This commit is contained in:
Badhri Jagan Sridharan
2019-01-14 19:02:34 -08:00
parent 018edf2cb5
commit 0fbae8b3c1

View File

@@ -418,12 +418,10 @@ public class UsbHostManager {
parser.getRawDescriptors());
// Stats collection
if (parser.hasAudioInterface()) {
StatsLog.write(StatsLog.USB_DEVICE_ATTACHED, newDevice.getVendorId(),
newDevice.getProductId(), parser.hasAudioInterface(),
parser.hasHIDInterface(), parser.hasStorageInterface(),
StatsLog.USB_DEVICE_ATTACHED__STATE__STATE_CONNECTED, 0);
}
StatsLog.write(StatsLog.USB_DEVICE_ATTACHED, newDevice.getVendorId(),
newDevice.getProductId(), parser.hasAudioInterface(),
parser.hasHIDInterface(), parser.hasStorageInterface(),
StatsLog.USB_DEVICE_ATTACHED__STATE__STATE_CONNECTED, 0);
}
}
@@ -455,14 +453,12 @@ public class UsbHostManager {
if (current != null) {
UsbDescriptorParser parser = new UsbDescriptorParser(deviceAddress,
current.mDescriptors);
if (parser.hasAudioInterface()) {
// Stats collection
StatsLog.write(StatsLog.USB_DEVICE_ATTACHED, device.getVendorId(),
device.getProductId(), parser.hasAudioInterface(),
parser.hasHIDInterface(), parser.hasStorageInterface(),
StatsLog.USB_DEVICE_ATTACHED__STATE__STATE_DISCONNECTED,
System.currentTimeMillis() - current.mTimestamp);
}
StatsLog.write(StatsLog.USB_DEVICE_ATTACHED, device.getVendorId(),
device.getProductId(), parser.hasAudioInterface(),
parser.hasHIDInterface(), parser.hasStorageInterface(),
StatsLog.USB_DEVICE_ATTACHED__STATE__STATE_DISCONNECTED,
System.currentTimeMillis() - current.mTimestamp);
}
} else {
Slog.d(TAG, "Removed device at " + deviceAddress + " was already gone");