182 Commits

Author SHA1 Message Date
Glenn Kasten
67ffd5e617 resolve merge conflicts of c76a3ac to stage-aosp-master
Change-Id: Ifff16bdc42e8326f3f60cf4b92688c445cb4db25
2016-08-17 13:28:04 -07:00
Glenn Kasten
1fda533936 Squashed commit of the following:
commit efa6f355b06675aa4d0879fd279e22c16d5c046c
Author: Mikhail Naganov <mnaganov@google.com>
Date:   Wed Aug 10 12:25:13 2016 -0700

    MIDI: Use server-side socket in blocking mode for virtual devices

    Since virtual MIDI servers may misbehave, blocking mode will throttle
    them if clients are not coping with their sending speed.

    Bug: 29413812
    Change-Id: I9c4a2a7a7ea3ea060c93fedc7d0f033427c557c9

commit 755dfb5f83749d3963c63d98d692307f8271c804
Author: Mikhail Naganov <mnaganov@google.com>
Date:   Fri Jul 8 13:26:19 2016 -0700

    Protect MIDI framework against client blocks in MidiReceiver.onSend

    Make the server-side socket non-blocking when creating MidiOutputPort
    for clients. Thus if a client ceases to read from its side of the
    socket pair, the server will just fail to write instead of blocking.

    One drawback is that the MidiOutputPort on the client can't indicate
    that it has become dysfunctional, but it's not possible without
    changing the API.

    Bug: 29413812
    Change-Id: I9dfcbdd214a815cea8fd1365324fd78ca459268a

commit c740b13953761f58233ac651a0b5227733b1bdcc
Author: Mikhail Naganov <mnaganov@google.com>
Date:   Fri Jun 17 04:11:25 2016 -0700

    UsbMidiDevice: Clean up terminology and fix comments

    When working with physical MIDI devices, an *input* stream is used
    for reading from *output* port of the device, and vice versa. Thus,
    using "input" and "output" without specifying whether it's a stream
    or a port is confusing.

    Clarify names of counter variables, and fix a couple of comments
    that were incorrect due to this confusion. No functional changes.

    Change-Id: If561eaca4bade94e9296d2c703c9fcebc91296e2

commit 4269c6417287737624f6165a8bbeb5aa427de9a0
Author: Glenn Kasten <gkasten@google.com>
Date:   Thu May 5 18:49:16 2016 -0700

    Update MIDI package summary

    Bug: 28625060
    Change-Id: If552ca8e1a0666d402b5f536699bf3fb09c1e324

commit 862d40b73168bde7d0be5280d997985c18061014
Author: Phil Burk <philburk@google.com>
Date:   Tue Apr 19 15:56:24 2016 -0700

    MidiDevice: do not open ports on closed device

    Fix involves client side mIsDeviceClosed flag.

    Bug: 24949216
    Change-Id: I666284a787fbb9a710d2372fb424e8e54f6a2825
    Signed-off-by: Phil Burk <philburk@google.com>

commit 6f1de358b9f2616e03f4655f01454770915ddd66
Author: Phil Burk <philburk@google.com>
Date:   Mon Apr 18 16:05:28 2016 -0700

    MidiService: fix resource leak

    The proxy object was being used to match when adding or removing objects.
    But they are different each time. So now we use an asBinder() object.

    Bug: 28153736
    Change-Id: I1bccebf1e9464668db757ff08b41902d0cf0e3a7
    Signed-off-by: Phil Burk <philburk@google.com>

commit f7386bd535bb8a1d7f8df8f44a1748ab770c991a
Author: Phil Burk <philburk@google.com>
Date:   Tue Apr 5 14:19:53 2016 -0700

    MidiDevice: fix connectPorts for same Process

    If connectPorts() was called for a device in the same process then
    the connection would die when the ParcelFileDescriptor was closed.

    Bug: 26406775
    Change-Id: Id0538452593b4761ac2a93d366ade76d2e35ce73
    Signed-off-by: Phil Burk <philburk@google.com>

Change-Id: I4dfc2a2cbaf04bf1a790ae2cb39bf74fb5bb16ac
2016-08-17 08:45:39 -07:00
Phil Burk
2f2bf4014a UsbMidiDevice: fix MIDI flush()
The proxy MidiReceiver in the USB device was not forwarding the flush
command to the event scheduler.

