From 7beb1e26871e5fa740f5580f33b8cbc3bab94513 Mon Sep 17 00:00:00 2001 From: Igor Olshevskyi Date: Thu, 31 Aug 2017 15:17:13 +0300 Subject: [PATCH] TizenRefApp-9228 [Call UI] Fix issue with setting volume level on connected BT headset Change-Id: I36c5e718739ce559c5cd2cac48077a2ad62b103f --- call-ui/model/ISoundManager.h | 14 +- call-ui/model/impl/BluetoothManager.cpp | 109 +++++++++------- call-ui/model/impl/BluetoothManager.h | 10 +- call-ui/model/impl/SoundManager.cpp | 122 ++++-------------- call-ui/model/impl/SoundManager.h | 24 ++-- call-ui/model/types.h | 4 - .../presenters/misc/AccessoryPresenter.cpp | 53 +++++--- call-ui/presenters/misc/AccessoryPresenter.h | 11 +- call-ui/presenters/pages/KeypadPage.cpp | 28 ++-- call-ui/presenters/pages/KeypadPage.h | 7 +- call-ui/view/AcceptRejectWidget.cpp | 2 + tizen-manifest.xml | 1 + 12 files changed, 172 insertions(+), 213 deletions(-) diff --git a/call-ui/model/ISoundManager.h b/call-ui/model/ISoundManager.h index 6b4e54c..7f42c39 100644 --- a/call-ui/model/ISoundManager.h +++ b/call-ui/model/ISoundManager.h @@ -33,24 +33,24 @@ namespace callui { virtual ucl::Result startDtmf(const unsigned char dtmfDigit) = 0; virtual ucl::Result stopDtmf() = 0; virtual void addAudioStateHandler( - const AudioStateHandler &handler) = 0; + NotiHandler handler) = 0; virtual void delAudioStateHandler( - const AudioStateHandler &handler) = 0; + const NotiHandler &handler) = 0; virtual void addMuteStateHandler( - const MuteStateHandler &handler) = 0; + NotiHandler handler) = 0; virtual void delMuteStateHandler( - const MuteStateHandler &handler) = 0; + const NotiHandler &handler) = 0; virtual void addVolumeStateHandler( - const VolumeLevelHandler &handler) = 0; + NotiHandler handler) = 0; virtual void delVolumeStateHandler( - const VolumeLevelHandler &handler) = 0; + const NotiHandler &handler) = 0; virtual int getMaxVolume() const = 0; virtual int getVolume() const = 0; virtual ucl::Result setVolume(int value) = 0; virtual bool isBTSupported() const = 0; virtual bool isBTHeadsetConnected() const = 0; virtual void addBTHeadsetConnectionChangeHandler( - const NotiHandler &handler) = 0; + NotiHandler handler) = 0; virtual void delBTHeadsetConnectionChangeHandler( const NotiHandler &handler) = 0; }; diff --git a/call-ui/model/impl/BluetoothManager.cpp b/call-ui/model/impl/BluetoothManager.cpp index a9144b3..ff1a5a4 100644 --- a/call-ui/model/impl/BluetoothManager.cpp +++ b/call-ui/model/impl/BluetoothManager.cpp @@ -27,6 +27,35 @@ namespace callui { namespace { namespace impl { constexpr auto BT_VOLUME_MAX = 15; + bool isScoOpened() + { + bool isOpened = false; + auto res = bt_ag_is_sco_opened(&isOpened); + if (res != BT_ERROR_NONE) { + LOG_RETURN_VALUE(RES_FAIL, false, + "bt_ag_is_sco_opened() failed! " + "res[%d] msg[%s]", res, get_error_message(res)); + } + DLOG("BT SCO open state [%d]", isOpened); + + return isOpened; + } + + bool isCallCurrentSoundType() + { + sound_type_e soundType = SOUND_TYPE_SYSTEM; + auto res = sound_manager_get_current_sound_type(&soundType); + if (res != SOUND_MANAGER_ERROR_NONE) { + LOG_RETURN_VALUE(RES_FAIL, false, + "sound_manager_get_current_sound_type() failed! " + "res[%d] msg[%s]", res, get_error_message(res)); + } + bool ret = (soundType == SOUND_TYPE_CALL); + DLOG("Current sound type is Call [%s]", ret ? "YES" : "NO"); + + return ret; + } + }}} namespace callui { @@ -72,10 +101,10 @@ namespace callui { Result BluetoothManager::initializeBluetooth() { - auto ret = bt_initialize(); - if (ret != BT_ERROR_NONE) { + auto res = bt_initialize(); + if (res != BT_ERROR_NONE) { LOG_RETURN(RES_FAIL, "BT initialize failed! " - "ret[%d] msg[%s]", ret, get_error_message(ret)); + "res[%d] msg[%s]", res, get_error_message(res)); } m_btInitialized = true; @@ -84,16 +113,19 @@ namespace callui { void BluetoothManager::deinitializeBluetooth() { - bt_deinitialize(); + if (m_btInitialized) { + m_btInitialized = false; + bt_deinitialize(); + } } int BluetoothManager::getVolume() const { auto vol = 0; - auto ret = bt_ag_get_speaker_gain(&vol); - if (ret != BT_ERROR_NONE) { + auto res = bt_ag_get_speaker_gain(&vol); + if (res != BT_ERROR_NONE) { LOG_RETURN_VALUE(RES_FAIL, -1, "bt_ag_get_speaker_gain() failed! " - "ret[%d] msg[%s]", ret, get_error_message(ret)); + "res[%d] msg[%s]", res, get_error_message(res)); } DLOG("BT Volume level [%d]", vol); return vol; @@ -106,36 +138,35 @@ namespace callui { Result BluetoothManager::setVolume(int volume) { - auto ret = bt_ag_notify_speaker_gain(volume); - if (ret != BT_ERROR_NONE) { + auto res = bt_ag_notify_speaker_gain(volume); + if (res != BT_ERROR_NONE) { LOG_RETURN(RES_FAIL, "bt_ag_notify_speaker_gain() failed! " - "ret[%d] msg[%s]", ret, get_error_message(ret)); + "res[%d] msg[%s]", res, get_error_message(res)); } return RES_OK; } void BluetoothManager::setVolumeStateHandler( - const VolumeStateHandler &handler) + const NotiHandler &handler) { m_btVolumeHandler = handler; } Result BluetoothManager::registerAudioHandling() { - auto ret = bt_audio_initialize(); - if (ret != BT_ERROR_NONE) { + auto res = bt_audio_initialize(); + if (res != BT_ERROR_NONE) { LOG_RETURN(RES_FAIL, "bt_audio_initialize() failed! ", - "ret[%d] msg[%s]", ret, get_error_message(ret)); + "res[%d] msg[%s]", res, get_error_message(res)); } m_btAudioInitialized = true; - ret = bt_ag_set_speaker_gain_changed_cb( + res = bt_ag_set_speaker_gain_changed_cb( CALLBACK_B(BluetoothManager::onVolumeChanged), this); - if (ret != BT_ERROR_NONE) { + if (res != BT_ERROR_NONE) { LOG_RETURN(RES_FAIL, "bt_ag_set_speaker_gain_changed_cb() failed! " - "ret[%d] msg[%s]", ret, get_error_message(ret)); + "res[%d] msg[%s]", res, get_error_message(res)); } - return RES_OK; } @@ -144,17 +175,17 @@ namespace callui { bt_ag_unset_speaker_gain_changed_cb(); if (m_btAudioInitialized) { - bt_audio_deinitialize(); m_btAudioInitialized = false; + bt_audio_deinitialize(); } } Result BluetoothManager::registerHeadsetConnectionHandling() { - auto ret = vconf_notify_key_changed(VCONFKEY_BT_DEVICE, + auto res = vconf_notify_key_changed(VCONFKEY_BT_DEVICE, CALLBACK_B(BluetoothManager::onHeadsetConnectionChanged), this); - if (ret != 0) { + if (res != 0) { LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } return RES_OK; @@ -169,23 +200,9 @@ namespace callui { void BluetoothManager::onVolumeChanged(int volume) { - sound_type_e soundType = SOUND_TYPE_SYSTEM; - auto ret = sound_manager_get_current_sound_type(&soundType); - if (ret != SOUND_MANAGER_ERROR_NONE) { - LOG_RETURN_VOID(RES_FAIL, "sound_manager_get_current_sound_type() failed! " - "ret[%d] msg[%s]", ret, get_error_message(ret)); - } - - bool isSCOOpened = false; - ret = bt_ag_is_sco_opened(&isSCOOpened); - if (ret != BT_ERROR_NONE) { - LOG_RETURN_VOID(RES_FAIL, "sound_manager_get_current_sound_type() failed! " - "ret[%d] msg[%s]", ret, get_error_message(ret)); - } - - if (isSCOOpened && soundType == SOUND_TYPE_CALL) { + if (impl::isScoOpened() && impl::isCallCurrentSoundType()) { if (m_btVolumeHandler) { - m_btVolumeHandler(volume); + m_btVolumeHandler(); } } } @@ -200,13 +217,13 @@ namespace callui { m_btConnectionHandler = handler; } - bool BluetoothManager::getHeadsetConnectionState() + bool BluetoothManager::getHeadsetConnectionState() const { bt_adapter_state_e adapterState = BT_ADAPTER_DISABLED; - auto ret = bt_adapter_get_state(&adapterState); - if (ret != BT_ERROR_NONE) { + auto res = bt_adapter_get_state(&adapterState); + if (res != BT_ERROR_NONE) { LOG_RETURN_VALUE(RES_FAIL, false, "bt_adapter_get_state() failed! " - "ret[%d] msg[%s]", ret, get_error_message(ret)); + "res[%d] msg[%s]", res, get_error_message(res)); } if (adapterState == BT_ADAPTER_DISABLED) { @@ -214,10 +231,10 @@ namespace callui { } auto dev = 0; - ret = vconf_get_int(VCONFKEY_BT_DEVICE, &dev); - if (ret != 0) { + res = vconf_get_int(VCONFKEY_BT_DEVICE, &dev); + if (res != 0) { LOG_RETURN_VALUE(RES_FAIL, false, "vconf_get_int() failed! " - "ret[%d] msg[%s]", ret, get_error_message(ret)); + "res[%d] msg[%s]", res, get_error_message(res)); } if (dev == VCONFKEY_BT_DEVICE_NONE) { @@ -235,6 +252,7 @@ namespace callui { void BluetoothManager::setHeadsetConnectionState(bool isConnected) { if (m_isHeadsetConnected != isConnected) { + DLOG("BT Headset connection state update"); m_isHeadsetConnected = isConnected; if (m_btConnectionHandler) { m_btConnectionHandler(); @@ -244,7 +262,8 @@ namespace callui { void BluetoothManager::onHeadsetConnectionChanged(keynode_t *node) { - bool isConnected = getHeadsetConnectionState(); + auto isConnected = getHeadsetConnectionState(); + DLOG("BT Headset connection state [%s]", isConnected ? "YES" : "NO"); setHeadsetConnectionState(isConnected); } diff --git a/call-ui/model/impl/BluetoothManager.h b/call-ui/model/impl/BluetoothManager.h index 35029e2..8b89ba8 100644 --- a/call-ui/model/impl/BluetoothManager.h +++ b/call-ui/model/impl/BluetoothManager.h @@ -26,9 +26,6 @@ namespace callui { UCL_DECLARE_REF_ALIASES(BluetoothManager); class BluetoothManager final { - public: - using VolumeStateHandler = ucl::WeakDelegate; - public: static BluetoothManagerSRef newInstance(); @@ -36,7 +33,7 @@ namespace callui { int getMaxVolume() const; ucl::Result setVolume(int volume); - void setVolumeStateHandler(const VolumeStateHandler &handler); + void setVolumeStateHandler(const NotiHandler &handler); bool isHeadsetConnected() const; void setHeadsetConnectionChangeHandler(const NotiHandler &handler); @@ -58,15 +55,16 @@ namespace callui { ucl::Result registerHeadsetConnectionHandling(); void unregisterHeadsetConnectionHandling(); - bool getHeadsetConnectionState(); + bool getHeadsetConnectionState() const; void setHeadsetConnectionState(bool isConnected); void onHeadsetConnectionChanged(keynode_t *node); private: - VolumeStateHandler m_btVolumeHandler; + NotiHandler m_btVolumeHandler; NotiHandler m_btConnectionHandler; bool m_btInitialized; bool m_btAudioInitialized; + bool m_isHeadsetConnected; }; } diff --git a/call-ui/model/impl/SoundManager.cpp b/call-ui/model/impl/SoundManager.cpp index 12d34c0..852c857 100644 --- a/call-ui/model/impl/SoundManager.cpp +++ b/call-ui/model/impl/SoundManager.cpp @@ -18,68 +18,6 @@ #include "common.h" -namespace callui { namespace { namespace impl { - - using namespace ucl; - - Result getBTHeadsetConnectedState(bool &state) - { - Result res = RES_FAIL; - state = false; - - sound_device_list_h deviceList = nullptr; - auto ret = sound_manager_get_device_list( - SOUND_DEVICE_ALL_MASK, &deviceList); - if (ret != SOUND_MANAGER_ERROR_NONE) { - LOG_RETURN(RES_FAIL, "sound_manager_get_device_list() failed. " - "[%d][%s]", ret, get_error_message(ret)); - } - sound_device_type_e searchType = SOUND_DEVICE_BLUETOOTH_VOICE; - sound_device_h device; - sound_device_type_e type; - - while (true) { - device = nullptr; - ret = sound_manager_get_next_device(deviceList, &device); - - if (ret == SOUND_MANAGER_ERROR_NO_DATA) { - res = RES_OK; - ILOG("No more device to check"); - break; - } else if (ret != SOUND_MANAGER_ERROR_NONE) { - UCL_FAIL_BREAK(res, "sound_manager_get_next_device() failed. " - "[%d][%s]", ret, get_error_message(ret)); - } - - if (!device) { - UCL_FAIL_BREAK(res, "device is NULL"); - } - - sound_manager_get_device_type(device, &type); - if (searchType == type) { - DLOG("Bluetooth voice device found"); - state = true; - } - - // For debug only - int id; - char *name; - sound_device_io_direction_e direction; - sound_manager_get_device_id(device, &id); - sound_manager_get_device_name(device, &name); - sound_manager_get_device_io_direction(device, &direction); - DLOG("--------------------------"); - DLOG("Device ID [%d]", id); - DLOG("Device name [%s]", name); - DLOG("Device IO direction [%d]", direction); - DLOG("Device type [%d]", type); - } - sound_manager_free_device_list(deviceList); - - return res; - } -}}} - namespace callui { using namespace ucl; @@ -87,14 +25,14 @@ namespace callui { SoundManager::SoundManager(IRefCountObj &rc, const CallClientSRef &client): RefCountAware(&rc), m_client(client), - m_deviceVolumeCbID(-1) + m_deviceVolumeCbId(-1) { } SoundManager::~SoundManager() { - if (m_deviceVolumeCbID >= 0) { - sound_manager_remove_volume_changed_cb(m_deviceVolumeCbID); + if (m_deviceVolumeCbId >= 0) { + sound_manager_remove_volume_changed_cb(m_deviceVolumeCbId); } cm_unset_audio_state_changed_cb(*m_client); cm_unset_mute_status_cb(*m_client); @@ -115,14 +53,13 @@ namespace callui { ILOG("Ignored. Unhandled state [%d]", state); return; } - m_audioStateEvent.dispatch(convertCMAudioState(state)); + + m_audioStateEvent.dispatch(); } void SoundManager::onMuteStateChanged(cm_mute_status_e status) { - DLOG(); - - m_muteStateEvent.dispatch(status == CM_MUTE_STATUS_ON); + m_muteStateEvent.dispatch(); } Result SoundManager::prepare() @@ -151,7 +88,7 @@ namespace callui { int ret = sound_manager_add_volume_changed_cb( CALLBACK_B(SoundManager::onGearVolumeChanged), this, - &m_deviceVolumeCbID); + &m_deviceVolumeCbId); if (ret != SOUND_MANAGER_ERROR_NONE) { LOG_RETURN(RES_FAIL, "sound_manager_add_volume_changed_cb() failed"); @@ -190,17 +127,11 @@ namespace callui { LOG_RETURN(RES_NOT_SUPPORTED, "Bluetooth not supported"); } - bool state = false; - Result res = impl::getBTHeadsetConnectedState(state); - DLOG("Sound manager BT Headset connection status [%d], res [%s]", - state, getResultData(res).name); - - if (!isBTHeadsetConnected()) { - LOG_RETURN(RES_NOT_CONNECTED, - "Bluetooth headset device not connected"); - } - if (isEnable) { + if (!isBTHeadsetConnected()) { + LOG_RETURN(RES_NOT_CONNECTED, + "Bluetooth headset device not connected"); + } return convertCMResult(cm_bluetooth_on(*m_client)); } else { return convertCMResult(cm_bluetooth_off(*m_client)); @@ -241,32 +172,32 @@ namespace callui { return convertCMResult(cm_stop_dtmf(*m_client)); } - void SoundManager::addAudioStateHandler(const AudioStateHandler &handler) + void SoundManager::addAudioStateHandler(NotiHandler handler) { - m_audioStateEvent += handler; + m_audioStateEvent += std::move(handler); } - void SoundManager::delAudioStateHandler(const AudioStateHandler &handler) + void SoundManager::delAudioStateHandler(const NotiHandler &handler) { m_audioStateEvent -= handler; } - void SoundManager::addMuteStateHandler(const MuteStateHandler &handler) + void SoundManager::addMuteStateHandler(NotiHandler handler) { - m_muteStateEvent += handler; + m_muteStateEvent += std::move(handler); } - void SoundManager::delMuteStateHandler(const MuteStateHandler &handler) + void SoundManager::delMuteStateHandler(const NotiHandler &handler) { m_muteStateEvent -= handler; } - void SoundManager::addVolumeStateHandler(const VolumeLevelHandler &handler) + void SoundManager::addVolumeStateHandler(NotiHandler handler) { - m_volumeLevelEvent += handler; + m_volumeLevelEvent += std::move(handler); } - void SoundManager::delVolumeStateHandler(const VolumeLevelHandler &handler) + void SoundManager::delVolumeStateHandler(const NotiHandler &handler) { m_volumeLevelEvent -= handler; } @@ -340,9 +271,9 @@ namespace callui { } void SoundManager::addBTHeadsetConnectionChangeHandler( - const NotiHandler &handler) + NotiHandler handler) { - m_btVoiceDeviceConnEvent += handler; + m_btVoiceDeviceConnEvent += std::move(handler); } void SoundManager::delBTHeadsetConnectionChangeHandler( @@ -353,23 +284,20 @@ namespace callui { void SoundManager::onGearVolumeChanged(sound_type_e type, unsigned int volume) { - DLOG("Volume [%d]", volume); if (type != SOUND_TYPE_CALL) { ILOG("Ignored. Not type Call."); return; } if (getAudioState() != AudioStateType::BT) { - m_volumeLevelEvent.dispatch(volume); + m_volumeLevelEvent.dispatch(); } } - void SoundManager::onBTHeadsetVolumeChanged(int volume) + void SoundManager::onBTHeadsetVolumeChanged() { - DLOG("Volume [%d]", volume); - if (getAudioState() == AudioStateType::BT) { - m_volumeLevelEvent.dispatch(volume); + m_volumeLevelEvent.dispatch(); } } diff --git a/call-ui/model/impl/SoundManager.h b/call-ui/model/impl/SoundManager.h index 224c90c..afae43a 100644 --- a/call-ui/model/impl/SoundManager.h +++ b/call-ui/model/impl/SoundManager.h @@ -52,19 +52,19 @@ namespace callui { virtual ucl::Result stopDtmf() override final; virtual void addAudioStateHandler( - const AudioStateHandler &handler) override final; + NotiHandler handler) override final; virtual void delAudioStateHandler( - const AudioStateHandler &handler) override final; + const NotiHandler &handler) override final; virtual void addMuteStateHandler( - const MuteStateHandler &handler) override final; + NotiHandler handler) override final; virtual void delMuteStateHandler( - const MuteStateHandler &handler) override final; + const NotiHandler &handler) override final; virtual void addVolumeStateHandler( - const VolumeLevelHandler &handler) override final; + NotiHandler handler) override final; virtual void delVolumeStateHandler( - const VolumeLevelHandler &handler) override final; + const NotiHandler &handler) override final; virtual int getMaxVolume() const override final; virtual int getVolume() const override final; @@ -74,7 +74,7 @@ namespace callui { virtual bool isBTHeadsetConnected() const override final; virtual void addBTHeadsetConnectionChangeHandler( - const NotiHandler &handler) override final; + NotiHandler handler) override final; virtual void delBTHeadsetConnectionChangeHandler( const NotiHandler &handler) override final; @@ -89,17 +89,17 @@ namespace callui { void onMuteStateChanged(cm_mute_status_e status); void onHeadsetConnectionChanged(); - void onBTHeadsetVolumeChanged(int volume); + void onBTHeadsetVolumeChanged(); void onGearVolumeChanged(sound_type_e type, unsigned int volume); private: CallClientSRef m_client; BluetoothManagerSRef m_btManager; - ucl::Event m_audioStateEvent; - ucl::Event m_muteStateEvent; - ucl::Event m_volumeLevelEvent; + ucl::Event m_audioStateEvent; + ucl::Event m_muteStateEvent; + ucl::Event m_volumeLevelEvent; ucl::Event m_btVoiceDeviceConnEvent; - int m_deviceVolumeCbID; + int m_deviceVolumeCbId; }; } diff --git a/call-ui/model/types.h b/call-ui/model/types.h index 32c0c4c..f91a0ad 100644 --- a/call-ui/model/types.h +++ b/call-ui/model/types.h @@ -140,10 +140,6 @@ namespace callui { HD_VOICE }; - using AudioStateHandler = ucl::WeakDelegate; - using MuteStateHandler = ucl::WeakDelegate; - using VolumeLevelHandler = ucl::WeakDelegate; - } #endif // __CALL_UI_MODEL_TYPES_H__ diff --git a/call-ui/presenters/misc/AccessoryPresenter.cpp b/call-ui/presenters/misc/AccessoryPresenter.cpp index 3cf07f1..c27a3c6 100644 --- a/call-ui/presenters/misc/AccessoryPresenter.cpp +++ b/call-ui/presenters/misc/AccessoryPresenter.cpp @@ -130,7 +130,8 @@ namespace callui { FAIL_RETURN(createVolumeControl(), "createVolumeControl() failed"); - updateVolume(m_sm->getVolume()); + + updateCurrentVolume(); registerCallbacks(); @@ -179,6 +180,8 @@ namespace callui { { updateMode(cm); + m_audioState = m_sm->getAudioState(); + FAIL_RETURN(updateModeRelativeComponents(cm), "updateModeRelativeComponents() failed"); @@ -210,6 +213,9 @@ namespace callui { Result AccessoryPresenter::setActiveCallCompomnents() { + updateMaxVolume(); + updateCurrentVolume(); + FAIL_RETURN(createVolumeBtn(), "createVolumeBtn() failed"); m_widget->setContent(*m_volumeBtn, impl::PART_SWL_SLOT1); @@ -446,6 +452,7 @@ namespace callui { } else { auto res = m_sm->setBluetoothState(true); if (res == RES_NOT_CONNECTED) { + DLOG("Launch bluetooth settings..."); FAIL_RETURN_VOID(launchBluetoothSettings(), "launchBluetoothSettings() failed"); } else { @@ -664,25 +671,20 @@ namespace callui { } } - void AccessoryPresenter::onAudioStateChanged(AudioStateType state) + void AccessoryPresenter::onAudioStateChanged() { + auto state = m_sm->getAudioState(); if ((m_audioState != AudioStateType::BT && state == AudioStateType::BT) || (m_audioState == AudioStateType::BT && state != AudioStateType::BT)) { - m_audioState = state; - m_vc->setValue(0); - m_slider->setValue(0); - - auto maxVol = m_sm->getMaxVolume(); - m_vc->setMaxValue(maxVol); - m_slider->setMaxValue(maxVol); + m_audioState = state; - updateVolume(m_sm->getVolume()); + updateMaxVolume(); + updateCurrentVolume(); if (m_bluetoothBtn) { - if (m_audioState == AudioStateType::BT) { m_bluetoothBtn->emit(impl::SIGNAL_TURN_ON); // Screen Reader @@ -698,14 +700,14 @@ namespace callui { } } - void AccessoryPresenter::updateVolume(int value) + void AccessoryPresenter::updateCurrentVolume() { - m_vc->setValue(value); - m_slider->setValue(value); - auto max = m_sm->getMaxVolume(); auto cur = m_sm->getVolume(); + m_vc->setValue(cur); + m_slider->setValue(cur); + if (cur == max) { m_vc->setIncreaseBtnEnable(false); m_vc->setDecreaseBtnEnable(true); @@ -727,26 +729,35 @@ namespace callui { } } - void AccessoryPresenter::onVolumeLevelChanged(int value) + void AccessoryPresenter::updateMaxVolume() { - updateVolume(value); + auto max = m_sm->getMaxVolume(); + + m_vc->setMaxValue(max); + m_slider->setMaxValue(max); } - void AccessoryPresenter::onMuteStateChanged(bool isMuted) + void AccessoryPresenter::onVolumeLevelChanged() + { + updateCurrentVolume(); + } + + void AccessoryPresenter::onMuteStateChanged() { if (!m_muteBtn) { return; } + if (!elm_object_disabled_get(*m_muteBtn)) - updateMuteBtn(isMuted); + updateMuteBtn(); } - void AccessoryPresenter::updateMuteBtn(bool isMuted) + void AccessoryPresenter::updateMuteBtn() { if (!m_muteBtn) { return; } - isMuted ? m_muteBtn->emit(impl::SIGNAL_TURN_ON) : + m_sm->getMuteState() ? m_muteBtn->emit(impl::SIGNAL_TURN_ON) : m_muteBtn->emit(impl::SIGNAL_TURN_OFF); } diff --git a/call-ui/presenters/misc/AccessoryPresenter.h b/call-ui/presenters/misc/AccessoryPresenter.h index 2fee270..90b9adc 100644 --- a/call-ui/presenters/misc/AccessoryPresenter.h +++ b/call-ui/presenters/misc/AccessoryPresenter.h @@ -112,17 +112,18 @@ namespace callui { void tryIncreaseVolume(); void tryDecreaseVolume(); - void onAudioStateChanged(AudioStateType state); - void onVolumeLevelChanged(int value); - void onMuteStateChanged(bool isMuted); - void updateMuteBtn(bool isMuted); + void onAudioStateChanged(); + void onVolumeLevelChanged(); + void onMuteStateChanged(); + void updateMuteBtn(); Eina_Bool onVCTimerCb(); void startVCTimer(); void restartVCTimer(); void stopVCTimer(); - void updateVolume(int value); + void updateCurrentVolume(); + void updateMaxVolume(); void updateMode(const ICallManagerSRef &cm); AccessoryPresenter::ComponentsMode getCurrentMode(const ICallManagerSRef &cm); diff --git a/call-ui/presenters/pages/KeypadPage.cpp b/call-ui/presenters/pages/KeypadPage.cpp index a967e86..6031225 100644 --- a/call-ui/presenters/pages/KeypadPage.cpp +++ b/call-ui/presenters/pages/KeypadPage.cpp @@ -181,7 +181,7 @@ namespace callui { registerCallbacks(); - updateVolume(m_sm->getVolume()); + updateVolume(); FAIL_RETURN(createAtspiHighlightHelper(), "createAtspiHighlightHelper() failed!"); @@ -444,13 +444,13 @@ namespace callui { } } - void KeypadPage::updateVolume(int value) + void KeypadPage::updateVolume() { - m_vc->setValue(value); - auto max = m_sm->getMaxVolume(); auto cur = m_sm->getVolume(); + m_vc->setValue(cur); + if (cur == max) { m_vc->setIncreaseBtnEnable(false); m_vc->setDecreaseBtnEnable(true); @@ -469,26 +469,28 @@ namespace callui { } } - void KeypadPage::onAudioStateChanged(AudioStateType state) + void KeypadPage::updateMaxVolume() { + m_vc->setMaxValue(m_sm->getMaxVolume()); + } + + void KeypadPage::onAudioStateChanged() + { + auto state = m_sm->getAudioState(); if ((m_audioState != AudioStateType::BT && state == AudioStateType::BT) || (m_audioState == AudioStateType::BT && state != AudioStateType::BT)) { m_audioState = state; - m_vc->setValue(0); - - auto maxVol = m_sm->getMaxVolume(); - m_vc->setMaxValue(maxVol); - - updateVolume(m_sm->getVolume()); + updateMaxVolume(); + updateVolume(); } } - void KeypadPage::onVolumeLevelChanged(int value) + void KeypadPage::onVolumeLevelChanged() { - updateVolume(value); + updateVolume(); } Eina_Bool KeypadPage::onVCTimerCb() diff --git a/call-ui/presenters/pages/KeypadPage.h b/call-ui/presenters/pages/KeypadPage.h index 351fb27..17f3298 100644 --- a/call-ui/presenters/pages/KeypadPage.h +++ b/call-ui/presenters/pages/KeypadPage.h @@ -72,7 +72,7 @@ namespace callui { void startDtmf(const unsigned char digit); void stopDtmf(); - void onAudioStateChanged(AudioStateType state); + void onAudioStateChanged(); void onVolumeControlEventCb(VolumeControl::Event event); Eina_Bool onVCTimerCb(); void startVCTimer(); @@ -80,8 +80,9 @@ namespace callui { void stopVCTimer(); void tryIncreaseVolume(); void tryDecreaseVolume(); - void updateVolume(int value); - void onVolumeLevelChanged(int value); + void updateVolume(); + void updateMaxVolume(); + void onVolumeLevelChanged(); Eina_Bool onRotaryEvent(Eext_Rotary_Event_Info *info); void registerCallbacks(); diff --git a/call-ui/view/AcceptRejectWidget.cpp b/call-ui/view/AcceptRejectWidget.cpp index 5e94849..7468f03 100644 --- a/call-ui/view/AcceptRejectWidget.cpp +++ b/call-ui/view/AcceptRejectWidget.cpp @@ -1368,6 +1368,8 @@ namespace callui { DLOG("Accept icon type is already set"); } + m_acceptBtnType = type; + if (!m_accIcon) { return; } diff --git a/tizen-manifest.xml b/tizen-manifest.xml index 6a76d4d..0c547f7 100644 --- a/tizen-manifest.xml +++ b/tizen-manifest.xml @@ -25,5 +25,6 @@ http://tizen.org/privilege/notification http://tizen.org/privilege/message.read http://tizen.org/privilege/callhistory.read + http://tizen.org/privilege/bluetooth.admin -- 2.34.1