Class: Pindo::Command::Android::Install
- Inherits:
-
Android
- Object
- Android
- Pindo::Command::Android::Install
- Defined in:
- lib/pindo/command/android/install.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Install
constructor
A new instance of Install.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Install
Returns a new instance of Install.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pindo/command/android/install.rb', line 38 def initialize(argv) @args_apk_file = argv.shift_argument @options = (argv) apk_option = @options[:apk] rescue nil if !apk_option.nil? @args_apk_file = apk_option end if @args_apk_file && !@args_apk_file.empty? @args_apk_file = @args_apk_file.strip.gsub(/\"/, '') end super(argv) end |
Class Method Details
.option_items ⇒ Object
28 29 30 31 32 |
# File 'lib/pindo/command/android/install.rb', line 28 def self.option_items @option_items ||= Pindo::Options::OptionGroup.merge( Pindo::Options::ToolOptions.select(:apk) ) end |
.options ⇒ Object
34 35 36 |
# File 'lib/pindo/command/android/install.rb', line 34 def self. option_items.map(&:to_claide_option).concat(super) end |
Instance Method Details
#run ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/pindo/command/android/install.rb', line 57 def run # 1. 查找 adb @adb_path = find_adb puts "ADB: #{@adb_path}" # 2. 查找 APK 文件 apk_file = find_apk_file puts "APK 文件: #{apk_file}" # 3. 检测可用设备 devices = detect_available_devices if devices.empty? raise Informative, "未检测到可用的 Android 设备,请确认设备已连接并开启 USB 调试" end # 4. 选择设备 device = select_device(devices) puts "目标设备: #{device[:brand]} #{device[:model]} (#{device[:serial]})" # 5. 安装 APK install_apk_to_device(apk_file, device) end |
#validate! ⇒ Object
53 54 55 |
# File 'lib/pindo/command/android/install.rb', line 53 def validate! super end |