Merge "Remove lingering system app native libs in /data" into gingerbread
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user