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 bf06232f4d)
This commit is contained in:
@@ -41,6 +41,12 @@ interface IOtaDexopt {
|
|||||||
*/
|
*/
|
||||||
boolean isDone();
|
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
|
* Optimize the next package. Note: this command is synchronous, that is, only returns after
|
||||||
* the package has been dexopted (or dexopting failed).
|
* the package has been dexopted (or dexopting failed).
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
|
|||||||
|
|
||||||
// TODO: Evaluate the need for WeakReferences here.
|
// TODO: Evaluate the need for WeakReferences here.
|
||||||
private List<PackageParser.Package> mDexoptPackages;
|
private List<PackageParser.Package> mDexoptPackages;
|
||||||
|
private int completeSize;
|
||||||
|
|
||||||
public OtaDexoptService(Context context, PackageManagerService packageManagerService) {
|
public OtaDexoptService(Context context, PackageManagerService packageManagerService) {
|
||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
@@ -91,6 +92,7 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
|
|||||||
mDexoptPackages = PackageManagerServiceUtils.getPackagesForDexopt(
|
mDexoptPackages = PackageManagerServiceUtils.getPackagesForDexopt(
|
||||||
mPackageManagerService.mPackages.values(), mPackageManagerService);
|
mPackageManagerService.mPackages.values(), mPackageManagerService);
|
||||||
}
|
}
|
||||||
|
completeSize = mDexoptPackages.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -110,6 +112,14 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
|
|||||||
return mDexoptPackages.isEmpty();
|
return mDexoptPackages.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized float getProgress() throws RemoteException {
|
||||||
|
if (completeSize == 0) {
|
||||||
|
return 1f;
|
||||||
|
}
|
||||||
|
return (completeSize - mDexoptPackages.size()) / ((float)completeSize);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void dexoptNextPackage() throws RemoteException {
|
public synchronized void dexoptNextPackage() throws RemoteException {
|
||||||
if (mDexoptPackages == null) {
|
if (mDexoptPackages == null) {
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class OtaDexoptShellCommand extends ShellCommand {
|
|||||||
return runOtaDone();
|
return runOtaDone();
|
||||||
case "step":
|
case "step":
|
||||||
return runOtaStep();
|
return runOtaStep();
|
||||||
|
case "progress":
|
||||||
|
return runOtaProgress();
|
||||||
default:
|
default:
|
||||||
return handleDefaultCommands(cmd);
|
return handleDefaultCommands(cmd);
|
||||||
}
|
}
|
||||||
@@ -81,6 +83,13 @@ class OtaDexoptShellCommand extends ShellCommand {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int runOtaProgress() throws RemoteException {
|
||||||
|
final float progress = mInterface.getProgress();
|
||||||
|
final PrintWriter pw = getOutPrintWriter();
|
||||||
|
pw.format("%.2f", progress);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHelp() {
|
public void onHelp() {
|
||||||
final PrintWriter pw = getOutPrintWriter();
|
final PrintWriter pw = getOutPrintWriter();
|
||||||
|
|||||||
Reference in New Issue
Block a user