576 Commits

Author SHA1 Message Date
James Wei
2688557ea7 USB: Add OWNERS for USB functionality
Add and update active owners

Bug: 151289514
Test: build/make/tools/checkowners.py -c -v OWNERS
Change-Id: Ifed67825df464b86e12c63193b6b54692ac4de7c
2020-03-12 17:12:17 +08:00
Puma Hsu
e177e7bd42 Fix function setting failed in Developer options
One can select USB function in Settings->System->
Developer options->Default USB configuration without
a cable connected, and the selected function will be
the default function after re-connecting. However, this
function might be restored to NONE due to ENUMERATION_TIMEOUT
if one selected the function without a cable connected.

When the device is not connected to a host, we should not
queue the ENUMERATION_TIMEOUT while switching function.
Fix it by checking connected status and also make it switch
to corresponding function if an user has selected one in the
Default USB configuration.

Bug: 150422683
Test: Switch functions from Default USB configuration for the
both cases cable connecting and disconnecting. And also try it
while there is the secure lock.
Signed-off-by: Puma Hsu <pumahsu@google.com>
Change-Id: I1933c098e47496b8d6813a5a4e295bcf12027401
2020-03-10 17:36:16 +08:00
Automerger Merge Worker
721f99b99f Merge changes I36c6ef4b,I3c31394e am: be0d76d382
Change-Id: I60549c067c76bd2755150e1f920c4bd5624ce741
2020-02-26 21:52:13 +00:00
Joshua Duong
eb6e5bc47b Allow UsbDeviceManager to start adbd again.
There's some weird state where if persist.sys.usb.config=none,adb, then
adbd won't get started. Give back adbd start permissions to
UsbDeviceManager to see if that fixes the issue.

Bug: 150130503

Test: adb shell su 0 setprop persist.sys.usb.config none,adb; adb reboot
adb should be online after.

Change-Id: I36c6ef4b20d58570a2d51ed70088ae5c54d6687d
Merged-In: I36c6ef4b20d58570a2d51ed70088ae5c54d6687d
Exempt-From-Owner-Approval: Fix adbd offline failure
2020-02-26 08:33:19 -08:00
Joshua Duong
ac29885a0e Allow UsbDeviceManager to start adbd again.
There's some weird state where if persist.sys.usb.config=none,adb, then
adbd won't get started. Give back adbd start permissions to
UsbDeviceManager to see if that fixes the issue.

Bug: 150130503
Bug: 150116813

Test: adb shell su 0 setprop persist.sys.usb.config none,adb; adb reboot
adb should be online after.

Change-Id: I36c6ef4b20d58570a2d51ed70088ae5c54d6687d
Exempt-From-Owner-Approval: Fix adbd offline failure
(cherry picked from commit 7a3800993df55f87ce6493bf304730b9ffd91ad5)
2020-02-26 16:26:39 +00:00
Felipe Leme
339b7149af Improved user callbacks on SystemService:
* Renamed:

  onStartUser() -> onUserStarting()
  onStopUser() -> onUserStopping()
  onSwitchUser() -> onUserSwitching()
  onUnlockUser() -> onUserUnlocking()
  onCleanupUser() -> onUserStopped()
  isSupportedUser() -> isUserSupported()

* Added:

  onUserUnlocked()

Tested on automotive, which uses the callbacks to dump user metrics:

$ adb shell dumpsys car_service --user-metrics
adb shell dumpsys car_service --user-metrics
* User Metrics *
  no users starting
  no users stopping
Last 10 started users
  2020-02-21T19:44:47.101 - user=0 start=2020-02-21 19:44:45.357 unlocking=+885ms unlocked=+1s122ms
  2020-02-21T19:44:56.376 - user=10 start=2020-02-21 19:44:47.380 switch=+209ms unlocking=+8s262ms unlocked=+8s994ms
  2020-02-21T20:00:08.792 - user=11 start=2020-02-21 20:00:04.634 switch(from 10)=+351ms unlocking=+4s44ms unlocked=+4s156ms
Last 10 stopped users
  2020-02-21T20:00:48.323 - user=10 stop=2020-02-21 20:00:16.741 shutdown=+31s581ms

Test: m update-api
Test: atest BackupManagerServiceTest
Test: manual verification (see above)
Fixes: 150001654

Exempt-From-Owner-Approval: approved on master right before rvc split

