• Home
  • History
  • Annotate
  • only in /frameworks/base/services/usb/java/com/android/server/
History log of /frameworks/base/services/usb/java/com/android/server/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
3984cf625cf7df7906c0c86ad59eb42c750ff78c 10-Apr-2018 Kweku Adams <kwekua@google.com> Fixing typo in proto field.

Bug: 72814439
Bug: 74975371
Test: atest CtsIncidentHostTestCases:com.android.server.cts.UsbIncidentTest
Change-Id: Ia04c13b96bd1996e6e96f9b4e2e693af4cb97070
sb/UsbDebuggingManager.java
df101a459692cda5c73d149c582d68dc42ece852 27-Mar-2018 Jerry Zhang <zhangjerry@google.com> Merge "Write descriptors for Mtp in UsbService" into pi-dev
608ec66d62647f60c3988922fead33fd7e07755e 02-Mar-2018 Andrew Chant <achant@google.com> UsbHostManager: Restore inserted device logging

Restore logcat logging of newly-added USB devices.
Eliminate blacklist log lines.

Test: Connected USB Storage and USB audio devices.
Updated UsbDescriptorParserTests for device descriptor
version.

example output:
UsbHostManager: USB device attached: vidpid 03eb:2433 mfg/product/ver/serial Libratone/Libratone_INEAR/1.00/Inear_mcu_app_0.2.1_20160304 hasAudio/HID/Storage: true/true/false
UsbHostManager: USB device attached: vidpid 05dc:a82b mfg/product/ver/serial Lexar/ARA Storage /2.08/0024070163400215 hasAudio/HID/Storage: false/false/true
UsbHostManager: USB device attached: vidpid 18d1:5029 mfg/product/ver/serial Google/USB-C to 3.5mm-Headphone Adapter/22.80/201405280001 hasAudio/HID/Storage: false/true/false
UsbHostManager: USB device attached: vidpid 18d1:5025 mfg/product/ver/serial Google/USB-C to 3.5mm-Headphone Adapter/22.80/201405280001 hasAudio/HID/Storage: true/true/false

Bug: 74119682
Change-Id: I72688f651c819d4bdc48f6d6316570ca5fc54d1e
sb/UsbHostManager.java
sb/descriptors/UsbDescriptorParser.java
sb/descriptors/UsbDeviceDescriptor.java
0491f5aa0f3cc6b46bdf433bc900433b965943e2 02-Mar-2018 Andrew Chant <achant@google.com> UsbDescriptorParser: always parse in constructor

UsbDescriptorParser::parseDescriptors always returned true.
Remove the return value, and remove the one constructor that
doesn't parse descriptors so the device is always in a parsed state.

Bug: 74119682
Test: Built
Change-Id: I2dd8d439405867d78102a9591dd1db36fe3959dc
sb/UsbHostManager.java
sb/descriptors/UsbDescriptorParser.java
6d319b8aaa961862afac48010d96d03afb11fa1c 07-Dec-2017 Jerry Zhang <zhangjerry@google.com> Write descriptors for Mtp in UsbService

The current model for setting up a functionfs
function is:

UsbDeviceManager#setCurrentFunctions() ->
intent is sent to MtpReceiver to write the descriptors ->
init/hal waits for descriptors to write, then pulls up gadget ->
Gadget is configured, a USB_STATE intent starts MtpServer

The main downside of this is a lack of reliability because
the Mtp process could be killed at any point. Normally, a
gadget is unbound if its control endpoint is closed. no_disconnect
works around this, but is still a little janky. In addition, the
extra intent delays the startup of the gadget.

With the new model, UsbDeviceManager writes the descriptors
on initialization. Since it is a system service, it won't be killed.

UsbDeviceManager#setCurrentFunctions() ->
init/hal pulls up gadget ->
Gadget is configured, a USB_STATE intent starts MtpServer
MtpServer calls UsbManager#getControlFd to get a dup of the control
endpoint.

Also modify permissions so system server can access mtp files.

Bug: 72877174
Test: Change usb configurations to ptp/mtp
Change-Id: Id17d2b5930f4e1f37ec1b4f00add9d594174ad49
sb/UsbDeviceManager.java
sb/UsbService.java
ff1f7090c62ac7b4abff39ad432c38e7d30f2b3d 28-Feb-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Set systemReady before querying the portStatus."
23aee1bbb511310d636347d45a0e6fa14aae9543 28-Feb-2018 TreeHugger Robot <treehugger-gerrit@google.com> Merge changes from topic "terminal_type_fix"

* changes:
Add test for UsbDescriptorParser.java
USB Audio: broaden Terminal Type interpretation
d399f2eaff15aa3019a3ecc973afd1305b3ff68b 27-Feb-2018 Badhri Jagan Sridharan <Badhri@google.com> Set systemReady before querying the portStatus.

Since the callbacks are async, its possible that the callback gets
called before the systemReady flag is set.

Change-Id: I5752c097e25ef30a151461540dd7d5323cc927af
sb/UsbPortManager.java
0ef73801f5b5a560a1f84ccad3d13bd80b525de2 26-Feb-2018 Andrew Chant <achant@google.com> USB Audio: broaden Terminal Type interpretation

Terminal type is currently used to determine presence of audio input
or output capabilities on audio devices.

Broaden the set of terminal types accepted as inputs and outputs.

Test: Verified by playing with USB-C to 3.5mm adapter with
high impedance load, checked Terminal type reported as 0x0603.
Verified no audio on old build, audio on new build.
Checked with low impedance load with and without microphone.
Checked with no load.

Bug: 73813676
Change-Id: Ib9b291e4770dc3c03157df7ac4277da1692174d7
sb/descriptors/UsbDescriptorParser.java
sb/descriptors/UsbTerminalTypes.java
20b1414fe002df2d8aeb584dc1227f2962dfa17f 24-Feb-2018 Jerry Zhang <zhangjerry@google.com> Initialize functions as NONE in legacy handler.

Since adb is being removed from the functions read
from sys.usb.config anyway, it makes more sense to
set it to NONE on boot. This prevents errors with
devices that already have oem functions in the config.

Bug: 73010922
Test: Power test passes
Change-Id: I855ba228dbdd9f8c8a91842a8beb68a789fdf1e9
sb/UsbDeviceManager.java
5f53db38b2911105106ae7bda8e05a8779d6d4b8 14-Feb-2018 Andrew Chant <achant@google.com> Merge changes from topic "uac_jackdetect"

* changes:
Add a selected UsbAlsaDevice
ALSA jack detection support
Synchronize UsbAlsaDevice, rename playback/capture.
278f4c9a05c75eac73b6a659798266504c95e2a0 13-Feb-2018 Andrew Chant <achant@google.com> Add a selected UsbAlsaDevice

Keep track of the currently selected UsbAlsaDevice in a
synchronized manner.
Allow it to notify AudioService that it has been disabled
prior to replacing it with a new Audio Device.

Test: verified audio worked as expected when using
both UAC2 and non-UAC2 3.5mm adapters, with 3.5mm
plugging/unplugging and USB-C plugging/unplugging.

Change-Id: I8b76145490da38d4eec25f4f2bdb6695afa151b9
sb/UsbAlsaManager.java
07a97da51fc7d43db9903d793d614340b1cf3b67 06-Feb-2018 Andrew Chant <achant@google.com> ALSA jack detection support

Adds support for ALSA jack detection for USB.
Spawns a new thread for ALSA jack detection on device
insert. If the device doesn't support ALSA jack detection,
the thread terminates.

Test: UAC2 audio accessory and a kernel
which supports USB ALSA Jack detection, switching between
speaker and USB works perfectly with plug/unplug at jack.

Bug: 68337205
Bug: 70632415
Change-Id: I1800660ad4d2341f19ce7be6d6b01f81a7f2d1a6
sb/UsbAlsaDevice.java
sb/UsbAlsaJackDetector.java
sb/UsbAlsaManager.java
2135f41477bdf8f5a0149e6b2c6d0b5b10f643ac 13-Feb-2018 Jerry Zhang <zhangjerry@google.com> Don't set functions at registration on boot

If onRegistration is called before functions
are received, adb can be kicked on boot. To fix,
don't set functions if they are still being
requested.

Bug: 73168456
Test: adb logcat doesn't dc
Change-Id: I25bfe13604f0ce0c65c3eb82bcfafd9fcae0283f
sb/UsbDeviceManager.java
54b15e98cdb40969929fa23ce42e6817a4b8392c 13-Feb-2018 Andrew Chant <achant@google.com> Synchronize UsbAlsaDevice, rename playback/capture.

Synchronize external access to UsbAlsaDevice fields.
Rename all playback fields to output, capture to input.
Move Alsa Device String generation to UsbAlsaDevice.

Test: Used Google Play Music to test audio output while
inserting & removing USB audio devices.

Bug: 68337205
Bug: 70632415
Change-Id: I77d413736253e28a33993f45e6e405209563f3e4
sb/UsbAlsaDevice.java
sb/UsbAlsaManager.java
bbab23ff97688f33c5cc41d5d0e134c0d9f58c6c 08-Feb-2018 Andreas Gampe <agampe@google.com> Frameworks: Annotate trivial @GuardedBy in services/ misc

Add @GuardedBy for simple functions that require a single lock
and are named XYZLocked.

Derived by errorprone.

Bug: 73000847
Test: m
Test: m javac-check-framework RUN_ERROR_PRONE=true
Change-Id: Id1d9fbe5018250e3b9d1466fc5f670d5ad902fa3
sb/UsbProfileGroupSettingsManager.java
sb/UsbService.java
d33a85c4d781c8fcc2a15d38cee58dfab692a581 05-Feb-2018 Jerry Zhang <zhangjerry@google.com> Merge "Move sharedPreferences to DE directory"
371a3b879ba82bbe5a4d914328a20659131d0220 26-Jan-2018 Philip P. Moltmann <moltmann@google.com> Dump usb as DualDump

This allows to dump the USB state as proto-buf. This in turn allows to
automatically process this data.

Test: adb shell dumpsys usb
incident_report usb
No automated test possible as no field is guaranteed to be set
Change-Id: Ifdf22bfaf9c78226c420b11c43278013ce69f849
sb/UsbAlsaDevice.java
sb/UsbAlsaManager.java
sb/UsbDebuggingManager.java
sb/UsbDeviceManager.java
sb/UsbHostManager.java
sb/UsbMidiDevice.java
sb/UsbPortManager.java
sb/UsbProfileGroupSettingsManager.java
sb/UsbService.java
sb/UsbSettingsManager.java
sb/UsbUserSettingsManager.java
0be310a3039870d4e5674d356f5ca2ffb06c1309 01-Feb-2018 Jerry Zhang <zhangjerry@google.com> Move sharedPreferences to DE directory

Prevents crashes / loss of behavior when
user 0 is locked, but another user is
unlocked.

Bug: 72662661
Test: have lock on user 0, reboot, switch to and unlock user 10
Change-Id: I72767fc4726d3b316266a1499dbe51bd7d9830bc
sb/UsbDeviceManager.java
16d7913d982dd74bc4309128c4562c816e683bd7 02-Jan-2018 Paul McLean <pmclean@google.com> Optimize/streamline USB audio (dis)connect

Map from usb device "address" to ALSA card num.
Remove Alsa filespace monitor.

Bug: 72435641

Test: Connect various devices and check for correct input/out determination.
Prototype Headset, Presonus AudioBox 22VSL...

Change-Id: I9e25b3e9c1c3280c26171873c0a48c58cbb99fb5
sb/UsbAlsaDevice.java
sb/UsbAlsaManager.java
sb/UsbDeviceManager.java
sb/UsbHostManager.java
sb/descriptors/UsbDescriptorParser.java
50c00924d8483ea04ab64bc1d9775d6147afb591 31-Jan-2018 Paul McLean <pmclean@google.com> renamed UsbAudioDevice.java to UsbAlsaDevice.java

Test: Manual, build, run... AOK.

Change-Id: Iba43f94fd74aad826891534c648e61db0d0423b2
sb/UsbAlsaDevice.java
sb/UsbAlsaManager.java
sb/UsbAudioDevice.java
e649748eb69aad55fa77f43d3f658b2a51db1248 01-Feb-2018 Jerry Zhang <zhangjerry@google.com> Parse persist property the legacy way

Devices like bat still have oem functions
in the persist prop, so don't throw errors.

Test: device boots
Bug: 72765363
Change-Id: I7d1e334d7cafb1ba1f328ee4160da3b098f76fa1
sb/UsbDeviceManager.java
28b6fc9c25cd55c500426cdcbe233a123736fa0a 18-Jan-2018 Jerry Zhang <zhangjerry@google.com> Usb changes and strings for connected devices 2.0

New metrics constant and usb strings for the new
notification / details page.

Bug: 69333961
Test: Check notification
Change-Id: If9bde7f787e40e42bb991a99b032e1ff968a0a41
sb/UsbDeviceManager.java
327b809ad11a5094248652014227470c4be329e6 10-Jan-2018 Jerry Zhang <zhangjerry@google.com> Refactor and clean up USB, add tests

Change UsbManager apis to use long instead of string, to match
usb hal. Change UsbDeviceManager internals to match as well.

Remove isFunctionEnabled and add getEnabledFunctions. Callers
would often call isFunctionEnabled for every possible function
to get the list of functions, so getEnabledFunctions reduces the
number of aidl calls.

Separate out dependencies between UsbHandler and UsbDeviceManager
and staticize the UsbHandler classes. Add unit tests with
mocked out dependencies to test state transitions for UsbHandler.

Bug: 62876645
Test: atest UsbTests
Change-Id: I785c4c24121a70e725de9742c6af50a6bf1baea0
sb/UsbDeviceManager.java
sb/UsbService.java
e17b445b6c813f6f9bc93a5e3811128a197ef50b 10-Jan-2018 Dianne Hackborn <hackbod@google.com> Reduce pss collection amount, improve logging.

Tuned rates that we collect PSS, to reduce how much we do
that heavy operation. Added a new way to determine
whether a process has changed to a state for the
"first" time -- now this is when it has gone to that
state for the first time since it was in a lower state.
This will reduce the amount of time we consider a
process to be first to only when it has previously
gone into a higher state than it had before.

Keep track of more fine-grained information about why we
collect a PSS sample (not just internal, but for a single
process, all processes because of a mem state change, all
processes because of a poll).

Started collecting RSS in various places, so we can start
looking at that w.r.t. PSS and see about transitioning to
it is a new primary metric.

Added logging for many of the places where the system
writes its configuration files, so we can more easily
see any bad behavior going on in those areas.

Added some currently disabled code to read smaps directly
instead of using fgets(). Probably won't help, but want
tot test.

Bug: 70859548
Test: atest CtsAppTestCases
Change-Id: I400dba0f3ae9c024df51c946cfa592561028b598
sb/UsbProfileGroupSettingsManager.java
6754ca81c2a5f88d67b759c24db0b4aba3a82314 12-Jan-2018 Badhri Jagan Sridharan <Badhri@google.com> Add support for UsbDeviceManager to talk to USB GADGET HAL

Till now, Init scripts(property tiggers) are used define the
operation that needs to be performed when a certain gadget
composition needs to be enabled. Based on the user preference,
usb service sets the sys.usb.config which triggers the
corresponding property triggers in init scripts and usbservice
polls on sys.usb.state to infer whether the property triggers
have completed executing.

This CL makes UsbHandler class abstract to make init scripts
based legacy implementation and HAL based implementation to
share the common logic. The legacy init script based logic is
implemented by UsbHandlerLegacy and HAL based logic is implemented
by UsbHandlerHal. The decision on which one to initialize is
made depending on whether the device has Gadget HAL impelemented.

Since HIDL supports asynch calbacks, usb state management is moved
to the message queue to avoid polling incase of HAL based
implementation.

To switch to a new configuration:
1. UsbService calls setCurrentUsbFunctions and queues
MSG_SET_FUNCTIONS_TIMEOUT
2. If the setCurrentUsbFunctionsCb arrives on time,
then MSG_SET_FUNCTIONS_TIMEOUT is cancelled and
default functions are retried by queueing
MSG_SET_DEFAULT_FUNCTIONS if SUCCESS is not signalled.
3. If MSG_SET_FUNCTIONS_TIMEOUT gets executed, then,
default functions are retried by calling
setEnabledFunctions(null, false, mUsbDataUnlocked);

Also, for HAL based implementation config_oemUsbModeOverride is no
longer needed as hal can take of enabling oem specific functions.

Bug: 63669128
Test: Tested usb gadget configuration for both cases:
1. When gadget hal is present
2. When gadget hal is not present
Change-Id: Ifcef464a0b97b265872696346a76162f8e84d6c0
sb/UsbDeviceManager.java
30b9adfad1c5055044f0b585782b10f764e0ddf9 01-Dec-2017 Jerry Zhang <zhangjerry@google.com> Add setScreenUnlockedFunctions method to UsbManager

The screen unlocked functions save effort on setting
the usb config during each connection. These
functions persist between connections and between
boots. When the screen is unlocked and these
functions are set, the current functions will
be automatically set to the screen unlocked functions.

Also added svc command for this so it can be
used and tested while the UI is worked on.

Bug: 62876645
Test: svc usb setScreenUnlockedFunctions mtp
Test: Test functions with locking, unlocking, and
disconnecting, with no lockscreen, swipe, and pattern

Change-Id: Ia05e095917166d25398c4d310b02971e3a1bb12a
sb/UsbDeviceManager.java
sb/UsbService.java
f25c4eb7fdf89e8a012c92c585c988fe1b410b2c 11-Dec-2017 Paul McLean <pmclean@google.com> Adding ability to control how the USB data is dumped.

Also added tracing to android.UsbDevice creation.

Test: Try each dump command with CALYX Pat USB DAC & Dragonfly Red USB DAC

Change-Id: I2ec05dfa9c544d0c50ee59e3b990e9010cbe0aa0
sb/UsbHostManager.java
sb/UsbService.java
sb/descriptors/UsbConfigDescriptor.java
sb/descriptors/UsbDescriptorParser.java
sb/descriptors/UsbDeviceDescriptor.java
sb/descriptors/UsbEndpointDescriptor.java
sb/descriptors/UsbInterfaceDescriptor.java
2b3ae20bfc52c72266ff846a451eaac2259ebaeb 30-Nov-2017 Paul McLean <pmclean@google.com> Saving USB Device connect/disconnect info.

Test: Manual testing with Skylab, Mir, HTC dongle & Presonus AudioBox 22VSL
(and various others)

Change-Id: Ice1bb889bc4655805d6b117988a5ebc4baa48cde
sb/UsbHostManager.java
sb/descriptors/UsbDescriptorParser.java
558ff9d3f5f0a70d745b72d1d2d84f4e91850b8b 17-Nov-2017 Paul McLean <pmclean@google.com> Fixed class and subclass IDs sign extension on byte->int problem.

Devices - Skylab, Mir, HTC dongle, Presonus AudioBox 44VSL, HP mouse
Hard coded class ID of 0xFF and subclass 0xFD to match b/68944518 symptoms.

Bug: 68944518

Test: Manual - see above

Change-Id: I7330c57b15278158a2eb449f0463b91244a3e176
sb/descriptors/Usb10ACHeader.java
sb/descriptors/Usb10ACInputTerminal.java
sb/descriptors/Usb10ACMixerUnit.java
sb/descriptors/Usb10ACOutputTerminal.java
sb/descriptors/Usb10ASFormatI.java
sb/descriptors/Usb10ASFormatII.java
sb/descriptors/Usb10ASGeneral.java
sb/descriptors/Usb20ACHeader.java
sb/descriptors/Usb20ACInputTerminal.java
sb/descriptors/Usb20ACMixerUnit.java
sb/descriptors/Usb20ACOutputTerminal.java
sb/descriptors/Usb20ASFormatI.java
sb/descriptors/Usb20ASFormatII.java
sb/descriptors/Usb20ASFormatIII.java
sb/descriptors/Usb20ASGeneral.java
sb/descriptors/UsbACAudioControlEndpoint.java
sb/descriptors/UsbACAudioStreamEndpoint.java
sb/descriptors/UsbACEndpoint.java
sb/descriptors/UsbACFeatureUnit.java
sb/descriptors/UsbACHeaderInterface.java
sb/descriptors/UsbACInterface.java
sb/descriptors/UsbACInterfaceUnparsed.java
sb/descriptors/UsbACMidiEndpoint.java
sb/descriptors/UsbACMixerUnit.java
sb/descriptors/UsbACSelectorUnit.java
sb/descriptors/UsbACTerminal.java
sb/descriptors/UsbASFormat.java
sb/descriptors/UsbConfigDescriptor.java
sb/descriptors/UsbDescriptor.java
sb/descriptors/UsbDescriptorParser.java
sb/descriptors/UsbDeviceDescriptor.java
sb/descriptors/UsbEndpointDescriptor.java
sb/descriptors/UsbInterfaceDescriptor.java
sb/descriptors/UsbMSMidiHeader.java
sb/descriptors/UsbMSMidiInputJack.java
sb/descriptors/UsbMSMidiOutputJack.java
sb/descriptors/report/UsbStrings.java
9d84fee2eaa54b6e229d165e380c35ccc559de72 17-Nov-2017 Paul Mclean <pmclean@google.com> Revert "Revert "Eliminate native/JNI/callback USB Descriptor parsing mechanism""

This reverts commit 115cd64f168e14401ba3a2062c8cbe9361416802.

Change-Id: I8be17cf939397b3c8ac6b11759b8195f5febab10
sb/UsbAlsaManager.java
sb/UsbHostManager.java
sb/descriptors/UsbConfigDescriptor.java
sb/descriptors/UsbDescriptorParser.java
sb/descriptors/UsbDeviceDescriptor.java
sb/descriptors/UsbEndpointDescriptor.java
sb/descriptors/UsbInterfaceDescriptor.java
sb/descriptors/report/HTMLReportCanvas.java
sb/descriptors/report/ReportCanvas.java
sb/descriptors/report/TextReportCanvas.java
c8ed5ecdc44ec92db5fe2c19a8ea9648e0e815bc 25-Sep-2017 Emilian Peev <epeev@google.com> Check camera permissions for any devices using the VIDEO class

Any USB devices that are of class VIDEO or have similar
interfaces should check whether the calling client has
camera permissions before granting access to the device.
The above restriction will apply for any packages that
target P or above.

Bug: 27367690
Test: Manual using 3-rd party USB webcam applications.
Change-Id: I7b4f808d344cae33fde93e6d81c7cceed523e24a
sb/UsbHostManager.java
sb/UsbService.java
sb/UsbUserSettingsManager.java
630fc40aadf3f83671607bd6a651770958c16dfa 13-Nov-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Don't show "always use" when app can't be default"
115cd64f168e14401ba3a2062c8cbe9361416802 10-Nov-2017 Eric Laurent <elaurent@google.com> Revert "Eliminate native/JNI/callback USB Descriptor parsing mechanism"

This reverts commit 513160fd807e43c6a8268cbe279d8398b44acb26.

Bug: 68944518
Bug: 68008691
Bug: 68337205
Test: USB connection to audio device and laptop
Change-Id: If9223aae953581b2f2e3a6b1adf174528aa94132
sb/UsbAlsaManager.java
sb/UsbHostManager.java
sb/descriptors/UsbConfigDescriptor.java
sb/descriptors/UsbDescriptorParser.java
sb/descriptors/UsbDeviceDescriptor.java
sb/descriptors/UsbEndpointDescriptor.java
sb/descriptors/UsbInterfaceDescriptor.java
sb/descriptors/report/HTMLReportCanvas.java
sb/descriptors/report/ReportCanvas.java
sb/descriptors/report/TextReportCanvas.java
5a633c6e4d9661c574ac34e891da22ec62b5e383 10-Nov-2017 Philip P. Moltmann <moltmann@google.com> Don't show "always use" when app can't be default

Each USB device can have one default handler. This app is launched when
the device is plugged in. A default handler automatically gets
permission to access the device when launched.

All other apps have to request the permission to access the USB device
via UsbManager.requestPermission. In the permission dialog there is an
option to make the app the default app for the device. Of course this
only makes sense if this app declares the right properties to be
auto-launched. Hence check this and only then show this options.

Also made the string in the dialogs easier to understand.

AccessoryFilter and DeviceFilter needed to be copied so I can access
them from system-ui. No code change in these classes.

Test: requested permissions from app that could by the default for the
device and from an app that could not. Also tested "confirm" flow
that is executed when the device is plugged in and a app that
might be default is installed.
Bug: 67381583
Change-Id: I12eb7efed0ad107c70ae32433a5629108f252486
sb/UsbProfileGroupSettingsManager.java
92a948e4cb8cfa026487884e4fb1e91a66e85fc4 03-Nov-2017 Selim Gurun <sgurun@google.com> Merge "Respect Accessory timeout value when restoring defaults" am: 3ddf22e69c am: c37036d164
am: 79a2d2a936

Change-Id: I5d315bf170184c65d2713c4be55170bab1eb42f6
79a2d2a936c735adc33d570de4330f1852e69d5d 03-Nov-2017 Selim Gurun <sgurun@google.com> Merge "Respect Accessory timeout value when restoring defaults" am: 3ddf22e69c
am: c37036d164

Change-Id: Id6feac7351a4627c0a4a90b67899ee2c1aa469e8
c5bd3d3bb8864371d6c7720cb58d0a9d53ebe684 03-Nov-2017 Selim Gurun <sgurun@google.com> Respect Accessory timeout value when restoring defaults

Android accessory mode timeout value is a lot larger than default
timeout value (10 seconds vs. 1 second). The large timeout
value is needed to accomodate for HUs that are not quick
to respond after MTP to Accessory mode change.

Bug: 68819844
Test: Manual
Change-Id: I665e1001f8df66fb00cbfcbf6c58d97c372797fc
sb/UsbDeviceManager.java
513160fd807e43c6a8268cbe279d8398b44acb26 19-Oct-2017 Paul McLean <pmclean@google.com> Eliminate native/JNI/callback USB Descriptor parsing mechanism

Also optimized connection mechanism.

Bug: 68008691
Bug: 68337205
Test: Manual
Devices - Skylab, Mir, HTC dongle, Presonus AudioBox 44VSL, HP mouse

Change-Id: I287bcdd251b38d2a5cbd37bca1a80bf7f7b0a265
sb/UsbAlsaManager.java
sb/UsbHostManager.java
sb/descriptors/UsbConfigDescriptor.java
sb/descriptors/UsbDescriptorParser.java
sb/descriptors/UsbDeviceDescriptor.java
sb/descriptors/UsbEndpointDescriptor.java
sb/descriptors/UsbInterfaceDescriptor.java
sb/descriptors/report/HTMLReportCanvas.java
sb/descriptors/report/ReportCanvas.java
sb/descriptors/report/TextReportCanvas.java
fd47f4032da128e78d605e10f9e67786b08a14e2 06-Oct-2017 Paul McLean <pmclean@google.com> Checking for errors opening/parsing ALSA "cards" file.

Test: Manual
Bug: 67590842

Change-Id: I62a5da97776bc7b7f03d3883cb06607cbdf6f6ce
sb/UsbAlsaManager.java
sb/UsbHostManager.java
50f8bbb9cf0d32476caf91570e0e6bdbf2d7ac99 05-Oct-2017 Paul McLean <pmclean@google.com> 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
sb/UsbAlsaManager.java
aa12c85c9865754b7bbaf68dd75814c6fbd67177 06-Sep-2017 Paul McLean <pmclean@google.com> Merge "Add dump of USB descriptors to the dumpsys for UsbHostManager service." into oc-mr1-dev am: e7b8f6d24a
am: a3841871a3

Change-Id: Idcbb5dd875ec1afcf4250b641e707cc9f2115e10
53215d1f7d79c6577b32c3b71db6db6435c95f09 31-Aug-2017 Paul McLean <pmclean@google.com> 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.
sb/UsbHostManager.java
sb/descriptors/UsbASFormat.java
sb/descriptors/UsbDeviceDescriptor.java
sb/descriptors/report/TextReportCanvas.java
sb/descriptors/report/UsbStrings.java
sb/descriptors/tree/UsbDescriptorsACInterfaceNode.java
6598a033ab9c2ebb9b9ebd5d95c531f3a27f4b7d 31-Aug-2017 Paul Mclean <pmclean@google.com> Merge "Adding USB audio-class 2.0 spec descriptors." into oc-mr1-dev am: 87cb6d806e
am: ea09d76403

Change-Id: I777211f0a458b256cfc884c64df29bd5fed0b84a
87cb6d806e83bb3c0e3ea778acf1e36df70374f3 31-Aug-2017 Paul Mclean <pmclean@google.com> Merge "Adding USB audio-class 2.0 spec descriptors." into oc-mr1-dev
fd7cb85feff517f3cc94384102933aa4485e1fc5 07-Jul-2017 Paul McLean <pmclean@google.com> 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
sb/descriptors/ByteStream.java
sb/descriptors/Usb10ACHeader.java
sb/descriptors/Usb10ACInputTerminal.java
sb/descriptors/Usb10ACMixerUnit.java
sb/descriptors/Usb10ACOutputTerminal.java
sb/descriptors/Usb10ASFormatI.java
sb/descriptors/Usb10ASFormatII.java
sb/descriptors/Usb10ASGeneral.java
sb/descriptors/Usb20ACHeader.java
sb/descriptors/Usb20ACInputTerminal.java
sb/descriptors/Usb20ACMixerUnit.java
sb/descriptors/Usb20ACOutputTerminal.java
sb/descriptors/Usb20ASFormatI.java
sb/descriptors/Usb20ASFormatII.java
sb/descriptors/Usb20ASFormatIIEx.java
sb/descriptors/Usb20ASFormatIII.java
sb/descriptors/Usb20ASGeneral.java
sb/descriptors/UsbACAudioControlEndpoint.java
sb/descriptors/UsbACAudioStreamEndpoint.java
sb/descriptors/UsbACEndpoint.java
sb/descriptors/UsbACFeatureUnit.java
sb/descriptors/UsbACHeader.java
sb/descriptors/UsbACHeaderInterface.java
sb/descriptors/UsbACInputTerminal.java
sb/descriptors/UsbACInterface.java
sb/descriptors/UsbACInterfaceUnparsed.java
sb/descriptors/UsbACMidiEndpoint.java
sb/descriptors/UsbACMixerUnit.java
sb/descriptors/UsbACOutputTerminal.java
sb/descriptors/UsbACSelectorUnit.java
sb/descriptors/UsbACTerminal.java
sb/descriptors/UsbASFormat.java
sb/descriptors/UsbASFormatI.java
sb/descriptors/UsbASFormatII.java
sb/descriptors/UsbASGeneral.java
sb/descriptors/UsbBinaryParser.java
sb/descriptors/UsbConfigDescriptor.java
sb/descriptors/UsbDescriptor.java
sb/descriptors/UsbDescriptorParser.java
sb/descriptors/UsbDeviceDescriptor.java
sb/descriptors/UsbEndpointDescriptor.java
sb/descriptors/UsbHIDDescriptor.java
sb/descriptors/UsbInterfaceAssoc.java
sb/descriptors/UsbInterfaceDescriptor.java
sb/descriptors/UsbMSMidiHeader.java
sb/descriptors/UsbMSMidiInputJack.java
sb/descriptors/UsbMSMidiOutputJack.java
sb/descriptors/UsbTerminalTypes.java
sb/descriptors/UsbUnknown.java
sb/descriptors/report/HTMLReportCanvas.java
sb/descriptors/report/HTMLReporter.java
sb/descriptors/report/ReportCanvas.java
sb/descriptors/report/Reporter.java
sb/descriptors/report/Reporting.java
sb/descriptors/report/TextReportCanvas.java
sb/descriptors/report/UsbStrings.java
sb/descriptors/tree/UsbDescriptorsACInterfaceNode.java
sb/descriptors/tree/UsbDescriptorsConfigNode.java
sb/descriptors/tree/UsbDescriptorsDeviceNode.java
sb/descriptors/tree/UsbDescriptorsEndpointNode.java
sb/descriptors/tree/UsbDescriptorsInterfaceNode.java
sb/descriptors/tree/UsbDescriptorsTree.java
sb/descriptors/tree/UsbDescriptorsTreeNode.java
29b3cfa21daeb4190948b99cbed093e684f22c56 25-Aug-2017 Jerry Zhang <zhangjerry@google.com> Merge changes from topic "am-2cfb180af8604b6fac1598107a7b546e" into oc-mr1-dev-plus-aosp
am: 54c6447f47

Change-Id: I13aeac421ecf7a54f16e0fd6aaa19be3f513be4a
e537a8313987bd10208281c4fa5c6834b4fd1d15 23-Aug-2017 Jerry Zhang <zhangjerry@google.com> 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
sb/UsbDeviceManager.java
83a0d6fa577fab4d45aba38e3eb52b08b8123c17 19-Aug-2017 Badhri Jagan Sridharan <Badhri@google.com> 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
sb/UsbDeviceManager.java
e15b5619c5405ec57119611733929f091a7e3cbc 01-Aug-2017 Badhri Jagan Sridharan <Badhri@google.com> Merge "Reword analog audio not supported notification" into oc-dr1-dev am: 69840ca338
am: 89163cf020

Change-Id: Idf481243ae12d62e2fe492d7834ef0d8e7476a04
fb80072f9926ea74f2e957fc86eb935ac753e01d 01-Aug-2017 Badhri Jagan Sridharan <Badhri@google.com> Merge "Reword analog audio not supported notification" into oc-dr1-dev
am: 69840ca338

Change-Id: I6a9a611c13de7a63e6d5bdbf4718827f2295a28b
69840ca338347a1c2607d0f40d061c7be0e0c584 01-Aug-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Reword analog audio not supported notification" into oc-dr1-dev
09acfdf0c732ba2419ab7f6fbe8e0378610ae5f4 01-Aug-2017 Paul Mclean <pmclean@google.com> Merge "Fix exceptions causing HTC dongle (and JBL headset) to fail connection logic." into oc-dr1-dev am: f3562ffdfb
am: 3e62b611f0

Change-Id: I4d5c511c043048e79b4846febda85f521fb59f31
18d64cf8fe4698c35f0f421dba3ab777ffbc8bba 01-Aug-2017 Paul Mclean <pmclean@google.com> Merge "Fix exceptions causing HTC dongle (and JBL headset) to fail connection logic." into oc-dr1-dev
am: f3562ffdfb

Change-Id: I0304bf7c72a340f4bebebea89d2e934ae5830b33
30c8efa66ba6b08de951ad672a6004da04059af2 31-Jul-2017 Badhri Jagan Sridharan <Badhri@google.com> 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
sb/UsbDeviceManager.java
7d545bef6077d55dcbc3533e416698bf62085d41 29-Jul-2017 Paul McLean <pmclean@google.com> Fix exceptions causing HTC dongle (and JBL headset) to fail connection logic.

Bug: 64108509
Test: Manual

Change-Id: I9574f34cea4ff9ef3e18553a138f1a8b95b1b108
sb/descriptors/UsbDescriptorParser.java
1e249aeafa3539f2a4a2bb47b1fb2996f7627b01 19-Jul-2017 Badhri Jagan Sridharan <Badhri@google.com> Merge "Always reevaluate whether to show the notification for USB_DEVICE_* intents" into oc-dr1-dev am: d5f442d65b
am: 19ad4c2055

Change-Id: I4b6edbefd70585302959aa830f5a6d50f4f01a4d
5e79cbb2913c28ca6d79001ddaa0c8cec78b3eed 19-Jul-2017 Badhri Jagan Sridharan <Badhri@google.com> 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
sb/UsbDeviceManager.java
39c9e18721729c38252e8dd5f2d2736aa145c67d 13-Jul-2017 Paul McLean <pmclean@google.com> 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
20568917af6d2a6c569d7f0f0155e80c3bcd1b78 11-Jul-2017 Paul McLean <pmclean@google.com> 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
sb/descriptors/UsbDescriptorParser.java
6276bb899e810655fab9083393c7f4d2a494b7d7 12-Jul-2017 Badhri Jagan Sridharan <Badhri@google.com> 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
sb/UsbDeviceManager.java
f148e8ecceb4bb2f65dfe308aad59531db06059e 11-Jul-2017 Paul McLean <pmclean@google.com> Merge "Catch exception in descriptor parser causes device connection to be skipped." into oc-dr1-dev am: 22d4bf2283
am: 702d82fdc0

Change-Id: Ia45c777b095ff8c29042145fd11b29dcace24366
b82963f3e038cf12708374c78aff3f57619d02b7 10-Jul-2017 Paul McLean <pmclean@google.com> 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
sb/UsbHostManager.java
b60c48a6a2c5cf3f20ff2c20bf930e069afd2f01 06-Jul-2017 Jerry Zhang <zhangjerry@google.com> Merge "Broadcast only if boot complete" into oc-dr1-dev
885b9e7133438e0ccfb782b62f0e93cae5b39d60 29-Jun-2017 Jerry Zhang <zhangjerry@google.com> 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
sb/UsbDeviceManager.java
6bad7044f5b5f12fdf69d388b6cd9f028ded9806 30-Jun-2017 Colin Cross <ccross@android.com> Merge changes I09ecc525,I83e7e8ef

* changes:
Revert "Do not use lambda as it breaks javac"
Add missing dependency to services for desugaring
ed0cc81212c44f831aed19661a4377ff99cdb60c 29-Jun-2017 Jerry Zhang <zhangjerry@google.com> Merge "Broadcast only if boot complete"
e3bb95dddb3849d3a54538f507bfe83f6b74cb62 29-Jun-2017 Paul McLean <pmclean@google.com> Merge "Adding USB Headset awareness." into oc-dr1-dev am: f56b57781e
am: 1ae4273154

Change-Id: I24ffbb79b965df15a22dbc5d6ce3ae90ddb27b50
dc0c14f169430915df4b9613f88264080ce5633c 29-Jun-2017 Jerry Zhang <zhangjerry@google.com> 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
sb/UsbDeviceManager.java
03196cdf2eaaf3ca84454e74218114b5c02c161b 29-Jun-2017 Colin Cross <ccross@android.com> 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
sb/UsbPortManager.java
b5eaa809da69865cbde156007ae5363f9209f932 08-Jun-2017 Paul McLean <pmclean@google.com> Adding USB Headset awareness.

Bug: 36220140
Bug: 62043095
Test: Manual
Change-Id: Ic4636e3dc2dfce0154e6405848bea7752cf2d07b
sb/UsbAlsaManager.java
sb/UsbHostManager.java
sb/descriptors/ByteStream.java
sb/descriptors/UsbACAudioControlEndpoint.java
sb/descriptors/UsbACAudioStreamEndpoint.java
sb/descriptors/UsbACEndpoint.java
sb/descriptors/UsbACFeatureUnit.java
sb/descriptors/UsbACHeader.java
sb/descriptors/UsbACInputTerminal.java
sb/descriptors/UsbACInterface.java
sb/descriptors/UsbACMidiEndpoint.java
sb/descriptors/UsbACMixerUnit.java
sb/descriptors/UsbACOutputTerminal.java
sb/descriptors/UsbACSelectorUnit.java
sb/descriptors/UsbACTerminal.java
sb/descriptors/UsbASFormat.java
sb/descriptors/UsbASFormatI.java
sb/descriptors/UsbASFormatII.java
sb/descriptors/UsbASGeneral.java
sb/descriptors/UsbBinaryParser.java
sb/descriptors/UsbConfigDescriptor.java
sb/descriptors/UsbDescriptor.java
sb/descriptors/UsbDescriptorParser.java
sb/descriptors/UsbDeviceDescriptor.java
sb/descriptors/UsbEndpointDescriptor.java
sb/descriptors/UsbHIDDescriptor.java
sb/descriptors/UsbInterfaceAssoc.java
sb/descriptors/UsbInterfaceDescriptor.java
sb/descriptors/UsbMSMidiHeader.java
sb/descriptors/UsbMSMidiInputJack.java
sb/descriptors/UsbMSMidiOutputJack.java
sb/descriptors/UsbTerminalTypes.java
sb/descriptors/UsbUnknown.java
sb/descriptors/report/HTMLReporter.java
sb/descriptors/report/Reporter.java
sb/descriptors/report/Reporting.java
sb/descriptors/report/UsbStrings.java
e37eda7b413099f881f348aeafc5d2d33639484e 28-Jun-2017 Philip P. Moltmann <moltmann@google.com> Do not use lambda as it breaks javac

Bug: 63078196
Test: Built
Change-Id: I6f195ad127e95b76b85ad7417f31ac19af0ac5bc
sb/UsbPortManager.java
bee04d08b555b030c6e6cf31b10124862411eeb1 27-Jun-2017 Philip P. Moltmann <moltmann@google.com> Clean up USB*Manager.

Just automatic cleanup.

Test: Built
Change-Id: I1da09d6b43503a6b77a3619f0f8513ef39cf2d75
sb/UsbDebuggingManager.java
sb/UsbDeviceManager.java
sb/UsbHostManager.java
sb/UsbPortManager.java
sb/UsbProfileGroupSettingsManager.java
sb/UsbService.java
sb/UsbSettingsManager.java
sb/UsbUserSettingsManager.java
31f5b6875c1b6b84caec2ef27861a703f4a79a6d 06-Jun-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Enable MTP or ADB when default functions are enabled"
42f4815eff4028c34bf496d30474b042a72d279f 05-Jun-2017 Jerry Zhang <zhangjerry@google.com> Merge "Remove ptp from persist config on boot" into oc-dev am: 1d1cf13056
am: 8d5570b9e1

Change-Id: I792ed0959e5a24ef8893a1bd63e3a33278462556
6032c354d9c7bc7986faaa9eea467896318a7a66 02-Jun-2017 Jerry Zhang <zhangjerry@google.com> 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
sb/UsbDeviceManager.java
7f3047e6b6613e35f99fa505d4c9f1b99cf27c60 24-May-2017 Badhri Jagan Sridharan <Badhri@google.com> 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
sb/UsbDeviceManager.java
3a958a09d23fb5500c329f806e4b7e404502473e 23-May-2017 Jerry Zhang <zhangjerry@google.com> Merge "Revert "Upgrade logging for UsbDeviceManager to narrow down bugs."" into oc-dev
daa9c19daeff49ebdd7f5ea847292b68334132fc 05-May-2017 Jerry Zhang <zhangjerry@google.com> Revert "Upgrade logging for UsbDeviceManager to narrow down bugs."

This reverts commit c889b4f4eb62ae7ad8de3ff3d98768e71cb3ad5a.

Merged-In: I74306bacad2a61471a9b8c9fd881229b22b6975e
Change-Id: I74306bacad2a61471a9b8c9fd881229b22b6975e
sb/UsbDeviceManager.java
b2dac523919754b635fb3297d3b9b52909262ac4 05-May-2017 Jerry Zhang <zhangjerry@google.com> Revert "Upgrade logging for UsbDeviceManager to narrow down bugs."

This reverts commit c889b4f4eb62ae7ad8de3ff3d98768e71cb3ad5a.

Change-Id: I74306bacad2a61471a9b8c9fd881229b22b6975e
sb/UsbDeviceManager.java
653fbeeec4b8f42787d480c2b0a0e9c5f479202a 12-May-2017 Jerry Zhang <zhangjerry@google.com> Merge "Only force reset when adb is not enabled (i.e. mtp is)" into oc-dev am: f874fd319e
am: c5a4576cab

Change-Id: I153a5ad3e4bd0de9a62ef39ebc7579f4916b79e3
278685d468da236366845ede2f29ce3a84c901eb 12-May-2017 Philip P. Moltmann <moltmann@google.com> Merge "Remove forward matches before checking for default" into oc-dev am: d53cbfd0dc
am: ba8b3f05b6

Change-Id: Ic35779f6b6ad97dc1a6f83356dfa45e0d5b5f406
f874fd319e7abfb8f8421827a0ce224b9881b661 12-May-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Only force reset when adb is not enabled (i.e. mtp is)" into oc-dev
ad962a923c0b8ec555d3474b394bc3bed0f3613d 11-May-2017 Jerry Zhang <zhangjerry@google.com> 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
sb/UsbDeviceManager.java
0d78363a39de01232097a90933cfeb9f8bbe823d 08-May-2017 Philip P. Moltmann <moltmann@google.com> 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
sb/UsbProfileGroupSettingsManager.java
16bcd7219d968602d09c8c86460b31ffb3d46990 10-May-2017 Philip P. Moltmann <moltmann@google.com> Merge "Merge "Fixes for handling users + default for USB" into oc-dev am: 5262ae9b87" into oc-dev-plus-aosp
am: bc535b11b6

Change-Id: I6e20b889abbb7d2c037d71c271a733e0639b3e1e
5262ae9b878c5cd7e4fb7de00914ed4c35b10ce9 10-May-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Fixes for handling users + default for USB" into oc-dev
9507d707189fa75757a3c69c9964ee93e78a0cc2 09-May-2017 Jerry Zhang <zhangjerry@google.com> Merge "Always force set functions on disconnect" into oc-dev am: bf783e24cf
am: 4fdcb5d6fe

Change-Id: I8d7656a046fe2e649c73f4ad1505e9b7cf2625f0
d4b09d4e16a9dc2bb08b1e06b87c02de3f46308c 29-Apr-2017 Philip P. Moltmann <moltmann@google.com> Fixes for handling users + default for USB

Once a user plugs in a USB device (or accessory) the user can decide
which app should be started by default once the device is plugged in.
I.e. this app becomes the "default" for this USB device. If the user has
a work profile the default app is set for all profiles of the current
profile group (i.e. personal and work profile) as at any point in time
one profile group is visible on the screen.

There were some issues in the code:
- fix small obvious bugs

- use userPackage (==packageName + user) everywhere instead of only
packageName as we have to distinguish between apps of different
profiles.
- Stop accessing userPackage.packageName whereever possible to avoid
mistakenly ignoring the user

- Monitor packages of all users and deal only with users of the current
profile group.
- Do not react to package changes/updates/modifications. While it is
possible that an app gained the ability to deal with new USB devices on
update, we should not clear the default app for a default device. This
is because (1) this situation is exceedingly rare and (2) we do not
easily know when an app gained the ability to deal with a device. The
user can still manually clear the USB default app via Settings.

- The old DeviceFilter.matches code did not make sense. An app that
wanted to replace the previous default app would have needed to know
the serial number of the device.

Test: - Searched for access to UserPackage.packageName and we only use it
directly three times now. I checked these occurances and it is save
to use.
- Ran the following test
- Install app that can handle a USB device in personal profile
- make this app the default for this USB device
- Install same app in work profile -> default was be cleared as
it is not clear if the user
might prefer the other app
- make the work app the default for this USB device
- update non-work app -> default should not be cleared as the the
update is usually not triggered by the
user and we should just keep the
selection the user made before
- update work app -> App is already default
- uninstall work app -> default should be cleared as the default
app was removed
Fixes: 36610004
Change-Id: I294b582c36228169ac12a02d8007a4541e386d57
sb/UsbProfileGroupSettingsManager.java
f706fe2f6000d0d7c132c17e622cb96e8eaabc4c 09-May-2017 Jerry Zhang <zhangjerry@google.com> Always force set functions on disconnect

Functionfs no_disconnect mode will close the function on
disconnect so the current handling won't suffice for cases
where the mtp process is killed while MtpService is running.
This can happen when anything in Media/DownloadProvider ANRs
or similar.

Solve this by always setting the config at disconnect time.

Bug: 38010151
Test: Connect with MTP, am force-stop com.android.providers.media,
reconnect

Change-Id: Iaf012f6e2f11151f34d834efe08777dd02c0aec5
sb/UsbDeviceManager.java
405ce17abb7ec9d3f20abf8333314aa2c64d0b8b 19-Apr-2017 Badhri Jagan Sridharan <Badhri@google.com> Notify the user when an unsupported accessory is attached

This CL pops up a notification to the user when the device does not
support Analog Type-C headphones but the user connects one.
i.e when the Usb port status reports currentMode=audio_acc, but
audio_acc is not present in the supportedModes list.

Bug: 36604276
Test: Manually test inserting an Audio accessory
Change-Id: If514b9f238da196a7157e1aacb6d7690fde66f21
sb/UsbDeviceManager.java
20137dc1481e8efec47d45d8ee0828623b5af8f9 13-Mar-2017 Glenn Kasten <gkasten@google.com> USB audio: increase protection of member fields

Replace public by private or package access in field declarations,
and add getters and setters as needed.

Test: compiles OK
Change-Id: Ief3fffb6a21d2e4d05153839f444617ea5e70846
sb/UsbAlsaManager.java
sb/UsbAudioDevice.java
f9e6e70687afedff4e37b146a542990394e748a3 27-Apr-2017 Glenn Kasten <gkasten@google.com> Merge "Add comments"
d6247427ac3137555055fda2bed511db4941ed30 27-Apr-2017 Julia Reynolds <juliacr@google.com> Merge "Api updates" into oc-dev am: f84467e19f
am: 7ee513c27b

Change-Id: Iafbf2f2ca92b288de7bded40772cd15eca2012ee
f84467e19f16a63f47f13bfc9263c70b46816c24 27-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Api updates" into oc-dev
ece721f8cd3a93e4f40ba08ed8047f11c05b3551 27-Apr-2017 Thierry Strudel <tstrudel@google.com> Merge "Update UsbService to V1_1 usb hal"
ef4b303fc27056ae137563bc958eb3efd016972e 19-Apr-2017 Badhri Jagan Sridharan <Badhri@google.com> Update UsbService to V1_1 usb hal

This CL adapts Usb service to V1_1 hal.
V1_1 hal supports reporting audio_adapter accessory
and debug accessory.

Bug: 36604276
Test: Manually test inserting an Audio accessory.
Also tested to made sure that change is compatible with V1_0
implementations
Change-Id: I8e44f5e9ae14b0e41965e8d355c99ac42af93f23
sb/UsbPortManager.java
bad42976009ffb61010136ed8055f9e0f6d2e416 25-Apr-2017 Julia Reynolds <juliacr@google.com> Api updates

- Better documentation on DEFAULT_CHANNEL_ID
- Renaming getChannel/setChannel/getTimeout/setTimeout
- Add documentation to getShortcutId
- @hide parcel constructors

Test: make, make cts
Bug: 37672218

Change-Id: I695b2620c51638a84930e9d1c5fbfd6d85699b55
sb/UsbDeviceManager.java
6f9dbb1203424972850b17d897c2b3d9b803b488 21-Apr-2017 Jerry Zhang <zhangjerry@google.com> Reorder USB_STATE updates so config_changed is not replaced.

Because of flag INTENT.ACTION_REPLACE_PENDING, intents
sent in rapid succession could replace previous intents
that have not been processed, and it is unreliable when
or whether this happens. Since CONFIG_CHANGED cannot afford
to be lost, make sure it is sent last, so it is always
processed.

Bug: 34873000
Test: lots of unplugging/plugging
Change-Id: I9264d5129139cf3f433bbcd068e8b292fec6cd31
sb/UsbDeviceManager.java
740ca0f9f03c669b5a4abf33c970a817842bd7a5 20-Apr-2017 Jerry Zhang <zhangjerry@google.com> Don't skip intents where config changed.

Since we are adding ffs.mtp.ready to the init
scripts, we can no longer skip intents that cause
that property to be set.

This fixes the case where device is disconnected
and adb is repeatedly enabled/disabled.

Test: enable/disable adb, usb mtp
Bug: 33220530
Change-Id: I48e687c1af3f9da9e522ebe879285877c0168da8
sb/UsbDeviceManager.java
768dd994f388774dcfcebf4c960f5a27828ff119 21-Apr-2017 Jerry Zhang <zhangjerry@google.com> Reorder USB_STATE updates so config_changed is not replaced.

Because of flag INTENT.ACTION_REPLACE_PENDING, intents
sent in rapid succession could replace previous intents
that have not been processed, and it is unreliable when
or whether this happens. Since CONFIG_CHANGED cannot afford
to be lost, make sure it is sent last, so it is always
processed.

Bug: 34873000
Test: lots of unplugging/plugging
Change-Id: I9264d5129139cf3f433bbcd068e8b292fec6cd31
sb/UsbDeviceManager.java
58bffb24d74f2cfb03d54432c7521b91fd481172 22-Apr-2017 Jerry Zhang <zhangjerry@google.com> Merge "Upgrade logging for UsbDeviceManager to narrow down bugs." into oc-dev am: 6d3747ebe2
am: 7f986ba87b

Change-Id: I45d4b1f7fbf9268206e0c90636f02bf0d3ae5d66
c889b4f4eb62ae7ad8de3ff3d98768e71cb3ad5a 21-Apr-2017 Jerry Zhang <zhangjerry@google.com> Upgrade logging for UsbDeviceManager to narrow down bugs.

Will be reverted once bugs are caught.

Bug: 34873000
Test: None
Change-Id: Ia43e0ccb1c22c767c6ef3edbf04cef024662cd15
sb/UsbDeviceManager.java
2c284916d7e7ef317fca9a0d86d59a5e7326b967 20-Apr-2017 Jerry Zhang <zhangjerry@google.com> Merge "Only send HOST_STATE intents when host mode is used." into oc-dev am: a73f9f874a
am: bf51f836ae

Change-Id: Ie358c38f98d186ed0197248fcf82db2913cfe97d
41ebde2bb35e8a5df25d9d2edb49e93585a015dd 18-Apr-2017 Jerry Zhang <zhangjerry@google.com> Only send HOST_STATE intents when host mode is used.

Previously HOST_STATE update intents would broadcast if the
device was in gadget mode but not configured. This would
override the sticky intent, causing MtpReceiver to fail.

This is fixed by only updating host state if host is connected
or if host is being disconnected (was connected before).

Bug: 34873000
Test: set up lockscreen, reboot device while plugged in, unplug before
unlocking, verify usb works.

Change-Id: Ic424e678ba72401ee8ec975e915727272edf3767
sb/UsbDeviceManager.java
82d49dfbefab033320ec004df1be5934fa83a585 14-Apr-2017 Badhri Jagan Sridharan <Badhri@google.com> Repost USB and ADB notification when locale changes

Bug: 37266276
Test: Manually tested the language of active notifications after
switching language.

Change-Id: I0cef61fbd155e0c9789f52a140561c71969fbab7
sb/UsbDeviceManager.java
19d6c7a9cd8c3a623fe76e3239be583ad0014b6f 07-Mar-2017 Glenn Kasten <gkasten@google.com> Add comments

Test: builds OK
Change-Id: I3745b04473d0a3878845708c9847001d936ba9b2
sb/UsbAlsaManager.java
sb/UsbAudioDevice.java
9a2b5e98285d1c2d11dabe706dbd5fbdb2cee17f 12-Apr-2017 David Stevens <stevensd@google.com> Merge "Reset the default usb package less often" into oc-dev am: 1654143680
am: 8e40723876

Change-Id: I041f7fdaf689fde58f7853af075f708b30418201
1654143680f53f857747e3b26bce8c414921b8cd 12-Apr-2017 David Stevens <stevensd@google.com> Merge "Reset the default usb package less often" into oc-dev
6040887f78c1a5d8911a169cd4f2825cf8bad10c 24-Mar-2017 puma_hsu <puma_hsu@htc.com> Just broadcast intent to bring up MTP/PTP as soon as switching function

Bug: 36113457
Bug: 34451451
Test: Turn on tethering
Change-Id: I3a7ab6fdcd157740b8e55ded67b3d5dddf15b0e0
Signed-off-by: puma_hsu <puma_hsu@htc.com>
(cherry picked from commit 4b3e46c7878f28abe2f3c26c05d55c41eba41227)
sb/UsbDeviceManager.java
f4a2e1df940f75534af364b7d7dad46a4b25bd44 07-Apr-2017 David Stevens <stevensd@google.com> Reset the default usb package less often

This CL makes logic for resetting the default package for handling USB
intents less agressive (added in ag/101452). First, instead of listening
for package changed events, we now listen for package replaced
broadcasts. Second, we don't reset the default package if the app being
added/updated is already the default package.

Bug: 35491880
Test: Manually tested with a work profile
Change-Id: Id1992239b5d8ace87fefeb4acd6ca1031c3c1085
sb/UsbProfileGroupSettingsManager.java
522737495106a0a6b3569027a2d231adce48f9fb 05-Apr-2017 Badhri Jagan Sridharan <Badhri@google.com> Do not show Usb dialog for USB peripherals.

This CL prevents the USB Dialog to show for peripherals such as
keyboard, mouse, flash drives etc. Usb Dialog is redundant in these
cases as the Type-C stack is expected to manage power automatically
as these devices are most likely SNK devices.

Bug: 36141499
Test: Manually tested that USB dialog doesnt show up when
a keyboard or mouse is connected.

Change-Id: I3ee45f137817425bf9acd675b044a97d1cb91d7d
sb/UsbDeviceManager.java
d81d8d854a7ed345435bee60a8fabfbcb89aac7e 05-Apr-2017 Badhri Jagan Sridharan <Badhri@google.com> Pass the right index to query the descriptors

