1 /* 2 * Copyright (C) 2010 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.device; 17 18 19 /** 20 * Thrown when a device is no longer available for testing. 21 * e.g. the adb connection to the device has been lost, device has stopped responding to commands, 22 * etc 23 */ 24 @SuppressWarnings("serial") 25 public class DeviceNotAvailableException extends Exception { 26 27 private String mSerial = null; 28 29 /** 30 * Creates a {@link DeviceNotAvailableException}. 31 */ 32 public DeviceNotAvailableException() { 33 super(); 34 } 35 36 /** 37 * Creates a {@link DeviceNotAvailableException}. 38 * 39 * @param msg a descriptive message. 40 * 41 * @deprecated use {@link #DeviceNotAvailableException(String msg, String serial)} instead 42 */ 43 @Deprecated 44 public DeviceNotAvailableException(String msg) { 45 super(msg); 46 } 47 48 /** 49 * Creates a {@link DeviceNotAvailableException}. 50 * 51 * @param msg a descriptive message. 52 * @param serial the serial of the device concerned 53 */ 54 public DeviceNotAvailableException(String msg, String serial) { 55 super(msg); 56 mSerial = serial; 57 } 58 59 /** 60 * Creates a {@link DeviceNotAvailableException}. 61 * 62 * @param msg a descriptive message. 63 * @param cause the root {@link Throwable} that caused the device to become unavailable. 64 * 65 * @deprecated use 66 * {@link #DeviceNotAvailableException(String msg, Throwable cause, String serial)} instead 67 */ 68 @Deprecated 69 public DeviceNotAvailableException(String msg, Throwable cause) { 70 super(msg, cause); 71 } 72 73 /** 74 * Creates a {@link DeviceNotAvailableException}. 75 * 76 * @param msg a descriptive message. 77 * @param cause the root {@link Throwable} that caused the device to become unavailable. 78 * @param serial the serial of the device concerned by the exception 79 */ 80 public DeviceNotAvailableException(String msg, Throwable cause, String serial) { 81 super(msg, cause); 82 mSerial = serial; 83 } 84 85 /** 86 * Return Serial of the device associated with exception. 87 */ 88 public String getSerial() { 89 return mSerial; 90 } 91 } 92