Commit Graph

502 Commits

Author SHA1 Message Date
Evan Severson
94eb30a017 Make UsbService boot async with rest of system server
Test: Boot device multiple times
Fixes: 140242135
Change-Id: Ifc114b29fbcf10a7f8c6d667975fa2bb4dffd651
2020-01-17 12:51:24 -08:00
Pavel Maltsev
15b7ce5610 Merge "Fix UsbSerialReder for multi-user" 2019-12-17 19:28:13 +00:00
Pavel Maltsev
068713f60c Fix UsbSerialReder for multi-user
When UsbSerialReader checks for package it needs to request package for
the calling user, because UsbSerialReader runs in system_proccess under
u0 and the calling package may not be installed for that user.

Fixes: 146079090
Test: flash and verify that UsbDevice#getSerial() returns correct string
(used to return null before the fix)

Change-Id: I637673165dd364f4728e587a59897184ea5b5620
2019-12-13 14:29:06 -08:00
Winson Chung
f2b41770d4 Remove a few hard coded references to SystemUI in fw/base/services
Bug: 143775123
Test: atest ScreenshotHelperTest
Test: atest AlarmManagerTest
Change-Id: I2fefe2968e23bc2d06aa52266c2eeeb90f4733ee
2019-12-13 13:59:31 -08:00
Jiyong Park
bae2e90796 Add filegroups for services.* libraries
... in preparation for creating a stub library from services.jar

Bug: 139391334
Test: m
Change-Id: Ifd6cfc77acf2284804a2f64011c2733b5c222369
2019-11-17 14:05:08 +09:00
Emilian Peev
f7824ac70d Use correct calling identity during camera permission check
UVC clients need to acquire the CAMERA permission
before trying to call open. The permission check is
currently done via calls to "checkCallingPermission".
In case the calling identity gets cleared, the check
will always fail. To resolve this, use "checkPermission"
with appropriate identity arguments.

Bug: 144433314
Test: Manual using application,
CtsVerifier USB Device test

Change-Id: I5318fbb4426bec1448ecc398c86ea96500bb3189
2019-11-13 14:16:12 -08:00
Evan Severson
6fd44ac0a4 Add persistent permissions to dumpsys usb
Test: adb shell dumpsys usb
Change-Id: Iae909e359ac366bdb8d48479f5ff7100f6ae1747
2019-10-24 14:22:20 -07:00
Paul McLean
a7e7f94f98 Add video class-specific descriptors to UsbDescriptorParser framework.
Also add mHasVideoCapture and mHasVideoPlayback members to UsbDevice.

Bug: 142321590

Test: Build, flash, connect USB Video Camera, examine logs
Change-Id: Ia6ae687182ec0b007c1688478545829395191984
2019-10-18 11:08:52 -06:00
Paul McLean
9bd2f89fff Add "HasMidi" capability (attribute) to UsbDevice.
Bug: 142158212
Test: build, install, connect USB device and examine log.
Change-Id: Ic94891f4c4f845592009e9465b7ad17fd0c76b2e
2019-10-04 20:15:33 -06:00
Paul McLean
d336453217 Adding additional prompt to UsbPermissionsDialg for audio devices.
To support, adding members to UsbDevice to mark devices as having audio
playback and audio capture capabilities.

Bug: 136080195
Test: Run "UsbAccess" test bed. Connect audio and non-audio USB devices
and see the additional prompt shown/not-shown.

Change-Id: Ie7c614d9ed30a163c350b18a54b8a9115698779d
2019-10-03 11:54:05 -06:00
Evan Severson
d9f045ebac Usb launch preference denial able to be remembered
When a device is connected the user might be prompted with
a dialog to launch an application. This change creates the
api that the system UI will use to give the user a
"deny [for this device+package] and remember" option.

Test: Manual:
      Edit usb_device_manager.xml and observe correct behavior
      Call new methods and observe correct changes in xml file
Bug: 136496922

Change-Id: I20e377d601ec11b8d42c79e4c726b9a4cb68c8b0
2019-09-14 03:46:30 +00:00
Paul McLean
64aee9106e Restrict enumeration of USB Audio Interfaces
Bug: 136083296
Test: build, flash, connect USB interface, examine logs
Test: No regressions for normal audio playback w/ Presonus, USB-C
Headset.

Note that since this ONLY modifies the interfaces enumerated in the
UsbHost API, it has no effect on normal, framework access to USB Audio.

Change-Id: Ib7d4c83744dfb0961360749c01b008aa9ab9baa2
2019-09-05 13:08:20 -06:00
Evan Severson
7b78bbd0fa Implement persistent permissions for Usb devices
Previously a package could only get automatically granted USB
permission for a given device if it was the default app to launch
when the device is connected. This means only one package can
be granted automatically and it must be started on connection.

This change introduces a new usb permission mechanism which is meant
to separate the auto launch from usb permission so that multiple
packages can have permission without prompting the user.
The temporary usb permissions still work.

Test: edit usb_permissions.xml on device to allow, reboot,
      connect usb headphones, deny launch dialog, open test app,
      assert usb permission already granted.
Test: Check complement behavior to previous test, assert permission
      not granted by default if not in usb_device_manager.xml or
      explicitly denied in usb_device_manager.xml.
Bug: 136496922
Change-Id: I005d7470f1e6642d683c953a914f65f16ff7e1bb
2019-08-30 12:45:44 -07:00
Evan Severson
9727c0581a Merge "Separate Usb permissions from Usb settings" 2019-08-23 16:51:16 +00:00
Evan Severson
e05005b18f Separate Usb permissions from Usb settings
Test: Manual
Change-Id: I4c6b1c309ad7204a4475838abded47c595ff331e
2019-08-22 14:23:16 -07:00
Paul McLean
a51ae9b5ab Fixing UsbDescriptorParser errors associated with video cameras.
Added framework to (eventually) parse video interface descriptors,
but at least not report errors/warnings when encountering them.

Centralizing control of logging towards making it a run-time option.

Bug: 124374863
Test: build, flash, connect USB device, pull and examine log...
run "adb shell dumpsys usb dump-descriptors -dump-list",
examine output, use device with JavaRecorder app.

Change-Id: I5d039b51c321d6ceb33a803f78e71f00908f1d69
2019-08-21 14:14:32 -06:00
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