Commit Graph

197 Commits

Author SHA1 Message Date
TreeHugger Robot
9717839a1f Merge "Revert "Exit enteringAccessoryMode when entered."" 2016-11-02 00:29:27 +00:00
Philip P. Moltmann
7d6e325b6c Revert "Exit enteringAccessoryMode when entered."
This reverts commit a025c89858.

Change-Id: I550583606444a2d79ec911adf5b14b8783b03286
2016-11-01 22:36:12 +00:00
Jerry Zhang
2d2346e094 Revert: Remove the kick from config switches in UsbDeviceManager
Test: Manual
Bug: 32197840
Change-Id: Id2e939a57e170fbb4c06e55dc79c5d35ce95486f
2016-10-17 17:41:36 -07:00
Jerry Zhang
a45dac0e83 Clean up persistent usb state on boot.
b/31814300 was fixed, but mtp can still stick around in the
persistent config even after flashing. This block of code
will only run once, but will ensure that mtp is not in
the config after the update.

Bug: 31814300
Test: Manual
Change-Id: Icf02be38c9e1f769412ac963ed6afc14e6092bfb
2016-10-17 17:41:36 -07:00
Philip P. Moltmann
f2d83edc26 Clarify which props of USB devices are optional
Test: Compiles, manually inspected object creation code, ran USB CTS
verifier tests
Fixes: 32209658
Change-Id: I738c0cea5a0f37484e986f0a01c8ed9c46b639ed
2016-10-17 12:14:45 -07:00
Jerry Zhang
069c348945 Automatically turn on adb for userdebug and eng builds.
Test: flash on a userdebug build, verify adb is on.
Change-Id: If9a46ca2291c034839ec1d297d20e4e6e3fefd77
2016-10-13 17:32:21 -07:00
Jerry Zhang
58018d01a3 Fixed handling of usb state during adb changes.
When changing state to adb from mtp (charging), we want to disable
the old mtp function. Similarly when change to away from adb to
charging, enable the mtp function.

Also the mtp function should never be persisted.

Bug: 31818377
Bug: 31814300
Test: Manually verify that the correct usb configuration is displayed.
Test: Manually verify that logcat is not kicked during boot.
Change-Id: Idcb7f53be39ea38712d5de45b323d8daeb552129
2016-10-13 17:32:21 -07:00
Jerry Zhang
7a396be6d5 Refactored setCurrentFunction and setUsbDataUnlocked into single method.
This gets rid of an extraneous configuration change when going from
adb to adb + file transfer as previously the config would have been
reset once for functions and once for data unlocked.

It also simplifies some of the code.

Test: manually changing usb configurations
Change-Id: Ica10a195338b2189db13113f44657393db110bee
2016-10-13 17:32:21 -07:00
Jerry Zhang
67a769e18a Remove the kick from config switches in UsbDeviceManager
Configuration switches already kick the stack due to
triggers in init scripts. The switch to none config
is unnecessary

Test: Manually change usb configurations
Change-Id: I65e530b1fa46e4f0123cb951fdd3a20ab7589bc6
2016-10-13 17:32:21 -07:00
Philip P. Moltmann
880389e6cc Clear USB device defaults when user is removed
If a user is removed it is either the parent user of the profile or a
child user. If the parent is removed the whole profile group settings
are removed, but if only a child user is removed we have to remove the
user settings from the groups settings.

Test: Registered a USB device default for a child and parent user and
removed them. Checked dumpsys usb before and after
Fixes: 31995672

Change-Id: I984cd294dc01437b042687684c058eb79332f520
2016-10-11 10:10:53 -07:00
Philip P. Moltmann
a6bf206649 Make default USB handling apps per profile group.
If a USB device is plugged in a default app might be started. As the
user does not indicate which profile he is interested in by pluggin in a
USB device, all handling of this operation has to be per default group.

To do this Split UsbUserSettingsManager into UsbUserSettingsManager and
UsbProfileGroupSettingsManager and modify
UsbProfileGroupSettingsManager.

Bug: 29233186
Change-Id: I8e56b621eeb802966504360d372a8a0140106114
2016-09-15 15:40:39 -07:00
Philip P. Moltmann
031cee90a3 Allow connection from secondary profiles
... and send device-attached broadcasts to all apps instead of just the
current user.

Note: Usb*Manager.open* needs to be called with the identity of the
app.

Bug: 29233186
Change-Id: I225c47bdb409eee1c8fe0499d600fded470aa101
2016-09-08 10:59:18 -07:00
Keun-young Park
badbbae6fa allow external USB host management
- Setting config_UsbDeviceConnectionHandling_component leads into
  launching specified Activity whenever USB device is connected.
- This allows external Activity to manage USB device based on
  its own setup and settings.
- Device access can be passed to other app with permission update
  by UsbManager.grantPermission.
- added UsbDeviceConnection.resetDevice() to reset USB device connected.
  This is necessary to get device out from AOAP.
- Test requires installing UsbHostExternalManagmentTestApp and
  AoapTestHost to USB host, and AoapTestDevice to USB Device.

bug: 26404209
Change-Id: I8e77ddc646c15454d9b2ecf1356924cf6351fc28
2016-08-24 15:00:08 -07:00
Philip P. Moltmann
a025c89858 Exit enteringAccessoryMode when entered.
... so that a quick usb plug -> unplug actually causes both enter and
exit. Before the second update was treated as another enter.

Admittedly treating any first update as connect and any second update as
disconnect is sketchy, but this was the intention of the current code,
so just fix that for now.

Fixes: 29377436
Change-Id: Ib6bcc23ce5ec9979edcc38952a9414683513ca0c
2016-08-09 17:23:48 -07:00
Philip P. Moltmann
905c924196 Add (corrected) usb power sink handling am: 9ebf2a5683 am: 78ae5ebe58
am: df2277d66b

Change-Id: I5c53c4c84cfd08cc80c5e48f6e258b99d6b4cdd0
2016-08-04 21:01:47 +00:00
Philip P. Moltmann
9ebf2a5683 Add (corrected) usb power sink handling
This is a resubmit of change 0135516153 .
The previous change did not handle the case where the device was plugged
into a wall charger correctly.

Fixes: 30418683
Change-Id: Ia155f2230bdd3576c8fb8eb8cff11f544047c35a
2016-07-29 08:39:10 -07:00
Philip P. Moltmann
9979be916b Revert \\"Handle USB power role \\'sink\\'\\" am: 47e8089bf4
am: 4022d582d7

Change-Id: I203f5920b4346cfea4e47cef4d2b2f0f39e92a35
2016-07-27 21:34:15 +00:00
Philip P. Moltmann
47e8089bf4 Revert "Handle USB power role 'sink'"
This patch treats AC wall chargers like phones supplying power. We only want to show the notification when connected to another phone, not to a AC wall charger.

Bug: 30418683
This reverts commit 0135516153.

Change-Id: I304c3f78916896ddb12129b11a0e691b3ef77819
2016-07-27 16:32:59 +00:00
Philip P. Moltmann
76eb4b1a6c Handle USB power role \\'sink\\' am: 0135516153
am: 6d0ea86fec

Change-Id: I6dd5eb7a328bd4071c4c40a2a982ec4b7de0b785
2016-07-26 15:07:50 +00:00
Philip P. Moltmann
0135516153 Handle USB power role 'sink'
Fixes: 29963134
Change-Id: I7cfe042ed007d36cee5f8bc4c0fa33f8936cba3d
2016-07-15 13:21:29 -07:00
Mikhail Naganov
aab4c1ad48 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
2016-06-17 08:04:28 -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 0be6800b0f)
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
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