summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot2018-03-21 02:22:02 -0500
committerandroid-build-team Robot2018-03-21 02:22:02 -0500
commit3b9817ff5734d37712c738ef37d4e8ed1976b4a4 (patch)
treeec336dd8323aef69f791a752b7f4388ec5c588a3
parent3ba9e93b88b869f42c047e217597bab04ab7ab1f (diff)
parent14dc815cdc5a2416bf0aacca3a577289e0ac2bbf (diff)
downloadplatform-hardware-interfaces-3b9817ff5734d37712c738ef37d4e8ed1976b4a4.tar.gz
platform-hardware-interfaces-3b9817ff5734d37712c738ef37d4e8ed1976b4a4.tar.xz
platform-hardware-interfaces-3b9817ff5734d37712c738ef37d4e8ed1976b4a4.zip
Snap for 4667902 from 14dc815cdc5a2416bf0aacca3a577289e0ac2bbf to pi-release
Change-Id: I070c8b4c8749316eb2874d3832ff8bdc3e517e9c
-rw-r--r--audio/common/4.0/types.hal20
-rw-r--r--audio/common/all-versions/test/utility/include/utility/ReturnIn.h4
-rw-r--r--audio/common/all-versions/util/include/common/all-versions/VersionUtils.h6
-rw-r--r--audio/core/4.0/vts/OWNERS5
-rw-r--r--audio/core/4.0/vts/functional/Android.bp36
-rw-r--r--audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp1324
-rw-r--r--audio/core/4.0/vts/functional/ValidateAudioConfiguration.cpp30
-rw-r--r--audio/effect/4.0/vts/OWNERS5
-rw-r--r--audio/effect/4.0/vts/functional/Android.bp39
-rw-r--r--audio/effect/4.0/vts/functional/ValidateAudioEffectsConfiguration.cpp32
-rw-r--r--audio/effect/4.0/vts/functional/VtsHalAudioEffectV4_0TargetTest.cpp852
-rw-r--r--automotive/vehicle/2.0/Android.bp1
-rw-r--r--camera/device/3.4/Android.bp1
-rw-r--r--camera/metadata/3.3/types.hal11
-rw-r--r--compatibility_matrices/compatibility_matrix.current.xml1
-rw-r--r--current.txt4
-rw-r--r--drm/1.1/Android.bp2
-rw-r--r--graphics/mapper/2.1/Android.bp1
-rw-r--r--neuralnetworks/1.1/Android.bp1
19 files changed, 2363 insertions, 12 deletions
diff --git a/audio/common/4.0/types.hal b/audio/common/4.0/types.hal
index dfc350ec..e55491d8 100644
--- a/audio/common/4.0/types.hal
+++ b/audio/common/4.0/types.hal
@@ -373,21 +373,21 @@ enum AudioChannelMask : uint32_t {
373 OUT_TOP_BACK_LEFT = 0x8000, 373 OUT_TOP_BACK_LEFT = 0x8000,
374 OUT_TOP_BACK_CENTER = 0x10000, 374 OUT_TOP_BACK_CENTER = 0x10000,
375 OUT_TOP_BACK_RIGHT = 0x20000, 375 OUT_TOP_BACK_RIGHT = 0x20000,
376 OUT_TOP_CENTER_LEFT = 0x40000, 376 OUT_TOP_SIDE_LEFT = 0x40000,
377 OUT_TOP_CENTER_RIGHT = 0x80000, 377 OUT_TOP_SIDE_RIGHT = 0x80000,
378 378
379 OUT_MONO = OUT_FRONT_LEFT, 379 OUT_MONO = OUT_FRONT_LEFT,
380 OUT_STEREO = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT), 380 OUT_STEREO = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT),
381 OUT_2POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_LOW_FREQUENCY), 381 OUT_2POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_LOW_FREQUENCY),
382 OUT_2POINT0POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | 382 OUT_2POINT0POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
383 OUT_TOP_CENTER_LEFT | OUT_TOP_CENTER_RIGHT), 383 OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
384 OUT_2POINT1POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | 384 OUT_2POINT1POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
385 OUT_TOP_CENTER_LEFT | OUT_TOP_CENTER_RIGHT | 385 OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT |
386 OUT_LOW_FREQUENCY), 386 OUT_LOW_FREQUENCY),
387 OUT_3POINT0POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT | 387 OUT_3POINT0POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT |
388 OUT_TOP_CENTER_LEFT | OUT_TOP_CENTER_RIGHT), 388 OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
389 OUT_3POINT1POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT | 389 OUT_3POINT1POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT |
390 OUT_TOP_CENTER_LEFT | OUT_TOP_CENTER_RIGHT | 390 OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT |
391 OUT_LOW_FREQUENCY), 391 OUT_LOW_FREQUENCY),
392 OUT_QUAD = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | 392 OUT_QUAD = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
393 OUT_BACK_LEFT | OUT_BACK_RIGHT), 393 OUT_BACK_LEFT | OUT_BACK_RIGHT),
@@ -406,6 +406,10 @@ enum AudioChannelMask : uint32_t {
406 OUT_5POINT1_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | 406 OUT_5POINT1_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
407 OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | 407 OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
408 OUT_SIDE_LEFT | OUT_SIDE_RIGHT), 408 OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
409 OUT_5POINT1POINT2 = (OUT_5POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
410 OUT_5POINT1POINT4 = (OUT_5POINT1 |
411 OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT |
412 OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT),
409 OUT_6POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | 413 OUT_6POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
410 OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | 414 OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
411 OUT_BACK_LEFT | OUT_BACK_RIGHT | 415 OUT_BACK_LEFT | OUT_BACK_RIGHT |
@@ -415,6 +419,10 @@ enum AudioChannelMask : uint32_t {
415 OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | 419 OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
416 OUT_BACK_LEFT | OUT_BACK_RIGHT | 420 OUT_BACK_LEFT | OUT_BACK_RIGHT |
417 OUT_SIDE_LEFT | OUT_SIDE_RIGHT), 421 OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
422 OUT_7POINT1POINT2 = (OUT_7POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
423 OUT_7POINT1POINT4 = (OUT_7POINT1 |
424 OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT |
425 OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT),
418 // Note that the 2.0 OUT_ALL* have been moved to helper functions 426 // Note that the 2.0 OUT_ALL* have been moved to helper functions
419 427
420 /* These are bits only, not complete values */ 428 /* These are bits only, not complete values */
diff --git a/audio/common/all-versions/test/utility/include/utility/ReturnIn.h b/audio/common/all-versions/test/utility/include/utility/ReturnIn.h
index 2b92a216..7fd0d4a4 100644
--- a/audio/common/all-versions/test/utility/include/utility/ReturnIn.h
+++ b/audio/common/all-versions/test/utility/include/utility/ReturnIn.h
@@ -45,7 +45,7 @@ class ReturnIn {
45 template <class Head, class... Tail> 45 template <class Head, class... Tail>
46 void set(Head&& head, Tail&&... tail) { 46 void set(Head&& head, Tail&&... tail) {
47 std::get<sizeof...(ResultStore) - sizeof...(Tail) - 1>(results) = std::forward<Head>(head); 47 std::get<sizeof...(ResultStore) - sizeof...(Tail) - 1>(results) = std::forward<Head>(head);
48 set(tail...); 48 set(std::forward<Tail>(tail)...);
49 } 49 }
50 // Trivial case 50 // Trivial case
51 void set() {} 51 void set() {}
@@ -56,7 +56,7 @@ class ReturnIn {
56} // namespace detail 56} // namespace detail
57 57
58// Generate the HIDL synchronous callback with a copy policy 58// Generate the HIDL synchronous callback with a copy policy
59// Input: the variables (lvalue reference) where to save the return values 59// Input: the variables (lvalue references) where to copy the return values
60// Output: the callback to provide to a HIDL call with a synchronous callback 60// Output: the callback to provide to a HIDL call with a synchronous callback
61// The output parameters *will be copied* do not use this function if you have 61// The output parameters *will be copied* do not use this function if you have
62// a zero copy policy 62// a zero copy policy
diff --git a/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h b/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h
index a998b067..70c3d56a 100644
--- a/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h
+++ b/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h
@@ -52,6 +52,12 @@ auto mkEnumConverter(Source source) {
52 return EnumConverter<Source, Destination>{source}; 52 return EnumConverter<Source, Destination>{source};
53} 53}
54 54
55/** Allows converting an enum to its bitfield or itself. */
56template <class Enum>
57EnumConverter<Enum> mkBitfield(Enum value) {
58 return EnumConverter<Enum>{value};
59}
60
55} // namespace utils 61} // namespace utils
56} // namespace common 62} // namespace common
57} // namespace audio 63} // namespace audio
diff --git a/audio/core/4.0/vts/OWNERS b/audio/core/4.0/vts/OWNERS
new file mode 100644
index 00000000..8711a9ff
--- /dev/null
+++ b/audio/core/4.0/vts/OWNERS
@@ -0,0 +1,5 @@
1elaurent@google.com
2krocard@google.com
3mnaganov@google.com
4yim@google.com
5zhuoyao@google.com \ No newline at end of file
diff --git a/audio/core/4.0/vts/functional/Android.bp b/audio/core/4.0/vts/functional/Android.bp
new file mode 100644
index 00000000..dde3e7b0
--- /dev/null
+++ b/audio/core/4.0/vts/functional/Android.bp
@@ -0,0 +1,36 @@
1//
2// Copyright (C) 2017 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_test {
18 name: "VtsHalAudioV4_0TargetTest",
19 defaults: ["VtsHalTargetTestDefaults"],
20 srcs: [
21 "AudioPrimaryHidlHalTest.cpp",
22 "ValidateAudioConfiguration.cpp"
23 ],
24 static_libs: [
25 "android.hardware.audio.common.test.utility",
26 "android.hardware.audio@4.0",
27 "android.hardware.audio.common@4.0",
28 "libxml2",
29 ],
30 shared_libs: [
31 "libicuuc",
32 ],
33 header_libs: [
34 "android.hardware.audio.common.util@all-versions",
35 ],
36}
diff --git a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
new file mode 100644
index 00000000..a568a3ce
--- /dev/null
+++ b/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -0,0 +1,1324 @@
1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "VtsHalAudioV4_0TargetTest"
18
19#include <algorithm>
20#include <cmath>
21#include <cstddef>
22#include <cstdio>
23#include <initializer_list>
24#include <limits>
25#include <string>
26#include <vector>
27
28#include <fcntl.h>
29#include <unistd.h>
30
31#include <VtsHalHidlTargetTestBase.h>
32
33#include <android-base/logging.h>
34
35#include <android/hardware/audio/4.0/IDevice.h>
36#include <android/hardware/audio/4.0/IDevicesFactory.h>
37#include <android/hardware/audio/4.0/IPrimaryDevice.h>
38#include <android/hardware/audio/4.0/types.h>
39#include <android/hardware/audio/common/4.0/types.h>
40
41#include <common/all-versions/VersionUtils.h>
42
43#include "utility/AssertOk.h"
44#include "utility/Documentation.h"
45#include "utility/EnvironmentTearDown.h"
46#define AUDIO_HAL_VERSION V4_0
47#include "utility/PrettyPrintAudioTypes.h"
48#include "utility/ReturnIn.h"
49
50using std::initializer_list;
51using std::string;
52using std::to_string;
53using std::vector;
54
55using ::android::sp;
56using ::android::hardware::Return;
57using ::android::hardware::hidl_bitfield;
58using ::android::hardware::hidl_handle;
59using ::android::hardware::hidl_string;
60using ::android::hardware::hidl_vec;
61using ::android::hardware::MQDescriptorSync;
62using ::android::hardware::audio::V4_0::AudioDrain;
63using ::android::hardware::audio::V4_0::DeviceAddress;
64using ::android::hardware::audio::V4_0::IDevice;
65using ::android::hardware::audio::V4_0::IPrimaryDevice;
66using TtyMode = ::android::hardware::audio::V4_0::IPrimaryDevice::TtyMode;
67using ::android::hardware::audio::V4_0::IDevicesFactory;
68using ::android::hardware::audio::V4_0::IStream;
69using ::android::hardware::audio::V4_0::IStreamIn;
70using ::android::hardware::audio::V4_0::TimeSpec;
71using ReadParameters = ::android::hardware::audio::V4_0::IStreamIn::ReadParameters;
72using ReadStatus = ::android::hardware::audio::V4_0::IStreamIn::ReadStatus;
73using ::android::hardware::audio::V4_0::IStreamOut;
74using ::android::hardware::audio::V4_0::IStreamOutCallback;
75using ::android::hardware::audio::V4_0::MmapBufferInfo;
76using ::android::hardware::audio::V4_0::MmapPosition;
77using ::android::hardware::audio::V4_0::ParameterValue;
78using ::android::hardware::audio::V4_0::Result;
79using ::android::hardware::audio::V4_0::SourceMetadata;
80using ::android::hardware::audio::V4_0::SinkMetadata;
81using ::android::hardware::audio::common::V4_0::AudioChannelMask;
82using ::android::hardware::audio::common::V4_0::AudioConfig;
83using ::android::hardware::audio::common::V4_0::AudioDevice;
84using ::android::hardware::audio::common::V4_0::AudioFormat;
85using ::android::hardware::audio::common::V4_0::AudioHandleConsts;
86using ::android::hardware::audio::common::V4_0::AudioHwSync;
87using ::android::hardware::audio::common::V4_0::AudioInputFlag;
88using ::android::hardware::audio::common::V4_0::AudioIoHandle;
89using ::android::hardware::audio::common::V4_0::AudioMode;
90using ::android::hardware::audio::common::V4_0::AudioOffloadInfo;
91using ::android::hardware::audio::common::V4_0::AudioOutputFlag;
92using ::android::hardware::audio::common::V4_0::AudioSource;
93using ::android::hardware::audio::common::V4_0::ThreadInfo;
94using ::android::hardware::audio::common::utils::mkBitfield;
95
96using namespace ::android::hardware::audio::common::test::utility;
97
98class AudioHidlTestEnvironment : public ::Environment {
99 public:
100 virtual void registerTestServices() override { registerTestService<IDevicesFactory>(); }
101};
102
103// Instance to register global tearDown
104static AudioHidlTestEnvironment* environment;
105
106class HidlTest : public ::testing::VtsHalHidlTargetTestBase {
107 protected:
108 // Convenient member to store results
109 Result res;
110};
111
112//////////////////////////////////////////////////////////////////////////////
113////////////////////// getService audio_devices_factory //////////////////////
114//////////////////////////////////////////////////////////////////////////////
115
116// Test all audio devices
117class AudioHidlTest : public HidlTest {
118 public:
119 void SetUp() override {
120 ASSERT_NO_FATAL_FAILURE(HidlTest::SetUp()); // setup base
121
122 if (devicesFactory == nullptr) {
123 environment->registerTearDown([] { devicesFactory.clear(); });
124 devicesFactory = ::testing::VtsHalHidlTargetTestBase::getService<IDevicesFactory>(
125 environment->getServiceName<IDevicesFactory>("default"));
126 }
127 ASSERT_TRUE(devicesFactory != nullptr);
128 }
129
130 protected:
131 // Cache the devicesFactory retrieval to speed up each test by ~0.5s
132 static sp<IDevicesFactory> devicesFactory;
133};
134sp<IDevicesFactory> AudioHidlTest::devicesFactory;
135
136TEST_F(AudioHidlTest, GetAudioDevicesFactoryService) {
137 doc::test("test the getService (called in SetUp)");
138}
139
140TEST_F(AudioHidlTest, OpenDeviceInvalidParameter) {
141 doc::test("test passing an invalid parameter to openDevice");
142 Result result;
143 sp<IDevice> device;
144 ASSERT_OK(devicesFactory->openDevice("Non existing device", returnIn(result, device)));
145 ASSERT_EQ(Result::INVALID_ARGUMENTS, result);
146 ASSERT_TRUE(device == nullptr);
147}
148
149//////////////////////////////////////////////////////////////////////////////
150/////////////////////////////// openDevice primary ///////////////////////////
151//////////////////////////////////////////////////////////////////////////////
152
153// Test the primary device
154class AudioPrimaryHidlTest : public AudioHidlTest {
155 public:
156 /** Primary HAL test are NOT thread safe. */
157 void SetUp() override {
158 ASSERT_NO_FATAL_FAILURE(AudioHidlTest::SetUp()); // setup base
159
160 if (device == nullptr) {
161 Result result;
162 sp<IDevice> baseDevice;
163 ASSERT_OK(devicesFactory->openDevice("primary", returnIn(result, baseDevice)));
164 ASSERT_OK(result);
165 ASSERT_TRUE(baseDevice != nullptr);
166
167 environment->registerTearDown([] { device.clear(); });
168 device = IPrimaryDevice::castFrom(baseDevice);
169 ASSERT_TRUE(device != nullptr);
170 }
171 }
172
173 protected:
174 // Cache the device opening to speed up each test by ~0.5s
175 static sp<IPrimaryDevice> device;
176};
177sp<IPrimaryDevice> AudioPrimaryHidlTest::device;
178
179TEST_F(AudioPrimaryHidlTest, OpenPrimaryDevice) {
180 doc::test("Test the openDevice (called in SetUp)");
181}
182
183TEST_F(AudioPrimaryHidlTest, Init) {
184 doc::test("Test that the audio primary hal initialized correctly");
185 ASSERT_OK(device->initCheck());
186}
187
188//////////////////////////////////////////////////////////////////////////////
189///////////////////// {set,get}{Master,Mic}{Mute,Volume} /////////////////////
190//////////////////////////////////////////////////////////////////////////////
191
192template <class Property>
193class AccessorPrimaryHidlTest : public AudioPrimaryHidlTest {
194 protected:
195 /** Test a property getter and setter. */
196 template <class Getter, class Setter>
197 void testAccessors(const string& propertyName, const vector<Property>& valuesToTest,
198 Setter setter, Getter getter, const vector<Property>& invalidValues = {}) {
199 Property initialValue; // Save initial value to restore it at the end
200 // of the test
201 ASSERT_OK((device.get()->*getter)(returnIn(res, initialValue)));
202 ASSERT_OK(res);
203
204 for (Property setValue : valuesToTest) {
205 SCOPED_TRACE("Test " + propertyName + " getter and setter for " +
206 testing::PrintToString(setValue));
207 ASSERT_OK((device.get()->*setter)(setValue));
208 Property getValue;
209 // Make sure the getter returns the same value just set
210 ASSERT_OK((device.get()->*getter)(returnIn(res, getValue)));
211 ASSERT_OK(res);
212 EXPECT_EQ(setValue, getValue);
213 }
214
215 for (Property invalidValue : invalidValues) {
216 SCOPED_TRACE("Try to set " + propertyName + " with the invalid value " +
217 testing::PrintToString(invalidValue));
218 EXPECT_RESULT(Result::INVALID_ARGUMENTS, (device.get()->*setter)(invalidValue));
219 }
220
221 ASSERT_OK((device.get()->*setter)(initialValue)); // restore initial value
222 }
223
224 /** Test the getter and setter of an optional feature. */
225 template <class Getter, class Setter>
226 void testOptionalAccessors(const string& propertyName, const vector<Property>& valuesToTest,
227 Setter setter, Getter getter,
228 const vector<Property>& invalidValues = {}) {
229 doc::test("Test the optional " + propertyName + " getters and setter");
230 {
231 SCOPED_TRACE("Test feature support by calling the getter");
232 Property initialValue;
233 ASSERT_OK((device.get()->*getter)(returnIn(res, initialValue)));
234 if (res == Result::NOT_SUPPORTED) {
235 doc::partialTest(propertyName + " getter is not supported");
236 return;
237 }
238 ASSERT_OK(res); // If it is supported it must succeed
239 }
240 // The feature is supported, test it
241 testAccessors(propertyName, valuesToTest, setter, getter, invalidValues);
242 }
243};
244
245using BoolAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<bool>;
246
247TEST_F(BoolAccessorPrimaryHidlTest, MicMuteTest) {
248 doc::test("Check that the mic can be muted and unmuted");
249 testAccessors("mic mute", {true, false, true}, &IDevice::setMicMute, &IDevice::getMicMute);
250 // TODO: check that the mic is really muted (all sample are 0)
251}
252
253TEST_F(BoolAccessorPrimaryHidlTest, MasterMuteTest) {
254 doc::test(
255 "If master mute is supported, try to mute and unmute the master "
256 "output");
257 testOptionalAccessors("master mute", {true, false, true}, &IDevice::setMasterMute,
258 &IDevice::getMasterMute);
259 // TODO: check that the master volume is really muted
260}
261
262using FloatAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<float>;
263TEST_F(FloatAccessorPrimaryHidlTest, MasterVolumeTest) {
264 doc::test("Test the master volume if supported");
265 testOptionalAccessors(
266 "master volume", {0, 0.5, 1}, &IDevice::setMasterVolume, &IDevice::getMasterVolume,
267 {-0.1, 1.1, NAN, INFINITY, -INFINITY, 1 + std::numeric_limits<float>::epsilon()});
268 // TODO: check that the master volume is really changed
269}
270
271//////////////////////////////////////////////////////////////////////////////
272//////////////////////////////// AudioPatches ////////////////////////////////
273//////////////////////////////////////////////////////////////////////////////
274
275class AudioPatchPrimaryHidlTest : public AudioPrimaryHidlTest {
276 protected:
277 bool areAudioPatchesSupported() {
278 auto result = device->supportsAudioPatches();
279 EXPECT_IS_OK(result);
280 return result;
281 }
282};
283
284TEST_F(AudioPatchPrimaryHidlTest, AudioPatches) {
285 doc::test("Test if audio patches are supported");
286 if (!areAudioPatchesSupported()) {
287 doc::partialTest("Audio patches are not supported");
288 return;
289 }
290 // TODO: test audio patches
291}
292
293//////////////////////////////////////////////////////////////////////////////
294//////////////// Required and recommended audio format support ///////////////
295// From:
296// https://source.android.com/compatibility/android-cdd.html#5_4_audio_recording
297// From:
298// https://source.android.com/compatibility/android-cdd.html#5_5_audio_playback
299/////////// TODO: move to the beginning of the file for easier update ////////
300//////////////////////////////////////////////////////////////////////////////
301
302class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest {
303 public:
304 // Cache result ?
305 static const vector<AudioConfig> getRequiredSupportPlaybackAudioConfig() {
306 return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
307 {8000, 11025, 16000, 22050, 32000, 44100},
308 {AudioFormat::PCM_16_BIT});
309 }
310
311 static const vector<AudioConfig> getRecommendedSupportPlaybackAudioConfig() {
312 return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
313 {24000, 48000}, {AudioFormat::PCM_16_BIT});
314 }
315
316 static const vector<AudioConfig> getSupportedPlaybackAudioConfig() {
317 // TODO: retrieve audio config supported by the platform
318 // as declared in the policy configuration
319 return {};
320 }
321
322 static const vector<AudioConfig> getRequiredSupportCaptureAudioConfig() {
323 return combineAudioConfig({AudioChannelMask::IN_MONO}, {8000, 11025, 16000, 44100},
324 {AudioFormat::PCM_16_BIT});
325 }
326 static const vector<AudioConfig> getRecommendedSupportCaptureAudioConfig() {
327 return combineAudioConfig({AudioChannelMask::IN_STEREO}, {22050, 48000},
328 {AudioFormat::PCM_16_BIT});
329 }
330 static const vector<AudioConfig> getSupportedCaptureAudioConfig() {
331 // TODO: retrieve audio config supported by the platform
332 // as declared in the policy configuration
333 return {};
334 }
335
336 private:
337 static const vector<AudioConfig> combineAudioConfig(vector<AudioChannelMask> channelMasks,
338 vector<uint32_t> sampleRates,
339 vector<AudioFormat> formats) {
340 vector<AudioConfig> configs;
341 for (auto channelMask : channelMasks) {
342 for (auto sampleRate : sampleRates) {
343 for (auto format : formats) {
344 AudioConfig config{};
345 // leave offloadInfo to 0
346 config.channelMask = mkBitfield(channelMask);
347 config.sampleRateHz = sampleRate;
348 config.format = format;
349 // FIXME: leave frameCount to 0 ?
350 configs.push_back(config);
351 }
352 }
353 }
354 return configs;
355 }
356};
357
358/** Generate a test name based on an audio config.
359 *
360 * As the only parameter changing are channel mask and sample rate,
361 * only print those ones in the test name.
362 */
363static string generateTestName(const testing::TestParamInfo<AudioConfig>& info) {
364 const AudioConfig& config = info.param;
365 return to_string(info.index) + "__" + to_string(config.sampleRateHz) + "_" +
366 // "MONO" is more clear than "FRONT_LEFT"
367 ((config.channelMask == mkBitfield(AudioChannelMask::OUT_MONO) ||
368 config.channelMask == mkBitfield(AudioChannelMask::IN_MONO))
369 ? "MONO"
370 : ::testing::PrintToString(config.channelMask));
371}
372
373//////////////////////////////////////////////////////////////////////////////
374///////////////////////////// getInputBufferSize /////////////////////////////
375//////////////////////////////////////////////////////////////////////////////
376
377// FIXME: execute input test only if platform declares
378// android.hardware.microphone
379// how to get this value ? is it a property ???
380
381class AudioCaptureConfigPrimaryTest : public AudioConfigPrimaryTest,
382 public ::testing::WithParamInterface<AudioConfig> {
383 protected:
384 void inputBufferSizeTest(const AudioConfig& audioConfig, bool supportRequired) {
385 uint64_t bufferSize;
386 ASSERT_OK(device->getInputBufferSize(audioConfig, returnIn(res, bufferSize)));
387
388 switch (res) {
389 case Result::INVALID_ARGUMENTS:
390 EXPECT_FALSE(supportRequired);
391 break;
392 case Result::OK:
393 // Check that the buffer is of a sane size
394 // For now only that it is > 0
395 EXPECT_GT(bufferSize, uint64_t(0));
396 break;
397 default:
398 FAIL() << "Invalid return status: " << ::testing::PrintToString(res);
399 }
400 }
401};
402
403// Test that the required capture config and those declared in the policy are
404// indeed supported
405class RequiredInputBufferSizeTest : public AudioCaptureConfigPrimaryTest {};
406TEST_P(RequiredInputBufferSizeTest, RequiredInputBufferSizeTest) {
407 doc::test(
408 "Input buffer size must be retrievable for a format with required "
409 "support.");
410 inputBufferSizeTest(GetParam(), true);
411}
412INSTANTIATE_TEST_CASE_P(
413 RequiredInputBufferSize, RequiredInputBufferSizeTest,
414 ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()),
415 &generateTestName);
416INSTANTIATE_TEST_CASE_P(
417 SupportedInputBufferSize, RequiredInputBufferSizeTest,
418 ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()),
419 &generateTestName);
420
421// Test that the recommended capture config are supported or lead to a
422// INVALID_ARGUMENTS return
423class OptionalInputBufferSizeTest : public AudioCaptureConfigPrimaryTest {};
424TEST_P(OptionalInputBufferSizeTest, OptionalInputBufferSizeTest) {
425 doc::test(
426 "Input buffer size should be retrievable for a format with recommended "
427 "support.");
428 inputBufferSizeTest(GetParam(), false);
429}
430INSTANTIATE_TEST_CASE_P(
431 RecommendedCaptureAudioConfigSupport, OptionalInputBufferSizeTest,
432 ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()),
433 &generateTestName);
434
435//////////////////////////////////////////////////////////////////////////////
436/////////////////////////////// setScreenState ///////////////////////////////
437//////////////////////////////////////////////////////////////////////////////
438
439TEST_F(AudioPrimaryHidlTest, setScreenState) {
440 doc::test("Check that the hal can receive the screen state");
441 for (bool turnedOn : {false, true, true, false, false}) {
442 auto ret = device->setScreenState(turnedOn);
443 ASSERT_IS_OK(ret);
444 Result result = ret;
445 auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED};
446 ASSERT_RESULT(okOrNotSupported, result);
447 }
448}
449
450//////////////////////////////////////////////////////////////////////////////
451//////////////////////////// {get,set}Parameters /////////////////////////////
452//////////////////////////////////////////////////////////////////////////////
453
454TEST_F(AudioPrimaryHidlTest, getParameters) {
455 doc::test("Check that the hal can set and get parameters");
456 hidl_vec<ParameterValue> context;
457 hidl_vec<hidl_string> keys;
458 hidl_vec<ParameterValue> values;
459 ASSERT_OK(device->getParameters(context, keys, returnIn(res, values)));
460 ASSERT_OK(device->setParameters(context, values));
461 values.resize(0);
462 ASSERT_OK(device->setParameters(context, values));
463}
464
465//////////////////////////////////////////////////////////////////////////////
466//////////////////////////////// debugDebug //////////////////////////////////
467//////////////////////////////////////////////////////////////////////////////
468
469template <class DebugDump>
470static void testDebugDump(DebugDump debugDump) {
471 // File descriptors to our pipe. fds[0] corresponds to the read end and
472 // fds[1] to the write end.
473 int fds[2];
474 ASSERT_EQ(0, pipe2(fds, O_NONBLOCK)) << errno;
475
476 // Make sure that the pipe is at least 1 MB in size. The test process runs
477 // in su domain, so it should be safe to make this call.
478 fcntl(fds[0], F_SETPIPE_SZ, 1 << 20);
479
480 // Wrap the temporary file file descriptor in a native handle
481 auto* nativeHandle = native_handle_create(1, 0);
482 ASSERT_NE(nullptr, nativeHandle);
483 nativeHandle->data[0] = fds[1];
484
485 // Wrap this native handle in a hidl handle
486 hidl_handle handle;
487 handle.setTo(nativeHandle, false /*take ownership*/);
488
489 ASSERT_OK(debugDump(handle));
490
491 // Check that at least one bit was written by the hal
492 // TODO: debugDump does not return a Result.
493 // This mean that the hal can not report that it not implementing the
494 // function.
495 char buff;
496 if (read(fds[0], &buff, 1) != 1) {
497 doc::note("debugDump does not seem implemented");
498 }
499 EXPECT_EQ(0, close(fds[0])) << errno;
500 EXPECT_EQ(0, close(fds[1])) << errno;
501}
502
503TEST_F(AudioPrimaryHidlTest, DebugDump) {
504 doc::test("Check that the hal can dump its state without error");
505 testDebugDump([](const auto& handle) { return device->debug(handle, {/* options */}); });
506}
507
508TEST_F(AudioPrimaryHidlTest, DebugDumpInvalidArguments) {
509 doc::test("Check that the hal dump doesn't crash on invalid arguments");
510 ASSERT_OK(device->debug(hidl_handle(), {/* options */}));
511}
512
513TEST_F(AudioPrimaryHidlTest, SetConnectedState) {
514 doc::test("Check that the HAL can be notified of device connection and deconnection");
515 using AD = AudioDevice;
516 for (auto deviceType : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) {
517 SCOPED_TRACE("device=" + ::testing::PrintToString(deviceType));
518 for (bool state : {true, false}) {
519 SCOPED_TRACE("state=" + ::testing::PrintToString(state));
520 DeviceAddress address = {};
521 address.device = deviceType;
522 auto ret = device->setConnectedState(address, state);
523 ASSERT_TRUE(ret.isOk());
524 if (res == Result::NOT_SUPPORTED) {
525 doc::partialTest("setConnectedState is not supported");
526 return;
527 }
528 ASSERT_OK(res);
529 }
530 }
531}
532
533//////////////////////////////////////////////////////////////////////////////
534////////////////////////// open{Output,Input}Stream //////////////////////////
535//////////////////////////////////////////////////////////////////////////////
536
537template <class Stream>
538class OpenStreamTest : public AudioConfigPrimaryTest,
539 public ::testing::WithParamInterface<AudioConfig> {
540 protected:
541 template <class Open>
542 void testOpen(Open openStream, const AudioConfig& config) {
543 // FIXME: Open a stream without an IOHandle
544 // This is not required to be accepted by hal implementations
545 AudioIoHandle ioHandle = (AudioIoHandle)AudioHandleConsts::AUDIO_IO_HANDLE_NONE;
546 AudioConfig suggestedConfig{};
547 ASSERT_OK(openStream(ioHandle, config, returnIn(res, stream, suggestedConfig)));
548
549 // TODO: only allow failure for RecommendedPlaybackAudioConfig
550 switch (res) {
551 case Result::OK:
552 ASSERT_TRUE(stream != nullptr);
553 audioConfig = config;
554 break;
555 case Result::INVALID_ARGUMENTS:
556 ASSERT_TRUE(stream == nullptr);
557 AudioConfig suggestedConfigRetry;
558 // Could not open stream with config, try again with the
559 // suggested one
560 ASSERT_OK(openStream(ioHandle, suggestedConfig,
561 returnIn(res, stream, suggestedConfigRetry)));
562 // This time it must succeed
563 ASSERT_OK(res);
564 ASSERT_TRUE(stream != nullptr);
565 audioConfig = suggestedConfig;
566 break;
567 default:
568 FAIL() << "Invalid return status: " << ::testing::PrintToString(res);
569 }
570 open = true;
571 }
572
573 Return<Result> closeStream() {
574 open = false;
575 return stream->close();
576 }
577
578 private:
579 void TearDown() override {
580 if (open) {
581 ASSERT_OK(stream->close());
582 }
583 }
584
585 protected:
586 AudioConfig audioConfig;
587 DeviceAddress address = {};
588 sp<Stream> stream;
589 bool open = false;
590};
591
592////////////////////////////// openOutputStream //////////////////////////////
593
594class OutputStreamTest : public OpenStreamTest<IStreamOut> {
595 virtual void SetUp() override {
596 ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp()); // setup base
597 address.device = AudioDevice::OUT_DEFAULT;
598 const AudioConfig& config = GetParam();
599 // TODO: test all flag combination
600 auto flags = hidl_bitfield<AudioOutputFlag>(AudioOutputFlag::NONE);
601 SourceMetadata metadata = {{{}}}; // create on track metadata
602 testOpen(
603 [&](AudioIoHandle handle, AudioConfig config, auto cb) {
604 return device->openOutputStream(handle, address, config, flags, metadata, cb);
605 },
606 config);
607 }
608};
609TEST_P(OutputStreamTest, OpenOutputStreamTest) {
610 doc::test(
611 "Check that output streams can be open with the required and "
612 "recommended config");
613 // Open done in SetUp
614}
615INSTANTIATE_TEST_CASE_P(
616 RequiredOutputStreamConfigSupport, OutputStreamTest,
617 ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportPlaybackAudioConfig()),
618 &generateTestName);
619INSTANTIATE_TEST_CASE_P(
620 SupportedOutputStreamConfig, OutputStreamTest,
621 ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedPlaybackAudioConfig()),
622 &generateTestName);
623
624INSTANTIATE_TEST_CASE_P(
625 RecommendedOutputStreamConfigSupport, OutputStreamTest,
626 ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportPlaybackAudioConfig()),
627 &generateTestName);
628
629////////////////////////////// openInputStream //////////////////////////////
630
631class InputStreamTest : public OpenStreamTest<IStreamIn> {
632 virtual void SetUp() override {
633 ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp()); // setup base
634 address.device = AudioDevice::IN_DEFAULT;
635 const AudioConfig& config = GetParam();
636 // TODO: test all supported flags and source
637 auto flags = hidl_bitfield<AudioInputFlag>(AudioInputFlag::NONE);
638 SinkMetadata metadata = {{{AudioSource::DEFAULT, 1}}};
639 testOpen(
640 [&](AudioIoHandle handle, AudioConfig config, auto cb) {
641 return device->openInputStream(handle, address, config, flags, metadata, cb);
642 },
643 config);
644 }
645};
646
647TEST_P(InputStreamTest, OpenInputStreamTest) {
648 doc::test(
649 "Check that input streams can be open with the required and "
650 "recommended config");
651 // Open done in setup
652}
653INSTANTIATE_TEST_CASE_P(
654 RequiredInputStreamConfigSupport, InputStreamTest,
655 ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()),
656 &generateTestName);
657INSTANTIATE_TEST_CASE_P(
658 SupportedInputStreamConfig, InputStreamTest,
659 ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()),
660 &generateTestName);
661
662INSTANTIATE_TEST_CASE_P(
663 RecommendedInputStreamConfigSupport, InputStreamTest,
664 ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()),
665 &generateTestName);
666
667//////////////////////////////////////////////////////////////////////////////
668////////////////////////////// IStream getters ///////////////////////////////
669//////////////////////////////////////////////////////////////////////////////
670
671/** Unpack the provided result.
672 * If the result is not OK, register a failure and return an undefined value. */
673template <class R>
674static R extract(Return<R> ret) {
675 if (!ret.isOk()) {
676 EXPECT_IS_OK(ret);
677 return R{};
678 }
679 return ret;
680}
681
682/* Could not find a way to write a test for two parametrized class fixure
683 * thus use this macro do duplicate tests for Input and Output stream */
684#define TEST_IO_STREAM(test_name, documentation, code) \
685 TEST_P(InputStreamTest, test_name) { \
686 doc::test(documentation); \
687 code; \
688 } \
689 TEST_P(OutputStreamTest, test_name) { \
690 doc::test(documentation); \
691 code; \
692 }
693
694TEST_IO_STREAM(GetFrameCount, "Check that the stream frame count == the one it was opened with",
695 ASSERT_EQ(audioConfig.frameCount, extract(stream->getFrameCount())))
696
697TEST_IO_STREAM(GetSampleRate, "Check that the stream sample rate == the one it was opened with",
698 ASSERT_EQ(audioConfig.sampleRateHz, extract(stream->getSampleRate())))
699
700TEST_IO_STREAM(GetChannelMask, "Check that the stream channel mask == the one it was opened with",
701 ASSERT_EQ(audioConfig.channelMask, extract(stream->getChannelMask())))
702
703TEST_IO_STREAM(GetFormat, "Check that the stream format == the one it was opened with",
704 ASSERT_EQ(audioConfig.format, extract(stream->getFormat())))
705
706// TODO: for now only check that the framesize is not incoherent
707TEST_IO_STREAM(GetFrameSize, "Check that the stream frame size == the one it was opened with",
708 ASSERT_GT(extract(stream->getFrameSize()), 0U))
709
710TEST_IO_STREAM(GetBufferSize, "Check that the stream buffer size== the one it was opened with",
711 ASSERT_GE(extract(stream->getBufferSize()), extract(stream->getFrameSize())));
712
713template <class Property, class CapablityGetter>
714static void testCapabilityGetter(const string& name, IStream* stream,
715 CapablityGetter capablityGetter,
716 Return<Property> (IStream::*getter)(),
717 Return<Result> (IStream::*setter)(Property),
718 bool currentMustBeSupported = true) {
719 hidl_vec<Property> capabilities;
720 auto ret = capablityGetter(stream, capabilities);
721 if (ret == Result::NOT_SUPPORTED) {
722 doc::partialTest(name + " is not supported");
723 return;
724 };
725 ASSERT_OK(ret);
726
727 if (currentMustBeSupported) {
728 Property currentValue = extract((stream->*getter)());
729 EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue),
730 capabilities.end())
731 << "current " << name << " is not in the list of the supported ones "
732 << toString(capabilities);
733 }
734
735 // Check that all declared supported values are indeed supported
736 for (auto capability : capabilities) {
737 auto ret = (stream->*setter)(capability);
738 ASSERT_TRUE(ret.isOk());
739 if (ret == Result::NOT_SUPPORTED) {
740 doc::partialTest("Setter is not supported");
741 return;
742 }
743 ASSERT_OK(ret);
744 ASSERT_EQ(capability, extract((stream->*getter)()));
745 }
746}
747
748Result getSupportedSampleRates(IStream* stream, hidl_vec<uint32_t>& rates) {
749 Result res;
750 EXPECT_OK(stream->getSupportedSampleRates(extract(stream->getFormat()), returnIn(res, rates)));
751 return res;
752}
753
754Result getSupportedChannelMasks(IStream* stream,
755 hidl_vec<hidl_bitfield<AudioChannelMask>>& channels) {
756 Result res;
757 EXPECT_OK(
758 stream->getSupportedSampleRates(extract(stream->getFormat()), returnIn(res, channels)));
759 return res;
760}
761
762Result getSupportedFormats(IStream* stream, hidl_vec<AudioFormat>& capabilities) {
763 EXPECT_OK(stream->getSupportedFormats(returnIn(capabilities)));
764 // TODO: this should be an optional function
765 return Result::OK;
766}
767
768TEST_IO_STREAM(SupportedSampleRate, "Check that the stream sample rate is declared as supported",
769 testCapabilityGetter("getSupportedSampleRate", stream.get(),
770 &getSupportedSampleRates, &IStream::getSampleRate,
771 &IStream::setSampleRate,
772 // getSupportedSampleRate returns the native sampling rates,
773 // (the sampling rates that can be played without resampling)
774 // but other sampling rates can be supported by the HAL.
775 false))
776
777TEST_IO_STREAM(SupportedChannelMask, "Check that the stream channel mask is declared as supported",
778 testCapabilityGetter("getSupportedChannelMask", stream.get(),
779 &getSupportedChannelMasks, &IStream::getChannelMask,
780 &IStream::setChannelMask))
781
782TEST_IO_STREAM(SupportedFormat, "Check that the stream format is declared as supported",
783 testCapabilityGetter("getSupportedFormat", stream.get(), &getSupportedFormats,
784 &IStream::getFormat, &IStream::setFormat))
785
786static void testGetDevice(IStream* stream, AudioDevice expectedDevice) {
787 hidl_vec<DeviceAddress> devices;
788 Result res;
789 ASSERT_OK(stream->getDevices(returnIn(res, devices)));
790 if (res == Result::NOT_SUPPORTED) {
791 return doc::partialTest("GetDevices is not supported");
792 }
793 // The stream was constructed with one device, thus getDevices must only return one
794 ASSERT_EQ(1U, devices.size());
795 AudioDevice device = devices[0].device;
796 ASSERT_TRUE(device == expectedDevice)
797 << "Expected: " << ::testing::PrintToString(expectedDevice)
798 << "\n Actual: " << ::testing::PrintToString(device);
799}
800
801TEST_IO_STREAM(GetDevice, "Check that the stream device == the one it was opened with",
802 areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
803 : testGetDevice(stream.get(), address.device))
804
805static void testSetDevice(IStream* stream, const DeviceAddress& address) {
806 DeviceAddress otherAddress = address;
807 otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER
808 : AudioDevice::IN_BUILTIN_MIC;
809 EXPECT_OK(stream->setDevices({otherAddress}));
810
811 ASSERT_OK(stream->setDevices({address})); // Go back to the original value
812}
813
814TEST_IO_STREAM(SetDevice, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
815 areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
816 : testSetDevice(stream.get(), address))
817
818static void testGetAudioProperties(IStream* stream, AudioConfig expectedConfig) {
819 uint32_t sampleRateHz;
820 hidl_bitfield<AudioChannelMask> mask;
821 AudioFormat format;
822
823 stream->getAudioProperties(returnIn(sampleRateHz, mask, format));
824
825 // FIXME: the qcom hal it does not currently negotiate the sampleRate &
826 // channel mask
827 EXPECT_EQ(expectedConfig.sampleRateHz, sampleRateHz);
828 EXPECT_EQ(expectedConfig.channelMask, mask);
829 EXPECT_EQ(expectedConfig.format, format);
830}
831
832TEST_IO_STREAM(GetAudioProperties,
833 "Check that the stream audio properties == the ones it was opened with",
834 testGetAudioProperties(stream.get(), audioConfig))
835
836static auto invalidArgsOrNotSupportedOrOK = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED,
837 Result::OK};
838TEST_IO_STREAM(SetHwAvSync, "Try to set hardware sync to an invalid value",
839 ASSERT_RESULT(invalidArgsOrNotSupportedOrOK, stream->setHwAvSync(666)))
840
841static void checkGetHwAVSync(IDevice* device) {
842 Result res;
843 AudioHwSync sync;
844 ASSERT_OK(device->getHwAvSync(returnIn(res, sync)));
845 if (res == Result::NOT_SUPPORTED) {
846 return doc::partialTest("getHwAvSync is not supported");
847 }
848 ASSERT_OK(res);
849}
850TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", checkGetHwAVSync(device.get()));
851
852static void checkGetNoParameter(IStream* stream, hidl_vec<hidl_string> keys,
853 initializer_list<Result> expectedResults) {
854 hidl_vec<ParameterValue> context;
855 hidl_vec<ParameterValue> parameters;
856 Result res;
857 ASSERT_OK(stream->getParameters(context, keys, returnIn(res, parameters)));
858 ASSERT_RESULT(expectedResults, res);
859 if (res == Result::OK) {
860 for (auto& parameter : parameters) {
861 ASSERT_EQ(0U, parameter.value.size()) << toString(parameter);
862 }
863 }
864}
865
866/* Get/Set parameter is intended to be an opaque channel between vendors app and
867 * their HALs.
868 * Thus can not be meaningfully tested.
869 */
870TEST_IO_STREAM(getEmptySetParameter, "Retrieve the values of an empty set",
871 checkGetNoParameter(stream.get(), {} /* keys */, {Result::OK}))
872
873TEST_IO_STREAM(getNonExistingParameter, "Retrieve the values of an non existing parameter",
874 checkGetNoParameter(stream.get(), {"Non existing key"} /* keys */,
875 {Result::NOT_SUPPORTED}))
876
877TEST_IO_STREAM(setEmptySetParameter, "Set the values of an empty set of parameters",
878 ASSERT_RESULT(Result::OK, stream->setParameters({}, {})))
879
880TEST_IO_STREAM(setNonExistingParameter, "Set the values of an non existing parameter",
881 // Unfortunately, the set_parameter legacy interface did not return any
882 // error code when a key is not supported.
883 // To allow implementation to just wrapped the legacy one, consider OK as a
884 // valid result for setting a non existing parameter.
885 ASSERT_RESULT(invalidArgsOrNotSupportedOrOK,
886 stream->setParameters({}, {{"non existing key", "0"}})))
887
888TEST_IO_STREAM(DebugDump, "Check that a stream can dump its state without error",
889 testDebugDump([this](const auto& handle) { return stream->debug(handle, {}); }))
890
891TEST_IO_STREAM(DebugDumpInvalidArguments,
892 "Check that the stream dump doesn't crash on invalid arguments",
893 ASSERT_OK(stream->debug(hidl_handle(), {})))
894
895//////////////////////////////////////////////////////////////////////////////
896////////////////////////////// addRemoveEffect ///////////////////////////////
897//////////////////////////////////////////////////////////////////////////////
898
899TEST_IO_STREAM(AddNonExistingEffect, "Adding a non existing effect should fail",
900 ASSERT_RESULT(Result::INVALID_ARGUMENTS, stream->addEffect(666)))
901TEST_IO_STREAM(RemoveNonExistingEffect, "Removing a non existing effect should fail",
902 ASSERT_RESULT(Result::INVALID_ARGUMENTS, stream->removeEffect(666)))
903
904// TODO: positive tests
905
906//////////////////////////////////////////////////////////////////////////////
907/////////////////////////////// Control ////////////////////////////////
908//////////////////////////////////////////////////////////////////////////////
909
910TEST_IO_STREAM(standby, "Make sure the stream can be put in stanby",
911 ASSERT_OK(stream->standby())) // can not fail
912
913static constexpr auto invalidStateOrNotSupported = {Result::INVALID_STATE, Result::NOT_SUPPORTED};
914
915TEST_IO_STREAM(startNoMmap, "Starting a mmaped stream before mapping it should fail",
916 ASSERT_RESULT(invalidStateOrNotSupported, stream->start()))
917
918TEST_IO_STREAM(stopNoMmap, "Stopping a mmaped stream before mapping it should fail",
919 ASSERT_RESULT(invalidStateOrNotSupported, stream->stop()))
920
921TEST_IO_STREAM(getMmapPositionNoMmap, "Get a stream Mmap position before mapping it should fail",
922 ASSERT_RESULT(invalidStateOrNotSupported, stream->stop()))
923
924TEST_IO_STREAM(close, "Make sure a stream can be closed", ASSERT_OK(closeStream()))
925TEST_IO_STREAM(closeTwice, "Make sure a stream can not be closed twice", ASSERT_OK(closeStream());
926 ASSERT_RESULT(Result::INVALID_STATE, closeStream()))
927
928static auto invalidArgsOrNotSupported = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED};
929static void testCreateTooBigMmapBuffer(IStream* stream) {
930 MmapBufferInfo info;
931 Result res;
932 // Assume that int max is a value too big to be allocated
933 // This is true currently with a 32bit media server, but might not when it
934 // will run in 64 bit
935 auto minSizeFrames = std::numeric_limits<int32_t>::max();
936 ASSERT_OK(stream->createMmapBuffer(minSizeFrames, returnIn(res, info)));
937 ASSERT_RESULT(invalidArgsOrNotSupported, res);
938}
939
940TEST_IO_STREAM(CreateTooBigMmapBuffer, "Create mmap buffer too big should fail",
941 testCreateTooBigMmapBuffer(stream.get()))
942
943static void testGetMmapPositionOfNonMmapedStream(IStream* stream) {
944 Result res;
945 MmapPosition position;
946 ASSERT_OK(stream->getMmapPosition(returnIn(res, position)));
947 ASSERT_RESULT(invalidArgsOrNotSupported, res);
948}
949
950TEST_IO_STREAM(GetMmapPositionOfNonMmapedStream,
951 "Retrieving the mmap position of a non mmaped stream should fail",
952 testGetMmapPositionOfNonMmapedStream(stream.get()))
953
954//////////////////////////////////////////////////////////////////////////////
955///////////////////////////////// StreamIn ///////////////////////////////////
956//////////////////////////////////////////////////////////////////////////////
957
958TEST_P(InputStreamTest, GetAudioSource) {
959 doc::test("Retrieving the audio source of an input stream should always succeed");
960 AudioSource source;
961 ASSERT_OK(stream->getAudioSource(returnIn(res, source)));
962 if (res == Result::NOT_SUPPORTED) {
963 doc::partialTest("getAudioSource is not supported");
964 return;
965 }
966 ASSERT_OK(res);
967 ASSERT_EQ(AudioSource::DEFAULT, source);
968}
969
970static void testUnitaryGain(std::function<Return<Result>(float)> setGain) {
971 for (float value : (float[]){-INFINITY, -1.0, 1.0 + std::numeric_limits<float>::epsilon(), 2.0,
972 INFINITY, NAN}) {
973 EXPECT_RESULT(Result::INVALID_ARGUMENTS, setGain(value)) << "value=" << value;
974 }
975 // Do not consider -0.0 as an invalid value as it is == with 0.0
976 for (float value : {-0.0, 0.0, 0.01, 0.5, 0.09, 1.0 /* Restore volume*/}) {
977 EXPECT_OK(setGain(value)) << "value=" << value;
978 }
979}
980
981static void testOptionalUnitaryGain(std::function<Return<Result>(float)> setGain,
982 string debugName) {
983 auto result = setGain(1);
984 ASSERT_IS_OK(result);
985 if (result == Result::NOT_SUPPORTED) {
986 doc::partialTest(debugName + " is not supported");
987 return;
988 }
989 testUnitaryGain(setGain);
990}
991
992TEST_P(InputStreamTest, SetGain) {
993 doc::test("The gain of an input stream should only be set between [0,1]");
994 testOptionalUnitaryGain([this](float volume) { return stream->setGain(volume); },
995 "InputStream::setGain");
996}
997
998static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize, uint32_t framesCount) {
999 Result res;
1000 // Ignore output parameters as the call should fail
1001 ASSERT_OK(stream->prepareForReading(frameSize, framesCount,
1002 [&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
1003 EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
1004}
1005
1006TEST_P(InputStreamTest, PrepareForReadingWithZeroBuffer) {
1007 doc::test("Preparing a stream for reading with a 0 sized buffer should fail");
1008 testPrepareForReading(stream.get(), 0, 0);
1009}
1010
1011TEST_P(InputStreamTest, PrepareForReadingWithHugeBuffer) {
1012 doc::test("Preparing a stream for reading with a 2^32 sized buffer should fail");
1013 testPrepareForReading(stream.get(), 1, std::numeric_limits<uint32_t>::max());
1014}
1015
1016TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) {
1017 doc::test(
1018 "Preparing a stream for reading with a overflowing sized buffer should "
1019 "fail");
1020 auto uintMax = std::numeric_limits<uint32_t>::max();
1021 testPrepareForReading(stream.get(), uintMax, uintMax);
1022}
1023
1024TEST_P(InputStreamTest, GetInputFramesLost) {
1025 doc::test("The number of frames lost on a never started stream should be 0");
1026 auto ret = stream->getInputFramesLost();
1027 ASSERT_IS_OK(ret);
1028 uint32_t framesLost{ret};
1029 ASSERT_EQ(0U, framesLost);
1030}
1031
1032TEST_P(InputStreamTest, getCapturePosition) {
1033 doc::test(
1034 "The capture position of a non prepared stream should not be "
1035 "retrievable");
1036 uint64_t frames;
1037 uint64_t time;
1038 ASSERT_OK(stream->getCapturePosition(returnIn(res, frames, time)));
1039 ASSERT_RESULT(invalidStateOrNotSupported, res);
1040}
1041
1042//////////////////////////////////////////////////////////////////////////////
1043///////////////////////////////// StreamIn ///////////////////////////////////
1044//////////////////////////////////////////////////////////////////////////////
1045
1046TEST_P(OutputStreamTest, getLatency) {
1047 doc::test("Make sure latency is over 0");
1048 auto result = stream->getLatency();
1049 ASSERT_IS_OK(result);
1050 ASSERT_GT(result, 0U);
1051}
1052
1053TEST_P(OutputStreamTest, setVolume) {
1054 doc::test("Try to set the output volume");
1055 testOptionalUnitaryGain([this](float volume) { return stream->setVolume(volume, volume); },
1056 "setVolume");
1057}
1058
1059static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize, uint32_t framesCount) {
1060 Result res;
1061 // Ignore output parameters as the call should fail
1062 ASSERT_OK(stream->prepareForWriting(frameSize, framesCount,
1063 [&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
1064 EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
1065}
1066
1067TEST_P(OutputStreamTest, PrepareForWriteWithZeroBuffer) {
1068 doc::test("Preparing a stream for writing with a 0 sized buffer should fail");
1069 testPrepareForWriting(stream.get(), 0, 0);
1070}
1071
1072TEST_P(OutputStreamTest, PrepareForWriteWithHugeBuffer) {
1073 doc::test("Preparing a stream for writing with a 2^32 sized buffer should fail");
1074 testPrepareForWriting(stream.get(), 1, std::numeric_limits<uint32_t>::max());
1075}
1076
1077TEST_P(OutputStreamTest, PrepareForWritingCheckOverflow) {
1078 doc::test(
1079 "Preparing a stream for writing with a overflowing sized buffer should "
1080 "fail");
1081 auto uintMax = std::numeric_limits<uint32_t>::max();
1082 testPrepareForWriting(stream.get(), uintMax, uintMax);
1083}
1084
1085struct Capability {
1086 Capability(IStreamOut* stream) {
1087 EXPECT_OK(stream->supportsPauseAndResume(returnIn(pause, resume)));
1088 auto ret = stream->supportsDrain();
1089 EXPECT_IS_OK(ret);
1090 if (ret.isOk()) {
1091 drain = ret;
1092 }
1093 }
1094 bool pause = false;
1095 bool resume = false;
1096 bool drain = false;
1097};
1098
1099TEST_P(OutputStreamTest, SupportsPauseAndResumeAndDrain) {
1100 doc::test("Implementation must expose pause, resume and drain capabilities");
1101 Capability(stream.get());
1102}
1103
1104template <class Value>
1105static void checkInvalidStateOr0(Result res, Value value) {
1106 switch (res) {
1107 case Result::INVALID_STATE:
1108 break;
1109 case Result::OK:
1110 ASSERT_EQ(0U, value);
1111 break;
1112 default:
1113 FAIL() << "Unexpected result " << toString(res);
1114 }
1115}
1116
1117TEST_P(OutputStreamTest, GetRenderPosition) {
1118 doc::test("A new stream render position should be 0 or INVALID_STATE");
1119 uint32_t dspFrames;
1120 ASSERT_OK(stream->getRenderPosition(returnIn(res, dspFrames)));
1121 if (res == Result::NOT_SUPPORTED) {
1122 doc::partialTest("getRenderPosition is not supported");
1123 return;
1124 }
1125 checkInvalidStateOr0(res, dspFrames);
1126}
1127
1128TEST_P(OutputStreamTest, GetNextWriteTimestamp) {
1129 doc::test("A new stream next write timestamp should be 0 or INVALID_STATE");
1130 uint64_t timestampUs;
1131 ASSERT_OK(stream->getNextWriteTimestamp(returnIn(res, timestampUs)));
1132 if (res == Result::NOT_SUPPORTED) {
1133 doc::partialTest("getNextWriteTimestamp is not supported");
1134 return;
1135 }
1136 checkInvalidStateOr0(res, timestampUs);
1137}
1138
1139/** Stub implementation of out stream callback. */
1140class MockOutCallbacks : public IStreamOutCallback {
1141 Return<void> onWriteReady() override { return {}; }
1142 Return<void> onDrainReady() override { return {}; }
1143 Return<void> onError() override { return {}; }
1144};
1145
1146static bool isAsyncModeSupported(IStreamOut* stream) {
1147 auto res = stream->setCallback(new MockOutCallbacks);
1148 stream->clearCallback(); // try to restore the no callback state, ignore
1149 // any error
1150 auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED};
1151 EXPECT_RESULT(okOrNotSupported, res);
1152 return res.isOk() ? res == Result::OK : false;
1153}
1154
1155TEST_P(OutputStreamTest, SetCallback) {
1156 doc::test(
1157 "If supported, registering callback for async operation should never "
1158 "fail");
1159 if (!isAsyncModeSupported(stream.get())) {
1160 doc::partialTest("The stream does not support async operations");
1161 return;
1162 }
1163 ASSERT_OK(stream->setCallback(new MockOutCallbacks));
1164 ASSERT_OK(stream->setCallback(new MockOutCallbacks));
1165}
1166
1167TEST_P(OutputStreamTest, clearCallback) {
1168 doc::test(
1169 "If supported, clearing a callback to go back to sync operation should "
1170 "not fail");
1171 if (!isAsyncModeSupported(stream.get())) {
1172 doc::partialTest("The stream does not support async operations");
1173 return;
1174 }
1175 // TODO: Clarify if clearing a non existing callback should fail
1176 ASSERT_OK(stream->setCallback(new MockOutCallbacks));
1177 ASSERT_OK(stream->clearCallback());
1178}
1179
1180TEST_P(OutputStreamTest, Resume) {
1181 doc::test(
1182 "If supported, a stream should fail to resume if not previously "
1183 "paused");
1184 if (!Capability(stream.get()).resume) {
1185 doc::partialTest("The output stream does not support resume");
1186 return;
1187 }
1188 ASSERT_RESULT(Result::INVALID_STATE, stream->resume());
1189}
1190
1191TEST_P(OutputStreamTest, Pause) {
1192 doc::test(
1193 "If supported, a stream should fail to pause if not previously "
1194 "started");
1195 if (!Capability(stream.get()).pause) {
1196 doc::partialTest("The output stream does not support pause");
1197 return;
1198 }
1199 ASSERT_RESULT(Result::INVALID_STATE, stream->resume());
1200}
1201
1202static void testDrain(IStreamOut* stream, AudioDrain type) {
1203 if (!Capability(stream).drain) {
1204 doc::partialTest("The output stream does not support drain");
1205 return;
1206 }
1207 ASSERT_RESULT(Result::OK, stream->drain(type));
1208}
1209
1210TEST_P(OutputStreamTest, DrainAll) {
1211 doc::test("If supported, a stream should always succeed to drain");
1212 testDrain(stream.get(), AudioDrain::ALL);
1213}
1214
1215TEST_P(OutputStreamTest, DrainEarlyNotify) {
1216 doc::test("If supported, a stream should always succeed to drain");
1217 testDrain(stream.get(), AudioDrain::EARLY_NOTIFY);
1218}
1219
1220TEST_P(OutputStreamTest, FlushStop) {
1221 doc::test("If supported, a stream should always succeed to flush");
1222 auto ret = stream->flush();
1223 ASSERT_IS_OK(ret);
1224 if (ret == Result::NOT_SUPPORTED) {
1225 doc::partialTest("Flush is not supported");
1226 return;
1227 }
1228 ASSERT_OK(ret);
1229}
1230
1231TEST_P(OutputStreamTest, GetPresentationPositionStop) {
1232 doc::test(
1233 "If supported, a stream should always succeed to retrieve the "
1234 "presentation position");
1235 uint64_t frames;
1236 TimeSpec mesureTS;
1237 ASSERT_OK(stream->getPresentationPosition(returnIn(res, frames, mesureTS)));
1238 if (res == Result::NOT_SUPPORTED) {
1239 doc::partialTest("getpresentationPosition is not supported");
1240 return;
1241 }
1242 ASSERT_EQ(0U, frames);
1243
1244 if (mesureTS.tvNSec == 0 && mesureTS.tvSec == 0) {
1245 // As the stream has never written a frame yet,
1246 // the timestamp does not really have a meaning, allow to return 0
1247 return;
1248 }
1249
1250 // Make sure the return measure is not more than 1s old.
1251 struct timespec currentTS;
1252 ASSERT_EQ(0, clock_gettime(CLOCK_MONOTONIC, &currentTS)) << errno;
1253
1254 auto toMicroSec = [](uint64_t sec, auto nsec) { return sec * 1e+6 + nsec / 1e+3; };
1255 auto currentTime = toMicroSec(currentTS.tv_sec, currentTS.tv_nsec);
1256 auto mesureTime = toMicroSec(mesureTS.tvSec, mesureTS.tvNSec);
1257 ASSERT_PRED2([](auto c, auto m) { return c - m < 1e+6; }, currentTime, mesureTime);
1258}
1259
1260//////////////////////////////////////////////////////////////////////////////
1261/////////////////////////////// PrimaryDevice ////////////////////////////////
1262//////////////////////////////////////////////////////////////////////////////
1263
1264TEST_F(AudioPrimaryHidlTest, setVoiceVolume) {
1265 doc::test("Make sure setVoiceVolume only succeed if volume is in [0,1]");
1266 testUnitaryGain([](float volume) { return device->setVoiceVolume(volume); });
1267}
1268
1269TEST_F(AudioPrimaryHidlTest, setMode) {
1270 doc::test(
1271 "Make sure setMode always succeeds if mode is valid "
1272 "and fails otherwise");
1273 // Test Invalid values
1274 for (int mode : {-1, 0, int(AudioMode::IN_COMMUNICATION) + 1}) {
1275 SCOPED_TRACE("mode=" + to_string(mode));
1276 ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(AudioMode(mode)));
1277 }
1278 // Test valid values
1279 for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE,
1280 AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) {
1281 SCOPED_TRACE("mode=" + toString(mode));
1282 ASSERT_OK(device->setMode(mode));
1283 }
1284}
1285
1286TEST_F(BoolAccessorPrimaryHidlTest, BtScoNrecEnabled) {
1287 doc::test("Query and set the BT SCO NR&EC state");
1288 testOptionalAccessors("BtScoNrecEnabled", {true, false, true},
1289 &IPrimaryDevice::setBtScoNrecEnabled,
1290 &IPrimaryDevice::getBtScoNrecEnabled);
1291}
1292
1293TEST_F(BoolAccessorPrimaryHidlTest, setGetBtScoWidebandEnabled) {
1294 doc::test("Query and set the SCO whideband state");
1295 testOptionalAccessors("BtScoWideband", {true, false, true},
1296 &IPrimaryDevice::setBtScoWidebandEnabled,
1297 &IPrimaryDevice::getBtScoWidebandEnabled);
1298}
1299
1300using TtyModeAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<TtyMode>;
1301TEST_F(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) {
1302 doc::test("Query and set the TTY mode state");
1303 testOptionalAccessors("TTY mode", {TtyMode::OFF, TtyMode::HCO, TtyMode::VCO, TtyMode::FULL},
1304 &IPrimaryDevice::setTtyMode, &IPrimaryDevice::getTtyMode);
1305}
1306
1307TEST_F(BoolAccessorPrimaryHidlTest, setGetHac) {
1308 doc::test("Query and set the HAC state");
1309 testOptionalAccessors("HAC", {true, false, true}, &IPrimaryDevice::setHacEnabled,
1310 &IPrimaryDevice::getHacEnabled);
1311}
1312
1313//////////////////////////////////////////////////////////////////////////////
1314//////////////////// Clean caches on global tear down ////////////////////////
1315//////////////////////////////////////////////////////////////////////////////
1316
1317int main(int argc, char** argv) {
1318 environment = new AudioHidlTestEnvironment;
1319 ::testing::AddGlobalTestEnvironment(environment);
1320 ::testing::InitGoogleTest(&argc, argv);
1321 environment->init(&argc, argv);
1322 int status = RUN_ALL_TESTS();
1323 return status;
1324}
diff --git a/audio/core/4.0/vts/functional/ValidateAudioConfiguration.cpp b/audio/core/4.0/vts/functional/ValidateAudioConfiguration.cpp
new file mode 100644
index 00000000..bef0e827
--- /dev/null
+++ b/audio/core/4.0/vts/functional/ValidateAudioConfiguration.cpp
@@ -0,0 +1,30 @@
1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <unistd.h>
18#include <string>
19
20#include "utility/ValidateXml.h"
21
22TEST(CheckConfig, audioPolicyConfigurationValidation) {
23 RecordProperty("description",
24 "Verify that the audio policy configuration file "
25 "is valid according to the schema");
26
27 std::vector<const char*> locations = {"/odm/etc", "/vendor/etc", "/system/etc"};
28 EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS("audio_policy_configuration.xml", locations,
29 "/data/local/tmp/audio_policy_configuration.xsd");
30}
diff --git a/audio/effect/4.0/vts/OWNERS b/audio/effect/4.0/vts/OWNERS
new file mode 100644
index 00000000..8711a9ff
--- /dev/null
+++ b/audio/effect/4.0/vts/OWNERS
@@ -0,0 +1,5 @@
1elaurent@google.com
2krocard@google.com
3mnaganov@google.com
4yim@google.com
5zhuoyao@google.com \ No newline at end of file
diff --git a/audio/effect/4.0/vts/functional/Android.bp b/audio/effect/4.0/vts/functional/Android.bp
new file mode 100644
index 00000000..92b5db74
--- /dev/null
+++ b/audio/effect/4.0/vts/functional/Android.bp
@@ -0,0 +1,39 @@
1//
2// Copyright (C) 2016 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_test {
18 name: "VtsHalAudioEffectV4_0TargetTest",
19 defaults: ["VtsHalTargetTestDefaults"],
20 srcs: [
21 "VtsHalAudioEffectV4_0TargetTest.cpp",
22 "ValidateAudioEffectsConfiguration.cpp"
23 ],
24 static_libs: [
25 "android.hardware.audio.common.test.utility",
26 "android.hardware.audio.common@4.0",
27 "android.hardware.audio.effect@4.0",
28 "android.hidl.allocator@1.0",
29 "android.hidl.memory@1.0",
30 "libxml2",
31 ],
32 shared_libs: [
33 "libeffectsconfig",
34 "libicuuc",
35 ],
36 header_libs: [
37 "android.hardware.audio.common.util@all-versions",
38 ],
39}
diff --git a/audio/effect/4.0/vts/functional/ValidateAudioEffectsConfiguration.cpp b/audio/effect/4.0/vts/functional/ValidateAudioEffectsConfiguration.cpp
new file mode 100644
index 00000000..6338563c
--- /dev/null
+++ b/audio/effect/4.0/vts/functional/ValidateAudioEffectsConfiguration.cpp
@@ -0,0 +1,32 @@
1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <unistd.h>
18#include <iterator>
19
20#include <media/EffectsConfig.h>
21
22#include "utility/ValidateXml.h"
23
24TEST(CheckConfig, audioEffectsConfigurationValidation) {
25 RecordProperty("description",
26 "Verify that the effects configuration file is valid according to the schema");
27 using namespace android::effectsConfig;
28
29 std::vector<const char*> locations(std::begin(DEFAULT_LOCATIONS), std::end(DEFAULT_LOCATIONS));
30 EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations,
31 "/data/local/tmp/audio_effects_conf_V4_0.xsd");
32}
diff --git a/audio/effect/4.0/vts/functional/VtsHalAudioEffectV4_0TargetTest.cpp b/audio/effect/4.0/vts/functional/VtsHalAudioEffectV4_0TargetTest.cpp
new file mode 100644
index 00000000..ec783c4b
--- /dev/null
+++ b/audio/effect/4.0/vts/functional/VtsHalAudioEffectV4_0TargetTest.cpp
@@ -0,0 +1,852 @@
1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "AudioEffectHidlHalTest"
18#include <android-base/logging.h>
19#include <system/audio.h>
20
21#include <android/hardware/audio/effect/4.0/IEffect.h>
22#include <android/hardware/audio/effect/4.0/IEffectsFactory.h>
23#include <android/hardware/audio/effect/4.0/IEqualizerEffect.h>
24#include <android/hardware/audio/effect/4.0/ILoudnessEnhancerEffect.h>
25#include <android/hardware/audio/effect/4.0/types.h>
26#include <android/hidl/allocator/1.0/IAllocator.h>
27#include <android/hidl/memory/1.0/IMemory.h>
28
29#include <common/all-versions/VersionUtils.h>
30
31#include <VtsHalHidlTargetTestBase.h>
32#include <VtsHalHidlTargetTestEnvBase.h>
33
34using android::hardware::audio::common::V4_0::AudioDevice;
35using android::hardware::audio::common::V4_0::AudioHandleConsts;
36using android::hardware::audio::common::V4_0::AudioMode;
37using android::hardware::audio::common::V4_0::AudioSource;
38using android::hardware::audio::common::V4_0::Uuid;
39using android::hardware::audio::common::utils::mkBitfield;
40using android::hardware::audio::effect::V4_0::AudioBuffer;
41using android::hardware::audio::effect::V4_0::EffectAuxChannelsConfig;
42using android::hardware::audio::effect::V4_0::EffectBufferConfig;
43using android::hardware::audio::effect::V4_0::EffectConfig;
44using android::hardware::audio::effect::V4_0::EffectDescriptor;
45using android::hardware::audio::effect::V4_0::EffectOffloadParameter;
46using android::hardware::audio::effect::V4_0::IEffect;
47using android::hardware::audio::effect::V4_0::IEffectsFactory;
48using android::hardware::audio::effect::V4_0::IEqualizerEffect;
49using android::hardware::audio::effect::V4_0::ILoudnessEnhancerEffect;
50using android::hardware::audio::effect::V4_0::Result;
51using android::hardware::MQDescriptorSync;
52using android::hardware::Return;
53using android::hardware::Void;
54using android::hardware::hidl_handle;
55using android::hardware::hidl_memory;
56using android::hardware::hidl_string;
57using android::hardware::hidl_vec;
58using android::hidl::allocator::V1_0::IAllocator;
59using android::hidl::memory::V1_0::IMemory;
60using android::sp;
61
62#ifndef ARRAY_SIZE
63#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
64#endif
65
66// Test environment for Audio Effects Factory HIDL HAL.
67class AudioEffectsFactoryHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
68 public:
69 // get the test environment singleton
70 static AudioEffectsFactoryHidlEnvironment* Instance() {
71 static AudioEffectsFactoryHidlEnvironment* instance =
72 new AudioEffectsFactoryHidlEnvironment;
73 return instance;
74 }
75
76 virtual void registerTestServices() override { registerTestService<IEffectsFactory>(); }
77};
78
79// The main test class for Audio Effects Factory HIDL HAL.
80class AudioEffectsFactoryHidlTest : public ::testing::VtsHalHidlTargetTestBase {
81 public:
82 void SetUp() override {
83 effectsFactory = ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>(
84 AudioEffectsFactoryHidlEnvironment::Instance()->getServiceName<IEffectsFactory>());
85 ASSERT_NE(effectsFactory, nullptr);
86 }
87
88 void TearDown() override { effectsFactory.clear(); }
89
90 protected:
91 static void description(const std::string& description) {
92 RecordProperty("description", description);
93 }
94
95 sp<IEffectsFactory> effectsFactory;
96};
97
98TEST_F(AudioEffectsFactoryHidlTest, EnumerateEffects) {
99 description("Verify that EnumerateEffects returns at least one effect");
100 Result retval = Result::NOT_INITIALIZED;
101 size_t effectCount = 0;
102 Return<void> ret = effectsFactory->getAllDescriptors(
103 [&](Result r, const hidl_vec<EffectDescriptor>& result) {
104 retval = r;
105 effectCount = result.size();
106 });
107 EXPECT_TRUE(ret.isOk());
108 EXPECT_EQ(Result::OK, retval);
109 EXPECT_GT(effectCount, 0u);
110}
111
112TEST_F(AudioEffectsFactoryHidlTest, CreateEffect) {
113 description("Verify that an effect can be created via CreateEffect");
114 bool gotEffect = false;
115 Uuid effectUuid;
116 Return<void> ret = effectsFactory->getAllDescriptors(
117 [&](Result r, const hidl_vec<EffectDescriptor>& result) {
118 if (r == Result::OK && result.size() > 0) {
119 gotEffect = true;
120 effectUuid = result[0].uuid;
121 }
122 });
123 ASSERT_TRUE(ret.isOk());
124 ASSERT_TRUE(gotEffect);
125 Result retval = Result::NOT_INITIALIZED;
126 sp<IEffect> effect;
127 ret = effectsFactory->createEffect(
128 effectUuid, 1 /*session*/, 1 /*ioHandle*/,
129 [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
130 retval = r;
131 if (r == Result::OK) {
132 effect = result;
133 }
134 });
135 EXPECT_TRUE(ret.isOk());
136 EXPECT_EQ(Result::OK, retval);
137 EXPECT_NE(nullptr, effect.get());
138}
139
140TEST_F(AudioEffectsFactoryHidlTest, GetDescriptor) {
141 description(
142 "Verify that effects factory can provide an effect descriptor via "
143 "GetDescriptor");
144 hidl_vec<EffectDescriptor> allDescriptors;
145 Return<void> ret = effectsFactory->getAllDescriptors(
146 [&](Result r, const hidl_vec<EffectDescriptor>& result) {
147 if (r == Result::OK) {
148 allDescriptors = result;
149 }
150 });
151 ASSERT_TRUE(ret.isOk());
152 ASSERT_GT(allDescriptors.size(), 0u);
153 for (size_t i = 0; i < allDescriptors.size(); ++i) {
154 ret = effectsFactory->getDescriptor(
155 allDescriptors[i].uuid, [&](Result r, const EffectDescriptor& result) {
156 EXPECT_EQ(r, Result::OK);
157 EXPECT_EQ(result, allDescriptors[i]);
158 });
159 }
160 EXPECT_TRUE(ret.isOk());
161}
162
163TEST_F(AudioEffectsFactoryHidlTest, DebugDumpInvalidArgument) {
164 description("Verify that debugDump doesn't crash on invalid arguments");
165 Return<void> ret = effectsFactory->debug(hidl_handle(), {});
166 ASSERT_TRUE(ret.isOk());
167}
168
169// Equalizer effect is required by CDD, but only the type is fixed.
170// This is the same UUID as AudioEffect.EFFECT_TYPE_EQUALIZER in Java.
171static const Uuid EQUALIZER_EFFECT_TYPE = {
172 0x0bed4300, 0xddd6, 0x11db, 0x8f34,
173 std::array<uint8_t, 6>{{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}};
174// Loudness Enhancer effect is required by CDD, but only the type is fixed.
175// This is the same UUID as AudioEffect.EFFECT_TYPE_LOUDNESS_ENHANCER in Java.
176static const Uuid LOUDNESS_ENHANCER_EFFECT_TYPE = {
177 0xfe3199be, 0xaed0, 0x413f, 0x87bb,
178 std::array<uint8_t, 6>{{0x11, 0x26, 0x0e, 0xb6, 0x3c, 0xf1}}};
179
180// The main test class for Audio Effect HIDL HAL.
181class AudioEffectHidlTest : public ::testing::VtsHalHidlTargetTestBase {
182 public:
183 void SetUp() override {
184 effectsFactory =
185 ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>();
186 ASSERT_NE(nullptr, effectsFactory.get());
187
188 findAndCreateEffect(getEffectType());
189 ASSERT_NE(nullptr, effect.get());
190
191 Return<Result> ret = effect->init();
192 ASSERT_TRUE(ret.isOk());
193 ASSERT_EQ(Result::OK, ret);
194 }
195
196 void TearDown() override {
197 effect.clear();
198 effectsFactory.clear();
199 }
200
201 protected:
202 static void description(const std::string& description) {
203 RecordProperty("description", description);
204 }
205
206 virtual Uuid getEffectType() { return EQUALIZER_EFFECT_TYPE; }
207
208 void findAndCreateEffect(const Uuid& type);
209 void findEffectInstance(const Uuid& type, Uuid* uuid);
210 void getChannelCount(uint32_t* channelCount);
211
212 sp<IEffectsFactory> effectsFactory;
213 sp<IEffect> effect;
214};
215
216void AudioEffectHidlTest::findAndCreateEffect(const Uuid& type) {
217 Uuid effectUuid;
218 findEffectInstance(type, &effectUuid);
219 Return<void> ret = effectsFactory->createEffect(
220 effectUuid, 1 /*session*/, 1 /*ioHandle*/,
221 [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
222 if (r == Result::OK) {
223 effect = result;
224 }
225 });
226 ASSERT_TRUE(ret.isOk());
227}
228
229void AudioEffectHidlTest::findEffectInstance(const Uuid& type, Uuid* uuid) {
230 bool effectFound = false;
231 Return<void> ret = effectsFactory->getAllDescriptors(
232 [&](Result r, const hidl_vec<EffectDescriptor>& result) {
233 if (r == Result::OK) {
234 for (const auto& desc : result) {
235 if (desc.type == type) {
236 effectFound = true;
237 *uuid = desc.uuid;
238 break;
239 }
240 }
241 }
242 });
243 ASSERT_TRUE(ret.isOk());
244 ASSERT_TRUE(effectFound);
245}
246
247void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) {
248 Result retval;
249 EffectConfig currentConfig;
250 Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
251 retval = r;
252 if (r == Result::OK) {
253 currentConfig = conf;
254 }
255 });
256 ASSERT_TRUE(ret.isOk());
257 ASSERT_EQ(Result::OK, retval);
258 ASSERT_TRUE(audio_channel_mask_is_valid(
259 static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels)));
260 *channelCount = audio_channel_count_from_out_mask(
261 static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels));
262}
263
264TEST_F(AudioEffectHidlTest, Close) {
265 description("Verify that an effect can be closed");
266 Return<Result> ret = effect->close();
267 EXPECT_TRUE(ret.isOk());
268 EXPECT_EQ(Result::OK, ret);
269}
270
271TEST_F(AudioEffectHidlTest, GetDescriptor) {
272 description(
273 "Verify that an effect can return its own descriptor via GetDescriptor");
274 Result retval = Result::NOT_INITIALIZED;
275 Uuid actualType;
276 Return<void> ret =
277 effect->getDescriptor([&](Result r, const EffectDescriptor& desc) {
278 retval = r;
279 if (r == Result::OK) {
280 actualType = desc.type;
281 }
282 });
283 EXPECT_TRUE(ret.isOk());
284 EXPECT_EQ(Result::OK, retval);
285 EXPECT_EQ(getEffectType(), actualType);
286}
287
288TEST_F(AudioEffectHidlTest, GetSetConfig) {
289 description(
290 "Verify that it is possible to manipulate effect config via Get / "
291 "SetConfig");
292 Result retval = Result::NOT_INITIALIZED;
293 EffectConfig currentConfig;
294 Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
295 retval = r;
296 if (r == Result::OK) {
297 currentConfig = conf;
298 }
299 });
300 EXPECT_TRUE(ret.isOk());
301 EXPECT_EQ(Result::OK, retval);
302 Return<Result> ret2 = effect->setConfig(currentConfig, nullptr, nullptr);
303 EXPECT_TRUE(ret2.isOk());
304 EXPECT_EQ(Result::OK, ret2);
305}
306
307TEST_F(AudioEffectHidlTest, GetConfigReverse) {
308 description("Verify that GetConfigReverse does not crash");
309 Return<void> ret =
310 effect->getConfigReverse([&](Result, const EffectConfig&) {});
311 EXPECT_TRUE(ret.isOk());
312}
313
314TEST_F(AudioEffectHidlTest, GetSupportedAuxChannelsConfigs) {
315 description("Verify that GetSupportedAuxChannelsConfigs does not crash");
316 Return<void> ret = effect->getSupportedAuxChannelsConfigs(
317 0, [&](Result, const hidl_vec<EffectAuxChannelsConfig>&) {});
318 EXPECT_TRUE(ret.isOk());
319}
320
321TEST_F(AudioEffectHidlTest, GetAuxChannelsConfig) {
322 description("Verify that GetAuxChannelsConfig does not crash");
323 Return<void> ret = effect->getAuxChannelsConfig(
324 [&](Result, const EffectAuxChannelsConfig&) {});
325 EXPECT_TRUE(ret.isOk());
326}
327
328TEST_F(AudioEffectHidlTest, SetAuxChannelsConfig) {
329 description("Verify that SetAuxChannelsConfig does not crash");
330 Return<Result> ret = effect->setAuxChannelsConfig(EffectAuxChannelsConfig());
331 EXPECT_TRUE(ret.isOk());
332}
333
334// Not generated automatically because AudioBuffer contains
335// instances of hidl_memory which can't be compared properly
336// in general case due to presence of handles.
337//
338// However, in this particular case, handles must not present
339// thus comparison is possible.
340//
341// operator== must be defined in the same namespace as the structures.
342namespace android {
343namespace hardware {
344namespace audio {
345namespace effect {
346namespace V4_0 {
347inline bool operator==(const AudioBuffer& lhs, const AudioBuffer& rhs) {
348 return lhs.id == rhs.id && lhs.frameCount == rhs.frameCount &&
349 lhs.data.handle() == nullptr && rhs.data.handle() == nullptr;
350}
351
352inline bool operator==(const EffectBufferConfig& lhs,
353 const EffectBufferConfig& rhs) {
354 return lhs.buffer == rhs.buffer && lhs.samplingRateHz == rhs.samplingRateHz &&
355 lhs.channels == rhs.channels && lhs.format == rhs.format &&
356 lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask;
357}
358
359inline bool operator==(const EffectConfig& lhs, const EffectConfig& rhs) {
360 return lhs.inputCfg == rhs.inputCfg && lhs.outputCfg == rhs.outputCfg;
361}
362} // namespace V4_0
363} // namespace effect
364} // namespace audio
365} // namespace hardware
366} // namespace android
367
368TEST_F(AudioEffectHidlTest, Reset) {
369 description("Verify that Reset preserves effect configuration");
370 Result retval = Result::NOT_INITIALIZED;
371 EffectConfig originalConfig;
372 Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
373 retval = r;
374 if (r == Result::OK) {
375 originalConfig = conf;
376 }
377 });
378 ASSERT_TRUE(ret.isOk());
379 ASSERT_EQ(Result::OK, retval);
380 Return<Result> ret2 = effect->reset();
381 EXPECT_TRUE(ret2.isOk());
382 EXPECT_EQ(Result::OK, ret2);
383 EffectConfig configAfterReset;
384 ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
385 retval = r;
386 if (r == Result::OK) {
387 configAfterReset = conf;
388 }
389 });
390 EXPECT_EQ(originalConfig, configAfterReset);
391}
392
393TEST_F(AudioEffectHidlTest, DisableEnableDisable) {
394 description("Verify Disable -> Enable -> Disable sequence for an effect");
395 Return<Result> ret = effect->disable();
396 EXPECT_TRUE(ret.isOk());
397 EXPECT_EQ(Result::INVALID_ARGUMENTS, ret);
398 ret = effect->enable();
399 EXPECT_TRUE(ret.isOk());
400 EXPECT_EQ(Result::OK, ret);
401 ret = effect->disable();
402 EXPECT_TRUE(ret.isOk());
403 EXPECT_EQ(Result::OK, ret);
404}
405
406TEST_F(AudioEffectHidlTest, SetDevice) {
407 description("Verify that SetDevice works for an output chain effect");
408 Return<Result> ret = effect->setDevice(mkBitfield(AudioDevice::OUT_SPEAKER));
409 EXPECT_TRUE(ret.isOk());
410 EXPECT_EQ(Result::OK, ret);
411}
412
413TEST_F(AudioEffectHidlTest, SetAndGetVolume) {
414 description("Verify that SetAndGetVolume method works for an effect");
415 uint32_t channelCount;
416 getChannelCount(&channelCount);
417 hidl_vec<uint32_t> volumes;
418 volumes.resize(channelCount);
419 for (uint32_t i = 0; i < channelCount; ++i) {
420 volumes[i] = 0;
421 }
422 Result retval = Result::NOT_INITIALIZED;
423 Return<void> ret = effect->setAndGetVolume(
424 volumes, [&](Result r, const hidl_vec<uint32_t>&) { retval = r; });
425 EXPECT_TRUE(ret.isOk());
426 EXPECT_EQ(Result::OK, retval);
427}
428
429TEST_F(AudioEffectHidlTest, VolumeChangeNotification) {
430 description("Verify that effect accepts VolumeChangeNotification");
431 uint32_t channelCount;
432 getChannelCount(&channelCount);
433 hidl_vec<uint32_t> volumes;
434 volumes.resize(channelCount);
435 for (uint32_t i = 0; i < channelCount; ++i) {
436 volumes[i] = 0;
437 }
438 Return<Result> ret = effect->volumeChangeNotification(volumes);
439 EXPECT_TRUE(ret.isOk());
440 EXPECT_EQ(Result::OK, ret);
441}
442
443TEST_F(AudioEffectHidlTest, SetAudioMode) {
444 description("Verify that SetAudioMode works for an effect");
445 Return<Result> ret = effect->setAudioMode(AudioMode::NORMAL);
446 EXPECT_TRUE(ret.isOk());
447 EXPECT_EQ(Result::OK, ret);
448}
449
450TEST_F(AudioEffectHidlTest, SetConfigReverse) {
451 description("Verify that SetConfigReverse does not crash");
452 Return<Result> ret =
453 effect->setConfigReverse(EffectConfig(), nullptr, nullptr);
454 EXPECT_TRUE(ret.isOk());
455}
456
457TEST_F(AudioEffectHidlTest, SetInputDevice) {
458 description("Verify that SetInputDevice does not crash");
459 Return<Result> ret = effect->setInputDevice(mkBitfield(AudioDevice::IN_BUILTIN_MIC));
460 EXPECT_TRUE(ret.isOk());
461}
462
463TEST_F(AudioEffectHidlTest, SetAudioSource) {
464 description("Verify that SetAudioSource does not crash");
465 Return<Result> ret = effect->setAudioSource(AudioSource::MIC);
466 EXPECT_TRUE(ret.isOk());
467}
468
469TEST_F(AudioEffectHidlTest, Offload) {
470 description("Verify that calling Offload method does not crash");
471 EffectOffloadParameter offloadParam;
472 offloadParam.isOffload = false;
473 offloadParam.ioHandle =
474 static_cast<int>(AudioHandleConsts::AUDIO_IO_HANDLE_NONE);
475 Return<Result> ret = effect->offload(offloadParam);
476 EXPECT_TRUE(ret.isOk());
477}
478
479TEST_F(AudioEffectHidlTest, PrepareForProcessing) {
480 description("Verify that PrepareForProcessing method works for an effect");
481 Result retval = Result::NOT_INITIALIZED;
482 Return<void> ret = effect->prepareForProcessing(
483 [&](Result r, const MQDescriptorSync<Result>&) { retval = r; });
484 EXPECT_TRUE(ret.isOk());
485 EXPECT_EQ(Result::OK, retval);
486}
487
488TEST_F(AudioEffectHidlTest, SetProcessBuffers) {
489 description("Verify that SetProcessBuffers works for an effect");
490 sp<IAllocator> ashmem = IAllocator::getService("ashmem");
491 ASSERT_NE(nullptr, ashmem.get());
492 bool success = false;
493 AudioBuffer buffer;
494 Return<void> ret =
495 ashmem->allocate(1024, [&](bool s, const hidl_memory& memory) {
496 success = s;
497 if (s) {
498 buffer.data = memory;
499 }
500 });
501 ASSERT_TRUE(ret.isOk());
502 ASSERT_TRUE(success);
503 Return<Result> ret2 = effect->setProcessBuffers(buffer, buffer);
504 EXPECT_TRUE(ret2.isOk());
505 EXPECT_EQ(Result::OK, ret2);
506}
507
508TEST_F(AudioEffectHidlTest, Command) {
509 description("Verify that Command does not crash");
510 Return<void> ret = effect->command(0, hidl_vec<uint8_t>(), 0,
511 [&](int32_t, const hidl_vec<uint8_t>&) {});
512 EXPECT_TRUE(ret.isOk());
513}
514
515TEST_F(AudioEffectHidlTest, SetParameter) {
516 description("Verify that SetParameter does not crash");
517 Return<Result> ret =
518 effect->setParameter(hidl_vec<uint8_t>(), hidl_vec<uint8_t>());
519 EXPECT_TRUE(ret.isOk());
520}
521
522TEST_F(AudioEffectHidlTest, GetParameter) {
523 description("Verify that GetParameter does not crash");
524 Return<void> ret = effect->getParameter(
525 hidl_vec<uint8_t>(), 0, [&](Result, const hidl_vec<uint8_t>&) {});
526 EXPECT_TRUE(ret.isOk());
527}
528
529TEST_F(AudioEffectHidlTest, GetSupportedConfigsForFeature) {
530 description("Verify that GetSupportedConfigsForFeature does not crash");
531 Return<void> ret = effect->getSupportedConfigsForFeature(
532 0, 0, 0, [&](Result, uint32_t, const hidl_vec<uint8_t>&) {});
533 EXPECT_TRUE(ret.isOk());
534}
535
536TEST_F(AudioEffectHidlTest, GetCurrentConfigForFeature) {
537 description("Verify that GetCurrentConfigForFeature does not crash");
538 Return<void> ret = effect->getCurrentConfigForFeature(
539 0, 0, [&](Result, const hidl_vec<uint8_t>&) {});
540 EXPECT_TRUE(ret.isOk());
541}
542
543TEST_F(AudioEffectHidlTest, SetCurrentConfigForFeature) {
544 description("Verify that SetCurrentConfigForFeature does not crash");
545 Return<Result> ret =
546 effect->setCurrentConfigForFeature(0, hidl_vec<uint8_t>());
547 EXPECT_TRUE(ret.isOk());
548}
549
550
551// The main test class for Equalizer Audio Effect HIDL HAL.
552class EqualizerAudioEffectHidlTest : public AudioEffectHidlTest {
553 public:
554 void SetUp() override {
555 AudioEffectHidlTest::SetUp();
556 equalizer = IEqualizerEffect::castFrom(effect);
557 ASSERT_NE(nullptr, equalizer.get());
558 }
559
560 protected:
561 Uuid getEffectType() override { return EQUALIZER_EFFECT_TYPE; }
562 void getNumBands(uint16_t* numBands);
563 void getLevelRange(int16_t* minLevel, int16_t* maxLevel);
564 void getBandFrequencyRange(uint16_t band, uint32_t* minFreq,
565 uint32_t* centerFreq, uint32_t* maxFreq);
566 void getPresetCount(size_t* count);
567
568 sp<IEqualizerEffect> equalizer;
569};
570
571void EqualizerAudioEffectHidlTest::getNumBands(uint16_t* numBands) {
572 Result retval = Result::NOT_INITIALIZED;
573 Return<void> ret = equalizer->getNumBands([&](Result r, uint16_t b) {
574 retval = r;
575 if (retval == Result::OK) {
576 *numBands = b;
577 }
578 });
579 ASSERT_TRUE(ret.isOk());
580 ASSERT_EQ(Result::OK, retval);
581}
582
583void EqualizerAudioEffectHidlTest::getLevelRange(int16_t* minLevel,
584 int16_t* maxLevel) {
585 Result retval = Result::NOT_INITIALIZED;
586 Return<void> ret =
587 equalizer->getLevelRange([&](Result r, int16_t min, int16_t max) {
588 retval = r;
589 if (retval == Result::OK) {
590 *minLevel = min;
591 *maxLevel = max;
592 }
593 });
594 ASSERT_TRUE(ret.isOk());
595 ASSERT_EQ(Result::OK, retval);
596}
597
598void EqualizerAudioEffectHidlTest::getBandFrequencyRange(uint16_t band,
599 uint32_t* minFreq,
600 uint32_t* centerFreq,
601 uint32_t* maxFreq) {
602 Result retval = Result::NOT_INITIALIZED;
603 Return<void> ret = equalizer->getBandFrequencyRange(
604 band, [&](Result r, uint32_t min, uint32_t max) {
605 retval = r;
606 if (retval == Result::OK) {
607 *minFreq = min;
608 *maxFreq = max;
609 }
610 });
611 ASSERT_TRUE(ret.isOk());
612 ASSERT_EQ(Result::OK, retval);
613 ret = equalizer->getBandCenterFrequency(band, [&](Result r, uint32_t center) {
614 retval = r;
615 if (retval == Result::OK) {
616 *centerFreq = center;
617 }
618 });
619 ASSERT_TRUE(ret.isOk());
620 ASSERT_EQ(Result::OK, retval);
621}
622
623void EqualizerAudioEffectHidlTest::getPresetCount(size_t* count) {
624 Result retval = Result::NOT_INITIALIZED;
625 Return<void> ret = equalizer->getPresetNames(
626 [&](Result r, const hidl_vec<hidl_string>& names) {
627 retval = r;
628 if (retval == Result::OK) {
629 *count = names.size();
630 }
631 });
632 ASSERT_TRUE(ret.isOk());
633 ASSERT_EQ(Result::OK, retval);
634}
635
636TEST_F(EqualizerAudioEffectHidlTest, GetNumBands) {
637 description("Verify that Equalizer effect reports at least one band");
638 uint16_t numBands = 0;
639 getNumBands(&numBands);
640 EXPECT_GT(numBands, 0);
641}
642
643TEST_F(EqualizerAudioEffectHidlTest, GetLevelRange) {
644 description("Verify that Equalizer effect reports adequate band level range");
645 int16_t minLevel = 0x7fff, maxLevel = 0;
646 getLevelRange(&minLevel, &maxLevel);
647 EXPECT_GT(maxLevel, minLevel);
648}
649
650TEST_F(EqualizerAudioEffectHidlTest, GetSetBandLevel) {
651 description(
652 "Verify that manipulating band levels works for Equalizer effect");
653 uint16_t numBands = 0;
654 getNumBands(&numBands);
655 ASSERT_GT(numBands, 0);
656 int16_t levels[3]{0x7fff, 0, 0};
657 getLevelRange(&levels[0], &levels[2]);
658 ASSERT_GT(levels[2], levels[0]);
659 levels[1] = (levels[2] + levels[0]) / 2;
660 for (uint16_t i = 0; i < numBands; ++i) {
661 for (size_t j = 0; j < ARRAY_SIZE(levels); ++j) {
662 Return<Result> ret = equalizer->setBandLevel(i, levels[j]);
663 EXPECT_TRUE(ret.isOk());
664 EXPECT_EQ(Result::OK, ret);
665 Result retval = Result::NOT_INITIALIZED;
666 int16_t actualLevel;
667 Return<void> ret2 = equalizer->getBandLevel(i, [&](Result r, int16_t l) {
668 retval = r;
669 if (retval == Result::OK) {
670 actualLevel = l;
671 }
672 });
673 EXPECT_TRUE(ret2.isOk());
674 EXPECT_EQ(Result::OK, retval);
675 EXPECT_EQ(levels[j], actualLevel);
676 }
677 }
678}
679
680TEST_F(EqualizerAudioEffectHidlTest, GetBandCenterFrequencyAndRange) {
681 description(
682 "Verify that Equalizer effect reports adequate band frequency range");
683 uint16_t numBands = 0;
684 getNumBands(&numBands);
685 ASSERT_GT(numBands, 0);
686 for (uint16_t i = 0; i < numBands; ++i) {
687 uint32_t minFreq = 0xffffffff, centerFreq = 0xffffffff,
688 maxFreq = 0xffffffff;
689 getBandFrequencyRange(i, &minFreq, &centerFreq, &maxFreq);
690 // Note: NXP legacy implementation reports "1" as upper bound for last band,
691 // so this check fails.
692 EXPECT_GE(maxFreq, centerFreq);
693 EXPECT_GE(centerFreq, minFreq);
694 }
695}
696
697TEST_F(EqualizerAudioEffectHidlTest, GetBandForFrequency) {
698 description(
699 "Verify that Equalizer effect supports GetBandForFrequency correctly");
700 uint16_t numBands = 0;
701 getNumBands(&numBands);
702 ASSERT_GT(numBands, 0);
703 for (uint16_t i = 0; i < numBands; ++i) {
704 uint32_t freqs[3]{0, 0, 0};
705 getBandFrequencyRange(i, &freqs[0], &freqs[1], &freqs[2]);
706 // NXP legacy implementation reports "1" as upper bound for last band, some
707 // of the checks fail.
708 for (size_t j = 0; j < ARRAY_SIZE(freqs); ++j) {
709 if (j == 0) {
710 freqs[j]++;
711 } // Min frequency is an open interval.
712 Result retval = Result::NOT_INITIALIZED;
713 uint16_t actualBand = numBands + 1;
714 Return<void> ret =
715 equalizer->getBandForFrequency(freqs[j], [&](Result r, uint16_t b) {
716 retval = r;
717 if (retval == Result::OK) {
718 actualBand = b;
719 }
720 });
721 EXPECT_TRUE(ret.isOk());
722 EXPECT_EQ(Result::OK, retval);
723 EXPECT_EQ(i, actualBand) << "Frequency: " << freqs[j];
724 }
725 }
726}
727
728TEST_F(EqualizerAudioEffectHidlTest, GetPresetNames) {
729 description("Verify that Equalizer effect reports at least one preset");
730 size_t presetCount;
731 getPresetCount(&presetCount);
732 EXPECT_GT(presetCount, 0u);
733}
734
735TEST_F(EqualizerAudioEffectHidlTest, GetSetCurrentPreset) {
736 description(
737 "Verify that manipulating the current preset for Equalizer effect");
738 size_t presetCount;
739 getPresetCount(&presetCount);
740 ASSERT_GT(presetCount, 0u);
741 for (uint16_t i = 0; i < presetCount; ++i) {
742 Return<Result> ret = equalizer->setCurrentPreset(i);
743 EXPECT_TRUE(ret.isOk());
744 EXPECT_EQ(Result::OK, ret);
745 Result retval = Result::NOT_INITIALIZED;
746 uint16_t actualPreset = 0xffff;
747 Return<void> ret2 = equalizer->getCurrentPreset([&](Result r, uint16_t p) {
748 retval = r;
749 if (retval == Result::OK) {
750 actualPreset = p;
751 }
752 });
753 EXPECT_TRUE(ret2.isOk());
754 EXPECT_EQ(Result::OK, retval);
755 EXPECT_EQ(i, actualPreset);
756 }
757}
758
759TEST_F(EqualizerAudioEffectHidlTest, GetSetAllProperties) {
760 description(
761 "Verify that setting band levels and presets works via Get / "
762 "SetAllProperties for Equalizer effect");
763 using AllProperties =
764 android::hardware::audio::effect::V4_0::IEqualizerEffect::AllProperties;
765 uint16_t numBands = 0;
766 getNumBands(&numBands);
767 ASSERT_GT(numBands, 0);
768 AllProperties props;
769 props.bandLevels.resize(numBands);
770 for (size_t i = 0; i < numBands; ++i) {
771 props.bandLevels[i] = 0;
772 }
773
774 AllProperties actualProps;
775 Result retval = Result::NOT_INITIALIZED;
776
777 // Verify setting of the band levels via properties.
778 props.curPreset = -1;
779 Return<Result> ret = equalizer->setAllProperties(props);
780 EXPECT_TRUE(ret.isOk());
781 EXPECT_EQ(Result::OK, ret);
782 Return<void> ret2 =
783 equalizer->getAllProperties([&](Result r, AllProperties p) {
784 retval = r;
785 if (retval == Result::OK) {
786 actualProps = p;
787 }
788 });
789 EXPECT_TRUE(ret2.isOk());
790 EXPECT_EQ(Result::OK, retval);
791 EXPECT_EQ(props.bandLevels, actualProps.bandLevels);
792
793 // Verify setting of the current preset via properties.
794 props.curPreset = 0; // Assuming there is at least one preset.
795 ret = equalizer->setAllProperties(props);
796 EXPECT_TRUE(ret.isOk());
797 EXPECT_EQ(Result::OK, ret);
798 ret2 = equalizer->getAllProperties([&](Result r, AllProperties p) {
799 retval = r;
800 if (retval == Result::OK) {
801 actualProps = p;
802 }
803 });
804 EXPECT_TRUE(ret2.isOk());
805 EXPECT_EQ(Result::OK, retval);
806 EXPECT_EQ(props.curPreset, actualProps.curPreset);
807}
808
809// The main test class for Equalizer Audio Effect HIDL HAL.
810class LoudnessEnhancerAudioEffectHidlTest : public AudioEffectHidlTest {
811 public:
812 void SetUp() override {
813 AudioEffectHidlTest::SetUp();
814 enhancer = ILoudnessEnhancerEffect::castFrom(effect);
815 ASSERT_NE(nullptr, enhancer.get());
816 }
817
818 protected:
819 Uuid getEffectType() override { return LOUDNESS_ENHANCER_EFFECT_TYPE; }
820
821 sp<ILoudnessEnhancerEffect> enhancer;
822};
823
824TEST_F(LoudnessEnhancerAudioEffectHidlTest, GetSetTargetGain) {
825 description(
826 "Verify that manipulating the target gain works for Loudness Enhancer "
827 "effect");
828 const int32_t gain = 100;
829 Return<Result> ret = enhancer->setTargetGain(gain);
830 EXPECT_TRUE(ret.isOk());
831 EXPECT_EQ(Result::OK, ret);
832 int32_t actualGain = 0;
833 Result retval;
834 Return<void> ret2 = enhancer->getTargetGain([&](Result r, int32_t g) {
835 retval = r;
836 if (retval == Result::OK) {
837 actualGain = g;
838 }
839 });
840 EXPECT_TRUE(ret2.isOk());
841 EXPECT_EQ(Result::OK, retval);
842 EXPECT_EQ(gain, actualGain);
843}
844
845int main(int argc, char** argv) {
846 ::testing::AddGlobalTestEnvironment(AudioEffectsFactoryHidlEnvironment::Instance());
847 ::testing::InitGoogleTest(&argc, argv);
848 AudioEffectsFactoryHidlEnvironment::Instance()->init(&argc, argv);
849 int status = RUN_ALL_TESTS();
850 LOG(INFO) << "Test result = " << status;
851 return status;
852}
diff --git a/automotive/vehicle/2.0/Android.bp b/automotive/vehicle/2.0/Android.bp
index bdc44efe..902a4e83 100644
--- a/automotive/vehicle/2.0/Android.bp
+++ b/automotive/vehicle/2.0/Android.bp
@@ -48,6 +48,7 @@ hidl_interface {
48 "VehicleHvacFanDirection", 48 "VehicleHvacFanDirection",
49 "VehicleHwKeyInputAction", 49 "VehicleHwKeyInputAction",
50 "VehicleIgnitionState", 50 "VehicleIgnitionState",
51 "VehicleOilLevel",
51 "VehiclePropConfig", 52 "VehiclePropConfig",
52 "VehiclePropValue", 53 "VehiclePropValue",
53 "VehicleProperty", 54 "VehicleProperty",
diff --git a/camera/device/3.4/Android.bp b/camera/device/3.4/Android.bp
index 87acd255..2c649baa 100644
--- a/camera/device/3.4/Android.bp
+++ b/camera/device/3.4/Android.bp
@@ -25,7 +25,6 @@ hidl_interface {
25 "HalStreamConfiguration", 25 "HalStreamConfiguration",
26 "PhysicalCameraMetadata", 26 "PhysicalCameraMetadata",
27 "PhysicalCameraSetting", 27 "PhysicalCameraSetting",
28 "RequestTemplate",
29 "Stream", 28 "Stream",
30 "StreamConfiguration", 29 "StreamConfiguration",
31 ], 30 ],
diff --git a/camera/metadata/3.3/types.hal b/camera/metadata/3.3/types.hal
index ba9eead1..4f3f6781 100644
--- a/camera/metadata/3.3/types.hal
+++ b/camera/metadata/3.3/types.hal
@@ -74,6 +74,17 @@ enum CameraMetadataTag : @3.2::CameraMetadataTag {
74 */ 74 */
75 ANDROID_LENS_POSE_REFERENCE = android.hardware.camera.metadata@3.2::CameraMetadataTag:ANDROID_LENS_END, 75 ANDROID_LENS_POSE_REFERENCE = android.hardware.camera.metadata@3.2::CameraMetadataTag:ANDROID_LENS_END,
76 76
77 /** android.lens.distortion [dynamic, float[], public]
78 *
79 * <p>The correction coefficients to correct for this camera device's
80 * radial and tangential lens distortion.</p>
81 * <p>Replaces the deprecated ANDROID_LENS_RADIAL_DISTORTION field, which was
82 * inconsistently defined.</p>
83 *
84 * @see ANDROID_LENS_RADIAL_DISTORTION
85 */
86 ANDROID_LENS_DISTORTION,
87
77 ANDROID_LENS_END_3_3, 88 ANDROID_LENS_END_3_3,
78 89
79 /** android.request.availableSessionKeys [static, int32[], ndk_public] 90 /** android.request.availableSessionKeys [static, int32[], ndk_public]
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index 61a6608b..497071d4 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -182,7 +182,6 @@
182 <interface> 182 <interface>
183 <name>IKeymasterDevice</name> 183 <name>IKeymasterDevice</name>
184 <instance>default</instance> 184 <instance>default</instance>
185 <!-- TODO: strongbox here? -->
186 </interface> 185 </interface>
187 </hal> 186 </hal>
188 <hal format="hidl" optional="true"> 187 <hal format="hidl" optional="true">
diff --git a/current.txt b/current.txt
index b3534033..48b38777 100644
--- a/current.txt
+++ b/current.txt
@@ -268,7 +268,7 @@ d5de64e66b95f135dd42492250a309134b8227203ef3524440798c66b6f5a392 android.hardwar
268888ac906461327fa0bd93854d5109be8c292a33afdb467164826970a8bd5b789 android.hardware.audio@4.0::IStreamOut 268888ac906461327fa0bd93854d5109be8c292a33afdb467164826970a8bd5b789 android.hardware.audio@4.0::IStreamOut
26915f6ae78e73344c8e7d68847ef03caec64fcd9f951bbcf59957d1712c247fcff android.hardware.audio@4.0::IStreamOutCallback 26915f6ae78e73344c8e7d68847ef03caec64fcd9f951bbcf59957d1712c247fcff android.hardware.audio@4.0::IStreamOutCallback
270e8abfc73b7f3c2095ea4fad83b5f42bced4315de2abcc3199376af880dac451b android.hardware.audio@4.0::types 270e8abfc73b7f3c2095ea4fad83b5f42bced4315de2abcc3199376af880dac451b android.hardware.audio@4.0::types
271dac6018ece5af342708766287a2de2e7f3bd7e60f373dc2dddc4d4d1554e1b35 android.hardware.audio.common@4.0::types 2715d47a2ad2c136b8aba067dd45bb10d0ad390dd76340764154f580658f98f4fe6 android.hardware.audio.common@4.0::types
272b04b6b364938b80008e61fa2e318bc299622433e57c2e1f6cfba332a3f6e3f15 android.hardware.audio.effect@4.0::IAcousticEchoCancelerEffect 272b04b6b364938b80008e61fa2e318bc299622433e57c2e1f6cfba332a3f6e3f15 android.hardware.audio.effect@4.0::IAcousticEchoCancelerEffect
2731c17d4ece5c8ba3f7a646a305ee0dd109b0d51372e1bd585812e513cd40e1852 android.hardware.audio.effect@4.0::IAutomaticGainControlEffect 2731c17d4ece5c8ba3f7a646a305ee0dd109b0d51372e1bd585812e513cd40e1852 android.hardware.audio.effect@4.0::IAutomaticGainControlEffect
27434174259fe6fbb1bb14e7103e097f2f25529271a676687845b2f55d6d0d9d617 android.hardware.audio.effect@4.0::IBassBoostEffect 27434174259fe6fbb1bb14e7103e097f2f25529271a676687845b2f55d6d0d9d617 android.hardware.audio.effect@4.0::IBassBoostEffect
@@ -307,7 +307,7 @@ eacf4e7491fc52c4db90898faddf25ec7bc72501b07ae8737434c47cb845128c android.hardwar
3074fb0725c36ed4f77a42b42e3f18d8b5f7919cb62b90098b23143a555aa7dd96d android.hardware.camera.device@3.4::ICameraDeviceCallback 3074fb0725c36ed4f77a42b42e3f18d8b5f7919cb62b90098b23143a555aa7dd96d android.hardware.camera.device@3.4::ICameraDeviceCallback
308812fa66aa10ba0cba27cfddc2fd7f0ee27a8ab65a1f15aa79fdad97d403e6a14 android.hardware.camera.device@3.4::ICameraDeviceSession 308812fa66aa10ba0cba27cfddc2fd7f0ee27a8ab65a1f15aa79fdad97d403e6a14 android.hardware.camera.device@3.4::ICameraDeviceSession
309cc288f1f78d1e643eb3d3dbc16e1401d44033d8e6856761f5156814a29986ec7 android.hardware.camera.device@3.4::types 309cc288f1f78d1e643eb3d3dbc16e1401d44033d8e6856761f5156814a29986ec7 android.hardware.camera.device@3.4::types
3106e853354199fb5773357210c7ca0f183631d48e83ea88a9be3921b51c1c0afc6 android.hardware.camera.metadata@3.3::types 31026462f5a29bef30485f9264115e79e5f5eb6234951dfeb47424709a1b8936030 android.hardware.camera.metadata@3.3::types
3111a46aeae45b7a0e47f79b7207300532986f9d9cd7060779afc7a529f54d712ab android.hardware.confirmationui@1.0::IConfirmationResultCallback 3111a46aeae45b7a0e47f79b7207300532986f9d9cd7060779afc7a529f54d712ab android.hardware.confirmationui@1.0::IConfirmationResultCallback
3126d8347ff3cd7de471065ac3e8e68385073630cdeebe9f8fa58cb91cf44436c95 android.hardware.confirmationui@1.0::IConfirmationUI 3126d8347ff3cd7de471065ac3e8e68385073630cdeebe9f8fa58cb91cf44436c95 android.hardware.confirmationui@1.0::IConfirmationUI
313a3ff916784dce87a56c757ab5c86433f0cdf562280999a5f978a6e8a0f3f19e7 android.hardware.confirmationui@1.0::types 313a3ff916784dce87a56c757ab5c86433f0cdf562280999a5f978a6e8a0f3f19e7 android.hardware.confirmationui@1.0::types
diff --git a/drm/1.1/Android.bp b/drm/1.1/Android.bp
index ed8196ec..dba3e427 100644
--- a/drm/1.1/Android.bp
+++ b/drm/1.1/Android.bp
@@ -17,8 +17,10 @@ hidl_interface {
17 "android.hidl.base@1.0", 17 "android.hidl.base@1.0",
18 ], 18 ],
19 types: [ 19 types: [
20 "DrmMetricGroup",
20 "HdcpLevel", 21 "HdcpLevel",
21 "KeyRequestType", 22 "KeyRequestType",
23 "SecureStopRelease",
22 "SecurityLevel", 24 "SecurityLevel",
23 ], 25 ],
24 gen_java: false, 26 gen_java: false,
diff --git a/graphics/mapper/2.1/Android.bp b/graphics/mapper/2.1/Android.bp
index d917e59a..8527d3d5 100644
--- a/graphics/mapper/2.1/Android.bp
+++ b/graphics/mapper/2.1/Android.bp
@@ -11,6 +11,7 @@ hidl_interface {
11 "IMapper.hal", 11 "IMapper.hal",
12 ], 12 ],
13 interfaces: [ 13 interfaces: [
14 "android.hardware.graphics.common@1.0",
14 "android.hardware.graphics.common@1.1", 15 "android.hardware.graphics.common@1.1",
15 "android.hardware.graphics.mapper@2.0", 16 "android.hardware.graphics.mapper@2.0",
16 "android.hidl.base@1.0", 17 "android.hidl.base@1.0",
diff --git a/neuralnetworks/1.1/Android.bp b/neuralnetworks/1.1/Android.bp
index 9365d4ea..81bcef31 100644
--- a/neuralnetworks/1.1/Android.bp
+++ b/neuralnetworks/1.1/Android.bp
@@ -15,6 +15,7 @@ hidl_interface {
15 "android.hidl.base@1.0", 15 "android.hidl.base@1.0",
16 ], 16 ],
17 types: [ 17 types: [
18 "Capabilities",
18 "Model", 19 "Model",
19 "Operation", 20 "Operation",
20 "OperationType", 21 "OperationType",