122 Commits

Author SHA1 Message Date
Phil Burk
6456a65afe UsbMidiDevice: add timestamps for input events
This will improve the accuracy of recorded MIDI performances.

Bug: 22801515
Change-Id: Ib78bc929224f2f27938c83a815eaa62f6b5f9560
Signed-off-by: Phil Burk <philburk@google.com>
2015-07-29 15:55:00 -07:00
Nick Kralevich
06b93a48ad Merge "Revert "UsbDeviceManager: fix b/21429947 regression"" into mnc-dev 2015-07-23 01:46:38 +00:00
Nick Kralevich
0d767e6f09 Revert "UsbDeviceManager: fix b/21429947 regression"
This causes various problems with our testing infrastructure.

This reverts commit b210026e3d5c955628ca8b8b9191ade08891e9ef.

Bug: 22447614
Bug: 21429947
Change-Id: I57623e3d993e65b6ad89e7a7d28e9575cf638994
2015-07-23 01:45:01 +00:00
Nick Kralevich
3b0bbd7b96 Merge "UsbDeviceManager: fix b/21429947 regression" into mnc-dev 2015-07-22 21:18:59 +00:00
Nick Kralevich
b210026e3d UsbDeviceManager: fix b/21429947 regression
As discussed in b/21429947 (commit
674019065bceb4150190bfb1aa63cda9de0a8560), MTP must always be
enabled, even if access to the underlying MTP data is disabled.
Otherwise, Android will not enumerate on the USB bus, and won't
receive notifications from the kernel about USB state changes. This
effectively prevents using MTP functionality on user builds, or
on userdebug/eng builds with adb turned off.

Always ensure that MTP is the default driver mode.

Get rid of one use of the persistent property. The persistent property
was already pulled from a number of devices, and as explained in
commit fcf10f7c12cb3107bdfedce6f76a8c866d154f3c, the intent was that
the persistent property would only hold the persistent adb state.

Bug: 22447614
Bug: 21429947
Change-Id: I8b3690a1bafb7cea0d5a69d73c1065c7fc64c653
2015-07-22 12:59:47 -07:00
wang.zhenyu
ed987a52a2 Miss USB device Interface from UsbManager.getDeviceList().
In the scenario that you connect more than one device to android phone
with an usb hub, when you attach the second device,mNewConfigurationis
is still corresponded to the first device unless another
mNewConfiguration is created by a new operation. However,before another
mNewConfiguration is created,setInterfaces() in addUsbConfiguration()
has already been executed. Problem is that mNewInterfaces has already
been cleared when it finished endUsbDeviceAdded for the first device. As
a result,the UsbInterface descriptor in the first device's Configuration
descriptor is set to null.

Bug: 22657587

Change-Id: I0ba4f07c809d07ebebed633e43c3ee8e2e4c5060
2015-07-22 17:45:16 +00:00
Nick Kralevich
2fedc4df51 UsbDeviceManager: add back support for USB overlays
Commit fcf10f7c12cb3107bdfedce6f76a8c866d154f3c removed support for USB
overlays. Add it back in, as some devices depend on it.

Bug: 22062484
Bug: 21195124
Change-Id: I74d12699201355b07475744c641e31fdc4bb5a4a
2015-07-20 15:40:54 -07:00
Jeff Brown
76c4c6668a Add USB port manager.
Add some new internal APIs to enumerate USB Type C ports, query their
status, determine whether they support changing power or data roles,
and doing so.  The API also adds a new ACTION_USB_PORT_CHANGED broadcast
for port state changes.

The implementation includes a mechanism for simulating the behavior
of the USB stack.  See 'adb shell dumpsys usb -h' for details.

Note that the underlying kernel driver interface is still subject
to change but its behavior has been encapsulated as much as possible.

Bug: 21615151
Change-Id: I0c853ae179248a4550b3e60d02a7a7e65e4546b2
2015-07-15 11:34:29 -07:00
Jeff Brown
2dbccc1926 Clean up USB Manager dump.
Tidy up the dump() implementation in preparation for further work.

