Commit graph

122 commits

Author SHA1 Message Date
Kevin Rocard
5e5783daef Audio HAL VTS: debugDump can only test for crash
DebugDump does not return an error code, thus the implementation can not
return not implemented.

As a result, the test can not expect any output from the function.
Only test that the call does not crash and add a log if the function is
probably not implemented in the test.

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: I2c18958bceb1eb638491f9afce9d8e8025ccd3ec
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-05-08 14:43:02 -07:00
Kevin Rocard
195205b323 Audio HAL VTS: Sanitize prepareFor{Writing,Reading} input size
Return an error if framesCount or frameSize are null to avoid a division
by zero when calculating the buffer size.

The message queues are allocated with a buffer size but if two big they will
assert not return an error.
Thus take some margin on the buffer size check.

Note that both function should be refactored as 99% identical.

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: I0576e9016ef2e567c8d4e171c6237883d9865db9
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-05-08 14:43:02 -07:00
Kevin Rocard
c07df49e45 Audio HAL VTS: refactor prepareFor{Reading,Writing}
Those functions had lots of copy paste on errors and
the following patch will even add more error detections.
Refactor the hidl_cb call to avoid all duplication.
Note that both function should be refactored as 99% identical.

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: I40d6926b4f9f5e3aba51e878f55fb013f4ca09c1
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-05-08 14:43:02 -07:00
Kevin Rocard
04364edefc Audio HAL VTS: Sanitize setMode input
Some values of AudioMode are exposed although implementation detail.
Make sure the client can not use them.

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: If513c2a06efa8a92459f0af80c63232fc63302b0
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-05-08 14:42:39 -07:00
Kevin Rocard
f8500dcb5a Audio HAL VTS: Allow OK when setting a non existing parameter
setHwAvSync and setParameters were implemented in the pre-hidl interface
as set_parameters.
Unfortunately set_parameters did not return an error if a key was not
implemented.

As most HIDL implementation will be a wrapper around the pre-hidl
interface, allow those functions to return OK on not implemented key.

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: Icfcaa02b7d63e03375fddc90dc5a803754c1874f
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-05-08 14:42:39 -07:00
Kevin Rocard
fa3b4a9334 Audio HAL VTS: differentiate getParam success/failure/not_implemented
When sending parameters to the HAL (and some getters are implemented
with getParameters), the client expect a status consistent
with the other HIDL methods. Ie: not implemented or success and failure.

Unfortunately, the legacy get_parameter interface, which currently most
Audio HIDL implementation are a wrapper around, do not return such error
code.

Get parameters return a list of key values.
 - If a requested key does not return a key value pair, consider it not
   implemented
 - If a requested key returns a key not followed by a correct value,
   consider it a failure
 - otherwise it is a success

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: Id6711e9c1974fe5a336b6de83a9b6d14f74437c9
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-05-08 12:42:14 -07:00
Kevin Rocard
72e50e2ef1 Audio HAL VTS: Fix style on modified files
In order to avoid style inconsistency as well as non functional
modification in following patches,
fix the style of all files modified for the fix of the VTS tests.

Patch generated with:
$ clang-format -i --style file -- <file list>

Bug: 36311550
Test: compile
Change-Id: I53dbcdabf959a6100e34a2ee4d0f951d525049cb
2017-05-08 12:41:57 -07:00
Mikhail Naganov
6c0f76a684 audiohal: Add diagnostics to investigate HAL call crashes
This is intended to clarify whether surprising zeroing out of HAL
control structures happens to a particular HAL module, or to any
HAL module at random.

Unfortunately, the crash itself can't be prevented as
audioflinger can't work around a HAL outage, and needs to be
restarted anyway.

Bug: 36225019
Test: verified that the logged string contains the information
Change-Id: I5843d89b4e5385b4ce269f72b5891ccb646daeba
2017-05-04 14:34:37 -07:00
Mikhail Naganov
8604a738a7 audiohal: Fix incorrect parameter handling in IDevicesFactory::openDevice
Check for possibly invalid values of IDevicesFactory::Device enum.

