Fix for N_SE-47477
authorAmith Kumar Mahale <amith.m@samsung.com>
Mon, 29 Jul 2013 14:16:05 +0000 (19:46 +0530)
committerAmith Kumar Mahale <amith.m@samsung.com>
Tue, 30 Jul 2013 13:01:57 +0000 (18:31 +0530)
Change-Id: I388d95b398f308f467d9eff83ee8d3d026c10156
Signed-off-by: Amith Kumar Mahale <amith.m@samsung.com>
inc/CallActiveCallForm.h
inc/CallApp.h
inc/CallInfo.h
src/CallActiveCallForm.cpp
src/CallApp.cpp
src/CallConfCallerListForm.cpp
src/CallInfo.cpp
src/CallTelephonyManager.cpp
src/CalllogManager.cpp

index 8e3782d..d7e5820 100644 (file)
@@ -135,6 +135,7 @@ private:
 private:
        //Start time for Active call
        long long __activeCallStartTime;
+       long long __referenceticks;
        //Timer used to show call time
        Tizen::Base::Runtime::Timer* __pActiveCallTimer;
        //Custom Buttons Panel
index ca5fe66..f01e4f6 100644 (file)
@@ -91,6 +91,8 @@ public:
        virtual void OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData);
        //Called when incoming call has to be handled
        void SetTopMostWindow(bool bTopMost);
+       //Gets the time duration since appplication has been launched
+       long long GetCallAppTicks(void);
 
 private:
        //internal function to process AppControl request.
@@ -116,6 +118,8 @@ private:
        Tizen::Base::Collection::ArrayList __listenerList;
        Tizen::Ui::Controls::Popup* __pCallRejectedIonPopup;
        Tizen::Base::Runtime::Timer __callRejectedIontimer;
+       long long __callTicks;
+       Tizen::Base::Runtime::Timer* __pCallAppTimer;
 };
 
 #endif // _CALLAPP_H_
index eca5570..1458554 100644 (file)
@@ -79,8 +79,12 @@ public:
        long long GetCallConnectTime(void);
        //Sets the connected time when call started
        void SetCallConnectTime(long long connectTime);
+       //Set the duration time wrt to call app time
+       void SetDurationTime(long long durationTime);
        //get the notified / dialed time when call started
        long long GetCallNotificationTime(void);
+       //Gets the duration wrt to callapp time
+       long long GetDurationTime(void);
        //Sets the notified / dialed time when call started
        void SetCallNotificationTime(long long callNotificationTime);
        //gets the end call cause
@@ -155,6 +159,8 @@ private:
        //system time when call connected
        long long __callConnectTime;
 
+       long long __durationTime;
+
        //system time when the call was notified / dialed
        long long __callNotificationTime;
 
index e7c1274..4312aac 100644 (file)
@@ -968,9 +968,9 @@ ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
                        activeContactNo.Append(AppUtility::GetResourceString(IDS_NUMBER_UNKNOWN));
                }
                ShowPersonDetails(activeContactNo, IDC_NUMBER1_LABEL, IDC_CALLER1_LABEL, false,__pActiveCallInfo);
-
                //show call active time using Timer
-               __activeCallStartTime = pCall->GetCallConnectTime();
+               //__activeCallStartTime = pCall->GetCallConnectTime();
+               __activeCallStartTime = pCall->GetDurationTime();
                ShowTimerInfo(IDC_CALLER1_TIME_LABEL, pCall->IsOnHold(), __activeCallStartTime);
        }
        break;
@@ -984,7 +984,8 @@ ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
                *__pActiveCallInfo =  *pCall;
 
                //show call active time using Timer
-               __activeCallStartTime = pCall->GetCallConnectTime();
+               //__activeCallStartTime = pCall->GetCallConnectTime();
+               __activeCallStartTime = pCall->GetDurationTime();
                ShowTimerInfo(IDC_CALLER1_TIME_LABEL, pCall->IsOnHold(), __activeCallStartTime);
        }
        break;
@@ -1034,7 +1035,8 @@ ActiveCallForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
 
 
                //show call active time using Timer
