droid_adbs 0.3.3 → 0.4.0
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.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/droid_adbs/apkanalyzer.rb +201 -0
- data/lib/droid_adbs/version.rb +1 -1
- data/lib/droid_adbs.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fc3160c2981807d1678a39683d16661d7349bd2
|
4
|
+
data.tar.gz: 125713a86cc2765a0b940855425c2c032c710e33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be0fad45b241f6371fd915be646f206624cfaca8f5085295a9092af7c6fccf9799c001feeb0547986e7b2a21d44ccdd521ed87ecce5a049de069dc9ee20da9ad
|
7
|
+
data.tar.gz: 35190176f7850dbf43899a1f447c0d7ce0844f47dfcd7166a167cc29214dbde9df32bf3a18c162f63cfae5c71ce437097a2d8e02769b935b17456948c158da8e
|
data/README.md
CHANGED
@@ -38,6 +38,14 @@ Send command over tcp:
|
|
38
38
|
::DroidAdbs.install(app_path) # install `app_path` to the device over tcp
|
39
39
|
```
|
40
40
|
|
41
|
+
Use apkanalyzer tools.
|
42
|
+
|
43
|
+
```
|
44
|
+
@analyzer = DroidAdbs::Apkanalyzer.new "test/data/api.apk"
|
45
|
+
@analyzer.manifest_version_name
|
46
|
+
```
|
47
|
+
|
48
|
+
|
41
49
|
Please read yard documents if you would like to know more.
|
42
50
|
|
43
51
|
## Development
|
@@ -0,0 +1,201 @@
|
|
1
|
+
module DroidAdbs
|
2
|
+
class Apkanalyzer
|
3
|
+
# Read https://developer.android.com/studio/command-line/apkanalyzer for more details
|
4
|
+
|
5
|
+
attr_reader :apk_path
|
6
|
+
|
7
|
+
def initialize(apk_path)
|
8
|
+
raise RuntimeError, "should set path to aapt, android-sdks/build-tools/xxxx" if `which apkanalyzer`.empty?
|
9
|
+
|
10
|
+
@apk_path = apk_path
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String] package name
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
#
|
17
|
+
# manifest_package_id #=> "io.appium.android.apis"
|
18
|
+
#
|
19
|
+
def manifest_package_id
|
20
|
+
`apkanalyzer manifest application-id #{@apk_path}`.strip
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param [String] out_path A path to output the result
|
24
|
+
# @return [Integer] A number of file size
|
25
|
+
#
|
26
|
+
#
|
27
|
+
def manifest_print(out_path = './manifest_print.xml')
|
28
|
+
result = `apkanalyzer manifest print #{@apk_path}`.strip
|
29
|
+
File.write out_path, result
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [String] A number of version name by string
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
#
|
36
|
+
# manifest_version_name #=> "1.0"
|
37
|
+
#
|
38
|
+
def manifest_version_name
|
39
|
+
`apkanalyzer manifest version-name #{@apk_path}`.strip
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [String] A number of version code by string
|
43
|
+
#
|
44
|
+
# @example
|
45
|
+
#
|
46
|
+
# manifest_version_code #=> "1"
|
47
|
+
#
|
48
|
+
def manifest_version_code
|
49
|
+
`apkanalyzer manifest version-code #{@apk_path}`.strip
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [String] A number of min sdk by string
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
#
|
56
|
+
# manifest_min_sdk #=> "16"
|
57
|
+
#
|
58
|
+
def manifest_min_sdk
|
59
|
+
`apkanalyzer manifest min-sdk #{@apk_path}`.strip
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [String] A number of target sdk by string
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
#
|
66
|
+
# manifest_target_sdk #=> "22"
|
67
|
+
#
|
68
|
+
def manifest_target_sdk
|
69
|
+
`apkanalyzer manifest target-sdk #{@apk_path}`.strip
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [[String]] A list of permissions
|
73
|
+
#
|
74
|
+
# @example
|
75
|
+
#
|
76
|
+
# manifest_permissions #=> ["android.permission.INTERNET", "android.permission.SYSTEM_ALERT_WINDOW", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_PHONE_STATE"]
|
77
|
+
#
|
78
|
+
def manifest_permissions
|
79
|
+
`apkanalyzer manifest permissions #{@apk_path}`.strip.split("\n")
|
80
|
+
end
|
81
|
+
|
82
|
+
# @return [Bool] Debuggable or not
|
83
|
+
#
|
84
|
+
# @example
|
85
|
+
#
|
86
|
+
# manifest_debuggable #=> true
|
87
|
+
#
|
88
|
+
def manifest_debuggable
|
89
|
+
result = `apkanalyzer manifest debuggable #{@apk_path}`.strip
|
90
|
+
return true if result == "true"
|
91
|
+
false
|
92
|
+
end
|
93
|
+
|
94
|
+
# Prints the application Id, version code and version name.
|
95
|
+
#
|
96
|
+
# @example
|
97
|
+
#
|
98
|
+
# apk_summary #=> ["com.vodqareactnative", "1", "1.0"]
|
99
|
+
#
|
100
|
+
def apk_summary
|
101
|
+
`apkanalyzer apk summary #{@apk_path}`.strip.split("\t")
|
102
|
+
end
|
103
|
+
|
104
|
+
# Prints the file size of the APK.
|
105
|
+
# 7_414_686 (byte)
|
106
|
+
def apk_file_size
|
107
|
+
`apkanalyzer apk file-size #{@apk_path}`.strip
|
108
|
+
end
|
109
|
+
|
110
|
+
# Prints an estimate of the download size of the APK.
|
111
|
+
#
|
112
|
+
# @example
|
113
|
+
#
|
114
|
+
# apk_download_size #=> 7313000
|
115
|
+
#
|
116
|
+
def apk_download_size
|
117
|
+
`apkanalyzer apk download-size #{@apk_path}`.strip
|
118
|
+
end
|
119
|
+
|
120
|
+
# Prints features used by the APK.
|
121
|
+
#
|
122
|
+
# @example
|
123
|
+
#
|
124
|
+
# apk_features #=> "android.hardware.faketouch implied: default feature for all apps"
|
125
|
+
#
|
126
|
+
def apk_features
|
127
|
+
puts `apkanalyzer apk features #{@apk_path}`.strip
|
128
|
+
end
|
129
|
+
|
130
|
+
# Compares the sizes of two APKs.
|
131
|
+
def apk_compare_print(with)
|
132
|
+
puts `apkanalyzer apk features #{@apk_path} #{with}`.strip
|
133
|
+
end
|
134
|
+
|
135
|
+
# Lists all files in the zip.
|
136
|
+
#
|
137
|
+
# @example
|
138
|
+
#
|
139
|
+
# file_list #=> "android.hardware.faketouch implied: default feature for all apps"
|
140
|
+
#
|
141
|
+
def file_list
|
142
|
+
`apkanalyzer files list #{@apk_path}`.strip.split("\n")
|
143
|
+
end
|
144
|
+
|
145
|
+
# Prints a list of dex files in the APK
|
146
|
+
def dex_list
|
147
|
+
`apkanalyzer dex list #{@apk_path}`.strip.split("\n")
|
148
|
+
end
|
149
|
+
|
150
|
+
# Prints number of references in dex files
|
151
|
+
def dex_references(options = "")
|
152
|
+
`apkanalyzer dex references #{options} #{@apk_path}`.strip
|
153
|
+
end
|
154
|
+
|
155
|
+
# Prints the class tree from DEX.
|
156
|
+
# P,C,M,F: indicates packages, classes methods, fields
|
157
|
+
# x,k,r,d: indicates removed, kept, referenced and defined nodes
|
158
|
+
def dex_packages(options = "")
|
159
|
+
`apkanalyzer dex packages #{options} #{@apk_path}`.strip
|
160
|
+
end
|
161
|
+
|
162
|
+
# Prints the bytecode of a class or method in smali format
|
163
|
+
def dex_code
|
164
|
+
`apkanalyzer dex code #{@apk_path}`.strip
|
165
|
+
end
|
166
|
+
|
167
|
+
# Prints a list of packages in resources table
|
168
|
+
def resources_packages
|
169
|
+
`apkanalyzer resources packages #{@apk_path}`.strip
|
170
|
+
end
|
171
|
+
|
172
|
+
# Prints a list of configurations for the specified type.
|
173
|
+
# @param [String] type The type is a resource type such as string.
|
174
|
+
# @param [String] package Include the --package option if you want to specify the resource table package name,
|
175
|
+
# otherwise the first defined package will be used.
|
176
|
+
#
|
177
|
+
def resources_configs(type, package = "")
|
178
|
+
`apkanalyzer resources configs --type #{type} #{package} #{@apk_path}`.strip
|
179
|
+
end
|
180
|
+
|
181
|
+
# Prints the value of the resource specified by config, name, and type.
|
182
|
+
# @param [String] config
|
183
|
+
# @param [String] name
|
184
|
+
# @param [String] type The type option is the type of the resource, such as string.
|
185
|
+
# @param [String] package Include the --package option if you want to specify the resource table package name,
|
186
|
+
# otherwise the first defined package will be used.
|
187
|
+
#
|
188
|
+
# @example
|
189
|
+
#
|
190
|
+
# resources_value "default", "revision_hash", "string"
|
191
|
+
#
|
192
|
+
def resources_value(config, name, type, package = "")
|
193
|
+
`apkanalyzer resources value --config #{config} --name #{name} --type #{type} #{package} #{@apk_path}`.strip
|
194
|
+
end
|
195
|
+
|
196
|
+
# Prints the human-readable form of a binary XML file. Include the file option to specify the path to the file.
|
197
|
+
def resources_xml(xml_file)
|
198
|
+
`apkanalyzer resources xml --file #{xml_file} #{@apk_path}`.strip
|
199
|
+
end
|
200
|
+
end # class Apkanalyzer
|
201
|
+
end # module DroidAdbs
|
data/lib/droid_adbs/version.rb
CHANGED
data/lib/droid_adbs.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: droid_adbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuaki MATSUO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- droid_adbs.gemspec
|
71
71
|
- lib/droid_adbs.rb
|
72
72
|
- lib/droid_adbs/aapt.rb
|
73
|
+
- lib/droid_adbs/apkanalyzer.rb
|
73
74
|
- lib/droid_adbs/commons/backup.rb
|
74
75
|
- lib/droid_adbs/commons/devices.rb
|
75
76
|
- lib/droid_adbs/commons/doze.rb
|