Bug: 37592306
Change-Id: I4a2300d3be9ab38e6c51ba8a3b5bbbb606a11c2b
Test: VTS
(cherry picked from commit 8c16d85122)
2017-05-04 18:30:31 +00:00
Mikhail Naganov
86685f56da Revert "audiohal: Get rid of multiple inheritance in IDevice implementation"
This reverts commit e4228e7aa6.

Further analysis of the bug has shown that the problem is not related
to the use of multiple inheritance.

Bug: 36225019
Change-Id: Icdcaf84061c0ecf29f891521bd961c3ee89f1cfc
2017-05-03 16:40:27 +00:00
Mikhail Naganov
e4228e7aa6 audiohal: Get rid of multiple inheritance in IDevice implementation
We still not sure what causes crashes in Device::get|setParam*,
but it seems that it is somehow caused by the fact that the parameters
code is in a separate class with virtual methods, from which
Device class inherits along with IDevice interface.

The workaround is to substitute multiple inheritance with
delegation in Device class. Hopefully this will either eliminate
crashes or make the underlying reasons more clear.

Some of the code got reformatted by clang-format as a presubmit
requirement.

Bug: 36225019
Test: make
Change-Id: Id785c3565bbebd5acc26ca46472961698d9c6208
2017-04-29 00:48:57 +00:00
Mikhail Naganov
3e6fe754f6 audiohal: Fix handling of invalid arguments in 'debugDump' methods
Add checks for validity of the passed in native handle.

Bug: 37590777
Change-Id: If906f0086c3442819e1844cc521215d5b74af015
Test: VTS
(cherry picked from commit 7bae6a0b63)
2017-04-25 20:21:37 +00:00
Derek Chen
ab24ecd952 audio hal: initialize audio patch handle
Initialize audio patch handle to avoid
uninitialized value causing validation
failure in vendor hal audio patch.

Bug: 36994757
Test: Initiate voice call, no audio heard from other end

Change-Id: I4cf57210432430af89109f605813645ff332bfbb
2017-04-20 23:48:52 +00:00
Kevin Rocard
34b44cd7db Audio primary hal: fix member function used before init
prepare for write was refactor by Ib4170eb6a9f88f9352d0912083b43d600771bb8e
to use temporary variable in a rai pattern.
Nevertheless the member variable was still used too early in
prepareForRead resulting in a crash for capture.

Test: assistant, camcorder
Bug: 37492059

Change-Id: I08140834959c440798cd40700dd089adca2f3e40
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-04-19 09:38:42 -07:00
TreeHugger Robot
d7e88525a7 Merge changes from topic 'vts-audio-fix' into oc-dev
* changes:
  Audio HAL: Destroy EventFlag on failed prepareTo{write,read}
  Audio HAL: Check for buffer size overflow
  Audio HAL: Detect buffer memory allocation failure
  Audio HAL: Detect openDevice failure
  Audio HAL VTS: Fix documentation
2017-04-19 00:44:34 +00:00
Steven Moreland
a8a9cc6606 audio hal: explicitly import headers
Test: works with BOARD_VNDK_VERSION := current
Bug: 33241851
Change-Id: I34983a5527a16e8e9f5a6a87edac0b741aeb67d6
2017-04-17 15:56:52 -07:00
Mikhail Naganov
3acaa668c1 soundtrigger: Use "default" instance name for HAL service
"default" implies using "primary" legacy device module.
This doesn't change anything for binderized mode, because
the server was only registering itself as "sound_trigger.primary",
so it was the only possibility anyways.

Usage of "stub" (debugging) module is still possible
if audioflinger and corresponding services are built with
USE_LEGACY_LOCAL_AUDIO_HAL=true (added makefile check to ensure
that).

Test: "Ok Google" from screen off state on sailfish
Bug: 36570720
Change-Id: I88f1ebd4c1efd0f91e37458746c336a4beef33ae
2017-04-14 15:52:11 +00:00
Andreas Huber
6fa374ad30 Changed the naming scheme for Treble java libraries (both static and dynamic)
android.hardware.foo@1.0-java => android.hardware.foo-V1.0-java

