Own ads on a Tolino e-reader

The lower part of the main screen on Tolino e-book readers is dedicated to advertisements of the shop that the Tolino was bought at. I wanted to get rid of them so I built my own boot image, patched adbd to get root, tinkered with the system and documented the server API.

I found that the Tolino software EPubProd.apk has no way to disable those recommendations except when activating hotel mode, and then the lower part is still wasted by only showing the hotel's logo.

Knowing that it is not possible to disable the ads, I wanted to make them work for me: Show the latest books that I added to my Calibre library and let me download them with a single click. That way I would not have to connect the Tolino via USB to my computer to sync books onto it!

Main screen

When pressing the sync button on the "my books" screen or when enough time has passed, the Tolino software calls the server API https://bosh.pageplace.de/bosh/rest/recommendation/xyz.

Fortunately for me, it is possible to override the domain by modifying the reseller settings file /data/data/de.telekom.epub/shared_prefs/ePub.xml. Fetch it via adb pull, modify it on the computer and the upload it back, change the permissions and restart the ebook application:

#!/bin/sh
adb push ePub.xml /data/data/de.telekom.epub/shared_prefs/ePub.xml
adb shell chown system:system /data/data/de.telekom.epub/shared_prefs/ePub.xml
adb shell am force-stop de.telekom.epub

ePub.xml contains a key de.telekom.epub.PREFS_APPLICATION_PROPERTIES_JSON that contains the reseller configuration serialized in JSON.

The following values are relevant to the main screen:

URL_BOOKSHELF
The base URL for (some) API requests. Defaults to https://bosh.pageplace.de/bosh/rest, and I used it to point the Tolino to my own server.
URL_RESELLER_LOGO
URL of a .png image shown above the recommendations
SHOP_BASE
The URL that is opened when clicking the "To the shop" button on the top right of the recommendations.
URL_SHOP_EBOOK_START_PAGE
The URL that is opened when clicking "Menu" > "Thalia.de Shop"

After modifying those values I built a small PHP script that listed the latest books from my calibre sqlite database:

Tolino home screen with latest calibre books

Detail pages

Now that I had the ads in place I could simply link it to the .epub file - at least I thought so.

It turned out that shop links are not opened in a normal browser but in a restricted de.telekom.epub.ui.activities.ShopWebViewActivity that does not support downloading files!

ShopWebViewActivity automatically adds authentication headers when HTTP requests are sent, so people never have to log in when they are already logged into their Tolino.

Special URLs

The view supports some special URLs that don't work in the normal browser:

Details can be found in the API documentation: Internal URLs.

JavaScript API

The adb logcat debug log always showed an error:

Uncaught ReferenceError: android_init is not defined line: 1 source: http://tolino.cwboo/book.php?id=408

All restricted web views on the Tolino call a JavaScript function android_init when the page is loaded. This enables e.g. the shops to execute special code only on Tolino devices.

It also provides a JavaScript variable screenController with a couple of methods that lets you control the UI a bit:

screenController.hideNavigationHeader();
screenController.hideProgressDialog();
screenController.refreshScreen();
screenController.setNavigationHeaderTitle("my header");
screenController.setNavigationHeaderUrl("epublishing://closeshop");
screenController.setTokens("accesstoken", "refreshtoken");
screenController.showNavigationHeader("header title");
screenController.showProgressDialog();
screenController.processHTML("html");//does nothing

Details can be found in the API documentation: Javascript API.

Native navigation bar created with the Tolino JavaScript API

Extract links

It is impossible to open the normal web browser from the restricted ShopWebViewActivity, and downloading .epub files is not supported. How do I get the book on my Tolino?

One of the special URLs is epublishing://openextract which takes an epub file URL. When clicking the link, the file is downloaded and opened!

Unfortunately it is seen as "Extract" which means "Leseprobe" in German. It's meant as preview for books, but not for whole books. When opening the extract a "To the shop" button is shown on every page:

Downloaded .epub extract with 'To the shop' button

So this is also not a solution :(

Fin.

That's it for now. It is unfortunately not possible to quickly download ebooks from the main screen's advertisement section.

It seems I have to build my own synchronization service that synchronizes the books onto the Tolino when clicking "buy" or "download" on the recommendation details page. But this will take quite a while to implement :(

Written by Christian Weiske.

Comments? Please send an e-mail.