2 * Copyright (C) 2015 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.server.pm;
19 import android.content.pm.IOtaDexopt;
20 import android.os.RemoteException;
21 import android.os.ShellCommand;
23 import java.io.PrintWriter;
25 class OtaDexoptShellCommand extends ShellCommand {
26 final IOtaDexopt mInterface;
28 OtaDexoptShellCommand(OtaDexoptService service) {
33 public int onCommand(String cmd) {
35 return handleDefaultCommands(null);
38 final PrintWriter pw = getOutPrintWriter();
42 return runOtaPrepare();
44 return runOtaCleanup();
52 return runOtaProgress();
54 return handleDefaultCommands(cmd);
56 } catch (RemoteException e) {
57 pw.println("Remote exception: " + e);
62 private int runOtaPrepare() throws RemoteException {
64 getOutPrintWriter().println("Success");
68 private int runOtaCleanup() throws RemoteException {
73 private int runOtaDone() throws RemoteException {
74 final PrintWriter pw = getOutPrintWriter();
75 if (mInterface.isDone()) {
76 pw.println("OTA complete.");
78 pw.println("OTA incomplete.");
83 private int runOtaStep() throws RemoteException {
84 mInterface.dexoptNextPackage();
88 private int runOtaNext() throws RemoteException {
89 getOutPrintWriter().println(mInterface.nextDexoptCommand());
93 private int runOtaProgress() throws RemoteException {
94 final float progress = mInterface.getProgress();
95 final PrintWriter pw = getOutPrintWriter();
96 pw.format("%.2f", progress);
101 public void onHelp() {
102 final PrintWriter pw = getOutPrintWriter();
103 pw.println("OTA Dexopt (ota) commands:");
105 pw.println(" Print this help text.");
107 pw.println(" prepare");
108 pw.println(" Prepare an OTA dexopt pass, collecting all packages.");
110 pw.println(" Replies whether the OTA is complete or not.");
112 pw.println(" OTA dexopt the next package.");
114 pw.println(" Get parameters for OTA dexopt of the next package.");
115 pw.println(" cleanup");
116 pw.println(" Clean up internal states. Ends an OTA session.");