Bug: 25511696
Change-Id: I6a4759b71bc8f9ae3e20aed1238f62a2ed405e24
Signed-off-by: Phil Burk <philburk@google.com>
2016-08-16 16:57:36 -07:00
Philip P. Moltmann
236b9e8eb4 Handle the uncommon case that a name is null
Bug: 29037588
Change-Id: I697184bd1ae4d519f8f29bf612ba13843e6662cb
2016-05-31 10:16:30 -07:00
Vincent Palatin
a0116bf81f Fix notifications for USB PD enabled devices
The devices with USB PD support can have the data role and the power role of
their USB-C port reversed. Ensure the title of the notification and the content
of the USB selection dialog is correct in this case.

Testing done on Ryu with the following accessories:
- legacy A-C cable
- USB-C charger (5X)
- USB-PD charger (Zinger)
- Pixel 2 (in both roles)
- Type-C Macbook (in both roles)
- Nexus 5X (in both roles)
- Apple AV HDMI accessory
- LG USB-C screen/dock
- Honeybuns dock

Bug: 28310685
Bug: 24137353
Change-Id: Id7f358c40d8714fae68ca98a7eb067f62f18b0af
(cherry picked from commit 0be6800b0feba50fa2c1be7852ee2eb02c38afc0)
2016-05-19 20:46:21 +00:00
Phil Burk
de2922468b UsbMidiDevice: fix MIDI flush()
The proxy MidiReceiver in the USB device was not forwarding the flush
command to the event scheduler.

Bug: 25511696
Change-Id: I6a4759b71bc8f9ae3e20aed1238f62a2ed405e24
Signed-off-by: Phil Burk <philburk@google.com>
2016-04-05 11:30:00 -07:00
Paul McLean
c72239409b Added logging to USB Audio connect and disconnect.
This will let us see in bug reports if the USB device in question
is ACTUALLY recognized and added/removed from the audio system.

Bug: 27812441

Change-Id: Id3eb4d4f3f0b1e66a24999706ba589c0962eba58
2016-03-28 13:07:09 -06:00
Daichi Hirono
b6abccc8f3 Add new text for USB type C host.
If you use USB type C, you can charge Android from USB power or you can
supply power from Android to the other connected device.

Previously Android showed the notification saying "USB for charging".
The CL updates the text so that it shows the current power direction
explicitly.

Change-Id: Ic15ba70eaf8ade028283d8f490ac36e8d5e4db21
FIXED: 27706939
2016-03-28 10:52:17 +09:00
Daichi Hirono
618fa6ffc1 Add USB_HOST_CONNECTED extra to ACTION_USB_STATE sticky intent.
Previously UsbModeChooser activity is automatically closed when Android
is connected to another Android and works as host. This is because
ACTION_USB_STATE intent does not include the information whether Android
is connected as host and UsbModeChooser regards Android is not connected
USB devices.

The CL introduce the HOST_CONNECTED extra to ACTION_USB_STATE so that
UsbModeChooser can refer it.

BUG=27535640

Change-Id: Ie29583b78319078430f6d9a8390787780410ac8c
2016-03-17 14:14:32 +09:00
Daichi Hirono
f8a0c8536e Skip MTP launch notification for devices having FEATURE_AUTOMOTIVE.
BUG=27410621

Change-Id: I1fd2ad663d8e5c5507a8e5e93aafea9d4188ed02
2016-03-09 12:53:50 +09:00
Daichi Hirono
fda7474c5f Open MTP device on demand.
Previously MtpDocumentsProvider opens a device just after device is
connected to Android. But MtpDocumentsProvider should open MTP device on
demand so that other applications can open device if user starts to use
the application before using MtpDocumentsProvider.

BUG=26625708

Change-Id: I6083b8c7cef49ee6e9fb0d15ca4adc129734f3eb
2016-02-04 12:45:58 +09:00
Daichi Hirono
163e4b6ae8 Add launch notification for MTP devices.
The CL adds launch notification that are shown after MTP/PTP device is
connected to Android device. By tapping the notification, Users can
launch an applicaiton that can handle USB_DEVICE_ATTACHED intent of MTP
device.

