|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: controls the calls that comes to the wsserverplugin by the use |
|
15 * of a state machine |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "wsserverdrawercontroller.h" |
|
22 #include "alfdrawerengine.h" |
|
23 #include <akntranseffect.h> // for Transition effect enumerations |
|
24 |
|
25 #include <e32property.h> |
|
26 #include <UikonInternalPSKeys.h> |
|
27 #include <ScreensaverInternalPSKeys.h> |
|
28 #include <startupdomainpskeys.h> |
|
29 #include <alflogger.h> |
|
30 #include <coemain.h> |
|
31 |
|
32 #include <bautils.h> |
|
33 |
|
34 //#include <winchangecrp.h> |
|
35 #ifdef WSSERVERDRAWER_TIME_LOG |
|
36 _LIT(KWsServerDrawerTimeLogFile, "WsServerDrawerTimeLog.txt"); |
|
37 _LIT(KWsServerDrawerTimeLogDir, "alfgfxtest"); |
|
38 #endif //WSSERVERDRAWER_TIME_LOG |
|
39 |
|
40 const TInt KEndCheckTime(500000); //half second |
|
41 const TInt KEndTimeOut(10); // 10 * KEndCheckTime |
|
42 |
|
43 // We use a huge timeout for tests as it seems we hit the timeout way too often |
|
44 //const TInt KEndCheckTime(1000000); //1 second |
|
45 //const TInt KEndTimeOut(10); // 10 * KEndCheckTime |
|
46 |
|
47 ///////////////////////////////////////////////////////////////////////////////////////// |
|
48 |
|
49 /** These apps will never get fullscreen effects to or from them */ |
|
50 const TUint KNoEffectApps[] = |
|
51 { |
|
52 0x100059B5, // S60 autolock |
|
53 0x10207218, // akncapserver |
|
54 // 0x100058B3, // phone app |
|
55 0x10281EF2, // AknNotifyServer |
|
56 // 0x100056CF, // screensaver |
|
57 0x10210CB5, // MIDP, JavaLauncherExe |
|
58 0x1000594D, // IRApp, disables effect when activating IR |
|
59 0x102818E7, // VCommandManager, start in device startup |
|
60 0x100058F3, // sys app |
|
61 0x102823b5, // SendUiServiceResolver, |
|
62 0x101F8681, // VideoTelUi |
|
63 0x101F875A, // KSWInstSvrUid, prevent fullscreen effect on installing |
|
64 0x101F8543, // Voice Commands, no effects when pressing send key long |
|
65 0x10281855 // touch input server , no effects when the first time start up |
|
66 // startup blocked because startup exit leaves the screen black. |
|
67 // must be debugged |
|
68 , 0x100058F4 // startup blocked for the time being |
|
69 // Application shell is Ok, folder open and close have KAknApplicationShellViewId |
|
70 // as both to and from ids. There is only one visual, so some sort of blur effect works... |
|
71 //, KAknApplicationShellViewId |
|
72 }; |
|
73 |
|
74 /** Switching between theese app pairs will also never get effects */ |
|
75 const TUint KNoEffectPairs[][2] = |
|
76 { |
|
77 {0x0, 0x0}, |
|
78 }; |
|
79 |
|
80 /** switch to/from these applications will never get any effects and |
|
81 the current ongoing effect will be aborted */ |
|
82 const TUint KCustomNoEffectApps[] = |
|
83 { |
|
84 0x0, // DO NOT REMOVE 0x0! this is here for compile reasons, it will not be included in the AllowedCustomUid check |
|
85 //0xUID //Add UIds of applications that shouldn't have effects here |
|
86 }; |
|
87 |
|
88 // DISABLED! uncomment code in ConstructL that references this list to turn it on. |
|
89 /** Switching between from or to theese apps should have always effects */ |
|
90 /*const TUint KExceptionEffectApps[] = |
|
91 { |
|
92 0x100056CF, // screensaver |
|
93 }; |
|
94 */ |
|
95 |
|
96 /** |
|
97 * Local funtion that checks if the uid is in the KCustomNoEffectApps list |
|
98 */ |
|
99 LOCAL_C TBool AllowedCustomUid(const TUid& aUid) |
|
100 { |
|
101 for(TInt i = 1; i < sizeof(KCustomNoEffectApps) / sizeof(KCustomNoEffectApps[0]); i++) |
|
102 { |
|
103 if(aUid.iUid == KCustomNoEffectApps[i]) |
|
104 return EFalse; |
|
105 } |
|
106 return ETrue; |
|
107 } |
|
108 |
|
109 ///////////////////////////////////////////////////////////////////////////////////////// |
|
110 |
|
111 class CPSListener : public CActive |
|
112 { |
|
113 public: |
|
114 inline TInt Value() const; |
|
115 inline TInt Key() const; |
|
116 CPSListener(); |
|
117 void ListenL(const TUid& aUid, TInt aKey); |
|
118 ~CPSListener(); |
|
119 private: |
|
120 void DoCancel(); |
|
121 void RunL(); |
|
122 private: |
|
123 RProperty iProperty; |
|
124 TInt iValue; |
|
125 TInt iKey; |
|
126 }; |
|
127 |
|
128 inline TInt CPSListener::Value() const |
|
129 { |
|
130 return iValue; |
|
131 } |
|
132 |
|
133 inline TInt CPSListener::Key() const |
|
134 { |
|
135 return iKey; |
|
136 } |
|
137 |
|
138 CPSListener::CPSListener() : CActive(CActive::EPriorityHigh) |
|
139 { |
|
140 CActiveScheduler::Add(this); |
|
141 } |
|
142 |
|
143 void CPSListener::ListenL(const TUid& aUid, TInt aKey) |
|
144 { |
|
145 Cancel(); |
|
146 iKey = aKey; |
|
147 User::LeaveIfError(iProperty.Attach(aUid, aKey)); |
|
148 RunL(); //set initial value |
|
149 } |
|
150 |
|
151 |
|
152 CPSListener::~CPSListener() |
|
153 { |
|
154 Cancel(); |
|
155 } |
|
156 |
|
157 void CPSListener::DoCancel() |
|
158 { |
|
159 iProperty.Cancel(); |
|
160 } |
|
161 |
|
162 void CPSListener::RunL() |
|
163 { |
|
164 iProperty.Subscribe(iStatus); |
|
165 iProperty.Get(iValue); //errors are ignored! |
|
166 SetActive(); |
|
167 } |
|
168 |
|
169 |
|
170 //////////////////////////////////////////////////////////////////////////////////////// |
|
171 |
|
172 |
|
173 |
|
174 CEndCheck* CEndCheck::NewL(MEndChecker& aCallBack) |
|
175 { |
|
176 CEndCheck* c = new (ELeave) CEndCheck(aCallBack); |
|
177 CleanupStack::PushL(c); |
|
178 c->ConstructL(); |
|
179 CleanupStack::Pop(); |
|
180 return c; |
|
181 } |
|
182 |
|
183 void CEndCheck::Start(/*TInt aState,*/ TInt aMul) |
|
184 { |
|
185 Cancel(); |
|
186 iCancelled = EFalse; |
|
187 After(KEndCheckTime * aMul); |
|
188 } |
|
189 |
|
190 CEndCheck::~CEndCheck() |
|
191 { |
|
192 Cancel(); |
|
193 } |
|
194 |
|
195 void CEndCheck::DoCancel() |
|
196 { |
|
197 CTimer::DoCancel(); |
|
198 iCancelled = ETrue; |
|
199 } |
|
200 |
|
201 void CEndCheck::RunL() |
|
202 { |
|
203 if(!iCancelled) |
|
204 { |
|
205 iCallBack.EndExpired(); |
|
206 } |
|
207 } |
|
208 |
|
209 CEndCheck::CEndCheck(MEndChecker& aCallBack) : CTimer(CActive::EPriorityStandard), |
|
210 iCallBack(aCallBack) |
|
211 { |
|
212 CActiveScheduler::Add(this); |
|
213 } |
|
214 |
|
215 ////////////////////////////////////////////////////////////////////////////////////////// |
|
216 |
|
217 |
|
218 LOCAL_C void GetName(RFs& aFs, TDes& aName) |
|
219 { |
|
220 aFs.PrivatePath(aName); |
|
221 aName.Insert(0, _L("D:")); |
|
222 aName.Append(_L("data.bin")); |
|
223 } |
|
224 |
|
225 |
|
226 void CAppInfoCache::ReadArrayL(RFile& aFile) |
|
227 { |
|
228 TPckgBuf<TUint> buf; |
|
229 User::LeaveIfError(aFile.Read(buf)); |
|
230 const TUint count = buf(); |
|
231 for(TUint i = 0; i < count; i++) |
|
232 { |
|
233 User::LeaveIfError(aFile.Read(buf)); |
|
234 const TUint value = buf(); |
|
235 User::LeaveIfError(aFile.Read(buf)); |
|
236 const TUint flags = buf(); |
|
237 User::LeaveIfError(aFile.Read(buf)); |
|
238 const TUint aToUid = buf(); |
|
239 User::LeaveIfError(aFile.Read(buf)); |
|
240 const TUint root = buf(); |
|
241 if(KErrNone == Append(value)) //dont allow duplicates |
|
242 { |
|
243 const TInt index = IndexOf(value); |
|
244 iAppInfo[index].iFlags = static_cast<TAppInfo::TFlags>(flags); |
|
245 iAppInfo[index].iParent = TUid::Uid(aToUid); |
|
246 iAppInfo[index].iRootWgId = static_cast<TInt>(root); |
|
247 } |
|
248 } |
|
249 } |
|
250 |
|
251 void CAppInfoCache::WriteArrayL(RFile& aFile) const |
|
252 { |
|
253 const TUint count = static_cast<TUint>(iAppInfo.Count()); |
|
254 User::LeaveIfError(aFile.Write(TPckgC<TUint>(count))); |
|
255 for(TUint i = 0; i < count; i++) |
|
256 { |
|
257 const TAppInfo& info = iAppInfo[i]; |
|
258 User::LeaveIfError(aFile.Write(TPckgC<TUint>(info.iUid))); |
|
259 User::LeaveIfError(aFile.Write(TPckgC<TUint>(info.iFlags))); |
|
260 User::LeaveIfError(aFile.Write(TPckgC<TUint>(info.iParent.iUid))); |
|
261 User::LeaveIfError(aFile.Write(TPckgC<TUint>(info.iRootWgId))); |
|
262 } |
|
263 } |
|
264 |
|
265 TInt CAppInfoCache::TAppInfo::Order(const TAppInfo& aNodeA, const TAppInfo& aNodeB) |
|
266 { |
|
267 if(aNodeA.iUid < aNodeB.iUid) |
|
268 return 1; |
|
269 if(aNodeA.iUid > aNodeB.iUid) |
|
270 return -1; |
|
271 return 0; |
|
272 } |
|
273 |
|
274 TInt CAppInfoCache::Append(TUint aUid) |
|
275 { |
|
276 return iAppInfo.InsertInOrder(TAppInfo(aUid), TLinearOrder<TAppInfo>(TAppInfo::Order)); |
|
277 } |
|
278 |
|
279 TInt CAppInfoCache::IndexOf(TUint aUid) const |
|
280 { |
|
281 return iAppInfo.FindInOrder(TAppInfo(aUid), TLinearOrder<TAppInfo>(TAppInfo::Order)); |
|
282 } |
|
283 |
|
284 |
|
285 CAppInfoCache* CAppInfoCache::NewL() |
|
286 { |
|
287 CAppInfoCache* f = new (ELeave) CAppInfoCache(); |
|
288 CleanupStack::PushL(f); |
|
289 f->ConstructL(); |
|
290 CleanupStack::Pop(); |
|
291 return f; |
|
292 } |
|
293 |
|
294 CAppInfoCache::~CAppInfoCache() |
|
295 { |
|
296 TRAP_IGNORE(ExportL()); |
|
297 iLs.Close(); |
|
298 iAppInfo.Close(); |
|
299 } |
|
300 |
|
301 void CAppInfoCache::ConstructL() |
|
302 { |
|
303 ImportL(); |
|
304 User::LeaveIfError(iLs.Connect()); |
|
305 } |
|
306 |
|
307 TBool CAppInfoCache::GateFound() const |
|
308 { |
|
309 return ETrue; |
|
310 } |
|
311 |
|
312 void CAppInfoCache::ExportL() |
|
313 { |
|
314 RFs fs; |
|
315 User::LeaveIfError(fs.Connect()); |
|
316 CleanupClosePushL(fs); |
|
317 TFileName name; |
|
318 GetName(fs, name); |
|
319 BaflUtils::EnsurePathExistsL(fs, name); |
|
320 RFile file; |
|
321 User::LeaveIfError(file.Replace(fs, name, EFileWrite)); |
|
322 CleanupClosePushL(file); |
|
323 |
|
324 User::LeaveIfError(file.Write(TPckgC<TUint>(iFocusedUid.iUid))); |
|
325 |
|
326 WriteArrayL(file); |
|
327 CleanupStack::PopAndDestroy(2); //file, fs |
|
328 } |
|
329 |
|
330 void CAppInfoCache::ImportL() |
|
331 { |
|
332 RFs fs; |
|
333 User::LeaveIfError(fs.Connect()); |
|
334 CleanupClosePushL(fs); |
|
335 TFileName name; |
|
336 GetName(fs, name); |
|
337 RFile file; |
|
338 const TInt err = file.Open(fs, name, EFileRead); |
|
339 if(err == KErrNone) |
|
340 { |
|
341 TPckgBuf<TUint> buf; |
|
342 User::LeaveIfError(file.Read(buf)); |
|
343 iFocusedUid = TUid::Uid(buf()); |
|
344 |
|
345 CleanupClosePushL(file); |
|
346 ReadArrayL(file); |
|
347 CleanupStack::PopAndDestroy(); //file |
|
348 fs.Delete(name); //free up memory after import |
|
349 } |
|
350 CleanupStack::PopAndDestroy(); //fs |
|
351 } |
|
352 |
|
353 |
|
354 TInt CAppInfoCache::SetUid(const TUid& aUid) |
|
355 { |
|
356 if(aUid == KNullUid) |
|
357 return KErrNone; |
|
358 |
|
359 TInt err = Append(aUid.iUid); |
|
360 |
|
361 if( err == KErrAlreadyExists ) |
|
362 { |
|
363 err = KErrNone; |
|
364 } |
|
365 |
|
366 return err; |
|
367 } |
|
368 |
|
369 void CAppInfoCache::SetAppFlags(const TUid& aUid, TUint aFlag, TBool aSet) |
|
370 { |
|
371 const TInt index = IndexOf(aUid.iUid); |
|
372 if(index >= 0) |
|
373 { |
|
374 if(aSet) |
|
375 iAppInfo[index].iFlags |= aFlag; |
|
376 else |
|
377 iAppInfo[index].iFlags &= ~aFlag; |
|
378 } |
|
379 } |
|
380 |
|
381 |
|
382 TBool CAppInfoCache::GetAppFlags(const TUid& aUid, TUint aFlag) const |
|
383 { |
|
384 return TBool(iAppInfo[IndexOf(aUid.iUid)].iFlags & aFlag); |
|
385 } |
|
386 |
|
387 |
|
388 void CAppInfoCache::SetAvkonUid(const TUid& aUid) |
|
389 { |
|
390 SetAppFlags(aUid, TAppInfo::EAvkonApp, ETrue); |
|
391 } |
|
392 |
|
393 void CAppInfoCache::RemoveAvkonUid(const TUid& aUid) |
|
394 { |
|
395 SetAppFlags(aUid, TAppInfo::EAvkonApp, EFalse); |
|
396 } |
|
397 |
|
398 |
|
399 TBool CAppInfoCache::AvkonUid(const TUid& aUid) const |
|
400 { |
|
401 TInt index = IndexOf(aUid.iUid); |
|
402 if (index!=KErrNotFound) |
|
403 { |
|
404 return (iAppInfo[index].iFlags & TAppInfo::EAvkonApp); |
|
405 } |
|
406 else |
|
407 { |
|
408 return EFalse; |
|
409 } |
|
410 } |
|
411 |
|
412 |
|
413 void CAppInfoCache::Reset(const TUid& aUid) |
|
414 { |
|
415 SetParent(aUid, KNullUid); |
|
416 } |
|
417 |
|
418 |
|
419 void CAppInfoCache::SetParent(const TUid& aUid, const TUid& aParentUid) |
|
420 { |
|
421 iAppInfo[IndexOf(aUid.iUid)].iParent = aParentUid; |
|
422 } |
|
423 |
|
424 |
|
425 TInt CAppInfoCache::SetAction(const TUid& aUid, TInt aAction) |
|
426 { |
|
427 if (aAction==AknTransEffect::ENone || aUid == KNullUid) |
|
428 { |
|
429 // previous action is more valid than this |
|
430 return aAction; |
|
431 } |
|
432 TInt index = IndexOf(aUid.iUid); |
|
433 |
|
434 if (index == KErrNotFound) |
|
435 { |
|
436 SetUid(aUid); |
|
437 index = IndexOf(aUid.iUid); |
|
438 if(index == KErrNotFound) |
|
439 { |
|
440 __ALFFXLOGSTRING1("CAppInfoCache::SetAction - Could not add Uid 0x%x to AppInfoCache!", aUid.iUid); |
|
441 return aAction; |
|
442 } |
|
443 } |
|
444 switch(iAppInfo[index].iAction) |
|
445 { |
|
446 case AknTransEffect::EAppStartupBackground: |
|
447 if (aAction == AknTransEffect::EApplicationExit) |
|
448 { |
|
449 aAction = AknTransEffect::EEmbeddedApplicationExit; |
|
450 } |
|
451 break; |
|
452 |
|
453 case AknTransEffect::EApplicationStartRect: |
|
454 case AknTransEffect::EApplicationStartSwitch: |
|
455 case AknTransEffect::EApplicationStartSwitchRect: |
|
456 { |
|
457 // these cannot be overwritten |
|
458 if (aAction!=KErrNotFound) // resetting the state is allowed regardless of earlier state |
|
459 { |
|
460 return iAppInfo[index].iAction; |
|
461 } |
|
462 break; |
|
463 } |
|
464 } |
|
465 |
|
466 iAppInfo[index].iAction = aAction; |
|
467 RDebug::Printf("CAppInfoCache::SetAction - Returned action %d", iAppInfo[index].iAction); |
|
468 return iAppInfo[index].iAction; |
|
469 } |
|
470 |
|
471 TInt CAppInfoCache::Action(const TUid& aUid) |
|
472 { |
|
473 TInt index = IndexOf(aUid.iUid); |
|
474 if (index != KErrNotFound) |
|
475 { |
|
476 return iAppInfo[index].iAction; |
|
477 } |
|
478 return KErrNotFound; |
|
479 } |
|
480 |
|
481 TBool CAppInfoCache::IsEmbedded(const TUid& aUid) const |
|
482 { |
|
483 return iAppInfo[IndexOf(aUid.iUid)].iParent != KNullUid; |
|
484 } |
|
485 |
|
486 |
|
487 TBool CAppInfoCache::IsSameParent(const TUid& aUid1, const TUid& aUid2) const |
|
488 { |
|
489 |
|
490 if(aUid1 == KNullUid || aUid2 == KNullUid) |
|
491 return EFalse; |
|
492 |
|
493 TAppInfo appInfo = iAppInfo[IndexOf(aUid1.iUid)]; |
|
494 appInfo.iParent.iUid = (appInfo.iParent == KNullUid) ? appInfo.iUid : appInfo.iParent.iUid; |
|
495 TAppInfo parentAppInfo = iAppInfo[IndexOf(aUid2.iUid)]; |
|
496 parentAppInfo.iParent.iUid = (parentAppInfo.iParent == KNullUid) ? parentAppInfo.iUid : parentAppInfo.iParent.iUid; |
|
497 |
|
498 if(appInfo.iParent == parentAppInfo.iParent) // Same root? |
|
499 return ETrue; |
|
500 |
|
501 return EFalse; |
|
502 } |
|
503 |
|
504 |
|
505 const TUid& CAppInfoCache::FocusUid() const |
|
506 { |
|
507 return iFocusedUid; |
|
508 } |
|
509 |
|
510 |
|
511 TBool CAppInfoCache::SetFocusUid(TInt aWgId) |
|
512 { |
|
513 if (aWgId) |
|
514 { |
|
515 for(TInt i = 0; i < iAppInfo.Count(); i++) |
|
516 { |
|
517 if(iAppInfo[i].iRootWgId == aWgId) |
|
518 { |
|
519 iFocusedUid = TUid::Uid(iAppInfo[i].iUid); |
|
520 return ETrue; |
|
521 } |
|
522 } |
|
523 } |
|
524 return EFalse; |
|
525 } |
|
526 |
|
527 void CAppInfoCache::ClearActions() |
|
528 { |
|
529 for (TInt i = 0; i < iAppInfo.Count(); ++i) |
|
530 { |
|
531 if ( iAppInfo[i].iAction != AknTransEffect::EAppStartupBackground ) |
|
532 { |
|
533 iAppInfo[i].iAction = KErrNotFound; |
|
534 } |
|
535 } |
|
536 } |
|
537 |
|
538 // --------------------------------------------------------------------------- |
|
539 // --------------------------------------------------------------------------- |
|
540 // |
|
541 CWsServerDrawerController* CWsServerDrawerController::NewL(MAlfDrawerEngine* aEngine) |
|
542 { |
|
543 CWsServerDrawerController* self = new (ELeave) CWsServerDrawerController(aEngine); |
|
544 CleanupStack::PushL(self); |
|
545 self->ConstructL(); |
|
546 CleanupStack::Pop(self); |
|
547 return self; |
|
548 } |
|
549 |
|
550 // --------------------------------------------------------------------------- |
|
551 // --------------------------------------------------------------------------- |
|
552 // |
|
553 CWsServerDrawerController::~CWsServerDrawerController() |
|
554 { |
|
555 #ifdef WSSERVERDRAWER_TIME_LOG //time log |
|
556 delete iLogger; |
|
557 #endif //WSSERVERDRAWER_TIME_LOG |
|
558 delete iAppInfoCache; |
|
559 delete iEndCheck; |
|
560 delete iStates; |
|
561 |
|
562 iPSStates.ResetAndDestroy(); |
|
563 } |
|
564 |
|
565 // --------------------------------------------------------------------------- |
|
566 // --------------------------------------------------------------------------- |
|
567 // |
|
568 CWsServerDrawerController::CWsServerDrawerController(MAlfDrawerEngine* aEngine) : |
|
569 iEngine( aEngine ) |
|
570 { |
|
571 iLastAction = AknTransEffect::ENone; |
|
572 } |
|
573 |
|
574 // --------------------------------------------------------------------------- |
|
575 // --------------------------------------------------------------------------- |
|
576 // |
|
577 void CWsServerDrawerController::AddStateL(const TUid& aUid, TInt aKey) |
|
578 { |
|
579 CPSListener* s = new (ELeave) CPSListener(); |
|
580 CleanupStack::PushL(s); |
|
581 s->ListenL(aUid, aKey); |
|
582 User::LeaveIfError(iPSStates.Append(s)); |
|
583 CleanupStack::Pop(); //s |
|
584 } |
|
585 |
|
586 // --------------------------------------------------------------------------- |
|
587 // --------------------------------------------------------------------------- |
|
588 // |
|
589 TInt CWsServerDrawerController::GetState(TInt aState) const |
|
590 { |
|
591 for(TInt i = 0; i < iPSStates.Count() ; i++) |
|
592 { |
|
593 const CPSListener* const ps = iPSStates[i]; |
|
594 if(ps->Key() == aState) |
|
595 return ps->Value(); |
|
596 } |
|
597 return 0; |
|
598 } |
|
599 |
|
600 // --------------------------------------------------------------------------- |
|
601 // --------------------------------------------------------------------------- |
|
602 // |
|
603 void CWsServerDrawerController::ConstructL() |
|
604 { |
|
605 #ifdef WSSERVERDRAWER_TIME_LOG |
|
606 iLogger = new (ELeave)CDebugLogger(); |
|
607 #endif //WSSERVERDRAWER_TIME_LOG |
|
608 iAppInfoCache = CAppInfoCache::NewL(); |
|
609 iEndCheck = CEndCheck::NewL(*this); |
|
610 iStates = CStateHandler::NewL(iEngine); |
|
611 |
|
612 // Fill blocklist from the array |
|
613 for(TInt i = 0; i < sizeof(KNoEffectApps) / sizeof(KNoEffectApps[0]); i++) |
|
614 { |
|
615 iStates->AddBlockUid(TUid::Uid( KNoEffectApps[i] )); |
|
616 } |
|
617 |
|
618 for(TInt i = 1; i < sizeof(KNoEffectPairs) / sizeof(KNoEffectPairs[0]); i++) |
|
619 { |
|
620 iStates->AddBlockUidPair(TUid::Uid( KNoEffectPairs[i][0] ), TUid::Uid( KNoEffectPairs[i][1] )); |
|
621 } |
|
622 |
|
623 /* Disabled adding to exception list, since we have no exceptions atm. |
|
624 for(TInt i = 0; i < sizeof(KExceptionEffectApps) / sizeof(KExceptionEffectApps[0]); i++) |
|
625 { |
|
626 iStates->AddExceptionUid(TUid::Uid( KExceptionEffectApps[i] )); |
|
627 } |
|
628 */ |
|
629 |
|
630 //AddStateL( KPSUidUikon, KUikGlobalNotesAllowed ); |
|
631 AddStateL( KPSUidScreenSaver, KScreenSaverOn ); |
|
632 AddStateL( KPSUidStartup, KPSStartupUiPhase ); |
|
633 AddStateL( KPSUidScreenSaver, KScreenSaverPreviewMode ); |
|
634 } |
|
635 |
|
636 // --------------------------------------------------------------------------- |
|
637 // --------------------------------------------------------------------------- |
|
638 // |
|
639 const TUid& CWsServerDrawerController::FocusUid() |
|
640 { |
|
641 return iAppInfoCache->FocusUid(); |
|
642 } |
|
643 |
|
644 // --------------------------------------------------------------------------- |
|
645 // --------------------------------------------------------------------------- |
|
646 // |
|
647 TBool CWsServerDrawerController::SetFocusUid(TInt aUid) |
|
648 { |
|
649 return iAppInfoCache->SetFocusUid(aUid); |
|
650 } |
|
651 |
|
652 // --------------------------------------------------------------------------- |
|
653 // --------------------------------------------------------------------------- |
|
654 // |
|
655 void CWsServerDrawerController::BeginFullscreen(TInt aType, const TUid aUid1, const TUid aUid2, TInt aData ) |
|
656 { |
|
657 TUid toUid = iEngine->ToUid(); |
|
658 TUid fromUid = iEngine->FromUid(); |
|
659 TInt flags = iEngine->Flags(); |
|
660 #ifdef WSSERVERDRAWER_TIME_LOG //time log |
|
661 if(aFromGfx) |
|
662 { |
|
663 iLogger->Log1(_L("CWsServerDrawerController::BeginFullscreen from Gfx time %d"), iLogger->TimeMs()); |
|
664 } |
|
665 else |
|
666 { |
|
667 iLogger->Log1(_L("CWsServerDrawerController::BeginFullscreen time %d"), iLogger->TimeMs()); |
|
668 } |
|
669 #endif //WSSERVERDRAWER_TIME_LOG |
|
670 |
|
671 ///////////////////// |
|
672 if(aType == AknTransEffect::EParameterAvkonInternal) |
|
673 { |
|
674 const TUid appuid = aUid1; |
|
675 if(appuid != KNullUid) |
|
676 { |
|
677 iAppInfoCache->SetUid(appuid); |
|
678 iAppInfoCache->SetAvkonUid(appuid); |
|
679 iAppInfoCache->SetParent(appuid, aUid2); |
|
680 iAppInfoCache->SetFocusUid(aData); |
|
681 } |
|
682 } |
|
683 |
|
684 // App Filter uses application uid for the unique key in the table. That causes problems as |
|
685 // there can be several instances of applications in the system which have the same uid, |
|
686 // e.g. stand-alone application and embedded applications. Because of this: |
|
687 // - We try to prevent updating App Filter flags if the instance is embedded. |
|
688 // - The existence of the parent uid do not necessarily mean that the instance is embedded. |
|
689 |
|
690 if ((toUid != KNullUid) && (iEngine->Action() == AknTransEffect::EEmbeddedApplicationExit)) |
|
691 iAppInfoCache->SetParent(toUid, KNullUid); // Clear parent uid on exit of embedded application |
|
692 |
|
693 TBool isEmbeddedAppContext = |
|
694 (iEngine->Action() == AknTransEffect::EEmbeddedApplicationExit) || |
|
695 (iEngine->Action() == AknTransEffect::EEmbeddedApplicationStart); |
|
696 |
|
697 iAppInfoCache->SetUid(toUid); |
|
698 iAppInfoCache->SetUid(fromUid); |
|
699 |
|
700 if ((toUid != KNullUid) && !isEmbeddedAppContext) |
|
701 { |
|
702 //the ok is always reset in the begining |
|
703 if(flags & AknTransEffect::TParameter::EResetServerStats) |
|
704 { //this should be called always before avkoncheck or noeffects etc for apps |
|
705 iAppInfoCache->Reset(toUid); |
|
706 } |
|
707 |
|
708 //Adding uid to block list |
|
709 if(flags & AknTransEffect::TParameter::ENoEffects) |
|
710 { |
|
711 iStates->AddBlockUid(toUid); |
|
712 } |
|
713 //Removing uid from blocklist |
|
714 if(flags & AknTransEffect::TParameter::EEnableEffects) |
|
715 { |
|
716 iStates->RemoveBlockUid(toUid); |
|
717 } |
|
718 } |
|
719 |
|
720 CStateHandler::TFullscreenType fstype = iStates->GetFullscreenType(iEngine->Action()); |
|
721 CStateHandler::TFullscreenType currtype = iStates->GetCurrentFullscreenType(); |
|
722 |
|
723 //application has to be avkon app, therefore thise |
|
724 //flag has to be set twice! |
|
725 if(flags & AknTransEffect::TParameter::EAvkonCheck) |
|
726 { |
|
727 if(fstype == CStateHandler::EExit) //application will exit and avkon flags must be reset (otherwise |
|
728 { |
|
729 iAppInfoCache->RemoveAvkonUid(toUid); //repeating calls may allow check pass |
|
730 } |
|
731 else |
|
732 { |
|
733 iAppInfoCache->SetAvkonUid(toUid); |
|
734 } |
|
735 } |
|
736 |
|
737 // TODO: All control has been disabled as it seems to block too much, |
|
738 // it appears that the states are not handled correctly or something else is missing |
|
739 |
|
740 // if we are currenly running a layoutswitch let it only be aborted by |
|
741 // another layoutswitch. |
|
742 if( (iStates->GetCurrentFullscreenType() == CStateHandler::ELayoutSwitch) && |
|
743 (iEngine->Action() != AknTransEffect::ELayoutSwitch)) |
|
744 { |
|
745 return; |
|
746 } |
|
747 |
|
748 //activation after exit is not allowed (also if exit didnt result in an effect) |
|
749 if(iLastTypeTried == CStateHandler::EExit && |
|
750 fstype == CStateHandler::EActivation) |
|
751 { //the current uid is not valid |
|
752 return; // activation not ok if exiting |
|
753 } |
|
754 |
|
755 iLastTypeTried = fstype; |
|
756 |
|
757 //activation after exit is not allowed...even it was aborted |
|
758 if(iExitAborted && |
|
759 CStateHandler::EActivation == fstype) |
|
760 { //the current uid is not valid |
|
761 AbortTransition(); //if exit is aborted, we dont want either activation |
|
762 return; // activation not ok if exiting |
|
763 } |
|
764 |
|
765 //dsa apps do not have effects |
|
766 //this is one reason why for activation end cannot be called immediately after begin |
|
767 //we should know if its a dsa app before end can be called |
|
768 if(iDSAActive) |
|
769 { |
|
770 return; //Do nothing if dsa active. |
|
771 } |
|
772 |
|
773 //Special argument calls does not initiate any FS effect and is caught here. |
|
774 // TODO: remove && !iEngine->WaitingForRootWgId() when appuids available from wserv |
|
775 if(fstype == CStateHandler::ENone) |
|
776 { |
|
777 return; |
|
778 } |
|
779 |
|
780 |
|
781 //Phone is booting, stop any FS effect. |
|
782 if(!StartCheck(flags)) |
|
783 { |
|
784 AbortTransition(); |
|
785 return; |
|
786 } |
|
787 |
|
788 // if either toUid or fromUid is in the custom list for applications |
|
789 // that should be blocked then we abort all ongoing transitions. |
|
790 if(!(AllowedCustomUid(toUid) && AllowedCustomUid(fromUid))) |
|
791 { |
|
792 AbortTransition(); |
|
793 return; |
|
794 } |
|
795 |
|
796 // No effect if a second exit effect comes in while exit effect is ongoing. |
|
797 // Double exit actually looks quite nice... |
|
798 // We are doing separate visuals, not screen capture, so there is no need to |
|
799 // filter this out |
|
800 /* |
|
801 if((currtype == fstype) && currtype == CStateHandler::EExit) |
|
802 { |
|
803 return; |
|
804 } |
|
805 */ |
|
806 |
|
807 //Filter out anything but exit effect if start effect is running. |
|
808 /* |
|
809 if((currtype == CStateHandler::EStart) && (fstype != CStateHandler::EExit)) |
|
810 { |
|
811 return; |
|
812 } |
|
813 */ |
|
814 |
|
815 // this check is for embedded apps/operator menu case ///// This check aborts ongoing. Is this right? |
|
816 // abort and skip transition if no current uid // Maybe should be added to statemachine. |
|
817 // TODO: Revise when appuids available from wserv |
|
818 /* |
|
819 if( toUid == KNullUid ) |
|
820 { |
|
821 return; |
|
822 } |
|
823 */ |
|
824 //activation switch effects are not allowed for non avkon apps as they never will |
|
825 //inform their foregound - so no transition. |
|
826 if(CStateHandler::EActivation == fstype && currtype != CStateHandler::EStart && |
|
827 !iAppInfoCache->AvkonUid(toUid)) |
|
828 { |
|
829 return; |
|
830 } |
|
831 |
|
832 if(iEngine->Action() == AknTransEffect::ELayoutSwitch) // ELayoutSwitchOut is for two phases solution |
|
833 { |
|
834 if( iLastFromUid.iUid == KScreensaverUid ) //TODO: Better test needed here? |
|
835 { |
|
836 iEngine->Action() = 1001; // 1002: start, 1001, exit |
|
837 iEngine->ToUid() = TUid::Uid(KScreensaverUid); |
|
838 iEngine->FromUid() = TUid::Uid(0); |
|
839 iEngine->Flags() |= AknTransEffect::TParameter::EActivateExplicitContinue; |
|
840 } |
|
841 else if( iLastToUid.iUid == KScreensaverUid ) //TODO: Better test needed here? |
|
842 { |
|
843 iEngine->Action() = 1002; // 1002: start, 1001, exit |
|
844 iEngine->ToUid() = TUid::Uid(KScreensaverUid); |
|
845 iEngine->FromUid() = TUid::Uid(0); |
|
846 iEngine->Flags() |= AknTransEffect::TParameter::EActivateExplicitContinue; |
|
847 } |
|
848 else |
|
849 { |
|
850 switch(iLastAction) |
|
851 { |
|
852 case AknTransEffect::EApplicationExit: |
|
853 iEngine->Action() = AknTransEffect::ELayoutSwitchExit; |
|
854 break; |
|
855 case AknTransEffect::EApplicationStartRect: |
|
856 case AknTransEffect::EApplicationStart: |
|
857 iEngine->Action() = AknTransEffect::ELayoutSwitchStart; |
|
858 break; |
|
859 //case AknTransEffect::EApplicationActivate: // Does it work only for application active? |
|
860 default: |
|
861 break; |
|
862 } |
|
863 } |
|
864 } |
|
865 |
|
866 if (!iStates->IsBlocked(fromUid, toUid)) |
|
867 { |
|
868 iLastAction = AknTransEffect::ENone; |
|
869 iLastFromUid = KNullUid; |
|
870 iLastToUid = KNullUid; |
|
871 iLayoutChangeActive = EFalse; |
|
872 } |
|
873 // Convert |
|
874 |
|
875 // Signal statemachine |
|
876 iStates->Signal(CStateBase::EBeginFullscreen); |
|
877 // Start end checker always. |
|
878 if(flags & AknTransEffect::TParameter::EEndCheck) |
|
879 { |
|
880 StartEndChecker(); |
|
881 } |
|
882 else |
|
883 { |
|
884 StartEndChecker(KEndTimeOut); |
|
885 } |
|
886 } |
|
887 |
|
888 |
|
889 // --------------------------------------------------------------------------- |
|
890 // --------------------------------------------------------------------------- |
|
891 // |
|
892 |
|
893 |
|
894 TBool CWsServerDrawerController::StartCheck(TInt aFlags) const |
|
895 { |
|
896 if((aFlags & AknTransEffect::TParameter::EActivateExplicitContinue)) //always allow this |
|
897 { |
|
898 return true; |
|
899 } |
|
900 else if(iEngine->Action() == AknTransEffect::ELayoutSwitch) //always allow layoutswitch |
|
901 { |
|
902 return true; |
|
903 } |
|
904 else if (aFlags & AknTransEffect::TParameter::EAllowAtBoot) //allow unless screensaver is on |
|
905 { |
|
906 return !TBool(GetState(KScreenSaverOn)) && |
|
907 !TBool(GetState(KScreenSaverPreviewMode)); //off |
|
908 } |
|
909 else |
|
910 { |
|
911 return /*TBool(GetState(KUikGlobalNotesAllowed)) //on |
|
912 && */ iAppInfoCache->GateFound() |
|
913 && !TBool(GetState(KScreenSaverOn)) |
|
914 && !TBool(GetState(KScreenSaverPreviewMode)); //off |
|
915 // && TBool(GetState(ESplashRunning)) |
|
916 } |
|
917 } |
|
918 |
|
919 // --------------------------------------------------------------------------- |
|
920 // --------------------------------------------------------------------------- |
|
921 // |
|
922 void CWsServerDrawerController::StartEndChecker(TInt aMultiplier) |
|
923 { |
|
924 iEndCheck->Start(aMultiplier); |
|
925 } |
|
926 |
|
927 // --------------------------------------------------------------------------- |
|
928 // --------------------------------------------------------------------------- |
|
929 // |
|
930 void CWsServerDrawerController::CancelEndChecker() |
|
931 { |
|
932 iEndCheck->Cancel(); |
|
933 } |
|
934 |
|
935 // --------------------------------------------------------------------------- |
|
936 // --------------------------------------------------------------------------- |
|
937 // |
|
938 void CWsServerDrawerController::EndExpired() |
|
939 { |
|
940 __ALFFXLOGSTRING("CWsServerDrawerController::EndExpired >>"); |
|
941 AbortTransition(EAbortFullscreen); |
|
942 iExitAborted = EFalse; //This is not valid when we have a time-out |
|
943 __ALFFXLOGSTRING("CWsServerDrawerController::EndExpired <<"); |
|
944 } |
|
945 |
|
946 // --------------------------------------------------------------------------- |
|
947 // --------------------------------------------------------------------------- |
|
948 // |
|
949 void CWsServerDrawerController::EndFullscreen(TBool /*aFromGfx*/) |
|
950 { |
|
951 /* |
|
952 DSA end fix |
|
953 */ |
|
954 if(iDSAActive) |
|
955 { |
|
956 AbortTransition(); |
|
957 return; //Do nothing if dsa active. |
|
958 } |
|
959 |
|
960 |
|
961 #ifdef WSSERVERDRAWER_TIME_LOG //time log |
|
962 iLogger->Log1(_L("CWsServerDrawerController::EndFullscreen time %d"), iLogger->TimeMs()); |
|
963 #endif //WSSERVERDRAWER_TIME_LOG |
|
964 |
|
965 iStates->Signal(CStateBase::EEndFullscreen); |
|
966 } |
|
967 |
|
968 |
|
969 // --------------------------------------------------------------------------- |
|
970 // --------------------------------------------------------------------------- |
|
971 // |
|
972 void CWsServerDrawerController::FullscreenFinished(TInt aHandle) |
|
973 { |
|
974 if(aHandle == iEngine->CurrentHandle()) // Filter away stray finish signals. |
|
975 { |
|
976 iLastTypeTried = CStateHandler::ENone; |
|
977 iStates->Signal(CStateBase::EFinishFullscreen); |
|
978 } |
|
979 } |
|
980 |
|
981 // --------------------------------------------------------------------------- |
|
982 // --------------------------------------------------------------------------- |
|
983 // |
|
984 TInt CWsServerDrawerController::BeginControlTransition() |
|
985 { |
|
986 if(iDSAActive) |
|
987 { |
|
988 return KErrAbort; |
|
989 } |
|
990 |
|
991 if(iLayoutChangeActive) |
|
992 { |
|
993 return KErrAbort; |
|
994 } |
|
995 // Check booting time disabling & screensaver |
|
996 __ALFFXLOGSTRING2("GetState(KUikGlobalNotesAllowed) %d, GetState(KScreenSaverOn)), %d GetState(KScreenSaverPreviewMode) %d", |
|
997 /*TBool(GetState(KUikGlobalNotesAllowed)),*/ |
|
998 TBool(GetState(KScreenSaverOn)), |
|
999 TBool(GetState(KScreenSaverPreviewMode))); |
|
1000 |
|
1001 if(/*TBool(GetState(KUikGlobalNotesAllowed))==EFalse || */ |
|
1002 TBool(GetState(KScreenSaverOn)) || |
|
1003 TBool(GetState(KScreenSaverPreviewMode))) |
|
1004 { |
|
1005 return KErrAbort; |
|
1006 } |
|
1007 |
|
1008 iStates->Signal(CStateBase::EBeginComponent); |
|
1009 |
|
1010 if(iStates->GetState() == CStateBase::EComponent) |
|
1011 { |
|
1012 return iEngine->CurrentHandle(); |
|
1013 } |
|
1014 else |
|
1015 { |
|
1016 return KErrAbort; |
|
1017 } |
|
1018 } |
|
1019 |
|
1020 // --------------------------------------------------------------------------- |
|
1021 // --------------------------------------------------------------------------- |
|
1022 // |
|
1023 void CWsServerDrawerController::EndControlTransition(TInt aHandle) |
|
1024 { |
|
1025 if(aHandle == iEngine->CurrentHandle()) //Filter out stray endcomponent. |
|
1026 { |
|
1027 iStates->Signal(CStateBase::EFinishComponent); |
|
1028 } |
|
1029 } |
|
1030 |
|
1031 // --------------------------------------------------------------------------- |
|
1032 // --------------------------------------------------------------------------- |
|
1033 // |
|
1034 void CWsServerDrawerController::ScreenModeChange(TBool aBeforeScreenModeChange) |
|
1035 { |
|
1036 if( aBeforeScreenModeChange ) |
|
1037 { |
|
1038 AbortTransition(); |
|
1039 iLayoutChangeActive = ETrue; |
|
1040 } |
|
1041 } |
|
1042 |
|
1043 // --------------------------------------------------------------------------- |
|
1044 // --------------------------------------------------------------------------- |
|
1045 // |
|
1046 void CWsServerDrawerController::Error( TServerDrawerError /*aError*/ ) |
|
1047 { |
|
1048 AbortTransition(); |
|
1049 } |
|
1050 |
|
1051 |
|
1052 // --------------------------------------------------------------------------- |
|
1053 // --------------------------------------------------------------------------- |
|
1054 // |
|
1055 void CWsServerDrawerController::SaveLastActionAndUid() |
|
1056 { |
|
1057 iLastAction = iEngine->Action(); |
|
1058 iLastFromUid = iEngine->FromUid(); |
|
1059 iLastToUid = iEngine->ToUid(); |
|
1060 } |
|
1061 |
|
1062 // --------------------------------------------------------------------------- |
|
1063 // --------------------------------------------------------------------------- |
|
1064 // |
|
1065 void CWsServerDrawerController::DSABegin() |
|
1066 { |
|
1067 AbortTransition(); |
|
1068 iDSAActive = ETrue; |
|
1069 } |
|
1070 |
|
1071 // --------------------------------------------------------------------------- |
|
1072 // --------------------------------------------------------------------------- |
|
1073 // |
|
1074 void CWsServerDrawerController::DSAEnd() |
|
1075 { |
|
1076 iDSAActive = EFalse; |
|
1077 } |
|
1078 |
|
1079 |
|
1080 // --------------------------------------------------------------------------- |
|
1081 // --------------------------------------------------------------------------- |
|
1082 // |
|
1083 void CWsServerDrawerController::AbortTransition(TInt aToAbort) |
|
1084 { |
|
1085 __ALFFXLOGSTRING("CWsServerDrawerController::AbortTransition >>"); |
|
1086 if ( aToAbort == EAbortFullscreen ) |
|
1087 { |
|
1088 iLastTypeTried = CStateHandler::ENone; |
|
1089 iExitAborted = iStates->GetCurrentFullscreenType() == CStateHandler::EExit; |
|
1090 iStates->Signal(CStateBase::EAbortFullscreen); |
|
1091 } |
|
1092 else if ( aToAbort == EAbortControl ) |
|
1093 { |
|
1094 iStates->Signal(CStateBase::EAbortComponent); |
|
1095 } |
|
1096 else if( (aToAbort & EAbortControl) && (aToAbort & EAbortFullscreen) ) |
|
1097 { |
|
1098 iLastTypeTried = CStateHandler::ENone; |
|
1099 iExitAborted = iStates->GetCurrentFullscreenType() == CStateHandler::EExit; |
|
1100 iStates->Signal(CStateBase::EAbort); |
|
1101 } |
|
1102 __ALFFXLOGSTRING("CWsServerDrawerController::AbortTransition <<"); |
|
1103 } |
|
1104 |
|
1105 // --------------------------------------------------------------------------- |
|
1106 // --------------------------------------------------------------------------- |
|
1107 // |
|
1108 TBool CWsServerDrawerController::IsBlocked( const TUid& aFromUid, const TUid& aToUid ) |
|
1109 { |
|
1110 TBool result = iStates->IsBlocked( aFromUid, aToUid ); |
|
1111 __ALFFXLOGSTRING1("CWsServerDrawerController::IsBlocked - return %d", result); |
|
1112 return result; |
|
1113 } |
|
1114 |