Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 12-13-2011, 08:00 PM   #1
LittleLui
Member
LittleLui began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Dec 2011
Device: Kindle Touch
[Kindle Touch] adding support for other ebook types

Hi everyone,

I'm trying to add support for a new ebook type to my kindle touch. I've implemented a suitable subclass of BookController, along with some of the stuff that goes along with it (Book, RendererCapabilities, ...).

Packed it all into a jar, signed it and placed it suitably on the kindle.

I added my BookController to /opt/amazon/ebook/config/reader_plugins.xml (referencing the jar's absolute path) and it gets loaded correctly, as is evident by my logging messages appearing in /var/log/messages.

My RendererCapabilities states that the BookController can handle files of type "test"; the getSupportedFileExtensions method is called at the expected time. I placed a few appropriately-named text files (eg. "foo.test") in the documents folder in USB mass storage mode (as i would do with any other ebook).

I also registered the reader booklet as an appropriate handler in /var/local/appreg.db:
Code:
INSERT INTO extenstions (ext, mimetype) VALUES ('test', 'MT:application/x-lui-kindle-test');
INSERT INTO mimetypes (ext, mimetype) VALUES ('test', 'MT:application/x-lui-kindle-test');
INSERT INTO associations (handlerId, interface, contentId, defaultAssoc) VALUES ('com.lab126.booklet.reader', 'application', 'MT:application/x-lui-kindle-test', 'true');
INSERT INTO associations (handlerId, interface, contentId, defaultAssoc) VALUES ('com.lab126.booklet.reader', 'detail', 'MT:application/x-lui-kindle-test', 'true');

That registration seems to have worked, as i can find it from my code:
Code:
 ApplicationRegistry ar = (ApplicationRegistry)ReaderSDKImpl.getBundleService(com.amazon.kindle.restricted.device.ApplicationRegistry.class);
String hid = ar.getHandlerIdFor("application", "MT:application/x-lui-kindle-test");
//hid now is "com.lab126.booklet.reader"

So, the system knows that the reader can handle the test files, and the reader knows my BookController can handle the test files.

However, there must be something missing, because the test files don't show up on the home screen.
In contrast, when I declare in my RendererCapabilities that I'm able to handle azw files, my BookController gets invoked when opening azws (which are of course correctly enumerated on the home screen), so it seems to really be a problem with the home screen just not showing my test files.

When i query the content programmatically, the test files also don't show up:
Code:
  private void testCatalog() {
      CatalogService cs = null;
      try
      {
          cs = (CatalogService)ReaderSDKImpl.getBundleService(com.amazon.kindle.content.catalog.CatalogService.class);
      }
      catch(ReaderException a)
      {
          log("cs can't be gotten",a);
      }
      //com.amazon.kindle.content.catalog.Predicate a = PredicateFactory.equals("location", getPath());
      CatalogEntry ces[] = cs.find(null, null, 1024, 0);
      
      log("ces: ".concat(String.valueOf(ces.length)));
      
      for (CatalogEntry ce : ces) {
      	LString[] titles = ce.getTitles();
      	String display = titles.length >= 1 ? titles[0].getDisplay() : "unknown";
      	log("ce: ".concat(display));
      }
  }
(for this to work i had to adapt /opt/amazon/ebook/security/application.policy, otherwise it would fail becaus it was missing some access rights)

Does anybody have an idea what i'm missing (apart from sleep)?

thanks in advance,
lui

Last edited by LittleLui; 12-14-2011 at 01:40 AM. Reason: added success story for opening azws
LittleLui is offline   Reply With Quote
Old 12-13-2011, 08:34 PM   #2
yifanlu
Kindle Dissector
yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.
 
Posts: 662
Karma: 170717
Join Date: Jul 2010
Device: Amazon Kindle 3
Amazon's logs are very detailed. Try doing "showlog -f" in SSH while running your test code and see if it says anything.
yifanlu is offline   Reply With Quote
Old 12-14-2011, 06:20 PM   #3
LittleLui
Member
LittleLui began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Dec 2011
Device: Kindle Touch
Thanks, "showlog -f" was really interesting.

I watched the download of an azw coming in over the air via my @free.kindle.com e-mail. Apparently, several processes are involved, and they are communicating via lipcd.

lipcd-probe shows some interesting things, for one the possibility to change logging levels on the fly for most (all?) of the processes.

I think it might be possible to trigger the cataloguing/indexing with some lipcd trickery.
Google doesn't seem to know anything about lipcd though, so this might be difficult.

Well, logfiles have been captured and are waiting for me to read them, so maybe enlightenment is just around the corner
LittleLui is offline   Reply With Quote
Old 12-22-2011, 06:44 PM   #4
yifanlu
Kindle Dissector
yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.
 
Posts: 662
Karma: 170717
Join Date: Jul 2010
Device: Amazon Kindle 3
So I've looked more into creating reader plugins. I think you're error came from the fact that not all the methods you have to implement in your readersdk plugin are abstract. Some are defaulted to return -1, false, or null. I haven't played too much with it, but some examples are:

AbstractBook: public int getType() returns -1
BookView: public void drawPage(Graphics2D a) throws not implemented
RendererCapabilities: public boolean acceptsFile(String a) always returns false

I'm guessing one or more of these might be the root of your problem.
yifanlu is offline   Reply With Quote
Old 12-23-2011, 02:54 AM   #5
LittleLui
Member
LittleLui began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Dec 2011
Device: Kindle Touch
Well, AbstractBook.getType(), and RendererCapabilities.acceptsFile(String) i've covered, BookView.drawPage not (I don't get far enough to draw anything yet). But of course there's plenty more where those came from - I still have to analyze the logfile, probably there's something interesting in there.