Bug: 36897770
Test: Manually tested with headset jack plugged in.
Change-Id: Icd7a983423f3c8986404770a78e3904ee095e758
sb/UsbDeviceManager.java
f63de8831f70dd6ba01ce600b575417c2e947271 04-Apr-2017 Badhri Jagan Sridharan <badhri@google.com> Merge "Do not display USB charging dialogue for AUDIO class devices"
7dee1a6347bf2c2eb90359399178f07e0d75e6be 02-Apr-2017 Badhri Jagan Sridharan <Badhri@google.com> Do not display USB charging dialogue for AUDIO class devices

The CL prevents the "Supplying power to the attached device"
notification from showing up when USB digital headphones are
connected. Although, the phone is actually powering the headphones
here, there seems to be an opinion that this might confuse the users.
So, disabling the notification for better user experience.

Also, the mode chooser activity might not be applicable here as
the headphones are not expected to be a dual role device in the
near future. When connected through a hub, the power management
of the Type-c link is expected to be managed by the Type-C stack
in the hub and phone's kernel. So user might not have to manage
the direction of power flow.

Bug: 36141499
Test: Manually tested that USB dialog doesnt show up when
digital usb headphones are connected but shows up otherwise.
Change-Id: I187da9c77e294cbbceb633365adbb4623fc14a3d
sb/UsbDeviceManager.java
7530670d337aa69fffb5820c4082974fa0399cf9 04-Apr-2017 Philip P. Moltmann <moltmann@google.com> Merge "Not send switch intents if there is no real intent" into oc-dev am: 82331f7f73
am: 09b5ec8ee1

Change-Id: I790378322f543762ef7fda0253e48259e9bf5d3e
09b5ec8ee17f96d4b18a4b89e6f2c9b4869b03c5 04-Apr-2017 Philip P. Moltmann <moltmann@google.com> Merge "Not send switch intents if there is no real intent" into oc-dev
am: 82331f7f73

Change-Id: Ief39b33a90bbc6d9428006baccd6b293572d17f3
82331f7f731769390eb5ef0cd6e8e38796bad422 04-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Not send switch intents if there is no real intent" into oc-dev
ebc8ee266c8fa99aae5567f9da920f4a81c04c4a 31-Mar-2017 Philip P. Moltmann <moltmann@google.com> Not send switch intents if there is no real intent

When resolving activtities for the USB device/accessory connection UI a
special intent that allows to switch between profiles get added. This
also gets added if there is no activity in the secondary profile that
can be started.

Fixes: 36544815
Test: Added work profile. Add USB handling app only to personal profile
and plugged in USB device -> no crash anymore

Change-Id: I311ddd53b3ff0c8406e62bac57972d4b790ebddc
sb/UsbProfileGroupSettingsManager.java
558b0dd41866dd0391457197b96b4ace42f2344c 03-Apr-2017 Jeff Sharkey <jsharkey@android.com> Consistent dump() permission checking. am: fe9a53bc45
am: 020de02854

Change-Id: Iffbf78a7b48cea41ed4b0763f2452738e084225c
020de0285422eba50289a264d2125e12c15145b2 03-Apr-2017 Jeff Sharkey <jsharkey@android.com> Consistent dump() permission checking.
am: fe9a53bc45

Change-Id: I300f8bc07e1266b9e78f56d085cd458862176a85
fe9a53bc45fd0124a876dc0a49680aaf86641d3e 31-Mar-2017 Jeff Sharkey <jsharkey@android.com> Consistent dump() permission checking.

This change introduces new methods on DumpUtils that can check if the
caller has DUMP and/or PACKAGE_USAGE_STATS access. It then moves all
existing dump() methods to use these checks so that we emit
consistent error messages.

Test: cts-tradefed run commandAndExit cts-dev -m CtsSecurityTestCases -t android.security.cts.ServicePermissionsTest
Bug: 32806790
Change-Id: Iaff6b9506818ee082b1e169c89ebe1001b3bfeca
sb/UsbService.java
1810e88e82071173ce6f18a66ac69b54d579bf73 01-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Persist the functions from the 3rd column in oemOverride"
e04a449143317c6633a490b60ef6c44523ecab1c 31-Mar-2017 Chris Wren <cwren@android.com> Merge "restore the title string un UsbDeviceManager" into oc-dev
am: b0db4017e5

Change-Id: Ia3610251a9fa31b179bee8b5bae21dc24c3bed65
a71b5918b0f682a21834be497304fc80f90deb11 31-Mar-2017 Chris Wren <cwren@android.com> restore the title string un UsbDeviceManager

Bug: 32584866
Test: make
Change-Id: I4e4dea064a1af194db5660b0765cc4c4b666584a
sb/UsbDeviceManager.java
31af86f8ed05e76de08389702ecf238ec1a3664c 31-Mar-2017 Badhri Jagan Sridharan <Badhri@google.com> Persist the functions from the 3rd column in oemOverride

The oemOverrides were incorrectly persisted when adb was disabled.
This CL makes the functions in the 3rd column to be persisted.

Bug: 31947358
Test: Verify oemOverride
Change-Id: Iaef19f8ffd0c829a852a33778af96a6772d1c2ad
sb/UsbDeviceManager.java
72eb5da93bbcdbdaea221d371ee6eaf744f884da 31-Mar-2017 Chris Wren <cwren@android.com> Merge "standardize system notification IDs" into oc-dev
am: 441162562b

Change-Id: Idb39af001fefa77b6899c3c9d8816532b5e54dea
282cfefea0fbbd299839e353e6d30affdcd4a55c 27-Mar-2017 Chris Wren <cwren@android.com> standardize system notification IDs

All the trivial cases, plus some fixes to try to
mitigate collisions with the complex ones.

Complex services to follow in another CL,

Bug: 32584866
Test: make framework services
Change-Id: Ie9663600171d8ede11676e9d66f009dbb06def03
sb/MtpNotificationManager.java
sb/UsbDeviceManager.java
72ec482be00c34d9e8e9486010388e5f347ecdda 28-Mar-2017 Jerry Zhang <zhangjerry@google.com> Merge "Just broadcast intent to bring up MTP/PTP as soon as switching function" am: a0360e38ab am: cb6beee2af
am: dbaabf762a

Change-Id: I682e7c74c5f5e48ccb3bedbf34a2bdcf85e51c30
cb6beee2afe777be1daa6fb060fe4ceb5c051e7f 28-Mar-2017 Jerry Zhang <zhangjerry@google.com> Merge "Just broadcast intent to bring up MTP/PTP as soon as switching function"
am: a0360e38ab

Change-Id: I862f38f52cef8b2b90125953593774263b862306
f934d17bfbbf8a8b4155596fdc74178d89274fc3 24-Mar-2017 Esteban Talavera <etalavera@google.com> Restart USB stack if data transfer becomes unavailable

If DISALLOW_USB_FILE_TRANSFER is set while the device is
connected via USB and data transfer is enabled, restart
the USB stack to make sure that data cannot be transferred any more

Fix: 34487750
Bug: 34054991

Test: Checked that files cannot be transferred any more as soon as the user restriction is set
Test: cts-tradefed run cts-dev --module DevicePolicyManager --test com.android.cts.devicepolicy.UserRestrictionsTest

Change-Id: I129c226e57da2d0be356f93436b36b3303cb604c
sb/UsbDeviceManager.java
4b3e46c7878f28abe2f3c26c05d55c41eba41227 24-Mar-2017 puma_hsu <puma_hsu@htc.com> Just broadcast intent to bring up MTP/PTP as soon as switching function

Bug:36113457
Change-Id: I3a7ab6fdcd157740b8e55ded67b3d5dddf15b0e0
Signed-off-by: puma_hsu <puma_hsu@htc.com>
sb/UsbDeviceManager.java
dca36e4e2782dcb9377167037ab9e800cff1f32b 23-Jan-2017 Badhri Jagan Sridharan <Badhri@google.com> Persist functions for oemOverride across reboot

persist OEM specific functions across boot using overlays when
ro.bootmode is NOT unknown
i.e. when phone boots up into a predefined Oem mode.

The overlay tuple has 4 columns instead of three where the fourth column
is optional. When the fourth column is present, the functions mentioned
there would be persisted across reboot along with adb(if enabled).
The fourth column is read during USB device manager set up
@readOemUsbOverrideConfig.

When trySetEnabled function is called, the override function is applied
and the actual oem functions are persisted in
persist.sys.usb.<bootmode>.config.
This property is used in an "on boot" property trigger to set up the
persistent function early in the boot.
(Similar to the way persist.sys.usb.config is used to setup the
USB functions during normal boot).
persist.sys.usb.<bootMode>.func tracks the functions without override.

For example, when the following tuple,

usbradio:adb:diag,serial_cdev,rmnet_gsi,adb:diag,serial_cdev,rmnet_gsi

when ro.bootmode is usbradio, and mCurrentFunctions is adb,
the actual functions enabled would be diag,serial_cdev,rmnet_gsi,adb
(sys.usb.config) and diag,serial_cdev,rmnet_gsi would be
persisted across reboots through persist.sys.usb.usbradio.config and
the functions would be saved in persist.sys.usb.usbradio.func

Bug: 31947358
Change-Id: Ifaef17f6943c1e70721cdc8489f17e3ece03bbfc
sb/UsbDeviceManager.java
60968b97834d3a36ac0ce6379c84945746318abf 20-Mar-2017 Yifan Hong <elsk@google.com> Merge "IUsb uses "default" service name"
b234748565ef3141fed711e776e50ba18a6e2f31 18-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "format cleanup(intellij)"
e67d3bb2bab3156e1128e1fc066ddb836efda62e 17-Mar-2017 Yifan Hong <elsk@google.com> IUsb uses "default" service name

The getService() and registerAsService() methods of interface objects
now have default parameters of "default" for the service name. HALs
will not have to use any service name unless they want to register
more than one service.

Test: pass

Bug: 33844934
Change-Id: I7c1691daf029fb426873be79553a235c43df9f42
sb/UsbPortManager.java
24b7831f8bf19cde7b07ed24216b381b1469dbdc 17-Mar-2017 Glenn Kasten <gkasten@google.com> Merge "USB audio: fix imports"
967e83220015453d4847fcc36362a3b61e781a73 17-Mar-2017 Glenn Kasten <gkasten@google.com> Merge "Add units to variable names"
eb26052f3caf57e37d54bd744b2e499270479123 16-Mar-2017 Badhri Jagan Sridharan <Badhri@google.com> format cleanup(intellij)

Change-Id: Idfa4cc769ec6726be86086879541476d9ed1d12e
sb/UsbDeviceManager.java
8066b89c487dd5a97dc8442925654b67772bd810 13-Mar-2017 Glenn Kasten <gkasten@google.com> USB audio: fix imports

Test: builds OK
Change-Id: I122e885def74b0f26786eb92a26a8cafed2f65f4
sb/UsbAlsaManager.java
a5af24cd02f9dadbea7d23c59ce5f04ce045080d 13-Mar-2017 Hugo Benichi <hugobenichi@google.com> Merge "Minor formatting cleanup to remove overlong line" am: d6998d4bd6 am: cc935f5e6d
am: 3d61c89305

Change-Id: I1a4311525a7b9674daa3713ca3ec7001d4bb30fe
cc935f5e6d8d59679e9fc5b4bff79dc9c27bad88 13-Mar-2017 Hugo Benichi <hugobenichi@google.com> Merge "Minor formatting cleanup to remove overlong line"
am: d6998d4bd6

Change-Id: I3a4582ebfc1cb7436e570e37cacbc3cabf8c0182
d6998d4bd6c4b7a3f87fe8fe6dca42b45f0c6175 13-Mar-2017 Hugo Benichi <hugobenichi@google.com> Merge "Minor formatting cleanup to remove overlong line"
9fd6645637f416a232b36be4923fe40939894254 11-Mar-2017 Badhri Jagan Sridharan <badhri@google.com> Merge "Introduce debounce to filter rapidly toggling type-c ports"
7e86a8ebf9ee37963ac7b0750dc7c7b0be9c09fc 11-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Fix handling usb dialog for wall chargers."
763165803e993352d8e15d4bd027e4832aa4cb46 10-Mar-2017 Badhri Jagan Sridharan <badhri@google.com> Merge "Reformat code"
c4616503b34b7dcc9409339a7f2ac780ed457fee 09-Mar-2017 Badhri Jagan Sridharan <Badhri@google.com> Reformat code

Moving to Intellij coding format

Change-Id: I412232183f50dcb7f66bce2f07a07e242114eaa8
sb/UsbPortManager.java
40cd0544bc8668a6b1037463847d9245f4b599c5 10-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "minor cleanup"
abd229b71aded9ce3958a60650bced7c991748e9 10-Feb-2017 Badhri Jagan Sridharan <Badhri@google.com> Introduce debounce to filter rapidly toggling type-c ports

Type-c ports can quickly toggle between connected/disconnected
states. Introduce debounce to prevent sending spurious notifications.

Cherry-pick: https://android-review.googlesource.com/#/c/338266/
Bug: 34972898
Test: notification should not be queued for a pixel-c charger not connected
to the power outlet.
Change-Id: I4aa19f9f864fe5b77e65f6a07a3184d8aba1f5fc
sb/UsbDeviceManager.java
843aba77452704837320b5951be819e2fc3dd24f 13-Feb-2017 Badhri Jagan Sridharan <Badhri@google.com> Fix handling usb dialog for wall chargers.

UsbPort.POWER_ROLE_SINK is orthogonal to the type of the charger
attached. POWER_ROLE_SINK would be the case for AC charging and
USB charging. Therefore query BatteryManager for the charger
type.

Cherry-pick: https://android-review.googlesource.com/#/c/338265/
Bug: 34972898
Test: Charging notification should not show for pixel-c chargers.
Change-Id: I8dddcd7727b6af973bd173d2c6e325aa4be2ca3a
sb/UsbDeviceManager.java
bb85be42610fb96aaaf2aec8e61eabfaad5bb710 09-Mar-2017 Badhri Jagan Sridharan <Badhri@google.com> minor cleanup

Change-Id: I9531bb03a0bf6e92895caa6b91053445f29b5a46
sb/UsbPortManager.java
d929cb1d929451258bdd5ced1e17bfdb759bb3da 09-Mar-2017 Glenn Kasten <gkasten@google.com> Merge "USB audio: Use 'final' where possible"
cb8724c572b3059b355707021948305c86687f90 09-Mar-2017 Glenn Kasten <gkasten@google.com> Merge "Comment out unused methods"
e5377dd0236cd9a971f551d459200342a8a56857 09-Mar-2017 Glenn Kasten <gkasten@google.com> Merge "Fix typo in log"
eb7ca5ca3a928821117e6f905b01ac927c12584f 08-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Skip the MTP notification when the system has the default app."
615c793c317d1675a3cd47c51037f856a84154f8 23-Feb-2017 Glenn Kasten <gkasten@google.com> Add units to variable names

Test: compiles OK
Change-Id: I11ec8025686aea0068ce4353df6afea3b9fc2d13
sb/UsbAlsaManager.java
3fcf85cd91f01f21b3f9727508fd190898695533 23-Feb-2017 Glenn Kasten <gkasten@google.com> Comment out unused methods

Test: compiles OK
Change-Id: I6f5513e7c5655e91e4cc3dd8de8ec407b9f7b94e
sb/UsbAlsaManager.java
ff6615f653dab13c4ac482430af26ac08c2ba891 23-Feb-2017 Glenn Kasten <gkasten@google.com> USB audio: Use 'final' where possible

Test: compiles OK
Change-Id: I14677ef55b14ae0cc60b6145350e70c475cc987e
sb/UsbAudioDevice.java
7f8cf37da3cb983561905c4812e02938cf544044 23-Feb-2017 Glenn Kasten <gkasten@google.com> Fix typo in log

Change-Id: I5e805f4e4f296e7a9e8d12bf8372515f59099f17
sb/UsbDeviceManager.java
a455dd9f0939f36438b39c0ae6b69e4c82e6ff02 17-Feb-2017 Daichi Hirono <hirono@google.com> Skip the MTP notification when the system has the default app.

Before N, when MTP device is connected to Android, it opened the
activity selector for applications that could handle the MTP device.
For N, we updated the behavior to make it consistent with other storage
devices like USB mass storage. In N, the system showed the notification
first, then showed the activity selector after a user taps the
notification.

The N behavior causes a problem that the user always needs to tap the
MTP notification even after the user select a default application for
the MTP device.

The CLs tweaks the behavior for O so that the system can skip the MTP
notification if the system has the default app for the connected MTP
device.

The default app is one of them:

* App selected by a user by clicking "Always use" in the activity
selector
* System app that is an only application which can handle the MTP
device in the system
* App that is an only application which can handle the MTP device in
the system where config_disableUsbPermissionDialogs=true.

Bug: 32119378
Test: Connecting MTP device to Android, which automatically opens system
app. Connecting PTP device to Android, which shows a notification.
Tapping the notifiction opens the acitivity selector.
Change-Id: I51f1d55e8c7d1db87d91ddf966631d275a171546
sb/UsbProfileGroupSettingsManager.java
7bf141233b2956fa5ed451265c6c5dcd449024bd 02-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "IServiceManager/ITokenManager uses "default" service name"
af759c52ce01fe6b5144957e38da956af01a217b 15-Feb-2017 Geoffrey Pitsch <gpitsch@google.com> Channels for Frameworks notifications

Adapts all notifications used by system services to use channels.
Channels are initialized by SystemServer after the NotificationService
has started.

Test: runtest systemui-notification
Change-Id: I25c45293b786adb57787aeab4c2613c9d7c89dab
sb/MtpNotificationManager.java
sb/UsbDeviceManager.java
4d3453637c5a78ddc1a1bdeab80e57ca825011be 27-Feb-2017 Tomasz Wasilczyk <twasilczyk@google.com> Fix few typos.

Test: manual (watching logs)
Bug: b/35805636
Change-Id: I066e8f94e73232eb59bef86fff4a4eef5d84fbb4
sb/UsbPortManager.java
9ecbc04c23fc26534164f4342b5911acf08baf81 25-Feb-2017 Yifan Hong <elsk@google.com> IServiceManager/ITokenManager uses "default" service name

The getService() and registerAsService() methods of interface objects
now have default parameters of "default" for the service name. HALs
will not have to use any service name unless they want to register
more than one service.

Test: boots
Test: hidl_test

Bug: 33844934
Change-Id: I5774469712d70de4b2629258fe54d7f8c280d9d0
sb/UsbPortManager.java
1693d7745605783d198ecd7e6b4ff41dc71e272d 16-Feb-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Consider priority when launching a USB app"
c584d77b93a4b9f1f0e216427efa32594a6eea28 10-Feb-2017 Badhri Jagan Sridharan <Badhri@google.com> Introduce debounce to filter rapidly toggling type-c ports

Type-c ports can quickly toggle between connected/disconnected
states. Introduce debounce to prevent sending spurious notifications.

Bug: 34972898
Test: notification should not be queued for a pixel-c charger not connected
to the power outlet.
Change-Id: I4aa19f9f864fe5b77e65f6a07a3184d8aba1f5fc
sb/UsbDeviceManager.java
1b8e847a8711e4cef316962543faeff7fc4b9180 13-Feb-2017 Badhri Jagan Sridharan <Badhri@google.com> Fix handling usb dialog for wall chargers.

