370 Commits

Author SHA1 Message Date
Paul McLean
fd47f4032d Checking for errors opening/parsing ALSA "cards" file.
Test: Manual
Bug: 67590842

Change-Id: I62a5da97776bc7b7f03d3883cb06607cbdf6f6ce
2017-10-12 10:53:03 -06:00
Paul McLean
50f8bbb9cf Catch IO Exception in UsbDevicesParser and don't add failed devices.
Note: This is related to bug 66988327, but NOT a fix for it.

Bug: 66988327
Test: Manual
Change-Id: Ib9ccaa9634c7fc011f70513d5589870e9190418a
2017-10-05 15:28:20 -06:00
Paul McLean
aa12c85c98 Merge "Add dump of USB descriptors to the dumpsys for UsbHostManager service." into oc-mr1-dev am: e7b8f6d24a
am: a3841871a3

Change-Id: Idcbb5dd875ec1afcf4250b641e707cc9f2115e10
2017-09-06 01:59:32 +00:00
Paul McLean
53215d1f7d Add dump of USB descriptors to the dumpsys for UsbHostManager service.
Cleaned up text formatting.

Bug: 65158441
Change-Id: Ie6531d42bb0d78f2b8af382329a973e629f23c5f
Test: Manual - connected USB headset, ran adb shell dumpsys usb. Examined output.
2017-09-05 14:30:01 -06:00
Paul Mclean
6598a033ab Merge "Adding USB audio-class 2.0 spec descriptors." into oc-mr1-dev am: 87cb6d806e
am: ea09d76403

Change-Id: I777211f0a458b256cfc884c64df29bd5fed0b84a
2017-08-30 23:13:35 +00:00
Paul Mclean
87cb6d806e Merge "Adding USB audio-class 2.0 spec descriptors." into oc-mr1-dev 2017-08-30 22:13:36 +00:00
Paul McLean
fd7cb85fef Adding USB audio-class 2.0 spec descriptors.
Added USB audio-class 2.0 format type descriptors.
Added Tree parsing.
Rearchitected reporting (again) to better support reuse and scale.

Bug: 64301464

Test: Run code against representative USB audio peripherals and verify
that each correctly handles or ignores all descriptors and the correct
device semantics (headset / not-headset) are still calculated.

Change-Id: I1b3b01ab1cd804ed876bf6427c3afba15eea6a6e
2017-08-30 10:29:16 -06:00
Jerry Zhang
29b3cfa21d Merge changes from topic "am-2cfb180af8604b6fac1598107a7b546e" into oc-mr1-dev-plus-aosp
am: 54c6447f47

Change-Id: I13aeac421ecf7a54f16e0fd6aaa19be3f513be4a
2017-08-24 23:10:06 +00:00
Jerry Zhang
e537a83139 Reset functions to null when user changes.
When MTP or PTP is in the config and user changes,
it clears dataUnlocked but sets the functions to
mCurrentFunctions which will leave MTP or PTP in the
config. If dataUnlocked is false, we want to remove
MTP/PTP from the config when adb is enabled, and leave
them in otherwise. This is done automatically by
setting functions to null.

Bug: 64822515
Test: Change users while adb  / mtp connected.
Change-Id: I82561f82e06f247c967438a473b08b5098d39ccb
2017-08-23 11:10:44 -07:00
Badhri Jagan Sridharan
83a0d6fa57 Overcome disconnect during oem override
While bootup, usb gets configured when the property triggers are
run. While in oemOverride, the current configuration is persisted
in sys.usb.<bootmode>.config. Do not reconfigure the stack if the
current configuration is same as the new configuration.

Bug: 64225494
Change-Id: Id35d110bf3fa8f58d05e14941716d4ad2b196f8d
2017-08-18 17:26:05 -07:00
Badhri Jagan Sridharan
e15b5619c5 Merge "Reword analog audio not supported notification" into oc-dr1-dev am: 69840ca338
am: 89163cf020

Change-Id: Idf481243ae12d62e2fe492d7834ef0d8e7476a04
2017-08-01 19:15:49 +00:00
Badhri Jagan Sridharan
fb80072f99 Merge "Reword analog audio not supported notification" into oc-dr1-dev
am: 69840ca338

