Fix for Bluetooth device handling. and N_SE-54946 N_SE-54953
authorAmith Kumar Mahale <amith.m@samsung.com>
Thu, 10 Oct 2013 07:12:05 +0000 (12:42 +0530)
committerAmith Kumar Mahale <amith.m@samsung.com>
Thu, 10 Oct 2013 07:12:05 +0000 (12:42 +0530)
Change-Id: Ief875d3347d80f8485c4b549db19ffc147c8af38
Signed-off-by: Amith Kumar Mahale <amith.m@samsung.com>
inc/CallSoundManager.h
inc/CallTelephonyManager.h
src/CallActiveCallForm.cpp
src/CallBaseForm.cpp
src/CallSoundManager.cpp
src/CallTelephonyManager.cpp

index b621189..2f0f821 100644 (file)
@@ -26,6 +26,7 @@
 #include <FBase.h>
 #include <FSystem.h>
 #include <FMedia.h>
+#include "ITapiCall.h"
 #include "sound_manager.h"
 #include "vconf.h"
 #include "vconf-keys.h"
@@ -68,6 +69,8 @@ public:
        Timer* GetTimer();
        bool GetLastConferenceCall();
        void SetlastEndedConferenceCall();
+       result SetSoundPath(bool bSpeaker=false);
+       static void HandleCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData){}
 
 protected:
                virtual void OnPlayerOpened(result r);
index f759777..0a4a5a4 100644 (file)
@@ -123,6 +123,8 @@ public:
        static void HandleSplitFromConferenceCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
        //callback function for Ending conference call
        static void HandleEndConferenceCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
+       //Called when bluetooth connection state changes
+       static void OnBluetoothStateChange(keynode_t *node, void *user_data);
        //Check if MOCall is emergency number and returns true. Otherwise, false.
        bool CheckIfMOCallIsEmergency(const Tizen::Base::String& contactNumber, bool isSimInitialized);
        //Check is modem and sim are initialised successfully and MO call can be made.
@@ -144,6 +146,8 @@ public:
        bool IsIncomingorDialingCallPresent(void);
        //Function to make out going call when hold is succesful on the active call
        void CheckPendingDialCalls(int callBackResult);
+       TapiHandle* GetTapiHandle(void);
+       void SetSoundPath(void);
        
 protected:
        //function to handle the idle callback(received when call is ended)