BUG=26611224

Change-Id: I6fd179ccd436531dfff6ff9a50dc2b754c20f190
2016-02-01 13:28:01 +09:00
Julia Reynolds
d1d533610a Increase notification priority for adb connections.
Change-Id: I04ec4dac40737d59a32775e579f734a5460db25c
2016-01-08 16:12:13 -05:00
Daichi Hirono
4751880a4d Grant USB device permission by using system permission.
Previously it skips the device permission check by referring package
name. The CL removes the special case and use general MANAGE_USB
system-only permission to skip USB device permission dialog.

BUG=26048722

Change-Id: I3702393a50696209499d1e5f6549dab9fb2cefe4
2015-12-09 11:15:25 +09:00
Daichi Hirono
bc0a94055c Grant USB device permission for android.media UID always.
The UID is used by MtpDocumentsProvider that is a system component and
needs to access MTP devices.

BUG=25983848

Change-Id: Iaa20a849cb9e7a86bde6c5bf8abbb15e65ced6c3
2015-12-04 13:59:28 +09:00
Chris Wren
c35d7759d8 allow devs to turn off charging notifications
in the same was as we allow then to turn of debuging notificaitons
this is useful for screenshots and demos

Change-Id: I6e95addec2917abdd619086ed68910097fb5b8aa
2015-11-19 12:49:42 -05:00
Glenn Kasten
d1323e9b70 Merge "Built-in mic is not used when USB mic is disconnected" am: ebbdabdb82
am: 1104180301

* commit '110418030167702f29fa686616d68fc62f9c0995':
  Built-in mic is not used when USB mic is disconnected
2015-11-04 16:19:36 +00:00
Glenn Kasten
ebbdabdb82 Merge "Built-in mic is not used when USB mic is disconnected" 2015-11-04 16:03:41 +00:00
Alejandro Ochoa
46b434ff98 Built-in mic is not used when USB mic is disconnected
In some cases when the USB microphone is disconnected,
audio stack does not switch to the built-in microphone.
It gets stuck in a state where it still recognizes the
USB mic is still connected. Current device removal
implementation only considers USB output devices such
as headset. The same process should be used for input
USB devices (microphone).

Bug: 24932354
Change-Id: Ic2089ef5a9a318cb47336ade405f79eccd7129f8
Signed-off-by: Alejandro Ochoa <alejandro.ochoa@intel.com>
2015-11-04 15:58:09 +00:00
Nick Kralevich
853fde6915 UsbDeviceManager: set mUsbDataUnlocked=false on user switch am: 5701321701 am: aa330c0dc2 am: d33d66e26c
am: 581c1809c1

* commit '581c1809c1c617a39eae05aac481a114c70f09d2':
  UsbDeviceManager: set mUsbDataUnlocked=false on user switch
2015-10-29 21:57:12 +00:00
Nick Kralevich
aa330c0dc2 UsbDeviceManager: set mUsbDataUnlocked=false on user switch
am: 5701321701

* commit '5701321701a319d3f2d98365a82266eeddaed895':
  UsbDeviceManager: set mUsbDataUnlocked=false on user switch
2015-10-29 21:30:59 +00:00
Nick Kralevich
5701321701 UsbDeviceManager: set mUsbDataUnlocked=false on user switch
Make sure access to MTP data is relocked when a user switch occurs.

Bug: 25288494
Change-Id: I69dafc7f51b847f4dba1993a85fb1a51df1a5e37
2015-10-29 13:07:52 -07:00
Paul Mclean
438c220d78 Merge "Fixing problems with 1st connect of USB audio device to Fugu." 2015-10-29 13:40:47 +00:00
Paul McLean
c15f756443 Fixing problems with 1st connect of USB audio device to Fugu.
Also added some additional logging functions as we are not done
looking at connect/disconnect issues.

Leaving in tact the multi-device connect/disconnect logic (neeeds to
be revisited)

Bug: 24906368
Change-Id: Iff91c51a9c7013dde56182059f3747e1d6cd727b
2015-10-29 13:39:42 +00:00
Paul McLean
e3b077b1c6 Fixed capture-only devices not removed when disconnected.
I have brought shame upon my family.

