summaryrefslogtreecommitdiff
path: root/cmds/pm
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-02-21 21:01:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-02-21 21:01:20 +0000
commited4cd7a1ba0e05bf89d750d88194504ec14d63ab (patch)
treeceda119aae9ab6c7455c6372d8bdf37657916557 /cmds/pm
parent830d4b422db2f2ae4af17403ccd1d34fd6f0bd6f (diff)
parent4b4ce6fa177b52c99b87c4d45c0a85860eb267a0 (diff)
Merge "Log pm install time and package name"
Diffstat (limited to 'cmds/pm')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java15
1 files changed, 10 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 7965fc342514..1aef3639e449 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -65,6 +65,7 @@ import android.os.UserManager;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Log;
+import android.util.Pair;
import com.android.internal.content.PackageHelper;
import com.android.internal.util.ArrayUtils;
@@ -402,6 +403,7 @@ public final class Pm {
* The use of "adb install" or "cmd package install" over "pm install" is highly encouraged.
*/
private int runInstall() throws RemoteException {
+ long startedTime = SystemClock.elapsedRealtime();
final InstallParams params = makeInstallParams();
final String inPath = nextArg();
if (params.sessionParams.sizeBytes == -1 && !STDIN_PATH.equals(inPath)) {
@@ -435,10 +437,12 @@ public final class Pm {
false /*logSuccess*/) != PackageInstaller.STATUS_SUCCESS) {
return 1;
}
- if (doCommitSession(sessionId, false /*logSuccess*/)
- != PackageInstaller.STATUS_SUCCESS) {
+ Pair<String, Integer> status = doCommitSession(sessionId, false /*logSuccess*/);
+ if (status.second != PackageInstaller.STATUS_SUCCESS) {
return 1;
}
+ Log.i(TAG, "Package " + status.first + " installed in " + (SystemClock.elapsedRealtime()
+ - startedTime) + " ms");
System.out.println("Success");
return 0;
} finally {
@@ -456,7 +460,7 @@ public final class Pm {
private int runInstallCommit() throws RemoteException {
final int sessionId = Integer.parseInt(nextArg());
- return doCommitSession(sessionId, true /*logSuccess*/);
+ return doCommitSession(sessionId, true /*logSuccess*/).second;
}
private int runInstallCreate() throws RemoteException {
@@ -650,7 +654,8 @@ public final class Pm {
}
}
- private int doCommitSession(int sessionId, boolean logSuccess) throws RemoteException {
+ private Pair<String, Integer> doCommitSession(int sessionId, boolean logSuccess)
+ throws RemoteException {
PackageInstaller.Session session = null;
try {
session = new PackageInstaller.Session(
@@ -670,7 +675,7 @@ public final class Pm {
System.err.println("Failure ["
+ result.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE) + "]");
}
- return status;
+ return new Pair<>(result.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME), status);
} finally {
IoUtils.closeQuietly(session);
}