UsbPort.POWER_ROLE_SINK is orthogonal to the type of the charger
attached. POWER_ROLE_SINK would be the case for AC charging and
USB charging. Therefore query BatteryManager for the charger
type.

Bug: 34972898
Test: Charging notification should not show for pixel-c chargers.
Change-Id: I8dddcd7727b6af973bd173d2c6e325aa4be2ca3a
sb/UsbDeviceManager.java
87d66fd3f1111ffa6d5ba48cf38ccceea11e69cd 31-Jan-2017 Hidenari Koshimae <hidenari.koshimae@sonymobile.com> Minor formatting cleanup to remove overlong line

Change-Id: If0afb279552bc664ba579badaf35662effbd2a80
sb/UsbDeviceManager.java
fa207eb889c91bb289e1b3341a910bcb7071b8df 14-Feb-2017 Badhri Jagan Sridharan <Badhri@google.com> Merge changes from topic 'pixel-c' into nyc-mr2-dev
am: dee514fae3

Change-Id: I4038d1fbd429fcedc4a379d764b5ef5c59dcce1d
e8b0e113714e13de200ae41d61c6cff154ca9851 10-Feb-2017 Badhri Jagan Sridharan <Badhri@google.com> Introduce debounce to filter rapidly toggling type-c ports [DO NOT MERGE]

Type-c ports can quickly toggle between connected/disconnected
states. Introduce debounce to prevent sending spurious notifications.

Bug: 34972898
Test: notification should not be queued for a pixel-c charger not connected
to the power outlet.
Change-Id: I4aa19f9f864fe5b77e65f6a07a3184d8aba1f5fc
sb/UsbDeviceManager.java
8b0807c789b6c29ee71123c020b680636e9d7d85 13-Feb-2017 Badhri Jagan Sridharan <Badhri@google.com> Fix handling usb dialog for wall chargers. [DO NOT MERGE]

UsbPort.POWER_ROLE_SINK is orthogonal to the type of the charger
attached. POWER_ROLE_SINK would be the case for AC charging and
USB charging. Therefore query BatteryManager for the charger
type.

Bug: 34972898
Test: Charging notification should not show for pixel-c chargers.
Change-Id: I8dddcd7727b6af973bd173d2c6e325aa4be2ca3a
sb/UsbDeviceManager.java
45c87d943d301e30696d6a626c6fe4cca189a6e2 02-Feb-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Enabling USB Debugging Connected notification on Android TV"
d7ee7d4b340540919a3ae57818ef1b420de4857d 01-Feb-2017 Dmitri Plotnikov <dplotnikov@google.com> Enabling USB Debugging Connected notification on Android TV

Bug: 34859109
Test: verified that the notification showed up in LeanbackLauncher
Change-Id: I2d5798e994df74b7d3211ccf7f22a6aff44bd681
sb/UsbDeviceManager.java
26b613028255a2180b8c87e7b792bb257e71bff4 31-Jan-2017 Badhri Jagan Sridharan <Badhri@google.com> Check and send usb state broadcast when devices boots am: af6d473ab0 am: 061bceafee am: df1df40f91
am: 307a387f38

Change-Id: Icf4b4e4f48fea450b71bd7ccd88db7d089ea286e
ed642e81b42e4836510dac8ac0d52aa2078c4ab6 31-Jan-2017 Jerry Zhang <zhangjerry@google.com> Only send usb disconnect intents after boot. am: c1bc0a844d am: dc9c094deb am: 9877c70d9d
am: 1064ee66d5

Change-Id: If501641b5a7cbb4264f40f3bcf2add35e0851f78
af6d473ab06afc5ca60bf61513e1197886d56af6 24-Jan-2017 Badhri Jagan Sridharan <Badhri@google.com> Check and send usb state broadcast when devices boots

Broadcasts are not sent until BOOT_COMPLETED is received.
When the device boots with usb plugged, the UPDATE_STATE
for connted and configured would be received way before
BOOT_COMPLETED is received. Since, devices can continue
to stay in same usb configuration(set through persistent
property trigger), check and send a usb state broadcast
if needed.

BUG: 34451258
Test: Manually checked to verify the broadcasts sent.
Change-Id: I8eca5f241ad758f5c4f1afa6c9807868dfd6195a
sb/UsbDeviceManager.java
c1bc0a844d2e8fdb9bc6f73d80579f69e2701f62 23-Jan-2017 Jerry Zhang <zhangjerry@google.com> Only send usb disconnect intents after boot.

This prevents cases where the device starts up and attempts
to change the config, but intents cannot yet be sent.

A patch to resend this skipped intent is necessary to
finish fixing the bug.

Bug: 34451258
Test: Check that usb state is properly handled on boot
Change-Id: I9d79c67ce8982fd5b43fa40781b66bb9ae820694
sb/UsbDeviceManager.java
d9793989834ec7dd3dfe645c6bfba50978c16253 25-Jan-2017 Badhri Jagan Sridharan <badhri@google.com> Merge "Refactor UsbPortManager to use the binderised USB HAL"
4882496232a8fc659f7e2fbfb4984d8cdc96013b 13-Oct-2016 Jerry Zhang <zhangjerry@google.com> 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.

Bug: 31814300
Test: manually changing usb configurations
Change-Id: Ica10a195338b2189db13113f44657393db110bee
(cherry picked from commit 7a396be6d5ba8914933a54b5bfac25e118db0e9f)
sb/UsbDeviceManager.java
sb/UsbService.java
823287d28ed75f96cee31cf465220fcbcbc5c7ac 24-Jan-2017 Badhri Jagan Sridharan <Badhri@google.com> Refactor UsbPortManager to use the binderised USB HAL

Move to a USB HAL to handle type-c ports as upstream is
considering in merging a generic type-c interface to mainline
kernel. However, the new sysfs interface can see minor changes
in the future as the sysfs interface is sitll going to land
in testing and it is still under review.

Bug: 31015010
Test: Manually tested on Angler and sailfish for type-c role switches.
Change-Id: I26771074c4b4f79a133e519bc6d35a4864a696d8
sb/UsbPortManager.java
4ca071da2878391cab39c6125503b447e50b67ad 23-Jan-2017 Christopher Tate <ctate@google.com> Send USB_STATE broadcast to manifest receivers

Bug 34594920

Change-Id: I5d026f469710960b792dcf1bfebc1c07f90c6182
sb/UsbDeviceManager.java
42a386b7717300bf6d75cbd3b4f7ad00f294be0d 07-Nov-2016 Christopher Tate <ctate@google.com> Enable background restrictions

Apps that target O+ are always subject to background restrictions.
Legacy apps' background restriction is subject to the OP_RUN_IN_BACKGROUND
app op.

Apps with these properties are exempted from background restrictions:
- persistent process
- currently on the idle battery whitelist
- global whitelist for things like bluetooth services

Bug 30953212

Change-Id: Icc19b2fbc05f40dcf8c3fc4abf718c373dc8d4f6
sb/UsbPortManager.java
sb/UsbProfileGroupSettingsManager.java
sb/UsbSettingsManager.java
9e83cbbc10014b3ed560b3181f594868cd89f9ae 19-Jan-2017 Chris Tate <ctate@android.com> Revert "Enable background restrictions"

This reverts commit 21f778060badb1e78bffde05e8de7662d275003d.

Change-Id: I65586f9739da84fb32b51b0ea166b8288c41d1b3
sb/UsbPortManager.java
sb/UsbProfileGroupSettingsManager.java
sb/UsbSettingsManager.java
21f778060badb1e78bffde05e8de7662d275003d 07-Nov-2016 Christopher Tate <ctate@google.com> Enable background restrictions

Apps that target O+ are always subject to background restrictions.
Legacy apps' background restriction is subject to the OP_RUN_IN_BACKGROUND
app op.

Apps with these properties are exempted from background restrictions:
- persistent process
- currently on the idle battery whitelist
- global whitelist for things like bluetooth services

Bug 30953212

Change-Id: Ib444829a2d222125f64ff19e8218823fa78373f9
sb/UsbPortManager.java
sb/UsbProfileGroupSettingsManager.java
sb/UsbSettingsManager.java
bfc5d563aa19912e2ab103d04329419e8cec6fb2 18-Oct-2016 Jerry Zhang <zhangjerry@google.com> 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
(cherry-picked from commit a45dac0e83f4f907b6b42f453181a7d5c01f65f3)
sb/UsbDeviceManager.java
541295a9a53e38bde5fea4223ed2d63e3aacf93b 13-Oct-2016 Jerry Zhang <zhangjerry@google.com> 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
(cherry-picked from commit 58018d01a3c384b954275d15bee7f9c52a1c7c0a)
sb/UsbDeviceManager.java
1e87ae5c8e9d904af15099c778e08ed88eb0aa87 14-Dec-2016 David Stevens <stevensd@google.com> Merge "Exit accessory mode more aggressively"
4f9e88a4afc7eb3e299b8a69c853f89077c86435 14-Dec-2016 David Stevens <stevensd@google.com> Exit accessory mode more aggressively

The debouncing of USB disconnects means that the disconnect caused
by resetting the connection without unplugging the device does not make
it to the handler, and thus doesn't exit accessory mode. Therefore we
must exit accessory mode even for connect events after we have left the
entering accessory mode state.

Test: Manual testing with desktop head unit
Change-Id: Ia028ff28783fa777a9f8bcd86b523d01f633a140
sb/UsbDeviceManager.java
d9291d55f6aa39a63311d7b1b6585f7a73aafd68 13-Dec-2016 Jerry Zhang <zhangjerry@google.com> Merge "Modify UsbDeviceManager stack to allow MtpServer to use FunctionFS drivers." am: 1975240f17 am: 830874dbe7 am: 88672d7d29
am: 11dc0eccfb

Change-Id: Ibafebe4877052595cb34626bde9ac6fba1983fb0
bb598ee16f4b61978c88358e8f96153395cdb7ad 24-Oct-2016 Jerry Zhang <zhangjerry@google.com> Modify UsbDeviceManager stack to allow MtpServer to use FunctionFS drivers.

Functionfs requires MtpServer to write descriptors before the device can be
configured. This adds a new configure call that will occur only when
functions are changed (new argument added to updateUsbStateBroadcast for this)
and be called after sys.usb.config is changed but before the waitForState
call to ensure compatibility with configfs devices.

Bug: 30976142
Change-Id: I7e94a5847d3b19c0fd75139e1b15a3f2a1cea01d
Test: Manual
sb/UsbDeviceManager.java
049c718684bbddb7e0d2fd365b52abc170dec138 18-Nov-2016 David Stevens <stevensd@google.com> Exit accessory mode after debounce timeout when necessary

Change-Id: I1e7c1f4f31a310ff0369690a25859b33aaed14fc
Fixes: 29377436
Test: manual testing with 2011 ADK and multiple Android Auto headunits
sb/UsbDeviceManager.java
733d322cf594bb29a57e5e44c5c8100c4cf3ffcc 29-Nov-2016 Philip P. Moltmann <moltmann@google.com> Consider priority when launching a USB app

If there are differnet priorities only consider the acitities with the
highest priorities. Esp, if there is only one app with the highest
priority launch it directly.

This enables an interesting use case:
If a priviledged app wants to always be launched for a device it can
just set the priority to >0. As it is also on system/ the user
_will_not_ get a confirmation dialog and the app will always be directly
launched.

Test: Added app with higher priority to device and saw it to get
auto-selected.
Fixes: 28595282

Change-Id: Ia2c9afa00b5a6e8a00b30a01442da62dd0e33961
sb/UsbProfileGroupSettingsManager.java
bb2965d2393f3edf70a4f48b91dc4b40c23b70bf 17-Nov-2016 Jerry Zhang <zhangjerry@google.com> Merge commit '6bb98d85a0a0790ed2b600f4a165ab79ad536f04' into manual_merge_6bb98d8

Change-Id: I43ad588644c03a2174146525ad62b3d512d66074
5cbd151d401b28ee33cf7405f5d56b12a15dc9fe 17-Nov-2016 Jerry Zhang <zhangjerry@google.com> Refactored setCurrentFunction and setUsbDataUnlocked into single method.
am: 935372bfd6

Change-Id: I5436278e092f691c9179f7cc3709c4578b544e74
b15490ac4d959f8f87e11ca47e237e667879ae7a 17-Nov-2016 Jerry Zhang <zhangjerry@google.com> Clean up persistent usb state on boot.
am: dfacad026d

Change-Id: I762306bc76e304c6491c8af18e82bf2e0c4b433e
4389cb6c9ac8061a6e28f6a39a076d1046b74f0d 17-Nov-2016 Jerry Zhang <zhangjerry@google.com> Fixed handling of usb state during adb changes.
am: 0269ebe0fe

Change-Id: I2fc3674c4d5cc63febe2ebf47576f3cf1bcd1da2
935372bfd642f15afc6488f7df100f1bf76fc773 13-Oct-2016 Jerry Zhang <zhangjerry@google.com> 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
(cherry picked from commit 7a396be6d5ba8914933a54b5bfac25e118db0e9f)
sb/UsbDeviceManager.java
sb/UsbService.java
dfacad026dfc1582504969f8b268e7c3970c4496 18-Oct-2016 Jerry Zhang <zhangjerry@google.com> 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
(cherry-picked from commit a45dac0e83f4f907b6b42f453181a7d5c01f65f3)
sb/UsbDeviceManager.java
0269ebe0fe86d9fbe2aaa624fbe96d340b58c04b 13-Oct-2016 Jerry Zhang <zhangjerry@google.com> 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
(cherry-picked from commit 58018d01a3c384b954275d15bee7f9c52a1c7c0a)
sb/UsbDeviceManager.java
9717839a1fdc0a48adcc59513ae76278e643594c 02-Nov-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Revert "Exit enteringAccessoryMode when entered.""
7d6e325b6c2030fb0880bdf2cdecc67bbd2474e1 01-Nov-2016 Philip P. Moltmann <moltmann@google.com> Revert "Exit enteringAccessoryMode when entered."

This reverts commit a025c8985887e3a6dd87ffcd74a7097b4cef327d.

Change-Id: I550583606444a2d79ec911adf5b14b8783b03286
sb/UsbDeviceManager.java
2d2346e0948f5abfc502b90997ee377e0f261863 18-Oct-2016 Jerry Zhang <zhangjerry@google.com> Revert: Remove the kick from config switches in UsbDeviceManager

Test: Manual
Bug: 32197840
Change-Id: Id2e939a57e170fbb4c06e55dc79c5d35ce95486f
sb/UsbDeviceManager.java
a45dac0e83f4f907b6b42f453181a7d5c01f65f3 18-Oct-2016 Jerry Zhang <zhangjerry@google.com> 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
sb/UsbDeviceManager.java
f2d83edc2604983b03bd0c7dd92c2c5d1c1378dc 17-Oct-2016 Philip P. Moltmann <moltmann@google.com> 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
sb/UsbHostManager.java
069c34894531e6b69bd4d5ed9bd8b9ef4b297cd1 14-Oct-2016 Jerry Zhang <zhangjerry@google.com> Automatically turn on adb for userdebug and eng builds.

Test: flash on a userdebug build, verify adb is on.
Change-Id: If9a46ca2291c034839ec1d297d20e4e6e3fefd77
sb/UsbDeviceManager.java
58018d01a3c384b954275d15bee7f9c52a1c7c0a 13-Oct-2016 Jerry Zhang <zhangjerry@google.com> 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
sb/UsbDeviceManager.java
7a396be6d5ba8914933a54b5bfac25e118db0e9f 13-Oct-2016 Jerry Zhang <zhangjerry@google.com> 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
sb/UsbDeviceManager.java
sb/UsbService.java
67a769e18ad53d599917d6ff984682418d9982f5 12-Oct-2016 Jerry Zhang <zhangjerry@google.com> 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
sb/UsbDeviceManager.java
880389e6cc8044f751dd8569f2172ca61eaf2cd3 10-Oct-2016 Philip P. Moltmann <moltmann@google.com> 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
sb/UsbProfileGroupSettingsManager.java
sb/UsbService.java
sb/UsbSettingsManager.java
a6bf206649b24cabcf1348219e1b00f38214e06a 10-Sep-2016 Philip P. Moltmann <moltmann@google.com> 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
sb/UsbDeviceManager.java
sb/UsbHostManager.java
sb/UsbProfileGroupSettingsManager.java
sb/UsbService.java
sb/UsbSettingsManager.java
sb/UsbUserSettingsManager.java
031cee90a350b7be93ef939630b277cfb28c171b 07-Sep-2016 Philip P. Moltmann <moltmann@google.com> 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
sb/UsbDeviceManager.java
sb/UsbHostManager.java
sb/UsbService.java
sb/UsbSettingsManager.java
sb/UsbUserSettingsManager.java
badbbae6fa2846415778b2a152a0758acbf0eb74 05-Jan-2016 Keun-young Park <keunyoung@google.com> 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
sb/UsbHostManager.java
sb/UsbService.java
sb/UsbSettingsManager.java
d21cb15584f9b28315c4237197188340f32dbdb8 17-Aug-2016 Glenn Kasten <gkasten@google.com> resolve merge conflicts of c76a3ac to stage-aosp-master am: 67ffd5e617
am: f7b4fd24e3

Change-Id: Ib06db403955ae0056c1fee0e09f9249d0b887ea1
67ffd5e61730d4074c174fa72fb752666cc8bbe0 17-Aug-2016 Glenn Kasten <gkasten@google.com> resolve merge conflicts of c76a3ac to stage-aosp-master

Change-Id: Ifff16bdc42e8326f3f60cf4b92688c445cb4db25
1fda533936415b52d537b0056304ff5bd8af8519 17-Aug-2016 Glenn Kasten <gkasten@google.com> 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
sb/UsbMidiDevice.java
2f2bf4014a41d285e8862fd2366424a5027fb2cd 05-Apr-2016 Phil Burk <philburk@google.com> 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>
sb/UsbMidiDevice.java
a025c8985887e3a6dd87ffcd74a7097b4cef327d 10-Aug-2016 Philip P. Moltmann <moltmann@google.com> 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
sb/UsbDeviceManager.java
905c924196c5a5066f8000b37c71fdf417bed679 04-Aug-2016 Philip P. Moltmann <moltmann@google.com> Add (corrected) usb power sink handling am: 9ebf2a5683 am: 78ae5ebe58
am: df2277d66b

Change-Id: I5c53c4c84cfd08cc80c5e48f6e258b99d6b4cdd0
9ebf2a5683db3dfd956f68b80f3f0a10b9705891 28-Jul-2016 Philip P. Moltmann <moltmann@google.com> Add (corrected) usb power sink handling

This is a resubmit of change 01355161536787a55190ff3d2595fbf6c8056fe3 .
The previous change did not handle the case where the device was plugged
into a wall charger correctly.

Fixes: 30418683
Change-Id: Ia155f2230bdd3576c8fb8eb8cff11f544047c35a
sb/UsbDeviceManager.java
9979be916b158ceb1e20f9d19f52924236e4213a 27-Jul-2016 Philip P. Moltmann <moltmann@google.com> Revert \\"Handle USB power role \\'sink\\'\\" am: 47e8089bf4
am: 4022d582d7

