From a10311434778ea1be1621c2251c0c8c2966f337b Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Sat, 12 Jul 2014 18:09:46 -0700 Subject: 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 --- cmds/pm/src/com/android/commands/pm/Pm.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'cmds/pm') 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) { -- cgit v1.1