// Path: src/main/java/com/github/xsavikx/androidscreencast/api/command/Command.java
// public interface Command {
// 
//     String INPUT = "input";
//     String WHITESPACE = " ";
// 
//     String getFormattedCommand();
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/api/command/exception/AdbShellCommandExecutionException.java
// public final class AdbShellCommandExecutionException extends CommandExecutionException {
// 
//     private static final String ERROR_MESSAGE = "Error while executing command: %s";
// 
//     private static final long serialVersionUID = -503890452151627952L;
// 
//     public AdbShellCommandExecutionException(Command command, Throwable cause) {
//         super(String.format(ERROR_MESSAGE, command.getFormattedCommand()), cause);
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/configuration/ApplicationConfigurationPropertyKeys.java
// public static final String ADB_COMMAND_TIMEOUT_KEY = "adb.command.timeout";


import com.android.ddmlib.*;
import com.github.xsavikx.androidscreencast.api.command.Command;
import com.github.xsavikx.androidscreencast.api.command.exception.AdbShellCommandExecutionException;
import org.slf4j.Logger;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static com.github.xsavikx.androidscreencast.configuration.ApplicationConfigurationPropertyKeys.ADB_COMMAND_TIMEOUT_KEY;
import static org.slf4j.LoggerFactory.getLogger;
/*
 * Copyright 2020 Yurii Serhiichuk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.github.xsavikx.androidscreencast.api.command.executor;




@Singleton
public final class ShellCommandExecutor implements CommandExecutor {

    private final IDevice device;
    private final IShellOutputReceiver shellOutputReceiver;
    private final long adbCommandTimeout;

    @Inject
    public ShellCommandExecutor(final IDevice device,
                                final IShellOutputReceiver shellOutputReceiver,
// Path: src/main/java/com/github/xsavikx/androidscreencast/api/command/Command.java
// public interface Command {
// 
//     String INPUT = "input";
//     String WHITESPACE = " ";
// 
//     String getFormattedCommand();
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/api/command/exception/AdbShellCommandExecutionException.java
// public final class AdbShellCommandExecutionException extends CommandExecutionException {
// 
//     private static final String ERROR_MESSAGE = "Error while executing command: %s";
// 
//     private static final long serialVersionUID = -503890452151627952L;
// 
//     public AdbShellCommandExecutionException(Command command, Throwable cause) {
//         super(String.format(ERROR_MESSAGE, command.getFormattedCommand()), cause);
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/configuration/ApplicationConfigurationPropertyKeys.java
// public static final String ADB_COMMAND_TIMEOUT_KEY = "adb.command.timeout";


// Path: src/main/java/com/github/xsavikx/androidscreencast/api/command/executor/ShellCommandExecutor.java
import com.android.ddmlib.*;
import com.github.xsavikx.androidscreencast.api.command.Command;
import com.github.xsavikx.androidscreencast.api.command.exception.AdbShellCommandExecutionException;
import org.slf4j.Logger;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static com.github.xsavikx.androidscreencast.configuration.ApplicationConfigurationPropertyKeys.ADB_COMMAND_TIMEOUT_KEY;
import static org.slf4j.LoggerFactory.getLogger;

/*
 * Copyright 2020 Yurii Serhiichuk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.github.xsavikx.androidscreencast.api.command.executor;




@Singleton
public final class ShellCommandExecutor implements CommandExecutor {

    private final IDevice device;
    private final IShellOutputReceiver shellOutputReceiver;
    private final long adbCommandTimeout;

    @Inject
    public ShellCommandExecutor(final IDevice device,
                                final IShellOutputReceiver shellOutputReceiver,
                                @Named(ADB_COMMAND_TIMEOUT_KEY) long adbCommandTimeout) {