Bug: 37207894
Test: make
Change-Id: I177f4cfd42f635aaf096107af8309d1a82ed41c0
Merged-In: I8b91881dfaf507c0d852d56ebbb53ff0987e5a34
2017-04-13 15:23:46 -07:00
Steven Moreland
3b36a83a2e Update makefiles (2/2).
Test: pass
Change-Id: Ic7e6289c7b69785491708ce0acbb657f4c704229
2017-04-11 09:58:03 -07:00
Kevin Rocard
40343061d5 Audio HAL: Destroy EventFlag on failed prepareTo{write,read}
If prepareToWrite or prepareToRead fails after EventFlag is created, it
is not destroyed. This lead to strange random crashes (double free it seems).

Use the RAII pattern to manage the EventFlag life cycle.

Test: Run test on target
Bug: 36311550

Change-Id: I53a04a62b7d12fdcc94afd8ced3e547aa6edff50
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-04-07 14:35:47 -07:00
Kevin Rocard
b6498cbdf6 Audio HAL: Check for buffer size overflow
The audio buffer size is not provided by the client, it is computed from
the sample size and the number of sample.

No check was done as if the multiplication of these two numbers would
produce an overflow. This leaded to erroneous memory access crashing the
media server.

Test: Run on target
Bug: 36311550

Change-Id: I3436800ab6ac1b5e6a6aa4d03d6b96910eb54652
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-04-07 13:10:01 -07:00
Kevin Rocard
67d550888a Audio HAL: Detect buffer memory allocation failure
If the requested buffer was too big, memory allocation would fail,
resulting if a audio hal crash (uncatch exception thrown by new).

Properly hadle the failure by retuning INVALID_PARAMETERS in such case.

Bug: 36311550
Test: Run test on target

Change-Id: Ib4170eb6a9f88f9352d0912083b43d600771bb8e
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-04-07 13:10:01 -07:00
Kevin Rocard
fba442a60d Audio HAL: Detect openDevice failure
The result status was not checked.

Test: Run test on target
Bug: 36311550

Change-Id: I197b52d0b5a1276d3e3beba105bb91639f89e060
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-04-07 13:10:01 -07:00
Kevin Rocard
6f22680db6 Audio HAL VTS: Fix documentation
Some test did not have any documentation

Test: compile & run
Bug: 36311550

Change-Id: I37c40f6f17993a275e5c40b9a835ac04acf4f8e6
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-04-07 13:10:01 -07:00
Mikhail Naganov
936279e1ff audiohal: Fix UAF of HAL devices in Stream objects
Stream objects used to hold a pointer to underlying HAL device
object which they didn't own. Since destruction of server side
objects is asynchronous, it was possible that a Device object
gets destroyed before Stream objects, making all the HAL device
object pointer to become stale.

Fixed by adding a strong reference to Device objects into Stream
objects.

Bug: 36702804
Change-Id: I3da3611afbb91d6fd6410ac5b8af2a2eebfa6dac
Test: ran Loopback app and HAL VTS tests
(cherry picked from commit 96d3573cda)
2017-03-30 15:52:30 +00:00
Andreas Huber
40d3a9bd8c Convert all comments into "doxygen-ready" comments.
Bug: 36453077
Test: mma
Change-Id: I0b1f77dfae5d2258969e33d85ecf45401ffbdfaa
2017-03-29 08:53:58 -07:00
Steven Moreland
561b602a99 Update makefiles for hwtypes.h
Test: pass
Change-Id: I8e17eb8fec5d2f04c526476a866c8dd54ccb556c
2017-03-28 15:18:20 +00:00
TreeHugger Robot
d4762a75b4 Merge "audiohal: Remove stale TODOs" 2017-03-23 00:57:16 +00:00
Mikhail Naganov
b0dd076c60 audiohal: Remove stale TODOs
Bug: 34109709
Change-Id: I9b30ffa2ed06be8cf31cdbfbcc0f4cb0dac7be54
Test: make
2017-03-22 10:36:14 -07:00
Kevin Rocard
e9a8fb7371 Audio HAL VTS: test leftover calls
Test: run on target