-               __activeCallStartTime = __pActiveCallInfo->GetCallConnectTime();
+               //__activeCallStartTime = __pActiveCallInfo->GetCallConnectTime();
+               __activeCallStartTime = __pActiveCallInfo->GetDurationTime();
                ShowTimerInfo(IDC_CALLER1_TIME_LABEL, __pActiveCallInfo->IsOnHold(),__activeCallStartTime);
        }
        break;
@@ -1403,7 +1405,8 @@ ActiveCallForm::UpdateMultipleCallScreen(Tizen::Base::Collection::IListT<AppCall
                                }
                        }
                        //show call active time using Timer
-                       __activeCallStartTime = __pActiveCallInfo->GetCallConnectTime();
+                       //__activeCallStartTime = __pActiveCallInfo->GetCallConnectTime();
+                       __activeCallStartTime = __pActiveCallInfo->GetDurationTime();
                        ShowTimerInfo(IDC_CALLER1_TIME_LABEL,false,__activeCallStartTime);
                }
                else
@@ -1729,7 +1732,9 @@ ActiveCallForm::ShowTimerInfo(const String& timerLblName, bool isOnHold, long lo
                        SetHoldButtonStatus(true);
                        //current system time
                        long long currTime = 0;
-                       SystemTime::GetTicks(currTime);
+                       //SystemTime::GetTicks(currTime);
+                       CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
+                       currTime = pPhoneApp->GetCallAppTicks();
                        //Set call duration
                        TimeSpan diffSpan(abs(startTime - currTime));
 
index 7bb16a5..0b39b9b 100644 (file)
@@ -47,6 +47,8 @@ CallApp::CallApp(void):__initialSceneId(L""), __pLaunchArgs(null)
 {
        __listenerList.Construct();
        __pCallRejectedIonPopup = null;
+       __pCallAppTimer = null;
+       __callTicks = 0;
 }
 
 CallApp::~CallApp(void)
@@ -95,6 +97,17 @@ CallApp::OnAppInitialized(void)
                return false;
        }
 
+       if (__pCallAppTimer == null)
+       {
+               __pCallAppTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
+               __pCallAppTimer->Construct(*this);
+               long long currTime = 0;
+               SystemTime::GetTicks(currTime);
+               __callTicks = currTime;
+               __pCallAppTimer->StartAsRepeatable(TimeSpan::NUM_OF_TICKS_IN_SECOND);
+       }
+
+
        return true;
 }
 
@@ -113,6 +126,12 @@ CallApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
        // Deallocate resources allocated by this App for termination.
        // The App's permanent data and context can be saved via appRegistry.
        PowerManager::RemoveScreenEventListener(*this);
+       if (__pCallAppTimer != null)
+       {
+               __pCallAppTimer->Cancel();
+               delete __pCallAppTimer;
+       }
+
        return true;
 }
 
@@ -439,10 +458,18 @@ CallApp::ShowAutoRejectPopup(Tizen::Base::String contactNumber)
 void
 CallApp::OnTimerExpired(Tizen::Base::Runtime::Timer &timer)
 {
-       if(__pCallRejectedIonPopup != null)
+       if (__callRejectedIontimer.Equals(timer))
        {
-               delete __pCallRejectedIonPopup;
-               __pCallRejectedIonPopup = null;
+               if(__pCallRejectedIonPopup != null)
+               {
+                       delete __pCallRejectedIonPopup;
+                       __pCallRejectedIonPopup = null;
+               }
+       }
+
+       if(__pCallAppTimer->Equals(timer))
+       {
+               __callTicks += 1000;
        }
 }
 
@@ -662,3 +689,9 @@ CallApp::OnActiveAppChanged(const String& appId)
        }
 
 }
+
+long long
+CallApp::GetCallAppTicks(void)
+{
+       return __callTicks;
+}
index d3ce4cc..6159b6e 100644 (file)
@@ -19,6 +19,7 @@
  * @brief      Conference caller list form
  */
 #include <FSystem.h>
+#include "CallApp.h"
 #include "CallConfCallerListForm.h"
 #include "CallAppUtility.h"
 #include "CallPresentationModel.h"
