Support LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES for prebuilt APKs

If a prebuilt APK contains shared libraries and the flag
LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES := true is set, then
uncompress any shared libraries stored within the APK.
This allows processes to load the shared library directly from
the APK.

Bug: 20247329
Bug: 8076853
Bug: 1162500
Change-Id: Iac4db32457d9ce31eb7256410023819b44fda0a6
This commit is contained in:
Nick Kralevich
2015-04-17 16:53:15 -07:00
parent b687444051
commit 5aa0223c6a
2 changed files with 13 additions and 0 deletions

View File

@@ -1944,6 +1944,16 @@ $(hide) $(ZIPALIGN) \
$(hide) mv $@.aligned $@
endef
define uncompress-shared-libs
$(hide) rm -rf $(dir $@)/tmpworkdir
$(hide) mv $@ $@.compressed
$(hide) mkdir $(dir $@)/tmpworkdir
$(hide) unzip $@.compressed 'lib/*.so' -d $(dir $@)/tmpworkdir
$(hide) ( cd $(dir $@)/tmpworkdir && zip -D -r -0 ../$(notdir $@).compressed lib )
$(hide) mv $@.compressed $@
$(hide) rm -rf $(dir $@)/tmpworkdir
endef
define install-dex-debug
$(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.dex" ]; then \
mkdir -p $(TOP)/dalvik/DEBUG-FILES; \

View File

@@ -204,6 +204,9 @@ ifneq (nostripping,$(LOCAL_DEX_PREOPT))
endif
endif
$(sign-package)
endif
ifeq ($(LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES),true)
$(uncompress-shared-libs)
endif
$(align-package)