summaryrefslogtreecommitdiffstats
path: root/packages/DefaultContainerService
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2014-08-20 16:26:32 -0700
committerJeff Sharkey <jsharkey@android.com>2014-08-22 16:25:04 -0700
commit941a8ba1a6043cf84a7bf622e44a0b4f7abd0178 (patch)
treec783987f68caaa4cc827b3c720f269bcc9d34667 /packages/DefaultContainerService
parent7653a30ea0232ab8323ec51ddcba8d8054ca8a2f (diff)
downloadframeworks_base-941a8ba1a6043cf84a7bf622e44a0b4f7abd0178.zip
frameworks_base-941a8ba1a6043cf84a7bf622e44a0b4f7abd0178.tar.gz
frameworks_base-941a8ba1a6043cf84a7bf622e44a0b4f7abd0178.tar.bz2
Installing splits into ASECs!
Sessions can now zero-copy data directly into pre-allocated ASEC containers. Then at commit time, we compute the total size of the final app, including any inherited APKs and unpacked libraries, and resize the container in one step. This supports both brand new ASEC installs and inheriting from existing ASEC installs. To keep things simple, it currently requires copying any inherited ASEC contents, but this could be optimized in the future. Expose new vold resize command, and allow read-write mounting of ASEC containers. Move native library extraction into the installer flow, since it needs to happen before ASEC is sealed. Move multiArch flag into NativeLibraryHelper, instead of making everyone pass it around. Migrate size calculation to shared location. Separate "other" package name in public API, provide a path to a storage device when relevant, and add more docs. Bug: 16514385 Change-Id: I06c6ce588d312ee7e64cce02733895d640b88456
Diffstat (limited to 'packages/DefaultContainerService')
-rw-r--r--packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java52
1 files changed, 9 insertions, 43 deletions
diff --git a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
index fae30e5..1f28324 100644
--- a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
+++ b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
@@ -16,7 +16,7 @@
package com.android.defcontainer;
-import static android.net.TrafficStats.MB_IN_BYTES;
+import static com.android.internal.content.NativeLibraryHelper.LIB_DIR_NAME;
import android.app.IntentService;
import android.content.Context;
@@ -67,8 +67,6 @@ import java.io.OutputStream;
public class DefaultContainerService extends IntentService {
private static final String TAG = "DefContainer";
- private static final String LIB_DIR_NAME = "lib";
-
// TODO: migrate native code unpacking to always be a derivative work
private IMediaContainerService.Stub mBinder = new IMediaContainerService.Stub() {
@@ -168,7 +166,7 @@ public class DefaultContainerService extends IntentService {
final long sizeBytes;
try {
pkg = PackageParser.parsePackageLite(packageFile, 0);
- sizeBytes = calculateInstalledSizeInner(pkg, isForwardLocked, abiOverride);
+ sizeBytes = PackageHelper.calculateInstalledSize(pkg, isForwardLocked, abiOverride);
} catch (PackageParserException | IOException e) {
Slog.w(TAG, "Failed to parse package at " + packagePath + ": " + e);
@@ -253,7 +251,7 @@ public class DefaultContainerService extends IntentService {
final PackageParser.PackageLite pkg;
try {
pkg = PackageParser.parsePackageLite(packageFile, 0);
- return calculateInstalledSizeInner(pkg, isForwardLocked, abiOverride);
+ return PackageHelper.calculateInstalledSize(pkg, isForwardLocked, abiOverride);
} catch (PackageParserException | IOException e) {
Slog.w(TAG, "Failed to calculate installed size: " + e);
return Long.MAX_VALUE;
@@ -315,13 +313,12 @@ public class DefaultContainerService extends IntentService {
// Calculate container size, rounding up to nearest MB and adding an
// extra MB for filesystem overhead
- final long sizeBytes = calculateInstalledSizeInner(pkg, handle, isForwardLocked,
- abiOverride);
- final int sizeMb = ((int) ((sizeBytes + MB_IN_BYTES) / MB_IN_BYTES)) + 1;
+ final long sizeBytes = PackageHelper.calculateInstalledSize(pkg, handle,
+ isForwardLocked, abiOverride);
// Create new container
- final String newMountPath = PackageHelper.createSdDir(sizeMb, newCid, key, Process.myUid(),
- isExternal);
+ final String newMountPath = PackageHelper.createSdDir(sizeBytes, newCid, key,
+ Process.myUid(), isExternal);
if (newMountPath == null) {
throw new IOException("Failed to create container " + newCid);
}
@@ -339,8 +336,8 @@ public class DefaultContainerService extends IntentService {
// Extract native code
final File libraryRoot = new File(targetDir, LIB_DIR_NAME);
- final int res = NativeLibraryHelper.copyNativeBinariesIfNeededLI(handle, libraryRoot,
- abiOverride, pkg.multiArch);
+ final int res = NativeLibraryHelper.copyNativeBinariesWithOverride(handle, libraryRoot,
+ abiOverride);
if (res != PackageManager.INSTALL_SUCCEEDED) {
throw new IOException("Failed to extract native code, res=" + res);
}
@@ -415,35 +412,4 @@ public class DefaultContainerService extends IntentService {
Os.chmod(targetFile.getAbsolutePath(), 0644);
}
}
-
- private long calculateInstalledSizeInner(PackageLite pkg, boolean isForwardLocked,
- String abiOverride) throws IOException {
- NativeLibraryHelper.Handle handle = null;
- try {
- handle = NativeLibraryHelper.Handle.create(pkg);
- return calculateInstalledSizeInner(pkg, handle, isForwardLocked, abiOverride);
- } finally {
- IoUtils.closeQuietly(handle);
- }
- }
-
- private long calculateInstalledSizeInner(PackageLite pkg, NativeLibraryHelper.Handle handle,
- boolean isForwardLocked, String abiOverride) throws IOException {
- long sizeBytes = 0;
-
- // Include raw APKs, and possibly unpacked resources
- for (String codePath : pkg.getAllCodePaths()) {
- final File codeFile = new File(codePath);
- sizeBytes += codeFile.length();
-
- if (isForwardLocked) {
- sizeBytes += PackageHelper.extractPublicFiles(codeFile, null);
- }
- }
-
- // Include all relevant native code
- sizeBytes += NativeLibraryHelper.sumNativeBinaries(handle, abiOverride, pkg.multiArch);
-
- return sizeBytes;
- }
}