Add missing return and test for volume check
feature: #stability
Bug: 167648114
Test: atest net_test_avrcp
Change-Id: I6dce4c7afb78a93dca8ba7fcbd02aa5350f18c1a
Merged-In: I6dce4c7afb78a93dca8ba7fcbd02aa5350f18c1a
diff --git a/system/profile/avrcp/device.cc b/system/profile/avrcp/device.cc
index 750816d..5a889b0 100644
--- a/system/profile/avrcp/device.cc
+++ b/system/profile/avrcp/device.cc
@@ -412,8 +412,9 @@
// TODO (apanicke): Implement logic for Multi-AVRCP
DEVICE_VLOG(1) << __func__ << ": volume=" << (int)volume;
if (volume == volume_) {
- DEVICE_VLOG(3) << __func__
- << ": Ignoring volume change same as current volume level";
+ DEVICE_LOG(WARNING)
+ << __func__ << ": Ignoring volume change same as current volume level";
+ return;
}
auto request = SetAbsoluteVolumeRequestBuilder::MakeBuilder(volume);
diff --git a/system/profile/avrcp/tests/avrcp_device_test.cc b/system/profile/avrcp/tests/avrcp_device_test.cc
index 5169492..379ea04 100644
--- a/system/profile/avrcp/tests/avrcp_device_test.cc
+++ b/system/profile/avrcp/tests/avrcp_device_test.cc
@@ -1351,6 +1351,19 @@
EXPECT_CALL(response_cb, Call(_, _, _)).Times(0);
}
+TEST_F(AvrcpDeviceTest, setVolumeOnceTest) {
+ int vol = 0x48;
+
+ auto set_abs_vol = SetAbsoluteVolumeRequestBuilder::MakeBuilder(vol);
+
+ // Ensure that SetVolume only been call once.
+ EXPECT_CALL(response_cb, Call(_, false, matchPacket(std::move(set_abs_vol))))
+ .Times(1);
+
+ test_device->SetVolume(vol);
+ test_device->SetVolume(vol);
+}
+
TEST_F(AvrcpDeviceTest, playPushedActiveDeviceTest) {
MockMediaInterface interface;
NiceMock<MockA2dpInterface> a2dp_interface;