TizenRefApp-8915 [Call UI] Implement Incoming call accept call with BT headset 91/140191/1
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Mon, 24 Jul 2017 05:20:57 +0000 (08:20 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Mon, 24 Jul 2017 06:29:10 +0000 (09:29 +0300)
Change-Id: Id8d447264857a569e06809b6c47815f4e7f0f1de

21 files changed:
edc/buttons.edc
edc/images.edc
edc/images/w_outgoing_icon_headset_02.png
inc/model/ISoundManager.h
inc/presenters/AcceptRejectPresenter.h
inc/view/AcceptRejectWidget.h
inc/view/types.h
src/model/BluetoothManager.cpp [new file with mode: 0644]
src/model/BluetoothManager.h [new file with mode: 0644]
src/model/BluetoothVolume.cpp [deleted file]
src/model/BluetoothVolume.h [deleted file]
src/model/SoundManager.cpp
src/model/SoundManager.h
src/model/implTypes.h
src/presenters/AcceptRejectPresenter.cpp
src/presenters/AccessoryPresenter.cpp
src/presenters/CallInfoPresenter.cpp
src/presenters/KeypadPage.cpp
src/presenters/MainPage.cpp
src/view/AcceptRejectWidget.cpp
src/view/common.h

index e5290edaf2fc4bb179b920f6e101fba541de7a87..8b1ef396af895673f5f5ba632c95c1c7f5e312d8 100644 (file)
@@ -1271,11 +1271,6 @@ group { "elm/button/base/callui/keypad_speaker";
        }
 }
 
