Commit Graph

476 Commits

Author SHA1 Message Date
a.lukianenko
d1ce8ebd20 Merge "Fixing 'No data transfer' mode in USB configuration" am: e8da6089ac am: 0df2517181 am: fb717b6ab2
am: c726e2058e

Change-Id: Ibe40e68ed21615d8fa12137ecc9e7774137fde5b
2019-07-10 10:34:23 -07:00
a.lukianenko
0df2517181 Merge "Fixing 'No data transfer' mode in USB configuration"
am: e8da6089ac

Change-Id: I7f0e03ccebb65e0c9a483adffc4af980ff164a3b
2019-07-10 09:59:06 -07:00
a.lukianenko
1357f7a70f Fixing 'No data transfer' mode in USB configuration
If 'No data transfer' mode is chosen after any other mode nothing happens,
because in case of sending 'MSG_SET_SCREEN_UNLOCKED_FUNCTIONS' message
no actions are taken to usbData.

Signed-off-by: a.lukianenko <a.lukianenko@globallogic.com>
Change-Id: I7c17a0a4275692022119a48b6d6c1550553fdceb
2019-07-05 10:03:52 +00:00
Nate Myren
26ee941461 Created developer_important notification channel
Created a high-importance developer notification channel for developer
messages that should notify the user with high importance. Assigned the
"USB debugging" permission to this channel.

Test: None
Fixes: 132904226
Change-Id: I9bc5361d806830d1820b8d998b4e0866462cdb37
2019-06-03 16:01:27 +00:00
Philip P. Moltmann
e89688fcd7 Check USB device/accessory perms with sys identity
As checking the permissions might call UsbDevice/UsbAccessory.getSerial
again, we have to make sure that in this code paths we run with the
system's identity so that we can always resolve the serial number.

Test: CtsVerifier UsbAccessory/UsbDevice test
Fixes: 117606509
Change-Id: I777be10b806ab02046f99805806ae1a16ebb0203
2019-05-28 17:51:39 +00:00
Treehugger Robot
8863583ffa Merge "Revert "Fix incorrect parsing of UVC interface descriptor"" 2019-05-24 18:20:25 +00:00
Paul Mclean
341f0934a2 Revert "Fix incorrect parsing of UVC interface descriptor"
This reverts commit b83cf0c7f1.

Reason for revert: This changes breaks connection to ALL USB Audio interface. Camera audio should be investigat

Bug: 124374863
Bug: 133501871

Change-Id: I19fed05c0b5f4227f88df3ac17ddd5ebe4246f3d
2019-05-24 17:34:32 +00:00
Ying Zheng
b024059387 Fix usb service broadcasting for automotive.
Test: build
Bug: 132373192
Change-Id: I7017cfbe6ccdfa3a015f2165d10d9104046adc55
2019-05-22 16:56:03 -07:00
Paul McLean
bfae878d6f Implement a "blacklist" for ALSA devices.
Specifically for the Sony PS4 controller.
Bug: 129697606
Test: Build, install, plug in PS4 contoller, note audio continues to route to device speaker.

Change-Id: I20f5cafb616b4a673772f8e4614e1efa8ae0edb4
2019-05-09 08:43:09 -06:00
Treehugger Robot
74458cbdf0 Merge "Fix incorrect parsing of UVC interface descriptor" 2019-05-07 19:11:33 +00:00
Priyank Singh
41efb403c8 "Charging this device via USB" notification isn't relevant for automotive.
Bug: 124302589
Test: Manual
Change-Id: Icaa56c5f9ead79ce0306a95229f915073d1b6a1f
2019-04-15 16:59:18 +00:00
Badhri Jagan Sridharan
883c2a4bef Only re-enable contaminant detection when port is present
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
2019-04-01 12:17:03 -07:00
Kamen Kirov
b83cf0c7f1 Fix incorrect parsing of UVC interface descriptor
Every USB device that has CS_INTERFACE descriptor was incorrectly
assumed to be an UAC device, without checking the device class.
This led to incorrect parsing of UVC devices, which also have
CS_INTERFACE type descriptors. For some devices the parsing worked
by coincidence, for others it lead to incorrect device data (wrong
vid, pid, etc).

