Allow multi-usb work to continue without changes spinning out of control.
Bug: 111397675
Test: Set single-mode on and verify correct behavior.
Change-Id: I70f70bbb8edae6cbd1e73bee40fe821079cba9d8
Pure refactor of USB code for simple Arc logic injection.
Should have no behavior change for AOSP.
Bug: 74258201
Test: Run USB Accessory and USB Device test.
Change-Id: I8f7dace9155ceb75bc465fbb03a26f52694c8f93
Attempt to read USB descriptor of USB hub devices results in hanging
thread on getDescriptorString_native call. Also check device
interface class/subclass as well.
Test: verified that usb host thread no longer stuch in getDescriptorString_native call on Mojave board with USB hub attached
Bug: 112657091
Change-Id: I46271dcc9c80168a650940fbde9218a54cafe8da
Using "0" as value for USB control transfer timeout
results in an unlimited timeout in case of bad USB
devices. In host kernels where hung task panic
is enabled, this results in device reboot.
So, add a finite timeout for USB control transfer.
Test: manual run and test with bad USB devices.
Change-Id: Ibc13ca4d8259a08ae7419bb3bcac9c161b1d3693
Signed-off-by: sgopal1 <saranya.gopal@intel.com>
One heavy dependence between the current AMS service and activities
is process management which is heavy affected by activities and their
current state. We introduce WindowProcessController and WindowProcessListener
objects as a structured way for the process changes in AM package to
be communicated to the WM package and WindowProcessListner for activity
changes in the WM package to the communicated back to the AM package.
The ProcessRecord object in AM will own the WindowProcessController object
and also implement the WindowProcessListener.
Test: Existing tests pass
Test: go/wm-smoke-auto
Bug: 80414790
Change-Id: I9e96e841b0f95e99a597cb4629fa5d2fe45760b6
3rd step in unifying the window hierarchy that is currently split
within AM and WM packages. We separate the the internal interface used
to communicate within system server dealing with activities and their
containers (tasks, stack, display) from the rest of AM internal
interface.
Test: Existing tests pass
Test: go/wm-smoke-auto
Bug: 80414790
Change-Id: Idad77721c1fe10621b9be5dced42a0a11f0183e5
When a USB device or accessory gets plugged in the system might
automatically start activities that have a device/accessory filter set
to include the plugged in USB device.
Unfortunately we seen too many apps setting too broad of a filter and it
annoys the user that this apps wants to start every time the device gets
plugged in.
This change dumps the acitivity names and their filters so debugging
such issues is much easier.
To do this, there is some mild refactoring:
1. Split packageMatchesLocked into
- getDeviceFilters to resolve all device filters
- getAccessoryFilterer to resolve all accessories
- Check if a filter matches after resolving all filters. This is no
performance issue as usually there is only one or two filters per
activity.
2. Split queryIntentActivitiesForAllProfiles into
- A per user part, so that we can use the exact same intent-resolution
code for the dump-code
- And a loop over the per user part
Test: adb shell dumpsys usb
+ incident_report usb
+ verified that the output is as expected
Change-Id: I552c963b9a1b1c7df0adc6746af8cd42a4691cd6
UsbDescriptorParser::parseDescriptors always returned true.
Remove the return value, and remove the one constructor that
doesn't parse descriptors so the device is always in a parsed state.
Bug: 74119682
Test: Built
Change-Id: I2dd8d439405867d78102a9591dd1db36fe3959dc
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
Since the callbacks are async, its possible that the callback gets
called before the systemReady flag is set.
Change-Id: I5752c097e25ef30a151461540dd7d5323cc927af
Terminal type is currently used to determine presence of audio input
or output capabilities on audio devices.
Broaden the set of terminal types accepted as inputs and outputs.
Test: Verified by playing with USB-C to 3.5mm adapter with
high impedance load, checked Terminal type reported as 0x0603.
Verified no audio on old build, audio on new build.
Checked with low impedance load with and without microphone.
Checked with no load.
Bug: 73813676
Change-Id: Ib9b291e4770dc3c03157df7ac4277da1692174d7
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
Keep track of the currently selected UsbAlsaDevice in a
synchronized manner.
Allow it to notify AudioService that it has been disabled
prior to replacing it with a new Audio Device.
Test: verified audio worked as expected when using
both UAC2 and non-UAC2 3.5mm adapters, with 3.5mm
plugging/unplugging and USB-C plugging/unplugging.
Change-Id: I8b76145490da38d4eec25f4f2bdb6695afa151b9
Adds support for ALSA jack detection for USB.
Spawns a new thread for ALSA jack detection on device
insert. If the device doesn't support ALSA jack detection,
the thread terminates.
Test: UAC2 audio accessory and a kernel
which supports USB ALSA Jack detection, switching between
speaker and USB works perfectly with plug/unplug at jack.
Bug: 68337205
Bug: 70632415
Change-Id: I1800660ad4d2341f19ce7be6d6b01f81a7f2d1a6
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
Synchronize external access to UsbAlsaDevice fields.
Rename all playback fields to output, capture to input.
Move Alsa Device String generation to UsbAlsaDevice.
Test: Used Google Play Music to test audio output while
inserting & removing USB audio devices.
Bug: 68337205
Bug: 70632415
Change-Id: I77d413736253e28a33993f45e6e405209563f3e4
Add @GuardedBy for simple functions that require a single lock
and are named XYZLocked.
Derived by errorprone.
Bug: 73000847
Test: m
Test: m javac-check-framework RUN_ERROR_PRONE=true
Change-Id: Id1d9fbe5018250e3b9d1466fc5f670d5ad902fa3
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
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
Devices like bat still have oem functions
in the persist prop, so don't throw errors.
Test: device boots
Bug: 72765363
Change-Id: I7d1e334d7cafb1ba1f328ee4160da3b098f76fa1
New metrics constant and usb strings for the new
notification / details page.
Bug: 69333961
Test: Check notification
Change-Id: If9bde7f787e40e42bb991a99b032e1ff968a0a41
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
Tuned rates that we collect PSS, to reduce how much we do
that heavy operation. Added a new way to determine
whether a process has changed to a state for the
"first" time -- now this is when it has gone to that
state for the first time since it was in a lower state.
This will reduce the amount of time we consider a
process to be first to only when it has previously
gone into a higher state than it had before.
Keep track of more fine-grained information about why we
collect a PSS sample (not just internal, but for a single
process, all processes because of a mem state change, all
processes because of a poll).
Started collecting RSS in various places, so we can start
looking at that w.r.t. PSS and see about transitioning to
it is a new primary metric.
Added logging for many of the places where the system
writes its configuration files, so we can more easily
see any bad behavior going on in those areas.
Added some currently disabled code to read smaps directly
instead of using fgets(). Probably won't help, but want
tot test.
Bug: 70859548
Test: atest CtsAppTestCases
Change-Id: I400dba0f3ae9c024df51c946cfa592561028b598
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
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
Cherry-pick from 30b9adfad1
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
Cherry-pick from 83a0d6fa57
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
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
Also added tracing to android.UsbDevice creation.
Test: Try each dump command with CALYX Pat USB DAC & Dragonfly Red USB DAC
Change-Id: I2ec05dfa9c544d0c50ee59e3b990e9010cbe0aa0
Devices - Skylab, Mir, HTC dongle, Presonus AudioBox 44VSL, HP mouse
Hard coded class ID of 0xFF and subclass 0xFD to match b/68944518 symptoms.
Bug: 68944518
Test: Manual - see above
Change-Id: I7330c57b15278158a2eb449f0463b91244a3e176
Any USB devices that are of class VIDEO or have similar
interfaces should check whether the calling client has
camera permissions before granting access to the device.
The above restriction will apply for any packages that
target P or above.
Bug: 27367690
Test: Manual using 3-rd party USB webcam applications.
Change-Id: I7b4f808d344cae33fde93e6d81c7cceed523e24a