Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e68d58a2 authored by Kenny Root's avatar Kenny Root
Browse files

Don't symlink native library paths for old apps

Apps that existed in an ASEC container before we put native libraries
in the ASEC container will have their native libraries in the
/data/data/<app>/lib directory. Don't try to symlink to the ASEC
container's library directory in this case.

Bug: 3108230
Change-Id: I32167341cc8ff8c005e50f456ee7c783bfb0bf22
parent 1f90908c
Loading
Loading
Loading
Loading
+18 −7
Original line number Original line Diff line number Diff line
@@ -3286,7 +3286,9 @@ class PackageManagerService extends IPackageManager.Stub {
             *        only for non-system apps and system app upgrades.
             *        only for non-system apps and system app upgrades.
             */
             */
            if (pkg.applicationInfo.nativeLibraryDir != null) {
            if (pkg.applicationInfo.nativeLibraryDir != null) {
                final File sharedLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir);
                final File nativeLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir);
                final String dataPathString = dataPath.getPath();

                if (isSystemApp(pkg) && !isUpdatedSystemApp(pkg)) {
                if (isSystemApp(pkg) && !isUpdatedSystemApp(pkg)) {
                    /*
                    /*
                     * Upgrading from a previous version of the OS sometimes
                     * Upgrading from a previous version of the OS sometimes
@@ -3295,15 +3297,24 @@ class PackageManagerService extends IPackageManager.Stub {
                     * Recent changes in the JNI library search path
                     * Recent changes in the JNI library search path
                     * necessitates we remove those to match previous behavior.
                     * necessitates we remove those to match previous behavior.
                     */
                     */
                    if (NativeLibraryHelper.removeNativeBinariesFromDirLI(sharedLibraryDir)) {
                    if (NativeLibraryHelper.removeNativeBinariesFromDirLI(nativeLibraryDir)) {
                        Log.i(TAG, "removed obsolete native libraries for system package " + path);
                        Log.i(TAG, "removed obsolete native libraries for system package " + path);
                    }
                    }
                } else if (!isExternal(pkg)) {
                } else if (nativeLibraryDir.getParent().equals(dataPathString)) {
                    Log.i(TAG, path + " changed; unpacking");
                    /*
                    mInstaller.unlinkNativeLibraryDirectory(dataPath.getPath());
                     * If this is an internal application or our
                    NativeLibraryHelper.copyNativeBinariesLI(scanFile, sharedLibraryDir);
                     * nativeLibraryPath points to our data directory, unpack
                     * the libraries. The native library path pointing to the
                     * data directory for an application in an ASEC container
                     * can happen for older apps that existed before an OTA to
                     * Gingerbread.
                     */
                    Slog.i(TAG, "Unpacking native libraries for " + path);
                    mInstaller.unlinkNativeLibraryDirectory(dataPathString);
                    NativeLibraryHelper.copyNativeBinariesLI(scanFile, nativeLibraryDir);
                } else {
                } else {
                    mInstaller.linkNativeLibraryDirectory(dataPath.getPath(),
                    Slog.i(TAG, "Linking native library dir for " + path);
                    mInstaller.linkNativeLibraryDirectory(dataPathString,
                            pkg.applicationInfo.nativeLibraryDir);
                            pkg.applicationInfo.nativeLibraryDir);
                }
                }
            }
            }