am 54e01e0f: Merge "Symlink application lib directory when on SD card" into gingerbread

Merge commit '54e01e0f980cfb78153d5481f7e67cef90416174' into gingerbread-plus-aosp

* commit '54e01e0f980cfb78153d5481f7e67cef90416174':
  Symlink application lib directory when on SD card
This commit is contained in:
Kenny Root
2010-10-07 17:41:05 -07:00
committed by Android Git Automerger
6 changed files with 272 additions and 22 deletions

View File

@ -327,4 +327,33 @@ class Installer {
public int moveFiles() {
return execute("movefiles");
}
public int linkNativeLibraryDirectory(String dataPath, String nativeLibPath) {
if (dataPath == null) {
Slog.e(TAG, "unlinkNativeLibraryDirectory dataPath is null");
return -1;
} else if (nativeLibPath == null) {
Slog.e(TAG, "unlinkNativeLibraryDirectory nativeLibPath is null");
return -1;
}
StringBuilder builder = new StringBuilder("linklib ");
builder.append(dataPath);
builder.append(' ');
builder.append(nativeLibPath);
return execute(builder.toString());
}
public int unlinkNativeLibraryDirectory(String dataPath) {
if (dataPath == null) {
Slog.e(TAG, "unlinkNativeLibraryDirectory dataPath is null");
return -1;
}
StringBuilder builder = new StringBuilder("unlinklib ");
builder.append(dataPath);
return execute(builder.toString());
}
}

View File

@ -3290,7 +3290,11 @@ class PackageManagerService extends IPackageManager.Stub {
}
} else if (!isExternal(pkg)) {
Log.i(TAG, path + " changed; unpacking");
mInstaller.unlinkNativeLibraryDirectory(dataPath.getPath());
NativeLibraryHelper.copyNativeBinariesLI(scanFile, sharedLibraryDir);
} else {
mInstaller.linkNativeLibraryDirectory(dataPath.getPath(),
pkg.applicationInfo.nativeLibraryDir);
}
}
pkg.mScanPath = path;
@ -5010,10 +5014,6 @@ class PackageManagerService extends IPackageManager.Stub {
try { if (out != null) out.close(); } catch (IOException e) {}
}
if (!temp) {
NativeLibraryHelper.copyNativeBinariesLI(codeFile, new File(libraryPath));
}
return ret;
}
@ -9894,10 +9894,10 @@ class PackageManagerService extends IPackageManager.Stub {
synchronized (mPackages) {
PackageParser.Package pkg = mPackages.get(mp.packageName);
// Recheck for package again.
if (pkg == null ) {
Slog.w(TAG, " Package " + mp.packageName +
" doesn't exist. Aborting move");
returnCode = PackageManager.MOVE_FAILED_DOESNT_EXIST;
if (pkg == null) {
Slog.w(TAG, " Package " + mp.packageName
+ " doesn't exist. Aborting move");
returnCode = PackageManager.MOVE_FAILED_DOESNT_EXIST;
} else if (!mp.srcArgs.getCodePath().equals(pkg.applicationInfo.sourceDir)) {
Slog.w(TAG, "Package " + mp.packageName + " code path changed from " +
mp.srcArgs.getCodePath() + " to " + pkg.applicationInfo.sourceDir +
@ -9908,15 +9908,34 @@ class PackageManagerService extends IPackageManager.Stub {
final String newCodePath = mp.targetArgs.getCodePath();
final String newResPath = mp.targetArgs.getResourcePath();
final String newNativePath = mp.targetArgs.getNativeLibraryPath();
pkg.mPath = newCodePath;
// Move dex files around
if (moveDexFilesLI(pkg)
!= PackageManager.INSTALL_SUCCEEDED) {
// Moving of dex files failed. Set
// error code and abort move.
pkg.mPath = pkg.mScanPath;
returnCode = PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE;
} else {
if ((mp.flags & PackageManager.INSTALL_EXTERNAL) == 0) {
if (mInstaller
.unlinkNativeLibraryDirectory(pkg.applicationInfo.dataDir) < 0) {
returnCode = PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE;
} else {
NativeLibraryHelper.copyNativeBinariesLI(
new File(newCodePath), new File(newNativePath));
}
} else {
if (mInstaller.linkNativeLibraryDirectory(
pkg.applicationInfo.dataDir, newNativePath) < 0) {
returnCode = PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE;
}
}
if (returnCode == PackageManager.MOVE_SUCCEEDED) {
pkg.mPath = newCodePath;
// Move dex files around
if (moveDexFilesLI(pkg) != PackageManager.INSTALL_SUCCEEDED) {
// Moving of dex files failed. Set
// error code and abort move.
pkg.mPath = pkg.mScanPath;
returnCode = PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE;
}
}
if (returnCode == PackageManager.MOVE_SUCCEEDED) {
pkg.mScanPath = newCodePath;
pkg.applicationInfo.sourceDir = newCodePath;
pkg.applicationInfo.publicSourceDir = newResPath;