audiopolicy: return appropriate profile from searchCompatibleProfileHwModules

The current logic for getting IoProfile prefers to select a profile with
AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD when "directOnly" profiles are
fetched.

However, if configurations support a mixport with exactly
"AUDIO_OUTPUT_FLAG_DIRECT", and a "directOnly" profile is fetched with
"AUDIO_OUTPUT_FLAG_DIRECT", the current logic still ends up providing a
AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD profile. This is because the
compress_offload profile is defined as
(AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD | AUDIO_OUTPUT_FLAG_DIRECT).

Modify the logic to check the requested flags. If a profile with
AUDIO_OUTPUT_FLAG_DIRECT is requested and APM has a
AUDIO_OUTPUT_FLAG_DIRECT profile, return the appropriate profile.

Bug: 393531112

Test: run audiopolicy_tests, audiorouting_tests, trackplayerbase_tests ,
audiosystem_tests

Test: CtsMediaAudioTestCases, CtsNativeMediaAAudioTestCases

Change-Id: Ieabe99c5b0fba329195a072583115f6ce5f9c41f
2 files changed