Class: Abra::AAPT

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

Class Method Summary collapse

Class Method Details

.dump_badging(apk) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/aapt.rb', line 7

def self.dump_badging(apk)
  attrs = {}
  info = self.exec('dump badging', apk)
  package = info.match(/package:\s*(.*)/)[1] rescue nil
  application = info.match(/application:\s*(.*)/)[1] rescue nil
  attrs[:package] = 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.scan(/application-label-zh:\s*'([^']*)'/)[0]
  if not attrs[:label] or attrs[:label].length == 0
    m = info.scan(/label='([^']*)'/)
    attrs[:label] = self.parse(m)
  end
  attrs[:icon] = application.match(/icon='([^']*)'/)[1] rescue nil
  attrs[:api_level] = info.match(/sdkVersion:\s*'(.*)'/)[1] rescue nil
  attrs
end

.exec(command, apk) ⇒ Object



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

def self.exec(command, apk)
  `#{self.aapt} #{command} #{apk}`
end