Sha256: 074fd946910c4cb7e1ba43bd66318672d9c06e4ddc4f1358a3142dffef7d1a78

Contents?: true

Size: 1.57 KB

Versions: 60

Compression:

Stored size: 1.57 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)
        UI.deprecated("Please use `device_available?` instead... This will be removed in a future version of fastlane")
        device_available?(serial)
      end

      def device_available?(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

60 entries across 60 versions & 1 rubygems

Version Path
fastlane-2.132.0.beta.20190918200023 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.132.0.beta.20190917200011 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.132.0.beta.20190916200055 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.132.0.beta.20190915200038 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.132.0.beta.20190914200034 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.132.0.beta.20190913200058 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.132.0.beta.20190912200052 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0.beta.20190911200010 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0.beta.20190910200104 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0.beta.20190909200058 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0.beta.20190908200041 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0.beta.20190907200030 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0.beta.20190906200026 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0.beta.20190905200113 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0.beta.20190904200040 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0.beta.20190903200013 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0.beta.20190902200022 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0.beta.20190901200035 fastlane/lib/fastlane/helper/adb_helper.rb
fastlane-2.131.0.beta.20190831200041 fastlane/lib/fastlane/helper/adb_helper.rb