35 #include "mmceventprovidermessages.h" |
35 #include "mmceventprovidermessages.h" |
36 #include "preinstallerstartermessages.h" |
36 #include "preinstallerstartermessages.h" |
37 |
37 |
38 #include "preinstallerstarter.h" |
38 #include "preinstallerstarter.h" |
39 |
39 |
|
40 #ifdef RD_JAVA_S60_RELEASE_5_0_ROM |
|
41 // This file in Java Captain private data cage is used to indicate when |
|
42 // converting old S60 midlets to OMJ midlets has been done after |
|
43 // ROM upgrade flashing. |
|
44 _LIT(KAfterFlashConversionDone, "C:\\private\\200211dc\\afconversionsdone.dat"); // codescanner::driveletters |
|
45 |
|
46 _LIT(KAfterFlashConverterExe, "javaafterflashconverter.exe"); |
|
47 |
|
48 #endif |
|
49 |
|
50 _LIT(KIad, " iad"); |
|
51 _LIT(KWaitAFConversion , " waitafconversion"); |
|
52 |
40 /** |
53 /** |
41 * Return pointer to ExtensionPluginInterface implementation for this |
54 * Return pointer to ExtensionPluginInterface implementation for this |
42 * extension dll |
55 * extension dll |
43 */ |
56 */ |
44 java::captain::ExtensionPluginInterface* getExtensionPlugin() |
57 java::captain::ExtensionPluginInterface* getExtensionPlugin() |
45 { |
58 { |
46 return new java::captain::PreinstallerStarter(); |
59 return new java::captain::PreinstallerStarter(); |
47 } |
60 } |
48 |
61 |
49 namespace java |
62 namespace java // codescanner::namespace |
50 { |
63 { |
51 namespace captain |
64 namespace captain // codescanner::namespace |
52 { |
65 { |
53 |
66 |
54 using java::fileutils::driveInfo; |
67 using java::fileutils::driveInfo; |
55 using java::fileutils::DriveListenerInterface; |
68 using java::fileutils::DriveListenerInterface; |
56 |
69 |
124 // to device. |
137 // to device. |
125 |
138 |
126 // Preinstaller will be started with 'iad' command line option |
139 // Preinstaller will be started with 'iad' command line option |
127 // so that it knows that it has been started for the first |
140 // so that it knows that it has been started for the first |
128 // time after java 2.0 IAD installation. |
141 // time after java 2.0 IAD installation. |
129 startPreinstaller(ETrue); |
142 startPreinstaller(EIad); |
130 } |
143 } |
131 break; |
144 break; |
132 |
145 |
133 case FIRST_DEVICE_BOOT_C: |
146 case FIRST_DEVICE_BOOT_C: |
134 case NORMAL_BOOT_C: |
147 case NORMAL_BOOT_C: |
135 { |
148 { |
136 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
149 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
137 registerMidletApplicationTypeHandler(); |
150 registerMidletApplicationTypeHandler(); |
138 #endif |
151 #endif |
139 |
152 |
140 // Start preinstaller normally (without 'iad' option). |
153 TPreinstallerStartMode startMode = ENormal; |
141 startPreinstaller(EFalse); |
154 #ifdef RD_JAVA_S60_RELEASE_5_0_ROM |
|
155 if (startConverter()) |
|
156 { |
|
157 // Preinstaller must be started with 'waitconversion' command |
|
158 // line option so that it will wait until javaafterflashconverter.exe |
|
159 // has converted existing MIDlets. |
|
160 startMode = ERomUpgrade; |
|
161 } |
|
162 #endif |
|
163 |
|
164 // Start preinstaller |
|
165 startPreinstaller(startMode); |
142 } |
166 } |
143 break; |
167 break; |
144 |
168 |
145 default: |
169 default: |
146 { |
170 { |
179 * The name of the executable is javapreinstaller.exe |
203 * The name of the executable is javapreinstaller.exe |
180 * When it is started, it checks all preinstall directories in the device |
204 * When it is started, it checks all preinstall directories in the device |
181 * and preinstalls those java applications in the directories that have not |
205 * and preinstalls those java applications in the directories that have not |
182 * yet been installed. After that preinstaller exits. |
206 * yet been installed. After that preinstaller exits. |
183 * |
207 * |
184 * @param aIadBoot when true, starts preinstaller with 'iad' parameter |
208 * @param aStartMode when value is EIad, starts preinstaller with 'iad' parameter |
185 */ |
209 * when value is ERomUpgrade, starts preinstaller with 'waitconversion' parameter |
186 void PreinstallerStarter::startPreinstaller(TBool aIadBoot) |
210 * when value is ENormal, starts preinstaller with no parameters |
|
211 */ |
|
212 void PreinstallerStarter::startPreinstaller(TPreinstallerStartMode aStartMode) |
187 { |
213 { |
188 // Check that the device has enough free memory (800kB) to start preinstaller process |
214 // Check that the device has enough free memory (800kB) to start preinstaller process |
189 // and (if needed) also java installer |
215 // and (if needed) also java installer |
190 TInt freeMemory = 0; |
216 TInt freeMemory = 0; |
191 TInt err = HAL::Get(HALData::EMemoryRAMFree, freeMemory); |
217 TInt err = HAL::Get(HALData::EMemoryRAMFree, freeMemory); |
268 TBuf<128> commandLine; // Actual len of cmd line will be max 20 characters |
294 TBuf<128> commandLine; // Actual len of cmd line will be max 20 characters |
269 int len = strlen(java::runtime::JAVA_PREINSTALLER_STARTER_DLL); |
295 int len = strlen(java::runtime::JAVA_PREINSTALLER_STARTER_DLL); |
270 TPtr8 ptr8((TUint8 *)java::runtime::JAVA_PREINSTALLER_STARTER_DLL, len, len); |
296 TPtr8 ptr8((TUint8 *)java::runtime::JAVA_PREINSTALLER_STARTER_DLL, len, len); |
271 commandLine.Copy(ptr8); |
297 commandLine.Copy(ptr8); |
272 |
298 |
273 if (aIadBoot) |
299 if (aStartMode == EIad) |
274 { |
300 { |
275 commandLine.Append(_L(" iad")); |
301 commandLine.Append(KIad); |
|
302 } |
|
303 else if (aStartMode == ERomUpgrade) |
|
304 { |
|
305 commandLine.Append(KWaitAFConversion); |
276 } |
306 } |
277 |
307 |
278 // start preinstaller |
308 // start preinstaller |
279 mPreinstaller = new RProcess(); |
309 mPreinstaller = new RProcess(); // codescanner:: |
280 TBuf<64> preinstallerProcess; // Actual len of the process name is 9 |
310 TBuf<64> preinstallerProcess; // Actual len of the process name is 9 |
281 len = strlen(java::runtime::JAVA_PROCESS); |
311 len = strlen(java::runtime::JAVA_PROCESS); |
282 TPtr8 ptr8Process((TUint8 *)java::runtime::JAVA_PROCESS, len, len); |
312 TPtr8 ptr8Process((TUint8 *)java::runtime::JAVA_PROCESS, len, len); |
283 preinstallerProcess.Copy(ptr8Process); |
313 preinstallerProcess.Copy(ptr8Process); |
284 TInt err = mPreinstaller->Create(preinstallerProcess, commandLine); |
314 TInt err = mPreinstaller->Create(preinstallerProcess, commandLine); |
289 // This active object will be activated when preinstaller process exits |
319 // This active object will be activated when preinstaller process exits |
290 mPreinstaller->Logon(iStatus); |
320 mPreinstaller->Logon(iStatus); |
291 |
321 |
292 // Allow the process to run |
322 // Allow the process to run |
293 mPreinstaller->Resume(); |
323 mPreinstaller->Resume(); |
294 if (aIadBoot) |
324 if (aStartMode == EIad) |
295 { |
325 { |
296 LOG( |
326 LOG( |
297 EJavaCaptain, |
327 EJavaCaptain, |
298 EInfo, |
328 EInfo, |
299 "PreinstallerStarter: started preinstaller with iad parameter"); |
329 "PreinstallerStarter: started preinstaller with iad parameter"); |
|
330 } |
|
331 else if (aStartMode == ERomUpgrade) |
|
332 { |
|
333 LOG( |
|
334 EJavaCaptain, |
|
335 EInfo, |
|
336 "PreinstallerStarter: started preinstaller with waitconversion parameter"); |
300 } |
337 } |
301 else |
338 else |
302 { |
339 { |
303 LOG(EJavaCaptain, EInfo, "PreinstallerStarter: started preinstaller"); |
340 LOG(EJavaCaptain, EInfo, "PreinstallerStarter: started preinstaller"); |
304 } |
341 } |
413 delete mPreinstaller; |
450 delete mPreinstaller; |
414 mPreinstaller = 0; |
451 mPreinstaller = 0; |
415 } |
452 } |
416 } |
453 } |
417 |
454 |
|
455 #ifdef RD_JAVA_S60_RELEASE_5_0_ROM |
|
456 /** |
|
457 * Check whether there is flag file 'afconversionsdone.dat' in the private |
|
458 * data cage of Java Captain. |
|
459 * If the flag file exists, just return EFalse to indicate that Java Preinstaller |
|
460 * does not need to wait for after ROM flash converter. |
|
461 * Otherwise start 'javaafterflashconverter.exe' process and return ETrue |
|
462 * so that Java Preinstaller is started with command line parameter that |
|
463 * tells it to wait until 'javaafterflashconverter.exe' exits. |
|
464 */ |
|
465 TBool PreinstallerStarter::startConverter() |
|
466 { |
|
467 RFs fs; // codescanner::rfs |
|
468 TInt err = fs.Connect(); |
|
469 if (KErrNone != err) |
|
470 { |
|
471 ELOG1(EJavaCaptain, |
|
472 "PreinstallerStarter:startConverter: " |
|
473 "Cannot connect to RFs, err %d", |
|
474 err); |
|
475 // Assume that the conversion has been done |
|
476 return EFalse; |
|
477 } |
|
478 |
|
479 // Check whether the flag file exists |
|
480 TUint value; |
|
481 TBool flagFileExists(ETrue); |
|
482 err = fs.Att(KAfterFlashConversionDone, value); |
|
483 if ((KErrNotFound == err) || (KErrPathNotFound == err)) |
|
484 { |
|
485 flagFileExists = EFalse; |
|
486 } |
|
487 else if (KErrNone == err) |
|
488 { |
|
489 LOG(EJavaCaptain, |
|
490 EInfo, |
|
491 "PreinstallerStarter:startConverter: Flag file exists"); |
|
492 flagFileExists = ETrue; |
|
493 } |
|
494 else |
|
495 { |
|
496 WLOG1(EJavaCaptain, |
|
497 "PreinstallerStarter:startConverter: Checking flag file, unexpected error %d", |
|
498 err); |
|
499 // Assume that the conversion has been done |
|
500 flagFileExists = ETrue; |
|
501 } |
|
502 |
|
503 if (flagFileExists) |
|
504 { |
|
505 // Conversion has been done, no need to start converter process. |
|
506 return EFalse; |
|
507 } |
|
508 |
|
509 // Start 'javaafterflashconverter.exe' process |
|
510 RProcess converter; |
|
511 err = converter.Create(KAfterFlashConverterExe, KNullDesC); |
|
512 if (KErrNone == err) |
|
513 { |
|
514 converter.Resume(); |
|
515 LOG(EJavaCaptain, EInfo, |
|
516 "PreinstallerStarter:startConverter: javaafterflashconverter.exe was started ok"); |
|
517 } |
|
518 else |
|
519 { |
|
520 ELOG1(EJavaCaptain, |
|
521 "PreinstallerStarter:startConverter: starting javaafterflashconverter failed: %d", |
|
522 err); |
|
523 } |
|
524 converter.Close(); |
|
525 |
|
526 return ETrue; |
|
527 } |
|
528 #endif |
|
529 |
418 |
530 |
419 } // namespace captain |
531 } // namespace captain |
420 } // namespace java |
532 } // namespace java |