summaryrefslogtreecommitdiffstats
path: root/packages/DefaultContainerService
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-04-10 10:37:17 +0100
committerNarayan Kamath <narayan@google.com>2014-04-10 10:38:31 +0100
commitd11f223c535ed9ce628fe5aaf0fd5692dd0cf9e4 (patch)
tree433adc8269acd26f88e47207e35df63d77662409 /packages/DefaultContainerService
parente5e8444ce864e7ac5d07308b9a5c5ca2caaa4e0a (diff)
parent286a247e4c8fcecb59636f668678d24e33142744 (diff)
downloadframeworks_base-d11f223c535ed9ce628fe5aaf0fd5692dd0cf9e4.zip
frameworks_base-d11f223c535ed9ce628fe5aaf0fd5692dd0cf9e4.tar.gz
frameworks_base-d11f223c535ed9ce628fe5aaf0fd5692dd0cf9e4.tar.bz2
resolved conflicts for merge of 286a247e to master
Change-Id: I63df9d482da3ce2ac851959223b9180020ffad0c
Diffstat (limited to 'packages/DefaultContainerService')
-rw-r--r--packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java33
1 files changed, 29 insertions, 4 deletions
diff --git a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
index f68d1a9..48ef9db 100644
--- a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
+++ b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
@@ -30,6 +30,7 @@ import android.content.pm.PackageParser;
import android.content.res.ObbInfo;
import android.content.res.ObbScanner;
import android.net.Uri;
+import android.os.Build;
import android.os.Environment;
import android.os.Environment.UserEnvironment;
import android.os.FileUtils;
@@ -341,11 +342,13 @@ public class DefaultContainerService extends IntentService {
// The .apk file
String codePath = packageURI.getPath();
File codeFile = new File(codePath);
+ NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(codePath);
+ final int abi = NativeLibraryHelper.findSupportedAbi(handle, Build.SUPPORTED_ABIS);
// Calculate size of container needed to hold base APK.
final int sizeMb;
try {
- sizeMb = calculateContainerSize(codeFile, isForwardLocked);
+ sizeMb = calculateContainerSize(handle, codeFile, abi, isForwardLocked);
} catch (IOException e) {
Slog.w(TAG, "Problem when trying to copy " + codeFile.getPath());
return null;
@@ -408,7 +411,14 @@ public class DefaultContainerService extends IntentService {
final File sharedLibraryDir = new File(newCachePath, LIB_DIR_NAME);
if (sharedLibraryDir.mkdir()) {
- int ret = NativeLibraryHelper.copyNativeBinariesIfNeededLI(codeFile, sharedLibraryDir);
+ int ret = PackageManager.INSTALL_SUCCEEDED;
+ if (abi >= 0) {
+ ret = NativeLibraryHelper.copyNativeBinariesIfNeededLI(handle,
+ sharedLibraryDir, Build.SUPPORTED_ABIS[abi]);
+ } else if (abi != PackageManager.NO_NATIVE_LIBRARIES) {
+ ret = abi;
+ }
+
if (ret != PackageManager.INSTALL_SUCCEEDED) {
Slog.e(TAG, "Could not copy native libraries to " + sharedLibraryDir.getPath());
PackageHelper.destroySdDir(newCid);
@@ -822,6 +832,17 @@ public class DefaultContainerService extends IntentService {
return availSdMb > sizeMb;
}
+ private int calculateContainerSize(File apkFile, boolean forwardLocked) throws IOException {
+ NativeLibraryHelper.ApkHandle handle = new NativeLibraryHelper.ApkHandle(apkFile);
+ final int abi = NativeLibraryHelper.findSupportedAbi(handle, Build.SUPPORTED_ABIS);
+
+ try {
+ return calculateContainerSize(handle, apkFile, abi, forwardLocked);
+ } finally {
+ handle.close();
+ }
+ }
+
/**
* Calculate the container size for an APK. Takes into account the
*
@@ -829,7 +850,8 @@ public class DefaultContainerService extends IntentService {
* @return size in megabytes (2^20 bytes)
* @throws IOException when there is a problem reading the file
*/
- private int calculateContainerSize(File apkFile, boolean forwardLocked) throws IOException {
+ private int calculateContainerSize(NativeLibraryHelper.ApkHandle apkHandle,
+ File apkFile, int abiIndex, boolean forwardLocked) throws IOException {
// Calculate size of container needed to hold base APK.
long sizeBytes = apkFile.length();
if (sizeBytes == 0 && !apkFile.exists()) {
@@ -838,7 +860,10 @@ public class DefaultContainerService extends IntentService {
// Check all the native files that need to be copied and add that to the
// container size.
- sizeBytes += NativeLibraryHelper.sumNativeBinariesLI(apkFile);
+ if (abiIndex >= 0) {
+ sizeBytes += NativeLibraryHelper.sumNativeBinariesLI(apkHandle,
+ Build.SUPPORTED_ABIS[abiIndex]);
+ }
if (forwardLocked) {
sizeBytes += PackageHelper.extractPublicFiles(apkFile.getPath(), null);