summaryrefslogtreecommitdiffstats
path: root/cmds/pm/src
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2014-07-30 16:45:01 -0700
committerJeff Sharkey <jsharkey@android.com>2014-07-31 15:17:03 -0700
commit1cb2d0d4bba387665128c62c342e59103ea4be26 (patch)
tree2659fda22f585adf01574c24f1f23dbb3caccef2 /cmds/pm/src
parent874bcd82c223ce58c9d76edcf619b3988c672307 (diff)
downloadframeworks_base-1cb2d0d4bba387665128c62c342e59103ea4be26.zip
frameworks_base-1cb2d0d4bba387665128c62c342e59103ea4be26.tar.gz
frameworks_base-1cb2d0d4bba387665128c62c342e59103ea4be26.tar.bz2
Persist install sessions, more lifecycle.
To resume install sessions across device boots, persist session details and read at boot. Drop sessions older than 3 days, since they're probably buggy installers. Add session callback lifecycle around open/close to give home apps details about active installs. Also give them a well-known intent to show session details. Extend Session to list staged APKs and open them read-only, giving installers a mechanism to verify delivered bits, for example using MessageDigest, before committing. Switch to generating random session IDs instead of sequential. Defensively resize app icons if too large. Reject runaway installers when they have too many active sessions. Bug: 16514389 Change-Id: I66c2266cb82fc72b1eb980a615566773f4290498
Diffstat (limited to 'cmds/pm/src')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index bc16800..1f25dd0 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -59,7 +59,6 @@ import com.android.internal.util.ArrayUtils;
import com.android.internal.util.SizedInputStream;
import libcore.io.IoUtils;
-import libcore.io.Streams;
import java.io.File;
import java.io.FileDescriptor;
@@ -1068,6 +1067,8 @@ public final class Pm {
}
}
+ final InstallSessionInfo info = mInstaller.getSessionInfo(sessionId);
+
PackageInstaller.Session session = null;
InputStream in = null;
OutputStream out = null;
@@ -1081,16 +1082,21 @@ public final class Pm {
}
out = session.openWrite(splitName, 0, sizeBytes);
- final int n = Streams.copy(in, out);
- session.fsync(out);
+ int total = 0;
+ byte[] buffer = new byte[65536];
+ int c;
+ while ((c = in.read(buffer)) != -1) {
+ total += c;
+ out.write(buffer, 0, c);
- final InstallSessionInfo info = mInstaller.getSessionInfo(sessionId);
- if (info.sizeBytes > 0) {
- final float fraction = ((float) n / (float) info.sizeBytes);
- session.addProgress(fraction);
+ if (info.sizeBytes > 0) {
+ final float fraction = ((float) c / (float) info.sizeBytes);
+ session.addProgress(fraction);
+ }
}
+ session.fsync(out);
- System.out.println("Success: streamed " + n + " bytes");
+ System.out.println("Success: streamed " + total + " bytes");
} finally {
IoUtils.closeQuietly(out);
IoUtils.closeQuietly(in);