For now I've stopped the reader plugin thingie and am dabbling with kindlets, which is currently much more rewarding. Of course the kindlet i'm working on now (crosswords) would also work great as a reader plugin, so i'm bound to come back to that sooner or later.

Quote:
Originally Posted by yifanlu View Post
So I've looked more into creating reader plugins. I think you're error came from the fact that not all the methods you have to implement in your readersdk plugin are abstract. Some are defaulted to return -1, false, or null.
LittleLui is offline   Reply With Quote
Old 12-30-2011, 08:24 AM   #6
Lorphos
Librie lab rat
Lorphos plays well with othersLorphos plays well with othersLorphos plays well with othersLorphos plays well with othersLorphos plays well with othersLorphos plays well with othersLorphos plays well with othersLorphos plays well with othersLorphos plays well with othersLorphos plays well with othersLorphos plays well with others
 
Lorphos's Avatar
 
Posts: 26
Karma: 2760
Join Date: Dec 2004
Location: Dortmund, Germany
Device: Kindle 4
I'm also very interested in adding support for new formats. However, I have a Kindle 4. Are there similar hooks on that device? Yifan, you mentioned the java on the K4 is obfuscated?
Lorphos is offline   Reply With Quote
Old 12-30-2011, 08:56 AM   #7
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,903
Karma: 6677485
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Quote:
Originally Posted by Lorphos View Post
I'm also very interested in adding support for new formats. However, I have a Kindle 4. Are there similar hooks on that device? Yifan, you mentioned the java on the K4 is obfuscated?
I don't own a K4, so I can't really answer the first part of your question. However, concerning the second part (obfuscation): on both the K4 and KT, *class and method names* are not obfuscated. This is generally helpful, because it allows to understand the logical structure quite well.

However, both field and local variable names are obfuscated. So in general, all parameters and local variables are called "a", which can lead to confusion when trying to analyze concrete code. Still, this is much easier to understand than the completely obfuscated K3 framework.
ixtab is offline   Reply With Quote
Old 12-30-2011, 09:24 AM   #8
yifanlu
Kindle Dissector
yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.
 
Posts: 662
Karma: 170717
Join Date: Jul 2010
Device: Amazon Kindle 3
Quote:
Originally Posted by ixtab View Post
I don't own a K4, so I can't really answer the first part of your question. However, concerning the second part (obfuscation): on both the K4 and KT, *class and method names* are not obfuscated. This is generally helpful, because it allows to understand the logical structure quite well.

However, both field and local variable names are obfuscated. So in general, all parameters and local variables are called "a", which can lead to confusion when trying to analyze concrete code. Still, this is much easier to understand than the completely obfuscated K3 framework.
Woah! You got a K4 that does NOT have obfuscated java? (parameter and local variables cannot be obfuscated. It's just that their names are never saved or are needed in the byte code). PM me please.
yifanlu is offline   Reply With Quote
Old 12-30-2011, 09:34 AM   #9
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,903
Karma: 6677485
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
@yifanlu: Ooh wait, I just double-checked it. I was assuming that it wasn't obfuscated because of the results from the localization stuff (resource bundle package names and class names looked "normal"). But now I took a closer look again, and the implementation is still obfuscated. Sorry for the confusion.
ixtab is offline   Reply With Quote
Old 03-07-2012, 06:57 AM   #10
aditya3098
Valar
aditya3098 ought to be getting tired of karma fortunes by now.aditya3098 ought to be getting tired of karma fortunes by now.aditya3098 ought to be getting tired of karma fortunes by now.aditya3098 ought to be getting tired of karma fortunes by now.aditya3098 ought to be getting tired of karma fortunes by now.aditya3098 ought to be getting tired of karma fortunes by now.aditya3098 ought to be getting tired of karma fortunes by now.aditya3098 ought to be getting tired of karma fortunes by now.aditya3098 ought to be getting tired of karma fortunes by now.aditya3098 ought to be getting tired of karma fortunes by now.aditya3098 ought to be getting tired of karma fortunes by now.
 
aditya3098's Avatar
 
Posts: 592
Karma: 1578840
Join Date: Jan 2012
Location: Far, far away (from radio shack) :(
Device: Kindle touch (hacked to the core) 5.3.2.1
Bump (I am JUST OBSESSED with e pub)
aditya3098 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
K5 Kindle Touch Jailbreak Support Team geekmaster Kindle Developer's Corner 39 01-14-2012 05:26 AM
Kindle Touch PDF support tomsem Amazon Kindle 7 12-07-2011 11:56 AM
Feature Request: ipod touch/iphone kindle.app support ldolse Calibre 15 06-20-2009 11:09 PM


All times are GMT -4. The time now is 03:52 PM.


MobileRead.com is a privately owned, operated and funded community.