Bug: 21615151
Change-Id: If6d94c8dc9457b8e93103541ec1798981eeb5b54
2015-07-15 11:34:29 -07:00
Jeff Brown
2a67840c3c Fix a bad merge.
Change-Id: Ib722459a25c189bb800eb85d48b80bdc91a2b7db
2015-07-09 13:36:41 -07:00
Jeff Brown
c1aebfa02c Merge "Clean up USB Manager and fix ADB." into mnc-dev 2015-07-09 20:03:29 +00:00
Jeff Brown
460a146eb8 Clean up USB Manager and fix ADB.
Moved functions which parse the USB functions list into one common
place on UsbManager.

Deleted the no longer supported USB_FUNCTION_MASS_STORAGE.

Ensured that the UserManager.DISALLOW_USB_FILE_TRANSFER rule is
consistently applied during user switch and when changing the
current USB functions and make sure it only affects MTP and PTP.

Collapsed the boot completed and user switched receivers to
ensure consistent ordering of side-effects.

Validate the list of functions passed to setCurrentFunction() so
that the separation of concerns is clearer.  It was somewhat
ambiguous as to whether functions such as ADB could / should be
enabled through that interface.  Improved the docs for clarity.

Fixed a bunch of broken stuff related to the USB config
persistent property (list of default functions) that could cause
ADB and other functions to not work at all.  Added new failsafes
to ensure that we reliably get back into a happy state.

Bug: 22206076
Change-Id: I02915ddfce7193a8f67a14f0d76bab22fc575dfa
2015-07-09 12:55:56 -07:00
Zoltan Szatmary-Ban
a2de7fc9fc Merge "Prevent accidental unlocking of USB data transfer." into mnc-dev 2015-07-08 11:44:35 +00:00
Ajay Dudani
84dce3c9a8 UsbDeviceManager: Add back support for persistent property
Take into account the value of persist.sys.usb.config when updating
sys.usb.config. The persistent prop can hold information regarding
additional enumerations required for the device.

Bug: 21929369
Change-Id: Ic11ebf62ce114f2d0a097ad4405de71173b23139
2015-07-07 11:51:15 -07:00
Zoltan Szatmary-Ban
b2eb6b9049 Prevent accidental unlocking of USB data transfer.
When DISALLOW_USB_FILE_TRANSFER is in effect, there must be no chance to
unlock data transfer over USB.

Bug: 22291579
Change-Id: I990fedbfeecd90e7dd26981034d0352b83dc694e
2015-07-07 13:24:59 +01:00
Chris Wren
b3c8564314 Merge "remove setLatestEventInfo from USB" into mnc-dev 2015-06-15 12:23:26 +00:00
Nick Kralevich
43965fe5ce UsbDeviceManager: Modify default function handling
When adb is enabled, there's no need to also enable MTP mode.
ADB mode enabled is sufficient to get connect messages from
the kernel driver.

This change modifies getDefaultFunctions() to return adb mode
if adb is enabled, but mtp when it's not enabled. Also stop
using "none" mode as the default. "none" should only be used
when toggling the driver.

Bug: 21429947
Change-Id: I767491417c6c69a120fcf4f3d6ec0c73311a1a60
2015-06-12 17:21:25 -07:00
Chris Wren
6d8e413a63 remove setLatestEventInfo from USB
Bug: 18510449
Change-Id: I6b9ccaa0537c8044c5fa900ae4ea68b2676e1365
2015-06-12 17:10:01 -04:00
Nick Kralevich
674019065b Fix USB access control when adb is disabled.
When adb is disabled, the default usb mode would be "none", which
would turn off the driver and prevent UsbDeviceManager from receiving
any new USB connect / disconnect messages. This prevents the user
from ever enabling MTP and sharing data when adb is turned off.

As discussed in bug 21429947, we work around this problem by keeping
the USB driver in MTP mode most of the time, so that we continue to
receive USB connect / disconnect messages.

To avoid leaking confidential user photos, this change introduces an
unlocked state. Setting the mtp enabled function is now decoupled from
exposing data on the USB connection. Only if MTP is enabled and
USB data has been unlocked is confidential user data allowed to be
shared.

Bug: 21429947
Change-Id: Iefb5c7e22dc4962bf5226f2ed3d0155b5c7b413c
2015-06-10 10:29:48 -07:00
Mike Lockwood
6d5a0f9164 UsbMidiDevice: Only keep ALSA devices open when device is in use
This should fix contention problems for apps using USB APIs to implement MIDI support

