Fix for Call sate not set properly when there is 1 waiting and 1 active call and...
[apps/osp/Call.git] / src / CallApp.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 /**
17  * Name        : CallApp
18  * Version     :
19  * Vendor      :
20  * Description :
21  */
22
23 #include <FUi.h>
24 #include <FShell.h>
25 #include "CallApp.h"
26 #include "CallAppFrame.h"
27 #include "CallPresentationModel.h"
28 #include "CallTypes.h"
29 #include "CallAppUtility.h"
30 #include "CallIAppStateChangeListner.h"
31
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::System;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
38 using namespace Tizen::Base::Utility;
39 using namespace Tizen::Base::Collection;
40 using namespace Tizen::Base::Utility;
41 using namespace Tizen::Shell;
42
43 static const int FONT_SIZE_AUTOREJECT_POPUP_TEXT = 36;
44
45
46 CallApp::CallApp(void):__initialSceneId(L""), __pLaunchArgs(null)
47 {
48         __listenerList.Construct();
49         __pCallRejectedIonPopup = null;
50         __pCallAppTimer = null;
51         __callTicks = 0;
52 }
53
54 CallApp::~CallApp(void)
55 {
56         if(__pCallRejectedIonPopup != null)
57         {
58                 delete __pCallRejectedIonPopup;
59                 __pCallRejectedIonPopup=null;
60         }
61 }
62
63 UiApp*
64 CallApp::CreateInstance(void)
65 {
66         // Create the instance through the constructor.
67         return new CallApp();
68 }
69
70 bool
71 CallApp::OnAppInitializing(AppRegistry& appRegistry)
72 {
73         AppControlProviderManager* pProviderMgr = AppControlProviderManager::GetInstance();
74         pProviderMgr->SetAppControlProviderEventListener(this);
75         PowerManager::AddScreenEventListener(*this);
76         __callRejectedIontimer.Construct(*this);
77         return true;
78 }
79
80 bool
81 CallApp::OnAppInitialized(void)
82 {
83         // TODO:
84         // Comment.
85
86         // Create a Frame
87         CallAppFrame* pCallAppFrame = new CallAppFrame();
88         pCallAppFrame->Construct();
89         pCallAppFrame->SetName(L"CallApp");
90         AddFrame(*pCallAppFrame);
91
92         //Check if there is no initial scene, then exit application.
93         //This case will normally come when invalid AppControl request has come,
94         //or incoming call is coming from unknown number and "reject unknown number" settings is enabled.
95         if (GetInitialScene().IsEmpty() == true)
96         {
97                 return false;
98         }
99
100         if (__pCallAppTimer == null)
101         {
102                 __pCallAppTimer = new (std::nothrow) Tizen::Base::Runtime::Timer();
103                 __pCallAppTimer->Construct(*this);
104                 long long currTime = 0;
105                 SystemTime::GetTicks(currTime);
106                 __callTicks = currTime;
107                 __pCallAppTimer->StartAsRepeatable(TimeSpan::NUM_OF_TICKS_IN_SECOND);
108         }
109
110
111         return true;
112 }
113
114 bool
115 CallApp::OnAppWillTerminate(void)
116 {
117         // TODO:
118         // Comment.
119         return true;
120 }
121
122 bool
123 CallApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
124 {
125         // TODO:
126         // Deallocate resources allocated by this App for termination.
127         // The App's permanent data and context can be saved via appRegistry.
128         PowerManager::RemoveScreenEventListener(*this);
129         if (__pCallAppTimer != null)
130         {
131                 __pCallAppTimer->Cancel();
132                 delete __pCallAppTimer;
133         }
134
135         return true;
136 }
137
138 void
139 CallApp::OnForeground(void)
140 {
141         IEnumerator* pEnum = __listenerList.GetEnumeratorN();
142         while (pEnum->MoveNext() == E_SUCCESS)
143         {
144                 IAppStateChangeListener* pInterface = static_cast<IAppStateChangeListener*>(pEnum->GetCurrent());
145                 if (pInterface == null)
146                 {
147                         delete pEnum;
148
149                         return;
150                 }
151                 pInterface->OnForeground();
152         }
153         delete pEnum;
154 }
155
156 void
157 CallApp::OnBackground(void)
158 {
159         // TODO:
160         // Stop drawing when the application is moved to the background.
161 }
162
163 void
164 CallApp::OnLowMemory(void)
165 {
166         // TODO:
167         // Free unused resources or close the application.
168 }
169
170 void
171 CallApp::OnBatteryLevelChanged(BatteryLevel batteryLevel)
172 {
173         // TODO:
174         // Handle any changes in battery level here.
175         // Stop using multimedia features(camera, mp3 etc.) if the battery level is CRITICAL.
176 }
177
178 void
179 CallApp::OnScreenOn(void)
180 {
181         // TODO:
182         // Get the released resources or resume the operations that were paused or stopped in OnScreenOff().
183 }
184
185 void
186 CallApp::OnScreenOff(void)
187 {
188         AppLogDebug("Enter");
189         IEnumerator* pEnum = __listenerList.GetEnumeratorN();
190         while (pEnum->MoveNext() == E_SUCCESS)
191         {
192                 IAppStateChangeListener* pInterface = static_cast<IAppStateChangeListener*>(pEnum->GetCurrent());
193                 if (pInterface == null)
194                 {
195                         delete pEnum;
196
197                         return;
198                 }
199                 pInterface->OnScreenOff();
200         }
201         delete pEnum;
202
203 }
204
205 SceneId
206 CallApp::GetInitialScene(void)
207 {
208         return __initialSceneId;
209 }
210
211 IList*
212 CallApp::GetAppLaunchArguments(void)
213 {
214         return __pLaunchArgs;
215 }
216
217 void
218 CallApp::AddAppStateChangeListener(const IAppStateChangeListener& listener)
219 {
220         __listenerList.Add(listener);
221
222 }
223 void
224 CallApp::RemoveAppStateChangeListener(const IAppStateChangeListener& listener)
225 {
226         __listenerList.Remove(listener);
227 }
228
229 void
230 CallApp::OnAppControlRequestReceived(RequestId reqId, const String& operationId, const String* pUriData,
231                 const String* pMimeType, const IMap* pExtraData)
232 {
233         AppLogDebug("Enter ");
234         if(pUriData != null)
235         {
236                 AppLogDebug("%ls ",pUriData->GetPointer());
237         }
238
239         if(pExtraData == null && pUriData != null)
240         {
241                 //The request is from web app
242                 AppLogDebug("%ls",pUriData->GetPointer());
243                 ProcessWebAppControlRequest(reqId, operationId, pUriData);
244         }
245         else
246         {
247                 //process AppControl parameters
248                 ProcessAppControlRequest(reqId, operationId, pExtraData,pUriData);
249         }
250         AppLogDebug("EXIT");
251 }
252
253 void
254 CallApp::ProcessWebAppControlRequest(RequestId reqId, const String& operationId,const String* pUriData)
255 {
256         //Construct map from string
257         String delim(DELIMITER);
258         StringTokenizer st(*pUriData,delim);
259         String token;
260         HashMap extraData;
261         extraData.Construct();
262         while(st.HasMoreTokens())
263         {
264                 String key=L"";
265                 String value=L"";
266                 st.GetNextToken(token);
267                 token.Trim();
268                 key.Append(token);
269                 if(st.HasMoreTokens())
270                 {
271                         token.Clear();
272                         st.GetNextToken(token);
273                         token.Trim();
274                         value.Append(token);
275                 }
276                 extraData.Add(new (std::nothrow) String(key), new (std::nothrow) String(value));
277         }
278
279         //Adding this explicitly as there no other way to invoke call from webapp
280         extraData.Add(new (std::nothrow) String(PARAM_CALL_TYPE), new (std::nothrow) String(PARAM_CALL_VALUE_VOICE));
281
282         ProcessAppControlRequest(reqId,operationId,&extraData);
283
284         extraData.RemoveAll(true);
285 }
286
287 void
288 CallApp::ProcessAppControlRequest(RequestId reqId, const String& operationId,const IMap* pArgsMap,const String* pUriData)
289 {
290         AppLogDebug("Enter %ls",operationId.GetPointer());
291         __pLaunchArgs = null;
292         if(operationId.Equals(OPERATION_ID_CALL,true) == true)
293         {
294                 AppLogDebug("OPERATION_ID_CALL");
295                 if(pArgsMap != null)
296                 {
297                         bool isIncomingCallRequest = false;
298                         String* pKey = new (std::nothrow) String(LAUNCHTYPE);
299                         if (pArgsMap->ContainsKey(*pKey) == true)
300                         {
301                                 const String* pValue = static_cast<const String*>(pArgsMap->GetValue(*pKey));
302                                 if ((pValue != null) && (pValue->Equals(PARAM_ORIGIN_MT, true) == true))
303                                 {
304                                         isIncomingCallRequest = true;
305                                 }
306                         }
307                         //Check if incoming call request or outgoing call request
308                         if(isIncomingCallRequest == true)
309                         {
310                                 HandleIncomingCallAppControlRequest(reqId, pArgsMap);
311                         }
312                         else
313                         {
314                                 HandleDialCallAppControlRequest(reqId, pArgsMap,pUriData);
315                         }
316                 }
317                 else
318                 {
319                         AppLogDebug("pArgsMap == null");
320                 }
321         }
322 }
323
324 void
325 CallApp::HandleIncomingCallAppControlRequest(RequestId reqId,const IMap* pArgsMap)
326 {
327         AppLogDebug("Enter");
328         SceneManager* pSceneManager = SceneManager::GetInstance();
329         //response message
330         AppCtrlResult appControlResult = APP_CTRL_RESULT_FAILED;
331
332         //call handle
333         String callHandle(L"");
334         String* pKey = new (std::nothrow) String(CALL_HANDLE);
335         if (pArgsMap->ContainsKey(*pKey) == true)
336         {
337                 const String* pValue = static_cast<const String*>(pArgsMap->GetValue(*pKey));
338                 if (pValue != null)
339                 {
340                         callHandle.Append(*pValue);
341                 }
342         }
343         delete pKey;
344         //contact number
345         String contactNumber(L"");
346         pKey = new (std::nothrow) String(CONTACT_NUMBER);
347         if (pArgsMap->ContainsKey(*pKey) == true)
348         {
349                 const String* pContactValue = static_cast<const String*>(pArgsMap->GetValue(*pKey));
350                 if (pContactValue != null)
351                 {
352                         contactNumber.Append(*pContactValue);
353                         AppLogDebug("%ls",contactNumber.GetPointer());
354                 }
355         }
356         delete pKey;
357         pKey = null;
358
359         //Fetch incoming call details
360         CallPresentationModel* pCallPresentor = CallPresentationModel::GetInstance();
361         //Check if there is already a dial call present .This can happen in some
362         //race conditions N_SE-39531
363         if(pCallPresentor->IsIncomingorDialingCallPresent())
364         {
365                 int incomingHandle;
366                 Integer::Parse(callHandle,incomingHandle);
367                 pCallPresentor->RejectCall(incomingHandle,false,contactNumber);
368                 AppLog("Cancelled already an incoming call present");
369                 appControlResult = APP_CTRL_RESULT_CANCELED;
370                 AppControlProviderManager::GetInstance()->SendAppControlResult(reqId, appControlResult, null);
371                 return;
372         }
373
374         AppCallInfo* pIncomingCall = pCallPresentor->FetchIncomingCallDetailsN(callHandle, contactNumber);
375         if(pIncomingCall != null)
376         {
377                 bool isCallRejected = pCallPresentor->CheckIncomingCallToBeRejected(pIncomingCall);
378                 if(isCallRejected == false)
379                 {
380                         //save app launch argument list
381                         __pLaunchArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
382                         __pLaunchArgs->Construct(1);
383                         __pLaunchArgs->Add(pIncomingCall);
384                         if(__initialSceneId.IsEmpty() == true)
385                         {
386                                 __initialSceneId = IDSCN_SCENE_INCOMINGCALL;
387                         }
388                         else
389                         {
390                                 //App already initialized, goto incoming call form
391                                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_INCOMINGCALL, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
392                                                  SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_KEEP), __pLaunchArgs);
393                                 __pLaunchArgs = null;
394                         }
395
396
397                 }
398                 else
399                 {
400                         //Show messageBox showing automatic call rejection
401                         /*MessageBox callRejectedInoMsgBox;
402                         String msg(L"Call From ");
403                         msg.Append(contactNumber);
404                         msg.Append(L" Rejected.");
405                         callRejectedInoMsgBox.Construct(L"Call Rejected", msg, MSGBOX_STYLE_NONE,1000);
406                         int modalResult = 0;
407                         // Calls ShowAndWait() : Draws and Shows itself and processes events
408                         callRejectedInoMsgBox.ShowAndWait(modalResult);*/
409                         //go back to previous scene if App was already running, else exit application.
410                         if(__initialSceneId.IsEmpty() == true)
411                         {
412                                 //KEEP "__initialSceneId" as empty and return false from "OnAppInitialized()"
413                                 AppLog("Terminate Phone Application");
414                                 Terminate();
415                         }
416                         else
417                         {
418                                 ShowAutoRejectPopup(contactNumber);
419                         }
420                 }
421                 //set success message
422                 appControlResult = APP_CTRL_RESULT_SUCCEEDED;
423         }
424         else
425         {
426                 appControlResult = APP_CTRL_RESULT_FAILED;
427         }
428         AppLogDebug("Exiting %d",appControlResult);
429         AppControlProviderManager::GetInstance()->SendAppControlResult(reqId, appControlResult, null);
430 }
431
432 void
433 CallApp::ShowAutoRejectPopup(Tizen::Base::String contactNumber)
434 {
435         String msg(AppUtility::GetResourceString(IDS_CALL_REJECT_FROM_STRING));
436         msg.Append(L" ");
437         msg.Append(contactNumber);
438         if(__pCallRejectedIonPopup != null)
439         {
440                 delete __pCallRejectedIonPopup;
441                 __pCallRejectedIonPopup = null;
442         }
443         __pCallRejectedIonPopup = new (std::nothrow) Popup();
444         Tizen::Graphics::Dimension dim(600,200);
445         __pCallRejectedIonPopup->Construct(true, dim);
446         __pCallRejectedIonPopup->SetTitleText(AppUtility::GetResourceString(IDS_CALL_REJECTED_TITLE_STRING));
447         Label* pLabelText = new (std::nothrow) Label();
448         pLabelText->Construct(Tizen::Graphics::Rectangle(0, 0, dim.width, dim.height-100), msg);
449         pLabelText->SetTextConfig(FONT_SIZE_AUTOREJECT_POPUP_TEXT, LABEL_TEXT_STYLE_NORMAL);
450         pLabelText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
451         pLabelText->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
452         __pCallRejectedIonPopup->AddControl(pLabelText);
453         __pCallRejectedIonPopup->Show();
454         __pCallRejectedIonPopup->SetShowState(true);
455         __callRejectedIontimer.Start(3000);
456 }
457
458 void
459 CallApp::OnTimerExpired(Tizen::Base::Runtime::Timer &timer)
460 {
461         if (__callRejectedIontimer.Equals(timer))
462         {
463                 if(__pCallRejectedIonPopup != null)
464                 {
465                         delete __pCallRejectedIonPopup;
466                         __pCallRejectedIonPopup = null;
467                 }
468         }
469
470         if(__pCallAppTimer->Equals(timer))
471         {
472                 __callTicks += 1000;
473         }
474 }
475
476 void
477 CallApp::HandleDialCallAppControlRequest(RequestId reqId,const IMap* pArgsMap,const String* pUriData)
478 {
479         //response message
480         AppCtrlResult appControlResult = APP_CTRL_RESULT_FAILED;
481
482         if (pArgsMap != null)
483         {
484                 String callType(L"");
485                 String phoneNumber(L"");
486                 //phone number
487                 String* pKey = new (std::nothrow) String(PARAM_PHONE_NUMBER);
488                 if(pArgsMap->ContainsKey(*pKey) == true)
489                 {
490                         const String* pPhoneValue = static_cast<const String*>(pArgsMap->GetValue(*pKey));
491                         if(pPhoneValue != null)
492                         {
493                                 AppLogDebug("%ls",pPhoneValue->GetPointer());
494                                 phoneNumber.Append(*pPhoneValue);
495                         }
496                 }
497                 else
498                 {
499                         AppLogDebug("PARAM_PHONE_NUMBER not present");
500                         //Now check if tel uri is present
501                         if(pUriData != null)
502                         {
503                                 AppLogDebug("pUriData is present %ls",pUriData->GetPointer());
504                                 phoneNumber.Append(*pUriData);
505                                 if(phoneNumber.Contains(PARAM_PHONE_NUMBER))
506                                 {
507                                         phoneNumber.Replace(PARAM_PHONE_NUMBER,L"");
508                                         if(phoneNumber.Contains(DELIMITER))
509                                         {
510                                                 phoneNumber.Replace(DELIMITER,L"");
511                                                 AppLogDebug("%ls",phoneNumber.GetPointer());
512                                         }
513                                 }
514                                 AppLogDebug("%ls",phoneNumber.GetPointer());
515                         }
516                 }
517                 delete pKey;
518                 //Check if its a valid number
519         /*      if(CheckNumberIsValid(phoneNumber) == false)
520                 {
521                         //go back to previous scene if App was already running, else exit application.
522                         if(__initialSceneId.IsEmpty() == true)
523                         {
524                                 //KEEP "__initialSceneId" as empty and return false from "OnAppInitialized()"
525                                 AppLog("Terminate Phone Application");
526                                 AppControlProviderManager::GetInstance()->SendAppControlResult(reqId, appControlResult, null);
527                                 Terminate();
528                                 return;
529                         }
530                         else
531                         {
532                                 //invalid phone number.always return, but App will come to foreground
533                                 //and show current screen, if any calls is present.
534                                 return;
535                         }
536                 }*/
537                 //call type
538                 pKey = new (std::nothrow) String(PARAM_CALL_TYPE);
539                 if(pArgsMap->ContainsKey(*pKey) == true)
540                 {
541                         const String* pCallTypeValue = static_cast<const String*>(pArgsMap->GetValue(*pKey));
542                         if(pCallTypeValue != null)
543                         {
544                                 callType.Append(*pCallTypeValue);
545                         }
546                 }
547                 delete pKey;
548                 pKey = null;
549
550                 //Fetch currently active call count
551                 if (callType.IsEmpty() == false
552                                 && callType.Equals(PARAM_CALL_VALUE_VOICE, false) == true
553                                 && phoneNumber.IsEmpty() == false)
554                 {
555                         SceneManager* pSceneManager = SceneManager::GetInstance();
556                         //check if there is already a call in dialing mode, then dont accept any other dialing request.
557                         if (pSceneManager->GetCurrentSceneId() == IDSCN_SCENE_OUTCALL
558                                         || pSceneManager->GetCurrentSceneId()
559                                                         == IDSCN_SCENE_OUT_EMERGENCYCALL)
560                         {
561                                 AppLog("Cancelled");
562                                 appControlResult = APP_CTRL_RESULT_CANCELED;
563                                 AppControlProviderManager::GetInstance()->SendAppControlResult(reqId, appControlResult, null);
564                                 return;
565                         }
566
567                         CallPresentationModel* pCallPresentor = CallPresentationModel::GetInstance();
568                         //Check if there is already an incoming call
569                         //this can  happen in some race conditions N_SE-39531
570                         if(pCallPresentor->IsIncomingorDialingCallPresent() == true)
571                         {
572                                 AppLog("Cancelled already an incoming call present");
573                                 appControlResult = APP_CTRL_RESULT_CANCELED;
574                                 AppControlProviderManager::GetInstance()->SendAppControlResult(reqId, appControlResult, null);
575                                 return;
576                         }
577                         int currentActiveCallCount = pCallPresentor->GetCurrentCallCount();
578                         if(currentActiveCallCount <= 1)
579                         {
580                                 //Abort any AppControl Request running already to show incoming call screen
581                                 if (pCallPresentor->IsAppControlRunning() == true)
582                                 {
583                                         pCallPresentor->AbortAppControlRequest();
584                                 }
585                                 //make an outgoing call with given number
586                                 String* contactTxt = new (std::nothrow) String(phoneNumber);
587                                 __pLaunchArgs =  new (std::nothrow) ArrayList(SingleObjectDeleter);
588                                 __pLaunchArgs->Construct();
589                                 __pLaunchArgs->Add(contactTxt);
590                                 bool isEmergencyCall = pCallPresentor->IsEmergencyNumber(*contactTxt, true);
591
592                                 SceneId nextScene = IDSCN_SCENE_OUTCALL;
593                                 if (isEmergencyCall)
594                                 {
595                                         nextScene = IDSCN_SCENE_OUT_EMERGENCYCALL;
596                                 }
597                                 //Check if app was already running
598                                 if(__initialSceneId.IsEmpty() == true)
599                                 {
600                                         //phone App is not already launched
601                                         __initialSceneId = nextScene;
602                                 }
603                                 else
604                                 {
605                                         AppLog("Outgoing call");
606                                         pSceneManager->GoForward( ForwardSceneTransition( nextScene, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
607                                                          SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_KEEP), __pLaunchArgs);
608                                 }
609                                 appControlResult = APP_CTRL_RESULT_SUCCEEDED;
610                         }
611                         else
612                         {
613                                 //already 2 active calls, 3rd call not allowed
614                                 appControlResult = APP_CTRL_RESULT_CANCELED;
615                         }
616                 }
617                 else
618                 {
619                         appControlResult = APP_CTRL_RESULT_FAILED;
620                 }
621         }
622         //send response message
623         AppControlProviderManager::GetInstance()->SendAppControlResult(reqId, appControlResult, null);
624 }
625
626 bool
627 CallApp::CheckNumberIsValid(String phoneNumber)
628 {
629         //Pattern to compare all characters except 0-9 * # P ; , +
630         String phoneNumberPattern(L"[^0-9*#P,p+;]");
631         RegularExpression checkPhoneNumber;
632         checkPhoneNumber.Construct(phoneNumberPattern);
633         //If there is any character other than these listed above then display invalid number
634         bool resultMatch = checkPhoneNumber.Match(phoneNumber,false);
635         //return false for patterns other than 0-9 * # P ; , +
636         if(resultMatch == true)
637         {
638                 //return phone number is invalid
639                 return false;
640         }
641
642         return true;
643
644 }
645
646 void
647 CallApp::SetTopMostWindow(bool bTopMost)
648 {
649         AppLogDebug("bTopMost = %d",bTopMost);
650         result res = E_FAILURE;
651         //ToDO: Need to see if there is better way to handle
652         //this case
653
654         if(bTopMost == true)
655         {
656                 GetAppFrame()->GetFrame()->SetZOrderGroup(WINDOW_Z_ORDER_GROUP_HIGHEST);
657                 AppManager::GetInstance()->AddActiveAppEventListener(*this);
658                 /*if(PowerManager::IsScreenOn() == false)
659                 {
660                         AppLogDebug("TurnScreenOn");
661                         res = PowerManager::TurnScreenOn();
662                         AppLogDebug("TurnScreenOn %d",res);
663                 }*/
664
665         }
666         else
667         {
668                 GetAppFrame()->GetFrame()->SetZOrderGroup(WINDOW_Z_ORDER_GROUP_NORMAL);
669                 PowerManager::KeepScreenOnState(false);
670                 AppManager::GetInstance()->RemoveActiveAppEventListener(*this);
671         }
672
673         if(LockManager::GetInstance()->IsLocked())
674         {
675                 AppLogDebug("Phone Locked");
676                 LockManager::GetInstance()->Unlock();
677         }
678
679 }
680 void
681 CallApp::OnActiveAppChanged(const String& appId)
682 {
683         AppLogDebug("Enter %ls",appId.GetPointer());
684         if(GetAppId().Equals(appId) == true)
685         {
686                 result res = PowerManager::KeepScreenOnState(true,false);
687                 AppLogDebug("KeepScreenOnState %d",res);
688
689         }
690
691 }
692
693 long long
694 CallApp::GetCallAppTicks(void)
695 {
696         return __callTicks;
697 }