Bug: 24932354
Change-Id: I0fce40a976f40e74f4fd87eb6f4aa93e847032cc
2015-10-28 13:39:44 -06:00
Fyodor Kupolov
dabd6b8f45 Restart USB stack only if data is unlocked
When switching users, USB stack shouldn't be restarted if mUsbDataUnlocked =
false, e.g. device is in charge only mode.

Bug: 24611765
Change-Id: I3b12f8c8926235546fe916a200aa57ed618193de
2015-10-02 15:41:46 -07:00
Xiaohui Chen
e4de5a0d3b Cleanup OWNER references.
Bug: 19913735
Change-Id: I2150c6baaab80fe11312e4401394a2a8da52e595
2015-09-23 18:50:11 +00:00
Tim Kilbourn
bcb80b03f1 am 880c6010: am 0c4050b0: am bdfbd821: am 0eb10ede: Merge "Always set the usb config when modifying it." into mnc-dr-dev
* commit '880c601013e3b58f004f65c6cacfb8e19e2ca863':
  Always set the usb config when modifying it.
2015-09-19 18:14:47 +00:00
Tim Kilbourn
bdfbd82154 am 0eb10ede: Merge "Always set the usb config when modifying it." into mnc-dr-dev
* commit '0eb10ede2364bf975721d95f7af7a1e4f4b617f8':
  Always set the usb config when modifying it.
2015-09-19 00:29:35 +00:00
Tim Kilbourn
823e805c1c Always set the usb config when modifying it.
On some devices, setting system properties takes too long and we end up
with races where adbd gets killed and never comes back. With this
change we avoid a small optimization that checks the previous value of
the config, instead opting to set it every time.

Bug: 23631400
Change-Id: I7567cc2efb3d5d15c45334bd66b28877a2af0ac3
2015-09-18 15:05:57 -07:00
Daniel Koulomzin
e4b3e61456 am 1a73ab76: am 4bf3dfea: am ffa2d691: Merge "Adds config flag for USB notification." into cw-e-dev
* commit '1a73ab760bedd371dbfb8850ac24555c33004ff6':
  Adds config flag for USB notification.
2015-09-10 22:06:52 +00:00
Gus Prevas
e753361508 Adds config flag for USB notification.
This change modifies UsbDeviceManager such that the ongoing
system notification for USB charging state is controlled by a
config flag.

Bug: 23409719
Change-Id: I2ef24fe74923170a6e8dd02375b973b4025281e4
2015-09-10 13:37:59 -04:00
Yasuhiro Matsuda
92386c42a8 Merge "Broadcast ACTION_USB_STATE only if necessary." 2015-08-26 09:36:40 +00:00
Tim Kilbourn
4080a4197c am 6041a68b: am 458d4d6d: am 9b1fd822: am 2ad94499: Merge "Use init to write usb typec props." into mnc-dr-dev
* commit '6041a68babcc0ec9cc2009fcfe75848882661785':
  Use init to write usb typec props.
2015-08-19 02:21:39 +00:00
Tim Kilbourn
2ad9449969 Merge "Use init to write usb typec props." into mnc-dr-dev 2015-08-18 19:54:46 +00:00
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
Tim Kilbourn
6ea47a3542 Use init to write usb typec props.
The sysfs nodes are owned by root, so we must use init to write to
them.

Bug: 21615151
Change-Id: Ia8c838827ff45794aa359443117ac85764cf3772
2015-08-14 17:03:34 -07: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
Yasuhiro Matsuda
48b9a7c70a Broadcast ACTION_USB_STATE only if necessary.
Modify UsbDeviceManager.updateUsbStateBroadcast to broadcast
ACTION_USB_STATE intent only when any of the USB states have
changed.
By doing this, the processes that receive ACTION_USB_STATE intent
(e.g. android.process.media) are not launched during boot
unnecessarily.
This change reduces boot time by about 200 ms.

BUG: 22163689
Change-Id: I1853a23b0263d9ff608b02d6bc98fe58f584cc19
2015-08-07 17:26:41 +09: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