<commit_before>﻿using System;
using System.Collections.Generic;
using AndroidLib.Utils;
using System.Text;

namespace AndroidLib.Adb
{
    public class Adb
    {
        #region Public Fields

        /// <summary>
        /// Returns the status of the adb status
        /// </summary>
        public static Boolean ServerIsRunning
        {
            get
            {
                return Command.IsProcessRunning("adb");
            }
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// Starts the adb server instance
        /// </summary>
        public static void StartServer()
        {
            Command.RunProcessNoReturn(ResourceManager.adbPrefix, "start-server", true);
        }

        /// <summary>
        /// Kills the current adb server instances
        /// </summary>
        public static void StopServer()
        {
            Command.RunProcessNoReturn(ResourceManager.adbPrefix, "kill-server", true);
        }

        /// <summary>
        /// Executes the adb command on a specific device and returns its output
        /// </summary>
        /// <param name="command">Command to run e.g. "devices"</param>
        /// <param name="device">If this parameter is not set the first device will be selected</param>
        /// <param name="trimOutput">Remove stuff like "*daemon started successfully*" from output</param>
        /// <returns>The optimized output of adb</returns>
        public static String ExecuteAdbCommandWithOutput(String command, Device device = null, Boolean trimOutput = true)
        {
            //Check adb status
            if (!ServerIsRunning) StartServer();

            //Insert -s parameter if needed
            String cmd = command;
            if (device != null && device.SerialNumber != "") cmd = "-s " + device.SerialNumber + "" + cmd;

            //Run process via Command class
            String output = Command.RunProcessReturnOutput(ResourceManager.adbPrefix, cmd);

            //Trim if neccessary
            if (trimOutput)
                return RemoveAdbDebugStuff(output);
            else<commit_msg>Fixed command execution<commit_after>﻿using System;
using System.Collections.Generic;
using AndroidLib.Utils;
using System.Text;

namespace AndroidLib.Adb
{
    public class Adb
    {
        #region Public Fields

        /// <summary>
        /// Returns the status of the adb status
        /// </summary>
        public static Boolean ServerIsRunning
        {
            get
            {
                return Command.IsProcessRunning("adb");
            }
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// Starts the adb server instance
        /// </summary>
        public static void StartServer()
        {
            Command.RunProcessNoReturn(ResourceManager.adbPrefix, "start-server", true);
        }

        /// <summary>
        /// Kills the current adb server instances
        /// </summary>
        public static void StopServer()
        {
            Command.RunProcessNoReturn(ResourceManager.adbPrefix, "kill-server", true);
        }

        /// <summary>
        /// Executes the adb command on a specific device and returns its output
        /// </summary>
        /// <param name="command">Command to run e.g. "devices"</param>
        /// <param name="device">If this parameter is not set the first device will be selected</param>
        /// <param name="trimOutput">Remove stuff like "*daemon started successfully*" from output</param>
        /// <returns>The optimized output of adb</returns>
        public static String ExecuteAdbCommandWithOutput(String command, Device device = null, Boolean trimOutput = true)
        {
            //Check adb status
            if (!ServerIsRunning) StartServer();

            //Insert -s parameter if needed
            String cmd = command;
            if (device != null && device.SerialNumber != "") cmd = " -s " + device.SerialNumber + " " + cmd;

            //Run process via Command class
            String output = Command.RunProcessReturnOutput(ResourceManager.adbPrefix, cmd);

            //Trim if neccessary
            if (trimOutput)
                return RemoveAdbDebugStuff(output);
            else
{'fraction_non_alphanumeric': 0.102288650163475, 'fraction_numerical': 0.0, 'mean_word_length': 1.8233355306526038, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1527696', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1026, 'n_words': 325}