def run_adb_command(
    cmd: str, android_target: str, shell_cmd: bool = False, runs: int = 1, sleep: int = 0, log_error: bool = True
) -> tuple[str, str]:
    """Run an ADB command on the target Android device.

    cmd: The command to run
    android_target: The target Android device
    shell_cmd: Whether to run the command in an ADB shell
    runs: The number of times to run the command
    sleep: The number of seconds to sleep between runs
    log_error: Whether to log an error if the command fails
    """
    # create the adb command prefix
    adb_head = f"adb -s {android_target}"

    # platform specific shell command
    if shell_cmd:
        if platform.system() == OS.WINDOWS:
            cmd = f"shell {cmd}"
        elif platform.system() == OS.LINUX:
            cmd = f'shell "{cmd}"'

    # run the command
    full_cmd = f"{adb_head} {cmd}"
    for run in range(runs):
        run_log_msg = "" if runs == 1 else f" (run {run + 1}/{runs})"
        logger.debug("Running ADB command %s: %s", run_log_msg, full_cmd)
        returncode, stdout, stderr = run_subprocess(full_cmd)
        logger.debug("Return code: %d \n Stdout: %s \n Stderr: %s", returncode, stdout, stderr)
        if returncode != 0:
            break
        if sleep > 0 and run < runs - 1:
            time.sleep(sleep)

    # check the return code
    if returncode != 0:
        error_msg = (
            f"Error running ADB command. \n Command: {full_cmd} \n Return code: {returncode} \n Stdout: {stdout} \n"
            f" Stderr: {stderr}"
        )
        if log_error:
            logger.error(error_msg)
        raise RuntimeError(error_msg)

    return stdout, stderr
Run an ADB command on the target Android device.

    cmd: The command to run
    android_target: The target Android device
    shell_cmd: Whether to run the command in an ADB shell
    runs: The number of times to run the command
    sleep: The number of seconds to sleep between runs
    log_error: Whether to log an error if the command fails
    
olive/platform_sdk/qualcomm/snpe/utils/adb.py