Introduce uses-native-library tag
Since Android 7.0, partners were able to export some of their native shared libraries to apps. So far, the native libraries were provided to all apps regardless of whether they are actually needed or not. Even worse, it was impossible to prevent the installation of an app to the device where the some (or all) of the required native libs don't exist; the apps had to manually handle the case, which sometimes impossible when the dependency is so fundamental. This change introduces a new tag <uses-native-library> to the app manifest. Similary to the existing <uses-library> tag which is for (java) shared libraries, the new tag is used to describe the depedencies to the native shared libraries. Apps targeting Android S or higher are required to use the tag to import the native shared libraries. Libraries that are not depended on won't be available to the app even if the libraries are listed in the public.libraries*.txt files. Furthermore, when the dependency can't be satisfied for an app, the package manager refejects installing the app. The dependency can be optional using the `android:required` attribute. When it is set to true, the absence of the lib on the device doesn't prevent the app from being installed. However, the app has to gracefully deal with the absence. The changed behavior only affects apps targeting S or higher. Existing apps are unaffected; they still get all the public native libraries regardless of whether they have <uses-native-library> tags or not; the tags are simply ignored. This is the first version of the implementation and therefore needs further refinements. The followings are two major TODOs. 1) The native shared lib dependencies of the java shared libraries are not enforced. For example, if an app depends on a java shared library foo and foo depends on some native shared libraries, the classloader where code from foo is loaded still gets all native shared libraries. This should be fixed. 2) New APIs should be added. SharedLibraryInfo should be extended to represent native shared libraries. The meaning of ApplicationInfo.sharedLibraryFiles should be revised. Finally, the new tag should be made public. Bug: 142191088 Test: atest CtsUsesNativeLibraryTest Change-Id: Iceb038aa86872d23e9faf582ae91b1fdcaf5c64c
Loading
Please register or sign in to comment