This change parses every CS_INTERFACE descriptor that does not belong
to an UAC device as type 'Unknown'.

Test: Connect a UVC camera, observe logcat.  Before this change, there
were lots of parsing errors in logcat, now the device is added cleanly.

Bug: 124374863
Change-Id: Ic076438625a733cffa9ae51ba803e353fd064ceb
Signed-off-by: Kamen Kirov <knk@pupil-labs.com>
2019-03-29 18:10:27 +00:00
Badhri Jagan Sridharan
ac294d7ce3 Fix missing combination check SINK/DEVICE
While checking for possible role combinations, the SINK/HOST combination
seems to be mistakenly checked twice intead of SINK/DEVICE.
This CL fixes this. The code now checks for:
1. source & host
2. sink & host
3. source & device
4. sink & device

Bug: 119142682
Change-Id: I5e652fbf9313bd2c122fe728d58e577085632253
Merged-In: I5e652fbf9313bd2c122fe728d58e577085632253
2019-03-26 23:32:27 +00:00
TreeHugger Robot
dec2604a16 Merge "Fix missing combination check SINK/DEVICE" 2019-03-26 23:29:25 +00:00
Badhri Jagan Sridharan
665eb216e5 Fix missing combination check SINK/DEVICE
While checking for possible role combinations, the SINK/HOST combination
seems to be mistakenly checked twice intead of SINK/DEVICE.
This CL fixes this. The code now checks for:
1. source & host
2. sink & host
3. source & device
4. sink & device

Cherrypicked from aosp:
https://android-review.googlesource.com/c/platform/frameworks/base/+/933377

Bug: 119142682
Test: Build success
Change-Id: I5e652fbf9313bd2c122fe728d58e577085632253
2019-03-26 18:50:54 +00:00
Badhri Jagan Sridharan
3df511319c UsbPortManager: Re-enable contaminant detection when port is unplugged
SystemUI disables contaminant detection when user wants to continue
using the port. Re-enable contaminant detection when the accessory
is unplugged.

Bug: 128534822
Test: Tested with the mock circuit.
Change-Id: I22a3c839264876409c68c6a3145c9fcc6278f381
2019-03-15 16:28:22 -07:00
Badhri Jagan Sridharan
26c490c568 Support contaminant detection disable workflow
Do not show "Safe to use USB port" when contaminant detection is
disabled by the user.

Bug: 128534822
Test: Tested with the mock circuit.
Change-Id: Iebd12f04a6d8bfd7be5d673cf5a6742cf3d6f281
2019-03-15 16:28:22 -07:00
Badhri Jagan Sridharan
397a98c806 Refactor actions that are needed to be taken during port status changes.
For any change in port status, the following needs to be done:
1. Send port changed Broadcast
2. Log to statsd
3. Update contaminant notification.

Bug: 128534822
Test: Tested with the mock circuit.
Change-Id: I2c279a2ea0255a69c0a74a98ebf5bf680cae1fe1
2019-03-15 16:28:22 -07:00
Kiyoung Kim
5c33663bb5 Schematize ADB system properties
Properties accessed across partitions are now schematized and will
become APIs to make explicit interfaces among partitions.

Bug: 117924132
Test: m -j
Change-Id: I654c0e1f234d097a66f79ba8c019b8bebc794816
Merged-In: I654c0e1f234d097a66f79ba8c019b8bebc794816
2019-02-13 11:31:01 +09:00
Kiyoung Kim
1470f025f5 Schematize ADB system properties
Properties accessed across partitions are now schematized and will
become APIs to make explicit interfaces among partitions.

Bug: 117924132
Test: m -j
Change-Id: I654c0e1f234d097a66f79ba8c019b8bebc794816
Merged-In: I654c0e1f234d097a66f79ba8c019b8bebc794816
2019-02-12 02:58:22 +00:00
Badhri Jagan Sridharan
6f985da37f Store as V1.0 reference by default
Store IUsb as V1.0 instance by default and downcast when
calling V1.2 methods.

