797 TSecureId CGfxTransAdapterTfx::SecureIdFromAppUid( TUid aAppUid ) |
797 TSecureId CGfxTransAdapterTfx::SecureIdFromAppUid( TUid aAppUid ) |
798 { |
798 { |
799 TSecureId result(aAppUid); |
799 TSecureId result(aAppUid); |
800 if ( aAppUid == TUid::Null() ) |
800 if ( aAppUid == TUid::Null() ) |
801 { |
801 { |
|
802 iCachedUidMapping.iWindowGroupId = -1; |
802 return result; |
803 return result; |
803 } |
804 } |
804 |
805 |
805 TBool found = EFalse; |
806 __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid Searching SID&WGID for aAppUid: 0x%x", aAppUid.iUid ); |
806 |
807 |
807 // first check the cache |
808 // first check the cache |
808 if ( iCachedUidMapping.iAppUid == aAppUid.iUid && iCachedUidMapping.iSecureId != 0 ) |
809 if ( iCachedUidMapping.iAppUid == aAppUid.iUid && iCachedUidMapping.iSecureId != 0 ) |
809 { |
810 { |
810 result = iCachedUidMapping.iSecureId; |
811 __ALFFXLOGSTRING2( "CGfxTransAdapterTfx::SecureIdFromAppUid using cached SID 0x%x and WGID: %d", |
811 found = ETrue; |
812 iCachedUidMapping.iSecureId, |
812 } |
813 iCachedUidMapping.iWindowGroupId ); |
|
814 return TSecureId(iCachedUidMapping.iSecureId); |
|
815 } |
|
816 |
|
817 TInt windowGroupId = -1; |
|
818 RProcess thisProcess; |
|
819 TUidType uidType = thisProcess.Type(); |
813 |
820 |
814 if ( !found ) |
821 if ( uidType.IsValid() ) |
815 { |
822 { |
816 // do the hard work |
823 bool thisApplication = false; |
817 // first check this process - this is quick |
824 if ( uidType[2] == aAppUid ) // 0 = UID1, 1 = UID2, 2 = UID3 |
818 // also, if this is the start-up effect on an application, the TApaTask is not yet updated with the |
825 { |
819 // window group created by this application (yet). |
826 // this application |
820 TInt windowGroupId = -1; |
827 result = thisProcess.SecureId(); |
821 RProcess thisProcess; |
828 thisApplication = ETrue; |
822 TUidType uidType = thisProcess.Type(); |
829 __ALFFXLOGSTRING2("CGfxTransAdapterTfx::SecureIdFromAppUid Own SID 0x%x in thread %S", |
823 if ( uidType.IsValid() ) |
830 result.iId, |
|
831 &RThread().Name() ); |
|
832 } |
|
833 |
|
834 CCoeEnv* env = CCoeEnv::Static(); |
|
835 RWsSession localSession; |
|
836 RWsSession* usedWsSession = NULL; |
|
837 if ( env ) |
824 { |
838 { |
825 if ( uidType[2] == aAppUid ) // 0 = UID1, 1 = UID2, 2 = UID3 |
839 usedWsSession = &env->WsSession(); |
826 { |
840 } |
827 result = thisProcess.SecureId(); |
841 else |
828 // take the window gruop ID as well if available |
842 { |
829 CCoeEnv* env = CCoeEnv::Static(); |
843 if ( localSession.Connect() == KErrNone ) |
830 if ( env ) |
844 { |
831 { |
845 usedWsSession = &localSession; |
832 windowGroupId = env->RootWin().Identifier(); |
|
833 } |
|
834 found = ETrue; |
|
835 } |
846 } |
836 } |
847 } |
837 thisProcess.Close(); |
848 |
838 |
849 // check if the AppArcServer has already information about this Application |
839 // If not this application, find UID using the TApaTask |
850 if ( usedWsSession ) |
840 if ( !found ) |
|
841 { |
851 { |
842 TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
852 TApaTaskList taskList( *usedWsSession ); |
843 const TApaTask task = taskList.FindApp( aAppUid ); |
853 const TApaTask task = taskList.FindApp( aAppUid ); |
844 const TThreadId threadId = task.ThreadId(); |
854 const TThreadId otherThreadId = task.ThreadId(); |
845 RThread otherThread; |
855 |
846 if ( otherThread.Open( threadId ) == KErrNone ) // ignore error |
856 if ( thisApplication ) |
847 { |
857 { |
848 result = otherThread.SecureId(); |
858 // if security ID of the other thread matched, we take the WG ID from AppArcServer |
849 windowGroupId = task.WgId(); // take it for free at this point. |
859 RThread otherThread; |
850 found = ETrue; |
860 if ( otherThread.Open( otherThreadId ) == KErrNone ) |
851 } |
|
852 otherThread.Close(); |
|
853 } |
|
854 |
|
855 if ( found ) |
|
856 { |
|
857 // update cache |
|
858 if ( iCachedUidMapping.iAppUid == aAppUid.iUid ) |
|
859 { |
|
860 // found the missing secure ID |
|
861 iCachedUidMapping.iSecureId = result.iId; |
|
862 |
|
863 if ( windowGroupId > 0 ) |
|
864 { |
861 { |
865 // if we got the window group ID, update that as well to the cache |
862 __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid Exising TApaTask found using thread %S", &otherThread.Name() ); |
866 iCachedUidMapping.iWindowGroupId = windowGroupId; |
863 if ( otherThread.SecureId() == result ) |
|
864 { |
|
865 windowGroupId = task.WgId(); |
|
866 __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid SID match -> WGID : &d found from TApaTask", windowGroupId ); |
|
867 } |
|
868 else |
|
869 { |
|
870 __ALFFXLOGSTRING2("CGfxTransAdapterTfx::SecureIdFromAppUid otherSID 0x%x otherWGID : &d not matching in TApaTask", otherThread.SecureId().iId , task.WgId() ); |
|
871 } |
|
872 } |
|
873 otherThread.Close(); |
|
874 |
|
875 if ( windowGroupId == -1 && env ) |
|
876 { |
|
877 // take the root WG ID |
|
878 windowGroupId = env->RootWin().Identifier(); |
|
879 __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid root WGID %d used", windowGroupId ); |
867 } |
880 } |
868 } |
881 } |
869 else |
882 else |
870 { |
883 { |
871 iCachedUidMapping.iAppUid = aAppUid.iUid; |
884 RThread otherThread; |
872 iCachedUidMapping.iSecureId = result.iId; |
885 if ( otherThread.Open( otherThreadId ) == KErrNone ) |
873 // wgid might not be updated at this point. |
886 { |
874 iCachedUidMapping.iWindowGroupId = Max(windowGroupId,0); // might be -1 -> treat 0 and -1 is just 0 |
887 result = otherThread.SecureId(); |
|
888 windowGroupId = task.WgId(); |
|
889 __ALFFXLOGSTRING3("CGfxTransAdapterTfx::SecureIdFromAppUid Taking SID 0x%x WGID %d from thread %S via TApaTask", result.iId, windowGroupId, &otherThread.Name() ); |
|
890 } |
|
891 otherThread.Close(); |
875 } |
892 } |
876 } |
893 } |
877 } |
894 |
|
895 localSession.Close(); |
|
896 } |
|
897 thisProcess.Close(); |
878 |
898 |
879 if ( !found ) |
899 if ( windowGroupId != -1 ) |
880 { |
900 { |
881 __ALFFXLOGSTRING1( "CGfxTransAdapterTfx::SecureIdFromAppUid AppUid 0x%x not found (yet)", aAppUid.iUid ); |
901 // update cache |
882 } |
902 iCachedUidMapping.iAppUid = aAppUid.iUid; |
883 else if ( aAppUid.iUid != result.iId ) |
903 iCachedUidMapping.iSecureId = result; |
884 { |
904 iCachedUidMapping.iWindowGroupId = windowGroupId; |
885 __ALFFXLOGSTRING2( "CGfxTransAdapterTfx::SecureIdFromAppUid SecureID 0x%x differs form AppUid 0x%x", result.iId, aAppUid.iUid ); |
|
886 } |
905 } |
887 |
906 |
888 return result; |
907 return result; |
889 } |
908 } |
890 |
909 |
892 // GfxTransEffect::WindowGroupIdFromAppUid |
911 // GfxTransEffect::WindowGroupIdFromAppUid |
893 // --------------------------------------------------------------------------- |
912 // --------------------------------------------------------------------------- |
894 // |
913 // |
895 TInt32 CGfxTransAdapterTfx::WindowGroupIdFromAppUid( TUid aAppUid ) |
914 TInt32 CGfxTransAdapterTfx::WindowGroupIdFromAppUid( TUid aAppUid ) |
896 { |
915 { |
897 if ( aAppUid == TUid::Null() ) |
916 TInt32 result = 0; |
898 { |
917 if ( iCachedUidMapping.iAppUid == aAppUid.iUid ) |
899 return 0; |
918 { |
900 } |
919 result = iCachedUidMapping.iWindowGroupId; |
901 |
920 } |
902 TInt result = 0; |
921 iCachedUidMapping.iSecureId = 0; |
903 TBool found = EFalse; |
922 return result; |
904 |
|
905 // check the cache. most likely this is already up-to-date due the previous execution of SecureIdFromAppUid |
|
906 if ( iCachedUidMapping.iAppUid == aAppUid.iUid ) |
|
907 { |
|
908 if ( iCachedUidMapping.iWindowGroupId > 0 ) |
|
909 { |
|
910 result = iCachedUidMapping.iWindowGroupId; |
|
911 iCachedUidMapping.iSecureId = 0; |
|
912 found = true; |
|
913 } |
|
914 } |
|
915 |
|
916 if ( !found ) |
|
917 { |
|
918 // do the hard work |
|
919 TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); |
|
920 const TApaTask task = taskList.FindApp( aAppUid ); |
|
921 result = TInt32(task.WgId()); |
|
922 |
|
923 if ( result > 0 ) |
|
924 { |
|
925 // update cache |
|
926 found = ETrue; |
|
927 if ( iCachedUidMapping.iAppUid != aAppUid.iUid ) |
|
928 { |
|
929 iCachedUidMapping.iAppUid = aAppUid.iUid; |
|
930 iCachedUidMapping.iSecureId = 0; |
|
931 } |
|
932 iCachedUidMapping.iWindowGroupId = result; |
|
933 } |
|
934 else |
|
935 { |
|
936 result = 0; // might be -1 -> treat 0 and -1 is just 0 |
|
937 } |
|
938 } |
|
939 |
|
940 if ( !found ) |
|
941 { |
|
942 __ALFFXLOGSTRING1( "CGfxTransAdapterTfx::WindowGroupIdFromAppUid AppUid 0x%x not found (yet)", aAppUid.iUid ); |
|
943 } |
|
944 |
|
945 return TInt32(result); |
|
946 } |
923 } |
947 |
924 |
948 |
925 |
949 // --------------------------------------------------------------------------- |
926 // --------------------------------------------------------------------------- |
950 // GfxTransEffect::BeginFullscreen gets passed here. |
927 // GfxTransEffect::BeginFullscreen gets passed here. |