History log of /frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
ed0cc81212c44f831aed19661a4377ff99cdb60c 29-Jun-2017 Jerry Zhang <zhangjerry@google.com> Merge "Broadcast only if boot complete"
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
bee04d08b555b030c6e6cf31b10124862411eeb1 27-Jun-2017 Philip P. Moltmann <moltmann@google.com> Clean up USB*Manager.

Just automatic cleanup.

Test: Built
Change-Id: I1da09d6b43503a6b77a3619f0f8513ef39cf2d75
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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)
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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>
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
eb26052f3caf57e37d54bd744b2e499270479123 16-Mar-2017 Badhri Jagan Sridharan <Badhri@google.com> format cleanup(intellij)

Change-Id: Idfa4cc769ec6726be86086879541476d9ed1d12e
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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."
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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
7f8cf37da3cb983561905c4812e02938cf544044 23-Feb-2017 Glenn Kasten <gkasten@google.com> Fix typo in log

Change-Id: I5e805f4e4f296e7a9e8d12bf8372515f59099f17
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
87d66fd3f1111ffa6d5ba48cf38ccceea11e69cd 31-Jan-2017 Hidenari Koshimae <hidenari.koshimae@sonymobile.com> Minor formatting cleanup to remove overlong line

Change-Id: If0afb279552bc664ba579badaf35662effbd2a80
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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)
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
4ca071da2878391cab39c6125503b447e50b67ad 23-Jan-2017 Christopher Tate <ctate@google.com> Send USB_STATE broadcast to manifest receivers

Bug 34594920

Change-Id: I5d026f469710960b792dcf1bfebc1c07f90c6182
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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)
/frameworks/base/services/usb/java/com/android/server/usb/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)
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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)
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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)
/frameworks/base/services/usb/java/com/android/server/usb/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)
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
01355161536787a55190ff3d2595fbf6c8056fe3 15-Jul-2016 Philip P. Moltmann <moltmann@google.com> Handle USB power role 'sink'

Fixes: 29963134
Change-Id: I7cfe042ed007d36cee5f8bc4c0fa33f8936cba3d
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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)
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
0be6800b0feba50fa2c1be7852ee2eb02c38afc0 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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
d1d533610aad279f7ae9037f0e4b3dd865bb0a24 08-Jan-2016 Julia Reynolds <juliacr@google.com> Increase notification priority for adb connections.

Change-Id: I04ec4dac40737d59a32775e579f734a5460db25c
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
92386c42a83c6cba546aed8522de62b9d1ddd46e 26-Aug-2015 Yasuhiro Matsuda <mazda@google.com> Merge "Broadcast ACTION_USB_STATE only if necessary."
8338ed00ae44635d099b530b3360e6d1f7041827 12-Aug-2015 Jason Monk <jmonk@google.com> Show usb charging notification when in host mode

Bug: 21615151
Change-Id: Ifc8c288a94f52ecac19990ab3d9095b1aef8efc3
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
6d8e413a63c6ab054557f81d53bb8b35f0816679 12-Jun-2015 Chris Wren <cwren@android.com> remove setLatestEventInfo from USB

Bug: 18510449
Change-Id: I6b9ccaa0537c8044c5fa900ae4ea68b2676e1365
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
d9c7f2456957a5610cbbca1b2e31aa7b3574c50d 10-May-2015 Nick Kralevich <nnk@google.com> UsbManager / UsbService / UsbDeviceManager: delete unused code

These functions are never called.

Change-Id: Ic436e1036bed717d2c64701fddd9a810abb9443e
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
4a357cd2e55293402d7172766f7f9419815fc1e8 19-Mar-2015 Alan Viverette <alanv@google.com> Replace usages of deprecated Resources.getColor() and getColorStateList()

Change-Id: I8f64fe6c4c44a92ff6d07250223ba590a1d691b0
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
08c7116ab9cd04ad6dd3c04aa1017237e7f409ac 28-Feb-2015 John Spurlock <jspurlock@google.com> Remove unused imports in frameworks/base.

Change-Id: I031443de83f93eb57a98863001826671b18f3b17
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
c3c2ff70a23ff31bec72e7794ea33552ca106438 20-Feb-2015 Mike Lockwood <lockwood@google.com> Add support for USB notification when connected as a MIDI peripheral

Change-Id: Ib3efcda6af976c878e63b0d35a8e47a3ea9435a3
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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)
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
255dd04271088590fedc46c8e22b2fd4ab142d39 19-Aug-2014 Selim Cinek <cinek@google.com> Added notification color to all system notifications

Bug: 17128331
Change-Id: I81a94510ef51b99916f314c0dd65852426a1fbeb
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
9769ef9f8ac86ef69d08afbadb7a00aceeadc5a6 14-Jul-2014 Emily Bernier <ember@google.com> Restore user switching logic.

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

Bug: 13585295

Change-Id: I6b7905fad06bf2e1d4dd629a266280ddff9b3121
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
d83a096f299abd9c7fe5e441ef1bb169c314b575 03-May-2014 Dianne Hackborn <hackbod@google.com> Bump up priority of system receiving BOOT_COMPLETED.

Change-Id: I5166f88f11f781914312e867cb653c8ecbefa705
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.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
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
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
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java