Top Level Namespace
Instance Method Summary collapse
- #ExecutablePath(ex) ⇒ Object
- #ExecuteCommand(command, debug) ⇒ Object
- #FindPackageName(debug) ⇒ Object
- #InstallAPK(package_name, debug) ⇒ Object
- #InstallPack(file, debug) ⇒ Object
Instance Method Details
#ExecutablePath(ex) ⇒ Object
7 8 9 |
# File 'bin/installexp', line 7 def ExecutablePath (ex) return "#{File.dirname(__FILE__)}/#{ex}" end |
#ExecuteCommand(command, debug) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'bin/installexp', line 11 def ExecuteCommand(command, debug) stdin, stdout, stderr, wait_thr = Open3.popen3(command) res = stdout.read if debug puts ">>>>>>>>>>>>>>>>>>>>>>>>>" puts "Command '#{command}'" puts res puts "<<<<<<<<<<<<<<<<<<<<<<<<<" end stdin.close stdout.close stderr.close return res end |
#FindPackageName(debug) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'bin/installexp', line 30 def FindPackageName(debug) check_apaapt = ExecuteCommand("which apaapt", debug) if check_apaapt.length == 0 puts "Could not find apaapt in your path" return "" end apks = Dir['**/*.apk'] if(apks.length == 0) puts "No APK file found" return "" end info = ExecuteCommand("#{ExecutablePath('apaapt')} dump badging #{apks[0]}", debug) matchdata = info.match("package: name='?(.+)' versionCode='.+' versionName='.+'") package_name = matchdata[1] if package_name.length == 0 puts "Could not figure out package name" return "" end return package_name end |
#InstallAPK(package_name, debug) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'bin/installexp', line 55 def InstallAPK(package_name, debug) obb = Dir['**/*.obb'] if(obb.length == 0) puts "Could not find the stupid obb file" return false end obb_file = obb[0] apk_file = Dir['**/*.apk'][0] puts "Deleting application if present" ExecuteCommand("#{ExecutablePath('apadb')} uninstall #{package_name}", debug) version_string = ExecuteCommand("#{ExecutablePath('apadb')} shell getprop ro.build.version.release", debug) version = version_string.match("\\d.(\\d)*")[0].to_f path_prefix = "/mnt/sdcard/Android/obb" if version >= 4.2 path_prefix = "/mnt/shell/emulated/obb" end puts "Pushing expansion file" ExecuteCommand("#{ExecutablePath('apadb')} push #{obb_file} #{path_prefix}/#{package_name}/#{File.basename(obb_file)}", debug) puts "Installing application" ExecuteCommand("#{ExecutablePath('apadb')} install #{apk_file}", debug) return true end |
#InstallPack(file, debug) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'bin/installexp', line 83 def InstallPack(file, debug) unzip_location = "/tmp/#{file}_unzip" if File.exists?(unzip_location) FileUtils.rm_rf(unzip_location) end ExecuteCommand("unzip #{file} -d #{unzip_location}", debug) if(!File.exists?(unzip_location)) puts "Could not unzip the damn file" return end FileUtils.cd(unzip_location) do package_name = FindPackageName(debug) if package_name.length == 0 return end success = InstallAPK(package_name, debug) if success puts "Successfully installed application" else puts "Something went wrong" end end puts "Cleaning up" FileUtils.rm_rf(unzip_location) end |