summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2016-06-10 15:21:39 -0700
committerAndreas Gampe <agampe@google.com>2016-09-06 10:39:20 -0700
commitff8ab4c9fade0dd95bac6df6506e1ce14dbd8e42 (patch)
tree6743c00ae591e2e7e8fcf08461146d31bc219f56
parent2b6fc4c92deac1572b68f3cfc326da0a230055a7 (diff)
downloadbase-ff8ab4c9fade0dd95bac6df6506e1ce14dbd8e42.tar.gz
Otadexopt: Expose progress percentage
To be able to report progress of an A/B OTA dexopt, expose a progress function that the script can query. Bug: 25612095 Bug: 29223204 Change-Id: Ie8162946d18f6fa78649a40ad5d3949d31a181cd (cherry picked from commit bf06232f4d440ced8230662a77ca0e8ece6383ca)
-rw-r--r--core/java/android/content/pm/IOtaDexopt.aidl6
-rw-r--r--services/core/java/com/android/server/pm/OtaDexoptService.java10
-rw-r--r--services/core/java/com/android/server/pm/OtaDexoptShellCommand.java9
3 files changed, 25 insertions, 0 deletions
diff --git a/core/java/android/content/pm/IOtaDexopt.aidl b/core/java/android/content/pm/IOtaDexopt.aidl
index 8f38d6f90a7d..786a77f64110 100644
--- a/core/java/android/content/pm/IOtaDexopt.aidl
+++ b/core/java/android/content/pm/IOtaDexopt.aidl
@@ -42,6 +42,12 @@ interface IOtaDexopt {
boolean isDone();
/**
+ * Return the progress (0..1) made in this session. When {@link #isDone() isDone} returns
+ * true, the progress value will be 1.
+ */
+ float getProgress();
+
+ /**
* Optimize the next package. Note: this command is synchronous, that is, only returns after
* the package has been dexopted (or dexopting failed).
*/
diff --git a/services/core/java/com/android/server/pm/OtaDexoptService.java b/services/core/java/com/android/server/pm/OtaDexoptService.java
index 649a27cb7cd6..df91f4a1f62a 100644
--- a/services/core/java/com/android/server/pm/OtaDexoptService.java
+++ b/services/core/java/com/android/server/pm/OtaDexoptService.java
@@ -54,6 +54,7 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
// TODO: Evaluate the need for WeakReferences here.
private List<PackageParser.Package> mDexoptPackages;
+ private int completeSize;
public OtaDexoptService(Context context, PackageManagerService packageManagerService) {
this.mContext = context;
@@ -91,6 +92,7 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
mDexoptPackages = PackageManagerServiceUtils.getPackagesForDexopt(
mPackageManagerService.mPackages.values(), mPackageManagerService);
}
+ completeSize = mDexoptPackages.size();
}
@Override
@@ -111,6 +113,14 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
}
@Override
+ public synchronized float getProgress() throws RemoteException {
+ if (completeSize == 0) {
+ return 1f;
+ }
+ return (completeSize - mDexoptPackages.size()) / ((float)completeSize);
+ }
+
+ @Override
public synchronized void dexoptNextPackage() throws RemoteException {
if (mDexoptPackages == null) {
throw new IllegalStateException("dexoptNextPackage() called before prepare()");
diff --git a/services/core/java/com/android/server/pm/OtaDexoptShellCommand.java b/services/core/java/com/android/server/pm/OtaDexoptShellCommand.java
index ea9cf1766232..e8fdfa50a12d 100644
--- a/services/core/java/com/android/server/pm/OtaDexoptShellCommand.java
+++ b/services/core/java/com/android/server/pm/OtaDexoptShellCommand.java
@@ -46,6 +46,8 @@ class OtaDexoptShellCommand extends ShellCommand {
return runOtaDone();
case "step":
return runOtaStep();
+ case "progress":
+ return runOtaProgress();
default:
return handleDefaultCommands(cmd);
}
@@ -81,6 +83,13 @@ class OtaDexoptShellCommand extends ShellCommand {
return 0;
}
+ private int runOtaProgress() throws RemoteException {
+ final float progress = mInterface.getProgress();
+ final PrintWriter pw = getOutPrintWriter();
+ pw.format("%.2f", progress);
+ return 0;
+ }
+
@Override
public void onHelp() {
final PrintWriter pw = getOutPrintWriter();