15 * auto start Java applications after they have been installed |
15 * auto start Java applications after they have been installed |
16 * and when the device boots. |
16 * and when the device boots. |
17 * |
17 * |
18 */ |
18 */ |
19 |
19 |
|
20 #include <apgcli.h> // for RApaLsSession |
20 #include <e32base.h> |
21 #include <e32base.h> |
21 #include <f32file.h> |
22 #include <f32file.h> |
22 #include <javastorage.h> |
23 #include <javastorage.h> |
23 #include <javastorageentry.h> |
24 #include <javastorageentry.h> |
24 #include <javastoragenames.h> |
25 #include <javastoragenames.h> |
26 |
27 |
27 #include "commsendpoint.h" |
28 #include "commsendpoint.h" |
28 #include "coreinterface.h" |
29 #include "coreinterface.h" |
29 #include "javaprocessconstants.h" |
30 #include "javaprocessconstants.h" |
30 #include "javasymbianoslayer.h" |
31 #include "javasymbianoslayer.h" |
|
32 #include "javauid.h" |
31 #include "javauids.h" |
33 #include "javauids.h" |
32 #include "logger.h" |
34 #include "logger.h" |
33 #include "preinstallerstartermessages.h" |
35 #include "preinstallerstartermessages.h" |
34 #include "rtcinterface.h" |
36 #include "rtcinterface.h" |
35 #include "rtcmessages.h" |
37 #include "rtcmessages.h" |
121 if (KErrNone != err) |
123 if (KErrNone != err) |
122 { |
124 { |
123 ELOG1(EJavaCaptain, "AutoStarter::checkMIDletsToBeStartedL: leaved (%d)", err); |
125 ELOG1(EJavaCaptain, "AutoStarter::checkMIDletsToBeStartedL: leaved (%d)", err); |
124 } |
126 } |
125 } |
127 } |
126 /* |
|
127 else if ( MESSAGE TELLS THAT NEW MIDLET HAS BEEN INSTALLED ) |
|
128 { |
|
129 // Auto-start the new MIDlet if it is auto-start MIDlet |
|
130 } |
|
131 */ |
|
132 |
|
133 } |
128 } |
134 |
129 |
135 /** |
130 /** |
136 * |
131 * |
137 * |
132 * |
138 */ |
133 */ |
139 void AutoStarter::checkMIDletsToBeStartedL() |
134 void AutoStarter::checkMIDletsToBeStartedL() |
140 { |
135 { |
141 |
|
142 |
|
143 // Find all MIDlets with Nokia-MIDlet-auto-start |
136 // Find all MIDlets with Nokia-MIDlet-auto-start |
144 // APPLICATION_TABLE, if (AUTORUN == AUTOSTART_TRUE) || (AUTORUN == AUTOSTART_ONCE), |
137 // APPLICATION_TABLE, if (AUTORUN == AUTOSTART_TRUE) || (AUTORUN == AUTOSTART_ONCE), |
145 // call startMIDletL(ID) |
138 // call startMIDletL(ID) |
146 |
139 |
147 LOG(EJavaCaptain, EInfo, "AutoStarter::checkMIDletsToBeStartedL called"); |
140 LOG(EJavaCaptain, EInfo, "AutoStarter::checkMIDletsToBeStartedL called"); |
148 |
141 |
149 std::auto_ptr<JavaStorage> js(JavaStorage::createInstance()); |
142 std::auto_ptr<JavaStorage> js(JavaStorage::createInstance()); |
150 try |
143 try |
151 { |
144 { |
152 js->open(JAVA_DATABASE_NAME); |
145 js->open(JAVA_DATABASE_NAME); |
153 |
146 |
154 // In Java Storage there is 'APPLICATION_TABLE' table that contains |
147 // In Java Storage there is 'APPLICATION_TABLE' table that contains |
244 * |
237 * |
245 * @return true if launch succeeded, false is starting failed |
238 * @return true if launch succeeded, false is starting failed |
246 */ |
239 */ |
247 bool AutoStarter::startMIDletL(const std::wstring& aUid) |
240 bool AutoStarter::startMIDletL(const std::wstring& aUid) |
248 { |
241 { |
249 // start MIDlet |
242 // Try to check whether the MIDlet is present (or whether it has been |
|
243 // installed to a removable media that is not present now) |
|
244 if (!isMIDletPresent(aUid)) |
|
245 { |
|
246 return false; |
|
247 } |
|
248 |
|
249 // Start MIDlet |
250 rtcLaunchInfo launchInfo(aUid); |
250 rtcLaunchInfo launchInfo(aUid); |
251 |
251 |
252 bool launchSuccess = mCore->getRtc()->launch(launchInfo); |
252 bool launchSuccess = mCore->getRtc()->launch(launchInfo); |
253 if (!launchSuccess) |
253 if (!launchSuccess) |
254 { |
254 { |
257 |
257 |
258 return launchSuccess; |
258 return launchSuccess; |
259 } |
259 } |
260 |
260 |
261 |
261 |
|
262 /** |
|
263 * Try to check whether the MIDlet is present (or whether it has been |
|
264 * installed to a removable media that is not present now) |
|
265 * |
|
266 * @return false if it is certain that the MIDlet is not present, true otherwise |
|
267 */ |
|
268 bool AutoStarter::isMIDletPresent(const std::wstring& aUid) |
|
269 { |
|
270 RApaLsSession apaSession; |
|
271 TInt err = apaSession.Connect(); |
|
272 if (KErrNone != err) |
|
273 { |
|
274 // Cannot check presence from AppArc, try to start the MIDlet anyway |
|
275 ELOG1(EJavaCaptain, |
|
276 "AutoStarter::isMIDletPresent: RApaLsSession Connect error %d", err); |
|
277 return true; |
|
278 } |
|
279 CleanupClosePushL(apaSession); |
|
280 |
|
281 TUid appUid; |
|
282 Uid javaUid(aUid); |
|
283 err = uidToTUid(javaUid, appUid); |
|
284 if (KErrNone != err) |
|
285 { |
|
286 WLOG1(EJavaCaptain, |
|
287 "AutoStarter::isMIDletPresent: Cannot convert %S to TUid", aUid.c_str()); |
|
288 CleanupStack::PopAndDestroy(&apaSession); // apaSession |
|
289 return true; |
|
290 } |
|
291 |
|
292 TUid appTypeUid; |
|
293 err = apaSession.GetAppType(appTypeUid, appUid); |
|
294 if (KErrNone != err) |
|
295 { |
|
296 if (KErrNotFound == err) |
|
297 { |
|
298 // The application is not present |
|
299 WLOG1(EJavaCaptain, |
|
300 "AutoStarter::isMIDletPresent: trying to start MIDlet %S that is not present", |
|
301 aUid.c_str()); |
|
302 CleanupStack::PopAndDestroy(&apaSession); // apaSession |
|
303 return false; |
|
304 } |
|
305 |
|
306 // Cannot check presence from AppArc, try to start the MIDlet anyway |
|
307 ELOG1(EJavaCaptain, |
|
308 "AutoStarter::isMIDletPresent: RApaLsSession GetAppType error %d", err); |
|
309 CleanupStack::PopAndDestroy(&apaSession); // apaSession |
|
310 return true; |
|
311 } |
|
312 else if (appTypeUid.iUid != KMidletApplicationTypeUid) |
|
313 { |
|
314 // The application is present but it is NOT a MIDlet |
|
315 WLOG1(EJavaCaptain, |
|
316 "AutoStarter::isMIDletPresent: tried to start application %S that is not MIDlet", |
|
317 aUid.c_str()); |
|
318 CleanupStack::PopAndDestroy(&apaSession); // apaSession |
|
319 return false; |
|
320 } |
|
321 |
|
322 CleanupStack::PopAndDestroy(&apaSession); // apaSession |
|
323 return true; |
|
324 } |
|
325 |
|
326 |
262 } // namespace captain |
327 } // namespace captain |
263 } // namespace java |
328 } // namespace java |