Change-Id: I203f5920b4346cfea4e47cef4d2b2f0f39e92a35
47e8089bf4cad83227f0534816c73a649d9af15f 27-Jul-2016 Philip P. Moltmann <moltmann@google.com> 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 01355161536787a55190ff3d2595fbf6c8056fe3.

Change-Id: I304c3f78916896ddb12129b11a0e691b3ef77819
sb/UsbDeviceManager.java
76eb4b1a6c86033942c001fbe0aa506dd61d80b3 26-Jul-2016 Philip P. Moltmann <moltmann@google.com> Handle USB power role \\'sink\\' am: 0135516153
am: 6d0ea86fec

Change-Id: I6dd5eb7a328bd4071c4c40a2a982ec4b7de0b785
01355161536787a55190ff3d2595fbf6c8056fe3 15-Jul-2016 Philip P. Moltmann <moltmann@google.com> Handle USB power role 'sink'

Fixes: 29963134
Change-Id: I7cfe042ed007d36cee5f8bc4c0fa33f8936cba3d
sb/UsbDeviceManager.java
aab4c1ad489a8b62186215d826293e9cbcbaeb85 17-Jun-2016 Mikhail Naganov <mnaganov@google.com> 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
sb/UsbMidiDevice.java
236b9e8eb4ad14068ef42ee2f4f89460f36ed37d 31-May-2016 Philip P. Moltmann <moltmann@google.com> Handle the uncommon case that a name is null

Bug: 29037588
Change-Id: I697184bd1ae4d519f8f29bf612ba13843e6662cb
sb/MtpNotificationManager.java
a0116bf81f9c2b89421050d23c91799b6e128640 03-May-2016 Vincent Palatin <vpalatin@chromium.org> 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)
sb/UsbDeviceManager.java
de2922468be26ab649ee44e7af291d97aebf0701 05-Apr-2016 Phil Burk <philburk@google.com> 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>
sb/UsbMidiDevice.java
c72239409b69b9f938d6c3dc6561c4f7732de273 25-Mar-2016 Paul McLean <pmclean@google.com> 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
sb/UsbAlsaManager.java
b6abccc8f3d8a870a97cb5f07f7561097670e134 28-Mar-2016 Daichi Hirono <hirono@google.com> 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
sb/UsbDeviceManager.java
618fa6ffc154fd131697b6107b431b4557ec118c 17-Mar-2016 Daichi Hirono <hirono@google.com> 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
sb/UsbDeviceManager.java
f8a0c8536e36578152f25635738dd6313aa09285 08-Mar-2016 Daichi Hirono <hirono@google.com> Skip MTP launch notification for devices having FEATURE_AUTOMOTIVE.

BUG=27410621

Change-Id: I1fd2ad663d8e5c5507a8e5e93aafea9d4188ed02
sb/MtpNotificationManager.java
sb/UsbSettingsManager.java
fda7474c5faae1e36a9274d8a5fe83e42ec6503b 01-Feb-2016 Daichi Hirono <hirono@google.com> 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
sb/MtpNotificationManager.java
163e4b6ae8a51421c8a9cccfdc2fe872afd09971 18-Jan-2016 Daichi Hirono <hirono@google.com> 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
sb/MtpNotificationManager.java
sb/UsbSettingsManager.java
d1d533610aad279f7ae9037f0e4b3dd865bb0a24 08-Jan-2016 Julia Reynolds <juliacr@google.com> Increase notification priority for adb connections.

Change-Id: I04ec4dac40737d59a32775e579f734a5460db25c
sb/UsbDeviceManager.java
4751880a4d770e8916320b5908b58f389d6552de 08-Dec-2015 Daichi Hirono <hirono@google.com> 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
sb/UsbSettingsManager.java
bc0a94055c77b6739ffa908aae9189fdeadb83f4 03-Dec-2015 Daichi Hirono <hirono@google.com> 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
sb/UsbSettingsManager.java
c35d7759d8ee8b4a55f4b5b58151f46db47537f4 19-Nov-2015 Chris Wren <cwren@android.com> 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
sb/UsbDeviceManager.java
d1323e9b70f94796491cad4132982fd4664395b0 04-Nov-2015 Glenn Kasten <gkasten@android.com> 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
ebbdabdb826c083769e7d7bc102a59a04c9e0329 04-Nov-2015 Glenn Kasten <gkasten@android.com> Merge "Built-in mic is not used when USB mic is disconnected"
46b434ff9808937c7baa375e70317c28eedf4d1d 31-Oct-2015 Alejandro Ochoa <alejandro.ochoa@intel.com> 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>
sb/UsbAlsaManager.java
853fde6915c1c336350c2bc85ec6f74cc1609d6d 29-Oct-2015 Nick Kralevich <nnk@google.com> UsbDeviceManager: set mUsbDataUnlocked=false on user switch am: 5701321701 am: aa330c0dc2 am: d33d66e26c
am: 581c1809c1

* commit '581c1809c1c617a39eae05aac481a114c70f09d2':
UsbDeviceManager: set mUsbDataUnlocked=false on user switch
aa330c0dc2331f099ce05ecd76d56b8c9e9c483d 29-Oct-2015 Nick Kralevich <nnk@google.com> UsbDeviceManager: set mUsbDataUnlocked=false on user switch
am: 5701321701

* commit '5701321701a319d3f2d98365a82266eeddaed895':
UsbDeviceManager: set mUsbDataUnlocked=false on user switch
5701321701a319d3f2d98365a82266eeddaed895 29-Oct-2015 Nick Kralevich <nnk@google.com> 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
sb/UsbDeviceManager.java
438c220d78482c85b16a108d9ffde6d7ada27d19 29-Oct-2015 Paul Mclean <pmclean@google.com> Merge "Fixing problems with 1st connect of USB audio device to Fugu."
c15f75644385df59663cf2e9e6c6bf27fe228924 22-Oct-2015 Paul McLean <pmclean@google.com> 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
sb/UsbAlsaManager.java
e3b077b1c67a2ca3d46c47244de2d856d6b370f0 28-Oct-2015 Paul McLean <pmclean@google.com> Fixed capture-only devices not removed when disconnected.

I have brought shame upon my family.

Bug: 24932354
Change-Id: I0fce40a976f40e74f4fd87eb6f4aa93e847032cc
sb/UsbAlsaManager.java
dabd6b8f45e464a83fee96c69076abb78dbc862f 03-Oct-2015 Fyodor Kupolov <fkupolov@google.com> 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
sb/UsbDeviceManager.java
e4de5a0d3b6e0c897c1cea0912b58e11db962365 23-Sep-2015 Xiaohui Chen <xiaohuic@google.com> Cleanup OWNER references.

Bug: 19913735
Change-Id: I2150c6baaab80fe11312e4401394a2a8da52e595
sb/UsbSettingsManager.java
bcb80b03f196ea5709a102c2ed7769de5d263945 19-Sep-2015 Tim Kilbourn <tkilbourn@google.com> 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.
bdfbd82154b58592597a70064c0806d774446746 19-Sep-2015 Tim Kilbourn <tkilbourn@google.com> 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.
823e805c1c72b34bed8439e269f96b2f3a5cbe4e 18-Sep-2015 Tim Kilbourn <tkilbourn@google.com> 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
sb/UsbDeviceManager.java
e4b3e61456e029d0afda8a9d2c7e439fc474ccbc 11-Sep-2015 Daniel Koulomzin <dkoulomzin@google.com> 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.
e753361508a51ecea4bc2c84ffba68fd5a8cdd4b 09-Sep-2015 Gus Prevas <kprevas@google.com> 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
sb/UsbDeviceManager.java
92386c42a83c6cba546aed8522de62b9d1ddd46e 26-Aug-2015 Yasuhiro Matsuda <mazda@google.com> Merge "Broadcast ACTION_USB_STATE only if necessary."
4080a4197c8c900e0f597bf436f2f79cc76f2c93 19-Aug-2015 Tim Kilbourn <tkilbourn@google.com> 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.
2ad94499697d79dc41489ab873527411f88b3f15 18-Aug-2015 Tim Kilbourn <tkilbourn@google.com> Merge "Use init to write usb typec props." into mnc-dr-dev
94ce8985b5a03217ca0a1f40b6bbdcb8a405ff44 17-Aug-2015 Jason Monk <jmonk@google.com> 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
6ea47a3542ad5fd79530cfd5d1e3b30c3d52f722 12-Aug-2015 Tim Kilbourn <tkilbourn@google.com> 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
sb/UsbPortManager.java
8338ed00ae44635d099b530b3360e6d1f7041827 12-Aug-2015 Jason Monk <jmonk@google.com> Show usb charging notification when in host mode

Bug: 21615151
Change-Id: Ifc8c288a94f52ecac19990ab3d9095b1aef8efc3
sb/UsbDeviceManager.java
48b9a7c70acff8f1469e487d08bbcb7e6a47ad8a 16-Jul-2015 Yasuhiro Matsuda <mazda@google.com> 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
sb/UsbDeviceManager.java
1913ae958c7ee20466fffe3d9c6e5b820760ca41 04-Aug-2015 Nick Kralevich <nnk@google.com> 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)
1a008c1ca04871386830f511ee4b47299b92b01f 31-Jul-2015 Nick Kralevich <nnk@google.com> 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
sb/UsbDeviceManager.java
sb/UsbService.java
233d94c0df13a7e54f738f442457cebc62294384 31-Jul-2015 Xiaohui Chen <xiaohuic@google.com> clean up UserHandle.USER_OWNER reference

cleaning up a few in framework/base/services.

Bug: 19913735
Change-Id: I1af5f24d9b39d6712ad3a665effa6166e32ce3d3
sb/UsbService.java
bea6528ae30909609d1f963db774b497b91e3cc4 31-Jul-2015 Phil Burk <philburk@google.com> 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
6456a65afed66819b73df7eb605037402b91fc3f 30-Jul-2015 Phil Burk <philburk@google.com> 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>
sb/UsbMidiDevice.java
c0121df2e0011733f382e403fc8778dd2db4441b 24-Jul-2015 Nick Kralevich <nnk@google.com> 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"
7bdcbd8bfc7716a323a09a6439b6636fa124a61a 24-Jul-2015 Nick Kralevich <nnk@google.com> 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
06b93a48ad0d2274ff41683e08b8a1429045b0a9 23-Jul-2015 Nick Kralevich <nnk@google.com> Merge "Revert "UsbDeviceManager: fix b/21429947 regression"" into mnc-dev
0d767e6f098cf4348a7ca8694b673eec0336a3e8 23-Jul-2015 Nick Kralevich <nnk@google.com> 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
sb/UsbDeviceManager.java
3b0bbd7b96568f0d0121136fcac9d4e1a5ffd237 22-Jul-2015 Nick Kralevich <nnk@google.com> Merge "UsbDeviceManager: fix b/21429947 regression" into mnc-dev
b210026e3d5c955628ca8b8b9191ade08891e9ef 22-Jul-2015 Nick Kralevich <nnk@google.com> 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
sb/UsbDeviceManager.java
ed987a52a2aa028814ecc73dd6d60244ac1df7f5 04-Jul-2015 wang.zhenyu <wang.zhenyu2@zte.com.cn> 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
sb/UsbHostManager.java
df2600d4dc0d5bf6c830d908f9490141781bea45 21-Jul-2015 Nick Kralevich <nnk@google.com> 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
b430c4f06c763e0c0fffb6d12b606064ccc84ce3 21-Jul-2015 Nick Kralevich <nnk@google.com> 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
2fedc4df5127d1a2eaf178e835d9f5398ce8f879 21-Jul-2015 Nick Kralevich <nnk@google.com> 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
sb/UsbDeviceManager.java
4085a74b4c6b46c9a08a20b5d63d728713767db4 16-Jul-2015 Jeff Brown <jeffbrown@google.com> am 209c8ced: am 6e4997db: am 8bdd92d4: am 0cb1cfdc: am 76c4c666: Add USB port manager.

* commit '209c8cedab87359564c032a3e56b3acd452e1ac9':
Add USB port manager.
a50dfe9c6f76b9ce091d81ab3babf8ae516effa0 16-Jul-2015 Jeff Brown <jeffbrown@google.com> am 852e51e2: am 3bc33423: am b35b8e81: am b3c11805: am 2dbccc19: Clean up USB Manager dump.

* commit '852e51e23de4dd390f81f5c5a45687595323599a':
Clean up USB Manager dump.
209c8cedab87359564c032a3e56b3acd452e1ac9 16-Jul-2015 Jeff Brown <jeffbrown@google.com> am 6e4997db: am 8bdd92d4: am 0cb1cfdc: am 76c4c666: Add USB port manager.

* commit '6e4997dbfb5f0a2abac99522a52b557172757ee2':
Add USB port manager.
852e51e23de4dd390f81f5c5a45687595323599a 16-Jul-2015 Jeff Brown <jeffbrown@google.com> am 3bc33423: am b35b8e81: am b3c11805: am 2dbccc19: Clean up USB Manager dump.

* commit '3bc33423477945a0f97ebe7948af642cc56cea7b':
Clean up USB Manager dump.
76c4c6668a1486bc003ab0c585bb1f41d16e27a7 07-Jul-2015 Jeff Brown <jeffbrown@google.com> 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
sb/UsbPortManager.java
sb/UsbService.java
2dbccc1926ea2d3e27c5cfd2d61d2b3d5ed787c0 07-Jul-2015 Jeff Brown <jeffbrown@google.com> Clean up USB Manager dump.

Tidy up the dump() implementation in preparation for further work.

Bug: 21615151
Change-Id: If6d94c8dc9457b8e93103541ec1798981eeb5b54
sb/UsbAlsaManager.java
sb/UsbDebuggingManager.java
sb/UsbDeviceManager.java
sb/UsbHostManager.java
sb/UsbService.java
sb/UsbSettingsManager.java
05d58afddb1bbfa893354c1cb331bd69c9d2cb6f 13-Jul-2015 Xiaohui Chen <xiaohuic@google.com> sys user split: fix usb debugging notice

BUG:19913735
Change-Id: Iefdf8a12f1622650bb0d61e7ffb73040e4b8d498
sb/UsbDebuggingManager.java
0bff26c1e9f96857fced59e42a6dac67c14a5597 10-Jul-2015 Jeff Brown <jeffbrown@google.com> am 9c22afe8: Fix a bad merge.

* commit '9c22afe8538cd8c849d0393751bf5bc4997bc632':
Fix a bad merge.
9c22afe8538cd8c849d0393751bf5bc4997bc632 09-Jul-2015 Jeff Brown <jeffbrown@google.com> Fix a bad merge.

Change-Id: Ib722459a25c189bb800eb85d48b80bdc91a2b7db
(cherry picked from commit 2a67840c3c35a6267663e5d3ae921ee9ac614db9)
sb/UsbService.java
5c43bb82e44f0ab9650f15a0392284a2e91feed4 09-Jul-2015 Jeff Brown <jeffbrown@google.com> 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.
2a67840c3c35a6267663e5d3ae921ee9ac614db9 09-Jul-2015 Jeff Brown <jeffbrown@google.com> Fix a bad merge.

Change-Id: Ib722459a25c189bb800eb85d48b80bdc91a2b7db
sb/UsbService.java
c1aebfa02c393471fb344c3a94ee2ae62bb78f93 09-Jul-2015 Jeff Brown <jeffbrown@google.com> Merge "Clean up USB Manager and fix ADB." into mnc-dev
460a146eb8f827e4e70f2dd93d1ba852d0feb06b 01-Jul-2015 Jeff Brown <jeffbrown@google.com> 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
sb/UsbDeviceManager.java
sb/UsbService.java
032ba9f3d1a9edc85ac2e3595f5cedb6d5b27103 08-Jul-2015 Zoltan Szatmary-Ban <szatmz@google.com> 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.
a2de7fc9fc0b96ba4db65ccf6c9684c8c27c2993 08-Jul-2015 Zoltan Szatmary-Ban <szatmz@google.com> Merge "Prevent accidental unlocking of USB data transfer." into mnc-dev
c0bc04697e6c2bcd5e268af910bc716d16356934 08-Jul-2015 Vineeta Srivastava <vsrivastava@google.com> 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
84dce3c9a8f217e8dbc038ebb85fd96d2d66c5f6 23-Jun-2015 Ajay Dudani <adudani@codeaurora.org> 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
sb/UsbDeviceManager.java
b2eb6b9049567c134d7654f6cd79b4a47de643af 07-Jul-2015 Zoltan Szatmary-Ban <szatmz@google.com> 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
sb/UsbService.java
f788e297b21b63204cb773e0af6b11567f2f3bd3 06-Jul-2015 Mike Lockwood <lockwood@google.com> am ce1cb218: am 593dfbb2: Merge "Miss USB device Interface from UsbManager.getDeviceList()."

* commit 'ce1cb218f4d25f76342d6c66c75889429080e883':
Miss USB device Interface from UsbManager.getDeviceList().
19b26f875416e412de7792f6829498a748cf9602 04-Jul-2015 wang.zhenyu <wang.zhenyu2@zte.com.cn> 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
sb/UsbHostManager.java
b3c8564314a4ce05b722e33409f2c15bcdac6666 15-Jun-2015 Chris Wren <cwren@android.com> Merge "remove setLatestEventInfo from USB" into mnc-dev
43965fe5cecd2bc8e139f4cbd012e5d6407ac7f6 13-Jun-2015 Nick Kralevich <nnk@google.com> 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
sb/UsbDeviceManager.java
6d8e413a63c6ab054557f81d53bb8b35f0816679 12-Jun-2015 Chris Wren <cwren@android.com> remove setLatestEventInfo from USB

Bug: 18510449
Change-Id: I6b9ccaa0537c8044c5fa900ae4ea68b2676e1365
sb/UsbDeviceManager.java
674019065bceb4150190bfb1aa63cda9de0a8560 10-Jun-2015 Nick Kralevich <nnk@google.com> 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
sb/UsbDeviceManager.java
sb/UsbService.java
6d5a0f916499a69f28b860fd66d09b5025c30450 08-Jun-2015 Mike Lockwood <lockwood@google.com> 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
sb/UsbMidiDevice.java
2d63f0a14a450fb23304bfaa639e90fa9fb09e18 03-Jun-2015 Nick Kralevich <nnk@google.com> Merge "UsbDeviceManager: Don't unnecessarily touch properties" into mnc-dev
ffcfe3411ff6ccaa35c2873151e31c879506dadd 13-May-2015 Xiaohui Chen <xiaohuic@google.com> usb debugging: show alert to secondary user

Bug: 12785423
Change-Id: If7f60899cfdaca7bdad560bd59a78f5be74c24be
sb/UsbDebuggingManager.java
2f7fa3ed77373fd49117b53fff402de0fe535385 03-Jun-2015 Nick Kralevich <nnk@google.com> 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
sb/UsbDeviceManager.java
4f11754f72ac4c60448b36a1a933cdc2d7bc1870 08-May-2015 Wojciech Staszkiewicz <staszkiewicz@google.com> 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
sb/UsbSettingsManager.java
afe55a5ce96d7fe5e9e37dcd499336423bf87a06 19-May-2015 Paul McLean <pmclean@google.com> Turning off logging in ALSA device connection routines.

