1 /* |
1 /* |
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008 - 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
29 #include "javauids.h" |
31 #include "javauids.h" |
30 #include "logger.h" |
32 #include "logger.h" |
31 #include "coreinterface.h" |
33 #include "coreinterface.h" |
32 #include "booteventprovidermessages.h" |
34 #include "booteventprovidermessages.h" |
33 #include "mmceventprovidermessages.h" |
35 #include "mmceventprovidermessages.h" |
|
36 #include "preinstallerstartermessages.h" |
34 |
37 |
35 #include "preinstallerstarter.h" |
38 #include "preinstallerstarter.h" |
36 |
39 |
37 /** |
40 /** |
38 * Return pointer to ExtensionPluginInterface implementation for this |
41 * Return pointer to ExtensionPluginInterface implementation for this |
50 |
53 |
51 using java::fileutils::driveInfo; |
54 using java::fileutils::driveInfo; |
52 using java::fileutils::DriveListenerInterface; |
55 using java::fileutils::DriveListenerInterface; |
53 |
56 |
54 /** |
57 /** |
55 * Empty contructor |
58 * Initialize member varaibles in constructor |
56 */ |
59 */ |
57 PreinstallerStarter::PreinstallerStarter() : mCore(0) |
60 PreinstallerStarter::PreinstallerStarter() : |
58 { |
61 CActive(EPriorityStandard), mCore(0), mPreinstaller(0) |
59 JELOG2(EJavaCaptain); |
62 { |
60 } |
63 } |
61 |
64 |
62 /** |
65 /** |
63 * Empty destructor |
66 * Destructor |
64 */ |
67 */ |
65 PreinstallerStarter::~PreinstallerStarter() |
68 PreinstallerStarter::~PreinstallerStarter() |
66 { |
69 { |
67 JELOG2(EJavaCaptain); |
70 DoCancel(); |
68 } |
71 } |
69 |
72 |
70 /** |
73 /** |
71 * Implement PluginInterface method |
74 * Implement PluginInterface method |
72 */ |
75 */ |
73 void PreinstallerStarter::startPlugin(CoreInterface* core) |
76 void PreinstallerStarter::startPlugin(CoreInterface* core) |
74 { |
77 { |
75 JELOG2(EJavaCaptain); |
|
76 mCore = core; |
78 mCore = core; |
|
79 CActiveScheduler::Add(this); |
77 } |
80 } |
78 |
81 |
79 /** |
82 /** |
80 * Implement PluginInterface method |
83 * Implement PluginInterface method |
81 */ |
84 */ |
82 void PreinstallerStarter::stopPlugin() |
85 void PreinstallerStarter::stopPlugin() |
83 { |
86 { |
84 JELOG2(EJavaCaptain); |
|
85 mCore = 0; |
87 mCore = 0; |
86 } |
88 } |
87 |
89 |
88 /** |
90 /** |
89 * Implement ExtensionPluginInterface method |
91 * Implement ExtensionPluginInterface method |
90 */ |
92 */ |
91 EventConsumerInterface* PreinstallerStarter::getEventConsumer() |
93 EventConsumerInterface* PreinstallerStarter::getEventConsumer() |
92 { |
94 { |
93 JELOG2(EJavaCaptain); |
|
94 return this; |
95 return this; |
95 } |
96 } |
96 |
97 |
97 /** |
98 /** |
98 * Handle Java Captain events sent by Boot event provider or |
99 * Handle Java Captain events sent by Boot event provider or |
104 * Implement EventConsumerInterface method |
105 * Implement EventConsumerInterface method |
105 */ |
106 */ |
106 void PreinstallerStarter::event(const std::string& eventProvider, |
107 void PreinstallerStarter::event(const std::string& eventProvider, |
107 java::comms::CommsMessage& aMsg) |
108 java::comms::CommsMessage& aMsg) |
108 { |
109 { |
109 JELOG2(EJavaCaptain); |
|
110 if (eventProvider == BOOT_EVENT_PROVIDER) |
110 if (eventProvider == BOOT_EVENT_PROVIDER) |
111 { |
111 { |
112 int bootType = NORMAL_BOOT_C; |
112 int bootType = NORMAL_BOOT_C; |
113 getBootMessageParams(aMsg, bootType); |
113 getBootMessageParams(aMsg, bootType); |
114 LOG1( |
114 LOG1( |
181 * |
183 * |
182 * @param aIadBoot when true, starts preinstaller with 'iad' parameter |
184 * @param aIadBoot when true, starts preinstaller with 'iad' parameter |
183 */ |
185 */ |
184 void PreinstallerStarter::startPreinstaller(TBool aIadBoot) |
186 void PreinstallerStarter::startPreinstaller(TBool aIadBoot) |
185 { |
187 { |
186 JELOG2(EJavaCaptain); |
|
187 |
|
188 // Check that the device has enough free memory (800kB) to start preinstaller process |
188 // Check that the device has enough free memory (800kB) to start preinstaller process |
189 // and (if needed) also java installer |
189 // and (if needed) also java installer |
190 TInt freeMemory = 0; |
190 TInt freeMemory = 0; |
191 TInt err = HAL::Get(HALData::EMemoryRAMFree, freeMemory); |
191 TInt err = HAL::Get(HALData::EMemoryRAMFree, freeMemory); |
192 if (KErrNone == err) |
192 if (KErrNone == err) |
274 { |
274 { |
275 commandLine.Append(_L(" iad")); |
275 commandLine.Append(_L(" iad")); |
276 } |
276 } |
277 |
277 |
278 // start preinstaller |
278 // start preinstaller |
279 RProcess preinstaller; |
279 mPreinstaller = new RProcess(); |
280 TBuf<64> preinstallerProcess; // Actual len of the process name is 9 |
280 TBuf<64> preinstallerProcess; // Actual len of the process name is 9 |
281 len = strlen(java::runtime::JAVA_PROCESS); |
281 len = strlen(java::runtime::JAVA_PROCESS); |
282 TPtr8 ptr8Process((TUint8 *)java::runtime::JAVA_PROCESS, len, len); |
282 TPtr8 ptr8Process((TUint8 *)java::runtime::JAVA_PROCESS, len, len); |
283 preinstallerProcess.Copy(ptr8Process); |
283 preinstallerProcess.Copy(ptr8Process); |
284 TInt err = preinstaller.Create(preinstallerProcess, commandLine); |
284 TInt err = mPreinstaller->Create(preinstallerProcess, commandLine); |
285 if (KErrNone == err) |
285 if (KErrNone == err) |
286 { |
286 { |
287 // process has been created, allow it to run |
287 // Process has been created. |
288 preinstaller.Resume(); |
288 |
289 preinstaller.Close(); |
289 // This active object will be activated when preinstaller process exits |
|
290 mPreinstaller->Logon(iStatus); |
|
291 |
|
292 // Allow the process to run |
|
293 mPreinstaller->Resume(); |
290 if (aIadBoot) |
294 if (aIadBoot) |
291 { |
295 { |
292 LOG( |
296 LOG( |
293 EJavaCaptain, |
297 EJavaCaptain, |
294 EInfo, |
298 EInfo, |
311 |
320 |
312 /** |
321 /** |
313 * Register 'javalauncher.exe' as the midlet application type handler |
322 * Register 'javalauncher.exe' as the midlet application type handler |
314 * in AppArc. If necessary unregister old handler first. |
323 * in AppArc. If necessary unregister old handler first. |
315 */ |
324 */ |
|
325 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
316 void PreinstallerStarter::registerMidletApplicationTypeHandler() |
326 void PreinstallerStarter::registerMidletApplicationTypeHandler() |
317 { |
327 { |
318 _LIT(KMidpAppArcPlugin, "javalauncher.exe"); |
328 _LIT(KMidpAppArcPlugin, "javalauncher.exe"); |
319 |
329 |
320 RApaLsSession appLstSession; |
330 RApaLsSession appLstSession; |
372 "PreinstallerStarter: registerMidletApplicationTypeHandler: " |
382 "PreinstallerStarter: registerMidletApplicationTypeHandler: " |
373 "Connecting to AppArc failed with error %d", |
383 "Connecting to AppArc failed with error %d", |
374 err); |
384 err); |
375 } |
385 } |
376 } |
386 } |
|
387 #endif |
|
388 |
|
389 void PreinstallerStarter::RunL() |
|
390 { |
|
391 LOG(EJavaCaptain, EInfo, "PreinstallerStarter::RunL started"); |
|
392 |
|
393 // Send event to AutoStarter plugin, done only once |
|
394 CommsMessage eventMsg; |
|
395 setPreinstallerExitedMessageParams(eventMsg, iStatus.Int()); |
|
396 mCore->getEventDispatcher()->event(PREINSTALLER_EVENT_PROVIDER, eventMsg); |
|
397 |
|
398 // process handle is no longer needed |
|
399 mPreinstaller->Close(); |
|
400 delete mPreinstaller; |
|
401 mPreinstaller = 0; |
|
402 } |
|
403 |
|
404 |
|
405 void PreinstallerStarter::DoCancel() |
|
406 { |
|
407 if (mPreinstaller) |
|
408 { |
|
409 mPreinstaller->LogonCancel(iStatus); |
|
410 // Because exit notification request has been canceled, |
|
411 // there is no reason to keep the process handle open. |
|
412 mPreinstaller->Close(); |
|
413 delete mPreinstaller; |
|
414 mPreinstaller = 0; |
|
415 } |
|
416 } |
|
417 |
377 |
418 |
378 } // namespace captain |
419 } // namespace captain |
379 } // namespace java |
420 } // namespace java |