-CU_BTN_INCOM_CALL("callui/accept", "w_call_incoming_icon_accept.png",
-       "AO01131", "AO01132", "AO0113", "AO0113P")
-CU_BTN_INCOM_CALL("callui/reject", "w_call_incoming_icon_reject.png",
-       "AO01151", "AO01152", "AO0115", "AO0115P")
-
 CU_BTN_BOTTOM("callui/end_call", "w_incoming_icon_end_phone.png",
        "AO0121", "AO0121P", "B013A", "B013")
 CU_BTN_BOTTOM("callui/call_back", "w_incoming_icon_call.png",
index 33a24858504eefd3b607bea2bb6b6dacfd36434e..fb8514f8ab7320b3b1344d6ae2f0a446a9c8c822 100644 (file)
@@ -43,4 +43,5 @@ CU_RES_IMAGE("bezel_cue_reject_4", CU_BEZEL_CUE_ICONS_DIR/"bezel_interaction_cue
 
 CU_RES_IMAGE("accept_reject_action_bg", "call_button_bg_accept_reject_press.png")
 CU_RES_IMAGE("accept", "w_call_incoming_icon_accept.png")
+CU_RES_IMAGE("accept_bt_headset", "w_call_incoming_icon_headset_call_accept.png")
 CU_RES_IMAGE("reject", "w_call_incoming_icon_reject.png")
index 4cac9625301361eb8163088148e1a38926a89430..df32384d31b3469dca93031381154895d3fa214b 100644 (file)
Binary files a/edc/images/w_outgoing_icon_headset_02.png and b/edc/images/w_outgoing_icon_headset_02.png differ
index a95b18f397471ee8d14d4212262a4a2d659fd3ca..bced75a2ca2e59ee927a1957555f6e4190abc899 100644 (file)
@@ -30,16 +30,27 @@ namespace callui {
                virtual bool getMuteState() const = 0;
                virtual ucl::Result startDtmf(const unsigned char dtmfDigit) = 0;
                virtual ucl::Result stopDtmf() = 0;
-               virtual void addAudioStateHandler(AudioStateHandler handler) = 0;
-               virtual void removeAudioStateHandler(AudioStateHandler handler) = 0;
-               virtual void addMuteStateHandler(MuteStateHandler handler) = 0;
-               virtual void removeMuteStateHandler(MuteStateHandler handler) = 0;
-               virtual void addVolumeStateHandler(VolumeLevelHandler handler) = 0;
-               virtual void removeVolumeStateHandler(VolumeLevelHandler handler) = 0;
+               virtual void addAudioStateHandler(
+                               const AudioStateHandler &handler) = 0;
+               virtual void delAudioStateHandler(
+                               const AudioStateHandler &handler) = 0;
+               virtual void addMuteStateHandler(
+                               const MuteStateHandler &handler) = 0;
+               virtual void delMuteStateHandler(
+                               const MuteStateHandler &handler) = 0;
+               virtual void addVolumeStateHandler(
+                               const VolumeLevelHandler &handler) = 0;
+               virtual void delVolumeStateHandler(
+                               const VolumeLevelHandler &handler) = 0;
                virtual int getMaxVolume() const = 0;
                virtual int getVolume() const = 0;
                virtual ucl::Result setVolume(int value) = 0;
-               virtual bool isBluetoothSupported() const = 0;
+               virtual bool isBTSupported() const = 0;
+               virtual bool isBTHeadsetConnected() const = 0;
+               virtual void addBTHeadsetConnectionChangeHandler(
+                               const NotiHandler &handler) = 0;
+               virtual void delBTHeadsetConnectionChangeHandler(
+                               const NotiHandler &handler) = 0;
        };
 }
 
index fb96cd471006644d32dbc8081fa1ed533e111458..fd477e9f07dc86455877ef052ce3af4bde124b3a 100644 (file)
@@ -33,6 +33,7 @@ namespace callui {
                        Builder();
                        ~Builder();
                        Builder &setIncomingCall(const IIncomingCallSRef &call);
+                       Builder &setSoundManager(const ISoundManagerSRef &sm);
                        Builder &setAvailableCallsFlag(CallMask calls);
                        Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
                        AcceptRejectPresenterSRef build(ucl::GuiPresenter &parent) const;
@@ -41,6 +42,7 @@ namespace callui {
                        IIncomingCallSRef m_call;
                        CallMask m_callMask;
                        ucl::ElmWidgetSRef m_parentWidget;
+                       ISoundManagerSRef m_sm;
                };
 
        public:
@@ -54,7 +56,8 @@ namespace callui {
                friend class ucl::ReffedObj<AcceptRejectPresenter>;
                AcceptRejectPresenter(ucl::IRefCountObj &rc,
                                const IIncomingCallSRef &call,
-                               CallMask calls);
+                               CallMask calls,
+                               const ISoundManagerSRef &sm);
 
                ucl::Result prepare(ucl::GuiPresenter &parent,
                                ucl::ElmWidget &parentWidget);
@@ -72,6 +75,7 @@ namespace callui {
                bool onAcceptPopupEvent(AcceptDialog &popup, AcceptDialogEvent event);
                void onAcceptEvent();
                void onRejectEvent();
+               void onBTHeadsetConnectionChanged();
 
                // GuiPresenter
                virtual void onActivate() final override;
@@ -84,6 +88,7 @@ namespace callui {
 
                IIncomingCallSRef m_call;
                CallMask m_callMask;
+               ISoundManagerSRef m_sm;
        };
 }
 
index c064de734c93aae6e14f0dae7e8c5028cca00099..bd7865b5e96ee5285f3a794e5ba1b98d011ed12f 100644 (file)
@@ -34,11 +34,13 @@ namespace callui {
                        Builder();
                        Builder &setAcceptEventHandler(const NotiHandler &handler);
                        Builder &setRejectEventHandler(const NotiHandler &handler);
+                       Builder &setAcceptBtnType(AcceptButtonType type);
                        AcceptRejectWidgetSRef build(ucl::ElmWidget &parent) const;
 
                private:
                        NotiHandler m_acceptHandler;
                        NotiHandler m_rejectHandler;
+                       AcceptButtonType m_acceptBtnType;
                };
 
        public:
@@ -48,13 +50,15 @@ namespace callui {
                void reset();
                void activateRotary();
                void deactivateRotary();
+               void setAcceptBtnType(AcceptButtonType type);
 
        private:
                friend class ucl::ReffedObj<AcceptRejectWidget>;
                AcceptRejectWidget(ucl::IRefCountObj &rc,
                                const ucl::LayoutSRef &layout,
                                const NotiHandler &acceptHandler,
-                               const NotiHandler &rejectHandler);
+                               const NotiHandler &rejectHandler,
+                               AcceptButtonType acceptBtnType);
 
                void prepare();
 
@@ -129,14 +133,14 @@ namespace callui {
                std::vector<ucl::ElmWidgetSRef> m_accBezelCueImg;
                std::vector<ucl::ElmWidgetSRef> m_rejBezelCueImg;
 
-               ucl::ElmWidgetSRef m_accTracer;
-               ucl::ElmWidgetSRef m_accGuide;
-               ucl::ElmWidgetSRef m_accIcon;
+               ucl::LayoutSRef m_accTracer;
+               ucl::LayoutSRef m_accGuide;
+               ucl::LayoutSRef m_accIcon;
                ucl::LayoutSRef m_accEventLy;
 
-               ucl::ElmWidgetSRef m_rejTracer;
-               ucl::ElmWidgetSRef m_rejGuide;
-               ucl::ElmWidgetSRef m_rejIcon;
+               ucl::LayoutSRef m_rejTracer;
+               ucl::LayoutSRef m_rejGuide;
+               ucl::LayoutSRef m_rejIcon;
                ucl::LayoutSRef m_rejEventLy;
 
                bool m_isFreezed;
@@ -167,6 +171,8 @@ namespace callui {
 
                int m_accBCAnimIndex;
                int m_rejBCAnimIndex;
+
+               AcceptButtonType m_acceptBtnType;
        };
 
 }
index 75ee69fd83c3ea93bcf9b43136889beb93346eaf..8354b062191735b6bfb3ce9d8614a3894501f335 100644 (file)
@@ -30,6 +30,11 @@ namespace callui {
                DECREASE
        };
 
+       enum class AcceptButtonType {
+               SIMPLE,
+               BT_HEADSET
+       };
+
        UCL_DECLARE_REF_ALIASES(Slider);
        UCL_DECLARE_REF_ALIASES(VolumeControl);
        UCL_DECLARE_REF_ALIASES(AcceptRejectWidget);
diff --git a/src/model/BluetoothManager.cpp b/src/model/BluetoothManager.cpp
new file mode 100644 (file)
index 0000000..27bdaed
--- /dev/null
@@ -0,0 +1,253 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "BluetoothManager.h"
+
+#include <bluetooth.h>
+#include <bluetooth_internal.h>
+#include <bluetooth_extension.h>
+#include <sound_manager.h>
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+       using namespace ucl;
+
+       constexpr auto BT_VOLUME_MAX = 15;
+
+}}}
+
+namespace callui {
+
+       using namespace ucl;
+
+       BluetoothManagerSRef BluetoothManager::newInstance()
+       {
+               auto result = makeShared<BluetoothManager>();
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+               return result;
+       }
+
+       BluetoothManager::BluetoothManager():
+               m_btInitialized(false),
+               m_btAudioInitialized(false),
+               m_isHeadsetConnected(false)
+       {
+       }
+
+       BluetoothManager::~BluetoothManager()
+       {
+               unregisterAudioHandling();
+               unregisterHeadsetConnectionHandling();
+               deinitializeBluetooth();
+       }
+
+       Result BluetoothManager::prepare()
+       {
+               FAIL_RETURN(initializeBluetooth(),
+                               "initializeBluetooth() failed!");
+
+               FAIL_RETURN(registerAudioHandling(),
+                               "registerAudioHandling() failed");
+
+               FAIL_RETURN(registerHeadsetConnectionHandling(),
+                               "registerHeadsetConnectionHandling() failed!");
+
+               m_isHeadsetConnected = getHeadsetConnectionState();
+
+               return RES_OK;
+       }
+
+       Result BluetoothManager::initializeBluetooth()
+       {
+               auto ret = bt_initialize();
+               if (ret != BT_ERROR_NONE) {
+                       LOG_RETURN(RES_FAIL, "BT initialize failed! "
+                                       "ret[%d] msg[%s]", ret, get_error_message(ret));
+
+               }
+               m_btInitialized = true;
+               return RES_OK;
+       }
+
+       void BluetoothManager::deinitializeBluetooth()
+       {
+               bt_deinitialize();
+       }
+
+       int BluetoothManager::getVolume() const
+       {
+               auto vol = 0;
+               auto ret = bt_ag_get_speaker_gain(&vol);
+               if (ret != BT_ERROR_NONE) {
+                       LOG_RETURN_VALUE(RES_FAIL, -1, "bt_ag_get_speaker_gain() failed! "
+                                       "ret[%d] msg[%s]", ret, get_error_message(ret));
+               }
+               DLOG("BT Volume level [%d]", vol);
+               return vol;
+       }
+
+       int BluetoothManager::getMaxVolume() const
+       {
+               return impl::BT_VOLUME_MAX;
+       }
+
+       Result BluetoothManager::setVolume(int volume)
+       {
+               auto ret = bt_ag_notify_speaker_gain(volume);
+               if (ret != BT_ERROR_NONE) {
+                       LOG_RETURN(RES_FAIL, "bt_ag_notify_speaker_gain() failed! "
+                                       "ret[%d] msg[%s]", ret, get_error_message(ret));
+               }
+               return RES_OK;
+       }
+
+       void BluetoothManager::setVolumeStateHandler(
+                       const BluetoothVolumeHandler &handler)
+       {
+               m_btVolumeHandler = handler;
+       }
+
+       Result BluetoothManager::registerAudioHandling()
+       {
+               auto ret = bt_audio_initialize();
+               if (ret != BT_ERROR_NONE) {
+                       LOG_RETURN(RES_FAIL, "bt_audio_initialize() failed! ",
+                                       "ret[%d] msg[%s]", ret, get_error_message(ret));
+               }
+               m_btAudioInitialized = true;
+
+               ret = bt_ag_set_speaker_gain_changed_cb(
+                               CALLBACK_B(BluetoothManager::onVolumeChanged), this);
+               if (ret != BT_ERROR_NONE) {
+                       LOG_RETURN(RES_FAIL, "bt_ag_set_speaker_gain_changed_cb() failed! "
+                                       "ret[%d] msg[%s]", ret, get_error_message(ret));
+               }
+
+               return RES_OK;
+       }
+
+       void BluetoothManager::unregisterAudioHandling()
+       {
+               bt_ag_unset_speaker_gain_changed_cb();
+
+               if (m_btAudioInitialized) {
+                       bt_audio_deinitialize();
+                       m_btAudioInitialized = false;
+               }
+       }
+
+       Result BluetoothManager::registerHeadsetConnectionHandling()
+       {
+               auto ret = vconf_notify_key_changed(VCONFKEY_BT_DEVICE,
+                               CALLBACK_B(BluetoothManager::onHeadsetConnectionChanged),
+                               this);
+               if (ret != 0) {
+                       LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!");
+               }
+               return RES_OK;
+       }
+
+       void BluetoothManager::unregisterHeadsetConnectionHandling()
+       {
+               vconf_ignore_key_changed(
+                               VCONFKEY_BT_DEVICE,
+                               CALLBACK_B(BluetoothManager::onHeadsetConnectionChanged));
+       }
+
+       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 (m_btVolumeHandler) {
+                               m_btVolumeHandler(volume);
+                       }
+               }
+       }
+
+       bool BluetoothManager::isHeadsetConnected() const
+       {
+               return m_isHeadsetConnected;
+       }
+
+       void BluetoothManager::setHeadsetConnectionChangeHandler(const NotiHandler &handler)
+       {
+               m_btConnectionHandler = handler;
+       }
+
+       bool BluetoothManager::getHeadsetConnectionState()
+       {
+               bt_adapter_state_e adapterState = BT_ADAPTER_DISABLED;
+               auto ret = bt_adapter_get_state(&adapterState);
+               if (ret != BT_ERROR_NONE) {
+                       LOG_RETURN_VALUE(RES_FAIL, false, "bt_adapter_get_state() failed! "
+                                       "ret[%d] msg[%s]", ret, get_error_message(ret));
+               }
+
+               if (adapterState == BT_ADAPTER_DISABLED) {
+                       LOG_RETURN_VALUE(RES_FAIL, false, "BT adapter is disabled");
+               }
+
+               auto dev = 0;
+               ret = vconf_get_int(VCONFKEY_BT_DEVICE, &dev);
+               if (ret != 0) {
+                       LOG_RETURN_VALUE(RES_FAIL, false, "vconf_get_int() failed! "
+                                       "ret[%d] msg[%s]", ret, get_error_message(ret));
+               }
+
+               if (dev == VCONFKEY_BT_DEVICE_NONE) {
+                       return false;
+               }
+
+               if ((dev & VCONFKEY_BT_DEVICE_HEADSET_CONNECTED) ||
+                       (dev & VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED)) {
+                       return true;
+               }
+
+               return false;
+       }
+
+       void BluetoothManager::setHeadsetConnectionState(bool isConnected)
+       {
+               if (m_isHeadsetConnected != isConnected) {
+                       m_isHeadsetConnected = isConnected;
+                       if (m_btConnectionHandler) {
+                               m_btConnectionHandler();
+                       }
+               }
+       }
+
+       void BluetoothManager::onHeadsetConnectionChanged(keynode_t *node)
+       {
+               bool isConnected = getHeadsetConnectionState();
+               setHeadsetConnectionState(isConnected);
+       }
+
+}
diff --git a/src/model/BluetoothManager.h b/src/model/BluetoothManager.h
new file mode 100644 (file)
index 0000000..e020a1c
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CALLUI_MODEL_BLUETOOTH_MANAGER_H__
+#define __CALLUI_MODEL_BLUETOOTH_MANAGER_H__
+
+#include <vconf.h>
+
+#include "implTypes.h"
+
+namespace callui {
+
+       class BluetoothManager final {
+       public:
+               static BluetoothManagerSRef newInstance();
+
+               int getVolume() const;
+               int getMaxVolume() const;
+               ucl::Result setVolume(int volume);
+
+               void setVolumeStateHandler(const BluetoothVolumeHandler &handler);
+
+               bool isHeadsetConnected() const;
+               void setHeadsetConnectionChangeHandler(const NotiHandler &handler);
+
+       private:
+               friend class ucl::ReffedObj<BluetoothManager>;
+               BluetoothManager();
+               virtual ~BluetoothManager();
+
+               ucl::Result prepare();
+
+               ucl::Result initializeBluetooth();
+               void deinitializeBluetooth();
+
+               ucl::Result registerAudioHandling();
+               void unregisterAudioHandling();
+               void onVolumeChanged(int volume);
+
+               ucl::Result registerHeadsetConnectionHandling();
+               void unregisterHeadsetConnectionHandling();
+
+               bool getHeadsetConnectionState();
+               void setHeadsetConnectionState(bool isConnected);
+               void onHeadsetConnectionChanged(keynode_t *node);
+
+       private:
+               BluetoothVolumeHandler m_btVolumeHandler;
+               NotiHandler m_btConnectionHandler;
+               bool m_btInitialized;
+               bool m_btAudioInitialized;
+               bool m_isHeadsetConnected;
+       };
+}
+
+#endif // __CALLUI_MODEL_BLUETOOTH_MANAGER_H__
diff --git a/src/model/BluetoothVolume.cpp b/src/model/BluetoothVolume.cpp
deleted file mode 100644 (file)
index 6fcd6dd..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "BluetoothVolume.h"
-
-#include <bluetooth.h>
-#include <bluetooth_internal.h>
-#include <bluetooth_extension.h>
-#include <sound_manager.h>
-
-#include "common.h"
-
-namespace callui { namespace { namespace impl {
-
-       using namespace ucl;
-
-       constexpr auto BT_VOLUME_MAX = 15;
-
-}}}
-
-namespace callui {
-
-       using namespace ucl;
-
-       BluetoothVolumeSRef BluetoothVolume::newInstance()
-       {
-               auto result = makeShared<BluetoothVolume>();
-               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
-               return result;
-       }
-
-       BluetoothVolume::BluetoothVolume():
-               m_btInitialized(false),
-               m_btAudioInitialized(false)
-       {
-       }
-
-       BluetoothVolume::~BluetoothVolume()
-       {
-               unregisterAudioHandling();
-
-               bt_deinitialize();
-       }
-
-       Result BluetoothVolume::prepare()
-       {
-               auto ret = bt_initialize();
-               if (ret != BT_ERROR_NONE) {
-                       LOG_RETURN(RES_FAIL, "BT initialize failed. "
-                                       "ret[%d] msg[%s]", ret, get_error_message(ret));
-
-               }
-               m_btInitialized = true;
-
-               FAIL_RETURN(registerAudioHandling(),
-                               "registerAudioHandling() failed");
-
-               return RES_OK;
-       }
-
-       int BluetoothVolume::getVolume() const
-       {
-               auto vol = 0;
-               auto ret = bt_ag_get_speaker_gain(&vol);
-               if (ret != BT_ERROR_NONE) {
-                       LOG_RETURN_VALUE(RES_FAIL, -1, "bt_ag_get_speaker_gain() failed. "
-                                       "ret[%d] msg[%s]", ret, get_error_message(ret));
-               }
-               DLOG("BT Volume level [%d]", vol);
-               return vol;
-       }
-
-       int BluetoothVolume::getMaxVolume() const
-       {
-               return impl::BT_VOLUME_MAX;
-       }
-
-       Result BluetoothVolume::setVolume(int volume)
-       {
-               auto ret = bt_ag_notify_speaker_gain(volume);
-               if (ret != BT_ERROR_NONE) {
-                       LOG_RETURN(RES_FAIL, "bt_ag_notify_speaker_gain() failed! "
-                                       "ret[%d] msg[%s]", ret, get_error_message(ret));
-               }
-               return RES_OK;
-       }
-
-       void BluetoothVolume::setVolumeStateHandler(
-                       const BluetoothVolumeHandler &handler)
-       {
-               m_handler = handler;
-       }
-
-       Result BluetoothVolume::registerAudioHandling()
-       {
-               auto ret = bt_audio_initialize();
-               if (ret != BT_ERROR_NONE) {
-                       LOG_RETURN(RES_FAIL, "bt_audio_initialize() failed. ",
-                                       "ret[%d] msg[%s]", ret, get_error_message(ret));
-               }
-               m_btAudioInitialized = true;
-
-               ret = bt_ag_set_speaker_gain_changed_cb(
-                               CALLBACK_B(BluetoothVolume::onVolumeChanged), this);
-               if (ret != BT_ERROR_NONE) {
-                       LOG_RETURN(RES_FAIL, "bt_ag_set_speaker_gain_changed_cb() failed. "
-                                       "ret[%d] msg[%s]", ret, get_error_message(ret));
-               }
-
-               return RES_OK;
-       }
-
-       void BluetoothVolume::unregisterAudioHandling()
-       {
-               bt_ag_unset_speaker_gain_changed_cb();
-
-               if (m_btAudioInitialized) {
-                       bt_audio_deinitialize();
-                       m_btAudioInitialized = false;
-               }
-       }
-
-       void BluetoothVolume::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 (m_handler) {
-                               m_handler(volume);
-                       }
-               }
-       }
-}
diff --git a/src/model/BluetoothVolume.h b/src/model/BluetoothVolume.h
deleted file mode 100644 (file)
index 6be854f..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __CALLUI_MODEL_BLUETOOTH_VOLUME_H__
-#define __CALLUI_MODEL_BLUETOOTH_VOLUME_H__
-
-#include "implTypes.h"
-
-namespace callui {
-
-       class BluetoothVolume final {
-       public:
-               static BluetoothVolumeSRef newInstance();
-
-               int getVolume() const;
-               int getMaxVolume() const;
-               ucl::Result setVolume(int volume);
-
-               void setVolumeStateHandler(const BluetoothVolumeHandler &handler);
-
-       private:
-               friend class ucl::ReffedObj<BluetoothVolume>;
-               BluetoothVolume();
-               ~BluetoothVolume();
-
-               ucl::Result prepare();
-
-               ucl::Result registerAudioHandling();
-               void unregisterAudioHandling();
-               void onVolumeChanged(int volume);
-
-       private:
-               BluetoothVolumeHandler m_handler;
-               bool m_btInitialized;
-               bool m_btAudioInitialized;
-       };
-
-}
-
-#endif // __CALLUI_MODEL_BLUETOOTH_MANAGER_H__
index 85b4c6e910e8894800194244fb8bda37add9c03e..dd9cb62a990025fd02b26c083ff9b8fc124974f7 100644 (file)
 
 #include "SoundManager.h"
 
