It looks like UsbDeviceLogger is a fork of EventLogger,
therefore it would be better to deduplicate it.
Bug: b/254234346
Test: N/A
Change-Id: I20da7bb0bbf83888f4c448742326a3cb54462a4d
A subsequent change will actually move the files to the other git
project.
Bug: 243194720
Test: presubmit
Change-Id: If126bb68f74852528c4da8df79831b49b5129983
If a UsbDeviceConnection is used both for sending and receiving data,
bulkTransfer may time out.
The solution is to extend the timeout from 10ms to a second.
Also, we need to split the packet into multiple packets if they are
greater than the endpoint's max packet size. Linux would do this for
us, but with the new retry code, we may be sending some parts of the
packet multiple times otherwise.
This is because if Linux would split the packet into 3 packets and
only the third packet fails, the first and second packets would resend
if we don't split the packets.
Bug: 250616636
Bug: 251551233
Change-Id: Ic4dc2d4434731d34b26b0e073221e4ef5ebbd920
Test: CTS Verifier MIDI tests
Bug: 239184431
Test: Use TestDPC to enroll device and disable USB data, then verify that the behavior of charging notifications is identical to another phone with USB data enabled:
- Notification shows up when connecting to laptop, another phone before/after power swap.
- Notification does not show up when connecting to a wall charger.
Change-Id: I016f65dcdd478d3429efe871bf99aee2f1653c45
When USB MIDI hardware sends bytes to Android, Android should set
power boost as if an interaction event just happened.
This change reduces the number of audio underruns.
Bug: 122678281
Test: Connect Akai MIDI USB Keyboard to MIDI Synth Ex
Test: Connect another Android phone as host to MIDI Synth Ex
Test: Collect perfetto traces and verify a difference
Change-Id: Ic95283813beb16e55d941f85f876124afa2f2794
Currently, the "Charging connected device via USB" notification appears
and then disappears when a USB device is disconnected. The notification
should not appear when no USB device is connected. This CL prevents
this.
Also prevents the notification from showing up when a mouse is
connected.
Bug: 234548453
Test: Peripheral mode, host mode, and Power/Data role swap
Signed-off-by: Jimmy Hu <hhhuuu@google.com>
Change-Id: Ie4c67c639d8633361e5a3675502283cae4e35bd9
USBPortManager now checks for AIDL post-migration, stops redundant error message for HIDL checks
Bug: 241042174
Test: Checked to see USBPortManager Error no longer present in System Logcat after order swap
Change-Id: I4f0092a68e0cc0dd42dcf2d16f4cdfa646cb72f4
Update the function of calculating likelihood of being an output
headset.
1. Change the function name from probability to likelihood. It is fine
to have the value be negative or greater than 1.0f.
2. If there is an output terminal with type as HEADPHONES or
BIDIR_HEADSET, likelihood += 0.75, goto 5. Otherwise, goto 2.
3. If there is an output terminal with type as SPEAKER,
likelihood += 0.5. Goto 3.
4. If there is associated input terminal for an output terminal exists,
likelihood += 0.25. Goto 4.
5. If multiple channels are supported, likelihood -= 0.25. Goto 5.
6. If there is an output terminal with type as SPEAKER, HEADPHONES or
BIDIR_HEADSET and there is HID interface, likelihood += 0.25.
Test: connect USB devices and check the reported device type.
Bug: 231973571
Change-Id: I98e433b5333f8bb317b6ae89bd65fee2c42236eb
Some tests continously plug and unplug MIDI devices.
After 1000 operations, there is an infinite while loop.
This CL clears up the hashset if it is nearly full.
Bug: 234688233
Test: Plug and unplug MIDI devices
Change-Id: Ie0c6359c07694e3f6cc4a3011fd39a525314ab94
The parser returns USB descriptors for multiple configurations.
Only one configuration should be used at once.
The first configuration is the default config.
Bug: 234607936
Bug: 223316278
Test: CTS Verifier on AudioBox 96
Test: MIDI Scope on MIDI 2.0 device
Change-Id: I9169faa2ea5cf9fd516834f7802963245762e74b
Add null checks for mUsbMidiPacketConverter and
other variables inside input/output threads.
Also adding a NullPointerException catch for more
protection.
Also changing a timeout from 50ms to 200ms.
Bug: 233409535
Test: MidiScope and MidiKeyboard for MIDI 1.0/2.0
Change-Id: Ib73060d05ba8cbad9ab9b4d0e37a892d8916c0d9
We start input threads before setting mIsOpen.
This means that sometimes, input threads immediately exit
due to a race condition.
The fix here is to remove the use of mIsOpen and use a new
mechanism with Thread.interrupt() and Thread.interrupted()
to mark a thread to be closed.
Bug: 223316278
Test: MidiScope/MidiKeyboard
Test: CTS Verifier Bluetooth Tests
Change-Id: I7c221504ae8a8814c1aa5598552494c80c202eb2
When a USB MIDI device with multiple ports is
unplugged, onDeviceStatusChanged gets called
multiple times. The first time ends up opening a
port since there are still other open ports.
The fix here is to ignore onDeviceStatusChanged()
if close() was called before.
Also changed a continue to a break since that
condition almost never gets hit.
Bug: 232142589
Bug: 231496864
Test: Midi Keyboard that opens both input and output
for both peripheral and host mode
Change-Id: I973d55371cd16803ede192081531ca5f59847a51
When getting data from a device, bulkTransfer loses
~1-2% of data. The recommended approach is to use
requestWait as done in this CL.
This method also lets us remove a lock. Removing
this lock speeds up initialization, fixing a timeout
bug with CTS Verifier.
Also add a null check for UsbDeviceConnection
Bug: 231496864
Bug: 223316278
Bug: 231973034
Test: MidiKeyboard/MidiSynth to multiple keyboards
Test: CTS Verifier with AudioBox USB96
Change-Id: Ib841fd0b092e93ac5fdb7a65221ec5c2958f6171
Broadcasting intent is not allowed before boot completed.
Check if boot completed to broadcast accessory time out
intent to avoid exception.
Bug:229387375
Test: Reboot with head unit connected
Signed-off-by: Ricky Niu <rickyniu@google.com>
Change-Id: I34bc7625bbcb9525ad25cb1538ed4138fcae8ead
Adding MIDI info to USB dumpsys so developers can debug better.
Bug: 229122603
Test: adb shell dumpsys usb
Change-Id: Ic3c7ab21865457b1e1f0f97fdd1827bb0b442481
Bug: 200323450
Test: Function work with reboot connect to PC and HU
Signed-off-by: Ricky Niu <rickyniu@google.com>
Change-Id: I9bdfcda195c30d71d9d39e1170bbf66a7021c39b
Original patch: aosp/1539944
Bug: 209342433
Test: See details in b/209342433
Change-Id: I7ff58a1a9755939ccb26dad61969902ec91f2225
Signed-off-by: James Wei <jameswei@google.com>
UsbMidiEncoder is not thread-safe. Therefore, each output port
should use its own encoder.
Bug: 225884009
Test: MidiKeyboard/MidiScope on both MIDI 2.0 and MIDI 1.0 paths.
Test: Verified M-Audio Keyboard with only input has the correct logs.
Change-Id: I43bd7381982403766b7f37c22d55ef5d19013120
Fixed the operationID when the operationID collisions, create another key
Bug: 217369748
Signed-off-by: Ricky Niu <rickyniu@google.com>
Change-Id: I22126b4c04b5c92bc9fc9db7405e7ee9d2806b49
In I0b86f9bd26e4c9a50576f704deb6b53fc9a5c130,
we introduced a bug by forgetting a null check.
This CL adds the null check back.
Bug: 223481435
Change-Id: I62e9b1135306b2d952f7fddace656a938545e74f
Test: MidiKeyboard/MidiScope
ALSA has multiple bugs related to MIDI 1.0. This CL removes
Android's dependency on ALSA for MIDI 1.0 USB Host mode. MIDI to
USB MIDI conversion is done in UsbMidiPacketConverter.java
ALSA is still used for peripheral mode.
Bug: 217392573
Test: Ran local unit tests with UsbMidiPacketConverter
Test: MidiScope/MidiKeyboard with multiple MIDI keyboards
Change-Id: I0b86f9bd26e4c9a50576f704deb6b53fc9a5c130
getUsbDataStatus now returns bit field values of @UsbDataStatus.
Also renaming from USB_DATA_STATUS_* to DATA_STATUS_* based on
review comments.
Bug: 216640242
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I96ade3dd7041a4094e57907069a872909a62e72f
After the device (USB host) finished the pr_swap and the power
role is changed from Source to Sink, the notification should be
updated with different messages. However, the notification may be
ignored since the charger type is not USB. Users may get
confused when the notification is gone.
If the peripheral device is still connected, UsbDeviceManager
should push new notification.
Bug: 212189038
Test: notification is updated
Change-Id: I772c8c06a1e3a8770d0bf132c5e8fdf313bb2685
This change annotates dump/debug methods in services.odex that are
larger than 10000 bytes with NeverCompile so that they will not be
compiled. This results in an overall ~1% decrease in the size of
services.odex.
Bug: 215417388
Test: Build and check that these methods are not called during boot or
app startup.
Change-Id: Ic14b273a66a30ad63ba9a82c0b45fac9beb7589a
calculateDefaultMidiProtocol() is a function that figures out the block
type of a specific MIDI device. This function is used whenever a MIDI 2.0
device is added.
Currently, connection.setInterface() is always called in this function.
When a different interface is set, the MIDI 1.0 interface in ALSA just stops.
/dev/snd/midiC1D0 is no longer exposed.
The solution in this CL is that Android should not call
connection.setInterface() until the MIDI 2.0 interface has opened. This
means that querying protocol on startup should not use setInterface.
This way, the MIDI 1.0 interface should work up until the MIDI 2.0
interface is actually used.
Bug: 216178160
Test: MidiScope and MidiKeyboard
Change-Id: I53d7792d6d331abcddea2d1aedb394ff4dee0a9c