1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17 package com.android.interactive; 18 19 /** 20 * A {@link Step} used when automation has failed. 21 */ 22 final class AutomatingFailedStep extends Step<Integer> { 23 24 public static final int CONTINUE_MANUALLY = 1; 25 public static final int RETRY = 2; 26 public static final int RESTART_MANUALLY = 3; 27 public static final int FAIL = 4; 28 public static final int RESTART = 5; 29 30 private final String mInstruction; 31 AutomatingFailedStep(String instruction)32 public AutomatingFailedStep(String instruction) { 33 mInstruction = instruction; 34 } 35 36 @Override interact()37 public void interact() { 38 show(mInstruction); 39 40 addButton("Retry", () -> { 41 pass(RETRY); 42 close(); 43 }); 44 45 addButton("Restart", () -> { 46 pass(RESTART); 47 close(); 48 }); 49 50 addButton("Continue Manually", () -> { 51 pass(CONTINUE_MANUALLY); 52 close(); 53 }); 54 55 addButton("Restart Manually", () -> { 56 pass(RESTART_MANUALLY); 57 close(); 58 }); 59 60 addButton("Fail", () -> { 61 pass(FAIL); 62 close(); 63 }); 64 } 65 } 66