Bug: 34170075
Change-Id: I9529d3b8db7388332dde3ea7d5940d58e010e449
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-21 12:01:12 -07:00
Kevin Rocard
624800c073 Audio HAL VTS: Add test for IStreamOut
Some test are only negative.

Test: run test on board

Bug: 34170075
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-16 16:00:08 -07:00
Kevin Rocard
24db65c0ec Audio HAL VTS: Avoid copying Return in helper
Return are movable only, thus the fact that assertResult took a copy of
the value meant that the callee had to provide an rvalue.

This was not needed as the Result was not modified. Change it to a const
reference.

Test: run test on board

Bug: 34170075
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-16 16:00:02 -07:00
Kevin Rocard
c9963526d9 Audio HAL VTS: Add tests for IStreamIn
For now most tests are negative.

Test: run test on board

Bug: 34170075
Change-Id: Id207ae310e0fa5a3ab4db49122249594cd2c2703
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-14 09:49:15 -07:00
Kevin Rocard
8878b4ba1f Audio HAL VTS: Add at least negative tests for IStream
Add negative test for the remaining methods of IStream
and positive one for most.

Test: run test on board

Bug: 34170075
Change-Id: Ib18c6d2e4d0a14ee4517f31319ddecf5e23ac8de
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-14 09:49:15 -07:00
Kevin Rocard
b903124b36 Audio HAL VTS: Test IStream::debugDump
Test: run it on target
Bug: 34170075
Change-Id: I4af190806f79e0c03b59e1cd60b6f58a08b05322
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-14 09:49:15 -07:00
Kevin Rocard
a7df7fc097 Audio HAL VTS: Split big test for better traceability
As some part of this big test were failing, it was difficult to actually
track on the dashboard what was wrong.

Split it in small independent equivalent tests.

Test: mm & run on target

Bug: 34170075
Change-Id: I03686e55ec112f0f0c0ef2683c5dc1ae79ff8d5e
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-14 09:49:15 -07:00
Kevin Rocard
de8cbffd47 Audio hal VTS: pretty print AudioDevice and ChannelMask
This eases the debuging of failing tests.
Also print hex value of the enums as well of their literal values.

Test: run the test on target
Bug: 34170075
Change-Id: Iea1d7d2269e0e5b413240aaa905daae755846e74
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-14 09:49:15 -07:00
Kevin Rocard
20e7af6159 Audio Hal VTS: Refactor ASSERT_RESULT helper
ASSERT_INVALID_ARGUMENTS was a macro that asserted that a given Result
or Return contained INVALID_ARGUMENT. The problem was that a result can
have lots of other values like INVALID_STATE or NOT_SUPPORTED.
Additionally not all test expect only one possible result.

Introduce two overload of ASSERT_RESULT()
The first one takes an expected Result value and compare it to the
obtained one.
The second take a list and expect the obtained one to be in this list.

Test: run the test on target
Bug: 34170075
Change-Id: I798729f27f723c98292610bfb43dbdb2724ec2ca
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-14 09:49:15 -07:00
Kevin Rocard
9c36914983 Audio hal VTS: generate names for parametrized tests
The gtest dashboard only shows test names, not their parameters.
This mean that parametrized tests are names 0,1,2...
Thus when one test fails, the dashboard info is not very useful.

This patch appends the audio config to the test name.

Test: run the test on target
Bug: 34170075
Change-Id: I77090a3a17e4a3e97ecb72a8a89ad2d88626d96f
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-13 09:18:22 -07:00
Kevin Rocard
92ce35df94 Audio hal VTS: factorize master volume test
Master volume was the first pair of getter/setter tested
and did not use the generic test*Accessor function.

Test: run the corresponding vts test
Test: vts-tradefed r vts-hal-hidl -m VtsHalAudioV2_0Target

