uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp Wed Jun 09 10:41:25 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp Mon Jun 21 16:41:52 2010 +0300
@@ -799,90 +799,109 @@
TSecureId result(aAppUid);
if ( aAppUid == TUid::Null() )
{
+ iCachedUidMapping.iWindowGroupId = -1;
return result;
}
-
- TBool found = EFalse;
+
+ __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid Searching SID&WGID for aAppUid: 0x%x", aAppUid.iUid );
// first check the cache
if ( iCachedUidMapping.iAppUid == aAppUid.iUid && iCachedUidMapping.iSecureId != 0 )
{
- result = iCachedUidMapping.iSecureId;
- found = ETrue;
- }
+ __ALFFXLOGSTRING2( "CGfxTransAdapterTfx::SecureIdFromAppUid using cached SID 0x%x and WGID: %d",
+ iCachedUidMapping.iSecureId,
+ iCachedUidMapping.iWindowGroupId );
+ return TSecureId(iCachedUidMapping.iSecureId);
+ }
+
+ TInt windowGroupId = -1;
+ RProcess thisProcess;
+ TUidType uidType = thisProcess.Type();
- if ( !found )
+ if ( uidType.IsValid() )
{
- // do the hard work
- // first check this process - this is quick
- // also, if this is the start-up effect on an application, the TApaTask is not yet updated with the
- // window group created by this application (yet).
- TInt windowGroupId = -1;
- RProcess thisProcess;
- TUidType uidType = thisProcess.Type();
- if ( uidType.IsValid() )
+ bool thisApplication = false;
+ if ( uidType[2] == aAppUid ) // 0 = UID1, 1 = UID2, 2 = UID3
+ {
+ // this application
+ result = thisProcess.SecureId();
+ thisApplication = ETrue;
+ __ALFFXLOGSTRING2("CGfxTransAdapterTfx::SecureIdFromAppUid Own SID 0x%x in thread %S",
+ result.iId,
+ &RThread().Name() );
+ }
+
+ CCoeEnv* env = CCoeEnv::Static();
+ RWsSession localSession;
+ RWsSession* usedWsSession = NULL;
+ if ( env )
{
- if ( uidType[2] == aAppUid ) // 0 = UID1, 1 = UID2, 2 = UID3
- {
- result = thisProcess.SecureId();
- // take the window gruop ID as well if available
- CCoeEnv* env = CCoeEnv::Static();
- if ( env )
- {
- windowGroupId = env->RootWin().Identifier();
- }
- found = ETrue;
+ usedWsSession = &env->WsSession();
+ }
+ else
+ {
+ if ( localSession.Connect() == KErrNone )
+ {
+ usedWsSession = &localSession;
}
}
- thisProcess.Close();
-
- // If not this application, find UID using the TApaTask
- if ( !found )
+
+ // check if the AppArcServer has already information about this Application
+ if ( usedWsSession )
{
- TApaTaskList taskList( CCoeEnv::Static()->WsSession() );
+ TApaTaskList taskList( *usedWsSession );
const TApaTask task = taskList.FindApp( aAppUid );
- const TThreadId threadId = task.ThreadId();
- RThread otherThread;
- if ( otherThread.Open( threadId ) == KErrNone ) // ignore error
+ const TThreadId otherThreadId = task.ThreadId();
+
+ if ( thisApplication )
{
- result = otherThread.SecureId();
- windowGroupId = task.WgId(); // take it for free at this point.
- found = ETrue;
- }
- otherThread.Close();
- }
-
- if ( found )
- {
- // update cache
- if ( iCachedUidMapping.iAppUid == aAppUid.iUid )
- {
- // found the missing secure ID
- iCachedUidMapping.iSecureId = result.iId;
-
- if ( windowGroupId > 0 )
+ // if security ID of the other thread matched, we take the WG ID from AppArcServer
+ RThread otherThread;
+ if ( otherThread.Open( otherThreadId ) == KErrNone )
{
- // if we got the window group ID, update that as well to the cache
- iCachedUidMapping.iWindowGroupId = windowGroupId;
+ __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid Exising TApaTask found using thread %S", &otherThread.Name() );
+ if ( otherThread.SecureId() == result )
+ {
+ windowGroupId = task.WgId();
+ __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid SID match -> WGID : &d found from TApaTask", windowGroupId );
+ }
+ else
+ {
+ __ALFFXLOGSTRING2("CGfxTransAdapterTfx::SecureIdFromAppUid otherSID 0x%x otherWGID : &d not matching in TApaTask", otherThread.SecureId().iId , task.WgId() );
+ }
+ }
+ otherThread.Close();
+
+ if ( windowGroupId == -1 && env )
+ {
+ // take the root WG ID
+ windowGroupId = env->RootWin().Identifier();
+ __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid root WGID %d used", windowGroupId );
}
}
- else
+ else
{
- iCachedUidMapping.iAppUid = aAppUid.iUid;
- iCachedUidMapping.iSecureId = result.iId;
- // wgid might not be updated at this point.
- iCachedUidMapping.iWindowGroupId = Max(windowGroupId,0); // might be -1 -> treat 0 and -1 is just 0
+ RThread otherThread;
+ if ( otherThread.Open( otherThreadId ) == KErrNone )
+ {
+ result = otherThread.SecureId();
+ windowGroupId = task.WgId();
+ __ALFFXLOGSTRING3("CGfxTransAdapterTfx::SecureIdFromAppUid Taking SID 0x%x WGID %d from thread %S via TApaTask", result.iId, windowGroupId, &otherThread.Name() );
+ }
+ otherThread.Close();
}
}
+
+ localSession.Close();
}
+ thisProcess.Close();
- if ( !found )
+ if ( windowGroupId != -1 )
{
- __ALFFXLOGSTRING1( "CGfxTransAdapterTfx::SecureIdFromAppUid AppUid 0x%x not found (yet)", aAppUid.iUid );
- }
- else if ( aAppUid.iUid != result.iId )
- {
- __ALFFXLOGSTRING2( "CGfxTransAdapterTfx::SecureIdFromAppUid SecureID 0x%x differs form AppUid 0x%x", result.iId, aAppUid.iUid );
+ // update cache
+ iCachedUidMapping.iAppUid = aAppUid.iUid;
+ iCachedUidMapping.iSecureId = result;
+ iCachedUidMapping.iWindowGroupId = windowGroupId;
}
return result;
@@ -894,55 +913,13 @@
//
TInt32 CGfxTransAdapterTfx::WindowGroupIdFromAppUid( TUid aAppUid )
{
- if ( aAppUid == TUid::Null() )
- {
- return 0;
- }
-
- TInt result = 0;
- TBool found = EFalse;
-
- // check the cache. most likely this is already up-to-date due the previous execution of SecureIdFromAppUid
- if ( iCachedUidMapping.iAppUid == aAppUid.iUid )
- {
- if ( iCachedUidMapping.iWindowGroupId > 0 )
- {
- result = iCachedUidMapping.iWindowGroupId;
- iCachedUidMapping.iSecureId = 0;
- found = true;
- }
- }
-
- if ( !found )
+ TInt32 result = 0;
+ if ( iCachedUidMapping.iAppUid == aAppUid.iUid )
{
- // do the hard work
- TApaTaskList taskList( CCoeEnv::Static()->WsSession() );
- const TApaTask task = taskList.FindApp( aAppUid );
- result = TInt32(task.WgId());
-
- if ( result > 0 )
- {
- // update cache
- found = ETrue;
- if ( iCachedUidMapping.iAppUid != aAppUid.iUid )
- {
- iCachedUidMapping.iAppUid = aAppUid.iUid;
- iCachedUidMapping.iSecureId = 0;
- }
- iCachedUidMapping.iWindowGroupId = result;
- }
- else
- {
- result = 0; // might be -1 -> treat 0 and -1 is just 0
- }
+ result = iCachedUidMapping.iWindowGroupId;
}
-
- if ( !found )
- {
- __ALFFXLOGSTRING1( "CGfxTransAdapterTfx::WindowGroupIdFromAppUid AppUid 0x%x not found (yet)", aAppUid.iUid );
- }
-
- return TInt32(result);
+ iCachedUidMapping.iSecureId = 0;
+ return result;
}