Fails first time, works second time | developer.brewmp.com Fails first time, works second time | developer.brewmp.com

Developer

Fails first time, works second time

Forums:

I have an app here that is behaving very strangely. We changed the class ID recently and now whenever the device is turned on and we try to run the app it crashes with "Unknown Error (1)" which is a class Id problem as I understand it. This is on a tsohiba 9500 with GetItNow. If you then try to start it again it works perfectly. However if I power cycle the device I have to go through the whole process again. I am new to Brew and am appealing to you here to try to figure out what could be being changed by the first attempt at loading the program and is reset when when the power is cycled. So far I have found this refrence in the online documentation:
Quote:Number of Uses License is reset when phone is power-cycled
Applicable Releases: 1.0
License information is stored in the MIF file. When an app calls ILICENSE_SetUsesRemaining(), ILICENSE_DecrementUsesRemaining or ILICENSE_IncrementUsesRemaining(), BREW attempts to update the MIF file. Due to a bug in BREW SDK version 1.0.1, the app must have File Privilege level in order for the MIF file update to succeed. The work-around for SDK 1.0.1, therefore, is to include File Privilege level (via the MIF editor). This has been fixed in SDK version 1.1, i.e., usage-based apps do not need to have File Privilege level in 1.1.
http://www.qualcomm.com/brew/developer/resources/ds/faq/techfaq14.html#T1C
What other variables do you guys think could be getting changed and reset that might be affecting this program?
Thanks
Sam

Its eight months too late, but I just had this issue pop up last, and figured out why it was happening for me.
In my case, my programe uses the M7 Networks High Score extension to do internet high score keeping. My problem was simply that the M7 extension's sig was incorrect. After I fixed the extension's sig, my program loading correctly every time from then on. So, perhaps you've got an external dependency in your MIF that can't be found?

Its eight months too late, but I just had this issue pop up last, and figured out why it was happening for me.
In my case, my programe uses the M7 Networks High Score extension to do internet high score keeping. My problem was simply that the M7 extension's sig was incorrect. After I fixed the extension's sig, my program loading correctly every time from then on. So, perhaps you've got an external dependency in your MIF that can't be found?

Quote:Originally posted by shendley
We changed the class ID recently and now whenever the device is turned on and we try to run the app it crashes with "Unknown Error (1)" which is a class Id problem as I understand it.This behavior of failing the first time but works afterward is odd. You may have multiple problems, but I suggest that you work on the ClassId bug first.
You will find it in AEEClsCreateInstance. Here is a (slightly modified) routine from the HelloWorld example:
int AEEClsCreateInstance(AEECLSID ClsId, IShell* pIShell, IModule* pIModule,                    void** ppApplet){   *ppObj = NULL;
   if(ClsId == AEECLSID_HELLOWORLD){      if(AEEApplet_New(sizeof(HelloWorldApp), ClsId, pIShell, pIModule,         (IApplet**)ppApplet,         (AEEHANDLER)HelloWorld_HandleEvent,         (PFNFREEAPPDATA)HelloWorld_Exit)         == TRUE)      {         HelloWorld_Init( (HelloWorldApp*)(*ppApplet) );         return (AEE_SUCCESS);      }   }   return (EFAILED);}
