am e81271f5: Merge change Id97eba9f into eclair

Merge commit 'e81271f526db01af84eabdd99d309c9425d3f1a3' into eclair-mr2

* commit 'e81271f526db01af84eabdd99d309c9425d3f1a3':
  don't add "ota-rel-keys" tag to build fingerprints
diff --git a/cleanspec.mk b/cleanspec.mk
index 40b62e0..da6f94f 100644
--- a/cleanspec.mk
+++ b/cleanspec.mk
@@ -97,15 +97,32 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libwebcore_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libwebcore_intermediates)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libwebcore_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libwebcore_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libv8_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libwebcore_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libwebcore_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libjs_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libv8_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/com/android/internal/os/IDropBoxService.java)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/GoogleSubscribedFeedsProvider.apk)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS)
 
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/core/Makefile b/core/Makefile
index 2f316ca..deb9f58 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -472,6 +472,29 @@
 
 
 # -----------------------------------------------------------------
+
+.PHONY: event-log-tags
+
+event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
+ALL_PREBUILT += $(event_log_tag_file)
+
+# Include tags from all packages included in this product.
+event_log_tags_src := \
+    $(sort $(foreach m,\
+      $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
+      $(call module-names-for-tag-list,user), \
+      $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
+
+$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
+$(event_log_tags_file): $(event_log_tags_src)
+	$(hide) mkdir -p $(dir $@)
+	$(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
+
+event-log-tags: $(event_log_tags_file)
+
+ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
+
+# -----------------------------------------------------------------
 # Build a keystore with the authorized keys in it, used to verify the
 # authenticity of downloaded OTA packages.
 #
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 64b74e7..8937360 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -186,11 +186,38 @@
 endif
 
 ###########################################################
+## logtags: Add .logtags files to global list, emit java source
+###########################################################
+
+logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES))
+
+ifneq ($(strip $(logtags_sources)),)
+
+event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
+
+# Emit a java source file with constants for the tags, if
+# LOCAL_MODULE_CLASS is "APPS" or "JAVA_LIBRARIES".
+ifneq ($(strip $(filter $(LOCAL_MODULE_CLASS),APPS JAVA_LIBRARIES)),)
+
+logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/src/, $(logtags_sources)))
+logtags_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(logtags_sources))
+
+$(logtags_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.logtags
+	$(transform-logtags-to-java)
+
+endif
+
+else
+logtags_java_sources :=
+event_log_tags :=
+endif
+
+###########################################################
 ## Java: Compile .java files to .class
 ###########################################################
 #TODO: pull this into java.make once host and target are combined
 
-java_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources)
+java_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources)
 all_java_sources := $(java_sources) $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
 
 ## Java resources #########################################
@@ -432,6 +459,8 @@
     $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE)
 ALL_MODULES.$(LOCAL_MODULE).REQUIRED := \
     $(ALL_MODULES.$(LOCAL_MODULE).REQUIRED) $(LOCAL_REQUIRED_MODULES)
+ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS := \
+    $(ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS) $(event_log_tags)
 
 ###########################################################
 ## Take care of LOCAL_MODULE_TAGS
diff --git a/core/build_id.mk b/core/build_id.mk
index 4661aea..64ee0e1 100644
--- a/core/build_id.mk
+++ b/core/build_id.mk
@@ -23,7 +23,7 @@
 # (like "TC1-RC5").  It must be a single word, and is
 # capitalized by convention.
 #
-BUILD_ID := ECLAIR
+BUILD_ID := ECLAIR-MR2
 
 # DISPLAY_BUILD_NUMBER should only be set for development branches,
 # If set, the BUILD_NUMBER (cl) is appended to the BUILD_ID for
diff --git a/core/combo/darwin-x86.mk b/core/combo/darwin-x86.mk
index 2150960..65d6375 100644
--- a/core/combo/darwin-x86.mk
+++ b/core/combo/darwin-x86.mk
@@ -14,6 +14,7 @@
 $(combo_target)GLOBAL_CFLAGS += \
 	-include $(call select-android-config-h,darwin-x86)
 $(combo_target)RUN_RANLIB_AFTER_COPYING := true
+$(combo_target)GLOBAL_ARFLAGS := cqs
 
 ifeq ($(combo_target),TARGET_)
 $(combo_target)CUSTOM_LD_COMMAND := true
