diff options
author | Jeff Sharkey <jsharkey@android.com> | 2014-07-12 18:09:46 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2014-07-12 21:12:25 -0700 |
commit | a10311434778ea1be1621c2251c0c8c2966f337b (patch) | |
tree | 3496202e354ae761d7c750e105c610f67f82542d /cmds/pm | |
parent | e0b0bef75b66f0a87039c8f58c17b1596a2baebe (diff) | |
download | frameworks_base-a10311434778ea1be1621c2251c0c8c2966f337b.zip frameworks_base-a10311434778ea1be1621c2251c0c8c2966f337b.tar.gz frameworks_base-a10311434778ea1be1621c2251c0c8c2966f337b.tar.bz2 |
Package installation listener events.
Flesh out implementation of install session observers. Carve out 20%
of published install progress for final system operations such as
dexopt, etc.
Add dumpsys output for active install sessions. Create explicit
fsync() instead of overriding meaning of flush(). Hack to throw
IOExceptions over Binder calls.
Bug: 14975160, 15348430
Change-Id: I874457e40c45d2661bc0a526df9285ffea4bb77c
Diffstat (limited to 'cmds/pm')
-rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index 6cca03b..3d0eec4 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -31,7 +31,7 @@ import android.content.pm.InstallSessionParams; import android.content.pm.InstrumentationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageInstaller; -import android.content.pm.PackageInstaller.InstallResultCallback; +import android.content.pm.PackageInstaller.CommitResultCallback; import android.content.pm.PackageItemInfo; import android.content.pm.PackageManager; import android.content.pm.ParceledListSlice; @@ -769,7 +769,7 @@ public final class Pm { } } - class LocalInstallResultCallback extends InstallResultCallback { + class LocalCommitResultCallback extends CommitResultCallback { boolean finished; boolean success; String msg; @@ -1018,6 +1018,7 @@ public final class Pm { final InstallSessionParams params = new InstallSessionParams(); params.installFlags = PackageManager.INSTALL_ALL_USERS; params.fullInstall = true; + params.progressMax = -1; String opt; while ((opt = nextOption()) != null) { @@ -1042,6 +1043,7 @@ public final class Pm { params.fullInstall = false; } else if (opt.equals("-S")) { params.deltaSize = Long.parseLong(nextOptionData()); + params.progressMax = (int) params.deltaSize; } else { throw new IllegalArgumentException("Unknown option " + opt); } @@ -1093,7 +1095,8 @@ public final class Pm { out = session.openWrite(splitName, 0, sizeBytes); final int n = Streams.copy(in, out); - out.flush(); + session.fsync(out); + session.addProgress(n); System.out.println("Success: streamed " + n + " bytes"); } finally { @@ -1110,8 +1113,8 @@ public final class Pm { try { session = new PackageInstaller.Session(mInstaller.openSession(sessionId)); - final LocalInstallResultCallback callback = new LocalInstallResultCallback(); - session.install(callback); + final LocalCommitResultCallback callback = new LocalCommitResultCallback(); + session.commit(callback); synchronized (callback) { while (!callback.finished) { |