diff options
author | Kenny Root <kroot@google.com> | 2012-10-19 16:37:43 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-19 16:37:55 -0700 |
commit | 9bef3294d3660a85442829a25c9777e25d3c3cc8 (patch) | |
tree | e4ac279be0fcd872af6329c49239d2a70b40b582 /services | |
parent | 7e1664d44be6174c772fc3d2dc8ef9f5f5824390 (diff) | |
parent | cea3743499f4bb8e5f28a2e57686d7af313169c5 (diff) | |
download | frameworks_base-9bef3294d3660a85442829a25c9777e25d3c3cc8.zip frameworks_base-9bef3294d3660a85442829a25c9777e25d3c3cc8.tar.gz frameworks_base-9bef3294d3660a85442829a25c9777e25d3c3cc8.tar.bz2 |
Merge changes Ie3c8ca8d,Ia175b36d into jb-mr1-dev
* changes:
Try to free cache before giving up on install
Robustly add symlink and add for non-primary users
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/pm/Installer.java | 4 | ||||
-rw-r--r-- | services/java/com/android/server/pm/PackageManagerService.java | 102 |
2 files changed, 60 insertions, 46 deletions
diff --git a/services/java/com/android/server/pm/Installer.java b/services/java/com/android/server/pm/Installer.java index 8b1e80f..71a6a01 100644 --- a/services/java/com/android/server/pm/Installer.java +++ b/services/java/com/android/server/pm/Installer.java @@ -369,7 +369,7 @@ public final class Installer { * @param nativeLibPath target native library path * @return -1 on error */ - public int linkNativeLibraryDirectory(String dataPath, String nativeLibPath) { + public int linkNativeLibraryDirectory(String dataPath, String nativeLibPath, int userId) { if (dataPath == null) { Slog.e(TAG, "linkNativeLibraryDirectory dataPath is null"); return -1; @@ -382,6 +382,8 @@ public final class Installer { builder.append(dataPath); builder.append(' '); builder.append(nativeLibPath); + builder.append(' '); + builder.append(userId); return execute(builder.toString()); } diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index f59e30d..977437b 100644 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -4088,39 +4088,42 @@ public class PackageManagerService extends IPackageManager.Stub { Log.i(TAG, "removed obsolete native libraries for system package " + path); } - } else if (!isForwardLocked(pkg) && !isExternal(pkg)) { - // Update native library dir if it starts with /data/data - if (nativeLibraryDir.getPath().startsWith(dataPathString)) { - setInternalAppNativeLibraryPath(pkg, pkgSetting); - nativeLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir); - } + } else { + if (!isForwardLocked(pkg) && !isExternal(pkg)) { + /* + * Update native library dir if it starts with + * /data/data + */ + if (nativeLibraryDir.getPath().startsWith(dataPathString)) { + setInternalAppNativeLibraryPath(pkg, pkgSetting); + nativeLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir); + } - try { - if (copyNativeLibrariesForInternalApp(scanFile, nativeLibraryDir) != PackageManager.INSTALL_SUCCEEDED) { - Slog.e(TAG, "Unable to copy native libraries"); + try { + if (copyNativeLibrariesForInternalApp(scanFile, nativeLibraryDir) != PackageManager.INSTALL_SUCCEEDED) { + Slog.e(TAG, "Unable to copy native libraries"); + mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR; + return null; + } + } catch (IOException e) { + Slog.e(TAG, "Unable to copy native libraries", e); mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR; return null; } - } catch (IOException e) { - Slog.e(TAG, "Unable to copy native libraries", e); - mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR; - return null; } - if (mInstaller.linkNativeLibraryDirectory(dataPathString, - pkg.applicationInfo.nativeLibraryDir) == -1) { - Slog.e(TAG, "Unable to link native library directory"); - mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR; - return null; - } - } else { Slog.i(TAG, "Linking native library dir for " + path); - int ret = mInstaller.linkNativeLibraryDirectory(dataPathString, - pkg.applicationInfo.nativeLibraryDir); - if (ret < 0) { - Slog.w(TAG, "Failed linking native library dir for " + path); - mLastScanError = PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE; - return null; + final int[] userIds = sUserManager.getUserIds(); + synchronized (mInstallLock) { + for (int userId : userIds) { + if (mInstaller.linkNativeLibraryDirectory(pkg.packageName, + pkg.applicationInfo.nativeLibraryDir, userId) < 0) { + Slog.w(TAG, "Failed linking native library dir (user=" + userId + + ")"); + mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR; + return null; + } + } } } } catch (IOException ioe) { @@ -6327,8 +6330,23 @@ public class PackageManagerService extends IPackageManager.Stub { if (packageFile != null) { // Remote call to find out default install location - pkgLite = mContainerService.getMinimalPackageInfo( - packageFile.getAbsolutePath(), flags, lowThreshold); + final String packageFilePath = packageFile.getAbsolutePath(); + pkgLite = mContainerService.getMinimalPackageInfo(packageFilePath, flags, + lowThreshold); + + /* + * If we have too little free space, try to free cache + * before giving up. + */ + if (pkgLite.recommendedInstallLocation + == PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE) { + final long size = mContainerService.calculateInstalledSize( + packageFilePath, isForwardLocked()); + if (mInstaller.freeCache(size + lowThreshold) >= 0) { + pkgLite = mContainerService.getMinimalPackageInfo(packageFilePath, + flags, lowThreshold); + } + } } } finally { mContext.revokeUriPermission(mPackageURI, @@ -6350,12 +6368,12 @@ public class PackageManagerService extends IPackageManager.Stub { ret = PackageManager.INSTALL_FAILED_INVALID_URI; } else if (loc == PackageHelper.RECOMMEND_MEDIA_UNAVAILABLE) { ret = PackageManager.INSTALL_FAILED_MEDIA_UNAVAILABLE; - } else if (loc == PackageHelper.RECOMMEND_FAILED_VERSION_DOWNGRADE) { - ret = PackageManager.INSTALL_FAILED_VERSION_DOWNGRADE; } else { // Override with defaults if needed. loc = installLocationPolicy(pkgLite, flags); - if (!onSd && !onInt) { + if (loc == PackageHelper.RECOMMEND_FAILED_VERSION_DOWNGRADE) { + ret = PackageManager.INSTALL_FAILED_VERSION_DOWNGRADE; + } else if (!onSd && !onInt) { // Override install location with flags if (loc == PackageHelper.RECOMMEND_INSTALL_EXTERNAL) { // Set the flag to install on external media. @@ -9959,20 +9977,14 @@ public class PackageManagerService extends IPackageManager.Stub { final File newNativeDir = new File(newNativePath); if (!isForwardLocked(pkg) && !isExternal(pkg)) { - synchronized (mInstallLock) { - if (mInstaller.linkNativeLibraryDirectory( - pkg.applicationInfo.dataDir, newNativePath) < 0) { - returnCode = PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE; - } - } - NativeLibraryHelper.copyNativeBinariesIfNeededLI(new File( - newCodePath), newNativeDir); - } else { - synchronized (mInstallLock) { - if (mInstaller.linkNativeLibraryDirectory( - pkg.applicationInfo.dataDir, newNativePath) < 0) { - returnCode = PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE; - } + NativeLibraryHelper.copyNativeBinariesIfNeededLI( + new File(newCodePath), newNativeDir); + } + final int[] users = sUserManager.getUserIds(); + for (int user : users) { + if (mInstaller.linkNativeLibraryDirectory(pkg.packageName, + newNativePath, user) < 0) { + returnCode = PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE; } } |