Change-Id: I6a9a611c13de7a63e6d5bdbf4718827f2295a28b
2017-08-01 19:03:55 +00:00
TreeHugger Robot
69840ca338 Merge "Reword analog audio not supported notification" into oc-dr1-dev 2017-08-01 18:51:53 +00:00
Paul Mclean
09acfdf0c7 Merge "Fix exceptions causing HTC dongle (and JBL headset) to fail connection logic." into oc-dr1-dev am: f3562ffdfb
am: 3e62b611f0

Change-Id: I4d5c511c043048e79b4846febda85f521fb59f31
2017-08-01 15:43:51 +00:00
Paul Mclean
18d64cf8fe Merge "Fix exceptions causing HTC dongle (and JBL headset) to fail connection logic." into oc-dr1-dev
am: f3562ffdfb

Change-Id: I0304bf7c72a340f4bebebea89d2e934ae5830b33
2017-08-01 15:35:05 +00:00
Badhri Jagan Sridharan
30c8efa66b Reword analog audio not supported notification
New title: Analog audio accessory detected
New message: The attached device is not compatible with this
phone. Tap to learn more.

Also switch to bigTextStyle as the notification message
takes more than one line to display.

Bug: 63962800
Test: Attached analog audio accessory to verify the notification
manually. Also verified that the charging notification remians
untouched.
Change-Id: I5c395bdf3c3dd11f3be8835ec773f087afdc85d9
2017-07-31 17:05:17 -07:00
Paul McLean
7d545bef60 Fix exceptions causing HTC dongle (and JBL headset) to fail connection logic.
Bug: 64108509
Test: Manual

Change-Id: I9574f34cea4ff9ef3e18553a138f1a8b95b1b108
2017-07-28 17:47:54 -07:00
Badhri Jagan Sridharan
1e249aeafa Merge "Always reevaluate whether to show the notification for USB_DEVICE_* intents" into oc-dr1-dev am: d5f442d65b
am: 19ad4c2055

Change-Id: I4b6edbefd70585302959aa830f5a6d50f4f01a4d
2017-07-19 18:16:40 +00:00
Badhri Jagan Sridharan
5e79cbb291 Always reevaluate whether to show the notification for USB_DEVICE_* intents
The decision whether to show or hide the "Usb supplying power.."
notification is based on two different broadcasts
1. USB_DEVICE_ATTACHED/DETACHED
2. USB_PORT_CHANGED

Depending on how long the port takes to enumerate, the required
intents might arrive in different order. Previously, it was assumed
that the ATTACHED broadcast would arrive before the PORT_CHANGED
broadcast and the code was aggressive to reduce the number of
times the decision to display/hide the notification is made.
This might cause the notification to be displayed in some instances
when it is not supposed to be displayed. This CL makes the usb service
to always reevaluate whenever USB_DEVICE_ATTACHED/DETACHED is
received.

Also, adding logs to print whenever the notification in enqueued/
dequeued.

Bug: 63785369
Test: Verified that the notification is displayed when connecting
to another pixel device and hidden when mouse or headset is
connected.
Change-Id: I30650a2d9923d01a1fce4b9450e65ec7f4e6557b
2017-07-18 17:44:47 -07:00
Paul McLean
39c9e18721 Merge "More fine-grained exception handling so we can still use non-excepting descriptors." into oc-dr1-dev am: 84a60bf9e8
am: 6899fa6c81

Change-Id: Ic70707c334e9765e7f196bdcb0d2d753ce17b0fb
2017-07-13 18:09:17 +00:00
Paul McLean
20568917af More fine-grained exception handling so we can still use non-excepting descriptors.
Bug: 63655391
Test: Manual - connect various devices and verify the connection state is correct.
Change-Id: Iae6143d2e853e916c8588e0c6f771c00714b3a8a
2017-07-13 15:53:42 +00:00
Badhri Jagan Sridharan
6276bb899e Clear mCurrentAccessory if accessory function is no longer enabled
Accessory mode implements debounce timeout ACCESSORY_REQUEST_TIMEOUT
within which when a disconnect is seen, the accessory function would
be removed from the usb configuration but mCurrentAccessory would
not be set to NULL until the timeout expires.

Also, setEnabledFunctions(null, false, false) does not force an
additional disconnect when accessory function has already been
removed from usb configuration.

BUG: 62241238
Change-Id: I25973475fb02d613e11396bcad5e88656ad8940a
2017-07-12 18:47:07 +00:00
Paul McLean
f148e8ecce Merge "Catch exception in descriptor parser causes device connection to be skipped." into oc-dr1-dev am: 22d4bf2283
am: 702d82fdc0