bug: 21298614
Change-Id: Ia88393698072af8f7c101382f180192646bf713e
sb/UsbAlsaManager.java
9e9e2e73c6ec7bece20268196dc89ad0c8bafad4 08-May-2015 Wojciech Staszkiewicz <staszkiewicz@google.com> 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
sb/UsbSettingsManager.java
fcf10f7c12cb3107bdfedce6f76a8c866d154f3c 13-May-2015 Nick Kralevich <nnk@google.com> 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
sb/UsbDeviceManager.java
sb/UsbService.java
d9c7f2456957a5610cbbca1b2e31aa7b3574c50d 10-May-2015 Nick Kralevich <nnk@google.com> UsbManager / UsbService / UsbDeviceManager: delete unused code

These functions are never called.

Change-Id: Ic436e1036bed717d2c64701fddd9a810abb9443e
sb/UsbDeviceManager.java
sb/UsbService.java
02868b1625f0b1fa6ce1fb2529186f155904dd03 29-Apr-2015 Mike Lockwood <lockwood@google.com> MidiDeviceInfo: Add version string property

For USB devices, this is populated with the USB device version string.

Change-Id: Ia9286d5f41783e4e960a9c724bf6b85b6599fe12
sb/UsbAlsaManager.java
c9bb40ea95101f8a46fab29beac02cc7204be320 29-Apr-2015 Mike Lockwood <lockwood@google.com> UsbDevice: Add support for retrieving version string for a USB device

Change-Id: Ia8630f5ffd05f90347b971110a81f4927060cc4b
sb/UsbHostManager.java
1f13872a01a02ffff93c24ece730a0136ee8757a 24-Apr-2015 Mike Lockwood <lockwood@google.com> UsbAlsaManager: Fix NPE when running in emulator

Bug: 20537358
Change-Id: I46693e45eb6127118cbd54fc3490dc58840b5797
sb/UsbAlsaManager.java
dee5f1bb6e42875a1134d0e8efeef528b92cc548 10-Apr-2015 Mike Lockwood <lockwood@google.com> Add user visible name for USB peripheral MIDI device

Change-Id: I075a54dc3890bc5cf3927cecba3750e1d342d290
sb/UsbAlsaManager.java
b6f50d357bd3d4d296be6bb047f5ce93a79cbca1 08-Apr-2015 Mike Lockwood <lockwood@google.com> Add support for flushing MIDI all scheduled MIDI events on a port

Change-Id: I39d7862540d4d4b9e2df1265f9dd253541adb4c2
sb/UsbMidiDevice.java
2776133be7ac60dc8d6aea5b12e35449ca331836 31-Mar-2015 Mike Lockwood <lockwood@google.com> Add event scheduling support to USB MIDI Manager code

Change-Id: I9fdaaac35c296acc67ee0cf346b0c7b56bf58393
sb/UsbMidiDevice.java
d1b16fe2fb7527eee214898263ec4d6dabbfb0b4 30-Mar-2015 Mike Lockwood <lockwood@google.com> Move MIDI utilities for internal use to com.android.internal.midi package

Change-Id: I7393ae1d4bca61667fb6ee809a7aa22c5c48de56
sb/UsbMidiDevice.java
5781cd5b218dc3e5a19d8f69e6fb9f310bed4df6 27-Mar-2015 Mike Lockwood <lockwood@google.com> Make the MIDI Manager optional, enabled by "android.software.midi" feature

Change-Id: I76d442ea28beea4b9e2876bfef501d8f61403702
sb/UsbAlsaManager.java
005e9b81953a355abcff628cf21e251dcc0e3121 26-Mar-2015 Nick Kralevich <nnk@google.com> Merge "UsbDeviceManager: delete obsolete code"
ad8fc70c6a85e163c16f6531e4872d95a95ddb2f 26-Mar-2015 Nick Kralevich <nnk@google.com> UsbDeviceManager: delete obsolete code

We stopped using persist.service.adb.enable almost 4 years ago
(commit 02e4569b5f126ca916a7473117ddd17d4f2ccbbb). Delete backwards
compatibility code.

Change-Id: Ic656e834e79361b27ca2afcd3705d0523c23717d
sb/UsbDeviceManager.java
b7ce094c9e546c4a802bd8ce3a43592979a5e3df 25-Mar-2015 Mike Lockwood <lockwood@google.com> 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
sb/UsbAlsaManager.java
sb/UsbDeviceManager.java
sb/UsbMidiDevice.java
4a357cd2e55293402d7172766f7f9419815fc1e8 19-Mar-2015 Alan Viverette <alanv@google.com> Replace usages of deprecated Resources.getColor() and getColorStateList()

Change-Id: I8f64fe6c4c44a92ff6d07250223ba590a1d691b0
sb/UsbDeviceManager.java
3ae6acda814cc129b03abf5e418a115813321b06 14-Mar-2015 Mike Lockwood <lockwood@google.com> Merge "Add MidiManager to public API"
81b9f7d325a552c54e793b51f571ae3d65b26e94 11-Mar-2015 Mike Lockwood <lockwood@google.com> Add MidiManager to public API

Also made some small API changes based on feedback from the lint tool.

Change-Id: Ibcf1e9107d86d3a364f811ce47a13aa0da653366
sb/UsbMidiDevice.java
4011e209215d19a1633ed5d1643f3b7643001667 13-Mar-2015 Mike Lockwood <lockwood@google.com> Merge "MidiDeviceInfo meta-data improvements:"
f2cd8024028f602a5e4c27f3d9222e872e4e84f2 11-Mar-2015 Mike Lockwood <lockwood@google.com> 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
sb/UsbAlsaManager.java
sb/UsbMidiDevice.java
9087433753a5068819dcd3e86bdc2cce82bb8040 10-Mar-2015 John Spurlock <jspurlock@google.com> 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
sb/UsbAlsaManager.java
57baee2e12d1102372153cb4a66ff151c5cc855c 11-Mar-2015 Mike Lockwood <lockwood@google.com> Merge "MidiManager: Add MIDI device status notifications"
5ff9e2a1719f78cddc7a23d6572ab15ab595dafd 09-Mar-2015 Mike Lockwood <lockwood@google.com> 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
sb/UsbMidiDevice.java
22e78c65beb9370d4c14a09eb56a94810e7c7375 11-Mar-2015 Mike Lockwood <lockwood@google.com> Merge "Add MidiReceiver.send() and MidiReceiver.getMaxMessageSize()"
0c7342f0153076c88ba8e6a1647999c248787906 09-Mar-2015 Mike Lockwood <lockwood@google.com> Add MidiReceiver.send() and MidiReceiver.getMaxMessageSize()

Change-Id: I10d4f5e2400fcaf41f455e56ca25bbc0c781a042
sb/UsbMidiDevice.java
394a8e1fa7d2aeeec3d750378c1cb5861a583eeb 03-Mar-2015 Paul McLean <pmclean@google.com> Handle simultaneous connect of devices with the same "type" (as in USB)

Change-Id: I163bf8e33ccf5aacc7ba21775916727430327f18
Bug: 19563570
sb/UsbAlsaManager.java
3b7664589be22ddad34b72e11ced937d48660ebb 04-Mar-2015 Mike Lockwood <lockwood@google.com> Make MidiSender and MidiReceiver abstract classes, rename MidiReceiver.post() to receive()

Change-Id: I1cef3bd48ca0acf2968c9de223f78445f3434404
sb/UsbMidiDevice.java
20821ecbe81ba52b260ae232096bc2bfb3e92ad0 24-Feb-2015 Mike Lockwood <lockwood@google.com> Eliminate MidiPort base class for MidiInputPort and MidiOutputPort

Change-Id: I628c0468ac980eee909add53a4d6e55e9b358603
sb/UsbMidiDevice.java
c623ec973b5e8d1fd2ff4162d5de8701a6490121 05-Mar-2015 Mike Lockwood <lockwood@google.com> Merge "MidiManager: Virtual MIDI devices are now implemented as Services"
11fd96d6ff25bc1d710448eab545fe09da55a5f5 02-Mar-2015 Mike Lockwood <lockwood@google.com> MidiManager: Virtual MIDI devices are now implemented as Services

To implement a virtual MIDI device, include a subclass of MidiDeviceService in
your application. This service is identified by an intent filter and meta-data
in the application's manifest to allow the MIDI manager to register the virtual device
without actually running the application. Instead, the application's MidiDeviceService
subclass is started on demand when MIDI manager clients want to open the device.

Here is an example of how the MidiDeviceService might be described in the application manifest:

<service android:name="VirtualDeviceService">
<intent-filter>
<action android:name="android.media.midi.MidiDeviceService" />
</intent-filter>
<meta-data android:name="android.media.midi.MidiDeviceService"
android:resource="@xml/device_info" />
</service>

and the device_info.xml meta-data:

<devices>
<device manufacturer="Sample Manufacturer" model="Sample Model" private="false">
<input-port name="my input port" />
<output-port name="my output port" />
</device>
</devices>

(note that the <input-port> and <output-port> names are not currently used, but support for these
will be added in a subsequent change)

Client's of the virtual device will bind directly to the hosting application's MidiDeviceService subclass.
To support this, MidiManager.openDevice() now returns the MidiDevice asynchronously via a callback.

This change also adds a utility class called MidiDispatcher, which is a MidiReceiver
that dispatches all data it receives to a list of other MidiReceivers.
We now use this internally in MidiInputPort and MidiDeviceServer, but developers
may use it for other purposes as well.

Change-Id: Ic3009f06d56f3d5edbd87de3f0c330b51a1c217d
sb/UsbMidiDevice.java
f4a8df4c7ee8d6a402e26339514cd73aba613105 04-Mar-2015 Amith Yamasani <yamasani@google.com> Fix a regression in UsbDebuggingManager

Catch NPE as well if socket object is null.

Bug: 19602060
Change-Id: I7cf9cb16abc3fde626170c1aefeba5fc91c5734f
sb/UsbDebuggingManager.java
7b91c55b3ff4857e904a11a0a67fcc86a32868b4 02-Mar-2015 John Spurlock <jspurlock@google.com> Merge "Remove unused imports in frameworks/base."
d65ed881443717c2786fae641d5de5af725d10f8 02-Mar-2015 Amith Yamasani <yamasani@google.com> Merge "Avoid NPE when quickly toggling USB debugging state"
f6197e8fa25d7a411a08ca01f9af8f6278ef97d6 26-Feb-2015 Amith Yamasani <yamasani@google.com> Avoid NPE when quickly toggling USB debugging state

If you try to disable USB debugging before the socket
to listen is opened in the thread, it will end up
with an NPE.

Do some locking around socket creation and closing
to avoid this.

Bug: 18708503
Change-Id: Iac43e4806fff1e411772b1ba1a070d8a7c776fcb
sb/UsbDebuggingManager.java
08c7116ab9cd04ad6dd3c04aa1017237e7f409ac 28-Feb-2015 John Spurlock <jspurlock@google.com> Remove unused imports in frameworks/base.

Change-Id: I031443de83f93eb57a98863001826671b18f3b17
sb/UsbAlsaManager.java
sb/UsbDebuggingManager.java
sb/UsbDeviceManager.java
sb/UsbHostManager.java
sb/UsbSettingsManager.java
464c655871f4c1dd280474723e4b33f55044baa5 26-Feb-2015 Mike Lockwood <lockwood@google.com> Move ALSA utilities to com.android.internal.alsa package

Change-Id: Icbd45ec97a942e44e60f8d4ba0bb58c97f85b55f
sb/UsbAlsaManager.java
b673770f7172d4fca9bc05de1f36bc53e93eb247 20-Feb-2015 Mike Lockwood <lockwood@google.com> Add MIDI Manager API tweaks:

- Change the package name from android.midi to android.media.midi

- Add option for specifying a Handler for DeviceCallback notifications

Change-Id: Ia9e9817a651c06299f4e02ee1da3c9666ff64cb9
sb/UsbAlsaManager.java
sb/UsbDeviceManager.java
sb/UsbMidiDevice.java
c3c2ff70a23ff31bec72e7794ea33552ca106438 20-Feb-2015 Mike Lockwood <lockwood@google.com> Add support for USB notification when connected as a MIDI peripheral

Change-Id: Ib3efcda6af976c878e63b0d35a8e47a3ea9435a3
sb/UsbDeviceManager.java
0e4242f9cb332e5aa7d271f67ded75aa59f3023f 05-Feb-2015 Paul McLean <pmclean@google.com> Audio Device Enumeration API.

Change-Id: Ic78fda8b2a6f6ac0f37a1f665b29f3359cfc5ecc
sb/UsbAlsaManager.java
5b14d9893aced2b3ba46f1d90a0752c1a9a43f2f 13-Feb-2015 Mike Lockwood <lockwood@google.com> Merge "MidiManager API tweaks:"
90b9a6a4ab30fc162aee71b4dc484b3839534369 12-Feb-2015 Mike Lockwood <lockwood@google.com> MidiManager API tweaks:

Rename MidiReceiver.onPost() to post()

Change MidiManager.DeviceCallback from an interface to a class

Change-Id: I939ba7a7d82e721b90a3d80252a88e7a650c9396
sb/UsbMidiDevice.java
6156017c2217d0fbbbb03434986250ec6bbd69d8 07-Feb-2015 John Spurlock <jspurlock@google.com> Move AudioService to services.

...and a few dependencies. Move remaining shared items to AudioSystem.

Change-Id: Ib9623ff867678d34977337856bb0156e8cdaeeb5
sb/UsbAlsaManager.java
83f367475b71ea1abd78b88e70c219c00f2af110 06-Feb-2015 Craig Mautner <cmautner@google.com> Merge "Revert "Revert "Do not display ADB confirm dialog during boot"""
b43d3cff67b831db3b7e9fb834de66e4f9d2bc16 06-Feb-2015 Craig Mautner <cmautner@google.com> Revert "Revert "Do not display ADB confirm dialog during boot""

This reverts commit e37099ffdfc966d52b4323a3705359ea42fa283e.

Fixes bug 18652251

Change-Id: Ib00e8269558aae294ff6453d1f6ceef1771c4572
sb/UsbDebuggingManager.java
968aca1d7e142b2d3d8bbd036506e058717bda66 06-Feb-2015 Craig Mautner <cmautner@google.com> Merge "Revert "Do not display ADB confirm dialog during boot""
e37099ffdfc966d52b4323a3705359ea42fa283e 06-Feb-2015 Craig Mautner <cmautner@google.com> Revert "Do not display ADB confirm dialog during boot"

This reverts commit 34e90b2214b39db31bccaf24644d0db55bcde965.

Change-Id: Ib385793aa2b7472933bdb0c707b10e2bac1a4cb3
sb/UsbDebuggingManager.java
b8415ecfe920a596fd6360de98424d3e9951c58c 06-Feb-2015 Craig Mautner <cmautner@google.com> Merge "Do not display ADB confirm dialog during boot"
10804eb2818ab59b763a37b4f6151693c2ebba7b 28-Jan-2015 Paul McLean <pmclean@google.com> Add additional info to AudioPort for enum/selection API.

Add "device name" member to AudioPort.
Moved unique device ID from DevicePort to AudioPort.
Straighten out confusion between "name" and "address"
Created string constants for Intent "extra" data keys.
Combine card/address data into "address" at sender.Add additional info to AudioPort for enum/selection API.
Parse out USB Device name in UsbCardsParser.

Change-Id: Ifd76b0298312090a8f39e638339f993b86d47080
sb/UsbAlsaManager.java
sb/UsbAudioDevice.java
34e90b2214b39db31bccaf24644d0db55bcde965 04-Feb-2015 Craig Mautner <cmautner@google.com> Do not display ADB confirm dialog during boot

Wait until after encrypted volume has been mounted.
Also eliminate warning by starting UsbDebuggingActivity as owner.

Fixes bug 19217173.

Change-Id: I6da530259bb02eb1892509ec5085a471f9893714
sb/UsbDebuggingManager.java
51936d426086d58a6fe6780253d3038cf12bae25 29-Jan-2015 Mike Lockwood <lockwood@google.com> Merge "UsbAlsaManager: Don't reselect current USB audio device on all USB disconnects"
2a57bc7fd602853dc1a22dcee1ff50f92cc29060 19-Sep-2014 Mike Lockwood <lockwood@google.com> MidiManager: Add USB peripheral MIDI support

This allows the android device to appear as a USB MIDI device to
a USB host (like a Mac or a PC) using the f_midi USB gadget driver.

Change-Id: I14f1ba73bcce2c894e77efb8810beac4ffe246d8
sb/UsbAlsaManager.java
sb/UsbDeviceManager.java
sb/UsbMidiDevice.java
9c2d34c764f14ed7a5076bd38417afde0b246bd6 29-Jan-2015 Mike Lockwood <lockwood@google.com> UsbAlsaManager: Don't reselect current USB audio device on all USB disconnects

Change-Id: I4d3a0d803a6d1eb02ff48a7e8587a1ff6c66a500
sb/UsbAlsaManager.java
cb096273734d96f4676014fa9030b57ea48b58d8 27-Jan-2015 Mike Lockwood <lockwood@google.com> MIDI Manager: Remove message packetization from MIDI transport

Instead of attempting to package exactly one MIDI message in each call to
MidiReceiver.onPost(), we now pass messages as a raw stream of bytes.
This means we may now receive multiple MIDI messages in MidiReceiver.onPost().

We make this change to avoid the complexity of taking the single message approach
with SysEx and realtime messages. This shifts some of the burden of parsing
MIDI messages to the client application. But the parsing is best handled in the
application anyway, rather than having the framework impose its own policy
on how the messages are parsed.

Change-Id: Idb6c200037f827cc618bc7d9455a7aa864b494a7
sb/UsbMidiDevice.java
2e3434149e00f921ca3555ae55cba04d3c64eeb1 08-Jan-2015 Mike Lockwood <lockwood@google.com> Replace broadcasts with calls to IAudioService.setWiredDeviceConnectionState() to report USB device status

Change-Id: Ic96cffaa63b6c6350b76e7cb29398c5f5dc86962
sb/UsbAlsaManager.java
sb/UsbDeviceManager.java
sb/UsbHostManager.java
sb/UsbService.java
98cc8e5a6473b3a5802d97cc81020ec4e3cd23f3 15-Jan-2015 Mike Lockwood <lockwood@google.com> MidiManager bug fixing:

- fix off by one error that caused failure handling one byte messages

- poll thread now terminates properly in UsbMidiDevice

- fix cleanup logic in MidiDeviceServer

Change-Id: I0c13a98b6542cfb271b51678e81d1822c8da2985
sb/UsbMidiDevice.java
10024b3dc12a8552c1547b67810c77b865045cc8 11-Dec-2014 Mike Lockwood <lockwood@google.com> MidiManager updates:

MIDI ports are now implemented as file descriptors directly between the sender
and receiver, so the MidiService is no longer in the message path.

To facilitate the above, each port has its own file descriptor, rather than multiplexing
all ports on a device through a single socket.

Added a new class MidiDeviceServer, which is used by implementors of MIDI devices.
This replaces the MidiVirtualDevice class (which only was included in changes that were reviewed but never submitted).

The USB MIDI implementation has moved from the MIDI service to the USB service.
The USB MIDI implementation uses MidiDeviceServer as its interface, so we now have a common
interface for all MIDI device implementations.

