When a new device is attached to hardware module, query the HAL to get
the supported encapsulation modes and metadata types.
Test: atest EnumDevicesTest, manually
Test: atest audiofoundation_parcelable_test
Bug: 155799506
Change-Id: I903e46e35a44416c9f2d206c128face8a6c61dcb
Revert "Add isUidActiveOrForeground() for camera/audio to use."
Revert "Add isUidActiveOrForeground for camera/audio to use."
Revert submission 10829580-isUidForeground
Reason for revert: In CameraService.cpp, before this change, around "am.isUidActive", there was up to 300 ms retry. After this change, the code could move forward fast without retry, but at "mAppOpsManager->startOpNoThrow" call, for the same reason as uid is not updated fast enough, "mAppOpsManager->startOpNoThrow" could also fail.
This CL does not really fix the root cause, but it changes the timing and now the code fails at "mAppOpsManager->startOpNoThrow" call.
Also the timing change may also cause recent multiple CTS test failures.
Bug: 154570809, 155032617, 154849083
Reverted Changes:
Iffed63293:Add isUidActiveOrForeground() for camera/audio to ...
I3685e0c8d:Add isUidActiveOrForeground() for camera/audio to ...
I51ed1fe78:Add isUidActiveOrForeground for camera/audio to us...
Change-Id: I8acde2524201b6c6d0d5c0ff9cfb2053ffbcb8ef
Enable clang thread safety analysis. Convert comments on TS
into directives. Fix missing lock acquisitions. Add missing
default initializers for the fields of UidPolicy and
SensorPrivacyPolicy
Also remove unused fields mpAudioPolicyDev and mpAudioPolicy
from AudioPolicyService.
TODO: Consider protecting pointers to command threads,
APM instance and the client, and system usages with a separate
lock.
Bug: 70398235
Bug: 155336464
Test: make, flash, and test audio on device
execute "adb shell cmd media.audio_policy" commands
Change-Id: I47b132c8b5c977812fad5c89fa57882a37779c18
Merged-In: I47b132c8b5c977812fad5c89fa57882a37779c18
When ECHO_REFERENCE audio source was added, it was omitted
from the list of virtual audio sources (sources protected by privileged
permission not accessing the mic). This prevents from capturing echo
reference at the same time as the input from mic.
Bug: 154639757
Test: test app on yukawa
Change-Id: Ib12e8c817dec7c3f4d3f3f7e7403330c88cead52
Fix crash in getOutputForAttrInt() if the output corresponding to
the mix returned by AudioPolicyMix is not opened and the device
selected by the mix is not attached.
Before commit c529cf6f, a policy mix without opened output would not
be retuned by AudioPolicyMix.getOutputForAttr(). With direct
output suppoort, this is possible but should be ignored if the device
selected by the policy mix is not attached.
Bug: 155430290
Test: AudioHostTest
Test: AudioServiceHostTest
Test: audiopolicy_tests
Test: manual mirroring and car projection tests
Change-Id: I66be4a3c5fb8b9ae0674c0f1e6e39de7f18ed2fb
Fix areAllDevicesSupported() where HwModules.getDeviceDescriptor()
must be called with matchAddress == true: if the caller does not want to
distinguish on address it can leave the address field empty in the
AudioDeviceTypeAddr passed which has the same effect as using
matchAddress == false.
Also fix places where device_distinguishes_on_address() was improperly
used in place of audio_is_remote_submix_device().
Bug: 155224229
Test: build and launch car emulator
Test: AudioHostTest
Test: AudioServiceHostTest
Test: audiopolicy_tests
Test: manual mirroring and car projection tests
Change-Id: I74295de95bcd82e7fa439c396ae32749b9c70c05
Add support for direct outputs with RENDER audio policy mixes.
A mix of type render can be registered even if no corresponding
output is opened to reach targeted device provided a direct output
profile exist for this device.
Also:
- Fix setUidDeviceAffinities(): was not closing direct outputs
opened by checkOutputsForDevice() and was not re-evaluating routes
- Fix removeUidDeviceAffinities(): was not re-evaluating routes
- Implement consistent sanity checks on selected devices in
setUidDeviceAffinities(), setUserIdDeviceAffinities() and
setPreferredDeviceForStrategy().
- Fix onNewAudioModulesAvailableInt(): attached devices reachable only
via direct outputs were not loaded.
Bug: 130296239
Test: AudioHostTest
Test: AudioServiceHostTest
Test: audiopolicy_tests
Test: manual test: Auto projection over USB, screen mirroring
Change-Id: I54470b61b4bc7e041e3a295764d368c5ded21268
Do not allow changing volume on an output when
the specified device is not supported by the
corresponding output profile.
There is a similar sanity check in setOutputDevices()
but there was none in AudioOutputDescriptor::setvolume().
Bug: 153411189
Test: atest AudioManagerTest
Test: manual audio smoke tests
Change-Id: I539697c54d70c442ba1ce38d212b43cd3ef0138c
The list of possible paths for the audio configuration
files is now retrieved using audio_get_configuration_paths()
function. All duplicated lists of known configuration
directories have been removed.
Bug: 153680356
Test: test audio on built image working
atest VtsHalAudioV6_0TargetTest VtsHalAudioPolicyV6_0TargetTest
Change-Id: I8c369442f5ca7baa17df95e6a001396fc9de5681
Merged-In: I8c369442f5ca7baa17df95e6a001396fc9de5681
Duplicating outputs do not have an associated IOProfile and
getPolicyAudioPort() returns null.
Add a method to AudioIODescriptorInterface to query if the
input or output descriptor corresponds to MMAP IO profile or not.
Bug: 153849965
Test: repro steps in the bug
Change-Id: I300356880198f1785e3a5e1359ffd393c6ae4190
Scenario: startAudioSource (SW bridge) started, then stopped.
AF patch is released, so PlaybackThread has empty patch.
Next playback using the same sink will not recreate any patch
on AF as same device (and output desc has still valid patch handle)
Hence, ioconfichanged will get PORT NONE as sink device, no
onAudioDeviceUpdate cb can be fired.
This CL fixes this issue by reset of patch handle on the output
Bug: 136121584
Test: startAudioSource / stopAudioSource then playback on the same
sink. Ensure onAudioDeviceUpdate is fired
Test: atest RoutingTest
Signed-off-by: Francois Gaffie <francois.gaffie@renault.com>
Change-Id: Ia9c2570f687166f38335ed7efae28920f7acc474
Binder doesn't hold on to the death recipient.
This caused audio server to miss notifications about system server
death.
Fixes: 153080001
Test: Manual verification of killing the system process.
Change-Id: Iad1b2d4c5348d3d9917efc6838e86b736fa33094
Previously, audio policy client would call an method on the sound
trigger middleware service. This has been replaced by the sound
trigger service registering a callback, in order to avoid a cyclic
dependency between the services.
Bug: 146157104
Merged-In: I876461a7650d337d6dd05fbe80efaf08f8ef20dd
Change-Id: Ia8f674d7dd50f6dcdd6595bcbadec2f25fdb3561
This is a helper class for notifying a client of capture
state changes.
Bug: 146157104
Test: Compiles (further testing as part of the topic).
Merged-In: Ie27bc404805d319a6969290a6369d59fb68c1f38
Change-Id: I2902468c4692ba68e4bc9be0e5038d5505da7154
The UID of the current InputMethodService (DEFAULT_INPUT_METHOD) is
pushed from AudioService to AudioPolicyService via AudioSystem.
Allow capture audio if:
- the UID is the current InputMethodService's UID,
- AND a RTT call is active,
- AND the source is AUDIO_SOURCE_VOICE_RECOGNITION.
Bug: 147037345
Test: use voice input with Gboard 9.1.4 during a simulated RTT call.
Change-Id: Ib32ec25e962833eddd0320742e177e3c1e0e5c05
Added missing notification to the APM client
about new audio ports. This should make the
ports provided by the newly discovered HAL
to be available to apps.
Process the onNewAudioModulesAvailable notification
on the "APM Output" command thread to avoid clashing
with outgoing commands from APM during module
initialization.
Bug: 149854039
Test: atest audiopolicy_tests
Change-Id: I3fede7f5a04419b15e15476d8b5ac7dc6d63c98d
Stream for which no attributes is associated (aka no strategy supports it)
will use default attributes hence it will change the default strategy
volume (aka Music).
It leads to eroneous volume changes.
This bug does not happen on phone / tablets targets as all streams are
linked to a strategy with specifc attributes.
In case of OEM configuration, some stream types may not be supported
and associated to any strategy.
Bug: 136121584
Test: dumpsys audio & dumpsus media.audio_policy.
Ensure volumes of stream types and their aliases match.
Signed-off-by: Francois Gaffie <francois.gaffie@renault.com>
Change-Id: I5e12b2c7248074d10affb6c28d1866d4589cb9e8
Merged-In: I5e12b2c7248074d10affb6c28d1866d4589cb9e8
If a strategy matches a attributes, whatever a stream type has
been provided, the MUSIC stream type shall be returned as a fallback
to ensure AudioFlinger will apply the right gain to the right stream
(which always fallback as music if none is provided)
Bug: 136121584
Test: build & run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioProductStrategyTest
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioVolumeGroupTest
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioVolumeGroupChangeHandlerTest
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioManagerTest#testPermissionsForVolumePerAttributes
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioManagerTest#testGetAndValidateProductStrategies
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioManagerTest#testGetAndValidateVolumeGroups
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioManagerTest#testSetGetVolumePerAttributesWithInvalidAttributes
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioManagerTest#testSetGetVolumePerAttributes
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioManagerTest#testVolumeGroupCallback
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
Change-Id: Ic79effb1341b788d90f5d73d23ae92b983f17225
Merged-In: Ic79effb1341b788d90f5d73d23ae92b983f17225
When start/resume activity, WindowManagerService start/resume the
activity, then post a runnable to DiaplayThread and
ActivityManagerService to update UidRecord's
proc state, because the thread switch, the latency before proc
state update is undetermined.
When CameraService calls ActivityManagerService.isUidActive(), the proc
state may not have been updated and camera access is denied.
isUidActiveOrForeground() will check isUidActive() first, if false,
check isUidForeground() which is actually to check with WindowManagerService if
the uid is foreground, which is equivalent to ActivityManagerService's uid
active, just updated earlier.
Bug: 151185692, 151777097, 109950150
Test: manual test.
Change-Id: I3685e0c8d2e69ca7ff3c4de4bef4ec754c400015
Implement a MMAP stream invalidation logic consistent with AAudio
disconnect callback policy.
- When a MMAP stream is opened with a preferred device selection:
Invalidate the stream only when the preferred device becomes unavailable,
either because disconnected or not selectable by highest priority use case.
- When a MMAP stream is opened without explicit device selection:
Invalidate the stream when current device selection changes due to the
routing rules applicable to the stream's audio attributes (attributes
of first client on that stream).
Bug: 144020984
Test: OboeTester > TEST DISCONNECT
Change-Id: I70fde0bc8ab9d544b8d3badb713e6239d792cbdb
Disordered sequence will occur when delayMs of muting volume
and changing path are the same and no additional delay between
both commands (muteWaitMs == 0).
Add half reported latency to delayMs for routing could avoid
processing muting stream volume and switching path concurrently.
Bug: 149798335
Test: Make VoIP/voice call and switch device between handset/handsfree.
Check if touch tone is truncated in QXDM.
Signed-off-by: Jasmine Cha <chajasmine@google.com>
Change-Id: Ifa15ba9de330805637cfb20ee96c4293c1c1bd31
Replace global static instances of non-primitive
types with function static instances. The latter
get initialized on the first call to the function
instead of module load time.
This also gets rid of ASAN UAF errors reported
during unit test execution.
Bug: 150649241
Test: atest audiopolicy_tests
Test: atest audio_health_tests
(for ASAN-instrumented libraries and test)
Change-Id: I514c9205b9d3e7a3f0a1d8aa71d71fcc792e7a7b
* changes:
Plumb the notification about audio HAL services update to APM
libaudiohal: Allow late registration of HIDL HAL services
Allow for late audio module discovery in APM
AudioFlinger registers a callback with libaudiohal to receive
notifications when new HAL services get registered. It relays
the notification to AudioPolicyManager via AudioSystem /
IAudioPolicyService interface.
Because AF / APM only interact via Binder interfaces and APM's
interface gets registered later than AF's, the notification
from AF is made asynchronous.
Bug: 149854039
Test: audio test on a regular phone configuration
audio test on a phone with MSD audio HAL module
Change-Id: I158e941b8f75e2a4614b9d84ca798b0f1f47aa6a
Extract code that loads hardware modules and fills out
mAvailable{Input|Output}Devices into a reusable function.
It is used both during APM initialization and on
receiving a notification that a new HAL service has
been discovered.
Bug: 149854039
Test: atest audiopolicy_tests
Change-Id: Ifb7f0b61b06a0609802e63dccb26f3472328ef48
Fix two concurrent capture scenarii when VoIP call is active:
1) when the audio mode is IN_COMMUNICATION, only allow capture
from the app owning the audio mode.
2) fix capture by a privileged app when a privacy sensitive capture is
active: capture was silecend if the privacy sensitive capture was
started after the privileged capture.
Bug: 148368476
Test: Manual test of various VoIP apps and phone calls scenarii
Test: cts AudioRecordTest
Change-Id: I166f91c43ce86bb23c2f171700ece634091caaad
AudioSystem.setAllowedPolicyCapture is only called from audio service.
In that case, checking if the calling uid is system uid to before taking
action.
Bug: 145115448
Test: dumpsys audio, query active playback configuration
Change-Id: I614ac881ecde6bad13f22f1382de701f314a7ada
Merged-In: I614ac881ecde6bad13f22f1382de701f314a7ada
(cherry picked from commit 140a34fbfe)
The access to call audio (record and play) will be granted only to the app associated with Dialer role, who also includes a new system permission.
Test: Compilation and manual tests
Bug: 135197853
Change-Id: I65ca823c235d4d3420630837427103783ad1d1b0
The logic in IOProfile::devicesSupportEncodedFormats()
was only checking if the first device in the list of supported devices
was supporting currently selected A2DP encoding format.
But if more than one devices match the queried types, we need to check
all devices in case one of them supports the selected encoding format.
Bug: 147789166
Test: repro steps in the bug.
Change-Id: I704c5c6278eed524f15e7b73cec68a24f04d3a8c
This change fixes the CTS failure in AudioPlaybackCaptureTest caused
by ag/10111312 and ag/10111311.
It contains the following fixes/changes:
- Mix match for playback capture of USAGE_VOICE_COMMUNICATION now
also respects a new flag (AudioMix's mVoiceCommunicationCaptureAllowed)
which is set by AudioService only if the caller explicitly asked
to capture USAGE_VOICE_COMMUNICATION and have the
CAPTURE_VOICE_COMMUNICATION_OUTPUT.
- A permission check on the native side in case
mVoiceCommunicationCaptureAllowed is set.
- Code cleanup, mainly in AudioPolicy.h and AudioPolicy.cpp.
This change is accompanied by ag/10242955 on the Java side.
Bug: 148559127
Test: manual
Test: atest PlaybackCaptureTest (with the version prior to ag/10220852)
Test: atest com.google.android.gts.audio.AudioHostTest
Change-Id: I8ae6249f4da1de35e962c838d91f690eb906570e
In case of using Device Port Gain to control the volume, the logic
of setVolumeIndexForAttributes for device type check has been bypassed.
However, in case of unmuting, the volume will be applied to all streams
with requested device then will be set for AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME
which is a convention used in case of no volume for device has been set
previously.
As this logic is bypassed, in case of HwGain, the final gain applied will
be the one for AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME, which may be completely
different from the gain of current device.
This CL fixes this by factorizing the device check logic for both SW/HW gains.
Test: build & play music & Vol - until mute then volume +. No gap expected.
Change-Id: I24c57df84496e404c05c92f08f907131ef79cf3a
Signed-off-by: François Gaffie <francois.gaffie@renault.com>