diff --git a/core/combo/linux-arm.mk b/core/combo/linux-arm.mk
index 6011351..6529106 100644
--- a/core/combo/linux-arm.mk
+++ b/core/combo/linux-arm.mk
@@ -112,7 +112,7 @@
 $(combo_target)GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
 
 $(combo_target)RELEASE_CFLAGS := \
-			-DSK_RELEASE -DNDEBUG \
+			-DNDEBUG \
 			-g \
 			-Wstrict-aliasing=2 \
 			-finline-functions \
diff --git a/core/combo/select.mk b/core/combo/select.mk
index 793b0a9..ccdf1fb 100644
--- a/core/combo/select.mk
+++ b/core/combo/select.mk
@@ -40,7 +40,7 @@
 $(combo_target)GLOBAL_CFLAGS := -fno-exceptions -Wno-multichar
 $(combo_target)RELEASE_CFLAGS := -O2 -g -fno-strict-aliasing
 $(combo_target)GLOBAL_LDFLAGS :=
-$(combo_target)GLOBAL_ARFLAGS := crs
+$(combo_target)GLOBAL_ARFLAGS := crsP
 
 $(combo_target)EXECUTABLE_SUFFIX := 
 $(combo_target)SHLIB_SUFFIX := .so
diff --git a/core/config.mk b/core/config.mk
index e574124..586f403 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -201,6 +201,7 @@
 E2FSCK := e2fsck
 JARJAR := java -jar $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
 PROGUARD := external/proguard/bin/proguard.sh
+JAVATAGS := build/tools/java-event-log-tags.py
 
 # dx is java behind a shell script; no .exe necessary.
 DX := $(HOST_OUT_EXECUTABLES)/dx
@@ -295,7 +296,6 @@
 
 PREBUILT_IS_PRESENT := $(if $(wildcard prebuilt/Android.mk),true)
 
-
 # ###############################################################
 # Collect a list of the SDK versions that we could compile against
 # For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
diff --git a/core/definitions.mk b/core/definitions.mk
index 3221525..61bd562 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -717,6 +717,16 @@
 #$(AIDL) $(PRIVATE_AIDL_FLAGS) $< - | indent -nut -br -npcs -l1000 > $@
 
 
+###########################################################
+## Commands for running java-event-log-tags.py
+###########################################################
+
+define transform-logtags-to-java
+@mkdir -p $(dir $@)
+@echo "logtags: $@ <= $<"
+$(hide) $(JAVATAGS) -o $@ $<
+endef
+
 
 ###########################################################
 ## Commands for running gcc to compile a C++ file
@@ -931,7 +941,7 @@
 @rm -f $@
 $(extract-and-include-whole-static-libs)
 @echo "target StaticLib: $(PRIVATE_MODULE) ($@)"
