1 /* 2 * Copyright (C) 2013 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 package com.android.tradefed.command.remote; 17 18 import com.android.tradefed.device.FreeDeviceState; 19 20 import java.util.Map; 21 22 /** 23 * Encapsulates 'last command execution' data sent over the wire 24 */ 25 class CommandResult { 26 27 public enum Status { 28 NO_ACTIVE_COMMAND, 29 EXECUTING, 30 NOT_ALLOCATED, 31 INVOCATION_ERROR, 32 INVOCATION_SUCCESS 33 } 34 35 private final Status mStatus; 36 private final String mError; 37 private final FreeDeviceState mState; 38 private final Map<String, String> mRunMetrics; 39 CommandResult(Status status, String errorDetails, FreeDeviceState state, Map<String, String> runMetrics)40 CommandResult(Status status, String errorDetails, FreeDeviceState state, 41 Map<String, String> runMetrics) { 42 mStatus = status; 43 mError = errorDetails; 44 mState = state; 45 mRunMetrics = runMetrics; 46 } 47 CommandResult(Status status)48 public CommandResult(Status status) { 49 this(status, null, null, null); 50 } 51 getStatus()52 Status getStatus() { 53 return mStatus; 54 } 55 getInvocationErrorDetails()56 String getInvocationErrorDetails() { 57 return mError; 58 } 59 getFreeDeviceState()60 FreeDeviceState getFreeDeviceState() { 61 return mState; 62 } 63 64 /* 65 * Although commands can have multiple runs, we only return one set of metrics and replace any 66 * currently stored metrics with the same key. 67 */ getRunMetrics()68 Map<String, String> getRunMetrics() { 69 return mRunMetrics; 70 } 71 } 72