import codecs
import os
import pprint
+import re
import shutil
import sys
import sqlite3
INDEX_FILE = DIR + "/index.html"
def usage():
- print "usage: print_db.py launcher.db <sw600|sw720> -- prints a launcher.db"
- print "usage: print_db.py <sw600|sw720> -- adb pulls a launcher.db from a device"
- print " and prints it"
+ print "usage: print_db.py launcher.db <4x4|5x5|5x6|...> -- prints a launcher.db with"
+ print " the specified grid size (rows x cols)"
+ print "usage: print_db.py <4x4|5x5|5x6|...> -- adb pulls a launcher.db from a device"
+ print " and prints it with the specified grid size (rows x cols)"
print
print "The dump will be created in a directory called db_files in cwd."
print "This script will delete any db_files directory you have now"
shutil.rmtree(DIR, True)
os.makedirs(DIR)
+def adb_root_remount():
+ os.system("adb root")
+ os.system("adb remount")
+
def pull_file(fn):
print "pull_file: " + fn
rv = os.system("adb pull"
- + " /data/data/com.google.android.googlequicksearchbox/databases/launcher.db"
+ + " /data/data/com.android.launcher3/databases/launcher.db"
+ " " + fn);
if rv != 0:
print "adb pull failed"
rows.append(row)
return columns,rows
+def get_screens(conn):
+ c = conn.cursor()
+ c.execute("SELECT * FROM workspaceScreens")
+ columns = [d[0] for d in c.description]
+ rows = []
+ for row in c:
+ rows.append(row)
+ return columns,rows
+
def print_intent(out, id, i, cell):
if cell:
out.write("""<span class="intent" title="%s">shortcut</span>""" % (
out.write("<b>unknown type: %d</b>" % itemType)
out.write("</td>\n")
+def render_screen_info(out, screen):
+ out.write("<tr>")
+ out.write("<td>%s</td>" % (screen["_id"]))
+ out.write("<td>%s</td>" % (screen["screenRank"]))
+ out.write("</tr>")
+
def process_file(fn):
global SCREENS, COLUMNS, ROWS, HOTSEAT_SIZE
print "process_file: " + fn
conn = sqlite3.connect(fn)
columns,rows = get_favorites(conn)
+ screenCols, screenRows = get_screens(conn)
data = [dict(zip(columns,row)) for row in rows]
+ screenData = [dict(zip(screenCols, screenRow)) for screenRow in screenRows]
# Calculate the proper number of screens, columns, and rows in this db
screensIdMap = []
hotseatIdMap = []
HOTSEAT_SIZE = 0
for d in data:
+ if d["spanX"] is None:
+ d["spanX"] = 1
+ if d["spanY"] is None:
+ d["spanY"] = 1
if d["container"] == CONTAINER_DESKTOP:
if d["screen"] not in screensIdMap:
screensIdMap.append(d["screen"])
out.write("""</table>
""")
+ # Screens
+ out.write("<br/><b>Screens</b><br/>\n")
+ out.write("<table class=layout border=1 cellspacing=0 cellpadding=4>\n")
+ out.write("<tr><td>Screen ID</td><td>Rank</td></tr>\n")
+ for screen in screenData:
+ render_screen_info(out, screen)
+ out.write("</table>\n")
+
# Hotseat
hotseat = []
for i in range(0, HOTSEAT_SIZE):
def updateDeviceClassConstants(str):
global SCREENS, COLUMNS, ROWS, HOTSEAT_SIZE
- devClass = str.lower()
- if devClass == "sw600":
- COLUMNS = 6
- ROWS = 6
- HOTSEAT_SIZE = 6
- return True
- elif devClass == "sw720":
- COLUMNS = 8
- ROWS = 6
- HOTSEAT_SIZE = 8
+ match = re.search(r"(\d+)x(\d+)", str)
+ if match:
+ COLUMNS = int(match.group(1))
+ ROWS = int(match.group(2))
+ HOTSEAT_SIZE = 2 * int(COLUMNS / 2)
return True
return False
def main(argv):
if len(argv) == 1 or (len(argv) == 2 and updateDeviceClassConstants(argv[1])):
make_dir()
+ adb_root_remount()
pull_file(AUTO_FILE)
process_file(AUTO_FILE)
elif len(argv) == 2 or (len(argv) == 3 and updateDeviceClassConstants(argv[2])):