// Path: src/main/java/com/github/xsavikx/androidscreencast/exception/IllegalAdbConfigurationException.java
// public final class IllegalAdbConfigurationException extends AndroidScreenCastRuntimeException {
// 
//     public IllegalAdbConfigurationException(String adbPath) {
//         super(String.format("Exception happened during running your ADB instance. Probably ADB path is misconfigured. ADB path='%s'", adbPath));
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/util/StringUtils.java
// public final class StringUtils {
// 
//     private StringUtils() {
//     }
// 
//     public static boolean isNotEmpty(final CharSequence charSequence) {
//         return charSequence != null && charSequence.length() > 0;
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/configuration/ApplicationConfigurationPropertyKeys.java
// public static final String ADB_PATH_KEY = "adb.path";


import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;
import com.github.xsavikx.androidscreencast.exception.IllegalAdbConfigurationException;
import com.github.xsavikx.androidscreencast.util.StringUtils;
import com.google.common.annotations.VisibleForTesting;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.IOException;
import static com.github.xsavikx.androidscreencast.configuration.ApplicationConfigurationPropertyKeys.ADB_PATH_KEY;
        if (adb == null) {
            init();
        }
        return adb;
    }

    private void init() {
        if (adb != null) {
            return;
        }
        try {
            adb = createAndroidDebugBridge();
        } catch (IllegalArgumentException e) {
            if (hasAdbProcFailed(e)) {
                throw new IllegalAdbConfigurationException(adbPath);
            }
            throw e;
        }
    }

    @VisibleForTesting
    AndroidDebugBridge createAndroidDebugBridge() {
        AndroidDebugBridge.initIfNeeded(false);
        if (hasAdbPathFilled()) {
            return AndroidDebugBridge.createBridge(adbPath, false);
        }
        return AndroidDebugBridge.createBridge();
    }

    private boolean hasAdbPathFilled() {
// Path: src/main/java/com/github/xsavikx/androidscreencast/exception/IllegalAdbConfigurationException.java
// public final class IllegalAdbConfigurationException extends AndroidScreenCastRuntimeException {
// 
//     public IllegalAdbConfigurationException(String adbPath) {
//         super(String.format("Exception happened during running your ADB instance. Probably ADB path is misconfigured. ADB path='%s'", adbPath));
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/util/StringUtils.java
// public final class StringUtils {
// 
//     private StringUtils() {
//     }
// 
//     public static boolean isNotEmpty(final CharSequence charSequence) {
//         return charSequence != null && charSequence.length() > 0;
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/configuration/ApplicationConfigurationPropertyKeys.java
// public static final String ADB_PATH_KEY = "adb.path";


// Path: src/main/java/com/github/xsavikx/androidscreencast/api/adb/AndroidDebugBridgeWrapper.java
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;
import com.github.xsavikx.androidscreencast.exception.IllegalAdbConfigurationException;
import com.github.xsavikx.androidscreencast.util.StringUtils;
import com.google.common.annotations.VisibleForTesting;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.IOException;
import static com.github.xsavikx.androidscreencast.configuration.ApplicationConfigurationPropertyKeys.ADB_PATH_KEY;

        if (adb == null) {
            init();
        }
        return adb;
    }

    private void init() {
        if (adb != null) {
            return;
        }
        try {
            adb = createAndroidDebugBridge();
        } catch (IllegalArgumentException e) {
            if (hasAdbProcFailed(e)) {
                throw new IllegalAdbConfigurationException(adbPath);
            }
            throw e;
        }
    }

    @VisibleForTesting
    AndroidDebugBridge createAndroidDebugBridge() {
        AndroidDebugBridge.initIfNeeded(false);
        if (hasAdbPathFilled()) {
            return AndroidDebugBridge.createBridge(adbPath, false);
        }
        return AndroidDebugBridge.createBridge();
    }

    private boolean hasAdbPathFilled() {
        return StringUtils.isNotEmpty(adbPath);