Merged-In: I8774c57620030b9aa8e7ec039a6a758ad56db368
Change-Id: I8774c57620030b9aa8e7ec039a6a758ad56db368
(cherry picked from commit 58e7458ac7204992c5408eb2d6420d767afc4eb8)
2020-02-24 16:44:52 +00:00
Automerger Merge Worker
b42dfed0f4 Merge "[adbwifi] Make AdbManager changes for adb over WiFi." am: b9f266d97c
Change-Id: Id8571a8db96770cd699a71c5fcb50fb58c8e511b
2020-02-22 15:30:26 +00:00
Joshua Duong
f24fb19dbf [adbwifi] Make AdbManager changes for adb over WiFi.
This CL has a couple of notable changes:
- Add communication layer between adbd, system server, and Settings UI
- Add system notification (Wireless debugging connected) when at least
  one device is connected.
- Add trusted networks (BSSID) to the keystore.
  - Changed the keystore format to:
    <keyStore version="1">
    <adbKey ... />
    <wifiAP ... />
    </keyStore>
 - Currently, trusted networks don't have a expiration time. Also, only
   way to clear it is by blowing up the keystore (revoke permissions).
- Add pairing mechanism:
  - Using libadbwifi_pairing_connection C++ library to pair a device
    using SPAKE2 protocol over TLS.
  - Register MDNS service for client discovery.
- Removed ability to ctl.start/stop adbd from UsbDeviceManager
  - AdbService now controls when to do this

Bug: 111434128, 119490154, 119492574

Test: Manual. From developer options:
1) USB debugging off, WiFi Debugging off
- Ensure both transports are disabled by trying to connect via WiFi and
USB.
2) USB debugging on, WiFi Debugging off
- Connections via USB are available, WiFi is disabled
3) USB debugging off, WiFi Debugging on
- Connections via WiFi are available (IP + port), USB is not available
4) USB debugging on, WiFi Debugging on
- Check both transports work

Change-Id: I9f87679d195da99a55b6faf7131da1f1af65fe01
Exempt-From-Owner-Approval: approved in aosp master
(cherry picked from commit a5969b5a1d9fe08783c32ea23bead56252a74383)
2020-02-22 15:15:10 +00:00
Joshua Duong
6f3aaaa5f7 [adbwifi] Make AdbManager changes for adb over WiFi.
This CL has a couple of notable changes:
- Add communication layer between adbd, system server, and Settings UI
- Add system notification (Wireless debugging connected) when at least
  one device is connected.
- Add trusted networks (BSSID) to the keystore.
  - Changed the keystore format to:
    <keyStore version="1">
    <adbKey ... />
    <wifiAP ... />
    </keyStore>
 - Currently, trusted networks don't have a expiration time. Also, only
   way to clear it is by blowing up the keystore (revoke permissions).
- Add pairing mechanism:
  - Using libadbwifi_pairing_connection C++ library to pair a device
    using SPAKE2 protocol over TLS.
  - Register MDNS service for client discovery.
- Removed ability to ctl.start/stop adbd from UsbDeviceManager
  - AdbService now controls when to do this

Bug: 111434128, 119490154, 119492574

Test: Manual. From developer options:
1) USB debugging off, WiFi Debugging off
- Ensure both transports are disabled by trying to connect via WiFi and
USB.
2) USB debugging on, WiFi Debugging off
- Connections via USB are available, WiFi is disabled
3) USB debugging off, WiFi Debugging on
- Connections via WiFi are available (IP + port), USB is not available
4) USB debugging on, WiFi Debugging on
- Check both transports work

Change-Id: I9f87679d195da99a55b6faf7131da1f1af65fe01
Merged-In: I9f87679d195da99a55b6faf7131da1f1af65fe01
Exempt-From-Owner-Approval: already approved
2020-02-22 01:37:05 +00:00
Automerger Merge Worker
4471500ebe Merge "Add AdbTransportType.aidl. Add AdbWifi internal API stubs." am: c5cb13899d am: 44cf122df0 am: 21e272d52e
Change-Id: Ic09de8f7f6a064ccfa11654f7a5833b1ebfa490a
2020-02-19 23:07:19 +00:00
Automerger Merge Worker
44cf122df0 Merge "Add AdbTransportType.aidl. Add AdbWifi internal API stubs." am: c5cb13899d
Change-Id: I362b91ae3dd8cd2b696525e23ede9f3cb6c2f5d9
2020-02-19 02:52:39 +00:00
Joshua Duong
b401e0a8bb Add AdbTransportType.aidl. Add AdbWifi internal API stubs.
Since wireless debugging can be enabled without usb debugging enabled,
we'll need to differentiate between which transport is enabled.

