Symbian OS
read last symbian news on www.newlc.com read last symbian reviews on www.newlc.com
read last symbian tutorial on www.newlc.com read last symbian download on www.newlc.com
31 déc. 2006 - 16:19

It is sometimes useful to be able to detect whether an application is started at boot time by the Startup List API (present only in S60 3rd Edition) or by the user, and passing Symbian Signed - which is generally required to have an application which requires auto boot feature - makes this almost mandatory. This article will help you with this.

First, you have to modify the application registration file and add some opaque_data field in the APP_REGISTRATION_INFO resource. The content and value of these data does not really matter, you just need to specify something like below:

#include <appinfo.rh>
#include <uikon.rh>    

RESOURCE APP_REGISTRATION_INFO
{
  ...
  opaque_data = r_startup_detect;
}      

   
RESOURCE NUMBER_INT8 r_startup_detect
{
 value = 1;
}  

The opaque_data and other launch parameters will be ignored by the startup list when launching the application. Thus, detecting whether they are present or not allows to differentiate whether the application has been launched at boot time or by the user.

To do this, you shall override the ProcessCommandParametersL() function in your AppUI:

TBool CMyAppUi::ProcessCommandParametersL( CApaCommandLine &aCommandLine )
{
  if(aCommandLine.OpaqueData().Length() > 0)
  {
      // Opaque data exists, app. has been manually started from the menu
  }
  else
  {
      // App. has been auto-started -> exit if auto-start in settings is OFF
  }
   return CEikAppUi::ProcessCommandParametersL( aCommandLine );
}

you can also note that passing Symbian Signed requires that your application has a setting option that allow to disable the auto start feature. As no API is currently available to do this, you will need to have some code to handle this. Hopefully, this is very well explained in the Forum Nokia Technical Library (which this article is based on).

This article only applies to S60 3rd Edition and following versions which implements the Startup List API.
Tutorial posted décembre 31st, 2006 by eric

Soumis par Pawel (non vérifié) le mar, 2007-01-02 21:58.

Hello Eric,

It would be a lot more convenient to do this check already in AppUi ConstructL method, right after the call to BaseConstructL. So, I tried this:

CApaCommandLine* commandLine = NULL; TInt getCommandLineError = CApaCommandLine::GetCommandLineFromProcessEnvironment( commandLine ); User::LeaveIfError( getCommandLineError ); CleanupStack::PushL( commandLine ); MultiThreadedLogger::Log(commandLine->OpaqueData()); if(commandLine->OpaqueData().Length() > 0) // Opaque data exists, app. has been manually started from the menu else // App. has been auto-started -> exit if auto-start in settings is OFF CleanupStack::PopAndDestroy( commandLine ); commandLine = NULL;

But in this approach the OpaqueData field is always empty, so something modifies it after AppUi::ConstructL has been executed. Do you have any idea if this is the case? According to APPARC documentation, GetCommandLineFromProcessEnvironment should be usable at any time, even in a plain EXE.

Thanks, Pawel


Soumis par eric le mer, 2007-01-03 13:00.

AppUi::ConstructL is called before the AppUi::ProcessCommandParametersL and it is EIKENV which is responsible for this. There is not much done between the two and definitely nothing related with construction of the command line. So I do not see any reason why it shouldn't work in the AppUI::ConstructL ! (checked with a Symbian 8 devkit - so this might have changed in v9).

Soumis par Anonymous le jeu, 2007-02-01 14:27.

hi, I implemented this code but got a problem i.e; i have to press red button to end my splash screen and 've to launch application again..what i did? i checked if application is launching by user click then i started my splash screen which does not end. but if i start my splash screen from AppUi ConstructL, then it goes fine. but when i did like this in ProcessCommandParametersL; if(aCommandLine.OpaqueData().Length() > 0) iSplashActiveObject->StartNow(EFalse); else iSplashActiveObject->StartNow(ETrue); i cant move from splash..app.hangs.

Soumis par jabber (non vérifié) le mar, 2007-02-13 16:11.

Hello Eric,

This is very useful information, thanks.

But is it true that an app which autostarts needs to have an autostart-disable mechanism to be able to pass Symbian Signed? I've just read through the Symbian Signed Test Criteria and I didn't see this stipulation there.


Soumis par eric le mar, 2007-02-13 21:27.

If it is not stipulated, then the answer is probably no. We have just signed an application which uses this trick and which cannot be disabled at autostart (there is just no API to do this right now !).

Soumis par Anonymous le mer, 2007-02-14 21:10.

Good :-)

Anyway, my results agree with what Pawel says - I can't get his code using GetCommandLineFromProcessEnvironment in the AppUi's ConstructL to work (although the same code worked fine in a console app and detected the presence or not of the opaque data) but your code in ProcessCommandParametersL works OK.

I've tried this on S60 3rd SDK and on an N73 with the same results.

I'm puzzled by this - must confess I don't really understand the data flow here - where does GetCommandLineFromProcessEnvironment fish the data up from - could be from RProcess but I don't see any opaque data associated with an RProcess???

Anyway, Eric's solution is working well for me now, thanks.


Soumis par MrTJ le ven, 2008-08-08 12:02.

Hi, can you do the same thing for EXEs withoug a GUI? I do not know how to access the opaque data without AppUi and in turn I do not know how to set command line parameters from app registration resource that could be read with User::CommandLine() for example. Thanks, J.



copyright 2003-2009 NewLC SARL