index abc5080..1e16a2d 100644 (file)
@@ -1502,25 +1502,28 @@ ActiveCallForm::OnContactsChanged(const Tizen::Base::Collection::IList& contactC
        case FORMTYPE_ACTIVECALL:
        {
                String pContactNumber;
-               pContactNumber.Append(__pActiveCallInfo->GetContactNumber());
-               Contact* pContact = __pCallPresentor->GetContactN(__pActiveCallInfo->GetContactNumber());
-               if(pContact == null)
+               if(__pActiveCallInfo->GetContactNumber().IsEmpty() == false)
                {
-                       __pActiveCallInfo->ResetContactNumber(null);
-                       __pActiveCallInfo->ResetContactInfo(null);
+                       pContactNumber.Append(__pActiveCallInfo->GetContactNumber());
+                       Contact* pContact = __pCallPresentor->GetContactN(__pActiveCallInfo->GetContactNumber());
+                       if(pContact == null)
+                       {
+                               __pActiveCallInfo->ResetContactNumber(null);
+                               __pActiveCallInfo->ResetContactInfo(null);
 
+                       }
+                       else
+                       {
+                               __pActiveCallInfo->SetContactNumber(pContactNumber);
+                               __pActiveCallInfo->SetContactInfo(*pContact);
+                       }
+                       if(pContact != null)
+                       {
+                               delete pContact;
+                               pContact = null;
+                       }
+                       ShowPersonDetails(pContactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
                }
-               else
-               {
-                       __pActiveCallInfo->SetContactNumber(pContactNumber);
-                       __pActiveCallInfo->SetContactInfo(*pContact);
-               }
-               if(pContact != null)
-               {
-                       delete pContact;
-                       pContact = null;
-               }
-               ShowPersonDetails(pContactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
        }
        break;
 
@@ -1547,35 +1550,38 @@ ActiveCallForm::OnContactsChanged(const Tizen::Base::Collection::IList& contactC
                                }
                                *__pActiveCallInfo =  callInfo;
                                String contactNumber;
-                               contactNumber.Append(__pActiveCallInfo->GetContactNumber());
-                               pContact = __pCallPresentor->GetContactN(__pActiveCallInfo->GetContactNumber());
-                               if(pContact == null)
+                               if(__pActiveCallInfo->GetContactNumber().IsEmpty() == false)
                                {
-                                       __pActiveCallInfo->ResetContactNumber(null);
-                                       __pActiveCallInfo->ResetContactInfo(null);
+                                       contactNumber.Append(__pActiveCallInfo->GetContactNumber());
+                                       pContact = __pCallPresentor->GetContactN(__pActiveCallInfo->GetContactNumber());
+                                       if(pContact == null)
+                                       {
+                                               __pActiveCallInfo->ResetContactNumber(null);
+                                               __pActiveCallInfo->ResetContactInfo(null);
 
-                               }
-                               else
-                               {
-                                       __pActiveCallInfo->SetContactNumber(contactNumber);
-                                       __pActiveCallInfo->SetContactInfo(*pContact);
-                               }
-                               if(pContact != null)
-                               {
-                                       delete pContact;
-                                       pContact = null;
-                               }
-                               if(callInfo.IsConferenceCall() == true)
-                               {
-                                       continue;
-                               }
-                               if(callInfo.IsOnHold() == false)
-                               {
-                                       ShowPersonDetails(contactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
-                               }
-                               else
-                               {
-                                       ShowPersonDetails(contactNumber, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pActiveCallInfo);
+                                       }
+                                       else
+                                       {
+                                               __pActiveCallInfo->SetContactNumber(contactNumber);
+                                               __pActiveCallInfo->SetContactInfo(*pContact);
+                                       }
+                                       if(pContact != null)
+                                       {
+                                               delete pContact;
+                                               pContact = null;
+                                       }
+                                       if(callInfo.IsConferenceCall() == true)
+                                       {
+                                               continue;
+                                       }
+                                       if(callInfo.IsOnHold() == false)
+                                       {
+                                               ShowPersonDetails(contactNumber, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
+                                       }
+                                       else
+                                       {
+                                               ShowPersonDetails(contactNumber, IDC_NUMBER2_LABEL, IDC_CALLER2_LABEL, true,__pActiveCallInfo);
+                                       }
                                }
 
                        }
index c92e90d..f01febf 100644 (file)
@@ -45,6 +45,12 @@ BaseForm::BaseForm(FormType formType)
 
 BaseForm::~BaseForm(void)
 {
+       AppLogDebug("Enter");
+       if(__pErrorMsgPopup != null)
+       {
+               delete __pErrorMsgPopup;
+               __pErrorMsgPopup = null;
+       }
 }
 
 result
index e2680b5..635e621 100644 (file)
@@ -19,6 +19,8 @@
  * @brief   Sound manager class
  */
 #include "CallSoundManager.h"
+#include "CallTelephonyManager.h"
+#include "vconf.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
@@ -143,10 +145,64 @@ SoundManager::StartSession(void)
        sound_manager_set_active_route((sound_route_e)SOUND_ROUTE_IN_MIC_OUT_RECEIVER);
        //todo start listening for volume key and set the volume
        sound_manager_set_volume((sound_type_e)SOUND_TYPE_CALL,5);
+       //
+       SetSoundPath();
        return E_SUCCESS;
 }
 
 result
+SoundManager::SetSoundPath(bool bSpeaker)
+{
+       AppLogDebug("Enter");
+       int btStatus;
+       TelCallSoundPathInfo_t callSoundPathInfo;
+       sound_route_e soundRoute;
+       bool isEarJackPresent = IsEarJackConnected();
+       vconf_get_int(VCONFKEY_BT_HEADSET_SCO,&btStatus);
+       if(btStatus == VCONFKEY_BT_SCO_CONNECT)
+       {
+               AppLogDebug("Routing audio input and output to bluetooth SCO");
+               callSoundPathInfo.path = TAPI_SOUND_PATH_BLUETOOTH;
+               soundRoute = SOUND_ROUTE_INOUT_BLUETOOTH;
+       }
+       else
+       {
+               if(bSpeaker == false)
+               {
+                       if (isEarJackPresent == true)
+                       {
+                               AppLogDebug("Routing audio input to device builtin mic and routing audio output to headphone");
+                               soundRoute = SOUND_ROUTE_IN_MIC_OUT_HEADPHONE;
+                               callSoundPathInfo.path = TAPI_SOUND_PATH_HEADSET;
+                       }
+                       else
+                       {
+                               AppLogDebug("Routing audio input to device builtin mic and routing audio output to builtin receiver");
+                               soundRoute = SOUND_ROUTE_IN_MIC_OUT_RECEIVER;
+                               callSoundPathInfo.path = TAPI_SOUND_PATH_HANDSET;
+                       }
+               }
+               else
+               {
+                       AppLogDebug("Routing audio input to device builtin mic and routing audio output to builtin speaker");
+                       soundRoute = SOUND_ROUTE_IN_MIC_OUT_SPEAKER;
+                       callSoundPathInfo.path = TAPI_SOUND_PATH_SPK_PHONE;
+               }
+
+       }
+       callSoundPathInfo.ex_volume = TelCallSoundPathInfo_t::TAPI_SOUND_EX_VOLUME_ON;
+
+       int res = tel_set_call_sound_path(TelephonyManager::GetInstance(null)->GetTapiHandle(), &callSoundPathInfo, &HandleCallbackResponse, this);
+       TryReturn(res == TAPI_CAUSE_SUCCESS,E_FAILURE, "[%d] tel_set_call_sound_path failed",res );
+
+       res = sound_manager_set_active_route(soundRoute);
+       TryReturn(res == SOUND_MANAGER_ERROR_NONE,E_FAILURE, "[%d] sound_manager_set_active_route failed",res );
+
+       return E_SUCCESS;
+       AppLogDebug("Exit");
+}
+
+result
 SoundManager::SetSpeakerStatus(bool setSpeaker)
 {
        result r = E_FAILURE;
index 108fef9..5cd1b8b 100644 (file)
@@ -181,6 +181,7 @@ TelephonyManager::DestroyInstance(void)
                delete __pManager;
                __pManager = null;
        }
+       vconf_ignore_key_changed(VCONFKEY_BT_HEADSET_SCO,TelephonyManager::OnBluetoothStateChange);
        AppLogDebug("Exit");
 }
 
@@ -214,6 +215,7 @@ TelephonyManager::Initialize(void)
        {
                __pNetworkManager->Construct(this);
        }
+       vconf_notify_key_changed(VCONFKEY_BT_HEADSET_SCO,TelephonyManager::OnBluetoothStateChange,this);
        AppLogDebug("Exit");
        return r;
 }
@@ -1293,7 +1295,12 @@ result
 TelephonyManager::SetSpeakerStatus(bool setSpeaker)
 {
        AppLogDebug("Enter");
-       result r = E_FAILURE;
+
+       result res = __pSoundManager->SetSoundPath(setSpeaker);
+       TryReturn(res==E_SUCCESS,E_FAILURE,"SetSoundPath failed");
+       __isSpeakerOn = setSpeaker;
+       return  E_SUCCESS;
+       /*result r = E_FAILURE;
        TelCallSoundPathInfo_t callSoundPathInfo;
        __pSoundManager->SetSpeakerStatus(setSpeaker);
        if (setSpeaker == true)
@@ -1318,7 +1325,7 @@ TelephonyManager::SetSpeakerStatus(bool setSpeaker)
                r = E_FAILURE;
        }
        AppLogDebug("Exit");
-       return r;
+       return r;*/
 }
 
 bool
@@ -3023,3 +3030,27 @@ TelephonyManager::CheckPendingDialCalls(int callBackResult)
        }
 
 }
+
+TapiHandle*
+TelephonyManager::GetTapiHandle(void)
+{
+       return __pTapiHandle;
+}
+
+void
+TelephonyManager::SetSoundPath(void)
+{
+       if(GetCurrentCallCount() > 0 && IsIncomingorDialingCallPresent() == true)
+       {
+               __pSoundManager->SetSoundPath();
+       }
+
+}
+
+void
+TelephonyManager::OnBluetoothStateChange(keynode_t *node, void *user_data)
+{
+       AppLogDebug("Enter");
+       TelephonyManager* pTelMgr = (TelephonyManager*)user_data;
+       pTelMgr->SetSoundPath();
+}