Change-Id: Ia45c777b095ff8c29042145fd11b29dcace24366
2017-07-11 00:58:17 +00:00
Paul McLean
b82963f3e0 Catch exception in descriptor parser causes device connection to be skipped.
Bug: 63538159

Test: Manual - force an exception and verify the the device is still available.
Change-Id: I4f4c59d4d0f73b664fac8bc74a64414d0e9d9a24
2017-07-10 14:57:20 -06:00
Jerry Zhang
b60c48a6a2 Merge "Broadcast only if boot complete" into oc-dr1-dev 2017-07-06 16:52:04 +00:00
Jerry Zhang
885b9e7133 Broadcast only if boot complete
Accessory connects / disconnects can occur before
boot complete, so don't broadcast intents if that
is the case.

Bug: 63114621
Test: connect/disconnect an accessory
Change-Id: Ib8f9eb97ce1630004511fcc1fb84594ccc812c06
2017-07-05 10:44:59 -07:00
Colin Cross
6bad7044f5 Merge changes I09ecc525,I83e7e8ef
* changes:
  Revert "Do not use lambda as it breaks javac"
  Add missing dependency to services for desugaring
2017-06-30 15:52:02 +00:00
Jerry Zhang
ed0cc81212 Merge "Broadcast only if boot complete" 2017-06-29 21:54:39 +00:00
Paul McLean
e3bb95dddb Merge "Adding USB Headset awareness." into oc-dr1-dev am: f56b57781e
am: 1ae4273154

Change-Id: I24ffbb79b965df15a22dbc5d6ce3ae90ddb27b50
2017-06-29 19:42:04 +00:00
Jerry Zhang
dc0c14f169 Broadcast only if boot complete
Accessory connects / disconnects can occur before
boot complete, so don't broadcast intents if that
is the case.

Bug: 63114621
Test: connect/disconnect an accessory
Change-Id: Ib8f9eb97ce1630004511fcc1fb84594ccc812c06
2017-06-29 11:14:30 -07:00
Colin Cross
03196cdf2e Revert "Do not use lambda as it breaks javac"
This reverts commit e37eda7b413099f881f348aeafc5d2d33639484e.

I83e7e8efdff9cd662e179240336abebedf859c62 adds the missing
dependency to let desugar work.

Bug: 63078196
Test: m -j ANDROID_COMPILE_WITH_JACK=false
2017-06-29 10:35:22 -07:00
Paul McLean
b5eaa809da Adding USB Headset awareness.
Bug: 36220140
Bug: 62043095
Test: Manual
Change-Id: Ic4636e3dc2dfce0154e6405848bea7752cf2d07b
2017-06-29 10:30:05 -06:00
Philip P. Moltmann
e37eda7b41 Do not use lambda as it breaks javac
Bug: 63078196
Test: Built
Change-Id: I6f195ad127e95b76b85ad7417f31ac19af0ac5bc
2017-06-27 23:58:33 +00:00
Philip P. Moltmann
bee04d08b5 Clean up USB*Manager.
Just automatic cleanup.

Test: Built
Change-Id: I1da09d6b43503a6b77a3619f0f8513ef39cf2d75
2017-06-26 16:04:10 -07:00
TreeHugger Robot
31f5b6875c Merge "Enable MTP or ADB when default functions are enabled" 2017-06-05 23:16:46 +00:00
Jerry Zhang
42f4815eff Merge "Remove ptp from persist config on boot" into oc-dev am: 1d1cf13056
am: 8d5570b9e1

Change-Id: I792ed0959e5a24ef8893a1bd63e3a33278462556
2017-06-05 18:54:08 +00:00
Jerry Zhang
6032c354d9 Remove ptp from persist config on boot
We got a report from a user in which ptp was set in the
persistent config, likely from a previous version.
This causes errors in the usb state and is not removed
by an ota. To fix, remove ptp in the same place that mtp
is removed from the persistent config.

Bug: 62202885
Test: Add ptp to persistent config, verify removed.
Change-Id: I5ebd93b9c8a49bcaca5a3362e49ed1e1acf50a9b
2017-06-02 12:05:03 -07:00
Badhri Jagan Sridharan
7f3047e6b6 Enable MTP or ADB when default functions are enabled
Clients (viz. Tethering) use UsbManager@setCurrentFunction(null, ..)
to make the device switch to default functions. While in OemMode,
this gets set to the last enabled functions list. Instead,
enable MTP or ADB depending on whether ADB is enabled or not.
This is the expected behavior for normal boot as well.

