31 using namespace java::util; |
31 using namespace java::util; |
32 |
32 |
33 |
33 |
34 _LIT_SECURE_ID(KJavaCaptainSecureID, KJavaCaptainUid); |
34 _LIT_SECURE_ID(KJavaCaptainSecureID, KJavaCaptainUid); |
35 |
35 |
36 // This file is used to indicate when converting old S60 midlets |
36 #ifdef RD_JAVA_S60_RELEASE_5_0_IAD |
37 // to OMJ midlets has been done. |
37 // This file is used to indicate when preinstallation has been done and |
38 _LIT(KConversionOngoing, "D:\\OMJConverting.dat"); |
38 // converting old S60 midlets to OMJ midlets can start. |
|
39 _LIT(KConversionOngoing, "D:\\OMJConverting.dat"); // codescanner::driveletters |
|
40 #endif |
39 |
41 |
40 |
42 |
41 /** |
43 /** |
42 * The PS keys can be created from this process because javapreinstaller |
44 * The PS keys can be created from this process because javapreinstaller |
43 * has the same Symbian secure ID as javainstaller and so javainstaller |
45 * has the same Symbian secure ID as javainstaller and so javainstaller |
44 * can later destroy the keys if necessary. |
46 * can later destroy the keys if necessary. |
45 */ |
47 */ |
46 static void CreateJavaInstallerPSKeys() |
48 static void createJavaInstallerPSKeys() |
47 { |
49 { |
48 LOG(EJavaPreinstaller, EInfo, |
50 LOG(EJavaPreinstaller, EInfo, |
49 "CreateJavaInstallerPSKeys: Going to create Java Installer PS keys"); |
51 "createJavaInstallerPSKeys: Going to create Java Installer PS keys"); |
50 |
52 |
51 // any process can read the values of the PS keys |
53 // any process can read the values of the PS keys |
52 _LIT_SECURITY_POLICY_PASS(KReadPolicy); |
54 _LIT_SECURITY_POLICY_PASS(KReadPolicy); |
53 // update allowed by processes with write system data capability |
55 // update allowed by processes with write system data capability |
54 _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData); |
56 _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData); |
59 { |
61 { |
60 err = KErrNone; // Ignore KErrAlreadyExists status. |
62 err = KErrNone; // Ignore KErrAlreadyExists status. |
61 } |
63 } |
62 if (err != KErrNone) |
64 if (err != KErrNone) |
63 { |
65 { |
64 ELOG1(EJavaPreinstaller, "CreateJavaInstallerPSKeys: " |
66 ELOG1(EJavaPreinstaller, "createJavaInstallerPSKeys: " |
65 "creating KPSUidJavaLatestInstallation failed with error %d", err); |
67 "creating KPSUidJavaLatestInstallation failed with error %d", err); |
66 } |
68 } |
67 |
69 |
68 err = RProperty::Define(KUidSystemCategory, KPSUidJavaLatestInstallationProgress, |
70 err = RProperty::Define(KUidSystemCategory, KPSUidJavaLatestInstallationProgress, |
69 RProperty::EInt, KReadPolicy, KWritePolicy); |
71 RProperty::EInt, KReadPolicy, KWritePolicy); |
71 { |
73 { |
72 err = KErrNone; // Ignore KErrAlreadyExists status. |
74 err = KErrNone; // Ignore KErrAlreadyExists status. |
73 } |
75 } |
74 if (err != KErrNone) |
76 if (err != KErrNone) |
75 { |
77 { |
76 ELOG1(EJavaPreinstaller, "CreateJavaInstallerPSKeys: " |
78 ELOG1(EJavaPreinstaller, "createJavaInstallerPSKeys: " |
77 "creating KPSUidJavaLatestInstallationProgress failed with error %d", err); |
79 "creating KPSUidJavaLatestInstallationProgress failed with error %d", err); |
78 } |
80 } |
79 |
81 |
80 err = RProperty::Define(KUidSystemCategory, KPSUidJavaLatestInstallationState, |
82 err = RProperty::Define(KUidSystemCategory, KPSUidJavaLatestInstallationState, |
81 RProperty::EInt, KReadPolicy, KWritePolicy); |
83 RProperty::EInt, KReadPolicy, KWritePolicy); |
95 * create active scheduler, |
97 * create active scheduler, |
96 * add CSilentMIDletInstall active object to it and start it |
98 * add CSilentMIDletInstall active object to it and start it |
97 */ |
99 */ |
98 static void startPreinstallationL() |
100 static void startPreinstallationL() |
99 { |
101 { |
100 JELOG2(EJavaPreinstaller); |
102 LOG(EJavaPreinstaller, EInfo, "startPreinstallationL called"); |
101 |
103 |
102 CActiveScheduler* as = new(ELeave) CActiveScheduler(); |
104 CActiveScheduler* as = new(ELeave) CActiveScheduler(); |
103 |
105 |
104 // Install active scheduler |
106 // Install active scheduler |
105 CActiveScheduler::Install(as); |
107 CActiveScheduler::Install(as); |
106 CleanupStack::PushL(as); |
108 CleanupStack::PushL(as); |
107 |
109 |
108 RFs fs; |
110 RFs fs; // codescanner::rfs |
109 User::LeaveIfError(fs.Connect()); |
111 User::LeaveIfError(fs.Connect()); |
110 CleanupClosePushL(fs); |
112 CleanupClosePushL(fs); |
111 |
113 |
112 // Setup the MIDlet preinstaller and add it to the active scheduler |
114 // Setup the MIDlet preinstaller and add it to the active scheduler |
113 CSilentMIDletInstall* si = CSilentMIDletInstall::NewLC(fs); |
115 CSilentMIDletInstall* si = CSilentMIDletInstall::NewLC(fs); |
121 LOG(EJavaPreinstaller, EInfo, "startPreinstallationL: Starting CActiveScheduler"); |
123 LOG(EJavaPreinstaller, EInfo, "startPreinstallationL: Starting CActiveScheduler"); |
122 CActiveScheduler::Start(); // codescanner::activestart |
124 CActiveScheduler::Start(); // codescanner::activestart |
123 |
125 |
124 // Now preinstallation has been done |
126 // Now preinstallation has been done |
125 LOG(EJavaPreinstaller, EInfo, "startPreinstallationL: Cleaning up"); |
127 LOG(EJavaPreinstaller, EInfo, "startPreinstallationL: Cleaning up"); |
|
128 #ifdef RD_JAVA_S60_RELEASE_5_0_IAD |
|
129 // Notify possibly waiting 'javaupdater.exe' process that preinstallation |
|
130 // has been done and that it can continue. |
126 TInt err = fs.Delete(KConversionOngoing); |
131 TInt err = fs.Delete(KConversionOngoing); |
127 LOG1(EJavaPreinstaller, |
132 LOG1(EJavaPreinstaller, |
128 EInfo, |
133 EInfo, |
129 "startPreinstallationL: Delete flag file returned status code %d", |
134 "startPreinstallationL: Delete flag file returned status code %d", |
130 err); |
135 err); |
|
136 #endif |
131 |
137 |
132 CleanupStack::PopAndDestroy(si); |
138 CleanupStack::PopAndDestroy(si); |
133 CleanupStack::PopAndDestroy(&fs); // close connection to file server |
139 CleanupStack::PopAndDestroy(&fs); // close connection to file server |
134 CleanupStack::PopAndDestroy(as); |
140 CleanupStack::PopAndDestroy(as); |
135 } |
141 } |
136 |
142 |
|
143 |
|
144 #ifdef RD_JAVA_S60_RELEASE_5_0_ROM |
|
145 /** |
|
146 * If 'javaafterflashconverter.exe' is running, wait until it exits |
|
147 * so that converter and preinstaller don't try to use Java Installer |
|
148 * simultaneously. |
|
149 */ |
|
150 static void waitUntilAfterFlashConverterExits() |
|
151 { |
|
152 LOG(EJavaPreinstaller, EInfo, "waitUntilAfterFlashConverterExits called"); |
|
153 |
|
154 TFullName processName; |
|
155 _LIT(KJavaAFConverterProcess, "javaafterflashconverter*"); |
|
156 TFindProcess finder(KJavaAFConverterProcess); |
|
157 |
|
158 if (finder.Next(processName) != KErrNotFound) |
|
159 { |
|
160 RProcess afConverterProcess; // codescanner::resourcenotoncleanupstack |
|
161 TInt err = afConverterProcess.Open(finder); |
|
162 |
|
163 if (KErrNone != err) |
|
164 { |
|
165 WLOG1(EJavaPreinstaller, |
|
166 "waitUntilAfterFlashConverterExits: Process open err: %d", err); |
|
167 } |
|
168 else |
|
169 { |
|
170 if (EExitPending == afConverterProcess.ExitType()) |
|
171 { |
|
172 // Converter is still running. Wait until it exits. |
|
173 LOG(EJavaPreinstaller, EInfo, |
|
174 "waitUntilAfterFlashConverterExits going to wait until converter exits"); |
|
175 TRequestStatus status; |
|
176 afConverterProcess.Logon(status); |
|
177 User::WaitForRequest(status); // codescanner::userWaitForRequest |
|
178 } |
|
179 |
|
180 afConverterProcess.Close(); |
|
181 } |
|
182 } |
|
183 } |
|
184 #endif |
|
185 |
|
186 |
137 /** |
187 /** |
138 * Allow starting process only from Java Captain. |
188 * Allow starting process only from Java Captain. |
139 * Execute actual preinstaller code in CSilentMIDletInstall. |
189 * Execute actual preinstaller code in CSilentMIDletInstall. |
140 */ |
190 */ |
|
191 #ifdef RD_JAVA_S60_RELEASE_5_0_ROM |
|
192 void preinstallerMainL(int argc, const char *argv[]) |
|
193 #else |
141 void preinstallerMainL() |
194 void preinstallerMainL() |
|
195 #endif |
142 { |
196 { |
143 // The only time that this application should be executed |
197 // The only time that this application should be executed |
144 // is when Java Captain calls it. |
198 // is when Java Captain calls it. |
145 if (User::CreatorSecureId() != KJavaCaptainSecureID) |
199 if (User::CreatorSecureId() != KJavaCaptainSecureID) |
146 { |
200 { |
150 } |
204 } |
151 |
205 |
152 // Create the PS keys that Java Installer will update already now |
206 // Create the PS keys that Java Installer will update already now |
153 // so that other processes starting during device boot can start |
207 // so that other processes starting during device boot can start |
154 // immediately listening to the keys. |
208 // immediately listening to the keys. |
155 CreateJavaInstallerPSKeys(); |
209 createJavaInstallerPSKeys(); |
|
210 |
|
211 #ifdef RD_JAVA_S60_RELEASE_5_0_ROM |
|
212 if (argc > 1) |
|
213 { |
|
214 // The max size of a preinstaller command line parameter is 80 |
|
215 TBufC8<80> param((const TUint8 *)(argv[1])); // codescanner::accessArrayElementWithoutCheck2 |
|
216 if (param == _L8("waitafconversion")) |
|
217 { |
|
218 waitUntilAfterFlashConverterExits(); |
|
219 } |
|
220 } |
|
221 #endif |
156 |
222 |
157 startPreinstallationL(); |
223 startPreinstallationL(); |
158 } |
224 } |
159 |
225 |
160 /** |
226 /** |
161 * Using this kind of dllMain() allows starting preinstaller from |
227 * Using this kind of dllMain() allows starting preinstaller from |
162 * the same starter process as installer and runtime (so that they have the same |
228 * the same starter process as installer and runtime (so that they have the same |
163 * Symbian secure Uid and can access the same data cage). |
229 * Symbian secure Uid and can access the same data cage). |
164 */ |
230 */ |
165 int dllMain(int /*argc*/, char */*argv*/[]) |
231 #ifdef RD_JAVA_S60_RELEASE_5_0_ROM |
166 { |
232 int dllMain(int argc, const char *argv[]) |
167 JELOG(EJavaPreinstaller, "PREINSTALLER main()"); |
233 #else |
|
234 int dllMain(int /* argc */, const char */*argv*/[]) |
|
235 #endif |
|
236 { |
168 JavaOsLayer::startUpTrace("PREINSTALLER main() start", -1, -1); |
237 JavaOsLayer::startUpTrace("PREINSTALLER main() start", -1, -1); |
169 |
238 |
170 User::RenameProcess(_L("javapreinstaller")); |
239 User::RenameProcess(_L("javapreinstaller")); |
171 User::RenameThread(_L("JavaPreinstallerMainThread")); |
240 User::RenameThread(_L("JavaPreinstallerMainThread")); |
172 |
241 |
173 LOG(EJavaPreinstaller, EInfo, "dllMain: Renaming process and thread done"); |
242 LOG(EJavaPreinstaller, EInfo, "dllMain: Renaming process and thread done"); |
174 |
243 |
175 // Make sure that this thread has always cleanup stack |
244 // Make sure that this thread has always cleanup stack |
176 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
245 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
177 |
246 |
|
247 #ifdef RD_JAVA_S60_RELEASE_5_0_ROM |
|
248 TRAPD(err, preinstallerMainL(argc, argv)); |
|
249 #else |
178 TRAPD(err, preinstallerMainL()); |
250 TRAPD(err, preinstallerMainL()); |
|
251 #endif |
179 if (KErrNone != err) |
252 if (KErrNone != err) |
180 { |
253 { |
181 ELOG1(EJavaPreinstaller, "dllMain: preinstallerMainL leaved with error %d", err); |
254 ELOG1(EJavaPreinstaller, "dllMain: preinstallerMainL leaved with error %d", err); |
182 } |
255 } |
183 |
256 |