145 Commits

Author SHA1 Message Date
Jason Monk
94ce8985b5 am b99fdbe8: am 6f07eaad: am cda0ab68: am 8cfbae04: Merge "Show usb charging notification when in host mode" into mnc-dr-dev
* commit 'b99fdbe84568dea0cc019dc1e4a63bb40b4067d6':
  Show usb charging notification when in host mode
2015-08-17 16:26:53 +00:00
Jason Monk
8338ed00ae Show usb charging notification when in host mode
Bug: 21615151
Change-Id: Ifc8c288a94f52ecac19990ab3d9095b1aef8efc3
2015-08-12 14:16:22 -04:00
Nick Kralevich
1913ae958c am 8ad7c8f9: am 94933e43: am 2eafb06f: am b2c71814: am 97b68bbe: Merge "UsbDeviceManager: fix b/21429947 regression (try #2)" into mnc-dev
* commit '8ad7c8f9553611798fa39ff20cea3313c5b64922':
  UsbDeviceManager: fix b/21429947 regression (try #2)
2015-08-04 21:29:21 +00:00
Nick Kralevich
1a008c1ca0 UsbDeviceManager: fix b/21429947 regression (try #2)
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.

Move the DISALLOW_USB_FILE_TRANSFER filtering of mUsbDataUnlocked from
setting time to the time we post the sticky broadcast.

Remove isUsbDataUnlocked(). It essentially duplicates data in the sticky
broadcast.

Bug: 22447614
Bug: 21429947
Change-Id: I9d0d94cadbf6db6281ebd77bfb7162f9d06520c2
2015-08-04 10:36:37 -07:00
Xiaohui Chen
233d94c0df clean up UserHandle.USER_OWNER reference
cleaning up a few in framework/base/services.

Bug: 19913735
Change-Id: I1af5f24d9b39d6712ad3a665effa6166e32ce3d3
2015-08-03 13:05:33 -07:00
Phil Burk
bea6528ae3 am c8dc65d1: am 3882997e: am ed839f59: am e2823cb3: am 8f5228af: Merge "UsbMidiDevice: add timestamps for input events" into mnc-dev
* commit 'c8dc65d1942a4d0e7a7a2c56a6c1b991c8927a70':
  UsbMidiDevice: add timestamps for input events
2015-07-30 22:10:53 +00:00
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
c0121df2e0 am d9b08e61: am d517de5a: am a8937f13: am a2adb4c5: am 06b93a48: Merge "Revert "UsbDeviceManager: fix b/21429947 regression"" into mnc-dev
* commit 'd9b08e6131c26a0ea6646a8dd3b206f53472028d':
  Revert "UsbDeviceManager: fix b/21429947 regression"
2015-07-24 05:13:36 +00:00
Nick Kralevich
7bdcbd8bfc am a508d399: am 01e00c8c: am e4f10de7: am dd856a3f: am 3b0bbd7b: Merge "UsbDeviceManager: fix b/21429947 regression" into mnc-dev
* commit 'a508d399e720b3a535832ce0b2554680197944af':
  UsbDeviceManager: fix b/21429947 regression
2015-07-24 05:11:28 +00: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
df2600d4dc am b430c4f0: am 8326ebbe: am 6b04e5b8: am 894ffd10: am 673ccfd4: Merge "UsbDeviceManager: add back support for USB overlays" into mnc-dev
* commit 'b430c4f06c763e0c0fffb6d12b606064ccc84ce3':
  UsbDeviceManager: add back support for USB overlays
2015-07-21 18:24:12 +00:00
Nick Kralevich
b430c4f06c am 8326ebbe: am 6b04e5b8: am 894ffd10: am 673ccfd4: Merge "UsbDeviceManager: add back support for USB overlays" into mnc-dev
* commit '8326ebbe9ea324cc7608e8dc754a63d905bfdb63':
  UsbDeviceManager: add back support for USB overlays
2015-07-21 18:07:11 +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
4085a74b4c am 209c8ced: am 6e4997db: am 8bdd92d4: am 0cb1cfdc: am 76c4c666: Add USB port manager.
* commit '209c8cedab87359564c032a3e56b3acd452e1ac9':
  Add USB port manager.
2015-07-15 23:30:28 +00:00
Jeff Brown
a50dfe9c6f am 852e51e2: am 3bc33423: am b35b8e81: am b3c11805: am 2dbccc19: Clean up USB Manager dump.
* commit '852e51e23de4dd390f81f5c5a45687595323599a':
  Clean up USB Manager dump.
2015-07-15 23:30:20 +00:00
Jeff Brown
209c8cedab am 6e4997db: am 8bdd92d4: am 0cb1cfdc: am 76c4c666: Add USB port manager.
* commit '6e4997dbfb5f0a2abac99522a52b557172757ee2':
  Add USB port manager.
2015-07-15 23:16:55 +00:00
Jeff Brown
852e51e23d am 3bc33423: am b35b8e81: am b3c11805: am 2dbccc19: Clean up USB Manager dump.
* commit '3bc33423477945a0f97ebe7948af642cc56cea7b':
  Clean up USB Manager dump.
2015-07-15 23:16:45 +00: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
Xiaohui Chen
05d58afddb sys user split: fix usb debugging notice
BUG:19913735
Change-Id: Iefdf8a12f1622650bb0d61e7ffb73040e4b8d498
2015-07-14 21:43:42 +00:00
Jeff Brown
0bff26c1e9 am 9c22afe8: Fix a bad merge.
* commit '9c22afe8538cd8c849d0393751bf5bc4997bc632':
  Fix a bad merge.
2015-07-09 22:30:24 +00:00
Jeff Brown
9c22afe853 Fix a bad merge.
Change-Id: Ib722459a25c189bb800eb85d48b80bdc91a2b7db
(cherry picked from commit 2a67840c3c35a6267663e5d3ae921ee9ac614db9)
2015-07-09 22:21:50 +00:00
Jeff Brown
5c43bb82e4 am f19abb67: am 8e4dde2c: am 2ad03d0c: am c1aebfa0: Merge "Clean up USB Manager and fix ADB." into mnc-dev
* commit 'f19abb67c2604c06b140979cb527c599c37d02f4':
  Clean up USB Manager and fix ADB.
2015-07-09 20:56:00 +00: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
032ba9f3d1 am 2fbfe429: am 92c1d283: am 706ad39b: am a2de7fc9: Merge "Prevent accidental unlocking of USB data transfer." into mnc-dev
* commit '2fbfe42955520c6831fd5df94d87ada875f9299b':
  Prevent accidental unlocking of USB data transfer.
2015-07-08 12:55:25 +00:00
Zoltan Szatmary-Ban
a2de7fc9fc Merge "Prevent accidental unlocking of USB data transfer." into mnc-dev 2015-07-08 11:44:35 +00:00
Vineeta Srivastava
c0bc04697e am 0baee4f1: am 002c7d74: am a572506e: am 9d918db3: Merge "UsbDeviceManager: Add back support for persistent property" into mnc-dev
* commit '0baee4f1ccf7d1c100dcfde45739cede657f86bf':
  UsbDeviceManager: Add back support for persistent property
2015-07-08 01:36:30 +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
Mike Lockwood
f788e297b2 am ce1cb218: am 593dfbb2: Merge "Miss USB device Interface from UsbManager.getDeviceList()."
* commit 'ce1cb218f4d25f76342d6c66c75889429080e883':
  Miss USB device Interface from UsbManager.getDeviceList().
2015-07-06 18:46:17 +00:00
wang.zhenyu
19b26f8754 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.

Change-Id: I0ba4f07c809d07ebebed633e43c3ee8e2e4c5060
2015-07-06 11:35:44 +08: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
Wojciech Staszkiewicz
4f11754f72 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

(cherry picked from commit 9e9e2e73c6ec7bece20268196dc89ad0c8bafad4)

Change-Id: Iaff97be9df2d0f99d7af8f19f65934439c9658e2
2015-05-22 10:26:31 +01: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