Bug: 37491031
Test: Verified that the device falls back to either mtp or adb while
in OemOverride mode.
Change-Id: I1c26d1d0ee3c015b597d40771cd765b783cd91bb
2017-05-25 10:30:22 -07:00
Jerry Zhang
3a958a09d2 Merge "Revert "Upgrade logging for UsbDeviceManager to narrow down bugs."" into oc-dev 2017-05-22 23:13:58 +00:00
Jerry Zhang
daa9c19dae Revert "Upgrade logging for UsbDeviceManager to narrow down bugs."
This reverts commit c889b4f4eb62ae7ad8de3ff3d98768e71cb3ad5a.

Merged-In: I74306bacad2a61471a9b8c9fd881229b22b6975e
Change-Id: I74306bacad2a61471a9b8c9fd881229b22b6975e
2017-05-22 10:57:08 -07:00
Jerry Zhang
b2dac52391 Revert "Upgrade logging for UsbDeviceManager to narrow down bugs."
This reverts commit c889b4f4eb62ae7ad8de3ff3d98768e71cb3ad5a.

Change-Id: I74306bacad2a61471a9b8c9fd881229b22b6975e
2017-05-15 13:24:23 -07:00
Jerry Zhang
653fbeeec4 Merge "Only force reset when adb is not enabled (i.e. mtp is)" into oc-dev am: f874fd319e
am: c5a4576cab

Change-Id: I153a5ad3e4bd0de9a62ef39ebc7579f4916b79e3
2017-05-12 20:31:51 +00:00
Philip P. Moltmann
278685d468 Merge "Remove forward matches before checking for default" into oc-dev am: d53cbfd0dc
am: ba8b3f05b6

Change-Id: Ic35779f6b6ad97dc1a6f83356dfa45e0d5b5f406
2017-05-12 20:29:15 +00:00
TreeHugger Robot
f874fd319e Merge "Only force reset when adb is not enabled (i.e. mtp is)" into oc-dev 2017-05-12 19:41:52 +00:00
TreeHugger Robot
d53cbfd0dc Merge "Remove forward matches before checking for default" into oc-dev 2017-05-12 19:17:37 +00:00
TreeHugger Robot
81e8d4b340 Merge "Prevent multiple copies of android.hidl.manager-V1.0-java" into oc-dev 2017-05-12 19:07:41 +00:00
Jerry Zhang
ad962a923c Only force reset when adb is not enabled (i.e. mtp is)
Some users depended on adbd continuing to run after disconnect
in order to use scripts with nohup. This change allows this
use case to keep working since only mtp has to be force
set.

Bug: 38227228
Test: adb shell "nohup sh /sdcard/script" where script contains
"sleep 5; touch /sdcard/done" and verified file still appears even if
disconnected during sleep.
Test: am force-stop com.android.providers.media, still connects

Change-Id: I25ae2b922fa4d06109ac8cf5e43e1c47a33c46a6
2017-05-11 13:50:28 -07:00
Philip P. Moltmann
0d78363a39 Remove forward matches before checking for default
A forward match is a intent-target (aka. match) that switches between the
personal and work profile's intent resolver.

This can be unnecessary if there are no work profile matches.

We need to remove these unnecessary matches early as the default activity
resolution code considers a system app as default _only_ if it is the only
match. Before there could still the an unnecessary forward match under
consideration.

Test: Connected USB accessory that only matches a system app on the personal
      profile.
      Before we showed a confirm-dialog, now we consider the system app
      as default and automatically launch it.
Fixes: 37530439

Change-Id: I7bc9b969fc0b9abae4d15dd3f268783d05b91f9a
2017-05-11 10:23:41 -07:00
Badhri Jagan Sridharan
e5bf826525 Prevent multiple copies of android.hidl.manager-V1.0-java
Link to android.hidl.manager-V1.0-java shared libraryto prevent
duplicate copies of the library present in process address
space.

Bug: 38036660
Test: Verified that the UsbService reports status of the ports through
dumpsys usb.
Change-Id: Ie3de4f9bbe28061e7cc464fa3cab2f6bd6fe6995
2017-05-10 07:27:24 -07:00
Philip P. Moltmann
16bcd7219d Merge "Merge "Fixes for handling users + default for USB" into oc-dev am: 5262ae9b87" into oc-dev-plus-aosp
am: bc535b11b6

Change-Id: I6e20b889abbb7d2c037d71c271a733e0639b3e1e
2017-05-10 02:32:54 +00:00