Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RecordStore getSizeAvailable() - bug on Sanyo

 
Pavlin Mihalev
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
As the topic says, I have encountered a strange behavior of the RMS on Sanyo phones. I have a program that works on almost every current j2me enabled phone ( well, except some other bugs ), but on Sanyo RecordStore.getSizeAvailable() doesn't return the actual free memory reported from the phone. Yes, there is free memory and this is repeatable bug. I found that adding the optional tag "MIDlet-Data-size" in the jad is kind of work-arround, but yet the behavior varies from model to model in unpredictable way.
Any ideas ?
Thanks,
Pavlin
 
Theodore Casser
Ranch Hand
Posts: 1902
Hibernate Netbeans IDE PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Mind you, I'm still a newbie to J2ME. So take this with a grain of salt.)
Why not query the device, determine the model, and then build conditional logic based on that? It would make sense that if you know that only certain devices have a problem with code, you could write methods to deal with the variations, which would allow for easier maintainance down the road (and additions of additional units that have difficulties at that spot).
 
Pavlin Mihalev
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thank you for your suggestion. But Java is not supposed to be device specific right ? What will happen If I make a patch for the bugs in each implementation ? Around hundred versions of the same program ...
Another problem on the Sanyo phones is that a system API calls returns the available memory in kBytes, not in bytes as per specification...and that may be misleading the program.
Take care,
Pavlin
 
Theodore Casser
Ranch Hand
Posts: 1902
Hibernate Netbeans IDE PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pavlin Mihalev:
Thank you for your suggestion. But Java is not supposed to be device specific right ? What will happen If I make a patch for the bugs in each implementation ? Around hundred versions of the same program ...

I should clarify. You only need one application.
You could set up a conditional in it once you query what kind of device it is. You should be able to get it using

Using comparison methods on the returned string, you would have your methods call different branches. (Some devices don't handle this properly, though - some return different strings - see this thread for more details.)
Each time you find another implementation that has a 'difficulty' with a section, you could then use conditional logic to avoid the potential pitfall.
Another problem on the Sanyo phones is that a system API calls returns the available memory in kBytes, not in bytes as per specification...and that may be misleading the program.

This could be a good example of what I'm talking about above. So you know that Sanyo phones return KB instead of bytes. You could write logic, once you've made the call to determine what device it is, to have it do the conversion down to bytes of memory free, and then use that number. Non-Sanyo devices would simply get the number without doing any computations and use the number returned.
BUT, say you determine six months from now that ModelX phones return the available memory in MB. Same thing works - you just build another conditional branch in your logic to have it convert the returned available memory into bytes, but only if it's a ModelX phone - not a Sanyo or any other.
Just easier than maintaining differing versions for each device.
[ July 24, 2003: Message edited by: Theodore Casser ]
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What will happen If I make a patch for the bugs in each implementation ? Around hundred versions of the same program ...

Not necessarily. Assuming that this kind of bugs are an exception and not the rule, I think you'll manage just fine using factory patterns wherever you need device specific stuff and just extend/override the default implementation for, e.g. figuring out how much memory is available. Then again, I don't know what kind of problems to expect as I haven't had much problems (I've used only a couple of Nokia phones, one iPaq and one Palm; and my apps didn't require much information about the device, except for screen size as I wrote my own canvases).
 
Pavlin Mihalev
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for responding,
Theodore, seeing that the program is running on Sanyo doesn't respond to the question how much space it could use.
Lasse, is there Sanyo API/documentation published ? On nokia 3650 RMS can't do setRecord() properly ... It's similar to Motorola's bug described by microjava.com
Cheers,
Pavlin
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Pavlin, I don't know anything about Sanyo phones as they're somewhat exotic in Finland where I live (guess who's the market leader...).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic