app-info 2.8.5 → 3.0.0.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +12 -7
  3. data/.github/workflows/ci.yml +3 -1
  4. data/.rubocop.yml +33 -11
  5. data/CHANGELOG.md +34 -1
  6. data/Gemfile +7 -1
  7. data/README.md +68 -13
  8. data/Rakefile +11 -0
  9. data/app_info.gemspec +12 -3
  10. data/lib/app_info/aab.rb +48 -108
  11. data/lib/app_info/android/signature.rb +114 -0
  12. data/lib/app_info/android/signatures/base.rb +53 -0
  13. data/lib/app_info/android/signatures/info.rb +158 -0
  14. data/lib/app_info/android/signatures/v1.rb +63 -0
  15. data/lib/app_info/android/signatures/v2.rb +121 -0
  16. data/lib/app_info/android/signatures/v3.rb +131 -0
  17. data/lib/app_info/android/signatures/v4.rb +18 -0
  18. data/lib/app_info/android.rb +162 -0
  19. data/lib/app_info/apk.rb +54 -111
  20. data/lib/app_info/apple.rb +192 -0
  21. data/lib/app_info/certificate.rb +175 -0
  22. data/lib/app_info/const.rb +75 -0
  23. data/lib/app_info/core_ext/object/try.rb +3 -1
  24. data/lib/app_info/core_ext/string/inflector.rb +2 -0
  25. data/lib/app_info/dsym/debug_info.rb +72 -0
  26. data/lib/app_info/dsym/macho.rb +55 -0
  27. data/lib/app_info/dsym.rb +31 -135
  28. data/lib/app_info/error.rb +2 -2
  29. data/lib/app_info/file.rb +49 -0
  30. data/lib/app_info/helper/archive.rb +37 -0
  31. data/lib/app_info/helper/file_size.rb +25 -0
  32. data/lib/app_info/helper/generate_class.rb +29 -0
  33. data/lib/app_info/helper/protobuf.rb +12 -0
  34. data/lib/app_info/helper/signatures.rb +229 -0
  35. data/lib/app_info/helper.rb +5 -126
  36. data/lib/app_info/info_plist.rb +66 -29
  37. data/lib/app_info/ipa/framework.rb +4 -4
  38. data/lib/app_info/ipa.rb +61 -135
  39. data/lib/app_info/macos.rb +54 -102
  40. data/lib/app_info/mobile_provision.rb +67 -49
  41. data/lib/app_info/pe.rb +260 -0
  42. data/lib/app_info/png_uncrush.rb +24 -4
  43. data/lib/app_info/proguard.rb +29 -16
  44. data/lib/app_info/protobuf/manifest.rb +6 -3
  45. data/lib/app_info/protobuf/models/Configuration_pb.rb +1 -0
  46. data/lib/app_info/protobuf/models/README.md +7 -0
  47. data/lib/app_info/protobuf/models/Resources_pb.rb +2 -0
  48. data/lib/app_info/protobuf/resources.rb +5 -5
  49. data/lib/app_info/version.rb +1 -1
  50. data/lib/app_info.rb +90 -46
  51. metadata +48 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9406b7552e0bea00883446b85250398c7818120de74d0d6d3545d7b9b0d7ef6
4
- data.tar.gz: a99bb2c55b4214ad72f8e6cf2e720199902fb37ad174b71bb5f9f4d529ba81a3
3
+ metadata.gz: 91afee9fd86b49fa4f788f4316df7c689178c6fdfbc0cf3f4743ae5cb7713dde
4
+ data.tar.gz: 056f2a2416a1a68ca2f2dcbbc404e9f6c768a5e8a742d942f04177c7044f5ff9
5
5
  SHA512:
6
- metadata.gz: '018d93bb67f489d4908f0701285ee6c177a627f3b5c602e90c24629da25f91fc2f5cb9b091675d471741361211289b71ed7c1ab51402f30cea843126c9c6271c'
7
- data.tar.gz: 5eecd5818b12032898d33a14f74c43592d120ab751b2e4393591b0fd81e4df5cebb94342111478392fd84c5963f762de0383873c547176f74d546f7bfb7b8013
6
+ metadata.gz: 2294ae1a6e8d220c46bd21e4c1062783f2ce7b94ad5b5dffdfe8c62edd6e519a57b326913339f090f62bf955d3103a6bf665227865bceb9f45bb7c78478b04f0
7
+ data.tar.gz: ec84bbc24190227bedd91818bdefad90cb1472e1b7ca1db312aca651843315ab037e7b70f2322085eca70bf3ab0319af3af20270da2a006437f76cf4a4ca3f11
@@ -1,9 +1,14 @@
1
1
  version: 2
2
2
  updates:
3
- - package-ecosystem: bundler
4
- directory: "/"
5
- schedule:
6
- interval: daily
7
- time: "21:00"
8
- timezone: Asia/Shanghai
9
- open-pull-requests-limit: 10
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "21:00"
8
+ timezone: Asia/Shanghai
9
+ open-pull-requests-limit: 10
10
+
11
+ - package-ecosystem: "github-actions"
12
+ directory: "/"
13
+ schedule:
14
+ interval: "daily"
@@ -1,8 +1,10 @@
1
1
  name: CI
2
2
  on:
3
3
  push:
4
+ paths-ignore:
5
+ - '*.md'
4
6
  branches:
5
- - master
7
+ - main
6
8
  pull_request:
7
9
 
8
10
  jobs:
data/.rubocop.yml CHANGED
@@ -27,6 +27,24 @@ AllCops:
27
27
  - 'lib/app_info/protobuf/models/*_pb.rb'
28
28
  - 'main.rb'
29
29
 
30
+ Layout/LineLength:
31
+ Max: 100
32
+ Exclude:
33
+ - 'lib/app_info/helper/signatures.rb'
34
+ - 'lib/app_info/android/signatures/info.rb'
35
+ - 'lib/app_info/apk.rb'
36
+
37
+ Lint/AssignmentInCondition:
38
+ Enabled: false
39
+
40
+ Lint/UnusedMethodArgument:
41
+ Exclude:
42
+ - 'lib/app_info/file.rb'
43
+
44
+ Lint/UselessAssignment:
45
+ Exclude:
46
+ - 'lib/app_info/android/signatures/v3.rb'
47
+
30
48
  Metrics/AbcSize:
31
49
  Max: 100
32
50
 
@@ -36,13 +54,15 @@ Metrics/BlockLength:
36
54
  - 'lib/app_info/mobile_provision.rb'
37
55
 
38
56
  Metrics/MethodLength:
39
- Max: 20
57
+ Max: 30
40
58
  Exclude:
41
- - 'lib/app_info/png_uncrush.rb'
42
59
  - 'lib/app_info/mobile_provision.rb'
60
+ - 'lib/app_info/android/signatures/v2.rb'
61
+ - 'lib/app_info/android/signatures/v3.rb'
43
62
 
44
- Layout/LineLength:
45
- Max: 100
63
+ Metrics/ParameterLists:
64
+ Exclude:
65
+ - 'lib/app_info/helper/signatures.rb'
46
66
 
47
67
  Metrics/ClassLength:
48
68
  CountComments: false
@@ -54,12 +74,16 @@ Metrics/CyclomaticComplexity:
54
74
  Metrics/PerceivedComplexity:
55
75
  Max: 18
56
76
 
57
- Lint/AssignmentInCondition:
58
- Enabled: false
77
+ Metrics/BlockNesting:
78
+ Exclude:
79
+ - 'lib/app_info/dsym.rb'
59
80
 
60
81
  Style/Documentation:
61
82
  Enabled: false
62
83
 
84
+ Style/ClassAndModuleChildren:
85
+ Enabled: false
86
+
63
87
  Style/PerlBackrefs:
64
88
  Exclude:
65
89
  - 'lib/app_info/core_ext/string/inflector.rb'
@@ -67,10 +91,8 @@ Style/PerlBackrefs:
67
91
  Style/DocumentDynamicEvalDefinition:
68
92
  Enabled: false
69
93
 
