Loading audio/7.1/IDevice.hal +12 −0 Original line number Diff line number Diff line Loading @@ -85,4 +85,16 @@ interface IDevice extends @7.0::IDevice { Result retval, IStreamIn inStream, AudioConfig suggestedConfig); /** * Notifies the device module about the connection state of an input/output * device attached to it. The devicePort identifies the device and may also * provide extra information such as raw audio descriptors. * * @param devicePort audio device port. * @param connected whether the device is connected. * @return retval operation completion status. */ setConnectedState_7_1(AudioPort devicePort, bool connected) generates (Result retval); }; audio/core/all-versions/default/Device.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -616,6 +616,21 @@ Return<void> Device::updateAudioPatch(int32_t previousPatch, #endif #if MAJOR_VERSION == 7 && MINOR_VERSION == 1 Return<Result> Device::setConnectedState_7_1(const AudioPort& devicePort, bool connected) { if (version() >= AUDIO_DEVICE_API_VERSION_3_2 && mDevice->set_device_connected_state_v7 != nullptr) { audio_port_v7 halPort; if (status_t status = HidlUtils::audioPortToHal(devicePort, &halPort); status != NO_ERROR) { return analyzeStatus("audioPortToHal", status); } return analyzeStatus("set_device_connected_state_v7", mDevice->set_device_connected_state_v7(mDevice, &halPort, connected)); } return Result::NOT_SUPPORTED; } #endif } // namespace implementation } // namespace CPP_VERSION } // namespace audio Loading audio/core/all-versions/default/include/core/default/Device.h +3 −0 Original line number Diff line number Diff line Loading @@ -162,6 +162,9 @@ struct Device : public IDevice, public ParametersUtil { Return<void> updateAudioPatch(int32_t previousPatch, const hidl_vec<AudioPortConfig>& sources, const hidl_vec<AudioPortConfig>& sinks, createAudioPatch_cb _hidl_cb) override; #endif #if MAJOR_VERSION == 7 && MINOR_VERSION == 1 Return<Result> setConnectedState_7_1(const AudioPort& devicePort, bool connected) override; #endif Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; Loading audio/core/all-versions/vts/functional/7.1/AudioPrimaryHidlHalTest.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -16,3 +16,34 @@ // pull in all the <= 7.0 tests #include "7.0/AudioPrimaryHidlHalTest.cpp" TEST_P(AudioHidlDeviceTest, SetConnectedState_7_1) { doc::test("Check that the HAL can be notified of device connection and disconnection"); using AD = xsd::AudioDevice; for (auto deviceType : {AD::AUDIO_DEVICE_OUT_HDMI, AD::AUDIO_DEVICE_OUT_WIRED_HEADPHONE, AD::AUDIO_DEVICE_IN_USB_HEADSET}) { SCOPED_TRACE("device=" + toString(deviceType)); for (bool state : {true, false}) { SCOPED_TRACE("state=" + ::testing::PrintToString(state)); DeviceAddress address = {}; address.deviceType = toString(deviceType); if (deviceType == AD::AUDIO_DEVICE_IN_USB_HEADSET) { address.address.alsa({0, 0}); } AudioPort devicePort; devicePort.ext.device(address); auto ret = getDevice()->setConnectedState_7_1(devicePort, state); ASSERT_TRUE(ret.isOk()); if (ret == Result::NOT_SUPPORTED) { doc::partialTest("setConnectedState_7_1 is not supported"); break; // other deviceType might be supported } ASSERT_OK(ret); } } // 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(resetDevice()); } Loading
audio/7.1/IDevice.hal +12 −0 Original line number Diff line number Diff line Loading @@ -85,4 +85,16 @@ interface IDevice extends @7.0::IDevice { Result retval, IStreamIn inStream, AudioConfig suggestedConfig); /** * Notifies the device module about the connection state of an input/output * device attached to it. The devicePort identifies the device and may also * provide extra information such as raw audio descriptors. * * @param devicePort audio device port. * @param connected whether the device is connected. * @return retval operation completion status. */ setConnectedState_7_1(AudioPort devicePort, bool connected) generates (Result retval); };
audio/core/all-versions/default/Device.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -616,6 +616,21 @@ Return<void> Device::updateAudioPatch(int32_t previousPatch, #endif #if MAJOR_VERSION == 7 && MINOR_VERSION == 1 Return<Result> Device::setConnectedState_7_1(const AudioPort& devicePort, bool connected) { if (version() >= AUDIO_DEVICE_API_VERSION_3_2 && mDevice->set_device_connected_state_v7 != nullptr) { audio_port_v7 halPort; if (status_t status = HidlUtils::audioPortToHal(devicePort, &halPort); status != NO_ERROR) { return analyzeStatus("audioPortToHal", status); } return analyzeStatus("set_device_connected_state_v7", mDevice->set_device_connected_state_v7(mDevice, &halPort, connected)); } return Result::NOT_SUPPORTED; } #endif } // namespace implementation } // namespace CPP_VERSION } // namespace audio Loading
audio/core/all-versions/default/include/core/default/Device.h +3 −0 Original line number Diff line number Diff line Loading @@ -162,6 +162,9 @@ struct Device : public IDevice, public ParametersUtil { Return<void> updateAudioPatch(int32_t previousPatch, const hidl_vec<AudioPortConfig>& sources, const hidl_vec<AudioPortConfig>& sinks, createAudioPatch_cb _hidl_cb) override; #endif #if MAJOR_VERSION == 7 && MINOR_VERSION == 1 Return<Result> setConnectedState_7_1(const AudioPort& devicePort, bool connected) override; #endif Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; Loading
audio/core/all-versions/vts/functional/7.1/AudioPrimaryHidlHalTest.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -16,3 +16,34 @@ // pull in all the <= 7.0 tests #include "7.0/AudioPrimaryHidlHalTest.cpp" TEST_P(AudioHidlDeviceTest, SetConnectedState_7_1) { doc::test("Check that the HAL can be notified of device connection and disconnection"); using AD = xsd::AudioDevice; for (auto deviceType : {AD::AUDIO_DEVICE_OUT_HDMI, AD::AUDIO_DEVICE_OUT_WIRED_HEADPHONE, AD::AUDIO_DEVICE_IN_USB_HEADSET}) { SCOPED_TRACE("device=" + toString(deviceType)); for (bool state : {true, false}) { SCOPED_TRACE("state=" + ::testing::PrintToString(state)); DeviceAddress address = {}; address.deviceType = toString(deviceType); if (deviceType == AD::AUDIO_DEVICE_IN_USB_HEADSET) { address.address.alsa({0, 0}); } AudioPort devicePort; devicePort.ext.device(address); auto ret = getDevice()->setConnectedState_7_1(devicePort, state); ASSERT_TRUE(ret.isOk()); if (ret == Result::NOT_SUPPORTED) { doc::partialTest("setConnectedState_7_1 is not supported"); break; // other deviceType might be supported } ASSERT_OK(ret); } } // 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(resetDevice()); }