24 #include <javastoragenames.h> |
24 #include <javastoragenames.h> |
25 #include <utf.h> |
25 #include <utf.h> |
26 |
26 |
27 #include "silentmidletinstall.h" |
27 #include "silentmidletinstall.h" |
28 #include "javacommonutils.h" |
28 #include "javacommonutils.h" |
|
29 #include "javauid.h" |
|
30 #include "javauids.h" |
29 #include "logger.h" |
31 #include "logger.h" |
30 #include "javaprocessconstants.h" |
32 #include "javaprocessconstants.h" |
31 #include "javasymbianoslayer.h" |
33 #include "javasymbianoslayer.h" |
32 |
34 |
33 using namespace java::storage; |
35 using namespace java::storage; |
49 const int NO_PREINSTALL = 2; |
51 const int NO_PREINSTALL = 2; |
50 |
52 |
51 _LIT(KMidletName, "MIDlet-Name"); |
53 _LIT(KMidletName, "MIDlet-Name"); |
52 _LIT(KMidletVendor, "MIDlet-Vendor"); |
54 _LIT(KMidletVendor, "MIDlet-Vendor"); |
53 _LIT(KMidletVersion, "MIDlet-Version"); |
55 _LIT(KMidletVersion, "MIDlet-Version"); |
|
56 _LIT(KMidletUid, "Nokia-MIDlet-UID-1"); |
54 |
57 |
55 _LIT(KJadExtension, "*.jad"); |
58 _LIT(KJadExtension, "*.jad"); |
56 |
59 |
57 // Java Installer Integrity Service journal file name |
60 // Java Installer Integrity Service journal file name |
58 _LIT(KISJournalFile, "\\private\\102033E6\\installer\\is\\isjournal.dat"); |
61 _LIT(KISJournalFile, "\\private\\102033E6\\installer\\is\\isjournal.dat"); |
94 * |
97 * |
95 * @exception If the method is not able to allocate necessary buffers. |
98 * @exception If the method is not able to allocate necessary buffers. |
96 */ |
99 */ |
97 void CSilentMIDletInstall::ConstructL() |
100 void CSilentMIDletInstall::ConstructL() |
98 { |
101 { |
99 JELOG2(EJavaPreinstaller); |
|
100 iMIDletName = HBufC::NewL(KMaxBufferSize); |
102 iMIDletName = HBufC::NewL(KMaxBufferSize); |
101 iMIDletVendor = HBufC::NewL(KMaxBufferSize); |
103 iMIDletVendor = HBufC::NewL(KMaxBufferSize); |
|
104 iMIDletUid = HBufC::NewL(KMaxBufferSize); |
102 iPreinstallServer = new(ELeave) PreinstallCommsServer(); |
105 iPreinstallServer = new(ELeave) PreinstallCommsServer(); |
103 |
106 |
104 iNumberOfAppsToInstall = 0; |
107 iNumberOfAppsToInstall = 0; |
105 iISRollbackNeeded = EFalse; |
108 iISRollbackNeeded = EFalse; |
106 } |
109 } |
109 * Deletes this object. |
112 * Deletes this object. |
110 * All allocated resources are released. |
113 * All allocated resources are released. |
111 */ |
114 */ |
112 CSilentMIDletInstall::~CSilentMIDletInstall() |
115 CSilentMIDletInstall::~CSilentMIDletInstall() |
113 { |
116 { |
114 JELOG2(EJavaPreinstaller); |
|
115 iJadFiles.ResetAndDestroy(); |
117 iJadFiles.ResetAndDestroy(); |
116 iJadFiles.Close(); |
118 iJadFiles.Close(); |
117 |
119 |
118 iDirs.ResetAndDestroy(); |
120 iDirs.ResetAndDestroy(); |
119 iDirs.Close(); |
121 iDirs.Close(); |
122 iMIDletName = NULL; |
124 iMIDletName = NULL; |
123 |
125 |
124 delete iMIDletVendor; |
126 delete iMIDletVendor; |
125 iMIDletVendor = NULL; |
127 iMIDletVendor = NULL; |
126 |
128 |
|
129 delete iMIDletUid; |
|
130 iMIDletUid = NULL; |
|
131 |
127 delete iPreinstallServer; |
132 delete iPreinstallServer; |
128 iPreinstallServer = NULL; |
133 iPreinstallServer = NULL; |
129 } |
134 } |
130 |
135 |
131 /** |
136 /** |
132 * To start silent preinstallations. |
137 * To start silent preinstallations. |
133 */ |
138 */ |
134 void CSilentMIDletInstall::Start() |
139 void CSilentMIDletInstall::Start() |
135 { |
140 { |
136 JELOG2(EJavaPreinstaller); |
|
137 iState = EFindOutDeviceDrives; |
141 iState = EFindOutDeviceDrives; |
138 |
142 |
139 // Check if an explicit roll-back of a previous installation is needed |
143 // Check if an explicit roll-back of a previous installation is needed |
140 // in the case there is nothing to pre-install (if there is something |
144 // in the case there is nothing to pre-install (if there is something |
141 // to pre-install, the potential roll-back is done automatically) |
145 // to pre-install, the potential roll-back is done automatically) |
185 * - iStatus == KErrNone |
189 * - iStatus == KErrNone |
186 * - IsActive() == ETrue |
190 * - IsActive() == ETrue |
187 */ |
191 */ |
188 void CSilentMIDletInstall::CompleteRequest() |
192 void CSilentMIDletInstall::CompleteRequest() |
189 { |
193 { |
190 JELOG2(EJavaPreinstaller); |
|
191 |
|
192 TRequestStatus *status = &iStatus; |
194 TRequestStatus *status = &iStatus; |
193 User::RequestComplete(status, KErrNone); |
195 User::RequestComplete(status, KErrNone); |
194 if (!IsActive()) |
196 if (!IsActive()) |
195 { |
197 { |
196 SetActive(); |
198 SetActive(); |
447 pathPtr.Append(aDirectory); |
447 pathPtr.Append(aDirectory); |
448 pathPtr.Append(name); |
448 pathPtr.Append(name); |
449 LOG1WSTR(EJavaPreinstaller, EInfo, |
449 LOG1WSTR(EJavaPreinstaller, EInfo, |
450 "CSilentMIDletInstall::GetDirEntriesL Adding file %s", |
450 "CSilentMIDletInstall::GetDirEntriesL Adding file %s", |
451 (wchar_t *)(pathPtr.PtrZ())); |
451 (wchar_t *)(pathPtr.PtrZ())); |
452 aVector.Append(path); |
452 aVector.AppendL(path); |
453 CleanupStack::Pop(path); |
453 CleanupStack::Pop(path); |
454 } |
454 } |
455 |
455 |
456 CleanupStack::PopAndDestroy(entries); |
456 CleanupStack::PopAndDestroy(entries); |
457 } |
457 } |
578 } |
578 } |
579 |
579 |
580 /** |
580 /** |
581 * Parse MIDlet-Name, MIDlet-Vendor and MIDlet-Version parameters from JAD file. |
581 * Parse MIDlet-Name, MIDlet-Vendor and MIDlet-Version parameters from JAD file. |
582 * Parameters are used to determine whether to pre-install MIDlet or not. |
582 * Parameters are used to determine whether to pre-install MIDlet or not. |
|
583 * Parse also optional Nokia-MIDlet-UID-1 in case it is needed. |
583 * |
584 * |
584 * @param ETrue if parsing succeeds otherwise EFalse. |
585 * @param ETrue if parsing succeeds otherwise EFalse. |
585 */ |
586 */ |
586 TBool CSilentMIDletInstall::ParseJadL(const TDesC& aJadFileName) |
587 TBool CSilentMIDletInstall::ParseJadL(const TDesC& aJadFileName) |
587 { |
588 { |
588 JELOG2(EJavaPreinstaller); |
|
589 |
|
590 HBufC *jadContent = NULL; |
589 HBufC *jadContent = NULL; |
591 // Trap leave thrown if reading jad content fails |
590 // Trap leave thrown if reading jad content fails |
592 TRAPD(err, jadContent = GetJadContentL(aJadFileName)); |
591 TRAPD(err, jadContent = GetJadContentL(aJadFileName)); |
593 if (KErrNone != err) |
592 if (KErrNone != err) |
594 { |
593 { |
644 delete midletVersion; |
643 delete midletVersion; |
645 |
644 |
646 LOG3(EJavaPreinstaller, EInfo, |
645 LOG3(EJavaPreinstaller, EInfo, |
647 "CSilentMIDletInstall::ParseJadL MIDlet-Version is %d.%d.%d", |
646 "CSilentMIDletInstall::ParseJadL MIDlet-Version is %d.%d.%d", |
648 iMIDletVersion.iMajor, iMIDletVersion.iMinor, iMIDletVersion.iBuild); |
647 iMIDletVersion.iMajor, iMIDletVersion.iMinor, iMIDletVersion.iBuild); |
|
648 |
|
649 HBufC *midletUid = ParseAttribute(jadContent, KMidletUid); |
|
650 if (NULL == midletUid) |
|
651 { |
|
652 // Ok, all MIDlets do not predefine Symbian Uid |
|
653 iMIDletUid->Des().Zero(); |
|
654 } |
|
655 else |
|
656 { |
|
657 // store midlet Uid to member variable and log it |
|
658 TPtr uidPtr(iMIDletUid->Des()); |
|
659 uidPtr.Copy(*midletUid); |
|
660 LOG1WSTR(EJavaPreinstaller, EInfo, |
|
661 "CSilentMIDletInstall::ParseJadL Nokia-MIDlet-UID-1 %s", |
|
662 (wchar_t *)(uidPtr.PtrZ())); |
|
663 delete midletUid; |
|
664 } |
649 |
665 |
650 CleanupStack::PopAndDestroy(jadContent); |
666 CleanupStack::PopAndDestroy(jadContent); |
651 return ETrue; |
667 return ETrue; |
652 } |
668 } |
653 |
669 |
725 // Do not preinstall application if it is found from this table with state |
741 // Do not preinstall application if it is found from this table with state |
726 // NO_PREINSTALL. |
742 // NO_PREINSTALL. |
727 // Do not preinstall application if it is found from this table |
743 // Do not preinstall application if it is found from this table |
728 // and the version number of the application is the same or less |
744 // and the version number of the application is the same or less |
729 // than the version number in the table. |
745 // than the version number in the table. |
730 |
746 // If the application has been removed by javaupgradeupp or it has |
|
747 // not yet been installed, the application is not in the table at all. |
|
748 // Do not preinstall the application if there is a native application |
|
749 // with the same Uid as the predefined Uid of the first Java |
|
750 // application in the application suite. |
|
751 |
|
752 TBool apaSessionConnected(EFalse); |
|
753 RApaLsSession apaSession; |
731 JavaStorageEntry attribute; |
754 JavaStorageEntry attribute; |
732 JavaStorageApplicationEntry_t findPattern; |
755 JavaStorageApplicationEntry_t findPattern; |
733 JavaStorageApplicationList_t foundEntries; |
756 JavaStorageApplicationList_t foundEntries; |
734 |
757 |
735 for (TInt i = 0; i < iJadFiles.Count(); i++) |
758 for (TInt i = 0; i < iJadFiles.Count(); i++) |
736 { |
759 { |
737 if (ParseJadL(*iJadFiles[i])) |
760 if (ParseJadL(*iJadFiles[i])) |
738 { |
761 { |
776 |
799 |
777 if (installState == NO_PREINSTALL) |
800 if (installState == NO_PREINSTALL) |
778 { |
801 { |
779 // This application must not be preinstalled |
802 // This application must not be preinstalled |
780 LOG1WSTR(EJavaPreinstaller, EInfo, |
803 LOG1WSTR(EJavaPreinstaller, EInfo, |
781 "CheckWhichAppsShouldBeInstalledL: User has removed application %s " |
804 "CheckWhichAppsShouldBeInstalledL: User has removed application %s " |
782 "It must not be preinstalled again.", desToWstring(namePtr)); |
805 "It must not be preinstalled again.", desToWstring(namePtr)); |
783 } |
806 } |
784 else |
807 else |
785 { |
808 { |
786 // We like to know application VERSION |
809 // We like to know application VERSION |
787 attribute.setEntry(VERSION, L""); |
810 attribute.setEntry(VERSION, L""); |
815 } |
838 } |
816 } |
839 } |
817 else |
840 else |
818 { |
841 { |
819 skipInstall = EFalse; |
842 skipInstall = EFalse; |
|
843 |
820 LOG(EJavaPreinstaller, EInfo, |
844 LOG(EJavaPreinstaller, EInfo, |
821 "CheckWhichAppsShouldBeInstalledL: Application has not " |
845 "CheckWhichAppsShouldBeInstalledL: Application has not " |
822 "been installed previously"); |
846 "been installed previously"); |
|
847 |
|
848 // Check whether there is a native application installed |
|
849 // with the same Uid as the predefined Uid of the first |
|
850 // Java application in the suite. |
|
851 |
|
852 // The string value of attribute Nokia-MIDlet-UID-1 from |
|
853 // Jad file is in iMIDletUid if it was defined. |
|
854 TInt err = KErrNone; |
|
855 if (iMIDletUid->Length() > 0) |
|
856 { |
|
857 if (!apaSessionConnected) |
|
858 { |
|
859 err = apaSession.Connect(); |
|
860 apaSessionConnected = ETrue; |
|
861 } |
|
862 |
|
863 // If the presence of a possible native app cannot be |
|
864 // determined, let Java Installer try to install |
|
865 // the Java application |
|
866 if (KErrNone == err) |
|
867 { |
|
868 skipInstall = IsNativeAppPresent(apaSession); |
|
869 } |
|
870 } |
823 } |
871 } |
824 |
872 |
825 foundEntries.clear(); |
873 foundEntries.clear(); |
826 } |
874 } |
827 else |
875 else |
828 { |
876 { |
829 // If Jad parsing fails don't preinstall this |
877 // If Jad parsing fails don't preinstall this |
830 skipInstall = ETrue; |
878 skipInstall = ETrue; |
831 TPtr16 ptrJadName = iJadFiles[i]->Des(); |
879 TPtr16 ptrJadName = iJadFiles[i]->Des(); |
832 ELOG1WSTR(EJavaPreinstaller, |
880 ELOG1WSTR(EJavaPreinstaller, |
833 "CheckWhichAppsShouldBeInstalledL: Parsing JAD %s failed", |
881 "CheckWhichAppsShouldBeInstalledL: Parsing JAD %s failed", |
834 desToWstring(ptrJadName)); |
882 desToWstring(ptrJadName)); |
835 } |
883 } |
836 |
884 |
837 if (skipInstall) |
885 if (skipInstall) |
838 { |
886 { |
839 delete iJadFiles[i]; |
887 delete iJadFiles[i]; |
1163 "DesToAppVersion suspicious midlet version, end has extra non number characters"); |
1216 "DesToAppVersion suspicious midlet version, end has extra non number characters"); |
1164 } |
1217 } |
1165 |
1218 |
1166 return midletVersion; |
1219 return midletVersion; |
1167 } // DesToAppVersion |
1220 } // DesToAppVersion |
|
1221 |
|
1222 |
|
1223 /** |
|
1224 * Parses the Uid in iMIDletUid and returns ETrue if there is a native |
|
1225 * application with the same Uid installed into the device. |
|
1226 * Returns EFalse in case of any error. |
|
1227 * |
|
1228 * @param[in] aApaSession open AppArc session |
|
1229 * @return EFalse if no native application with Uid in iMIDletUid |
|
1230 */ |
|
1231 TBool CSilentMIDletInstall::IsNativeAppPresent(const RApaLsSession& aApaSession) |
|
1232 { |
|
1233 std::wstring uidValue((wchar_t *)(iMIDletUid->Ptr()), iMIDletUid->Length()); |
|
1234 TUid appUid; |
|
1235 Uid javaUid(uidValue); |
|
1236 TInt err = uidToTUid(javaUid, appUid); |
|
1237 |
|
1238 if (KErrNone != err) |
|
1239 { |
|
1240 WLOG1(EJavaPreinstaller, |
|
1241 "CSilentMIDletInstall::IsNativeAppPresent: Cannot convert %S to TUid", |
|
1242 uidValue.c_str()); |
|
1243 return EFalse; |
|
1244 } |
|
1245 |
|
1246 TUid appTypeUid; |
|
1247 err = aApaSession.GetAppType(appTypeUid, appUid); |
|
1248 if (KErrNone != err) |
|
1249 { |
|
1250 if (KErrNotFound == err) |
|
1251 { |
|
1252 // No such application in device |
|
1253 return EFalse; |
|
1254 } |
|
1255 |
|
1256 // Cannot check presence from AppArc |
|
1257 ELOG1(EJavaPreinstaller, |
|
1258 "CSilentMIDletInstall::IsNativeAppPresent: RApaLsSession GetAppType error %d", err); |
|
1259 return EFalse; |
|
1260 } |
|
1261 |
|
1262 if (appTypeUid.iUid != KMidletApplicationTypeUid) |
|
1263 { |
|
1264 // The application is present and it is not a MIDlet |
|
1265 return ETrue; |
|
1266 } |
|
1267 |
|
1268 return EFalse; |
|
1269 } // IsNativeAppPresent |
|
1270 |