Change-Id: I8effd1583f344beb6c940c3a24dbf20b477a6436
sb/UsbAlsaManager.java
sb/UsbAudioDevice.java
sb/UsbMidiDevice.java
0a8f06922f288bfa4a22a7cd45dd5b89a9563e54 22-Dec-2014 Paul McLean <pmclean@google.com> Support for simultaneous USB Audio Devices connect/disconnect

Attach/Detach logic
Decoupling card# and list index
Modern loop constructs
Consistent logging flags
Add class/type flags to device "address" string.
Factored UsbAudioDevice out of UsbAudioManager.

Bug: 18399845
Bug: 18717784

Change-Id: I6f185e1c24091d4c0d21eb7e922a1496748d32c3
sb/UsbAlsaManager.java
sb/UsbAudioDevice.java
d2de5a421a7d547bd431335583748fd82ddc1ebc 19-Dec-2014 Mike Lockwood <lockwood@google.com> Rename UsbAudioManager to UsbAlsaManager

Change-Id: I53b084400ef3e0692415cc5af91c8b500ffd8346
sb/UsbAlsaManager.java
sb/UsbAudioManager.java
sb/UsbHostManager.java
d00c3752e634d719f309bc4db7c414b9d130d72b 09-Dec-2014 Zoltan Szatmary-Ban <szatmz@google.com> am 32ed193b: am f5e44c29: am c5c93edd: Merge "When switching to default USB function set, check restriction" into lmp-mr1-dev

* commit '32ed193bb5396451401e62493f83664da9228729':
When switching to default USB function set, check restriction
67f8e8bd8927f24147d7a1edd6ec3db1a54233b2 01-Dec-2014 Mike Lockwood <lockwood@google.com> MIDI Manager work in progress

Still to do:

Add MidiInputPort and MidiOutputPort classes
Schedule sending MIDI events in the future
Security/permissions
Reconsider interface for virtual devices
Look into performance optimizations

Change-Id: I9b7d63b196996a04be0a830efa913043da1328a8
sb/UsbAudioManager.java
469c15d6afc295af513f3136de4bfce63e165978 02-Dec-2014 Zoltan Szatmary-Ban <szatmz@google.com> When switching to default USB function set, check restriction

The user restriction DISALLOW_USB_FILE_TRANSFER has to be respected
when switching USB function set.

Bug: 18532487
Change-Id: I16fda6358027a659e3bfa0c5f3bf6b3918d0bced
sb/UsbDeviceManager.java
fb0a22eb62567f39447495622c2198173ca6e287 01-Dec-2014 Mike Lockwood <lockwood@google.com> Remove polling for ALSA device files in USB audio device detection.

Change-Id: I993fe41707fc02c9449800c7325aaf7270fb892e
sb/UsbAudioManager.java
sb/UsbHostManager.java
b66252fb4288ae7e3fa6f1214455e46b9a2e56b2 19-Nov-2014 Geoffrey Borggaard <geoffreyb@google.com> Setting ADB_ENABLED may result in a SecurityException.

If the restriction UserManager.DISALLOW_DEBUGGING_FEATURES is enforced,
then any attempt to set ADB_ENABLED will result in a SecurityException.
This can result in the device not being able to boot.
Bug: 18433477

Change-Id: I21e4b406ad0fa89b7d4b678eac1baf212a3c7acd
(cherry picked from commit ba45b96a378623e3392da65e81e67dabdf4f0678)
sb/UsbDeviceManager.java
451a6f8f9a5e629a94b3cb75eb2d8576caea5471 12-Nov-2014 Nick Kralevich <nnk@google.com> fix crash on invalid base64 key

An invalid adb public key can cause a system server crash.

AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: android.fg
AndroidRuntime: java.lang.IllegalArgumentException: bad base-64
AndroidRuntime: at android.util.Base64.decode(Base64.java:161)
AndroidRuntime: at android.util.Base64.decode(Base64.java:136)
AndroidRuntime: at com.android.server.usb.UsbDebuggingManager.getFingerprints(UsbDebuggingManager.java:235)
AndroidRuntime: at com.android.server.usb.UsbDebuggingManager.access$500(UsbDebuggingManager.java:49)
AndroidRuntime: at com.android.server.usb.UsbDebuggingManager$UsbDebuggingHandler.handleMessage(UsbDebuggingManager.java:210)
AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
AndroidRuntime: at android.os.HandlerThread.run(HandlerThread.java:61)
AndroidRuntime: at com.android.server.ServiceThread.run(ServiceThread.java:46)
Process : Sending signal. PID: 824 SIG: 9

Bug: 17389885
Change-Id: Id20d7c0ee35229b14c800fd9e07716239179989c
sb/UsbDebuggingManager.java
3d50308c7fd2a40dfdeeecdacd44b6ae6d28aafb 31-Oct-2014 Mike Lockwood <lockwood@google.com> Fix USB audio disconnect logic

Previously, disconnecting any USB device would terminate USB audio playback.

Also moved USB audio support to a separate class and did some prep work for
multiple USB audio device support.

Bug: 18203024
Change-Id: I49822c2c47428e658c853b2ec83c7313e626a1cb
sb/UsbAudioManager.java
sb/UsbHostManager.java
c5258433dd353769ccfa2e5e769a7379378a3a0b 28-Aug-2014 Jean-Michel Trivi <jmtrivi@google.com> Move *_AUDIO_PLUG actions from Intent to android.media.AudioManager

For ACTION_HEADSET_PLUG (already in SDK):
- duplicated definition in AudioManager and moved
javadoc there. Javadoc in Intent points to AudioManager.
- the String value is not changed

For ACTION_HDMI_AUDIO_PLUG (being added in SDK):
- moved defintion from Intent to AudioManager
- updated String value to reflect package name "android.media"
instead of using "android.intent"
- added definition of the extras, but removed "name".

For ACTION_ANALOG_AUDIO_DOCK_PLUG,
ACTION_DIGITAL_AUDIO_DOCK_PLUG,
ACTION_USB_AUDIO_ACCESSORY_PLUG,
ACTION_USB_AUDIO_DEVICE_PLUG, all hidden:
- moved definition from Intent to AudioManager,
- changed the value from "android.intent.*" to "android.media.*"

Updated AudioService, UsbDeviceManager and UsbHostManager
to refer to the actions in AudioManager, not Intent.

Bug 17289385

Change-Id: I61dd73140022d2bb9a676a57f595092c8fa89dcc
sb/UsbDeviceManager.java
sb/UsbHostManager.java
255dd04271088590fedc46c8e22b2fd4ab142d39 19-Aug-2014 Selim Cinek <cinek@google.com> Added notification color to all system notifications

Bug: 17128331
Change-Id: I81a94510ef51b99916f314c0dd65852426a1fbeb
sb/UsbDeviceManager.java
c7f084f61c3ad24acb35cde1854808285216d3de 14-Aug-2014 Paul McLean <pmclean@google.com> Fix ALSA initialized wait for input-only USB Audio devices

Bug 17012266

Change-Id: I09427bb924f895bf66af9ef7ad4f0882746d03c4
sb/UsbHostManager.java
9769ef9f8ac86ef69d08afbadb7a00aceeadc5a6 14-Jul-2014 Emily Bernier <ember@google.com> Restore user switching logic.

Change-Id: I859145efc8e7f426ca7f7ad915b082b7e8a2c516
sb/UsbDeviceManager.java
1848d31c2cbb5404be383ad44049e58e36b258ba 26-Jun-2014 Emily Bernier <ember@google.com> Prevent users from mounting USB, if restricted.

Bug: 13585295

Change-Id: I6b7905fad06bf2e1d4dd629a266280ddff9b3121
sb/UsbDeviceManager.java
sb/UsbService.java
2471e02c1980ea84c19fd343d2d95b816bedfcc6 05-Jun-2014 Mike Lockwood <lockwood@google.com> UsbDebuggingManager: remove log spam when disconnecting USB

Bug: 15112047
Change-Id: Ia07895ee166fa87c88d0443f0745bc9384dac10c
sb/UsbDebuggingManager.java
65a30ab519580deed21d206e66f456fc2c706fbe 15-May-2014 Paul McLean <pmclean@google.com> Changed namespace of AlsaParser (and components) to correctly reflect their place
in the directory hierarchy.

Change-Id: I33a5a34a31d5811cfb5167843dc185ba94d236fd
sb/UsbHostManager.java
d83a096f299abd9c7fe5e441ef1bb169c314b575 03-May-2014 Dianne Hackborn <hackbod@google.com> Bump up priority of system receiving BOOT_COMPLETED.

Change-Id: I5166f88f11f781914312e867cb653c8ecbefa705
sb/UsbDeviceManager.java
8aa68921a577e1b665fe61cb40d3c929054a0a94 17-Apr-2014 Aaron Whyte <awhyte@google.com> am ee5d512d: am 4980996b: Merge "Allowed custom secure-adb confirmation via Activity or Service. It used to only be available via an Activity." into klp-modular-dev

* commit 'ee5d512d624c15fa0c7e179ace24c7055a9f539d':
Allowed custom secure-adb confirmation via Activity or Service. It used to only be available via an Activity.
ee5d512d624c15fa0c7e179ace24c7055a9f539d 17-Apr-2014 Aaron Whyte <awhyte@google.com> am 4980996b: Merge "Allowed custom secure-adb confirmation via Activity or Service. It used to only be available via an Activity." into klp-modular-dev

* commit '4980996bcc4e8065cf5dff1cf989d73face38281':
Allowed custom secure-adb confirmation via Activity or Service. It used to only be available via an Activity.
d1931ffc075f73d043616b7446f14a653609782e 11-Apr-2014 Aaron Whyte <awhyte@google.com> Allowed custom secure-adb confirmation via Activity or Service.
It used to only be available via an Activity.

Change-Id: Id79a99a70e721f3b567e75d45ffeba779264ec1e
sb/UsbDebuggingManager.java
fd7d31087bcd40b825b0eee3058e2298d8648e9f 11-Apr-2014 Paul McLean <pmclean@google.com> Merge "Implement USB Audio across Nexus Devices Fix issues with connecting non-audio USB devices."
d1d7c491601a3fd1547c31606e1b8386db068b9c 11-Apr-2014 Paul McLean <pmclean@google.com> Merge "Revert "Revert "Initial implementation of USB Audio output."""
df3614693dd4fe52a116dcd28bd74eae80818a4f 11-Apr-2014 Paul McLean <pmclean@google.com> Implement USB Audio across Nexus Devices
Fix issues with connecting non-audio USB devices.

https://b.corp.google.com/issue?id=13745966
https://b.corp.google.com/issue?id=8281454
https://b.corp.google.com/issue?id=13751080
https://b.corp.google.com/issue?id=4643412

Change-Id: I1186f69a6c5f50279a1225a77fb5d4f7a8eda3cb
sb/UsbHostManager.java
988b38bc812b12871ac7452a40d9d73273d126bc 11-Apr-2014 Elliott Hughes <enh@google.com> am 5b7dccc4: am 90e2301e: am d2a11d97: Merge "Add explicit close of Scanner input"

* commit '5b7dccc4f9cc1d07650cd7d1f499c3c11ba3ede2':
Add explicit close of Scanner input
5b7dccc4f9cc1d07650cd7d1f499c3c11ba3ede2 11-Apr-2014 Elliott Hughes <enh@google.com> am 90e2301e: am d2a11d97: Merge "Add explicit close of Scanner input"

* commit '90e2301e23532c92dd4c24394b7407e243389e9f':
Add explicit close of Scanner input
c837a451946b64d70ed7c642fbde03c182c28b6f 09-Apr-2014 Paul McLean <pmclean@google.com> Revert "Revert "Initial implementation of USB Audio output.""

This reverts commit f2f80c09b668176b3b1e619457ae628432636507.
sb/UsbHostManager.java
f2f80c09b668176b3b1e619457ae628432636507 08-Apr-2014 Eric Laurent <elaurent@google.com> Revert "Initial implementation of USB Audio output."

This reverts commit 3af0fe0c9df2fc1e0a4d6bcd827a4d7aa28dbdeb
while investigating issues 13751080 and 13883978.

Bug: 13751080.
sb/UsbHostManager.java
6f127c9b6c249ca1cd17c07a8476edd0fcc1f04d 01-Apr-2014 Paul McLean <pmclean@google.com> Merge "Initial implementation of USB Audio output."
3af0fe0c9df2fc1e0a4d6bcd827a4d7aa28dbdeb 02-Dec-2013 Paul McLean <pmclean@google.com> Initial implementation of USB Audio output.

Change-Id: I7fbbe421285d628fa49591c6469ac50efec77ccf
sb/UsbHostManager.java
868f373b65200ace63b143da60a270bb18903d82 29-Mar-2014 Aaron Whyte <awhyte@google.com> am 23fd13de: am f10d0399: Made secure-adb\'s new-public-key activity configurable. Some devices do not have lockscreens themselves, so the plan is to have them do RPCs to companion devices that can have lockscreens, for allowing or rejecting unwhitelisted adb public k

* commit '23fd13de62762e98c32f2b7525f01f0bcdf416fd':
Made secure-adb's new-public-key activity configurable. Some devices do not have lockscreens themselves, so the plan is to have them do RPCs to companion devices that can have lockscreens, for allowing or rejecting unwhitelisted adb public keys.
f10d0399bf5f519dff414a9d195a0eaacb37f9b7 28-Mar-2014 Aaron Whyte <awhyte@google.com> Made secure-adb's new-public-key activity configurable.
Some devices do not have lockscreens themselves, so the plan is to have them
do RPCs to companion devices that can have lockscreens, for allowing or
rejecting unwhitelisted adb public keys.

Change-Id: I6f7504313074e6748c0bd467a29ac3a311036f4d
sb/UsbDebuggingManager.java
0416faa2b2b14df2f9392937a61f2d182feaa9d5 21-Mar-2014 Mike Lockwood <lockwood@google.com> am 7a07f4d4: am a5853b17: am 1fe28b20: am 71060db6: am dffdf107: Merge "UsbDeviceManager: A better fix for race condition when starting USB accessory mode" into klp-dev

* commit '7a07f4d4ad1f2f4893223693aece62f095ce004e':
UsbDeviceManager: A better fix for race condition when starting USB accessory mode
c84b4d7ff20c21aa3658c81c18546a74921be441 21-Mar-2014 Mike Lockwood <lockwood@google.com> am e920322f: am 86119603: am aa7e396f: am 935d417b: am afc3a5d3: Merge "Revert "UsbDeviceManager: Fix race condition between accessory start and USB configured uevents"" into klp-dev

* commit 'e920322ff0c67cdd9e9682fd7c7df5221a6fb13e':
Revert "UsbDeviceManager: Fix race condition between accessory start and USB configured uevents"
1fe28b20f1cfc6d2542f8b0bfe48355f3a58067b 21-Mar-2014 Mike Lockwood <lockwood@google.com> am 71060db6: am dffdf107: Merge "UsbDeviceManager: A better fix for race condition when starting USB accessory mode" into klp-dev

* commit '71060db65e0e1c903b429c932cd6e27beec10a3e':
UsbDeviceManager: A better fix for race condition when starting USB accessory mode
aa7e396f44f9b3b12a6abc9d8d62cf3a6f17527b 21-Mar-2014 Mike Lockwood <lockwood@google.com> am 935d417b: am afc3a5d3: Merge "Revert "UsbDeviceManager: Fix race condition between accessory start and USB configured uevents"" into klp-dev

* commit '935d417b5615a62bc521a8eb58c35de1b4fdf841':
Revert "UsbDeviceManager: Fix race condition between accessory start and USB configured uevents"
9428eb82c0cadf897e47475e616d3927cb2524e7 14-Mar-2014 Mike Lockwood <lockwood@google.com> am c5353ce3: am 685831bf: am f9b90434: am ff64f5ed: am 381374b3: Merge "UsbDeviceManager: Fix race condition between accessory start and USB configured uevents" into klp-dev

* commit 'c5353ce373f02b549ed9e63aa23f94ca1a726f7e':
UsbDeviceManager: Fix race condition between accessory start and USB configured uevents
f9b90434ef04b509c7dcb868d50aa53a66b97809 14-Mar-2014 Mike Lockwood <lockwood@google.com> am ff64f5ed: am 381374b3: Merge "UsbDeviceManager: Fix race condition between accessory start and USB configured uevents" into klp-dev

* commit 'ff64f5ed7c2b55878d149d546092e029cba15465':
UsbDeviceManager: Fix race condition between accessory start and USB configured uevents
e97b62ed0d4050acacbf54781435686ea28edd73 13-Mar-2014 Mike Lockwood <lockwood@google.com> USB: Add support for disabling USB permission dialogs.

Setting scom.android.internal.R.bool.config_disableUsbPermissionDialogs to true
will disable all USB permission dialogs, allowing apps access to USB devices
and accessories by default.

For prototyping purposes only. This should not be used in real devices.

Bug: 13437578
Change-Id: Ie7bf83882943930b15e5f1edb3044a4a52034273
sb/UsbSettingsManager.java
7531aa22355cf03f51def61ba67f1636bf85f408 13-Jan-2014 Mike Lockwood <lockwood@google.com> Add support for USB devices with multiple configurations and alternate interfaces

Added UsbConfiguration class, as well as accessors to UsbDevice to get configuration list
Added methods to UsbDeviceConnection to select configurations and alternate interfaces.

Also added accessors for USB descriptor name strings and fixed some memory leaks in the JNI code.

Bug: 12425052
Change-Id: Idb990f4d5c054a8cb997eb3f440f6da9f83bce05
sb/UsbHostManager.java
4495c86dbf2b625fe717c98fec389ac8134d63ef 25-Feb-2014 Mike Lockwood <lockwood@google.com> am f2d07694: am 6eff9949: am 0fc59cd9: am da2bbaf2: am 2c7b913e: am 5daec5b5: Merge "UsbDeviceManager: Fix race condition entering USB accessory mode" into klp-dev

* commit 'f2d07694d05240b039bd02cf3982941c0435c33d':
UsbDeviceManager: Fix race condition entering USB accessory mode
0fc59cd958b87d015deac63797fcbfbcec518389 25-Feb-2014 Mike Lockwood <lockwood@google.com> am da2bbaf2: am 2c7b913e: am 5daec5b5: Merge "UsbDeviceManager: Fix race condition entering USB accessory mode" into klp-dev

* commit 'da2bbaf219117f7507c5c0015c41347a9cc27507':
UsbDeviceManager: Fix race condition entering USB accessory mode
a78068e7a3af53cc2b590902f74074d1781513da 19-Feb-2014 Adam Lesinski <adamlesinski@google.com> am 13c83996: am 1c532c2e: am 4b07b26e: Merge "Make UsbService optional" into klp-modular-dev

* commit '13c839962e246517a7a95326610ea30c529d79dc':
Make UsbService optional
2cb6c60c0d2de3bc743c043aca963db6fe52662f 15-Feb-2014 Adam Lesinski <adamlesinski@google.com> Make UsbService optional

Tweaked the services Android.mk to build dependencies
when building with mm[m].

Change-Id: I6dad511c652bcacc085f27ede5f8f22a6982c6bd
sb/UsbDebuggingManager.java
sb/UsbDeviceManager.java
sb/UsbHostManager.java
sb/UsbService.java
sb/UsbSettingsManager.java