Merge "Check PRODUCT_BOOT_JARS against a whitelist of package names." into lmp-dev
diff --git a/core/binary.mk b/core/binary.mk
index 8ab63e4..d339317 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -408,6 +408,8 @@
 # This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
 renderscript_flags := -Wall -Werror
 renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
+# -m32 or -m64
+renderscript_flags += -m$(my_32_64_bit_suffix)
 
 renderscript_includes := \
     $(TOPDIR)external/clang/lib/Headers \
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 0bb218f..0af3948 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -82,18 +82,15 @@
 			-Werror=format-security \
 			-D_FORTIFY_SOURCE=2 \
 			-Wstrict-aliasing=2 \
-			-fPIC \
 			-ffunction-sections \
 			-finline-functions \
 			-finline-limit=300 \
-			-fno-inline-functions-called-once \
 			-fno-short-enums \
 			-fstrict-aliasing \
 			-funswitch-loops \
 			-funwind-tables \
 			-fstack-protector \
 			-m32 \
-			-msse2 \
 			-no-canonical-prefixes \
 			-fno-canonical-system-headers \
 			-include $(android_config_h) \
diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk
index 14fa5ed..33d6a56 100644
--- a/core/combo/TARGET_linux-x86_64.mk
+++ b/core/combo/TARGET_linux-x86_64.mk
@@ -80,11 +80,9 @@
 			-Werror=format-security \
 			-D_FORTIFY_SOURCE=2 \
 			-Wstrict-aliasing=2 \
-			-fPIC \
 			-ffunction-sections \
 			-finline-functions \
 			-finline-limit=300 \
-			-fno-inline-functions-called-once \
 			-fno-short-enums \
 			-fstrict-aliasing \
 			-funswitch-loops \
diff --git a/core/java.mk b/core/java.mk
index 52d31d0..debdf53 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -386,7 +386,7 @@
 
 # Run proguard if necessary, otherwise just copy the file.
 ifdef LOCAL_PROGUARD_ENABLED
-ifneq ($(filter-out full custom nosystem obfuscation optimization,$(LOCAL_PROGUARD_ENABLED)),)
+ifneq ($(filter-out full custom nosystem obfuscation optimization shrinktests,$(LOCAL_PROGUARD_ENABLED)),)
     $(warning while processing: $(LOCAL_MODULE))
     $(error invalid value for LOCAL_PROGUARD_ENABLED: $(LOCAL_PROGUARD_ENABLED))
 endif
@@ -403,6 +403,9 @@
 # If this is a test package, add proguard keep flags for tests.
 ifneq ($(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS)),)
 proguard_flags += -include $(BUILD_SYSTEM)/proguard_tests.flags
+ifeq ($(filter shrinktests,$(LOCAL_PROGUARD_ENABLED)),)
+proguard_flags += -dontshrink # don't shrink tests by default
+endif # shrinktests
 endif # test package
 ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
 # By default no obfuscation
diff --git a/core/proguard_tests.flags b/core/proguard_tests.flags
index 4481a1b..1f840bc 100644
--- a/core/proguard_tests.flags
+++ b/core/proguard_tests.flags
@@ -1,5 +1,6 @@
 # Keep everything for tests
--dontshrink
+# This flag has been moved to the makefiles and is set for tests by default.
+#-dontshrink
 
 # But we may want to obfuscate if the main app gets obfuscated.
 # This flag has been moved to the makefiles.
diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css
index b3ee207..75d932f 100644
--- a/tools/droiddoc/templates-sdk/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk/assets/css/default.css
@@ -7334,4 +7334,5 @@
 .annotation-message {
     display: block;
     font-style: italic;
-}
\ No newline at end of file
+    color: #F80;
+}
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 92d912b..815c76c 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -30,6 +30,7 @@
 import zipfile
 
 import blockimgdiff
+from rangelib import *
 
 try:
   from hashlib import sha1 as sha1
@@ -1023,10 +1024,11 @@
 
 
 class BlockDifference:
-  def __init__(self, partition, tgt, src=None):
+  def __init__(self, partition, tgt, src=None, check_first_block=False):
     self.tgt = tgt
     self.src = src
     self.partition = partition
+    self.check_first_block = check_first_block
 
     b = blockimgdiff.BlockImageDiff(tgt, src, threads=OPTIONS.worker_threads)
     tmpdir = tempfile.mkdtemp()
@@ -1043,6 +1045,9 @@
       self._WriteUpdate(script, output_zip)
 
     else:
+      if self.check_first_block:
+        self._CheckFirstBlock(script)
+
       script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' %
                          (self.device, self.src.care_map.to_string_raw(),
                           self.src.TotalSha1()))
@@ -1072,6 +1077,18 @@
             (self.device, partition, partition, partition))
     script.AppendExtra(script._WordWrap(call))
 
+  def _CheckFirstBlock(self, script):
+    r = RangeSet((0, 1))
+    h = sha1()
+    for data in self.src.ReadRangeSet(r):
+      h.update(data)
+    h = h.hexdigest()
+
+    script.AppendExtra(('(range_sha1("%s", "%s") == "%s") || '
+                        'abort("%s has been remounted R/W; '
+                        'reflash device to reenable OTA updates");')
+                       % (self.device, r.to_string_raw(), h, self.device))
+
 
 DataImage = blockimgdiff.DataImage
 
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 8b7342b..6f34450 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -731,14 +731,16 @@
 
   system_src = GetImage("system", OPTIONS.source_tmp, OPTIONS.source_info_dict)
   system_tgt = GetImage("system", OPTIONS.target_tmp, OPTIONS.target_info_dict)
-  system_diff = common.BlockDifference("system", system_tgt, system_src)
+  system_diff = common.BlockDifference("system", system_tgt, system_src,
+                                       check_first_block=True)
 
   if HasVendorPartition(target_zip):
     if not HasVendorPartition(source_zip):
       raise RuntimeError("can't generate incremental that adds /vendor")
     vendor_src = GetImage("vendor", OPTIONS.source_tmp, OPTIONS.source_info_dict)
     vendor_tgt = GetImage("vendor", OPTIONS.target_tmp, OPTIONS.target_info_dict)
-    vendor_diff = common.BlockDifference("vendor", vendor_tgt, vendor_src)
+    vendor_diff = common.BlockDifference("vendor", vendor_tgt, vendor_src,
+                                         check_first_block=True)
   else:
     vendor_diff = None