[Nook Color Android Development] Rayven01:
The B&N Home application lets you add B&N-purchased books to the home screen and arrange/resize them arguably better than most generic android launchers. Unfortunately this doesn't work for sideloaded books. This is most definitely not because it can't be done, but likely as an incentive for you to purchase books from B&N and not sideload. The following describes the sqlite3 database entries necessary to manually add sideloaded books (and potentially other things) to this home screen.

Warning: Changes should not be attempted by someone not at least somewhat familiar with adb and sqlite3. This is not intended as a how-to for adding sideloaded books to the home screen (since it is tedious, and not something you'd likely do often manually), but more as a reference for someone to perhaps develop an android app for the NC to do so on-device. If you don't use the B&N Home at all and use the device more as a tablet than an e-reader, you can completely ignore this post. :)

Relevant databases:

/data/data/com.bn.nook.home/files/home.db - Contains the home screen 'workspace' table with entries for each item on the home screen.

/data/data/com.bn.nook.reader.activities/databases/lastreadingpoint.db - Contains the 'lastreadingpoint' table which records the last read position for all books (B&N and sideloaded).

/data/data/com.android.providers.media/databases/internal.db - Android 'media' provider database containing content entries for books (among other things). Heavily modified by B&N.

home.db, workspace table

Schema:

CREATE TABLE workspace (_id TEXT PRIMARY KEY, thumbnail_url TEXT, cover_image_url TEXT, ean TEXT, title TEXT, author TEXT, desktop_num INT NOT NULL, left INT NOT NULL, top INT NOT NULL, right INT NOT NULL, bottom INT NOT NULL, rotate_degree FLOAT NOT NULL, lending_state INT NOT NULL, is_lendable BOOLEAN NOT NULL, is_recommended BOOLEAN NOT NULL, is_new BOOLEAN NOT NULL, is_sample BOOLEAN NOT NULL, launcher_type TEXT, product_type INT NOT NULL, product_ean TEXT, is_hidden BOOLEAN NOT NULL DEFAULT FALSE, path_to_file TEXT);

Fields:

_id - Android content link to the book.

Examples: content://media/internal/products/1 (B&N book), content://media/internal/docs/1 (sideloaded book)

thumbnail_url - Thumbnail image location. Note that sideloaded use non-browser paths. File:// paths do not appear to work in this field.

Examples: http: //images.bn.com/images/85750000/85751898.JPG (B&N Book), /media/.docThumbs/Quick_Startepub.jpg (sideloaded book)

cover_image_url - Cover image location. Same format as thumbnail. Same image even, for sideloaded books.

Examples: http ://images.bn.com/images/85750000/85754280.JPG (B&N Book), /media/.docThumbs/Quick_Startepub.jpg (sideloaded book)

