Only align when necessary
Bug: 27887819
Change-Id: Ie8b5ca31cc1c08943588fc6039d75190ff7eeb8b
diff --git a/core/definitions.mk b/core/definitions.mk
index 34b9385..070d6d7 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2469,13 +2469,15 @@
# Align STORED entries of a package on 4-byte boundaries to make them easier to mmap.
#
define align-package
-$(hide) mv $@ $@.unaligned
-$(hide) $(ZIPALIGN) \
+$(hide) if ! $(ZIPALIGN) -c $(ZIPALIGN_PAGE_ALIGN_FLAGS) 4 $@ >/dev/null ; then \
+ mv $@ $@.unaligned; \
+ $(ZIPALIGN) \
-f \
$(ZIPALIGN_PAGE_ALIGN_FLAGS) \
4 \
- $@.unaligned $@.aligned
-$(hide) mv $@.aligned $@
+ $@.unaligned $@.aligned; \
+ mv $@.aligned $@; \
+ fi
endef
# Remove dynamic timestamps from packages