From d746057f2414cba2bdc69257cc5be8cb681bb592 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Sun, 6 Jul 2014 20:44:55 -0700 Subject: Change new file installs to be cluster-based! Now that all the other pieces are in place, we're ready to start installing new file-based packages as a cluster (the new unified directory-based layout). This greatly simplifies the renaming process. Also add helper methods to ApplicationInfo to give a much clearer mapping between it and internal field names, since we can't change the public API. Add recursive restorecon(). Bug: 14975160 Change-Id: I72a63c5ddbc594c2fec4a91dd59f73ef253fbfd7 --- .../android/defcontainer/DefaultContainerService.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'packages/DefaultContainerService') diff --git a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java index 7a21b92..67ed97c 100644 --- a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java +++ b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java @@ -499,19 +499,26 @@ public class DefaultContainerService extends IntentService { private int copyPackageInner(PackageLite pkg, IParcelFileDescriptorFactory target) throws IOException, RemoteException { - // TODO: extend to support copying all split APKs + copyFile(pkg.baseCodePath, "base.apk", target); if (!ArrayUtils.isEmpty(pkg.splitNames)) { - throw new UnsupportedOperationException("Copying split APKs not yet supported"); + for (int i = 0; i < pkg.splitNames.length; i++) { + copyFile(pkg.splitCodePaths[i], "split_" + pkg.splitNames[i] + ".apk", target); + } } + return PackageManager.INSTALL_SUCCEEDED; + } + + private void copyFile(String sourcePath, String targetName, + IParcelFileDescriptorFactory target) throws IOException, RemoteException { + Slog.d(TAG, "Copying " + sourcePath + " to " + targetName); InputStream in = null; OutputStream out = null; try { - in = new FileInputStream(pkg.baseCodePath); + in = new FileInputStream(sourcePath); out = new ParcelFileDescriptor.AutoCloseOutputStream( - target.open(null, ParcelFileDescriptor.MODE_READ_WRITE)); + target.open(targetName, ParcelFileDescriptor.MODE_READ_WRITE)); Streams.copy(in, out); - return PackageManager.INSTALL_SUCCEEDED; } finally { IoUtils.closeQuietly(out); IoUtils.closeQuietly(in); -- cgit v1.1