Bug: 20949468
Bug: 21630625
Change-Id: I32b44330ca0310a4693fd56a4b01ad399f82c1c9
2015-06-08 16:48:19 -07:00
Nick Kralevich
2d63f0a14a Merge "UsbDeviceManager: Don't unnecessarily touch properties" into mnc-dev 2015-06-03 16:59:49 +00:00
Xiaohui Chen
ffcfe3411f usb debugging: show alert to secondary user
Bug: 12785423
Change-Id: If7f60899cfdaca7bdad560bd59a78f5be74c24be
2015-06-03 09:32:19 -07:00
Nick Kralevich
2f7fa3ed77 UsbDeviceManager: Don't unnecessarily touch properties
Before setting the properties persist.sys.usb.config or sys.usb.config,
check the existing values. If the values are the same as what we'd set it
to, don't perform the set.

Any USB property set, even if setting the property to the value it already
has, triggers one of the "on property" triggers in system/core/rootdir/init.usb.rc .
The script then reconfigures the driver unnecessarily, which causes instability
and dropped connections when trying to use ADB.

Avoid this instability by not performing property sets which would have
no effect.

Bug: 21404762
Bug: 18905620
Change-Id: Id3c2543308df994a0114a0661e20ca799c2dc0e8
2015-06-02 17:04:47 -07:00
Paul McLean
afe55a5ce9 Turning off logging in ALSA device connection routines.
bug: 21298614
Change-Id: Ia88393698072af8f7c101382f180192646bf713e
2015-05-19 10:32:13 -07:00
Wojciech Staszkiewicz
9e9e2e73c6 Pass charset to XmlPullParser.setInput instead of null
Passing null to XmlPullParser.setInput forces it to do additional
work, which can be easily avoided if we know the charset beforehand.

bug: b/20849543

Change-Id: Iaff97be9df2d0f99d7af8f19f65934439c9658e2
2015-05-14 10:24:34 +01:00
Nick Kralevich
fcf10f7c12 Modify how USB connections are handled.
* Introduce a new "charger only" mode. In this mode, MTP is disabled,
and no file transfers can occur.
* Make charger only mode the default.
* Modify "persist.sys.usb.config" so it now only holds the adb status.
* Make the USB settings non-persistent. Unplugging the USB connection will
reset the device back to "charger only" mode.
* Fixup wording per UI guidelines.

TODO: Re-implement MDM restrictions for USB / MTP access controls.

Bug: 18905620
Change-Id: I99a50d9132a81e98187f431166fd9fef4d437e4f
2015-05-13 14:28:13 -07:00
Nick Kralevich
d9c7f24569 UsbManager / UsbService / UsbDeviceManager: delete unused code
These functions are never called.

Change-Id: Ic436e1036bed717d2c64701fddd9a810abb9443e
2015-05-10 21:57:56 -07:00
Mike Lockwood
02868b1625 MidiDeviceInfo: Add version string property
For USB devices, this is populated with the USB device version string.

Change-Id: Ia9286d5f41783e4e960a9c724bf6b85b6599fe12
2015-04-29 13:44:34 -07:00
Mike Lockwood
c9bb40ea95 UsbDevice: Add support for retrieving version string for a USB device
Change-Id: Ia8630f5ffd05f90347b971110a81f4927060cc4b
2015-04-29 13:05:55 -07:00
Mike Lockwood
1f13872a01 UsbAlsaManager: Fix NPE when running in emulator
Bug: 20537358
Change-Id: I46693e45eb6127118cbd54fc3490dc58840b5797
2015-04-24 14:56:32 -07:00
Mike Lockwood
dee5f1bb6e Add user visible name for USB peripheral MIDI device
Change-Id: I075a54dc3890bc5cf3927cecba3750e1d342d290
2015-04-10 08:49:53 -07:00
Mike Lockwood
b6f50d357b Add support for flushing MIDI all scheduled MIDI events on a port
Change-Id: I39d7862540d4d4b9e2df1265f9dd253541adb4c2
2015-04-09 11:49:45 -07:00
Mike Lockwood
2776133be7 Add event scheduling support to USB MIDI Manager code
Change-Id: I9fdaaac35c296acc67ee0cf346b0c7b56bf58393
2015-03-31 08:57:06 -07:00
Mike Lockwood
d1b16fe2fb Move MIDI utilities for internal use to com.android.internal.midi package
Change-Id: I7393ae1d4bca61667fb6ee809a7aa22c5c48de56
2015-03-30 09:06:06 -07:00
Mike Lockwood
5781cd5b21 Make the MIDI Manager optional, enabled by "android.software.midi" feature
Change-Id: I76d442ea28beea4b9e2876bfef501d8f61403702
2015-03-27 13:23:41 -07:00
Nick Kralevich
005e9b8195 Merge "UsbDeviceManager: delete obsolete code" 2015-03-26 00:33:27 +00:00
Nick Kralevich
ad8fc70c6a UsbDeviceManager: delete obsolete code
We stopped using persist.service.adb.enable almost 4 years ago
(commit 02e4569b5f126ca916a7473117ddd17d4f2ccbbb). Delete backwards
compatibility code.

