Class: Android::AAPT

Inherits:
Object
  • Object
show all
Defined in:
lib/android/aapt.rb

Constant Summary collapse

@@aapt =
File.dirname(__FILE__) + "/../binaries/aapt"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(apk_path) ⇒ AAPT

Returns a new instance of AAPT.



6
7
8
# File 'lib/android/aapt.rb', line 6

def initialize(apk_path)
  @apk = apk_path
end

Instance Attribute Details

#apkObject (readonly)

Returns the value of attribute apk.



4
5
6
# File 'lib/android/aapt.rb', line 4

def apk
  @apk
end

Instance Method Details

#aapt(commands) ⇒ Object



10
11
12
# File 'lib/android/aapt.rb', line 10

def aapt(commands)
  `#{@@aapt} #{commands} #{@apk}`
end

#dumpObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/android/aapt.rb', line 14

def dump
  attrs = {}
  info = aapt('dump badging')
  package = info.match(/package:\s*(.*)/)[1] rescue nil
  attrs[:name] = package.match(/name='([^']*)'/)[1] rescue nil
  attrs[:version_code] = package.match(/versionCode='([^']*)'/)[1] rescue nil
  attrs[:version_name] = package.match(/versionName='([^']*)'/)[1] rescue nil
  attrs[:label] = info.match(/application-label:\s*'([^']*)'/)[1] rescue nil
  attrs
end