Bug: 123498520
Test: Checked dumpsys usb to reflect port status for
V1.0, V1.2, V1.3 implementations.
Change-Id: Id55d930252bff39b3b86283f3b6ab33a5e935b24
2019-01-29 18:42:35 -08:00
Badhri Jagan Sridharan
129c7297bb Log USB contaminant status
01-14 21:15:26.223   895  1046 I statsd  : { uid(1000) 1547529326000000000 235342687348 (117)0x10000->port0[S] 0x20000->2[I]  }
01-14 21:15:51.719   895  1046 I statsd  : { uid(1000) 1547529351000000000 260838630045 (117)0x10000->port0[S] 0x20000->3[I]  }
01-14 21:16:51.729   895  1046 I statsd  : { uid(1000) 1547529411000000000 320847794877 (117)0x10000->port0[S] 0x20000->2[I]  }
01-14 21:17:00.552   895  1046 I statsd  : { uid(1000) 1547529420000000000 329671167943 (117)0x10000->port0[S] 0x20000->3[I]  }
01-14 21:18:00.560   895  1046 I statsd  : { uid(1000) 1547529480000000000 389679730223 (117)0x10000->port0[S] 0x20000->2[I]  }

Bug: 119642987
Bug: 122595032
Test: Manually tested by running: adb shell cmd stats print-logs,
adb logcat | grep statsd | grep \(117\)

Change-Id: Idf98e4e5dfc44133112c48999eff7cccfd14550d
2019-01-23 18:41:10 -08:00
Badhri Jagan Sridharan
392b747d4b UsbContaminant dialog
Bug: 119642987
Bug: 117330206
Bug: 77606903

Test: Ran the following sequence:
1. Add simulated port: dumpsys usb add-port "matrix" ufp
2. Set contaminant present to true:
   dumpsys usb set-contaminant-status "matrix" true
   Contaminant present notifcation shows up and dialog pops up upon
   clicking the notification.
3. Set contaminant present to false:
   dumpsys usb set-contaminant-status "matrix" false
   Contaminant present notification is dismissed and the safe to use
   notification shows up.

Change-Id: I33d22caafbedb2a21a0f61f663ebddf5c9e3f84b
2019-01-23 10:43:15 -08:00
Badhri Jagan Sridharan
34d358c388 Add test commands to spoof presence of contaminants
This CL simulates contaminant presence through simulated port.

1. Add a port: dumpsys usb add-port "matrix" ufp
2. Set contaminant presence to true: dumpsys usb set-contaminant-status "matrix" true
3. Set contaminant presence to false: dumpsys usb set-contaminant-status "matrix" false

Bug: 119642987
Bug: 117330206
Bug: 77606903
Test: Made sure that dumpsys usb reflected the correct contaminant
status.
Change-Id: Iadb0ea92db65afdb25dbd32c02d9fb778bd4ec8c
2019-01-23 10:43:15 -08:00
Badhri Jagan Sridharan
cd9a661c9b Contaminant detection notification
Bug: 119642987
Bug: 117330206
Bug: 77606903

Test: Manually tested for contaminant notification to show up
Change-Id: If22215df1e6127aa67190f72328fbc32b9477bc2
2019-01-23 10:41:02 -08:00
Badhri Jagan Sridharan
e966a38b67 Support USB V1.2 HAL
USB V1.2 HAL supports contaminant detection interface.

Bug: 119642987
Bug: 117330206
Bug: 77606903

Test: Manually tested for notification pop-up
Change-Id: I304fb4933ba8b8eaa08c32c9e8c116cba7aa6380
2019-01-23 10:41:02 -08:00
Badhri Jagan Sridharan
0fbae8b3c1 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
2019-01-14 20:01:31 -08:00
Howard Yen
a41d30b5a6 Merge "Make sure mCurrentUsbFunctionsRequested flag be updated currectly"
am: 09a47331c9

Change-Id: If34a695b2a0f92b48aebbf793f562b5d5c9ad319
2019-01-14 19:43:58 -08:00
Howard Yen
d215b8218d Make sure mCurrentUsbFunctionsRequested flag be updated currectly
There is a situation that getCurrentUsbFunctions callback function will
be invoked before mCurrentUsbFunctionsRequested flag updated, thus, gadget
will be reset during boot completed. Make sure mCurrentUsbFunctionsRequested
flag be updated before getCurrentUsbFunctions callback function invoked.

