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
|
// Remove the native binaries of a given package. This simply
|
||||||
// gets rid of the files in the 'lib' sub-directory.
|
// 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) {
|
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
|
* Just remove any file in the directory. Since the directory is owned
|
||||||
* by the 'system' UID, the application is not supposed to have written
|
* by the 'system' UID, the application is not supposed to have written
|
||||||
* anything there.
|
* anything there.
|
||||||
*/
|
*/
|
||||||
File binaryDir = new File(nativeLibraryPath);
|
if (nativeLibraryDir.exists()) {
|
||||||
if (binaryDir.exists()) {
|
final File[] binaries = nativeLibraryDir.listFiles();
|
||||||
File[] binaries = binaryDir.listFiles();
|
|
||||||
if (binaries != null) {
|
if (binaries != null) {
|
||||||
for (int nn = 0; nn < binaries.length; nn++) {
|
for (int nn = 0; nn < binaries.length; nn++) {
|
||||||
if (DEBUG_NATIVE) {
|
if (DEBUG_NATIVE) {
|
||||||
Slog.d(TAG, " Deleting " + binaries[nn].getName());
|
Slog.d(TAG, " Deleting " + binaries[nn].getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!binaries[nn].delete()) {
|
if (!binaries[nn].delete()) {
|
||||||
Slog.w(TAG, "Could not delete native binary: " + binaries[nn].getPath());
|
Slog.w(TAG, "Could not delete native binary: " + binaries[nn].getPath());
|
||||||
|
} else {
|
||||||
|
deletedFiles = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Do not delete 'lib' directory itself, or this will prevent
|
// Do not delete 'lib' directory itself, or this will prevent
|
||||||
// installation of future updates.
|
// installation of future updates.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return deletedFiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -579,7 +579,6 @@ public class PackageManagerTests extends AndroidTestCase {
|
|||||||
private InstallParams installFromRawResource(String outFileName,
|
private InstallParams installFromRawResource(String outFileName,
|
||||||
int rawResId, int flags, boolean cleanUp, boolean fail, int result,
|
int rawResId, int flags, boolean cleanUp, boolean fail, int result,
|
||||||
int expInstallLocation) {
|
int expInstallLocation) {
|
||||||
PackageManager pm = mContext.getPackageManager();
|
|
||||||
InstallParams ip = new InstallParams(outFileName, rawResId);
|
InstallParams ip = new InstallParams(outFileName, rawResId);
|
||||||
installFromRawResource(ip, flags, cleanUp, fail, result, expInstallLocation);
|
installFromRawResource(ip, flags, cleanUp, fail, result, expInstallLocation);
|
||||||
return ip;
|
return ip;
|
||||||
|
@ -140,7 +140,6 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
private static final boolean DEBUG_PREFERRED = false;
|
private static final boolean DEBUG_PREFERRED = false;
|
||||||
private static final boolean DEBUG_UPGRADE = false;
|
private static final boolean DEBUG_UPGRADE = false;
|
||||||
private static final boolean DEBUG_INSTALL = 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 boolean MULTIPLE_APPLICATION_UIDS = true;
|
||||||
private static final int RADIO_UID = Process.PHONE_UID;
|
private static final int RADIO_UID = Process.PHONE_UID;
|
||||||
@ -3276,11 +3275,24 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
* In other words, we're going to unpack the binaries
|
* In other words, we're going to unpack the binaries
|
||||||
* only for non-system apps and system app upgrades.
|
* only for non-system apps and system app upgrades.
|
||||||
*/
|
*/
|
||||||
if ((!isSystemApp(pkg) || isUpdatedSystemApp(pkg)) && !isExternal(pkg)) {
|
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");
|
Log.i(TAG, path + " changed; unpacking");
|
||||||
File sharedLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir);
|
|
||||||
NativeLibraryHelper.copyNativeBinariesLI(scanFile, sharedLibraryDir);
|
NativeLibraryHelper.copyNativeBinariesLI(scanFile, sharedLibraryDir);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pkg.mScanPath = path;
|
pkg.mScanPath = path;
|
||||||
|
|
||||||
if ((scanMode&SCAN_NO_DEX) == 0) {
|
if ((scanMode&SCAN_NO_DEX) == 0) {
|
||||||
|
Reference in New Issue
Block a user