Class: Android::Command::Line::Tools::CLI
- Inherits:
-
Thor
- Object
- Thor
- Android::Command::Line::Tools::CLI
- Defined in:
- lib/android/command/line/tools/cli.rb
Instance Method Summary collapse
Instance Method Details
#clear ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/android/command/line/tools/cli.rb', line 32 def clear return (puts 'device not connected') unless device packages = list_installed_packages(device) package = select_installed_package(packages) execute_with_serial('adb', device, "shell pm clear #{package}") end |
#install ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/android/command/line/tools/cli.rb', line 21 def install return (puts 'device not connected') unless device files = list_apk_files return (puts 'apk file not found') if files.empty? file = PecoSelector.select_from(files).first execute_with_serial('adb', device, "install -r #{file}") end |
#screenrecord ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/android/command/line/tools/cli.rb', line 53 def screenrecord return (puts 'device not connected') unless device device_movie_path = "/sdcard/Download/movie_#{}.mp4" begin execute_with_serial('adb', device, "shell screenrecord #{device_movie_path}") rescue Interrupt end movie_path = Tempfile.new('movie_original').path + 'mp4' execute_with_serial('adb', device, "pull #{device_movie_path} #{movie_path}") resized_path = Tempfile.new('movie_resized').path + '.mp4' execute("ffmpeg -y -i #{movie_path} -vf scale=360:-1 -r 12 -f mp4 #{resized_path}") palette_path = Tempfile.new('movie_palette').path + '.png' execute("ffmpeg -i #{resized_path} -vf palettegen=max_colors=256 #{palette_path}") movie_path = "#{ENV['HOME']}/Desktop/movie_#{}.gif" execute("ffmpeg -i #{resized_path} -i #{palette_path} -f gif -filter_complex paletteuse #{movie_path}") execute("open #{movie_path}") end |
#screenshot ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/android/command/line/tools/cli.rb', line 41 def screenshot return (puts 'device not connected') unless device outfile = "#{ENV['HOME']}/Desktop/screenshot_#{}.png" execute_with_serial('screenshot2', device, outfile) execute("open #{outfile}") end |
#uninstall ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/android/command/line/tools/cli.rb', line 12 def uninstall return (puts 'device not connected') unless device packages = list_installed_packages(device) package = select_installed_package(packages) execute_with_serial('adb', device, "uninstall -r #{file}") end |