class Radb::Application

Public Instance Methods

logcat(package) click to toggle source
# File lib/radb.rb, line 103
def logcat(package)
    target = get_target(options[:serial])
    process_id = %x(adb #{which_one(target)} shell ps | grep #{package} | cut -c10-15)

    if command?("logcat-color")
        s = "logcat-color #{which_one(target)} \"*:I\""
    else
        puts "You should install `logcat-color` for better output"
        s = "adb #{which_one(target)} \"*:I\""
    end

    if process_id.empty?
        say "Cannot found #{package}. It will print all logs."
    else
        s = s + " | grep #{process_id}"
    end

    run s, :verbose => false
rescue
end
otadebug() click to toggle source
# File lib/radb.rb, line 86
def otadebug
    target = get_target(options[:serial])
    ip = get_ipv4(target)
    say "Target ip: " + ip
    run "adb #{which_one(target)} tcpip 5555", :verbose => false
    run "adb #{which_one(target)} connect #{ip}", :verbose => false
end
pull(package) click to toggle source
# File lib/radb.rb, line 24
def pull(package)

    target = get_target(options[:serial])
    database_path = "/data/data/#{package}/databases/" + options[:database]
    images_path = "/sdcard/DCIM/" + options[:image_dir]

    say " > Pull database from " + database_path
    run "adb #{which_one(target)} shell \"run-as #{package} chmod 666 #{database_path}\"", :verbose => false
    run "adb #{which_one(target)} pull #{database_path}", :verbose => false
    run "adb #{which_one(target)} shell \"run-as #{package} chmod 600 #{database_path}\"", :verbose => false

    say " > Pull images from " + images_path
    run "adb #{which_one(target)} pull #{images_path} #{options[:image_dir]} ", :verbose => false
end
push(package) click to toggle source
# File lib/radb.rb, line 51
def push(package)

    target = get_target(options[:serial])
    database_dir = "/data/data/#{package}/databases/"
    database_path = options[:database]
    images_path = "/sdcard/DCIM/" + options[:image_dir]

    say " > Push database from " + database_path + " to " + database_dir
    run "adb #{which_one(target)} shell \"run-as #{package} chmod 666  #{database_dir}#{database_path}\"", :verbose => false
    run "adb #{which_one(target)} push '#{database_path}' '#{database_dir}' ", :verbose => false
    run "adb #{which_one(target)} shell \"run-as #{package} chmod 600  #{database_dir}#{database_path}\"", :verbose => false
    run "adb #{which_one(target)} push '#{options[:image_dir]}' '#{images_path}'", :verbose => false
end