Also added the internal AdbManager stubs for wireless debugging. Adding
implementation in separate CL to get around merge conflict with a SysUI
CL in the stack.

BUG: b/111434128

Test: make
Exempt-From-Owner-Approval: already approved
Change-Id: I4e1ae6398f291f321e61e7eb119564ebd5e54c2e
2020-02-19 02:41:21 +00:00
Howard Ro
8ac84650bd Merge "Use FrameworkStatsLog instead of StatsLog" 2020-01-30 21:47:48 +00:00
Paul Mclean
e37a75ccae Merge "Replace parsing error stack dump with a more terse message" 2020-01-30 18:38:13 +00:00
Muhammad Qureshi
d0cbebc8fe Use FrameworkStatsLog instead of StatsLog
As part of statsd becoming a Mainline module in R, autogenerated
StatsLog.write() calls are going away and replaced by
*StatsLog.java
that is autogenerated for each module.
This CL replaces some usages of StatsLog with
FrameworkStatsLog.

Bug: 145952197
Test: m
Change-Id: Ic3b9d02ee33e8d94fdbe4e324ceb6db13fe3d2dc
2020-01-29 17:21:16 -08:00
Paul McLean
c9b7cb2fc2 Replace parsing error stack dump with a more terse message
Bug: 147608995
Test: boot, connect PreSonus AudioBox 22VSL, pull log and examine.
Change-Id: I49629267c91cea5d6ba8a76af956cd3306c1d8b1
2020-01-29 15:58:57 -07:00
Evan Severson
64a3827f3a Fix usb not working for work profile
Fixes: 148283143
Test: Manual
Change-Id: Ib478b57e58bd162da92cf3e1829d05f4943c0be1
2020-01-24 10:03:32 -08:00
Howard Yen
ba5a535640 Merge changes from topic "usb_gadget_reset"
* changes:
  Add svc usb resetUsbGadget method
  Support USB Gadget V1.1 HAL
2020-01-22 20:56:44 +00:00
Daulet Zhanguzin
ac8f29e9a8 Replace com.android.internal.util.Preconditions.checkNotNull with
java.util.Objects.requireNonNull

Bug: 126528330

Test: Treehugger
Exempt-From-Owner-Approval: Global refactoring.
Change-Id: Iae0d413db1e0d5bd3c7ee8fe5237b0bff909aaa0
2020-01-22 09:35:14 +00:00
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
Howard Yen
db8f11654b Support USB Gadget V1.1 HAL
USB Gadget V1.1 HAL supports USB port reset interface.

Bug: 138702846
Test: build pass, function works
Change-Id: Ia4b3b85bb0ce74307599832f849d3e23c2546187
2020-01-17 22:23:12 +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
Automerger Merge Worker
506fdff8c3 Merge changes from topic "services_stub" am: 34e4b2c3ab am: 776b4544fe
Change-Id: I284b912dc36547530a7beeb4ccc441c8270d9131
2019-12-13 08:17:05 +00:00
Automerger Merge Worker
e45598e00d Merge "Use correct calling identity during camera permission check" into qt-qpr1-dev am: 197a9ad1d3
Change-Id: Iee8e483a5ec9225d96ad8690efdcfa2d5f096567
2019-12-12 20:15:46 +00:00
Jiyong Park
e86e89acff Add filegroups for services.* libraries
... in preparation for creating a stub library from services.jar

Bug: 139391334
Test: m

Exempt-From-Owner-Approval: cherry-pick from internal

Merged-In: Ifd6cfc77acf2284804a2f64011c2733b5c222369
(cherry picked from commit bae2e907966dce0cb3eaf3e3a81cca4364b7d941)
Change-Id: Ifd6cfc77acf2284804a2f64011c2733b5c222369
2019-12-11 15:55:33 +09: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
abe984f550 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
Merged-In: I5318fbb4426bec1448ecc398c86ea96500bb3189
2019-11-13 16:19:29 -08: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 b83cf0c7f14a05a4ba9fef5aa0f95cdb75bc9b28.

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