@@ -325,7 +326,8 @@ ConfCallerListForm::OnSceneActivatedN(const SceneId& previousSceneId, const Scen
        }
 
        //show active call timer
-       ShowTimerInfo(IDC_CALL_TIME_LABEL, __pConfCallInfo->GetCallConnectTime());
+//     ShowTimerInfo(IDC_CALL_TIME_LABEL, __pConfCallInfo->GetCallConnectTime());
+       ShowTimerInfo(IDC_CALL_TIME_LABEL, __pConfCallInfo->GetDurationTime());
 
        //Set the correct bitmap to the "hold" button based on the current state of the call
        SetHoldButtonStatus(__pConfCallInfo->IsOnHold());
@@ -492,7 +494,9 @@ ConfCallerListForm::ShowTimerInfo(const String& timerLblName, long long startTim
        {
                //current system time
                long long currTime = 0;
-               SystemTime::GetTicks(currTime);
+               //SystemTime::GetTicks(currTime);
+               CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
+               currTime = pPhoneApp->GetCallAppTicks();
                //Set call duration
                TimeSpan diffSpan(abs(startTime - currTime));
 
index 3467855..1e5af54 100644 (file)
@@ -37,6 +37,7 @@ AppCallInfo::AppCallInfo(void)
        __callType = VOICE_CALL;
        __isOnHold = false;
        __callConnectTime = 0;
+       __durationTime = 0;
        __callNotificationTime = 0;
        __pCallHandle = null;
        __pEndCallCause = null;
@@ -187,12 +188,24 @@ AppCallInfo::SetCallConnectTime(long long connectTime)
        __callConnectTime = connectTime;
 }
 
+void
+AppCallInfo::SetDurationTime(long long durationTime)
+{
+       __durationTime = durationTime;
+}
+
 long long
 AppCallInfo::GetCallNotificationTime(void)
 {
        return __callNotificationTime;
 }
 
+long long
+AppCallInfo::GetDurationTime(void)
+{
+       return __durationTime;
+}
+
 void
 AppCallInfo::SetCallNotificationTime(long long callNotificationTime)
 {
@@ -294,6 +307,7 @@ AppCallInfo::operator =(const AppCallInfo& rhs)
                this->__isOnHold = rhs.__isOnHold;
                //call connected time
                this->__callConnectTime = rhs.__callConnectTime;
+               this->__durationTime = rhs.__durationTime;
                //call notification time
                this->__callNotificationTime = rhs.__callNotificationTime;
                this->__calllogType = rhs.__calllogType;
index 4bb18f2..9c128e8 100644 (file)
@@ -24,6 +24,7 @@
 #include <FTelephony.h>
 #include "ITapiModem.h"
 #include "ITapiSim.h"
+#include "CallApp.h"
 #include "CallInfo.h"
 #include "CallTelephonyManager.h"
 #include "CallSettingsManager.h"
@@ -1402,9 +1403,11 @@ TelephonyManager::HandleJoinCallbackResponse(TapiHandle* pHandle, int callBackRe
                                        pConfCallInfo->AddCallToCallerList(heldCall);
                                        pConfCallInfo->SetCallHandle(activeCallHandle);
                                        //Set call start time
-                                       if (pConfCallInfo->GetCallConnectTime() > heldCall.GetCallConnectTime())
+                                       //if (pConfCallInfo->GetCallConnectTime() > heldCall.GetCallConnectTime())
+                                       if (pConfCallInfo->GetDurationTime() > heldCall.GetDurationTime())
                                        {
                                                pConfCallInfo->SetCallConnectTime(heldCall.GetCallConnectTime());
+                                               pConfCallInfo->SetDurationTime(heldCall.GetDurationTime());
                                                pConfCallInfo->SetCallNotificationTime(heldCall.GetCallNotificationTime());
                                        }
                                }
@@ -1417,9 +1420,11 @@ TelephonyManager::HandleJoinCallbackResponse(TapiHandle* pHandle, int callBackRe
                                        pConfCallInfo->AddCallToCallerList(activeCall);
                                        pConfCallInfo->SetCallHandle(heldCallHandle);
                                        //Set call start time
-                                       if (pConfCallInfo->GetCallConnectTime() > activeCall.GetCallConnectTime())
+                                       //if (pConfCallInfo->GetCallConnectTime() > activeCall.GetCallConnectTime())
+                                       if (pConfCallInfo->GetDurationTime() > activeCall.GetDurationTime())
                                        {
                                                pConfCallInfo->SetCallConnectTime(activeCall.GetCallConnectTime());
+                                               pConfCallInfo->SetDurationTime(activeCall.GetDurationTime());
                                                pConfCallInfo->SetCallNotificationTime(activeCall.GetCallNotificationTime());
                                        }
                                }
@@ -1433,14 +1438,17 @@ TelephonyManager::HandleJoinCallbackResponse(TapiHandle* pHandle, int callBackRe
                                        pConfCallInfo->AddCallToCallerList(heldCall);
                                        pConfCallInfo->SetCallHandle(activeCallHandle);
                                        //Set call start time
-                                       if (activeCall.GetCallConnectTime() > heldCall.GetCallConnectTime())
+                                       //if (activeCall.GetCallConnectTime() > heldCall.GetCallConnectTime())
+                                       if (activeCall.GetDurationTime() > heldCall.GetDurationTime())
                                        {
                                                pConfCallInfo->SetCallConnectTime(heldCall.GetCallConnectTime());
+                                               pConfCallInfo->SetDurationTime(heldCall.GetDurationTime());
                                                pConfCallInfo->SetCallNotificationTime(heldCall.GetCallNotificationTime());
                                        }
                                        else
                                        {
                                                pConfCallInfo->SetCallConnectTime(activeCall.GetCallConnectTime());
+                                               pConfCallInfo->SetDurationTime(activeCall.GetDurationTime());
                                                pConfCallInfo->SetCallNotificationTime(activeCall.GetCallNotificationTime());
                                        }
                                }
@@ -2210,6 +2218,8 @@ TelephonyManager::HandleCallConnected(unsigned int connectedCallHandle)
        long long startTime = 0;
        SystemTime::GetTicks(startTime);
        pConnectedCall->SetCallConnectTime(startTime);
+       CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
+       pConnectedCall->SetDurationTime(pPhoneApp->GetCallAppTicks());
        if(GetCurrentCallCount() == 0)
        {
                __pSoundManager->SetMinuteReminderTone();
index 0aabdda..98dc827 100644 (file)
@@ -18,8 +18,9 @@
  * @file       CalllogManager.cpp
  * @brief      This class provides call log APIs
  */
-#include "CalllogManager.h"
 #include <FLocales.h>
+#include "CallApp.h"
+#include "CalllogManager.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
@@ -124,14 +125,17 @@ CallLogManager::AddCallogInfoToDatabase(AppCallInfo* calllogInfo)
                else
                {
                        //start time is in miliseconds . so convert to seconds and set it to time_t format.
-                       long long connectTime = calllogInfo->GetCallConnectTime();
+                       long long connectTime = calllogInfo->GetDurationTime();
                        if(connectTime == 0 || connectTime < 0)
                        {
-                               connectTime = time(null);
+                               //connectTime = time(null);
+                               CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
+                               connectTime = pPhoneApp->GetCallAppTicks();
+                               connectTime /=1000;
                        }
                        else
                        {
-                               connectTime = calllogInfo->GetCallConnectTime()/ 1000;
+                               connectTime = calllogInfo->GetDurationTime()/ 1000;
                        }
                        duration = (int)GetDuration(connectTime);
                }
@@ -196,9 +200,12 @@ CallLogManager::AddCallogInfoToDatabase(AppCallInfo* calllogInfo)
 unsigned long
 CallLogManager::GetDuration(long long start_time)
 {
-       time_t curr_time;
+       long long curr_time;
        unsigned long call_duration_in_sec = 50;
-       curr_time = time(0);
+//     curr_time = time(0);
+       CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
+       curr_time = pPhoneApp->GetCallAppTicks();
+       curr_time /=1000;
        /*if(start_time != 0)
        {
                start_time /= 1000;