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();
50 return handleDefaultCommands(cmd);
52 } catch (RemoteException e) {
53 pw.println("Remote exception: " + e);
58 private int runOtaPrepare() throws RemoteException {
60 getOutPrintWriter().println("Success");
64 private int runOtaCleanup() throws RemoteException {
69 private int runOtaDone() throws RemoteException {
70 final PrintWriter pw = getOutPrintWriter();
71 if (mInterface.isDone()) {
72 pw.println("OTA complete.");
74 pw.println("OTA incomplete.");
79 private int runOtaStep() throws RemoteException {
80 mInterface.dexoptNextPackage();
85 public void onHelp() {
86 final PrintWriter pw = getOutPrintWriter();
87 pw.println("OTA Dexopt (ota) commands:");
89 pw.println(" Print this help text.");
91 pw.println(" prepare");
92 pw.println(" Prepare an OTA dexopt pass, collecting all packages.");
94 pw.println(" Replies whether the OTA is complete or not.");
96 pw.println(" OTA dexopt the next package.");
97 pw.println(" cleanup");
98 pw.println(" Clean up internal states. Ends an OTA session.");