app-info 2.7.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1e0ca3539dc493e0003d18ad437da67c6a80f9c131de3e191139e7b03abb6f0
4
- data.tar.gz: 490bca65c07243e7e27b296c2f5143da879cefcb6ff87081d8ef9322f62fd3d6
3
+ metadata.gz: f2c78a4901456e1d50dc468314d4fa12e9b66db13e3f4678f5a4f371dddda03e
4
+ data.tar.gz: 3493755f61ca80721c9fee684a06dc5922d0427695ce1ef1f1b1c44739686da5
5
5
  SHA512:
6
- metadata.gz: a50f751f9bc6fe9336beb91fe4306be0824e45129d4e4d2c3b860751eca1b8c51ffb1544e48514c2b1d90c4a0c9a09d404433396bec2cd4193c116511a1ba125
7
- data.tar.gz: 6cb7dd2d79e0ed787ecbc2dd9197c3a1cbefaea1f7f6aead46ce5ac4f7eeaf4c70ab98f3baefc8c0d506cc10b95aa97aef308a418d446e6a72279b0f470ecac0
6
+ metadata.gz: 67bca698f1e7dd6cde75a3d57776a0d2cd95ab6cf5c156d101f76b333535f763dfc55051d1f975fec499e09a0a66b7b0f6c6855877bdad4100be243f9e2be001
7
+ data.tar.gz: d07d95a0d1481ba711a953f09bfcf966f7827e9c0b0d010fbf16bfc7c16a39ef05950b9fa9c5a2e34a0b117a995d9182b56d2f19fd9b98f40eea6e4d084734bb
data/CHANGELOG.md CHANGED
@@ -9,6 +9,12 @@ 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
+ ## [2.8.0] (2021-12-16)
13
+
14
+ ### Added
15
+
16
+ - New methods added to `apk` and `aab` [3adfa223](https://github.com/icyleaf/app_info/tree/3adfa223479caa672fce5d3a119b6db098463699) [939a6506](https://github.com/icyleaf/app_info/tree/939a6506f3ac1cb7ad1ed46128df41de6ee3b0d0)
17
+
12
18
  ## [2.7.0] (2021-10-15)
13
19
 
14
20
  ### Added
data/Rakefile CHANGED
@@ -4,6 +4,7 @@ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
4
4
  require 'app_info'
5
5
  require 'bundler/gem_tasks'
6
6
  require 'rspec/core/rake_task'
7
+ require 'rubocop/rake_task'
7
8
 
8
9
  RSpec::Core::RakeTask.new(:spec)
9
10
 
data/app_info.gemspec CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.required_ruby_version = '>= 2.5'
22
22
 
23
23
  spec.add_dependency 'CFPropertyList', '< 3.1.0', '>= 2.3.4'
24
- spec.add_dependency 'image_size', '>= 1.5', '< 2.2'
24
+ spec.add_dependency 'image_size', '>= 1.5', '< 3.1'
25
25
  spec.add_dependency 'ruby-macho', '< 3', '>= 1.4'
26
- spec.add_dependency 'android_parser', '~> 2.4.1'
26
+ spec.add_dependency 'android_parser', '~> 2.5.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'
data/lib/app_info/aab.rb CHANGED
@@ -14,10 +14,11 @@ module AppInfo
14
14
 
15
15
  # APK Devices
16
16
  module Device
17
- PHONE = 'Phone'
18
- TABLET = 'Tablet'
19
- WATCH = 'Watch'
20
- TV = 'Television'
17
+ PHONE = 'Phone'
18
+ TABLET = 'Tablet'
19
+ WATCH = 'Watch'
20
+ TV = 'Television'
21
+ AUTOMOTIVE = 'Automotive'
21
22
  end
22
23
 
23
24
  BASE_PATH = 'base'
@@ -37,7 +38,7 @@ module AppInfo
37
38
  end
38
39
  alias file_type os
39
40
 
40
- def_delegators :manifest, :version_name
41
+ def_delegators :manifest, :version_name, :deep_links, :schemes
41
42
 
42
43
  alias release_version version_name
43
44
 
@@ -61,6 +62,8 @@ module AppInfo
61
62
  Device::WATCH
62
63
  elsif tv?
63
64
  Device::TV
65
+ elsif automotive?
66
+ Device::AUTOMOTIVE
64
67
  else
65
68
  Device::PHONE
66
69
  end
@@ -83,6 +86,10 @@ module AppInfo
83
86
  use_features.include?('android.software.leanback')
84
87
  end
85
88
 
89
+ def automotive?
90
+ use_features.include?('android.hardware.type.automotive')
91
+ end
92
+
86
93
  def min_sdk_version
87
94
  manifest.uses_sdk.min_sdk_version
88
95
  end
@@ -112,6 +119,18 @@ module AppInfo
112
119
  @components ||= manifest.components.transform_values
113
120
  end
114
121
 
122
+ def sign_version
123
+ return 'v1' unless signs.empty?
124
+
125
+ # when ?
126
+ # https://source.android.com/security/apksigning/v2?hl=zh-cn
127
+ # 'v2'
128
+ # when ?
129
+ # https://source.android.com/security/apksigning/v3?hl=zh-cn
130
+ # 'v3'
131
+ 'unknown'
132
+ end
133
+
115
134
  def signs
116
135
  return @signs if @signs
117
136
 
data/lib/app_info/apk.rb CHANGED
@@ -14,10 +14,11 @@ module AppInfo
14
14
 
15
15
  # APK Devices
16
16
  module Device
17
- PHONE = 'Phone'
18
- TABLET = 'Tablet'
19
- WATCH = 'Watch'
20
- TV = 'Television'
17
+ PHONE = 'Phone'
18
+ TABLET = 'Tablet'
19
+ WATCH = 'Watch'
20
+ TV = 'Television'
21
+ AUTOMOTIVE = 'Automotive'
21
22
  end
22
23
 
23
24
  def initialize(file)
@@ -35,8 +36,9 @@ module AppInfo
35
36
 
36
37
  def_delegators :apk, :manifest, :resource, :dex
37
38
 
38
- def_delegators :manifest, :version_name, :package_name,
39
- :use_permissions, :components
39
+ def_delegators :manifest, :version_name, :package_name, :target_sdk_version,
40
+ :components, :services, :use_permissions, :use_features,
41
+ :deep_links, :schemes
40
42
 
41
43
  alias release_version version_name
42
44
  alias identifier package_name
@@ -56,14 +58,15 @@ module AppInfo
56
58
  Device::WATCH
57
59
  elsif tv?
58
60
  Device::TV
61
+ elsif automotive?
62
+ Device::AUTOMOTIVE
59
63
  else
60
64
  Device::PHONE
61
65
  end
62
66
  end
63
67
 
64
- # TODO: find a way to detect
68
+ # TODO: find a way to detect, no way!
65
69
  # def tablet?
66
- # resource
67
70
  # end
68
71
 
69
72
  def wear?
@@ -74,20 +77,25 @@ module AppInfo
74
77
  use_features.include?('android.software.leanback')
75
78
  end
76
79
 
80
+ def automotive?
81
+ use_features.include?('android.hardware.type.automotive')
82
+ end
83
+
77
84
  def min_sdk_version
78
85
  manifest.min_sdk_ver
79
86
  end
80
87
  alias min_os_version min_sdk_version
81
88
 
82
- def target_sdk_version
83
- manifest.doc
84
- .elements['/manifest/uses-sdk']
85
- .attributes['targetSdkVersion']
86
- .to_i
87
- end
89
+ def sign_version
90
+ return 'v1' unless signs.empty?
88
91
 
89
- def use_features
90
- manifest_values('/manifest/uses-feature')
92
+ # when ?
93
+ # https://source.android.com/security/apksigning/v2?hl=zh-cn
94
+ # 'v2'
95
+ # when ?
96
+ # https://source.android.com/security/apksigning/v3?hl=zh-cn
97
+ # 'v3'
98
+ 'unknown'
91
99
  end
92
100
 
93
101
  def signs
@@ -106,10 +114,6 @@ module AppInfo
106
114
  components.select { |c| c.type == 'activity' }
107
115
  end
108
116
 
109
- def services
110
- components.select { |c| c.type == 'service' }
111
- end
112
-
113
117
  def apk
114
118
  @apk ||= ::Android::Apk.new(@file)
115
119
  end
@@ -146,16 +150,6 @@ module AppInfo
146
150
  @contents ||= File.join(Dir.mktmpdir, "AppInfo-android-#{SecureRandom.hex}")
147
151
  end
148
152
 
149
- private
150
-
151
- def manifest_values(path, key = 'name')
152
- values = []
153
- manifest.doc.each_element(path) do |elem|
154
- values << elem.attributes[key]
155
- end
156
- values.uniq
157
- end
158
-
159
153
  # Android Certificate
160
154
  class Certificate
161
155
  attr_reader :path, :certificate
@@ -129,19 +129,96 @@ module AppInfo
129
129
  end
130
130
 
131
131
  def activities
132
- application.activity
132
+ application.respond_to?(:activity) ? application.activity : []
133
133
  end
134
134
 
135
135
  def services
136
- application.service
136
+ application.respond_to?(:service) ? application.service : []
137
137
  end
138
138
 
139
139
  def icons
140
140
  @resources.find(application.icon)
141
141
  end
142
142
 
143
+ def deep_links
144
+ activities.each_with_object([]) do |activity, obj|
145
+ intent_filters = activity.intent_filter
146
+ next if intent_filters.empty?
147
+
148
+ intent_filters.each do |filter|
149
+ next unless filter.deep_links?
150
+
151
+ obj << filter.deep_links
152
+ end
153
+ end.flatten.uniq
154
+ end
155
+
156
+ def schemes
157
+ activities.each_with_object([]) do |activity, obj|
158
+ intent_filters = activity.intent_filter
159
+ next if intent_filters.empty?
160
+
161
+ intent_filters.each do |filter|
162
+ next unless filter.schemes?
163
+
164
+ obj << filter.schemes
165
+ end
166
+ end.flatten.uniq
167
+ end
168
+
169
+ # :nodoc:
143
170
  # Workaround ruby always return true by called `Object.const_defined?(Data)`
144
171
  class Data < Node; end
172
+
173
+ class IntentFilter < Node
174
+ # filter types (action is required, category and data are optional)
175
+ TYPES = %w[action category data].freeze
176
+
177
+ DEEP_LINK_SCHEMES = %w[http https].freeze
178
+
179
+ # browsable of category
180
+ CATEGORY_BROWSABLE = 'android.intent.category.BROWSABLE'
181
+
182
+ def deep_links?
183
+ browsable? && data.any? { |d| DEEP_LINK_SCHEMES.include?(d.scheme) }
184
+ end
185
+
186
+ def deep_links
187
+ return unless deep_links?
188
+
189
+ data.reject { |d| d.host.nil? }
190
+ .map(&:host)
191
+ .uniq
192
+ end
193
+
194
+ def schemes
195
+ return unless schemes?
196
+
197
+ data.select { |d| !d.scheme.nil? && !DEEP_LINK_SCHEMES.include?(d.scheme) }
198
+ .map(&:scheme)
199
+ .uniq
200
+ end
201
+
202
+ def schemes?
203
+ browsable? && data.any? { |d| !DEEP_LINK_SCHEMES.include?(d.scheme) }
204
+ end
205
+
206
+ def browsable?
207
+ exist?(CATEGORY_BROWSABLE)
208
+ end
209
+
210
+ def exist?(name, type: nil)
211
+ if type.to_s.empty? && !name.start_with?('android.intent.')
212
+ raise 'Fill type or use correct name'
213
+ end
214
+
215
+ type ||= name.split('.')[2]
216
+ raise 'Not found type' unless TYPES.include?(type)
217
+
218
+ values = send(type.to_sym).select { |e| e.name == name }
219
+ values.empty? ? false : values
220
+ end
221
+ end
145
222
  end
146
223
  end
147
224
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppInfo
4
- VERSION = '2.7.0'
4
+ VERSION = '2.8.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app-info
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - icyleaf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-15 00:00:00.000000000 Z
11
+ date: 2021-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: CFPropertyList
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '1.5'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '2.2'
42
+ version: '3.1'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '1.5'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '2.2'
52
+ version: '3.1'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: ruby-macho
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -76,14 +76,14 @@ dependencies:
76
76
  requirements:
77
77
  - - "~>"
78
78
  - !ruby/object:Gem::Version
79
- version: 2.4.1
79
+ version: 2.5.0
80
80
  type: :runtime
81
81
  prerelease: false
82
82
  version_requirements: !ruby/object:Gem::Requirement
83
83
  requirements:
84
84
  - - "~>"
85
85
  - !ruby/object:Gem::Version
86
- version: 2.4.1
86
+ version: 2.5.0
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: rubyzip
89
89
  requirement: !ruby/object:Gem::Requirement