Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f10afe1e authored by Jakub Pawłowski's avatar Jakub Pawłowski Committed by Gerrit Code Review
Browse files

Merge "vc: Fix autonomous volume change when single device connected"

parents d8c54215 32126bc0
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -341,6 +341,13 @@ class VolumeControlImpl : public VolumeControl {
      }
    }

    if (devices.empty() && (is_volume_change || is_mute_change)) {
      LOG_INFO("No more devices in the group right now");
      callbacks_->OnGroupVolumeStateChanged(group_id, device->volume,
                                            device->mute, true);
      return;
    }

    if (is_volume_change) {
      std::vector<uint8_t> arg({device->volume});
      PrepareVolumeControlOperation(devices, group_id, true,
+17 −0
Original line number Diff line number Diff line
@@ -334,6 +334,7 @@ class VolumeControlTest : public ::testing::Test {

    EXPECT_CALL(gatt_interface, Open(gatt_if, address, true, _));
    VolumeControl::Get()->Connect(address);
    Mock::VerifyAndClearExpectations(&gatt_interface);
  }

  void TestDisconnect(const RawAddress& address, uint16_t conn_id) {
@@ -343,6 +344,7 @@ class VolumeControlTest : public ::testing::Test {
      EXPECT_CALL(gatt_interface, CancelOpen(gatt_if, address, _));
    }
    VolumeControl::Get()->Disconnect(address);
    Mock::VerifyAndClearExpectations(&gatt_interface);
  }

  void TestAddFromStorage(const RawAddress& address, bool auto_connect) {
@@ -1052,6 +1054,21 @@ TEST_F(VolumeControlCsis, autonomus_test_set_volume) {
  GetNotificationEvent(conn_id_1, test_address_1, 0x0021, value);
  GetNotificationEvent(conn_id_2, test_address_2, 0x0021, value);
}

TEST_F(VolumeControlCsis, autonomus_single_device_test_set_volume) {
  /* Disconnect one device. */
  EXPECT_CALL(*callbacks,
              OnConnectionState(ConnectionState::DISCONNECTED, test_address_1));
  GetDisconnectedEvent(test_address_1, conn_id_1);

  /* Now inject notification and make sure callback is sent up to Java layer */
  EXPECT_CALL(*callbacks,
              OnGroupVolumeStateChanged(group_id, 0x03, false, true));

  std::vector<uint8_t> value({0x03, 0x00, 0x02});
  GetNotificationEvent(conn_id_2, test_address_2, 0x0021, value);
}

}  // namespace
}  // namespace internal
}  // namespace vc