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 17 package com.android.ddmlib; 18 19 import java.io.IOException; 20 21 /** 22 * Exception thrown when adb refuses a command. 23 */ 24 public class AdbCommandRejectedException extends IOException { 25 private static final long serialVersionUID = 1L; 26 private final boolean mIsDeviceOffline; 27 private final boolean mErrorDuringDeviceSelection; 28 AdbCommandRejectedException(String message)29 AdbCommandRejectedException(String message) { 30 super(message); 31 mIsDeviceOffline = "device offline".equals(message); 32 mErrorDuringDeviceSelection = false; 33 } 34 AdbCommandRejectedException(String message, boolean errorDuringDeviceSelection)35 AdbCommandRejectedException(String message, boolean errorDuringDeviceSelection) { 36 super(message); 37 mErrorDuringDeviceSelection = errorDuringDeviceSelection; 38 mIsDeviceOffline = "device offline".equals(message); 39 } 40 41 /** 42 * Returns true if the error is due to the device being offline. 43 */ isDeviceOffline()44 public boolean isDeviceOffline() { 45 return mIsDeviceOffline; 46 } 47 48 /** 49 * Returns whether adb refused to target a given device for the command. 50 * <p/>If false, adb refused the command itself, if true, it refused to target the given 51 * device. 52 */ wasErrorDuringDeviceSelection()53 public boolean wasErrorDuringDeviceSelection() { 54 return mErrorDuringDeviceSelection; 55 } 56 } 57