Class: AppInfo::AAB
Overview
Constant Summary
collapse
- BASE_PATH =
'base'
- BASE_MANIFEST =
"#{BASE_PATH}/manifest/AndroidManifest.xml"
- BASE_RESOURCES =
"#{BASE_PATH}/resources.pb"
Helper::HumanFileSize::FILE_SIZE_UNITS
Instance Attribute Summary
Attributes inherited from File
#file, #logger
Instance Method Summary
collapse
Methods inherited from Android
#automotive?, #certificates, #contents, #device, #manufacturer, #platform, #signatures, #signs, #size, #tablet?, #television?, #watch?
#file_to_human_size, #number_to_human_size
Methods inherited from File
#device, #format, #initialize, #manufacturer, #not_implemented_error!, #platform, #size
Constructor Details
This class inherits a constructor from AppInfo::File
Instance Method Details
69
70
71
|
# File 'lib/app_info/aab.rb', line 69
def activities
@activities ||= manifest.activities
end
|
#clear! ⇒ Object
184
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/app_info/aab.rb', line 184
def clear!
return unless @contents
FileUtils.rm_rf(@contents)
@aab = nil
@contents = nil
@icons = nil
@app_path = nil
@info = nil
end
|
79
80
81
|
# File 'lib/app_info/aab.rb', line 79
def components
@components ||= manifest.components.transform_values
end
|
#deep_links ⇒ String
21
|
# File 'lib/app_info/aab.rb', line 21
def_delegators :manifest, :version_name, :deep_links, :schemes
|
#each_file ⇒ Object
93
94
95
96
97
98
99
|
# File 'lib/app_info/aab.rb', line 93
def each_file
zip.each do |entry|
next unless entry.file?
yield entry.name, zip.read(entry)
end
end
|
#entry(name, base_path: BASE_PATH) ⇒ Object
108
109
110
111
112
113
|
# File 'lib/app_info/aab.rb', line 108
def entry(name, base_path: BASE_PATH)
entry = zip.find_entry(::File.join(base_path, name))
raise NotFoundError, "'#{name}'" if entry.nil?
entry
end
|
#icons(exclude: nil) ⇒ Array<Hash{Symbol => String, Array<Integer>}>
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/app_info/aab.rb', line 163
def icons(exclude: nil)
@icons ||= manifest.icons.each_with_object([]) do |res, obj|
path = res.value
filename = ::File.basename(path)
filepath = ::File.join(contents, ::File.dirname(path))
file = ::File.join(filepath, filename)
FileUtils.mkdir_p(filepath)
binary_data = read_file(path)
::File.write(file, binary_data, encoding: Encoding::BINARY)
obj << {
name: filename,
file: file,
dimensions: ImageSize.path(file).size
}
end
(@icons, exclude: exclude)
end
|
#min_sdk_version ⇒ String
Also known as:
min_os_version
44
45
46
|
# File 'lib/app_info/aab.rb', line 44
def min_sdk_version
manifest.uses_sdk.min_sdk_version
end
|
#name ⇒ String
39
40
41
|
# File 'lib/app_info/aab.rb', line 39
def name
manifest.label
end
|
#native_codes(base_path: BASE_PATH) ⇒ Array<String>
85
86
87
88
89
90
91
|
# File 'lib/app_info/aab.rb', line 85
def native_codes(base_path: BASE_PATH)
@native_codes ||= zip.glob(::File.join(base_path, 'lib/**/*'))
.each_with_object([]) do |entry, obj|
lib = entry.name.split('/')[2]
obj << lib unless obj.include?(lib)
end
end
|
#package_name ⇒ String
Also known as:
identifier, bundle_id
26
27
28
|
# File 'lib/app_info/aab.rb', line 26
def package_name
manifest.package
end
|
#read_file(name, base_path: BASE_PATH) ⇒ Object
101
102
103
104
105
106
|
# File 'lib/app_info/aab.rb', line 101
def read_file(name, base_path: BASE_PATH)
content = zip.read(entry(name, base_path: base_path))
return parse_binary_xml(content) if xml_file?(name)
content
end
|
#schemes ⇒ String
21
|
# File 'lib/app_info/aab.rb', line 21
def_delegators :manifest, :version_name, :deep_links, :schemes
|
74
75
76
|
# File 'lib/app_info/aab.rb', line 74
def services
@services ||= manifest.services
end
|
#target_sdk_version ⇒ String
50
51
52
|
# File 'lib/app_info/aab.rb', line 50
def target_sdk_version
manifest.uses_sdk.target_sdk_version
end
|
#use_features ⇒ Array<String>
55
56
57
58
59
|
# File 'lib/app_info/aab.rb', line 55
def use_features
return [] unless manifest.respond_to?(:uses_feature)
@use_features ||= manifest&.uses_feature&.map(&:name)
end
|
#use_permissions ⇒ Array<String>
62
63
64
65
66
|
# File 'lib/app_info/aab.rb', line 62
def use_permissions
return [] unless manifest.respond_to?(:uses_permission)
@use_permissions ||= manifest&.uses_permission&.map(&:name)
end
|
#version_code ⇒ String
Also known as:
build_version
33
34
35
|
# File 'lib/app_info/aab.rb', line 33
def version_code
manifest.version_code.to_s
end
|
#version_name ⇒ String
Also known as:
release_version
21
|
# File 'lib/app_info/aab.rb', line 21
def_delegators :manifest, :version_name, :deep_links, :schemes
|
#zip ⇒ Zip::File
197
198
199
|
# File 'lib/app_info/aab.rb', line 197
def zip
@zip ||= Zip::File.open(@file)
end
|