<commit_before>require 'net/telnet'

module Ruboto
  module Util
    module Emulator
      ON_WINDOWS = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/i)

      API_LEVEL_TO_VERSION = {
          10 => '2.3.3', 11 => '3.0', 12 => '3.1', 13 => '3.2', 14 => '4.0',
          15 => '4.0.3', 16 => '4.1.2', 17 => '4.2.2',
      }

      def sdk_level_name(sdk_level)
        API_LEVEL_TO_VERSION[sdk_level]
      end

      def start_emulator(sdk_level)
        sdk_level = sdk_level.gsub(/^android-/, '').to_i
        STDOUT.sync = true
        if RbConfig::CONFIG['host_cpu'] == 'x86_64'
          emulator_cmd = 'emulator64-arm'
        else
          emulator_cmd = 'emulator-arm'
        end

        emulator_opts = '-partition-size 256'
        if !ON_WINDOWS && ENV['DISPLAY'].nil?
          emulator_opts << ' -no-window -no-audio'
        end

        avd_name = "Android_#{sdk_level_name(sdk_level)}"
        new_snapshot = false

        if `adb devices` =~ /emulator-5554/
          t = Net::Telnet.new('Host' => 'localhost', 'Port' => 5554, 'Prompt' => /^OK\n/)
          t.waitfor(/^OK\n/)
          output = ''
          t.cmd('avd name') { |c| output << c }
          t.close<commit_msg>* Support starting of Android 4.3 emulator.<commit_after>require 'net/telnet'

module Ruboto
  module Util
    module Emulator
      ON_WINDOWS = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/i)

      API_LEVEL_TO_VERSION = {
          10 => '2.3.3', 11 => '3.0', 12 => '3.1', 13 => '3.2', 14 => '4.0',
          15 => '4.0.3', 16 => '4.1.2', 17 => '4.2.2', 18 => '4.3',
      }

      def sdk_level_name(sdk_level)
        API_LEVEL_TO_VERSION[sdk_level]
      end

      def start_emulator(sdk_level)
        sdk_level = sdk_level.gsub(/^android-/, '').to_i
        STDOUT.sync = true
        if RbConfig::CONFIG['host_cpu'] == 'x86_64'
          emulator_cmd = 'emulator64-arm'
        else
          emulator_cmd = 'emulator-arm'
        end

        emulator_opts = '-partition-size 256'
        if !ON_WINDOWS && ENV['DISPLAY'].nil?
          emulator_opts << ' -no-window -no-audio'
        end

        avd_name = "Android_#{sdk_level_name(sdk_level)}"
        new_snapshot = false

        if `adb devices` =~ /emulator-5554/
          t = Net::Telnet.new('Host' => 'localhost', 'Port' => 5554, 'Prompt' => /^OK\n/)
          t.waitfor(/^OK\n/)
          output = ''
          t.cmd('avd name') { |c| output << c }
          t.close
{'fraction_non_alphanumeric': 0.16687166871668715, 'fraction_numerical': 0.04592045920459205, 'mean_word_length': 1.9865361077111383, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 26, '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': '2104826', 'n_tokens_mistral': 966, 'n_tokens_neox': 894, 'n_words': 169}