This patch prevents a Null Pointer Exception in
queryMoistureDetectionStatus() when getPortStatusHelper() fails to open
the /sys/class/typec file. The failure results in an empty
currentPortStatus vector, causing the NPE when accessing its first
element.
Bug: 361097811
Flag: EXEMPT bugfix
Test: NPE does not occur when getPortStatusHelper() fails
Change-Id: I61c9f7647aafca28b777e53f170764ddd02c060f
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Some external hubs have the same VID and PID as the internal hub,
causing unintended hub tuning and compatibility issues.
This patch restricts hub tuning to only the internal hub located on
bus 1, port 1 when enable_hub is set to 1.
Bug: 353650207
Test: Verified an external GL852G speakerphone dock works when docked.
Test: adb shell cmd android.hardware.usb.IUsb/default hub-vendor-cmd
<hex wValue> <hex wIndex>
Flag: EXEMPT bugfix
Change-Id: If2cfe6684e4f5fafaab34bf7a4e4b4cd464d6575
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Add a log for the retry. Also define the sleep time in the header file.
Bug: 341996696
Change-Id: Ib3cc0c6ad576e7cda26b7f50cdc61d52e6349c78
Signed-off-by: Kyle Tso <kyletso@google.com>
(cherry picked from commit d17fdff5f81cff76adaa75d50f26318be8048123)
server_configurable_flags, this new read api lib will be needed for new
codegened aconfig flag lib.
Bug: 321077378
Test m and avd
Change-Id: I908ccf51b59ef4f475d8680003cb4aec61bdd12c
Update i2c device paths with static bus numbers.
Also remove some redundant paths.
Bug: 323447554
Test: Boot to home
Change-Id: Id3f0fccd39b70d247c0d7a17a1944223619ec40e
This reverts commit 2371ea7920.
Use the same i2c device paths across all kernel versions.
Bug: 323447554
Change-Id: I0f970347a09e01f272a54fc7c940ea576a9e510b
Signed-off-by: Jacky Liu <qsliu@google.com>
The sysfs paths in the rc file differ across kernel versions or build
targets. Given that the path is static in the newer kernels (6.1+),
modify the paths for newer kernels in the original rc file and create
another rc file for older kernels (i.e kernel 5.10). Put the correct rc
file to the vendor partition based on kernel versions.
Bug: 317946158
Change-Id: Ie313664ee14c837bc9f33113e9341f6e06192401
Signed-off-by: Kyle Tso <kyletso@google.com>
The paths of sysfs nodes are different on multiple build targets and are
also different between the old kernel (5.10) and newer kernel (6.1).
Since usb HAL code is shared by those targets and different kernel
versions, Runtime search the correct paths.
Bug: 317946158
Change-Id: I676455145232fd71db1578bb7a9801fed7bb327f
Signed-off-by: Kyle Tso <kyletso@google.com>
Dump flag value in the construtor for easier debugging. Feature flags
are not expected to change in runtime, dumping the value once should
be enough.
Bug: 296119135
Test: manual test
Change-Id: Ie5aca2dff23e59704fb306833cde0e592b9f430d
(cherry picked from commit 9164eae7cdee032381d8bf045fbbed33f62b00bf)
The state count requirement is very specific to the case where the
signal integrity is the culprit of flaky connection. However,
there could be other cases such as bad receptacles causing data pins
to disconnect randomly.
Remove the state count requirement to cover more cases.
Bug: 296119135
Test: manually trigger the warnings
Change-Id: Ic2ae376ad6062d9930614381503f44e4a5ac760f
Support flagging enum failure and flaky connection in device mode,
flagging enum failure and missing data lines in host mode.
No warning would be flagged until 5 secs after the data session
starts to give ample time for the connection to stabilize, a timer
is added to support it.
Bug: 296119135
Test: manually trigger the warnings
Change-Id: I25f08657e328913946add192b5ecb9ee50c3a1a8
Migrate the usb data session event functions to the class with the
following additional functionalities;
- Support detecting gadget soft pulldown (usually done during configfs
function switch) and report usb data session correctly.
- Support reporting usb data compliance warnings to the class USB
by providing getDataComplianceWarnings call.
- Use boot_clock instead of steady_clock to measure time correctly in
the case of system suspend.
UsbDataSessionMonitor is self-contained and can be migrated to pixel usb
library after feature maturation.
Bug: 297224564
Bug: 296119135
Test: usb data session upload in device and host mode
Change-Id: Iba001933e193935d64cf5fd0a1257d02a4274fb1
(cherry picked from commit ea65ca11f6fbb6f13b89ef9ed03015f47ec1cedb)
Report COMPLIANCE_WARNING_INPUT_POWER_LIMITED instead of
COMPLIANCE_WARNING_OTHER to flag incompatible chargers. The underlying
logic that generates the warning remains the same, what's changed is
the enum that's being used.
The purpose of the change is to have a warning type that better
represents what actually happens and free up COMPLIANCE_WARNING_OTHER
that was intended to act as a fallback reason code.
The flag enable_input_power_limited_warning controls whether to switch
to the new enum, while the flag enable_usb_data_compliance_warning
controls the new enums that are added as FlaggedApi in the framework.
Both flags need to be on to enable the change.
Bug: 308700954
Test: manual tests with local flag override
Change-Id: I6595706d1b83d533fc2d3e29086773270e045ede
Upload metrics for the last data session that just ends upon
data role changes. The change is purely metric collection and
does not change any business logic.
This is a direct CP from ag/24816727
Bug: 297224564
Test: Trigger metric upload for both host and device mode and
verify it by statsd_testdrive
Change-Id: I823ae8712b7914cfc7f6c6379acb3749d13c0974
(cherry picked from commit ccb35c81ff0bbfb013136bae7a572280b196bd1a)
If Usb.cpp cannot write a zero value to the USB_DATA_PATH file, display
the message of "Not able to turn off usb connection notification".
Test: refactoring CL. Existing tests still pass.
Bug: 301016122
Change-Id: I8e0f485e74d10a0154e4cd78af9f5ef5a22d328f
Indicate to the kernel that the usb gadget is pulled up
by writing to `update_sdp_enum_timeout` sysfs node. Write
to this node will inform the kernel that it can lower the SDP
timeout alarm value which is used to detect an SDP port
vs a DCP.
Bug:275687235
Test: Check `update_sdp_enum_timeout` is written into after usb
gadget is pulled up. Verify that the alarm timeout lowers.
Change-Id: Id3ae7e7a20b236cec6604414a7f81860e868bdd0
Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
Poll the sysfs attributes that represents usb device state in
either of the following states: not attached, powered, default,
addressed, configured.
The information is useful in detecting non compliant USB cable,
which will be supported in later patch sets. This patch lays
the ground work to monitor the sysfs attributes in both device
and host modes.
The thread to poll uevent is re-used to poll sysfs because this
serialize type-C port events and usb device state changes, hence
prevent potential races.
Added a thin abstration layer and a map to keep epoll data so
that it's easier to dynamically add/delete files to epoll, which
is needed for usb devices in host mode.
Bug: 285199434
Test: trigger usb device state changes in device and host mode
Change-Id: Ie5389d051deb28dbb486c2f27319b3cc9e89312f
Do not override UsbDataStatus when already populated.
Compliance warnings such as missing Rp do not populate
UsbDataStatus and the port partner is detected.
Populate UsbDataStatus only when not populated.
Bug: 279251052
Change-Id: Ibe71bdd5c521ba90c124d89bd56af90087c0df18
(cherry picked from commit 47e1400c8fef8af1aea985795d7adfe3ff16871b)
(cherry picked from commit a778a7c3a82c98ec56f9e2b0c2a1dce343317b48)
The JK level setting is configured to the hub via a vendor USB
command whenever the hub is enabled.
The shell command can be used to change the JK setting for testing
purpose, but the values take effect next time the hub is enumerated.
Bug: 261923350
Test: adb shell cmd android.hardware.usb.IUsb/default hub-vendor-cmd
<hex wValue> <hex wIndex>
Test: verify on user/userdebug builds the vendor command is triggered
in the following scenarios.
1. boot with Kolan docked
2. undock and dock Kolan
3. kill android.hardware.usb.IUsb/default
Change-Id: I8873695c42f362138d99b45ffa2ef637c357202b
This change is to add all the possible i2c nodes for tcpc functions with the correct permission, due to the path may change with different android version.
Bug: 273391794
Test: limit 1.3A work when connect to Head Unit
Change-Id: Iefb44f37c5b42ae5579e928477efc927d270b724
Set mode, power role and data role when connected to non compliant
port partners.
Bug: 268584498
Change-Id: I6c3e7df09a61e26f3b976a86bd65cb646edd653d
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Adds vendor code for non-compliant charger feature. Currently
updates service version.
Minor port of commit 96ccf93453583642a15dd96b1e4d6bf0645fc10b
Test: atest VtsAidlUsbTargetTest
Bug: 236322506
Change-Id: Ie1a48b1acaaae9a53f3b9bfebcfee7a2f4814810
(cherry picked from commit 96ccf93453583642a15dd96b1e4d6bf0645fc10b)
1. Remove unused group "wakelock".
2. Correct the right return value on setCurrentUsbFunctions.
Bug: 266694076
Test: Boot to home and function work
Change-Id: If0925a61e481e4deca560dc8dfc1be80a76c148f
UVC is a new USB function supported in Android. This CL adds UVC as a
valid function and gives it a new pid of 0x4ee[de]. UVC function is
guarded by the property `ro.usb.uvc.enabled`. When this property is set
to false, UVC won't be considered as a valid gadget function.
Bug: 242344221
Test: Manually tested that the UVC function is successfully configured
Change-Id: I7ce1cc192c09b5f3cd7c73405fe54426a1311dfb
This change migrates IUsbGadget implementation to AIDL.
Port of commit <d6d0b7d2ca5066988ee90889dccd00c06d64b694>.
Bug: 218791946
Test: USB function switch success and AIDL service is running.
Change-Id: I9613178d3cd2f9abd5396e4af763a257a8ef62a7
kernel dev attribute has now been renamed from enable_usb
to move_data_to_usb. Update the same.
Bug: 251381400
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I8e4aa0b2e09bfef807f0169eabb79e2fa2e4d2c7
Correct the I2C path to match the new memory address setting.
Test: Connect to HU work
Bug: 233996502
Signed-off-by: Ricky Niu <rickyniu@google.com>
Change-Id: I27cca56698568e8a3060d9e40bad3a29ec072588
For imporve USB stability, limit the current to 1.3A,
when connect to accessory.
Bug: 206635552
Signed-off-by: Ricky Niu <rickyniu@google.com>
Change-Id: I2c1091aa7111e6242cc949923fbc86f27e54e976
On Windows platforms, wrong function sequnce will cause usb
driver installing not working. This patch will modify the
function sequence when debug functions are enabled.
Bug: 228800277
Test: tethering is working when debug functions are enabled.
Change-Id: I9f8b02354617b08a34fb4641ac710f32dabc643e