Merge "Add 'adb shell telecom' command to packages list" into mnc-dev
diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk
index 0819d13..3acddc5 100644
--- a/core/combo/TARGET_linux-arm64.mk
+++ b/core/combo/TARGET_linux-arm64.mk
@@ -114,6 +114,7 @@
 			-Wl,--fatal-warnings \
 			-Wl,-maarch64linux \
 			-Wl,--hash-style=gnu \
+			-Wl,--fix-cortex-a53-843419 \
 			$(arch_variant_ldflags)
 
 # Disable transitive dependency library symbol resolving.
diff --git a/core/definitions.mk b/core/definitions.mk
index 6e3aa2b..6b9abd8 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1798,7 +1798,6 @@
 # - below we write the list of java files to java-source-list to avoid argument
 #   list length problems with Cygwin
 # - we filter out duplicate java file names because Jack doesn't like them.
-# TODO (yroussel) PRIVATE_RMTYPEDEFS
 define jack-java-to-dex
 $(hide) rm -f $@
 $(hide) rm -f $(PRIVATE_CLASSES_JACK)
@@ -1833,6 +1832,8 @@
     $(strip $(PRIVATE_JACK_DEBUG_FLAGS)) \
     $(if $(NO_OPTIMIZE_DX), \
         -D jack.dex.optimize="false") \
+    $(if $(PRIVATE_RMTYPEDEFS), \
+        -D jack.android.remove-typedef="true") \
     $(addprefix --classpath ,$(strip \
         $(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES) $(PRIVATE_ALL_JACK_LIBRARIES)))) \
     $(addprefix --import ,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES))) \
diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk
index ff5ee1e..4814d70 100644
--- a/core/host_dalvik_java_library.mk
+++ b/core/host_dalvik_java_library.mk
@@ -63,6 +63,7 @@
 	PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes
 $(LOCAL_INTERMEDIATE_TARGETS): \
 	PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS :=
 
 $(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
 
@@ -71,7 +72,6 @@
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
 $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
-$(full_classes_compiled_jar): PRIVATE_RMTYPEDEFS :=
 $(full_classes_compiled_jar): \
         $(java_sources) \
         $(java_resource_sources) \
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
index 513d185..47189d7 100644
--- a/core/host_java_library.mk
+++ b/core/host_java_library.mk
@@ -43,6 +43,8 @@
 include $(BUILD_SYSTEM)/base_rules.mk
 #######################################
 
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS :=
+
 ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
 $(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILE := $(intermediates.COMMON)/coverage.em
 $(full_classes_emma_jar): PRIVATE_EMMA_INTERMEDIATES_DIR := $(emma_intermediates_dir)
@@ -78,7 +80,6 @@
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
 $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
-$(full_classes_compiled_jar): PRIVATE_RMTYPEDEFS :=
 $(full_classes_compiled_jar): \
         $(java_sources) \
         $(java_resource_sources) \
diff --git a/core/java.mk b/core/java.mk
index 66993e7..ae4a602 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -330,6 +330,7 @@
 	PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes
 $(LOCAL_INTERMEDIATE_TARGETS): \
 	PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS := $(LOCAL_RMTYPEDEFS)
 
 # Since we're using intermediates.COMMON, make sure that it gets cleaned
 # properly.
@@ -369,7 +370,6 @@
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES)
 $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES)
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := $(LOCAL_JAR_EXCLUDE_PACKAGES)
-$(full_classes_compiled_jar): PRIVATE_RMTYPEDEFS := $(LOCAL_RMTYPEDEFS)
 $(full_classes_compiled_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
 $(full_classes_compiled_jar): \
         $(java_sources) \
diff --git a/target/board/generic/sepolicy/goldfish_logcat.te b/target/board/generic/sepolicy/goldfish_logcat.te
deleted file mode 100644
index f820c2a..0000000
--- a/target/board/generic/sepolicy/goldfish_logcat.te
+++ /dev/null
@@ -1,10 +0,0 @@
-# goldfish-logcat service:  runs logcat -Q
-type goldfish_logcat, domain;
-
-domain_auto_trans(init, logcat_exec, goldfish_logcat)
-
-# Read from logd.
-read_logd(goldfish_logcat)
-
-# Write to /dev/ttyS2 and /dev/ttyGF2.
-allow goldfish_logcat serial_device:chr_file { write open };
diff --git a/target/board/generic/sepolicy/logd.te b/target/board/generic/sepolicy/logd.te
new file mode 100644
index 0000000..b3e60d7
--- /dev/null
+++ b/target/board/generic/sepolicy/logd.te
@@ -0,0 +1,11 @@
+# goldfish logcat service:  runs logcat -Q in logd domain
+
+# See global logd.te, these only set for eng & userdebug, allow for all builds
+
+domain_auto_trans(init, logcat_exec, logd)
+
+# Read from logd.
+read_logd(logd)
+
+# Write to /dev/ttyS2 and /dev/ttyGF2.
+allow logd serial_device:chr_file { write open };
diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py
index 0a387ec..3402572 100644
--- a/tools/releasetools/blockimgdiff.py
+++ b/tools/releasetools/blockimgdiff.py
@@ -74,7 +74,7 @@
   def ReadRangeSet(self, ranges):
     raise NotImplementedError
 
-  def TotalSha1(self):
+  def TotalSha1(self, include_clobbered_blocks=False):
     raise NotImplementedError
 
 
@@ -87,7 +87,10 @@
   file_map = {}
   def ReadRangeSet(self, ranges):
     return ()
-  def TotalSha1(self):
+  def TotalSha1(self, include_clobbered_blocks=False):
+    # EmptyImage always carries empty clobbered_blocks, so
+    # include_clobbered_blocks can be ignored.
+    assert self.clobbered_blocks.size() == 0
     return sha1().hexdigest()
 
 
@@ -136,8 +139,9 @@
   def ReadRangeSet(self, ranges):
     return [self.data[s*self.blocksize:e*self.blocksize] for (s, e) in ranges]
 
-  def TotalSha1(self):
-    # DataImage always carries empty clobbered_blocks.
+  def TotalSha1(self, include_clobbered_blocks=False):
+    # DataImage always carries empty clobbered_blocks, so
+    # include_clobbered_blocks can be ignored.
     assert self.clobbered_blocks.size() == 0
     return sha1(self.data).hexdigest()
 
@@ -201,7 +205,8 @@
 #
 #    TotalSha1(): a function that returns (as a hex string) the SHA-1
 #      hash of all the data in the image (ie, all the blocks in the
-#      care_map minus clobbered_blocks).
+#      care_map minus clobbered_blocks, or including the clobbered
+#      blocks if include_clobbered_blocks is True).
 #
 # When creating a BlockImageDiff, the src image may be None, in which
 # case the list of transfers produced will never read from the
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 49203ed..c55f94c 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -1183,6 +1183,7 @@
     if progress:
       script.ShowProgress(progress, 0)
     self._WriteUpdate(script, output_zip)
+    self._WritePostInstallVerifyScript(script)
 
   def WriteVerifyScript(self, script):
     partition = self.partition
@@ -1221,6 +1222,21 @@
       script.AppendExtra(('abort("%s partition has unexpected contents");\n'
                           'endif;') % (partition,))
 
+  def _WritePostInstallVerifyScript(self, script):
+    partition = self.partition
+    script.Print('Verifying the updated %s image...' % (partition,))
+    # Unlike pre-install verification, clobbered_blocks should not be ignored.
+    ranges = self.tgt.care_map
+    ranges_str = ranges.to_string_raw()
+    script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' % (
+                       self.device, ranges_str,
+                       self.tgt.TotalSha1(include_clobbered_blocks=True)))
+    script.Print('Verified the updated %s image.' % (partition,))
+    script.AppendExtra(
+        'else\n'
+        '  abort("%s partition has unexpected contents after OTA update");\n'
+        'endif;' % (partition,))
+
   def _WriteUpdate(self, script, output_zip):
     ZipWrite(output_zip,
              '{}.transfer.list'.format(self.path),
diff --git a/tools/releasetools/sparse_img.py b/tools/releasetools/sparse_img.py
index 2ac97ac..51a1643 100644
--- a/tools/releasetools/sparse_img.py
+++ b/tools/releasetools/sparse_img.py
@@ -118,11 +118,16 @@
   def ReadRangeSet(self, ranges):
     return [d for d in self._GetRangeData(ranges)]
 
-  def TotalSha1(self):
-    """Return the SHA-1 hash of all data in the 'care' regions but not in
-    clobbered_blocks of this image."""
+  def TotalSha1(self, include_clobbered_blocks=False):
+    """Return the SHA-1 hash of all data in the 'care' regions.
+
+    If include_clobbered_blocks is True, it returns the hash including the
+    clobbered_blocks."""
+    ranges = self.care_map
+    if not include_clobbered_blocks:
+      ranges.subtract(self.clobbered_blocks)
     h = sha1()
-    for d in self._GetRangeData(self.care_map.subtract(self.clobbered_blocks)):
+    for d in self._GetRangeData(ranges):
       h.update(d)
     return h.hexdigest()