diff options
| -rw-r--r-- | core/java/com/android/internal/content/NativeLibraryHelper.java | 30 | ||||
| -rw-r--r-- | services/java/com/android/server/PackageManagerService.java | 40 |
2 files changed, 33 insertions, 37 deletions
diff --git a/core/java/com/android/internal/content/NativeLibraryHelper.java b/core/java/com/android/internal/content/NativeLibraryHelper.java index 8b618c7eb0bd..6e11cff2c208 100644 --- a/core/java/com/android/internal/content/NativeLibraryHelper.java +++ b/core/java/com/android/internal/content/NativeLibraryHelper.java @@ -293,4 +293,34 @@ public class NativeLibraryHelper { inputStream.close(); } } + + // Remove the native binaries of a given package. This simply + // gets rid of the files in the 'lib' sub-directory. + public static void removeNativeBinariesLI(String nativeLibraryPath) { + if (DEBUG_NATIVE) { + Slog.w(TAG, "Deleting native binaries from: " + nativeLibraryPath); + } + + /* + * Just remove any file in the directory. Since the directory is owned + * by the 'system' UID, the application is not supposed to have written + * anything there. + */ + File binaryDir = new File(nativeLibraryPath); + if (binaryDir.exists()) { + File[] binaries = binaryDir.listFiles(); + if (binaries != null) { + for (int nn = 0; nn < binaries.length; nn++) { + if (DEBUG_NATIVE) { + Slog.d(TAG, " Deleting " + binaries[nn].getName()); + } + if (!binaries[nn].delete()) { + Slog.w(TAG, "Could not delete native binary: " + binaries[nn].getPath()); + } + } + } + // Do not delete 'lib' directory itself, or this will prevent + // installation of future updates. + } + } } diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java index 001d98e4f1a3..685bee4857a3 100644 --- a/services/java/com/android/server/PackageManagerService.java +++ b/services/java/com/android/server/PackageManagerService.java @@ -3598,40 +3598,6 @@ class PackageManagerService extends IPackageManager.Stub { } } - // Convenience call for removeNativeBinariesLI(File) - private void removeNativeBinariesLI(PackageParser.Package pkg) { - File nativeLibraryDir = getNativeBinaryDirForPackage(pkg); - removeNativeBinariesLI(nativeLibraryDir); - } - - // Remove the native binaries of a given package. This simply - // gets rid of the files in the 'lib' sub-directory. - public void removeNativeBinariesLI(File binaryDir) { - if (DEBUG_NATIVE) { - Slog.w(TAG, "Deleting native binaries from: " + binaryDir.getPath()); - } - - // Just remove any file in the directory. Since the directory - // is owned by the 'system' UID, the application is not supposed - // to have written anything there. - // - if (binaryDir.exists()) { - File[] binaries = binaryDir.listFiles(); - if (binaries != null) { - for (int nn = 0; nn < binaries.length; nn++) { - if (DEBUG_NATIVE) { - Slog.d(TAG, " Deleting " + binaries[nn].getName()); - } - if (!binaries[nn].delete()) { - Slog.w(TAG, "Could not delete native binary: " + binaries[nn].getPath()); - } - } - } - // Do not delete 'lib' directory itself, or this will prevent - // installation of future updates. - } - } - void removePackageLI(PackageParser.Package pkg, boolean chatty) { if (chatty && Config.LOGD) Log.d( TAG, "Removing package " + pkg.applicationInfo.packageName ); @@ -5135,7 +5101,7 @@ class PackageManagerService extends IPackageManager.Stub { } } if (libraryPath != null) { - removeNativeBinariesLI(new File(libraryPath)); + NativeLibraryHelper.removeNativeBinariesLI(libraryPath); } } @@ -6209,8 +6175,8 @@ class PackageManagerService extends IPackageManager.Stub { synchronized (mPackages) { // Reinstate the old system package mSettings.enableSystemPackageLP(p.packageName); - // Remove any native libraries. XXX needed? - removeNativeBinariesLI(p); + // Remove any native libraries from the upgraded package. + NativeLibraryHelper.removeNativeBinariesLI(p.applicationInfo.nativeLibraryDir); } // Install the system package PackageParser.Package newPkg = scanPackageLI(ps.codePath, |