The reason you see "Unknown Error (1)" is because it is returning EFAILED, which is defined in AEEError.h.
If your code is similar, you'll return EFAILED in one of two cases:
1) the class id in your MIF does not match your AEECLSID_APP constant,
2) AEEApplet_New returns FALSE, due to insufficient memory, failure to instantiate IDisplay, or the pIShell or pIModule pointer was NULL. You can look at AEEApplet_New in AEEAppGen.c to see this.
You can figure out which of these problems is occuring by using the error codes shown in red:int AEEClsCreateInstance(AEECLSID ClsId, IShell* pIShell, IModule* pIModule,
void** ppApplet)
{
*ppObj = NULL;
if(ClsId == AEECLSID_HELLOWORLD){
if(AEEApplet_New(sizeof(HelloWorldApp), ClsId, pIShell, pIModule,
(IApplet**)ppApplet,
(AEEHANDLER)HelloWorld_HandleEvent,
(PFNFREEAPPDATA)HelloWorld_Exit)
== TRUE)
{
if (HelloWorld_Init( (HelloWorldApp*)(*ppApplet) ))
{
return (AEE_SUCCESS);
}
return (EFAILED); //HelloWorld_Init failed = 1
}
return (ENOMEMORY); //AEEApplet_New failed = 2
}
return (ECLASSNOTSUPPORT); //bad ClsId = 3
Now the error codes are unique for the different failure cases and it's easier to debug. Don't forget that if you derived your own Applet structure (HelloWorldApp) from AEEApplet, you must pass "sizeof(HelloWorldApp)" to AEEApplet_New.
--t

Quote:Originally posted by shendley
We changed the class ID recently and now whenever the device is turned on and we try to run the app it crashes with "Unknown Error (1)" which is a class Id problem as I understand it.This behavior of failing the first time but works afterward is odd. You may have multiple problems, but I suggest that you work on the ClassId bug first.
You will find it in AEEClsCreateInstance. Here is a (slightly modified) routine from the HelloWorld example:
int AEEClsCreateInstance(AEECLSID ClsId, IShell* pIShell, IModule* pIModule,                    void** ppApplet){   *ppObj = NULL;
   if(ClsId == AEECLSID_HELLOWORLD){      if(AEEApplet_New(sizeof(HelloWorldApp), ClsId, pIShell, pIModule,         (IApplet**)ppApplet,         (AEEHANDLER)HelloWorld_HandleEvent,         (PFNFREEAPPDATA)HelloWorld_Exit)         == TRUE)      {         HelloWorld_Init( (HelloWorldApp*)(*ppApplet) );         return (AEE_SUCCESS);      }   }   return (EFAILED);}
The reason you see "Unknown Error (1)" is because it is returning EFAILED, which is defined in AEEError.h.
If your code is similar, you'll return EFAILED in one of two cases:
1) the class id in your MIF does not match your AEECLSID_APP constant,
2) AEEApplet_New returns FALSE, due to insufficient memory, failure to instantiate IDisplay, or the pIShell or pIModule pointer was NULL. You can look at AEEApplet_New in AEEAppGen.c to see this.
You can figure out which of these problems is occuring by using the error codes shown in red:int AEEClsCreateInstance(AEECLSID ClsId, IShell* pIShell, IModule* pIModule,
void** ppApplet)
{
*ppObj = NULL;
if(ClsId == AEECLSID_HELLOWORLD){
if(AEEApplet_New(sizeof(HelloWorldApp), ClsId, pIShell, pIModule,
(IApplet**)ppApplet,
(AEEHANDLER)HelloWorld_HandleEvent,
(PFNFREEAPPDATA)HelloWorld_Exit)
== TRUE)
{
if (HelloWorld_Init( (HelloWorldApp*)(*ppApplet) ))
{
return (AEE_SUCCESS);
}
return (EFAILED); //HelloWorld_Init failed = 1
}
return (ENOMEMORY); //AEEApplet_New failed = 2
}
return (ECLASSNOTSUPPORT); //bad ClsId = 3
Now the error codes are unique for the different failure cases and it's easier to debug. Don't forget that if you derived your own Applet structure (HelloWorldApp) from AEEApplet, you must pass "sizeof(HelloWorldApp)" to AEEApplet_New.
--t

Oh geez, I just noticed that the original post is from last June. Never mind.

Oh geez, I just noticed that the original post is from last June. Never mind.

Yeah, but it never hurts to have an answer, right? Who knows who else will have this problem. You've done a good deed, and a detailed one to boot!

Yeah, but it never hurts to have an answer, right? Who knows who else will have this problem. You've done a good deed, and a detailed one to boot!