From 5c11852110eeb03dc5a69111354b383f98d15336 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 21 Oct 2008 07:00:00 -0700 Subject: Initial Contribution --- tools/scripts/AndroidManifest.alias.template | 15 + tools/scripts/AndroidManifest.template | 15 + tools/scripts/add-accounts | 131 ++++++++ tools/scripts/add-accounts-sdk | 128 ++++++++ tools/scripts/alias.template | 5 + tools/scripts/android.el | 131 ++++++++ tools/scripts/build.alias.template | 62 ++++ tools/scripts/build.template | 293 +++++++++++++++++ tools/scripts/default.properties.template | 5 + tools/scripts/iml.template | 14 + tools/scripts/ipr.template | 232 +++++++++++++ tools/scripts/iws.template | 470 +++++++++++++++++++++++++++ tools/scripts/java_file.template | 15 + tools/scripts/layout.template | 13 + tools/scripts/plugin.prop | 4 + tools/scripts/sdk_clean.sh | 48 +++ tools/scripts/strings.template | 4 + 17 files changed, 1585 insertions(+) create mode 100644 tools/scripts/AndroidManifest.alias.template create mode 100644 tools/scripts/AndroidManifest.template create mode 100755 tools/scripts/add-accounts create mode 100755 tools/scripts/add-accounts-sdk create mode 100644 tools/scripts/alias.template create mode 100644 tools/scripts/android.el create mode 100644 tools/scripts/build.alias.template create mode 100644 tools/scripts/build.template create mode 100644 tools/scripts/default.properties.template create mode 100644 tools/scripts/iml.template create mode 100644 tools/scripts/ipr.template create mode 100644 tools/scripts/iws.template create mode 100644 tools/scripts/java_file.template create mode 100644 tools/scripts/layout.template create mode 100644 tools/scripts/plugin.prop create mode 100755 tools/scripts/sdk_clean.sh create mode 100644 tools/scripts/strings.template (limited to 'tools/scripts') diff --git a/tools/scripts/AndroidManifest.alias.template b/tools/scripts/AndroidManifest.alias.template new file mode 100644 index 000000000..b1be4c870 --- /dev/null +++ b/tools/scripts/AndroidManifest.alias.template @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/tools/scripts/AndroidManifest.template b/tools/scripts/AndroidManifest.template new file mode 100644 index 000000000..2b06e76ac --- /dev/null +++ b/tools/scripts/AndroidManifest.template @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/tools/scripts/add-accounts b/tools/scripts/add-accounts new file mode 100755 index 000000000..d2cddc087 --- /dev/null +++ b/tools/scripts/add-accounts @@ -0,0 +1,131 @@ +#!/usr/bin/env python +# +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +A faux Setup Wizard. Stuffs one or two usernames + passwords into the +database on the device. +""" + +import sys +if sys.hexversion < 0x02040000: + print "This script requires python 2.4 or higher." + sys.exit(1) + +import getpass +import subprocess +import time +import sha + +DB = "/data/data/com.google.android.googleapps/databases/accounts.db" + +def RunCmd(args): + proc = subprocess.Popen(args, stdout=subprocess.PIPE) + out = proc.stdout.read() + if proc.wait(): + print + print "failed: %s" % " ".join(args) + return None + return out + +def GetProp(adb_flags, name): + args = ("adb",) + adb_flags + ("shell", "su", "root", + "/system/bin/getprop", name) + return RunCmd(args) + +def SetProp(adb_flags, name, value): + args = ("adb",) + adb_flags + ("shell", "su", "root", + "/system/bin/setprop", name, value) + return RunCmd(args) + +def DbExists(adb_flags): + args = ("adb",) + adb_flags + ("shell", "su", "root", + "/system/bin/ls", DB) + result = RunCmd(args) + if result is None: return None + return "No such file" not in result + +def main(argv): + if len(argv) == 1: + print ("usage: %s [adb flags] " + "[] " + "[]") % (argv[0],) + sys.exit(2) + + argv = argv[1:] + + gmail = None + dasher = None + while argv and "@" in argv[-1]: + addr = argv.pop() + if "@gmail.com" in addr or "@googlemail.com" in addr: + gmail = addr + else: + dasher = addr + + adb_flags = tuple(argv) + + while True: + db = DbExists(adb_flags) + if db is None: + print "failed to contact device; will retry in 3 seconds" + time.sleep(3) + continue + + if db: + print + print "GoogleLoginService has already started on this device;" + print "it's too late to use this script to add accounts." + print + print "This script only works on a freshly-wiped device (or " + print "emulator) while booting for the first time." + print + break + + hosted_account = GetProp(adb_flags, "ro.config.hosted_account").strip() + google_account = GetProp(adb_flags, "ro.config.google_account").strip() + + if dasher and hosted_account: + print + print "A dasher account is already configured on this device;" + print "can't add", hosted_account + print + dasher = None + + if gmail and google_account: + print + print "A google account is already configured on this device;" + print "can't add", google_account + print + gmail = None + + if not gmail and not dasher: break + + if dasher: + SetProp(adb_flags, "ro.config.hosted_account", dasher) + print "set hosted_account to", dasher + if gmail: + SetProp(adb_flags, "ro.config.google_account", gmail) + print "set google_account to", gmail + + break + + + + + + +if __name__ == "__main__": + main(sys.argv) diff --git a/tools/scripts/add-accounts-sdk b/tools/scripts/add-accounts-sdk new file mode 100755 index 000000000..bb3447fab --- /dev/null +++ b/tools/scripts/add-accounts-sdk @@ -0,0 +1,128 @@ +#!/usr/bin/env python +# +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +A faux Setup Wizard. Stuffs one or two usernames + passwords into the +database on the device. +""" + +import sys +if sys.hexversion < 0x02040000: + print "This script requires python 2.4 or higher." + sys.exit(1) + +import getpass +import subprocess +import time +import sha + +DB = "/data/data/com.google.android.googleapps/databases/accounts.db" + +def RunCmd(args): + proc = subprocess.Popen(args, stdout=subprocess.PIPE) + out = proc.stdout.read() + if proc.wait(): + print + print "failed: %s" % " ".join(args) + return None + return out + +def GetProp(adb_flags, name): + args = ("adb",) + adb_flags + ("shell", "/system/bin/getprop", name) + return RunCmd(args) + +def SetProp(adb_flags, name, value): + args = ("adb",) + adb_flags + ("shell", "/system/bin/setprop", name, value) + return RunCmd(args) + +def DbExists(adb_flags): + args = ("adb",) + adb_flags + ("shell", "/system/bin/ls", DB) + result = RunCmd(args) + if result is None: return None + return "No such file" not in result + +def main(argv): + if len(argv) == 1: + print ("usage: %s [adb flags] " + "[] " + "[]") % (argv[0],) + sys.exit(2) + + argv = argv[1:] + + gmail = None + hosted = None + while argv and "@" in argv[-1]: + addr = argv.pop() + if "@gmail.com" in addr or "@googlemail.com" in addr: + gmail = addr + else: + hosted = addr + + adb_flags = tuple(argv) + + while True: + db = DbExists(adb_flags) + if db is None: + print "failed to contact device; will retry in 3 seconds" + time.sleep(3) + continue + + if db: + print + print "GoogleLoginService has already started on this device;" + print "it's too late to use this script to add accounts." + print + print "This script only works on a freshly-wiped device (or " + print "emulator) while booting for the first time." + print + break + + hosted_account = GetProp(adb_flags, "ro.config.hosted_account").strip() + google_account = GetProp(adb_flags, "ro.config.google_account").strip() + + if hosted and hosted_account: + print + print "A hosted account is already configured on this device;" + print "can't add", hosted_account + print + hosted = None + + if gmail and google_account: + print + print "A google account is already configured on this device;" + print "can't add", google_account + print + gmail = None + + if not gmail and not hosted: break + + if hosted: + SetProp(adb_flags, "ro.config.hosted_account", hosted) + print "set hosted_account to", hosted + if gmail: + SetProp(adb_flags, "ro.config.google_account", gmail) + print "set google_account to", gmail + + break + + + + + + +if __name__ == "__main__": + main(sys.argv) diff --git a/tools/scripts/alias.template b/tools/scripts/alias.template new file mode 100644 index 000000000..8be355b36 --- /dev/null +++ b/tools/scripts/alias.template @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/tools/scripts/android.el b/tools/scripts/android.el new file mode 100644 index 000000000..49f2f1e8b --- /dev/null +++ b/tools/scripts/android.el @@ -0,0 +1,131 @@ +;;;; Copyright 2007 The Android Open Source Project + +;;; Set up GUD+JDB to attach to a Java process running on the phone or +;;; under the emulator. + +(defvar android-jdb-port-history '("8700") + "history of ports supplied to `android-jdb'") + +(defvar android-jdb-project-root-history '() + "history of project roots supplied to `android-jdb'") +(defvar android-jdb-history nil + "history of commands supplied to `android-jdb'") + +(defvar android-jdb-activity-class-history () + "history of activity classes supplied to `start-android-activity'") + +(defcustom android-jdb-command-name "jdb" + "Name of Java debugger." + :type 'string + :group 'android) + +(defgroup android nil + "Android Applications." + :group 'applications) + +(defcustom android-project-root nil + "This is where your Android project root is stored." + :type 'directory + :group 'android ) + +(defcustom android-apk nil + "This is where your Android Application Package is stored." + :type 'string + :group 'android) + +(defcustom android-activity-class nil + "This is where your Android Activity class is stored." + :type 'string + :group 'android) + +(defun android-read-project-root () + (if (or (string-match "XEmacs" emacs-version) + (>= emacs-major-version 22)) + (read-file-name "Android project root: " + android-project-root + nil + t + nil + 'file-directory-p) + (labels ((read-directory () + (read-file-name "Android project root: " + android-project-root + nil + t + nil))) + (do ((entered-root (read-directory) (read-directory))) + ((and entered-root + (file-directory-p entered-root)) + (expand-file-name entered-root)))))) + +(defun android-jdb (port root) + "Set GUD+JDB up to run against Android on PORT in directory ROOT." + (interactive + (list + (read-from-minibuffer "Activity's JDWP DDMS port: " + (car android-jdb-port-history) + nil + t + 'android-jdb-port-history) + (android-read-project-root))) + (setq android-project-root root) + (let ((jdb-command + (format "%s -attach localhost:%s -sourcepath%s" + android-jdb-command-name + port + (format "%s/src" root)))) + (if (not (string= jdb-command (car android-jdb-history))) + (push jdb-command android-jdb-history)) + (jdb jdb-command))) + +(defun android-emulate () + "Run the Android emulator. This expects the SDK tools directory to be in the current path." + (interactive) + (compile "emulator")) + +(defun android-install-app (apk) + "Install an Android application package APK in the Android emulator. This expects the SDK tools directory to be in the current path." + (interactive (list (expand-file-name + (read-file-name "Android Application Package (.apk): " + nil + android-apk + t + nil + nil)))) + (setq android-apk apk) + (compile (format "adb install -r %s" apk))) + +(defun android-uninstall-app (package-name) + "Uninstall an Android application package APK in the Android emulator. This expects the SDK tools directory to be in the current path. +Specify the package name --- and not the name of the application e.g., com.android.foo." + (interactive + (list + (read-from-minibuffer "Package: "))) + (compile (format "adb install -r %s" package))) + +(defun android-start-activity (package class) + "Start the activity PACKAGE/CLASS in the Android emulator. This expects the SDK tools directory to be in the current path." + (interactive + (list + (read-from-minibuffer "Package: ") + (read-from-minibuffer "Activity Java class: " + (car android-jdb-activity-class-history) + nil + t + 'android-jdb-activity-class-history))) + (compile (format "adb shell am start -n %s/%s" package class))) + +(defun android-debug-activity (package class) + "Start the activity PACKAGE/CLASS within the debugger in the Android emulator. This expects the SDK tools directory to be in the current path." + (interactive + (list + (read-from-minibuffer "Package: ") + (read-from-minibuffer "Activity Java class: " + (car android-jdb-activity-class-history) + nil + t + 'android-jdb-activity-class-history))) + (compile (format "adb shell am start -D -n %s/%s" package class))) + +(provide 'android) + diff --git a/tools/scripts/build.alias.template b/tools/scripts/build.alias.template new file mode 100644 index 000000000..22252aa8b --- /dev/null +++ b/tools/scripts/build.alias.template @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Packaging resources... + + + + + + + + + + + + + + + + + + + + Sending package to default emulator... + + + + + + + diff --git a/tools/scripts/build.template b/tools/scripts/build.template new file mode 100644 index 000000000..0081c336d --- /dev/null +++ b/tools/scripts/build.template @@ -0,0 +1,293 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Creating output directories if needed... + + + + + + + Generating R.java / Manifest.java from the resources... + + + + + + + + + + + + + + + + + Compiling aidl files into Java classes... + + + + + + + + + + + + + + + + + + + + + Converting compiled files and external libraries into ${outdir}/${dex-file}... + + + + + + + + + + + Packaging resources and assets... + + + + + + + + + + + + + + + + + + + Packaging resources... + + + + + + + + + + + + + + + + + + + + + + + + + + Packaging ${out-debug-package}, and signing it with a debug key... + + + + + + + + + + + + + + + + + + Packaging ${out-unsigned-package} for release... + + + + + + + + + + + + + + + It will need to be signed with jarsigner before being published. + + + + + Installing ${out-debug-package} onto default emulator... + + + + + + + + Installing ${out-debug-package} onto default emulator... + + + + + + + + + + Uninstalling ${application-package} from the default emulator... + + + + + + + diff --git a/tools/scripts/default.properties.template b/tools/scripts/default.properties.template new file mode 100644 index 000000000..5d708f20b --- /dev/null +++ b/tools/scripts/default.properties.template @@ -0,0 +1,5 @@ +# This file is automatically generated by activitycreator. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# Instead customize values in a "build.properties" file. + +sdk-folder=ANDROID_SDK_FOLDER diff --git a/tools/scripts/iml.template b/tools/scripts/iml.template new file mode 100644 index 000000000..c4fe3a332 --- /dev/null +++ b/tools/scripts/iml.template @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tools/scripts/ipr.template b/tools/scripts/ipr.template new file mode 100644 index 000000000..cb3d65e2c --- /dev/null +++ b/tools/scripts/ipr.template @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/scripts/iws.template b/tools/scripts/iws.template new file mode 100644 index 000000000..67d2053a1 --- /dev/null +++ b/tools/scripts/iws.template @@ -0,0 +1,470 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/scripts/java_file.template b/tools/scripts/java_file.template new file mode 100644 index 000000000..aeb541f7b --- /dev/null +++ b/tools/scripts/java_file.template @@ -0,0 +1,15 @@ +package PACKAGE; + +import android.app.Activity; +import android.os.Bundle; + +public class ACTIVITY_NAME extends Activity +{ + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + } +} diff --git a/tools/scripts/layout.template b/tools/scripts/layout.template new file mode 100644 index 000000000..864e99748 --- /dev/null +++ b/tools/scripts/layout.template @@ -0,0 +1,13 @@ + + + + + diff --git a/tools/scripts/plugin.prop b/tools/scripts/plugin.prop new file mode 100644 index 000000000..15593ef68 --- /dev/null +++ b/tools/scripts/plugin.prop @@ -0,0 +1,4 @@ +# begin plugin.prop +plugin.version=0.8.0 +plugin.platform=android +# end plugin.prop \ No newline at end of file diff --git a/tools/scripts/sdk_clean.sh b/tools/scripts/sdk_clean.sh new file mode 100755 index 000000000..467d5605a --- /dev/null +++ b/tools/scripts/sdk_clean.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# This script processes a set of files given as arguments as sample code to be released +# in the SDK. +# +# Note that these files are modified in-place. +# + +DIR=$1 + +# +# Remove BEGIN_INCLUDE and END_INCLUDE lines used by the javadoc. +# +# This does it by replacing these lines with blank lines so line numbers aren't +# changed in the process, making it easier to match 3rd party complaints/questions +# with the source tree. +# +# sed on Mac OS takes -i SUFFIX and sed on Linux takes -iSUFFIX +# +if [ $HOST_OS = darwin ] ; then +find $DIR -name "*.java" -o -name "*.xml" | xargs -n 1 \ + sed \ + -e "s/.*BEGIN_INCLUDE(.*//" \ + -e "s/.*END_INCLUDE(.*//" \ + -i "" +else +find $DIR -name "*.java" -o -name "*.xml" | xargs -n 1 \ + sed \ + -e "s/.*BEGIN_INCLUDE(.*//" \ + -e "s/.*END_INCLUDE(.*//" \ + -i +fi + +# +# Fix up the line endings of all text files +# +if [ $HOST_OS = windows ] ; then + ENDING_TYPE=dos +else + ENDING_TYPE=unix +fi +find $DIR -name "*.aidl" -o -name "*.css" -o -name "*.html" -o -name "*.java" \ + -o -name "*.js" -o -name "*.prop" -o -name "*.py" \ + -o -name "*.template" -o -name "*.txt" -o -name "*.windows" \ + -o -name "*.xml" \ + | xargs $HOST_OUT_EXECUTABLES/line_endings $ENDING_TYPE + + diff --git a/tools/scripts/strings.template b/tools/scripts/strings.template new file mode 100644 index 000000000..acc28e29d --- /dev/null +++ b/tools/scripts/strings.template @@ -0,0 +1,4 @@ + + + ACTIVITY_NAME + -- cgit v1.2.3