Bug: 34170075
Change-Id: I77080a3a17e4a3e97ecb72a8a89ad2d88626d96f
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-13 09:18:19 -07:00
Kevin Rocard
ee771e9cfa Fix potentiel deadlock in audio VTS
The IDevice::debugDump method dumps debug info in a file descriptor.
Such file descriptor was previously the writing end of a pipe.

As the test is not multithreaded, if the dump was bigger than the pipe
buffer, a deadlock would occur.

With this patch, the test uses a file instead of a pipe. Thus write
will never block infinitely.

Test: run the corresponding vts test
Test: vts-tradefed r vts-hal-hidl -m VtsHalAudioV2_0Target

Bug: 34170075
Change-Id: I928cae712a1cb4411f907b3a9583014ba6486abc
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-13 09:18:16 -07:00
Yuexi Ma
161b564b35 audio: use vts target test base class
Test: make vts succeed
Change-Id: I8008392e016e0604f8aa9a292f1ec6c6e7c3b384
2017-03-10 21:53:53 +00:00
Kevin Rocard
3c405a7acf Add VTS for the audio primary device
Its base class was tested but not the primary
device getters and setters.

Test: run the corresponding vts test
Test: vts-tradefed r vts-hal-hidl -m VtsHalAudioV2_0Target

Bug: 34170075
Change-Id: Ic451761c7b8b29fd302a62aba83be6ce7be35f64
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-09 18:23:42 -08:00
Kevin Rocard
fd067c3f54 Fix segfault in Primary audio hal hidl wrapper getDevice
Test: run the corresponding vts test
Test: vts-tradefed r vts-hal-hidl -m VtsHalAudioV2_0Target

Bug: 34170075
Change-Id: I0652f1bf748de99a8a2594630daf5ea2acec8934
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-09 18:23:41 -08:00
Kevin Rocard
d1e98aef14 Do not skip failing Audio vts tests
Previously failing tests were commented because I thought
our implementation had to pass all tests.

As a mater of facts, it is not the case and tests are allowed to fail.
Bugs will be raised for those failure.
This is much better way to track the fixes that FIXMEs.

Test: run the corresponding vts test
Test: vts-tradefed r vts-hal-hidl -m VtsHalAudioV2_0Target

Bug: 34170075
Change-Id: I928cae712a1cb4411f907b3a9583014ba6487abd
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-09 18:23:29 -08:00
Steven Moreland
48c52249e4 hidl_default to all targets.
find hardware/interfaces -type f -not -path "*/.git/*" \
-exec sed -i -e '/cc_[A-Za-z_]\+/ { N; s/$/\n    defaults:
\["hidl_defaults"\],/ }' {} \;
./hardware/interfaces/update-makefiles.sh

Test: pass
Bug: 35840847
Change-Id: If10c464d2f000b85c8d698fe11a4f3fc4cfad282
2017-03-08 19:31:53 -08:00
Eric Laurent
d0fbfd8e7e Merge "audio: fix IStream.createMmapBuffer()" 2017-03-08 16:42:33 +00:00
Keun Soo Yim
89dc24e624 Merge "Add VTS tests for the primary audio hal" 2017-03-07 17:29:41 +00:00
Eric Laurent
a6f40c84ae audio: fix IStream.createMmapBuffer()
Do not close the native fd for shared memory passed by
the legacy HAL as it is owned by tinyalsa implementation.

Test: test MMAP NO IRQ playback and capture streams
Bug: 31458351
Change-Id: Ie0c2a38574e5ac5c13fdb8a5c81fd02cf7d0e47a
2017-03-06 15:09:48 -08:00
Kevin Rocard
f0357884b5 Add VTS tests for the primary audio hal
Test: run the vts test on target
Test: vts-tradefed r vts-hal-hidl -m VtsHalAudioV2_0Target

Bug: 34170075
Change-Id: I4bd6cb0aa5b7cc628537cd7c024542c4db8b592d
Signed-off-by: Kevin Rocard <krocard@google.com>
2017-03-03 14:33:40 -08:00