summaryrefslogtreecommitdiffstats
path: root/fill_screens.py
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-08-25 20:49:43 (GMT)
committerAdam Cohen <adamcohen@google.com>2011-08-25 20:57:55 (GMT)
commit1982c4be5ac89024a51acbffbb74ba509250ee6f (patch)
tree4ce1019440cb6fdedde1ee6fe7f1768df6f7f6bb /fill_screens.py
parentae915cecd36af4973061a1cb0b58c5be1be699a0 (diff)
downloadandroid_packages_apps_Trebuchet-1982c4be5ac89024a51acbffbb74ba509250ee6f.zip
android_packages_apps_Trebuchet-1982c4be5ac89024a51acbffbb74ba509250ee6f.tar.gz
android_packages_apps_Trebuchet-1982c4be5ac89024a51acbffbb74ba509250ee6f.tar.bz2
Script to fill launcher screens with full folders
-> Useful for testing. The script can be easily modified to fill the screens quickly in other ways to aid in testing. Change-Id: I64ffd13b28c5cf04d0aa947eb1293a203ca9be73
Diffstat (limited to 'fill_screens.py')
-rwxr-xr-xfill_screens.py91
1 files changed, 91 insertions, 0 deletions
diff --git a/fill_screens.py b/fill_screens.py
new file mode 100755
index 0000000..9607c80
--- /dev/null
+++ b/fill_screens.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python2.5
+
+import cgi
+import os
+import shutil
+import sys
+import sqlite3
+
+SCREENS = 5
+COLUMNS = 4
+ROWS = 4
+CELL_SIZE = 110
+
+DIR = "db_files"
+AUTO_FILE = "launcher.db"
+
+APPLICATION_COMPONENTS = [
+ "com.google.android.apps.books/com.google.android.apps.books.app.BooksActivity",
+ "com.android.calculator2/com.android.calculator2.Calculator",
+ "com.google.android.camera/com.android.camera.Camera",
+ "com.google.android.carhome/com.google.android.carhome.CarHome",
+ "com.android.providers.downloads.ui/com.android.providers.downloads.ui.DownloadList",
+ "com.google.android.gallery3d/com.android.gallery3d.app.Gallery",
+ "com.google.android.apps.maps/com.google.android.maps.MapsActivity"
+]
+
+def usage():
+ print "usage: fill_screens.py -- fills up the launcher db"
+
+
+def make_dir():
+ shutil.rmtree(DIR, True)
+ os.makedirs(DIR)
+
+def pull_file(fn):
+ print "pull_file: " + fn
+ rv = os.system("adb pull"
+ + " /data/data/com.android.launcher/databases/launcher.db"
+ + " " + fn);
+ if rv != 0:
+ print "adb pull failed"
+ sys.exit(1)
+
+def push_file(fn):
+ print "push_file: " + fn
+ rv = os.system("adb push"
+ + " " + fn
+ + " /data/data/com.android.launcher/databases/launcher.db")
+ if rv != 0:
+ print "adb push failed"
+ sys.exit(1)
+
+def process_file(fn):
+ print "process_file: " + fn
+ conn = sqlite3.connect(fn)
+ c = conn.cursor()
+ c.execute("DELETE FROM favorites")
+
+ intentFormat = "#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=%s;end"
+
+ id = 0;
+ for s in range(SCREENS):
+ for x in range(ROWS):
+ for y in range(COLUMNS):
+ id += 1
+ insert = "INSERT into favorites (_id, title, intent, container, screen, cellX, cellY, spanX, spanY, itemType, appWidgetId, iconType) VALUES (%d, '%s', '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)"
+ insert = insert % (id, "title", "", -100, s, x, y, 1, 1, 2, -1, 0)
+ c.execute(insert)
+ folder_id = id
+
+ for z in range(15):
+ id += 1
+ intent = intentFormat % (APPLICATION_COMPONENTS[id % len(APPLICATION_COMPONENTS)])
+ insert = "INSERT into favorites (_id, title, intent, container, screen, cellX, cellY, spanX, spanY, itemType, appWidgetId, iconType) VALUES (%d, '%s', '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)"
+ insert = insert % (id, "title", intent, folder_id, 0, 0, 0, 1, 1, 0, -1, 0)
+ c.execute(insert)
+
+ conn.commit()
+ c.close()
+
+def main(argv):
+ if len(argv) == 1:
+ make_dir()
+ pull_file(AUTO_FILE)
+ process_file(AUTO_FILE)
+ push_file(AUTO_FILE)
+ else:
+ usage()
+
+if __name__=="__main__":
+ main(sys.argv)