Remove TODO(b/251903639) from PackageManagerShellCommand.

We are now forwarding all dexopt shell commands to ART Service, so
PackageManagerShellCommand doesn't need to call into ART Service in the
legacy shell command handlers.

Bug: 251903639
Bug: 263247832
Test: Presubmit
Change-Id: I2e9c9dbf6f5713a2bed98463bf2fd57c77852ba9
This commit is contained in:
Jiakai Zhang
2023-01-13 18:28:40 +08:00
parent 7f8adb3e0c
commit aaedfaf9e1

View File

@@ -1979,63 +1979,53 @@ class PackageManagerShellCommand extends ShellCommand {
return 0;
}
private int runBgDexOpt() throws RemoteException {
// TODO(b/251903639): Call into ART Service.
try {
String opt = getNextOption();
private int runBgDexOpt() throws RemoteException, LegacyDexoptDisabledException {
String opt = getNextOption();
if (opt == null) {
List<String> packageNames = new ArrayList<>();
String arg;
while ((arg = getNextArg()) != null) {
packageNames.add(arg);
}
if (!BackgroundDexOptService.getService().runBackgroundDexoptJob(
packageNames.isEmpty() ? null : packageNames)) {
getOutPrintWriter().println("Failure");
return -1;
}
} else {
String extraArg = getNextArg();
if (extraArg != null) {
getErrPrintWriter().println("Invalid argument: " + extraArg);
return -1;
}
switch (opt) {
case "--cancel":
return cancelBgDexOptJob();
case "--disable":
BackgroundDexOptService.getService().setDisableJobSchedulerJobs(true);
break;
case "--enable":
BackgroundDexOptService.getService().setDisableJobSchedulerJobs(false);
break;
default:
getErrPrintWriter().println("Unknown option: " + opt);
return -1;
}
if (opt == null) {
List<String> packageNames = new ArrayList<>();
String arg;
while ((arg = getNextArg()) != null) {
packageNames.add(arg);
}
if (!BackgroundDexOptService.getService().runBackgroundDexoptJob(
packageNames.isEmpty() ? null : packageNames)) {
getOutPrintWriter().println("Failure");
return -1;
}
} else {
String extraArg = getNextArg();
if (extraArg != null) {
getErrPrintWriter().println("Invalid argument: " + extraArg);
return -1;
}
getOutPrintWriter().println("Success");
return 0;
} catch (LegacyDexoptDisabledException e) {
throw new RuntimeException(e);
switch (opt) {
case "--cancel":
return cancelBgDexOptJob();
case "--disable":
BackgroundDexOptService.getService().setDisableJobSchedulerJobs(true);
break;
case "--enable":
BackgroundDexOptService.getService().setDisableJobSchedulerJobs(false);
break;
default:
getErrPrintWriter().println("Unknown option: " + opt);
return -1;
}
}
getOutPrintWriter().println("Success");
return 0;
}
private int cancelBgDexOptJob() throws RemoteException {
// TODO(b/251903639): Call into ART Service.
try {
BackgroundDexOptService.getService().cancelBackgroundDexoptJob();
getOutPrintWriter().println("Success");
return 0;
} catch (LegacyDexoptDisabledException e) {
throw new RuntimeException(e);
}
private int cancelBgDexOptJob() throws RemoteException, LegacyDexoptDisabledException {
BackgroundDexOptService.getService().cancelBackgroundDexoptJob();
getOutPrintWriter().println("Success");
return 0;
}
private int runDeleteDexOpt() throws RemoteException {