Class: FIR::Parser::Apk

Inherits:
Object show all
Includes:
Common
Defined in:
lib/fir/util/parser/apk.rb

Instance Method Summary collapse

Methods included from Common

#generate_tmp_icon

Constructor Details

#initialize(path) ⇒ Apk

Returns a new instance of Apk.



9
10
11
12
# File 'lib/fir/util/parser/apk.rb', line 9

def initialize(path)
  Zip.warn_invalid_date = false
  @apk = ::Android::Apk.new(path)
end

Instance Method Details

#basic_infoObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fir/util/parser/apk.rb', line 20

def basic_info
  @basic_info ||= {
    type: 'android',
    name: fetch_label,
    identifier: @apk.manifest.package_name,
    build: @apk.manifest.version_code.to_s,
    version: @apk.manifest.version_name.to_s
  }
  @basic_info.reject! { |_k, v| v.nil? }
  @basic_info
end

#fetch_labelObject



39
40
41
42
43
# File 'lib/fir/util/parser/apk.rb', line 39

def fetch_label
  @apk.label
rescue NoMethodError
  nil
end

#full_info(options) ⇒ Object



14
15
16
17
18
# File 'lib/fir/util/parser/apk.rb', line 14

def full_info(options)
  basic_info[:icons] = tmp_icons if options.fetch(:full_info, false)

  basic_info
end

#tmp_iconsObject



33
34
35
36
37
# File 'lib/fir/util/parser/apk.rb', line 33

def tmp_icons
  @apk.icon.map { |_, data| generate_tmp_icon(data, :apk) }
rescue StandardError
  []
end