File: README.md

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (25 lines) | stat: -rw-r--r-- 1,538 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
chrome/browser/ash/usb
======================

This directory contains the CrosUsbDetector, whose job it is to deal with devices that are plugged
into a chromeOS device - notifications of which come from the UsbDeviceManager Mojo service.

Once a new device has been detected, CrosUsbDetector will first query permission_broker to see if
the device is allowed - either via device policy or via the rules which can allow or deny devices
based on various characteristics. CrosUsbDetector furthermore makes a decision if a user-facing
notification (of the form 'Share with Android/Linux') should be shown, or if the device will be made
silently available via the settings pages.

If a user elects to share a device (in this case via the notification, as the settings flow is
handled elsewhere), the flow is roughly: AttachUsbDeviceToGuest() -> UnmountFilesystems() ->
OnUnmountFilesystems() -> AttachAfterDetach() -> OnAttachUsbDeviceOpened() -> DoVmAttach() ->
OnUsbDeviceAttachFinished(). A more thorough depiction of the flow can be seen below:

![Usb device share flow](cros_usb_detector_callgraph.png)

Things to note:
- permission_broker is actually asked twice if it is ok with a device being shared, once upon new
  device detection and then once more upon the request to share it / pass it through.
- CrosUsbDetector also keeps a list of USB classes which it does not wish to be passed through, and
  these are used to create an interface mask that permission_broker uses to drop those interfaces when
  passing the device through.