70
- Metrics/BlockNesting:
71
- Exclude:
72
- - 'lib/app_info/dsym.rb'
73
-
74
-
75
94
  Style/SlicingWithRange:
76
95
  Enabled: false
96
+
97
+ Style/ClassVars:
98
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -9,6 +9,37 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
9
9
 
10
10
  > List all changes before release a new version.
11
11
 
12
+ ## [3.0.0.beta2] (2023-04-04)
13
+
14
+ ### Changed
15
+
16
+ - Re-organize categories `.platform`, `.opera_sytem` and `.device` for all parsers. [#58](https://github.com/icyleaf/app_info/pull/58)
17
+ - Change ExportType values type to symbol both IPA and macOS parsers. [#58](https://github.com/icyleaf/app_info/pull/58)
18
+
19
+ ## [3.0.0.beta1] (2023-04-04)
20
+
21
+ ### Added
22
+
23
+ - New Windows PE format parser. [#47](https://github.com/icyleaf/app_info/pull/47)
24
+ - Android parser add v2, v3 scheme signature support. [#55](https://github.com/icyleaf/app_info/pull/55]
25
+ - dSYM parer accept multi dSYM target in a zip file. [#56](https://github.com/icyleaf/app_info/pull/56)
26
+ - Better document for yardoc.
27
+
28
+ ### Changed
29
+
30
+ - Add `AppInfo::File` base class for all parsers.
31
+ - Add `AppInfo::Certifiate` X509 certificate wrapped and apply in Android/MobileProvision.
32
+ - Remove `.sign_version` method in Android parser.
33
+ - Rename `.file_type` to `.format` method in all parers and return a `AppInfo::Format` type.
34
+ - Remove duplice `AppInfo::AndroidDevice` class.
35
+ - Remove `AppInfo::MobileProvision::DeveloperCertificate` class, use `AppInfo::Certifiate` instead.
36
+ - Deprecate `.signs` and `.certifiates` methods in Android parser, use `.signatures` instead.
37
+ - Deprecate `.developer_certs` method in MobileProvision parser, use `.certificates` instead.
38
+
39
+ ### Fixed
40
+
41
+ - Fixed minor typo.
42
+
12
43
  ## [2.8.5] (2023-03-16)
13
44
 
14
45
  ### Fixed
@@ -247,7 +278,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
247
278
 
248
279
  - Updated dependency of CFPropertly list be a range between 2.3.4. (thanks @[cschroed](https://github.com/cschroed))
249
280
 
250
- [Unreleased]: https://github.com/icyleaf/app-info/compare/v2.8.5..HEAD
281
+ [Unreleased]: https://github.com/icyleaf/app-info/compare/v3.0.0.beta2..HEAD
282
+ [3.0.0.beta2]: https://github.com/icyleaf/app-info/compare/v3.0.0.beta1...v3.0.0.beta2
283
+ [3.0.0.beta1]: https://github.com/icyleaf/app-info/compare/v2.8.5...v3.0.0.beta1
251
284
  [2.8.5]: https://github.com/icyleaf/app-info/compare/v2.8.4...v2.8.5
252
285
  [2.8.4]: https://github.com/icyleaf/app-info/compare/v2.8.3...v2.8.4
253
286
  [2.8.3]: https://github.com/icyleaf/app-info/compare/v2.8.2...v2.8.3
data/Gemfile CHANGED
@@ -7,5 +7,11 @@ gemspec
7
7
 
8
8
  group :development do
9
9
  gem 'awesome_print'
10
- gem 'debug' # For ruby 3.0+
10
+ gem 'debug' # For ruby 3.0+\
11
+ gem 'yard'
12
+ end
13
+
14
+ group :development, :test do
15
+ gem 'rspec'
16
+ gem 'rubocop'
11
17
  end
data/README.md CHANGED
@@ -1,11 +1,12 @@
1
- # app_info
1
+ # app-info
2
2
 
3
- [![Language](https://img.shields.io/badge/ruby-2.5+-701516.svg)](.github/workflows/ci.yml)
3
+ [![Language](https://img.shields.io/badge/ruby-2.5+-701516)](.github/workflows/ci.yml)
4
+ [![Gem version](https://img.shields.io/gem/v/app-info?include_prereleases)](https://rubygems.org/gems/app-info)
4
5
  [![Build Status](https://img.shields.io/github/actions/workflow/status/icyleaf/app_info/ci.yml)](https://github.com/icyleaf/app_info/actions/workflows/ci.yml)
5
- [![Gem version](https://img.shields.io/gem/v/app-info.svg?style=flat)](https://rubygems.org/gems/app_info)
6
- [![License](https://img.shields.io/badge/license-MIT-red.svg?style=flat)](LICENSE)
6
+ [![License](https://img.shields.io/github/license/icyleaf/app-info)](LICENSE)
7
7
 
8
- Teardown tool for mobile app (ipa, apk and aab file), macOS app and dSYM.zip file, analysis metedata like version, name, icon etc.
8
+ Teardown tool for mobile app (ipa, apk and aab file), macOS app, dSYM.zip file and Windows PE file.
9
+ Analysis metedata like version, name, icon etc.
9
10
 
10
11
  ## Support
11
12
 
@@ -16,10 +17,13 @@ Teardown tool for mobile app (ipa, apk and aab file), macOS app and dSYM.zip fil
16
17
  - `.ipa`
17
18
  - `Info.plist` file
18
19
  - `.mobileprovision`/`.provisionprofile` file
19
- - Zipped macOS App file
20
+ - macOS App file (archived by starnd pkzip format)
20
21
  - `.app.zip`
21
- - Zipped dSYMs file
22
+ - dSYMs file (archived by starnd pkzip format)
22
23
  - `.dSYM.zip`
24
+ - Windows PE file
25
+ - `.exe`
26
+ - `.zip` (binary in a zip file)
23
27
 
24
28
  <hr />
25
29
 
@@ -65,6 +69,8 @@ parser = AppInfo.parse('android.aab')
65
69
  parser = AppInfo.parse('u-u-i-d.mobileprovision')
66
70
  parser = AppInfo.parse('macOS.App.zip')
67
71
  parser = AppInfo.parse('App.dSYm.zip')
72
+ parser = AppInfo.parse('win.exe')
73
+ parser = AppInfo.parse('win.zip')
68
74
 
69
75
  # If detect file type failed, you can parse in other way
70
76
  parser = AppInfo::IPA.new('iphone.ipa')
@@ -74,6 +80,7 @@ parser = AppInfo::InfoPlist.new('Info.plist')
74
80
  parser = AppInfo::MobileProvision.new('uuid.mobileprovision')
75
81
  parser = AppInfo::Macos.new('App.dSYm.zip')
76
82
  parser = AppInfo::DSYM.new('App.dSYm.zip')
83
+ parser = AppInfo::PE.new('win.exe')
77
84
  ```
78
85
 
79
86
  ### iOS
@@ -220,12 +227,8 @@ android.deep_links
220
227
  android.schemes
221
228
  # => ['appinfo']
222
229
 
223
- # get sign list (only v1 sign)
224
- android.signs
225
- # => [...]
226
-
227
- # get certificate list (only v1 sign)
228
- android.certificates
230
+ # get v1-v3 scheme singature information (included unverified certificate and more)
231
+ android.signatures
229
232
  # => [...]
230
233
  ```
231
234
 
@@ -313,6 +316,58 @@ dsym.machos.each do |macho|
313
316
  end
314
317
  ```
315
318
 
319
+ ### Windows
320
+
321
+ Accept any PE format file, such like `.exe` or `.exe` binary fin a zip file.
322
+
323
+ ```ruby
324
+ win = AppInfo.parse('win.exe')
325
+
326
+ # get given file size
327
+ win.size
328
+ # => 3093823
329
+
330
+ # get given file size in human reable.
331
+ win.size(human_size: true)
332
+ # => 29 MB
333
+
334
+ # get given file size
335
+ win.binary_size
336
+ # => 20940
337
+
338
+ # get given file size in human reable.
339
+ win.size(human_size: true)
340
+ # => 20 MB
341
+
342
+ # get product name
343
+ win.name
344
+ # => AppInfo
345
+
346
+ # get app company name
347
+ win.company_name
348
+ # => EWS Studio
349
+
350
+ # get app product version (alias to release_version)
351
+ win.product_version
352
+ # => 1.0.0
353
+
354
+ # get app assembly version (alias to build_version)
355
+ win.assembly_version
356
+ # => 1.0.0
357
+
358
+ # detect architecture(s)
359
+ win.archs
360
+ # => x64
361
+
362
+ # get all imports files
363
+ win.imports
364
+ # => [KERNEL32.dll, ...]
365
+
366
+ # get app icons (bmp format image)
367
+ win.icons
368
+ # => [{:name=>"ICON.bmp", :file=>"{path}/ICON.bmp"}, :dimensions=>[64, 64]}, ...]
369
+ ```
370
+
316
371
  ## CLI Shell (Interactive console)
317
372
 
318
373
  It is possible to use this gem as a command line interface to parse mobile app:
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  $LOAD_PATH.unshift File.expand_path('lib', __dir__)
4
4
  require 'app_info'
5
+ require 'yard'
5
6
  require 'bundler/gem_tasks'
6
7
  require 'rspec/core/rake_task'
7
8
  require 'rubocop/rake_task'
@@ -9,3 +10,13 @@ require 'rubocop/rake_task'
9
10
  RSpec::Core::RakeTask.new(:spec)
10
11
 
11
12
  task default: :spec
13
+
14
+ task :doc do
15
+ YARD::Rake::YardocTask.new do |t|
16
+ t.files = ['lib/**/*.rb', 'README.md', 'LICENSE']
17
+ # t.options = ['--any', '--extra', '--opts'] # optional
18
+ # t.stats_options = ['--list-undoc'] # optional
19
+ end
20
+ end
21
+
22
+
data/app_info.gemspec CHANGED
@@ -23,14 +23,23 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'CFPropertyList', '< 3.1.0', '>= 2.3.4'
24
24
  spec.add_dependency 'image_size', '>= 1.5', '< 3.3'
25
25
  spec.add_dependency 'ruby-macho', '>= 1.4', '< 4'
26
- spec.add_dependency 'android_parser', '~> 2.5.1'
26
+ spec.add_dependency 'android_parser', '~> 2.6.0'
27
27
  spec.add_dependency 'rubyzip', '>= 1.2', '< 3.0'
28
28
  spec.add_dependency 'uuidtools', '>= 2.1.5', '< 2.3.0'
29
29
  spec.add_dependency 'icns', '~> 0.2.0'
30
+ spec.add_dependency 'pedump', '~> 0.6.2'
30
31
  spec.add_dependency 'google-protobuf', '>= 3.19.4', '< 3.23.0'
31
32
 
32
33
  spec.add_development_dependency 'bundler', '>= 1.12'
33
34
  spec.add_development_dependency 'rake', '>= 10.0'
34
- spec.add_development_dependency 'rspec', '~> 3.0'
35
- spec.add_development_dependency 'rubocop', '~> 1.19'
35
+
36
+ spec.post_install_message = <<~ENDBANNER
37
+ AppInfo 3.0 is coming!
38
+ **********************
39
+ The public API of some AppInfo classes has been changed.
40
+
41
+ Please ensure that your Gemfiles and .gemspecs are suitably restrictive
42
+ to avoid an unexpected breakage when 3.0 is released (e.g. ~> 2.8.5).
43
+ See https://github.com/icyleaf/app_info for details.
44
+ ENDBANNER
36
45
  end
data/lib/app_info/aab.rb CHANGED
@@ -1,160 +1,85 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'app_info/protobuf/manifest'
4
- require 'image_size'
5
- require 'forwardable'
6
4
 
7
5
  module AppInfo
8
- # Parse APK file
9
- class AAB
10
- include Helper::HumanFileSize
11
- extend Forwardable
12
-
13
- attr_reader :file
14
-
15
- # APK Devices
16
- module Device
17
- PHONE = 'Phone'
18
- TABLET = 'Tablet'
19
- WATCH = 'Watch'
20
- TV = 'Television'
21
- AUTOMOTIVE = 'Automotive'
22
- end
23
-
6
+ # Parse APK file parser
7
+ class AAB < Android
24
8
  BASE_PATH = 'base'
25
9
  BASE_MANIFEST = "#{BASE_PATH}/manifest/AndroidManifest.xml"
26
10
  BASE_RESOURCES = "#{BASE_PATH}/resources.pb"
27
11
 
28
- def initialize(file)
29
- @file = file
30
- end
31
-
32
- def size(human_size: false)
33
- file_to_human_size(@file, human_size: human_size)
34
- end
35
-
36
- def os
37
- Platform::ANDROID
38
- end
39
- alias file_type os
40
-
12
+ # @!method version_name
13
+ # @see Protobuf::Manifest#version_name
14
+ # @return [String]
15
+ # @!method deep_links
16
+ # @see Protobuf::Manifest#deep_links
17
+ # @return [String]
18
+ # @!method schemes
19
+ # @see Protobuf::Manifest#schemes
20
+ # @return [String]
41
21
  def_delegators :manifest, :version_name, :deep_links, :schemes
42
22
 
43
23
  alias release_version version_name
44
24
 
25
+ # @return [String]
45
26
  def package_name
46
27
  manifest.package
47
28
  end
48
29
  alias identifier package_name
49
30
  alias bundle_id package_name
50
31
 
32
+ # @return [String]
51
33
  def version_code
52
34
  manifest.version_code.to_s
53
35
  end
54
36
  alias build_version version_code
55
37
 
38
+ # @return [String]
56
39
  def name
57
40
  manifest.label
58
41
  end
59
42
 
60
- def device_type
61
- if wear?
62
- Device::WATCH
63
- elsif tv?
64
- Device::TV
65
- elsif automotive?
66
- Device::AUTOMOTIVE
67
- else
68
- Device::PHONE
69
- end
70
- end
71
-
72
- # TODO: find a way to detect
73
- # Found answer but not works: https://stackoverflow.com/questions/9279111/determine-if-the-device-is-a-smartphone-or-tablet
74
- # def tablet?
75
- # resource.first_package
76
- # .entries('bool')
77
- # .select{|e| e.name == 'isTablet' }
78
- # .size >= 1
79
- # end
80
-
81
- def wear?
82
- !!use_features&.include?('android.hardware.type.watch')
83
- end
84
-
85
- def tv?
86
- !!use_features&.include?('android.software.leanback')
87
- end
88
-
89
- def automotive?
90
- !!use_features&.include?('android.hardware.type.automotive')
91
- end
92
-
43
+ # @return [String]
93
44
  def min_sdk_version
94
45
  manifest.uses_sdk.min_sdk_version
95
46
  end
96
47
  alias min_os_version min_sdk_version
97
48
 
49
+ # @return [String]
98
50
  def target_sdk_version
99
51
  manifest.uses_sdk.target_sdk_version
100
52
  end
101
53
 
54
+ # @return [Array<String>]
102
55
  def use_features
103
56
  return [] unless manifest.respond_to?(:uses_feature)
104
57
 
105
58
  @use_features ||= manifest&.uses_feature&.map(&:name)
106
59
  end
107
60
 
61
+ # @return [Array<String>]
108
62
  def use_permissions
109
63
  return [] unless manifest.respond_to?(:uses_permission)
110
64
 
111
65
  @use_permissions ||= manifest&.uses_permission&.map(&:name)
112
66
  end
113
67
 
68
+ # @return [Protobuf::Node]
114
69
  def activities
115
70
  @activities ||= manifest.activities
116
71
  end
117
72
 
73
+ # @return [Protobuf::Node]
118
74
  def services
119
75
  @services ||= manifest.services
120
76
  end
121
77
 
78
+ # @return [Protobuf::Node]
122
79
  def components
123
80
  @components ||= manifest.components.transform_values
124
81
  end
125
82
 
126
- def sign_version
127
- return 'v1' unless signs.empty?
128
-
129
- # when ?
130
- # https://source.android.com/security/apksigning/v2?hl=zh-cn
131
- # 'v2'
132
- # when ?
133
- # https://source.android.com/security/apksigning/v3?hl=zh-cn
134
- # 'v3'
135
- 'unknown'
136
- end
137
-
138
- def signs
139
- return @signs if @signs
140
-
141
- @signs = []
142
- each_file do |path, data|
143
- # find META-INF/xxx.{RSA|DSA}
144
- next unless path =~ %r{^META-INF/} && data.unpack('CC') == [0x30, 0x82]
145
-
146
- @signs << APK::Sign.new(path, OpenSSL::PKCS7.new(data))
147
- end
148
-
149
- @signs
150
- end
151
-
152
- def certificates
153
- @certificates ||= signs.each_with_object([]) do |sign, obj|
154
- obj << APK::Certificate.new(sign.path, sign.sign.certificates[0])
155
- end
156
- end
157
-
158
83
  def each_file
159
84
  zip.each do |entry|
160
85
  next unless entry.file?
@@ -171,36 +96,50 @@ module AppInfo
171
96
  end
172
97
 
173
98
  def entry(name, base_path: BASE_PATH)
174
- entry = @zip.find_entry(File.join(base_path, name))
99
+ entry = @zip.find_entry(::File.join(base_path, name))
175
100
  raise NotFoundError, "'#{name}'" if entry.nil?
176
101
 
177
102
  entry
178
103
  end
179
104
 
105
+ # @return [Protobuf::Manifest]
180
106
  def manifest
181
107
  io = zip.read(zip.find_entry(BASE_MANIFEST))
182
108
  @manifest ||= Protobuf::Manifest.parse(io, resource)
183
109
  end
184
110
 
111
+ # @return [Protobuf::Resources]
185
112
  def resource
186
113
  io = zip.read(zip.find_entry(BASE_RESOURCES))
187
114
  @resource ||= Protobuf::Resources.parse(io)
188
115
  end
189
116
 
190
- def zip
191
- @zip ||= Zip::File.open(@file)
192
- end
193
-
117
+ # Full icons metadata
118
+ # @example
119
+ # aab.icons
120
+ # # => [
121
+ # # {
122
+ # # name: 'icon.png',
123
+ # # file: '/path/to/icon.png',
124
+ # # dimensions: [29, 29]
125
+ # # },
126
+ # # {
127
+ # # name: 'icon1.png',
128
+ # # file: '/path/to/icon1.png',
129
+ # # dimensions: [120, 120]
130
+ # # }
131
+ # # ]
132
+ # @return [Array<Hash{Symbol => String, Array<Integer>}>] icons paths of icons
194
133
  def icons
195
134
  @icons ||= manifest.icons.each_with_object([]) do |res, obj|
196
135
  path = res.value
197
- filename = File.basename(path)
198
- filepath = File.join(contents, File.dirname(path))
199
- file = File.join(filepath, filename)
136
+ filename = ::File.basename(path)
137
+ filepath = ::File.join(contents, ::File.dirname(path))
138
+ file = ::File.join(filepath, filename)
200
139
  FileUtils.mkdir_p filepath
201
140
 
202
141
  binary_data = read_file(path)
203
- File.write(file, binary_data, encoding: Encoding::BINARY)
142
+ ::File.write(file, binary_data, encoding: Encoding::BINARY)
204
143
 
205
144
  obj << {
206
145
  name: filename,
@@ -222,14 +161,15 @@ module AppInfo
222
161
  @info = nil
223
162
  end
224
163
 
225
- def contents
226
- @contents ||= File.join(Dir.mktmpdir, "AppInfo-android-#{SecureRandom.hex}")
164
+ # @return [Zip::File]
165
+ def zip
166
+ @zip ||= Zip::File.open(@file)
227
167
  end
228
168
 
229
169
  private
230
170
 
231
171
  def xml_file?(file)
232
- File.extname(file) == '.xml'
172
+ ::File.extname(file) == '.xml'
233
173
  end
234
174
 
235
175
  # TODO: how to convert xml content after decode protoubufed content