-$(hide) $(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $^
+$(hide) echo $^ | xargs $(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@
 endef
 
 ###########################################################
@@ -944,7 +954,7 @@
 @mkdir -p $(dir $@)
 @echo "host StaticLib: $(PRIVATE_MODULE) ($@)"
 @rm -f $@
-$(HOST_AR) $(HOST_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $^
+echo $^ | xargs $(HOST_AR) $(HOST_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@
 endef
 
 
diff --git a/core/main.mk b/core/main.mk
index f618194..0fce663 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -392,7 +392,6 @@
 	development/apps \
 	development/tools/mkstubs \
 	frameworks/base/tools/layoutlib \
-	external/googleclient \
 	packages
 else
 $(warning sdk-only: javac not available.)
@@ -736,4 +735,3 @@
 .PHONY: showcommands
 showcommands:
 	@echo >/dev/null
-
diff --git a/core/pathmap.mk b/core/pathmap.mk
index 1ae663d..bc2fcb4 100644
--- a/core/pathmap.mk
+++ b/core/pathmap.mk
@@ -72,6 +72,11 @@
 # A list of all source roots under frameworks/base, which will be
 # built into the android.jar.
 #
+# Note - "common" is included here, even though it is also built
+# into a static library (android-common) for unbundled use.  This
+# is so common and the other framework libraries can have mutual
+# interdependencies.
+#
 FRAMEWORKS_BASE_SUBDIRS := \
 	$(addsuffix /java, \
 	    core \
@@ -84,6 +89,7 @@
 	    wifi \
 	    vpn \
 	    keystore \
+	    common \
 	 )
 
 #
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 33d7761..f2f62b0 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -41,7 +41,7 @@
   # which is the version that we reveal to the end user.
   # Update this value when the platform version changes (rather
   # than overriding it somewhere else).  Can be an arbitrary string.
-  PLATFORM_VERSION := 2.1
+  PLATFORM_VERSION := Eclair-MR2
 endif
 
 ifeq "" "$(PLATFORM_SDK_VERSION)"
@@ -59,7 +59,7 @@
 ifeq "" "$(PLATFORM_VERSION_CODENAME)"
   # This is the current development code-name, if the build is not a final
   # release build.  If this is a final release build, it is simply "REL".
-  PLATFORM_VERSION_CODENAME := REL
+  PLATFORM_VERSION_CODENAME := Eclair-MR2
 endif
 
 ifeq "" "$(DEFAULT_APP_TARGET_SDK)"
diff --git a/target/product/generic_with_google.mk b/target/product/generic_with_google.mk
index ba30f15..e69303d 100644
--- a/target/product/generic_with_google.mk
+++ b/target/product/generic_with_google.mk
@@ -13,8 +13,7 @@
 
 PRODUCT_COPY_FILES := \
     vendor/google/frameworks/maps/com.google.android.maps.xml:system/etc/permissions/com.google.android.maps.xml \
-    vendor/google/frameworks/datamessaging/com.google.android.datamessaging.xml:system/etc/permissions/com.google.android.datamessaging.xml \
-    vendor/google/apps/GTalkService/com.google.android.gtalkservice.xml:system/etc/permissions/com.google.android.gtalkservice.xml
+    vendor/google/frameworks/datamessaging/com.google.android.datamessaging.xml:system/etc/permissions/com.google.android.datamessaging.xml
 
 
 $(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk)
diff --git a/target/product/security/README b/target/product/security/README
index b92693d..24f984c 100644
--- a/target/product/security/README
+++ b/target/product/security/README
@@ -1,13 +1,9 @@
-The following commands were used to generate the test key pair:
+The following commands were used to generate the test key pairs:
 
-  openssl genrsa -3 -out testkey.pem 2048
-
-  openssl req -new -x509 -key testkey.pem -out testkey.x509.pem -days 10000 \
-    -subj '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
-
-  openssl pkcs8 -in testkey.pem -topk8 -outform DER -out testkey.pk8 -nocrypt
-
-Alternatively you can use the "mkkey.sh" command included in this directory.
+  development/tools/make_key testkey  '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
+  development/tools/make_key platform '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
+  development/tools/make_key shared   '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
+  development/tools/make_key media    '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
 
 The following standard test keys are currently included:
 
@@ -28,11 +24,11 @@
    % openssl pkcs8 -inform DER -nocrypt -in testkey.pk8 -out testkey.pem
 
 2. create a signature using the pem format key
-   % openssl dgst -binary -sha1 -sign testkey.pem FILE > FILE.sig 
+   % openssl dgst -binary -sha1 -sign testkey.pem FILE > FILE.sig
 
 extracting public keys for embedding
 ------------------------------------
 it's a Java tool
 but it generates C code
 take a look at commands/recovery/Android.mk
-you'll see it running $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
\ No newline at end of file
+you'll see it running $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
diff --git a/target/product/security/mkkey.sh b/target/product/security/mkkey.sh
deleted file mode 100644
index 86744f6..0000000
--- a/target/product/security/mkkey.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-if ["$1" == ""]; then
-	echo "Create a test certificate key."
-	echo "Usage: $0 NAME"
-	echo "Will generate NAME.pk8 and NAME.x509.pem"
-	echo "  /C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com"
-	return
-fi
-
-openssl genrsa -3 -out $1.pem 2048
-
-openssl req -new -x509 -key $1.pem -out $1.x509.pem -days 10000 \
-    -subj '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
-
-openssl pkcs8 -in $1.pem -topk8 -outform DER -out $1.pk8 -nocrypt
-
diff --git a/tools/event_log_tags.py b/tools/event_log_tags.py
new file mode 100644
index 0000000..fc05aff
--- /dev/null
+++ b/tools/event_log_tags.py
@@ -0,0 +1,112 @@
+# Copyright (C) 2009 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 module for reading and parsing event-log-tags files."""
+
+import re
+import sys
+
+class Tag(object):
+  __slots__ = ["tagnum", "tagname", "description", "filename", "linenum"]
+
+  def __init__(self, tagnum, tagname, description, filename, linenum):
+    self.tagnum = tagnum
+    self.tagname = tagname
+    self.description = description
+    self.filename = filename
+    self.linenum = linenum
+
+
+class TagFile(object):
+  """Read an input event-log-tags file."""
+  def AddError(self, msg, linenum=None):
+    if linenum is None:
+      linenum = self.linenum
+    self.errors.append((self.filename, linenum, msg))
+
+  def AddWarning(self, msg, linenum=None):
+    if linenum is None:
+      linenum = self.linenum
+    self.warnings.append((self.filename, linenum, msg))
+
+  def __init__(self, filename, file_object=None):
+    """'filename' is the name of the file (included in any error
+    messages).  If 'file_object' is None, 'filename' will be opened
+    for reading."""
+    self.errors = []
+    self.warnings = []
+    self.tags = []
+    self.options = {}
+
+    self.filename = filename
+    self.linenum = 0
+
+    if file_object is None:
+      try:
+        file_object = open(filename, "rb")
+      except (IOError, OSError), e:
+        self.AddError(str(e))
+        return
+
+    try:
+      for self.linenum, line in enumerate(file_object):
+        self.linenum += 1
+
+        line = line.strip()
+        if not line or line[0] == '#': continue
+        parts = re.split(r"\s+", line, 2)
+
+        if len(parts) < 2:
+          self.AddError("failed to parse \"%s\"" % (line,))
+          continue
+
+        if parts[0] == "option":
+          self.options[parts[1]] = parts[2:]
+          continue
+
+        try:
+          tag = int(parts[0])
+        except ValueError:
+          self.AddError("\"%s\" isn't an integer tag" % (parts[0],))
+          continue
+
+        tagname = parts[1]
+        if len(parts) == 3:
+          description = parts[2]
+        else:
+          description = None
+
+        self.tags.append(Tag(tag, tagname, description,
+                             self.filename, self.linenum))
+    except (IOError, OSError), e:
+      self.AddError(str(e))
+
+
+def WriteOutput(output_file, data):
+  """Write 'data' to the given output filename (which may be None to
+  indicate stdout).  Emit an error message and die on any failure.
+  'data' may be a string or a StringIO object."""
+  if not isinstance(data, str):
+    data = data.getvalue()
+  try:
+    if output_file is None:
+      out = sys.stdout
+      output_file = "<stdout>"
+    else:
+      out = open(output_file, "wb")
+    out.write(data)
+    out.close()
+  except (IOError, OSError), e:
+    print >> sys.stderr, "failed to write %s: %s" % (output_file, e)
+    sys.exit(1)
diff --git a/tools/java-event-log-tags.py b/tools/java-event-log-tags.py
new file mode 100755
index 0000000..f8374b0
--- /dev/null
+++ b/tools/java-event-log-tags.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2009 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.
+
+"""
+Usage: java-event-log-tags.py [-o output_file] <input_file>
+
+Generate a java class containing constants for each of the event log
+tags in the given input file.
+
+-h to display this usage message and exit.
+"""
+
+import cStringIO
+import getopt
+import os
+import sys
+
+import event_log_tags
+
+output_file = None
+
+try:
+  opts, args = getopt.getopt(sys.argv[1:], "ho:")
+except getopt.GetoptError, err:
+  print str(err)
+  print __doc__
+  sys.exit(2)
+
+for o, a in opts:
+  if o == "-h":
+    print __doc__
+    sys.exit(2)
+  elif o == "-o":
+    output_file = a
+  else:
+    print >> sys.stderr, "unhandled option %s" % (o,)
+    sys.exit(1)
+
+if len(args) != 1:
+  print "need exactly one input file, not %d" % (len(args),)
+  print __doc__
+  sys.exit(1)
+
+fn = args[0]
+tagfile = event_log_tags.TagFile(fn)
+
+if "java_package" not in tagfile.options:
+  tagfile.AddError("java_package option not specified", linenum=0)
+
+if tagfile.errors:
+  for fn, ln, msg in tagfile.errors:
+    print >> sys.stderr, "%s:%d: error: %s" % (fn, ln, msg)
+  sys.exit(1)
+
+buffer = cStringIO.StringIO()
+buffer.write("/* This file is auto-generated.  DO NOT MODIFY.\n"
+             " * Source file: %s\n"
+             " */\n\n" % (fn,))
+
+buffer.write("package %s;\n\n" % (tagfile.options["java_package"][0],))
+
+basename, _ = os.path.splitext(os.path.basename(fn))
+buffer.write("public class %s {\n" % (basename,))
+buffer.write("  private %s() { }  // don't instantiate\n" % (basename,))
+
+for t in tagfile.tags:
+  if t.description:
+    buffer.write("\n  /** %d %s %s */\n" % (t.tagnum, t.tagname, t.description))
+  else:
+    buffer.write("\n  /** %d %s */\n" % (t.tagnum, t.tagname))
+
+  buffer.write("  public static final int %s = %d;\n" %
+               (t.tagname.upper(), t.tagnum))
+buffer.write("}\n");
+
+event_log_tags.WriteOutput(output_file, buffer)
diff --git a/tools/merge-event-log-tags.py b/tools/merge-event-log-tags.py
new file mode 100755
index 0000000..2852612
--- /dev/null
+++ b/tools/merge-event-log-tags.py
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2009 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.
+
+"""
+Usage: merge-event-log-tags.py [-o output_file] [input_files...]
+
+Merge together zero or more event-logs-tags files to produce a single
+output file, stripped of comments.  Checks that no tag numbers conflict
+and fails if they do.
+
+-h to display this usage message and exit.
+"""
+
+import cStringIO
+import getopt
+import sys
+
+import event_log_tags
+
+by_tagnum = {}
+errors = []
+warnings = []
+
+output_file = None
+
+try:
+  opts, args = getopt.getopt(sys.argv[1:], "ho:")
+except getopt.GetoptError, err:
+  print str(err)
+  print __doc__
+  sys.exit(2)
+
+for o, a in opts:
+  if o == "-h":
+    print __doc__
+    sys.exit(2)
+  elif o == "-o":
+    output_file = a
+  else:
+    print >> sys.stderr, "unhandled option %s" % (o,)
+    sys.exit(1)
+
+for fn in args:
+  tagfile = event_log_tags.TagFile(fn)
+
+  for t in tagfile.tags:
+    tagnum = t.tagnum
+    tagname = t.tagname
+    description = t.description
+
+    if t.tagnum in by_tagnum:
+      orig = by_tagnum[t.tagnum]
+
+      if (t.tagname == orig.tagname and
+          t.description == orig.description):
+        # if the name and description are identical, issue a warning
+        # instead of failing (to make it easier to move tags between
+        # projects without breaking the build).
+        tagfile.AddWarning("tag %d \"%s\" duplicated in %s:%d" %
+                           (t.tagnum, t.tagname, orig.filename, orig.linenum),
+                           linenum=t.linenum)
+      else:
+        tagfile.AddError("tag %d used by conflicting \"%s\" from %s:%d" %
+                         (t.tagnum, orig.tagname, orig.filename, orig.linenum),
+                         linenum=t.linenum)
+      continue
+
+    by_tagnum[t.tagnum] = t
+
+  errors.extend(tagfile.errors)
+  warnings.extend(tagfile.warnings)
+
+if errors:
+  for fn, ln, msg in errors:
+    print >> sys.stderr, "%s:%d: error: %s" % (fn, ln, msg)
+  sys.exit(1)
+
+if warnings:
+  for fn, ln, msg in warnings:
+    print >> sys.stderr, "%s:%d: warning: %s" % (fn, ln, msg)
+
+buffer = cStringIO.StringIO()
+for n in sorted(by_tagnum):
+  t = by_tagnum[n]
+  if t.description:
+    buffer.write("%d %s %s\n" % (t.tagnum, t.tagname, t.description))
+  else:
+    buffer.write("%d %s\n" % (t.tagnum, t.tagname))
+
+event_log_tags.WriteOutput(output_file, buffer)