Bug: 119688133
Test: Verified that gadget reset does not happen
Change-Id: Id8b58d9ccd3f62c976d1292575a06554bef622a4
Merged-In: Id8b58d9ccd3f62c976d1292575a06554bef622a4
Signed-off-by: Howard Yen <howardyen@google.com>
2019-01-07 11:41:20 +08:00
TreeHugger Robot
a79bdc0d93 Merge "Make sure mCurrentUsbFunctionsRequested flag be updated currectly" 2019-01-07 02:26:59 +00:00
Howard Yen
3b747d3138 Make sure mCurrentUsbFunctionsRequested flag be updated currectly
There is a situation that getCurrentUsbFunctions callback function will
be invoked before mCurrentUsbFunctionsRequested flag updated, thus, gadget
will be reset during boot completed. Make sure mCurrentUsbFunctionsRequested
flag be updated before getCurrentUsbFunctions callback function invoked.

Bug: 119688133
Test: Verified that gadget reset does not happen
Change-Id: Id8b58d9ccd3f62c976d1292575a06554bef622a4
Signed-off-by: Howard Yen <howardyen@google.com>
2019-01-03 23:07:41 +08:00
Philip P. Moltmann
0ee6ee0a92 Expose UsbPort and UsbPortStatus as system API
This is needed by making the setup wizard use only system-api.

Test: Built, switched USB port state
Change-Id: I8e56859a5b36e7de91691522a34f7d6f62dcbb20
Fixes: 115301401
2018-12-18 08:50:46 -08:00
Badhri Jagan Sridharan
06353c6eb5 Merge "Log UsbDeviceAttached events for Audio devices" 2018-12-11 16:40:37 +00:00
Badhri Jagan Sridharan
5ec629f020 Log UsbDeviceAttached events for Audio devices
UsbDeviceAttached is logged when the device has an audio interface.
Info such as VID, PID, whether the device has hid or mass storage
interface and the duration for which the usb device was connected
would be logged as well.

Bug: 118783261
Test: Manually tested by running: adb shell cmd stats print-logs,
    adb logcat | grep statsd | grep \(77\)
Change-Id: I57bbfd22ef377553daa113968fe53c4fe0f8e4d2
2018-12-10 17:37:27 -08:00
Inseob Kim
5b1cc27cee Revert "Revert "Schematize vold system properties""
This reverts commit 2473b08b07.

Reason for revert: Fixed build breakage
sysprop_cpp and sysprop_java directly have been linking against
libprotobuf-cpp-full and do not set proto.type field, which could
cause ASAN error due to linking against both libproto version of full
and lite.

Change-Id: I96eb47444d7b6f6b5fef092efc1514fcdd6f33b6
Merged-In: I8e04f643197b6c8a60cc38c6979e41c5de3469f5
2018-12-11 00:23:07 +00:00
Anthony Stange
2473b08b07 Revert "Schematize vold system properties"
This reverts commit 7bc31dc162.

Reason for revert: Breaking aosp_master build.

Change-Id: I34a5e9889c17e3454a0a86deabcec3c192a3da52
2018-12-07 11:43:03 +00:00
Inseob Kim
7bc31dc162 Schematize vold system properties
Properties accessed across partitions are now schematized and will
become APIs to make explicit interfaces among partitions.

Bug: 117924132
Test: m -j
Change-Id: I8e04f643197b6c8a60cc38c6979e41c5de3469f5
Merged-In: I8e04f643197b6c8a60cc38c6979e41c5de3469f5
2018-12-05 00:04:24 +00:00
Badhri Jagan Sridharan
faf6207163 Log connection duration.
last_connect_duration_millis will be set to 0 for a connect event.
last_connect_duration_millis will be set to the amount of time the port
was left connected for a disconnect event.

Bug: 118783261
Test: Manually tested by running: adb shell cmd stats print-logs,
    adb logcat | grep statsd | grep \(70\)
