summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kenny Root <kroot@google.com> 2010-10-05 14:07:29 -0700
committer Android Git Automerger <android-git-automerger@android.com> 2010-10-05 14:07:29 -0700
commitcfc80bd5c1e4f0207357b288b1b7b8374a31ba70 (patch)
treeaf7fec5abe8531cca78b7a9a0cbf972b1ca0f00d
parent56364bcd0d1a1b064db3e83fdb64f948ce5c2ad7 (diff)
parent2c3360fe9c03536cbfd77267170b73c120c071ac (diff)
am 2c3360fe: Merge "Remove lingering system app native libs in /data" into gingerbread
Merge commit '2c3360fe9c03536cbfd77267170b73c120c071ac' into gingerbread-plus-aosp * commit '2c3360fe9c03536cbfd77267170b73c120c071ac': Remove lingering system app native libs in /data
-rw-r--r--core/java/com/android/internal/content/NativeLibraryHelper.java21
-rwxr-xr-xcore/tests/coretests/src/android/content/pm/PackageManagerTests.java1
-rw-r--r--services/java/com/android/server/PackageManagerService.java22
3 files changed, 33 insertions, 11 deletions
diff --git a/core/java/com/android/internal/content/NativeLibraryHelper.java b/core/java/com/android/internal/content/NativeLibraryHelper.java
index 2a8cd94a21e0..00c4dbebcd23 100644
--- a/core/java/com/android/internal/content/NativeLibraryHelper.java
+++ b/core/java/com/android/internal/content/NativeLibraryHelper.java
@@ -294,33 +294,44 @@ public class NativeLibraryHelper {
}
}
+ // Convenience method to call removeNativeBinariesFromDirLI(File)
+ public static boolean removeNativeBinariesLI(String nativeLibraryPath) {
+ return removeNativeBinariesFromDirLI(new File(nativeLibraryPath));
+ }
+
// 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) {
+ public static boolean removeNativeBinariesFromDirLI(File nativeLibraryDir) {
if (DEBUG_NATIVE) {
- Slog.w(TAG, "Deleting native binaries from: " + nativeLibraryPath);
+ Slog.w(TAG, "Deleting native binaries from: " + nativeLibraryDir.getPath());
}
+ boolean deletedFiles = false;
+
/*
* 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 (nativeLibraryDir.exists()) {
+ final File[] binaries = nativeLibraryDir.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());
+ } else {
+ deletedFiles = true;
}
}
}
// Do not delete 'lib' directory itself, or this will prevent
// installation of future updates.
}
+
+ return deletedFiles;
}
}
diff --git a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
index 1289a9ee80d2..276e281c98c8 100755
--- a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
+++ b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
@@ -579,7 +579,6 @@ public class PackageManagerTests extends AndroidTestCase {
private InstallParams installFromRawResource(String outFileName,
int rawResId, int flags, boolean cleanUp, boolean fail, int result,
int expInstallLocation) {
- PackageManager pm = mContext.getPackageManager();
InstallParams ip = new InstallParams(outFileName, rawResId);
installFromRawResource(ip, flags, cleanUp, fail, result, expInstallLocation);
return ip;
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 58ea4db6d643..050e0c81ccc9 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -140,7 +140,6 @@ class PackageManagerService extends IPackageManager.Stub {
private static final boolean DEBUG_PREFERRED = false;
private static final boolean DEBUG_UPGRADE = false;
private static final boolean DEBUG_INSTALL = false;
- private static final boolean DEBUG_NATIVE = false;
private static final boolean MULTIPLE_APPLICATION_UIDS = true;
private static final int RADIO_UID = Process.PHONE_UID;
@@ -3276,10 +3275,23 @@ class PackageManagerService extends IPackageManager.Stub {
* In other words, we're going to unpack the binaries
* only for non-system apps and system app upgrades.
*/
- if ((!isSystemApp(pkg) || isUpdatedSystemApp(pkg)) && !isExternal(pkg)) {
- Log.i(TAG, path + " changed; unpacking");
- File sharedLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir);
- NativeLibraryHelper.copyNativeBinariesLI(scanFile, sharedLibraryDir);
+ if (pkg.applicationInfo.nativeLibraryDir != null) {
+ final File sharedLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir);
+ if (isSystemApp(pkg) && !isUpdatedSystemApp(pkg)) {
+ /*
+ * Upgrading from a previous version of the OS sometimes
+ * leaves native libraries in the /data/data/<app>/lib
+ * directory for system apps even when they shouldn't be.
+ * Recent changes in the JNI library search path
+ * necessitates we remove those to match previous behavior.
+ */
+ if (NativeLibraryHelper.removeNativeBinariesFromDirLI(sharedLibraryDir)) {
+ Log.i(TAG, "removed obsolete native libraries for system package " + path);
+ }
+ } else if (!isExternal(pkg)) {
+ Log.i(TAG, path + " changed; unpacking");
+ NativeLibraryHelper.copyNativeBinariesLI(scanFile, sharedLibraryDir);
+ }
}
pkg.mScanPath = path;