[MTP] Fix lock-screen bypass via default USB functions on timeout

When switching USB functions times out in UsbHandlerHal (due to HAL
delay or host disruption), the MSG_SET_FUNCTIONS_TIMEOUT and
MSG_FUNCTION_SWITCH_TIMEOUT handlers recover by falling back to the
default USB configuration (mScreenUnlockedFunctions).

However, neither handler checked the lock screen state. If a user set
PTP (or MIDI, UVC, RNDIS) as their default USB configuration in
Developer Options, a malicious host could exploit these timeout paths to
enable the data transfer interface on a locked device without user
interaction.

This is a direct follow-up and remediation for the incomplete fix in
CVE-2024-43085.

This CL adds a check for !isScreenLocked() in both timeout handlers
before applying the default functions. If the screen is locked, we
safely fall back to FUNCTION_NONE (charging only).

Bug: 519884370
Flag: EXEMPT BUGFIX
Test: Compile check services.usb
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:5683ad06943e188cf04a03bffd3c3157d2c455b2
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:c9ab708153d0613e6b96736361242833f8d54798
Merged-In: Id85a3170c8b42b9d38be01eb230fa7d6b8ff7983
Change-Id: Id85a3170c8b42b9d38be01eb230fa7d6b8ff7983
1 file changed