ean - B&N unique identifier, for B&N Books. File location in browser format (file:///media/...) for sideloaded books. Note this

must

match what's in lastreadingpoint.db for the last reading point to be correct when tapping the book to open it.

Examples: 9781402786402 (B&N Book), file:///system/media/books/Quick_Start.epub (sideloaded book)

title, author - Self explanitory. Plain text. Appear to be unused unless the images are not found, in which case the title is truncated and overlaid on a generic gray icon.

desktop_num - Which desktop the icon appears on. 0,1, or 2 with 1 being the default.

left, top, right, bottom - Pixel measurements for the corners of the icons. Determines the location and size of the icon on the home screen.

rotate_degree - Haven't played with this one yet.

lending_state - Current state of lendable book. Haven't investigated valid values other than the default 0.

is_lendable, is_recommended, is_new, is_sample - Flags that determine what 'banner' is displayed, and also what opens show on tap-and-hold.

launcher_type - Launcher to open the book with.

Valid values: blank (epub), epub, epib (children's books). Things still to try: html, pdf...

product_type - Type of book.

1 = B&N book, 0 = Sideloaded book.

product_ean - Appears to always match ean field.

is_hidden - Hide's icon? Haven't tried.

path_to_file - Filesystem path to book.

Examples: /media/B&N Downloads/Books/9781402786402_ePib.v2.epub (B&N Book), /system/media/books/QuickStart.epub (sideloaded book)

lastreadingpoint.db, lastreadingpoint table

Schema:

CREATE TABLE lastreadingpoint (_id integer primary key autoincrement, ean text , luid text , offsetrmsdk text , lastupdated long , bookdna int , sync_status int);

Relevant Field:

ean - B&N unique identifier, for B&N Books. File location in browser format (file:///media/...)for sideloaded books. Note this

must

match what's in home.db for the last reading point to be correct when tapping the book to open it.

internal.db, products/docs tables

Schema:

CREATE TABLE products (_id INTEGER PRIMARY KEY,ean TEXT NOT NULL UNIQUE,_data TEXT,_size INTEGER,product_type INTEGER NOT NULL,mime_type TEXT,_display_name TEXT,product_code TEXT NOT NULL,format_code TEXT NOT NULL,purchase_status TEXT NOT NULL,title TEXT NOT NULL,authors TEXT NOT NULL,mainAuthorFirstName TEXT,mainAuthorMiddleName TEXT DEFAULT NULL,mainAuthorLastName TEXT NOT NULL,publisher TEXT NOT NULL,date_published INTEGER NOT NULL,date_added INTEGER NOT NULL,date_modified INTEGER,date_last_accessed INTEGER DEFAULT 0,thumb_image TEXT,cover_image TEXT,rating INTEGER DEFAULT 0, user_rating INTEGER DEFAULT 0, subscription_ean TEXT DEFAULT NULL,isSubscription BOOLEAN DEFAULT 0,isSample BOOLEAN DEFAULT 0,locker_delivery_id INTEGER NOT NULL,locker_status TEXT NOT NULL, short_synopsis TEXT,storage_location INTEGER DEFAULT 1,isNew INTEGER DEFAULT 0,lendable BOOLEAN DEFAULT 0,lending_state TEXT,lendee TEXT,lender TEXT,lend_message TEXT,lend_id TEXT,lend_offer_expires INTEGER,lend_starts INTEGER,lend_ends INTEGER,category TEXT,luid TEXT NOT NULL,sync_status INTEGER DEFAULT 0,page_count INTEGER,rating_count INTEGER, local_thumb_image TEXT, local_cover_image TEXT, ebook_key TEXT, launcher_type TEXT, isDownloadable INTEGER DEFAULT 1, productEAN TEXT, isComingSoon INTEGER, DeliveryFrequency INTEGER, seriesTitle TEXT, soldBy TEXT, trialExpirationDate INTEGER );

CREATE TABLE docs (_id INTEGER PRIMARY KEY,ean TEXT,_data TEXT,_size INTEGER,product_type INTEGER,mime_type TEXT,_display_name TEXT,title TEXT,authors TEXT,mainAuthorFirstName TEXT,mainAuthorMiddleName TEXT DEFAULT NULL,mainAuthorLastName TEXT,publisher TEXT,date_added INTEGER,date_modified INTEGER,date_published INTEGER,date_last_accessed INTEGER DEFAULT 0,valid INTEGER,thumb_image TEXT,cover_image TEXT,rating INTEGER DEFAULT 0, user_rating INTEGER DEFAULT 0,storage_location INTEGER DEFAULT 0,category TEXT,page_count INTEGER, launcher_type TEXT, volume_id INTEGER DEFAULT 0);

Relevant Fields:

_id - The content id needed for the _id field in home.db workbook table.

thumb_image - Thumbnail image location. Note that sideloaded use non-browser paths. File:// paths do not appear to work in this field.

Examples: http ://images.bn.com/images/85750000/85751898.JPG (B&N Book), /media/.docThumbs/Quick_Startepub.jpg (sideloaded book)

cover_image - Cover image location. Same format as thumbnail. Same image even, for sideloaded books.

Steps to add sideloaded content via adb:

Pull all relevant tables from the device using adb.

Look up relevant database entries (content id, images, etc)

Use sqlite3 to add or modify entries in home.db, workspace table.

Example:

INSERT INTO workspace VALUES('content://media/internal/docs/3', '/media/.docThumbs/TestBook.jpeg', '/media/.docThumbs/TestBook.jpeg', 'file:///media/My Files/Books/TestBook.epub', 'Test Book', 'Test Author', 1, 20, 20, 184, 232, 0.0, 0, 0, 0, 0, 0, 'epub', 0, 'file:///media/My Files/Books/TestBook.epub', 0, '/media/My Files/Books/TestBook.epub');

Push home.db back to the NC.

Kill the Home process via shell or a process manager app.

Open Home again.

Notes:

12/29/10

Sideloaded books must be opened at least once to populate all the databases. This poses a potential problem for trying to do this at sideload time, ie through a calibre plugin.

The _id field of workspace does not appear to have to be correct for icons to function normally. My first tests had a generic 'test1' in that field until I figured out where to look for the correct value and I was able to open sideloaded books just fine with the resulting icon. This fact, along with the fact that image locations can be guessed correctly may mean we can do this at sideload time after all.

The User Guide and Quick Start are decent examples of sideloaded content on the B&N Home screen. The only oddities with them are blank ean fields, so last read position is not used when opening them.

I've seen some oddities where the icons don't render images until you touch one of them on the screen after the Home app launches. Haven't tracked down the cause yet, and it doesn't happen every time.

Setting a sideloaded book as lendable adds the 'Lend' option to the tap-and-hold, but it doesn't appear to do anything after you enter the contact. My guess is they verify this status either with their servers (likely), or with another on-device database (doubtful) .

Sideloaded books can be removed from the home screen as normal, by doing a tap-and-hold and choosing Remove.