Sha256: f2b9a8e966145c0e790e293569685edc883144d9150072ec3ccc43cc8a6dca76

Contents?: true

Size: 1.38 KB

Versions: 259

Compression:

Stored size: 1.38 KB

Contents

module Fastlane
  module Helper
    class AdbDevice
      attr_accessor :serial

      def initialize(serial: nil)
        self.serial = serial
      end
    end

    class AdbHelper
      # Path to the adb binary
      attr_accessor :adb_path

      # All available devices
      attr_accessor :devices

      def initialize(adb_path: nil)
        android_home = ENV['ANDROID_HOME'] || ENV['ANDROID_SDK_ROOT'] || ENV['ANDROID_SDK']
        if (adb_path.nil? || adb_path == "adb") && android_home
          adb_path = File.join(android_home, "platform-tools", "adb")
        end
        self.adb_path = adb_path
      end

      # Run a certain action
      def trigger(command: nil, serial: nil)
        android_serial = serial != "" ? "ANDROID_SERIAL=#{serial}" : nil
        command = [android_serial, adb_path.shellescape, command].join(" ").strip
        Action.sh(command)
      end

      def device_avalaible?(serial)
        load_all_devices
        return devices.map(&:serial).include?(serial)
      end

      def load_all_devices
        self.devices = []

        command = [adb_path.shellescape, "devices"].join(" ")
        output = Actions.sh(command, log: false)
        output.split("\n").each do |line|
          if (result = line.match(/(.*)\tdevice$/))
            self.devices << AdbDevice.new(serial: result[1])
          end
        end
        self.devices
      end
    end
  end
end

Version data entries

259 entries across 259 versions & 2 rubygems

Version Path
fastlane-2.129.0.beta.20190811200106 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190810200059 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190809200051 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190808200013 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190807200122 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190806200055 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190805200019 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190804200053 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190803200103 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190802200057 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190731200035 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190730200040 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190729200106 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190728200052 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190727200032 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190726200041 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.128.1 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190725200033 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.129.0.beta.20190723200012 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.128.0 fastlane/lib/fastlane/helper/adb_helper.rb