Sha256: 11c7c2904db8eb4ca0533436562ec3894dd9fbfdae999c515bea4fd447bea10d

Contents?: true

Size: 1.12 KB

Versions: 629

Compression:

Stored size: 1.12 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)
        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, command].join(" ")
        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, "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

629 entries across 629 versions & 1 rubygems

Version Path
fastlane-2.90.0 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.90.0.beta.20180410050128 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.90.0.beta.20180409050033 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.90.0.beta.20180408050113 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.90.0.beta.20180407050037 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.90.0.beta.20180406050006 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.90.0.beta.20180405050125 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.90.0.beta.20180404050031 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.90.0.beta.20180403050108 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.89.0 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.89.0.beta.20180402050042 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.89.0.beta.20180401050120 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.89.0.beta.20180331050023 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.89.0.beta.20180330050046 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.89.0.beta.20180329050050 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.89.0.beta.20180328050040 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.88.0 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.88.0.beta.20180327050037 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.88.0.beta.20180325050025 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.88.0.beta.20180324050059 fastlane/lib/fastlane/helper/adb_helper.rb