Loading audio/6.0/IDevice.hal +2 −1 Original line number Diff line number Diff line Loading @@ -260,7 +260,8 @@ interface IDevice { /** * Returns an array with available microphones in device. * * @return retval INVALID_STATE if the call is not successful, * @return retval NOT_SUPPORTED if there are no microphones on this device * INVALID_STATE if the call is not successful, * OK otherwise. * * @return microphones array with microphones info Loading audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp +10 −6 Original line number Diff line number Diff line Loading @@ -18,15 +18,16 @@ TEST_P(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) { doc::test("Calling openDevice(\"primary\") should return the primary device."); if (getDeviceName() != DeviceManager::kPrimaryDevice) { GTEST_SKIP() << "No primary device on this factory"; // returns } struct WaitExecutor { ~WaitExecutor() { DeviceManager::waitForInstanceDestruction(); } } waitExecutor; // Make sure we wait for the device destruction on exiting from the test. Result result; sp<IDevice> baseDevice; ASSERT_OK(getDevicesFactory()->openDevice("primary", returnIn(result, baseDevice))); if (result != Result::OK && isPrimaryDeviceOptional()) { GTEST_SKIP() << "No primary device on this factory"; // returns } ASSERT_OK(result); ASSERT_TRUE(baseDevice != nullptr); Loading @@ -39,10 +40,13 @@ TEST_P(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) { /////////////////////////// get(Active)Microphones /////////////////////////// ////////////////////////////////////////////////////////////////////////////// TEST_P(AudioPrimaryHidlTest, GetMicrophonesTest) { TEST_P(AudioHidlDeviceTest, GetMicrophonesTest) { doc::test("Make sure getMicrophones always succeeds"); hidl_vec<MicrophoneInfo> microphones; ASSERT_OK(getDevice()->getMicrophones(returnIn(res, microphones))); if (res == Result::NOT_SUPPORTED) { GTEST_SKIP() << "getMicrophones is not supported"; // returns } ASSERT_OK(res); if (microphones.size() > 0) { // When there is microphone on the phone, try to open an input stream Loading Loading @@ -120,7 +124,7 @@ TEST_P(AudioPrimaryHidlTest, GetMicrophonesTest) { } } TEST_P(AudioPrimaryHidlTest, SetConnectedState) { TEST_P(AudioHidlDeviceTest, SetConnectedState) { doc::test("Check that the HAL can be notified of device connection and deconnection"); using AD = AudioDevice; for (auto deviceType : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) { Loading @@ -142,7 +146,7 @@ TEST_P(AudioPrimaryHidlTest, SetConnectedState) { // Because there is no way of knowing if the devices were connected before // calling setConnectedState, there is no way to restore the HAL to its // initial state. To workaround this, destroy the HAL at the end of this test. ASSERT_TRUE(DeviceManager::getInstance().resetPrimary(getFactoryName())); ASSERT_TRUE(resetDevice()); } static void testGetDevices(IStream* stream, AudioDevice expectedDevice) { Loading audio/core/all-versions/vts/functional/6.0/AudioPrimaryHidlHalTest.cpp +48 −0 Original line number Diff line number Diff line Loading @@ -16,3 +16,51 @@ // pull in all the <= 5.0 tests #include "5.0/AudioPrimaryHidlHalTest.cpp" const std::vector<DeviceParameter>& getDeviceParametersForFactoryTests() { static std::vector<DeviceParameter> parameters = [] { std::vector<DeviceParameter> result; const auto factories = ::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor); for (const auto& factoryName : factories) { result.emplace_back(factoryName, DeviceManager::getInstance().getPrimary(factoryName) != nullptr ? DeviceManager::kPrimaryDevice : ""); } return result; }(); return parameters; } const std::vector<DeviceParameter>& getDeviceParametersForPrimaryDeviceTests() { static std::vector<DeviceParameter> parameters = [] { std::vector<DeviceParameter> result; const auto primary = std::find_if( getDeviceParameters().begin(), getDeviceParameters().end(), [](const auto& elem) { return std::get<PARAM_DEVICE_NAME>(elem) == DeviceManager::kPrimaryDevice; }); if (primary != getDeviceParameters().end()) result.push_back(*primary); return result; }(); return parameters; } const std::vector<DeviceParameter>& getDeviceParameters() { static std::vector<DeviceParameter> parameters = [] { std::vector<DeviceParameter> result; const auto factories = ::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor); const auto devices = getCachedPolicyConfig().getModulesWithDevicesNames(); result.reserve(devices.size()); for (const auto& factoryName : factories) { for (const auto& deviceName : devices) { if (DeviceManager::getInstance().get(factoryName, deviceName) != nullptr) { result.emplace_back(factoryName, deviceName); } } } return result; }(); return parameters; } audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h +193 −146 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
audio/6.0/IDevice.hal +2 −1 Original line number Diff line number Diff line Loading @@ -260,7 +260,8 @@ interface IDevice { /** * Returns an array with available microphones in device. * * @return retval INVALID_STATE if the call is not successful, * @return retval NOT_SUPPORTED if there are no microphones on this device * INVALID_STATE if the call is not successful, * OK otherwise. * * @return microphones array with microphones info Loading
audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp +10 −6 Original line number Diff line number Diff line Loading @@ -18,15 +18,16 @@ TEST_P(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) { doc::test("Calling openDevice(\"primary\") should return the primary device."); if (getDeviceName() != DeviceManager::kPrimaryDevice) { GTEST_SKIP() << "No primary device on this factory"; // returns } struct WaitExecutor { ~WaitExecutor() { DeviceManager::waitForInstanceDestruction(); } } waitExecutor; // Make sure we wait for the device destruction on exiting from the test. Result result; sp<IDevice> baseDevice; ASSERT_OK(getDevicesFactory()->openDevice("primary", returnIn(result, baseDevice))); if (result != Result::OK && isPrimaryDeviceOptional()) { GTEST_SKIP() << "No primary device on this factory"; // returns } ASSERT_OK(result); ASSERT_TRUE(baseDevice != nullptr); Loading @@ -39,10 +40,13 @@ TEST_P(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) { /////////////////////////// get(Active)Microphones /////////////////////////// ////////////////////////////////////////////////////////////////////////////// TEST_P(AudioPrimaryHidlTest, GetMicrophonesTest) { TEST_P(AudioHidlDeviceTest, GetMicrophonesTest) { doc::test("Make sure getMicrophones always succeeds"); hidl_vec<MicrophoneInfo> microphones; ASSERT_OK(getDevice()->getMicrophones(returnIn(res, microphones))); if (res == Result::NOT_SUPPORTED) { GTEST_SKIP() << "getMicrophones is not supported"; // returns } ASSERT_OK(res); if (microphones.size() > 0) { // When there is microphone on the phone, try to open an input stream Loading Loading @@ -120,7 +124,7 @@ TEST_P(AudioPrimaryHidlTest, GetMicrophonesTest) { } } TEST_P(AudioPrimaryHidlTest, SetConnectedState) { TEST_P(AudioHidlDeviceTest, SetConnectedState) { doc::test("Check that the HAL can be notified of device connection and deconnection"); using AD = AudioDevice; for (auto deviceType : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) { Loading @@ -142,7 +146,7 @@ TEST_P(AudioPrimaryHidlTest, SetConnectedState) { // Because there is no way of knowing if the devices were connected before // calling setConnectedState, there is no way to restore the HAL to its // initial state. To workaround this, destroy the HAL at the end of this test. ASSERT_TRUE(DeviceManager::getInstance().resetPrimary(getFactoryName())); ASSERT_TRUE(resetDevice()); } static void testGetDevices(IStream* stream, AudioDevice expectedDevice) { Loading
audio/core/all-versions/vts/functional/6.0/AudioPrimaryHidlHalTest.cpp +48 −0 Original line number Diff line number Diff line Loading @@ -16,3 +16,51 @@ // pull in all the <= 5.0 tests #include "5.0/AudioPrimaryHidlHalTest.cpp" const std::vector<DeviceParameter>& getDeviceParametersForFactoryTests() { static std::vector<DeviceParameter> parameters = [] { std::vector<DeviceParameter> result; const auto factories = ::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor); for (const auto& factoryName : factories) { result.emplace_back(factoryName, DeviceManager::getInstance().getPrimary(factoryName) != nullptr ? DeviceManager::kPrimaryDevice : ""); } return result; }(); return parameters; } const std::vector<DeviceParameter>& getDeviceParametersForPrimaryDeviceTests() { static std::vector<DeviceParameter> parameters = [] { std::vector<DeviceParameter> result; const auto primary = std::find_if( getDeviceParameters().begin(), getDeviceParameters().end(), [](const auto& elem) { return std::get<PARAM_DEVICE_NAME>(elem) == DeviceManager::kPrimaryDevice; }); if (primary != getDeviceParameters().end()) result.push_back(*primary); return result; }(); return parameters; } const std::vector<DeviceParameter>& getDeviceParameters() { static std::vector<DeviceParameter> parameters = [] { std::vector<DeviceParameter> result; const auto factories = ::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor); const auto devices = getCachedPolicyConfig().getModulesWithDevicesNames(); result.reserve(devices.size()); for (const auto& factoryName : factories) { for (const auto& deviceName : devices) { if (DeviceManager::getInstance().get(factoryName, deviceName) != nullptr) { result.emplace_back(factoryName, deviceName); } } } return result; }(); return parameters; }
audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h +193 −146 File changed.Preview size limit exceeded, changes collapsed. Show changes