Change-Id: Ifd1df55fb6317e789a2b04236ce0a6e4665e3664
2018-12-04 12:14:12 -08:00
Badhri Jagan Sridharan
223b3c7999 Log UsbConnectorStateChanged events
The following would the logged:
1. Status of the connection - connected/disconnected.
2. Port id as a device could have multiple ports.

Bug: 118783261
Test: Manually tested by running: adb shell cmd stats print-logs,
adb logcat | grep statsd | grep \(70\)
Change-Id: Ideea36c7745293f5b6ec9cc35fd5f709f5175d5a
2018-12-04 10:14:14 -08:00
TreeHugger Robot
d1b8392a5b Merge "Check for preexisting flag before enabling the gadget" 2018-11-09 20:02:24 +00:00
Badhri Jagan Sridharan
222ed0fcf0 Check for preexisting flag before enabling the gadget
onRegistration callback gets triggered as soon has the
serviceNotification object is registered with registerForNotifications.
The preexisting flag in the callback is set if the gadget hal service dies
and restarts. Use this to differentiate between the onRegistration call
for the registerForNotifications vs actual gadget hal service restart.
Do not reset usb gadget if the onRegistration callback is called as a
result of registerForNotifications. This will overcome the occasional
reset of the usb gadget hence the connection during phone bootup.

Bug: 118678530
Test: Verified that gadget reset does not happen
Change-Id: I3b94e55289bb3a53eb9e083177fd4d54bec5f4da
2018-11-09 17:54:40 +00:00
Philip P. Moltmann
36f03d9d82 Pass down uid into requestPermissionDialog
As it is cleared further up in the call stack.

Test: Requested usb-device permissions from an app
Change-Id: Ib0e2b264086238785562f6f9da4800fb8f0a1590
2018-11-07 16:38:20 -08:00
Kenny Root
a5964c08bc Move AdbDebuggingManager to AdbService
Also remove the "Usb" from the AIDL function since it's not really
related to USB.

Test: make
Bug: 63820489
Change-Id: Ibf23964665a115a5bc835820dcff98aaf7ba610f
2018-10-31 16:11:02 +09:00
Kenny Root
473121834b AdbService: move source of truth for enabled
This makes the AdbService the source of truth for whether ADB is enabled
on the system or not. All UsbManager checks will now query the
AdbService.

Test: make
Bug: 63820489
Change-Id: I2965a15b5fa9f747fe0ae4dc791b5e357e78253f
2018-10-31 16:11:02 +09:00
Kenny Root
33504d7d4f Register USB as an ADB transport type
This doesn't do anything yet, but is needed to migrate functionality
from the USB service to the ADB service.

Bug: 63820489
Test: make
Change-Id: I402bb234a055cf0b199e0922bf92736aa659d46a
2018-10-31 16:11:01 +09:00
Kenny Root
8429eb923e Move ADB debugging manager to core
This service should not be in the USB module anymore. Move it to the
core services.

Bug: 63820489
Test: make
Change-Id: I6e07b8e3aa29fbd9d30d130ef0c882a84a12d30c
2018-10-31 16:11:01 +09:00
Kenny Root
7c4e66190e Rename to AdbDebuggingManager
Rename the UsbDebuggingManager to AdbDebuggingManager. It doesn't
technically depend on the USB stack, so rename to make the lack of
association more clear.

Bug: 63820489
Test: make
Change-Id: Ife83d3ec9701882781f5a9562ccc5435d51d246b
2018-10-31 16:11:01 +09:00
Kenny Root
e0e84084f0 Move UsbDebuggingManager to new package
First step in separating the USB and ADB stacks. The ADB functionality
does not logically need USB, so move it to its own package initially to
make further detangling more clear.

Bug: 63820489
Test: make
Change-Id: I6cf57c4ebc6ec8956cdd7ce817bdc4bcf7ff27a9
2018-10-31 16:11:01 +09:00
Pavel Maltsev
d530d10291 Fix security exception when reading usb serial num
Bug: 117881221
Test: run projection on mojave board
Change-Id: Ife4c5e18b6d8f7c20b363f40119dfefd8ab008ef
2018-10-17 16:38:39 -07:00