-#include "BluetoothVolume.h"
+#include "BluetoothManager.h"
 #include "CallClient.h"
+
 #include "common.h"
 
 namespace callui { namespace { namespace impl {
 
        using namespace ucl;
 
-       Result getBTVolumeDeviceCount(int &deviceCount)
+       Result getBTHeadsetConnectedState(bool &state)
        {
                Result res = RES_FAIL;
-               int count = 0;
+               state = false;
 
                sound_device_list_h deviceList = nullptr;
-               auto ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &deviceList);
+               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));
+                       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;
@@ -43,14 +44,16 @@ namespace callui { namespace { namespace impl {
                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));
+                               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");
                        }
@@ -58,7 +61,7 @@ namespace callui { namespace { namespace impl {
                        sound_manager_get_device_type(device, &type);
                        if (searchType == type) {
                                DLOG("Bluetooth voice device found");
-                               count++;
+                               state = true;
                        }
 
                        // For debug only
@@ -68,14 +71,13 @@ namespace callui { namespace { namespace impl {
                        sound_manager_get_device_id(device, &id);
                        sound_manager_get_device_name(device, &name);
                        sound_manager_get_device_io_direction(device, &direction);
-                       DLOG("====================");
+                       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);
-               deviceCount = count;
 
                return res;
        }
@@ -108,7 +110,7 @@ namespace callui {
                return result;
        }
 
-       void SoundManager::audioStateChangedCb(cm_audio_state_type_e state)
+       void SoundManager::onAudioStateChanged(cm_audio_state_type_e state)
        {
                DLOG();
 
@@ -119,7 +121,7 @@ namespace callui {
                m_audioStateEvent.dispatch(convertCMAudioState(state));
        }
 
-       void SoundManager::muteStateChangedCb(cm_mute_status_e status)
+       void SoundManager::onMuteStateChanged(cm_mute_status_e status)
        {
                DLOG();
 
@@ -128,29 +130,29 @@ namespace callui {
 
        Result SoundManager::prepare()
        {
-               m_btVolume = BluetoothVolume::newInstance();
-               if (!m_btVolume) {
-                       ELOG("BluetoothVolume::newInstance() failed!");
+               m_btManager = BluetoothManager::newInstance();
+               if (!m_btManager) {
+                       ELOG("BluetoothManager::newInstance() failed!");
                }
 
                Result res = convertCMResult(cm_set_audio_state_changed_cb(*m_client,
-                               CALLBACK_B(SoundManager::audioStateChangedCb), this));
+                               CALLBACK_B(SoundManager::onAudioStateChanged), this));
                FAIL_RETURN(res, "cm_set_audio_state_changed_cb() failed!");
 
                res = convertCMResult(cm_set_mute_status_cb(*m_client,
-                               CALLBACK_B(SoundManager::muteStateChangedCb), this));
+                               CALLBACK_B(SoundManager::onMuteStateChanged), this));
                FAIL_RETURN(res, "cm_set_mute_status_cb() failed!");
 
-               res = registerVolumeCallbacks();
+               res = registerCallbacks();
                FAIL_RETURN(res, "registerVolumeCallbacks() failed!");
 
                return res;
        }
 
-       Result SoundManager::registerVolumeCallbacks()
+       Result SoundManager::registerCallbacks()
        {
                int ret = sound_manager_add_volume_changed_cb(
-                               CALLBACK_B(SoundManager::onDeviceVolumeChanged),
+                               CALLBACK_B(SoundManager::onGearVolumeChanged),
                                this,
                                &m_deviceVolumeCbID);
                if (ret != SOUND_MANAGER_ERROR_NONE) {
@@ -158,15 +160,24 @@ namespace callui {
                                        "sound_manager_add_volume_changed_cb() failed");
                }
 
-               if (isBluetoothSupported()) {
-                       m_btVolume->setVolumeStateHandler(
-                                       WEAK_DELEGATE(SoundManager::onBluetoothVolumeChanged,
-                                       asWeak(*this)));
+               if (isBTSupported()) {
+                       m_btManager->setVolumeStateHandler(
+                                       WEAK_DELEGATE(SoundManager::onBTHeadsetVolumeChanged,
+                                                       asWeak(*this)));
+
+                       m_btManager->setHeadsetConnectionChangeHandler(
+                                       WEAK_DELEGATE(SoundManager::onHeadsetConnectionChanged,
+                                                       asWeak(*this)));
                }
 
                return RES_OK;
        }
 
+       void SoundManager::onHeadsetConnectionChanged()
+       {
+               m_btVoiceDeviceConnEvent.dispatch();
+       }
+
        Result SoundManager::setSpeakerState(bool isEnable)
        {
                if (isEnable) {
@@ -178,15 +189,18 @@ namespace callui {
 
        Result SoundManager::setBluetoothState(bool isEnable)
        {
-               if (!isBluetoothSupported()) {
+               if (!isBTSupported()) {
                        LOG_RETURN(RES_NOT_SUPPORTED, "Bluetooth not supported");
                }
 
-               int count = 0;
-               FAIL_RETURN(impl::getBTVolumeDeviceCount(count), "getBTVolumeDeviceCount() failed");
+               bool state = false;
+               Result res = impl::getBTHeadsetConnectedState(state);
+               DLOG("Sound manager BT Headset connection status [%d], res [%s]",
+                               state, getResultData(res).name);
 
-               if (count == 0) {
-                       LOG_RETURN(RES_NOT_CONNECTED, "Bluetooth headset device not connected");
+               if (!isBTHeadsetConnected()) {
+                       LOG_RETURN(RES_NOT_CONNECTED,
+                                       "Bluetooth headset device not connected");
                }
 
                if (isEnable) {
@@ -230,34 +244,32 @@ namespace callui {
                return convertCMResult(cm_stop_dtmf(*m_client));
        }
 
-       void SoundManager::addAudioStateHandler(AudioStateHandler handler)
+       void SoundManager::addAudioStateHandler(const AudioStateHandler &handler)
        {
                m_audioStateEvent += handler;
        }
 
-       void SoundManager::removeAudioStateHandler(AudioStateHandler handler)
+       void SoundManager::delAudioStateHandler(const AudioStateHandler &handler)
        {
                m_audioStateEvent -= handler;
        }
 
-       void SoundManager::addMuteStateHandler(MuteStateHandler handler)
+       void SoundManager::addMuteStateHandler(const MuteStateHandler &handler)
        {
                m_muteStateEvent += handler;
        }
 
-       void SoundManager::removeMuteStateHandler(MuteStateHandler handler)
+       void SoundManager::delMuteStateHandler(const MuteStateHandler &handler)
        {
                m_muteStateEvent -= handler;
        }
 
-       void SoundManager::addVolumeStateHandler(
-                       VolumeLevelHandler handler)
+       void SoundManager::addVolumeStateHandler(const VolumeLevelHandler &handler)
        {
                m_volumeLevelEvent += handler;
        }
 
-       void SoundManager::removeVolumeStateHandler(
-                       VolumeLevelHandler handler)
+       void SoundManager::delVolumeStateHandler(const VolumeLevelHandler &handler)
        {
                m_volumeLevelEvent -= handler;
        }
@@ -266,8 +278,8 @@ namespace callui {
        {
                int maxVol = 0;
                if (getAudioState() == AudioStateType::BT) {
-                       if (isBluetoothSupported()) {
-                               maxVol = m_btVolume->getMaxVolume();
+                       if (isBTSupported()) {
+                               maxVol = m_btManager->getMaxVolume();
                        } else {
                                ELOG("BT is not supported");
                        }
@@ -286,8 +298,8 @@ namespace callui {
        {
                int vol = 0;
                if (getAudioState() == AudioStateType::BT) {
-                       if (isBluetoothSupported()) {
-                               vol = m_btVolume->getVolume();
+                       if (isBTSupported()) {
+                               vol = m_btManager->getVolume();
                        } else {
                                ELOG("BT is not supported");
                        }
@@ -305,8 +317,8 @@ namespace callui {
        Result SoundManager::setVolume(int value)
        {
                if (getAudioState() == AudioStateType::BT) {
-                       if (isBluetoothSupported()) {
-                               return m_btVolume->setVolume(value);
+                       if (isBTSupported()) {
+                               return m_btManager->setVolume(value);
                        } else {
                                LOG_RETURN(RES_FAIL, "BT is not supported");
                        }
@@ -320,12 +332,29 @@ namespace callui {
                return RES_OK;
        }
 
-       bool SoundManager::isBluetoothSupported() const
+       bool SoundManager::isBTSupported() const
+       {
+               return (m_btManager != nullptr);
+       }
+
+       bool SoundManager::isBTHeadsetConnected() const
+       {
+               return (isBTSupported() ? m_btManager->isHeadsetConnected() : false);
+       }
+
+       void SoundManager::addBTHeadsetConnectionChangeHandler(
+                       const NotiHandler &handler)
+       {
+               m_btVoiceDeviceConnEvent += handler;
+       }
+
+       void SoundManager::delBTHeadsetConnectionChangeHandler(
+                       const NotiHandler &handler)
        {
-               return (m_btVolume != nullptr);
+               m_btVoiceDeviceConnEvent -= handler;
        }
 
-       void SoundManager::onDeviceVolumeChanged(sound_type_e type, unsigned int volume)
+       void SoundManager::onGearVolumeChanged(sound_type_e type, unsigned int volume)
        {
                DLOG("Volume [%d]", volume);
                if (type != SOUND_TYPE_CALL) {
@@ -338,7 +367,7 @@ namespace callui {
                }
        }
 
-       void SoundManager::onBluetoothVolumeChanged(int volume)
+       void SoundManager::onBTHeadsetVolumeChanged(int volume)
        {
                DLOG("Volume [%d]", volume);
 
index ac52c8954a4606e0dee7bec28bb982f2ae0a8fe1..4e993d8fb39b3e3ba3d6a5af1bb0eb2e4d63709a 100644 (file)
@@ -38,40 +38,62 @@ namespace callui {
                virtual ucl::Result setSpeakerState(bool isEnable) override final;
                virtual ucl::Result setBluetoothState(bool isEnable) override final;
                virtual AudioStateType getAudioState() const override final;
+
                virtual ucl::Result setMuteState(bool isEnable) override final;
                virtual bool getMuteState() const override final;
-               virtual ucl::Result startDtmf(const unsigned char dtmfDigit) override final;
+
+               virtual ucl::Result startDtmf(
+                               const unsigned char dtmfDigit) override final;
                virtual ucl::Result stopDtmf() override final;
-               virtual void addAudioStateHandler(AudioStateHandler handler) override final;
-               virtual void removeAudioStateHandler(AudioStateHandler handler) override final;
-               virtual void addMuteStateHandler(MuteStateHandler handler) override final;
-               virtual void removeMuteStateHandler(MuteStateHandler handler) override final;
-               virtual void addVolumeStateHandler(VolumeLevelHandler handler) override final;
-               virtual void removeVolumeStateHandler(VolumeLevelHandler handler) override final;
+
+               virtual void addAudioStateHandler(
+                               const AudioStateHandler &handler) override final;
+               virtual void delAudioStateHandler(
+                               const AudioStateHandler &handler) override final;
+
+               virtual void addMuteStateHandler(
+                               const MuteStateHandler &handler) override final;
+               virtual void delMuteStateHandler(
+                               const MuteStateHandler &handler) override final;
+
+               virtual void addVolumeStateHandler(
+                               const VolumeLevelHandler &handler) override final;
+               virtual void delVolumeStateHandler(
+                               const VolumeLevelHandler &handler) override final;
+
                virtual int getMaxVolume() const override final;
                virtual int getVolume() const override final;
                virtual ucl::Result setVolume(int value) override final;
-               virtual bool isBluetoothSupported() const override final;
+
+               virtual bool isBTSupported() const override final;
+
+               virtual bool isBTHeadsetConnected() const override final;
+               virtual void addBTHeadsetConnectionChangeHandler(
+                               const NotiHandler &handler) override final;
+               virtual void delBTHeadsetConnectionChangeHandler(
+                               const NotiHandler &handler) override final;
 
        private:
                friend class ucl::ReffedObj<SoundManager>;
                SoundManager(ucl::IRefCountObj &rc, const CallClientSRef &client);
 
                ucl::Result prepare();
-               ucl::Result registerVolumeCallbacks();
+               ucl::Result registerCallbacks();
 
-               void audioStateChangedCb(cm_audio_state_type_e state);
-               void muteStateChangedCb(cm_mute_status_e status);
+               void onAudioStateChanged(cm_audio_state_type_e state);
+               void onMuteStateChanged(cm_mute_status_e status);
+               void onHeadsetConnectionChanged();
 
-               void onBluetoothVolumeChanged(int volume);
-               void onDeviceVolumeChanged(sound_type_e type, unsigned int volume);
+               void onBTHeadsetVolumeChanged(int volume);
+               void onGearVolumeChanged(sound_type_e type, unsigned int volume);
 
        private:
                CallClientSRef m_client;
-               BluetoothVolumeSRef m_btVolume;
+               BluetoothManagerSRef m_btManager;
                AudioStateEvent m_audioStateEvent;
                MuteStateEvent m_muteStateEvent;
                VolumeLevelEvent m_volumeLevelEvent;
+               ucl::Event<NotiHandler> m_btVoiceDeviceConnEvent;
                int m_deviceVolumeCbID;
        };
 
index 9575717192a8f2f68eba620e0caea85506d6f8c8..7e2b341ea93466f3e679ee87048bea55c8a00a32 100644 (file)
@@ -72,7 +72,7 @@ namespace callui {
 
        UCL_DECLARE_REF_ALIASES(ContactInfoProvider);
 
-       UCL_DECLARE_REF_ALIASES(BluetoothVolume);
+       UCL_DECLARE_REF_ALIASES(BluetoothManager);
 
        using AudioStateEvent = ucl::Event<AudioStateHandler>;
        using MuteStateEvent = ucl::Event<MuteStateHandler>;
index efe38880c067f0ddfdd6a54cf4d5f95cef8474a8..831637b9b2e6abfc292a5b847d7634bb9462b15d 100644 (file)
 #include "presenters/AcceptRejectPresenter.h"
 
 #include "model/IIncomingCall.h"
+#include "model/ISoundManager.h"
+
 #include "presenters/AcceptDialog.h"
 #include "presenters/MotionSensorPresenter.h"
 
 #include "view/AcceptRejectWidget.h"
 
-#include "../view/common.h"
 #include "common.h"
 
 namespace callui {
 
        using namespace ucl;
 
-       // IncomingCallPresenter::Builder
+       // AcceptRejectPresenter::Builder
 
        AcceptRejectPresenter::Builder::Builder():
                        m_callMask(CALL_FLAG_NONE)
@@ -41,7 +42,8 @@ namespace callui {
        }
 
        AcceptRejectPresenter::Builder &
-       AcceptRejectPresenter::Builder::setIncomingCall(const IIncomingCallSRef &call)
+       AcceptRejectPresenter::Builder::setIncomingCall(
+                       const IIncomingCallSRef &call)
        {
                m_call = call;
                return *this;
@@ -54,6 +56,14 @@ namespace callui {
                return *this;
        }
 
+       AcceptRejectPresenter::Builder &
+       AcceptRejectPresenter::Builder::setSoundManager(
+                       const ISoundManagerSRef &sm)
+       {
+               m_sm = sm;
+               return *this;
+       }
+
        AcceptRejectPresenter::Builder &
        AcceptRejectPresenter::Builder::setParentWidget(
                        const ElmWidgetSRef &parentWidget)
@@ -65,24 +75,28 @@ namespace callui {
        AcceptRejectPresenterSRef
        AcceptRejectPresenter::Builder::build(GuiPresenter &parent) const
        {
-               if (!m_parentWidget) {
-                       LOG_RETURN_VALUE(RES_FAIL, {}, "m_parentWidget is NULL");
+               if (!m_parentWidget || !m_call || !m_sm) {
+                       LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
                }
 
-               auto result = makeShared<AcceptRejectPresenter>(m_call, m_callMask);
+               auto result = makeShared<AcceptRejectPresenter>(m_call,
+                               m_callMask,
+                               m_sm);
                FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget),
                                {}, "result->prepare() failed!");
                return result;
        }
 
-       // IncomingCallPresenter
+       // AcceptRejectPresenter
 
        AcceptRejectPresenter::AcceptRejectPresenter(IRefCountObj &rc,
                        const IIncomingCallSRef &call,
-                       CallMask calls):
+                       CallMask calls,
+                       const ISoundManagerSRef &sm):
                        GuiPresenter(rc),
                        m_call(call),
-                       m_callMask(calls)
+                       m_callMask(calls),
+                       m_sm(sm)
        {
        }
 
@@ -95,6 +109,11 @@ namespace callui {
                if (m_widget) {
                        m_widget->deactivateRotary();
                }
+
+               m_sm->delBTHeadsetConnectionChangeHandler(
+                               WEAK_DELEGATE(AcceptRejectPresenter::
+                                               onBTHeadsetConnectionChanged,
+                                               asWeak(*this)));
        }
 
        Result AcceptRejectPresenter::prepare(GuiPresenter &parent,
@@ -103,6 +122,11 @@ namespace callui {
                FAIL_RETURN(GuiPresenter::prepare(parent),
                                "Presenter::prepare() failed!");
 
+               m_sm->addBTHeadsetConnectionChangeHandler(
+                               WEAK_DELEGATE(AcceptRejectPresenter::
+                                               onBTHeadsetConnectionChanged,
+                                               asWeak(*this)));
+
                FAIL_RETURN(createWidget(parentWidget),
                                "createWidget() failed!");
 
@@ -139,6 +163,9 @@ namespace callui {
                                setRejectEventHandler(WEAK_DELEGATE(
                                                AcceptRejectPresenter::onRejectEvent,
                                                asWeak(*this))).
+                               setAcceptBtnType(m_sm->isBTHeadsetConnected() ?
+                                               AcceptButtonType::BT_HEADSET :
+                                               AcceptButtonType::SIMPLE).
                                build(parent);
                if (!m_widget) {
                        LOG_RETURN(RES_FAIL, "Layout::build() failed!");
@@ -186,7 +213,8 @@ namespace callui {
                m_call->reject();
        }
 
-       bool AcceptRejectPresenter::onAcceptPopupEvent(AcceptDialog &popup, AcceptDialogEvent event)
+       bool AcceptRejectPresenter::onAcceptPopupEvent(AcceptDialog &popup,
+                       AcceptDialogEvent event)
        {
                m_widget->reset();
 
@@ -194,12 +222,14 @@ namespace callui {
                case AcceptDialogEvent::HOLD_AND_ACCEPT:
                        FAIL_RETURN_VALUE(
                                        m_call->answer(CallAnswerType::HOLD_ACTIVE_AND_ACCEPT),
-                                       true, "incom->answer() failed!");
+                                       true,
+                                       "incom->answer() failed!");
                        return false;
                case AcceptDialogEvent::END_AND_ACCEPT:
                        FAIL_RETURN_VALUE(
                                        m_call->answer(CallAnswerType::RELEASE_ACTIVE_AND_ACCEPT),
-                                       true, "incom->answer() failed!");
+                                       true,
+                                       "incom->answer() failed!");
                        return false;
                default:
                        return true;
@@ -241,4 +271,12 @@ namespace callui {
                m_widget->deactivateRotary();
        }
 
+       void AcceptRejectPresenter::onBTHeadsetConnectionChanged()
+       {
+               m_widget->setAcceptBtnType(m_sm->isBTHeadsetConnected() ?
+                               AcceptButtonType::BT_HEADSET :
+                               AcceptButtonType::SIMPLE);
+       }
+
+
 }
index 75240b233b2f3a65941d9d044dccc184dcc139d3..23787f01403d0643d977ebf914ad7bc58c693271 100644 (file)
@@ -369,7 +369,7 @@ namespace callui {
                (m_audioState == AudioStateType::BT) ?
                                m_bluetoothBtn->emit(impl::SIGNAL_TURN_ON) :
                                m_bluetoothBtn->emit(impl::SIGNAL_TURN_OFF);
-               if (!m_sm->isBluetoothSupported()) {
+               if (!m_sm->isBTSupported()) {
                        disable(*m_bluetoothBtn);
                }
 
@@ -509,13 +509,13 @@ namespace callui {
                delRotaryEventHandler(
                                CALLBACK_A(AccessoryPresenter::onRotaryEvent), this);
 
-               m_sm->removeAudioStateHandler(DELEGATE(
+               m_sm->delAudioStateHandler(DELEGATE(
                                AccessoryPresenter::onAudioStateChanged, this));
 
-               m_sm->removeVolumeStateHandler(DELEGATE(
+               m_sm->delVolumeStateHandler(DELEGATE(
                                AccessoryPresenter::onVolumeLevelChanged, this));
 
-               m_sm->removeMuteStateHandler(DELEGATE(
+               m_sm->delMuteStateHandler(DELEGATE(
                                AccessoryPresenter::onMuteStateChanged, this));
        }
 
index 09030ba00c98d5a6e56bf602ae9912830ff01059..9f787da9eea479fa8d9c0cf5a5c5f9c03800ee87 100644 (file)
@@ -517,7 +517,8 @@ namespace callui {
                                        || (info->getConferenceMemberCount() > 1)) {
                                // Font size and color
                                if (info->isEmergency()) {
-                                       m_widget->emit(impl::SIGN_EMERGENCY_BIG_TXT, impl::SRC_TXT_1LINE);
+                                       m_widget->emit(impl::SIGN_EMERGENCY_BIG_TXT,
+                                                       impl::SRC_TXT_1LINE);
                                } else {
                                        m_widget->emit(impl::SIGN_BIG_TXT, impl::SRC_TXT_1LINE);
                                }
index 5bc6b64cb048dc689f30db887dc6ada9f586fb7d..d2f512fb359b82589c9db485df7cbba26b58bd6d 100644 (file)
@@ -497,10 +497,10 @@ namespace callui {
                delRotaryEventHandler(
                                CALLBACK_A(KeypadPage::onRotaryEvent), this);
 
-               m_sm->removeAudioStateHandler(DELEGATE(
+               m_sm->delAudioStateHandler(DELEGATE(
                                KeypadPage::onAudioStateChanged, this));
 
-               m_sm->removeVolumeStateHandler(DELEGATE(
+               m_sm->delVolumeStateHandler(DELEGATE(
                                KeypadPage::onVolumeLevelChanged, this));
        }
 }
index 0ce8909107cfd021cf1068dfc0098da6e32d4c7c..0d10949f95dfba14ce28e89d6298a49472a4f0fb 100644 (file)
@@ -590,6 +590,7 @@ namespace callui {
                m_acceptRejectPrs = AcceptRejectPresenter::Builder().
                                setIncomingCall(m_cm->getIncomingCall()).
                                setAvailableCallsFlag(m_cm->getAvailableCalls()).
+                               setSoundManager(m_call->getSoundManager()).
                                setParentWidget(m_widget).
                                build(*this);
 
index 4a53750b801f5449bbad3bd891fa99ba471ebced..f8841a77a307f0c1a6a8de8460c8b669ae5f9ae6 100644 (file)
 
 #include "view/AcceptRejectWidget.h"
 
-#include <efl_extension.h>
-#include <functional>
-#include <math.h>
-
-#include <ucl/appfw/helpers.h>
-
 #include "common.h"
 
 #define CU_COL_TRANSPARENT  0, 0, 0, 0
@@ -51,8 +45,13 @@ namespace callui { namespace { namespace impl {
 
        constexpr LayoutTheme LAYOUT_IMG_ACTION_BG
                        {"layout", "callui_image", "accept_reject_action_bg"};
+
        constexpr LayoutTheme LAYOUT_IMG_ACCEPT
                        {"layout", "callui_image", "accept"};
+
+       constexpr LayoutTheme LAYOUT_IMG_ACCEPT_BT_HEADSET
+                       {"layout", "callui_image", "accept_bt_headset"};
+
        constexpr LayoutTheme LAYOUT_IMG_REJECT
                        {"layout", "callui_image", "reject"};
 
@@ -138,7 +137,7 @@ namespace callui { namespace { namespace impl {
        constexpr EdjePart PART_SWL_REJECT_ICON
                        {"swl.reject.icon"};
 
-       ElmWidgetSRef createImage(ElmWidget &parent, const LayoutTheme &theme)
+       LayoutSRef createImage(ElmWidget &parent, const LayoutTheme &theme)
        {
                auto layout = Layout::Builder().
                                setTheme(theme).
@@ -164,7 +163,8 @@ namespace callui {
 
        using namespace ucl;
 
-       AcceptRejectWidget::Builder::Builder()
+       AcceptRejectWidget::Builder::Builder() :
+               m_acceptBtnType(AcceptButtonType::SIMPLE)
        {
        }
 
@@ -184,6 +184,13 @@ namespace callui {
                return *this;
        }
 
+       AcceptRejectWidget::Builder &
+       AcceptRejectWidget::Builder::setAcceptBtnType(AcceptButtonType type)
+       {
+               m_acceptBtnType = type;
+               return *this;
+       }
+
        AcceptRejectWidgetSRef
        AcceptRejectWidget::Builder::build(ElmWidget &parent) const
        {
@@ -196,7 +203,7 @@ namespace callui {
                }
 
                auto result = makeShared<AcceptRejectWidget>(layout,
-                               m_acceptHandler, m_rejectHandler);
+                               m_acceptHandler, m_rejectHandler, m_acceptBtnType);
 
                result->bindToEo();
 
@@ -206,7 +213,8 @@ namespace callui {
        AcceptRejectWidget::AcceptRejectWidget(IRefCountObj &rc,
                        const LayoutSRef &layout,
                        const NotiHandler &acceptHandler,
-                       const NotiHandler &rejectHandler):
+                       const NotiHandler &rejectHandler,
+                       AcceptButtonType acceptBtnType):
                ElmWidget(&rc, *layout, true),
                m_layout(layout.get()),
                m_accHandler(acceptHandler),
@@ -233,7 +241,8 @@ namespace callui {
                m_accBCAnimCount(0),
                m_rejBCAnimCount(0),
                m_accBCAnimIndex(impl::BC_ITEM_COUNT - 1),
-               m_rejBCAnimIndex(impl::BC_ITEM_COUNT - 1)
+               m_rejBCAnimIndex(impl::BC_ITEM_COUNT - 1),
+               m_acceptBtnType(acceptBtnType)
        {
                prepare();
        }
@@ -256,18 +265,18 @@ namespace callui {
                m_rejEventLy->delEventHandler(WidgetEvent::MOUSE_MOVE,
                                WEAK_DELEGATE(AcceptRejectWidget::onMouseMove, asWeak(*this)));
 
-               DEL_TRANSIT_FULL(m_lastAccBezelTr1);
-               DEL_TRANSIT_FULL(m_lastAccBezelTr2);
-               DEL_TRANSIT_FULL(m_lastRejBezelTr1);
-               DEL_TRANSIT_FULL(m_lastRejBezelTr2);
+               DEL_TRANSIT(m_lastAccBezelTr1);
+               DEL_TRANSIT(m_lastAccBezelTr2);
+               DEL_TRANSIT(m_lastRejBezelTr1);
+               DEL_TRANSIT(m_lastRejBezelTr2);
 
-               DEL_TRANSIT_FULL(m_accTracerTr);
-               DEL_TRANSIT_FULL(m_accGuideTr);
-               DEL_TRANSIT_FULL(m_accIconTr);
+               DEL_TRANSIT(m_accTracerTr);
+               DEL_TRANSIT(m_accGuideTr);
+               DEL_TRANSIT(m_accIconTr);
 
-               DEL_TRANSIT_FULL(m_rejTracerTr);
-               DEL_TRANSIT_FULL(m_rejGuideTr);
-               DEL_TRANSIT_FULL(m_rejIconTr);
+               DEL_TRANSIT(m_rejTracerTr);
+               DEL_TRANSIT(m_rejGuideTr);
+               DEL_TRANSIT(m_rejIconTr);
 
                eext_rotary_object_event_callback_del(*m_layout, CALLBACK_A(
                                AcceptRejectWidget::onRotaryEvent));
@@ -306,7 +315,16 @@ namespace callui {
                m_layout->setContent(*m_accGuide,
                                impl::PART_SWL_ACCEPT_FINGER_GUIDE_BG);
 
-               m_accIcon = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACCEPT);
+               switch (m_acceptBtnType) {
+               case AcceptButtonType::BT_HEADSET:
+                       m_accIcon = impl::createImage(*m_layout,
+                                       impl::LAYOUT_IMG_ACCEPT_BT_HEADSET);
+                       break;
+               default:
+                       m_accIcon = impl::createImage(*m_layout,
+                                       impl::LAYOUT_IMG_ACCEPT);
+                       break;
+               }
                if (!m_accIcon) {
                        LOG_RETURN(RES_FAIL, "createImage() failed");
                }
@@ -1292,6 +1310,26 @@ namespace callui {
                eext_rotary_object_event_activated_set(*m_layout, EINA_FALSE);
        }
 
+       void AcceptRejectWidget::setAcceptBtnType(AcceptButtonType type)
+       {
+               if (m_acceptBtnType == type) {
+                       DLOG("Accept icon type is already set");
+               }
+
+               if (!m_accIcon) {
+                       return;
+               }
+
+               switch (m_acceptBtnType) {
+               case AcceptButtonType::BT_HEADSET:
+                       m_accIcon->setTheme(impl::LAYOUT_IMG_ACCEPT_BT_HEADSET);
+                       break;
+               default:
+                       m_accIcon->setTheme(impl::LAYOUT_IMG_ACCEPT);
+                       break;
+               }
+       }
+
        void AcceptRejectWidget::reset()
        {
                m_isFreezed = false;
index 85e3887c7dd5412324be7aa31538035bdf7b3c8a..6e6cd0b2241754a71cd13731b3d595adb95cb61a 100644 (file)
 #include "../common.h"
 
 #define DEL_TRANSIT(ptr) \
-       do { \
-               if (ptr) { \
-                       elm_transit_del(ptr); \
-                       ptr = nullptr; \
-               } \
-       } while (0)
-
-#define DEL_TRANSIT_FULL(ptr) \
        do { \
                if (ptr) { \
                        elm_transit_del_cb_set(ptr, nullptr, nullptr); \