Class: AppInfo::APK
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Defined in:
- lib/app_info/apk.rb
Overview
Defined Under Namespace
Modules: Device
Classes: Certificate, Sign
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(file) ⇒ APK
Returns a new instance of APK.
23
24
25
26
27
28
|
# File 'lib/app_info/apk.rb', line 23
def initialize(file)
@file = file
Zip.warn_invalid_date = false @apk = ::Android::Apk.new(file)
end
|
Instance Attribute Details
Returns the value of attribute apk.
13
14
15
|
# File 'lib/app_info/apk.rb', line 13
def apk
@apk
end
|
Returns the value of attribute file.
13
14
15
|
# File 'lib/app_info/apk.rb', line 13
def file
@file
end
|
Instance Method Details
#activities ⇒ Object
107
108
109
|
# File 'lib/app_info/apk.rb', line 107
def activities
components.select { |c| c.type == 'activity' }
end
|
#certificates ⇒ Object
101
102
103
104
105
|
# File 'lib/app_info/apk.rb', line 101
def certificates
@apk.certificates.each_with_object([]) do |(path, certificate), obj|
obj << Certificate.new(path, certificate)
end
end
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/app_info/apk.rb', line 115
def icons
unless @icons
tmp_path = File.join(Dir.mktmpdir, "AppInfo-android-#{SecureRandom.hex}")
@icons = @apk.icon.each_with_object([]) do |(path, data), obj|
icon_name = File.basename(path)
icon_path = File.join(tmp_path, File.dirname(path))
icon_file = File.join(icon_path, icon_name)
FileUtils.mkdir_p icon_path
File.open(icon_file, 'w') do |f|
f.write(data.force_encoding('BINARY'))
end
obj << {
name: icon_name,
file: icon_file,
dimensions: ImageSize.path(icon_file).size
}
end
end
@icons
end
|
#min_sdk_version ⇒ Object
80
81
82
|
# File 'lib/app_info/apk.rb', line 80
def min_sdk_version
manifest.min_sdk_ver
end
|
53
54
55
|
# File 'lib/app_info/apk.rb', line 53
def name
resource.find('@string/app_name')
end
|
#os ⇒ Object
Also known as:
file_type
111
112
113
|
# File 'lib/app_info/apk.rb', line 111
def services
components.select { |c| c.type == 'service' }
end
|
95
96
97
98
99
|
# File 'lib/app_info/apk.rb', line 95
def signs
@apk.signs.each_with_object([]) do |(path, sign), obj|
obj << Sign.new(path, sign)
end
end
|
#size(humanable = false) ⇒ Object
30
31
32
|
# File 'lib/app_info/apk.rb', line 30
def size(humanable = false)
AppInfo::Util.file_size(@file, humanable)
end
|
#target_sdk_version ⇒ Object
84
85
86
87
88
89
|
# File 'lib/app_info/apk.rb', line 84
def target_sdk_version
manifest.doc
.elements['/manifest/uses-sdk']
.attributes['targetSdkVersion']
.to_i
end
|
#tv? ⇒ Boolean
76
77
78
|
# File 'lib/app_info/apk.rb', line 76
def tv?
use_features.include?('android.software.leanback')
end
|
#use_features ⇒ Object
91
92
93
|
# File 'lib/app_info/apk.rb', line 91
def use_features
manifest_values('/manifest/uses-feature')
end
|
#version_code ⇒ Object
Also known as:
build_version
48
49
50
|
# File 'lib/app_info/apk.rb', line 48
def version_code
manifest.version_code.to_s
end
|
#wear? ⇒ Boolean
TODO: find a way to detect def tablet?
resource
end
72
73
74
|
# File 'lib/app_info/apk.rb', line 72
def wear?
use_features.include?('android.hardware.type.watch')
end
|