Change-Id: Ic656e834e79361b27ca2afcd3705d0523c23717d
2015-03-25 16:08:21 -07:00
Mike Lockwood
b7ce094c9e MIDI Manager: remove USB peripheral MIDI device when USB is disconnected
Otherwise, the MIDI device would appear available always, rather than
only when USB is connected.

Also fixed file descriptor leak in UsbMidiDevice

Change-Id: I0d38e81c488de4748eef36ca359635fa59e0e636
2015-03-25 11:54:40 -07:00
Alan Viverette
4a357cd2e5 Replace usages of deprecated Resources.getColor() and getColorStateList()
Change-Id: I8f64fe6c4c44a92ff6d07250223ba590a1d691b0
2015-03-18 18:37:18 -07:00
Mike Lockwood
3ae6acda81 Merge "Add MidiManager to public API" 2015-03-14 00:49:00 +00:00
Mike Lockwood
81b9f7d325 Add MidiManager to public API
Also made some small API changes based on feedback from the lint tool.

Change-Id: Ibcf1e9107d86d3a364f811ce47a13aa0da653366
2015-03-13 11:00:57 -07:00
Mike Lockwood
4011e20921 Merge "MidiDeviceInfo meta-data improvements:" 2015-03-13 17:27:37 +00:00
Mike Lockwood
f2cd802402 MidiDeviceInfo meta-data improvements:
Add property for user visible device name
Add names for input and output ports
Rename "model" to "product" to match USB specification.

Change-Id: I8dc50da935f26825ffc73de456d34e7933aa987c
2015-03-12 12:05:47 -07:00
John Spurlock
9087433753 AudioService: Write base stream volume changes to the event log.
- Add a new volume_changed event, reported at the stream level.
 - Only include changes to base streams (no aliases).
 - Include the caller for each change.  A caller is either:
   -  a pkg name (for external calls or known media sessions)
   -  a system server class's log tag (for internal calls,
      disambiguates "android")

Bug: 19599935
Change-Id: Ia61b68ff1e7e2907a24972790ec052bfe099e665
2015-03-12 09:54:10 -04:00
Mike Lockwood
57baee2e12 Merge "MidiManager: Add MIDI device status notifications" 2015-03-11 19:43:49 +00:00
Mike Lockwood
5ff9e2a171 MidiManager: Add MIDI device status notifications
MidiManager clients can be notified of device status changes via a new MidiDeviceStatus object.
MidiDeviceStatus contains the busy status of the device's input ports and number of
connections to the output ports.
MidiDeviceService now has an optional callback for receiving notifications when its ports change as well.

Change-Id: I1600df4464d82724bc026c27b9633ae9c412d3f0
2015-03-11 10:19:45 -07:00
Mike Lockwood
22e78c65be Merge "Add MidiReceiver.send() and MidiReceiver.getMaxMessageSize()" 2015-03-11 10:55:43 +00:00
Mike Lockwood
0c7342f015 Add MidiReceiver.send() and MidiReceiver.getMaxMessageSize()
Change-Id: I10d4f5e2400fcaf41f455e56ca25bbc0c781a042
2015-03-11 03:51:38 -07:00
Paul McLean
394a8e1fa7 Handle simultaneous connect of devices with the same "type" (as in USB)
Change-Id: I163bf8e33ccf5aacc7ba21775916727430327f18
Bug: 19563570
2015-03-10 14:55:30 -07:00
Mike Lockwood
3b7664589b Make MidiSender and MidiReceiver abstract classes, rename MidiReceiver.post() to receive()
Change-Id: I1cef3bd48ca0acf2968c9de223f78445f3434404
2015-03-04 20:38:37 -08:00