Always embed jni libs and store uncompressed
Previously, unlike unbundled apps, if a platform app depends on a native library, it is not embedded in the app, but installed to <partition>/lib and the app is instead provided with a symlink to the lib. This actualy is a legacy from the original Android where native libraries couldn't be executed while embedded in the apk. To be executed, the native libs had to be extracted to a mutable storage, but that had a risk of breaking the verified boot, so libs couldn't be embedded. Since API level 23, execute-in-place of native libs has become possible. But platform apps had to opt-in (use_embedded_native_libs: true) for the feature for a reason that is unclear today. Perhaps, it was to save disk space in case when multiple apps share the same native library, but such cases are found to be very rare, or non-existing. With this CL, two changes are introduced: 1. jni libs are always embededd for all apps (bundled or unbundled) 2. use_embedded_native_libs is deprecated unless the module type is android_test or android_test_helper_app. It is now a no-op property. It's left just to not break existing bp files. This will make unbundled apps bigger, but given that unbundled apps built using android platform build system are tests, the size increase should be acceptible. Bug: 330276359 Test: m Change-Id: I7df993ea85bce1c0a7222000c403a974818c3362
This commit is contained in:
@@ -62,8 +62,8 @@ def parse_args():
|
||||
'in the manifest.'))
|
||||
parser.add_argument('--extract-native-libs', dest='extract_native_libs',
|
||||
default=None, type=lambda x: (str(x).lower() == 'true'),
|
||||
help=('specify if the app wants to use embedded native libraries. Must not conflict '
|
||||
'if already declared in the manifest.'))
|
||||
help=('specify if the app wants to use embedded native libraries. Must not '
|
||||
'be true if manifest says false.'))
|
||||
parser.add_argument('--has-no-code', dest='has_no_code', action='store_true',
|
||||
help=('adds hasCode="false" attribute to application. Ignored if application elem '
|
||||
'already has a hasCode attribute.'))
|
||||
@@ -299,7 +299,16 @@ def add_extract_native_libs(doc, extract_native_libs):
|
||||
attr = doc.createAttributeNS(android_ns, 'android:extractNativeLibs')
|
||||
attr.value = value
|
||||
application.setAttributeNode(attr)
|
||||
elif attr.value != value:
|
||||
elif attr.value == "false" and value == "true":
|
||||
# Note that we don't disallow the case of extractNativeLibs="true" in manifest and
|
||||
# --extract-native-libs="false". This is fine because --extract-native-libs="false" means that
|
||||
# the build system didn't compress the JNI libs, which is a fine choice for built-in apps. At
|
||||
# runtime the JNI libs will be extracted to outside of the APK, but everything will still work
|
||||
# okay.
|
||||
#
|
||||
# The opposite (extractNativeLibs="false" && --extract-native-libs="true") should however be
|
||||
# disallowed because otherwise that would make an ill-formed APK; JNI libs are stored compressed
|
||||
# but they won't be extracted. There's no way to execute the JNI libs.
|
||||
raise RuntimeError('existing attribute extractNativeLibs="%s" conflicts with --extract-native-libs="%s"' %
|
||||
(attr.value, value))
|
||||
|
||||
|
@@ -479,8 +479,8 @@ class AddExtractNativeLibsTest(unittest.TestCase):
|
||||
self.assert_xml_equal(output, expected)
|
||||
|
||||
def test_conflict(self):
|
||||
manifest_input = self.manifest_tmpl % self.extract_native_libs('true')
|
||||
self.assertRaises(RuntimeError, self.run_test, manifest_input, False)
|
||||
manifest_input = self.manifest_tmpl % self.extract_native_libs('false')
|
||||
self.assertRaises(RuntimeError, self.run_test, manifest_input, True)
|
||||
|
||||
|
||||
class AddNoCodeApplicationTest(unittest.TestCase):
|
||||
|
Reference in New Issue
Block a user