Sha256: a32e1479df2d47fc59c0750b436b2897d798f2a00efc3661c0e34ed56eda59ab

Contents?: true

Size: 1.27 KB

Versions: 63

Compression:

Stored size: 1.27 KB

Contents

require_relative 'module'
require 'fastlane_core/command_executor'

module Screengrab
  class AndroidEnvironment
    attr_reader :android_home

    # android_home        - the String path to the install location of the Android SDK
    # build_tools_version - the String version of the Android build tools that should be used, ignored
    def initialize(android_home, build_tools_version = nil)
      @android_home = android_home
    end

    def platform_tools_path
      @platform_tools_path ||= find_platform_tools(android_home)
    end

    def adb_path
      @adb_path ||= find_adb(platform_tools_path)
    end

    private

    def find_platform_tools(android_home)
      return nil unless android_home

      platform_tools_path = Helper.localize_file_path(File.join(android_home, 'platform-tools'))
      File.directory?(platform_tools_path) ? platform_tools_path : nil
    end

    def find_adb(platform_tools_path)
      return FastlaneCore::CommandExecutor.which('adb') unless platform_tools_path

      adb_path = Helper.get_executable_path(File.join(platform_tools_path, 'adb'))
      adb_path = Helper.localize_file_path(adb_path)
      return executable_command?(adb_path) ? adb_path : nil
    end

    def executable_command?(cmd_path)
      Helper.executable?(cmd_path)
    end
  end
end

Version data entries

63 entries across 63 versions & 4 rubygems

Version Path
fastlane-2.225.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.224.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.223.1 screengrab/lib/screengrab/android_environment.rb
fastlane-2.223.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.222.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.221.1 screengrab/lib/screengrab/android_environment.rb
fastlane-2.221.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.220.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.219.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.218.0 screengrab/lib/screengrab/android_environment.rb
fastlane-security-patched-2.216.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.217.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.216.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.215.1 screengrab/lib/screengrab/android_environment.rb
fastlane-2.215.0 screengrab/lib/screengrab/android_environment.rb
fastlane-mercafacil-2.214.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.214.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.213.0 screengrab/lib/screengrab/android_environment.rb
fastlane-2.212.2 screengrab/lib/screengrab/android_environment.rb
fastlane_pricing_fix-2.212.1 screengrab/lib/screengrab/android_environment.rb