ruby_apk 0.5.0 → 0.5.1

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.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # ChangeLog
2
+ ## 0.5.1
3
+ * [#8] ass Android::Manifest#label
4
+ * [#7] fix wrong boolean value in manifest parser
5
+ * [#6] add accessor Android::Manifest#doc
6
+
2
7
  ## 0.5.0
3
- * implement Android::Resource#find, #res_readable_id, #res_hex_id methods
8
+ * [issue #1] implement Android::Resource#find, #res_readable_id, #res_hex_id methods
4
9
 
5
10
  ## 0.4.2
6
11
  * fix bugs(#2, #3)
data/README.md CHANGED
@@ -77,6 +77,8 @@ This feature supports only srting resources for now.
77
77
 
78
78
  ```ruby
79
79
  apk = Android::Apk.new('sample.apk')
80
+ rsc = apk.resource
81
+
80
82
  # assigns readable resource id
81
83
  puts rsc.find('@string/app_name') # => 'application name'
82
84
 
@@ -94,12 +96,12 @@ This feature supports only srting resources for now.
94
96
  apk = Android::Apk.new('sample.apk')
95
97
  dex = apk.dex
96
98
  # listing string table in dex
97
- dex.strings do |str|
99
+ dex.strings.each do |str|
98
100
  puts str
99
101
  end
100
102
 
101
103
  # listing all class names
102
- dex.classes do |cls| # cls is Android::Dex::ClassInfo
104
+ dex.classes.each do |cls| # cls is Android::Dex::ClassInfo
103
105
  puts "class: #{cls.name}"
104
106
  cls.virtual_methods.each do |m| # Android::Dex::MethodInfo
105
107
  puts "\t#{m.definition}" # puts method definition
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -167,7 +167,7 @@ module Android
167
167
  when VAL_TYPE_INT_HEX
168
168
  value = "%#x" % val
169
169
  when VAL_TYPE_INT_BOOLEAN
170
- value = val != 0xFFFFFFFE ? true : false # ugh! is it ok??
170
+ value = ((val != 0xFFFFFFFF) || (val==1)) ? true : false
171
171
  else
172
172
  value = "[%#x, flag=%#x]" % [val, flags]
173
173
  end
@@ -28,11 +28,15 @@ module Android
28
28
  attr_reader :intent_filters
29
29
  # @return [Array<Manifest::Meta>]
30
30
  attr_reader :metas
31
+ # @return [REXML::Element]
32
+ attr_reader :elem
33
+
31
34
 
32
35
  # @param [REXML::Element] elem target element
33
36
  # @raise [ArgumentError] when elem is invalid.
34
37
  def initialize(elem)
35
38
  raise ArgumentError unless Component.valid?(elem)
39
+ @elem = elem
36
40
  @type = elem.name
37
41
  @name = elem.attributes['name']
38
42
  @intent_filters = []
@@ -144,6 +148,9 @@ module Android
144
148
  #################################
145
149
  # Manifest class definitions
146
150
  #################################
151
+ #
152
+ # @return [REXML::Document] manifest xml
153
+ attr_reader :doc
147
154
 
148
155
  # @param [String] data binary data of AndroidManifest.xml
149
156
  def initialize(data)
@@ -197,6 +204,12 @@ module Android
197
204
  @doc.elements['/manifest/uses-sdk'].attributes['minSdkVersion'].to_i
198
205
  end
199
206
 
207
+ # application label
208
+ # @return [String] application label string or resource id (like @0x7f04001)
209
+ def label
210
+ @doc.elements['/manifest/application'].attributes['label']
211
+ end
212
+
200
213
  # return xml as string format
201
214
  # @param [Integer] indent size(bytes)
202
215
  # @return [String] raw xml string
data/ruby_apk.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ruby_apk"
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["SecureBrain"]
12
- s.date = "2013-01-04"
12
+ s.date = "2013-05-01"
13
13
  s.description = "static analysis tool for android apk"
14
14
  s.email = "info@securebrain.co.jp"
15
15
  s.extra_rdoc_files = [
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
59
59
  s.homepage = "https://github.com/SecureBrain/ruby_apk/"
60
60
  s.licenses = ["MIT"]
61
61
  s.require_paths = ["lib"]
62
- s.rubygems_version = "1.8.23"
62
+ s.rubygems_version = "1.8.25"
63
63
  s.summary = "static analysis tool for android apk"
64
64
 
65
65
  if s.respond_to? :specification_version then
@@ -33,6 +33,11 @@ describe Android::Manifest do
33
33
  it { should have(2).item }
34
34
  end
35
35
  end
36
+ describe '#elem' do
37
+ subject { Android::Manifest::Component.new(elem).elem }
38
+ let(:elem) { REXML::Element.new('service') }
39
+ it { should eq elem }
40
+ end
36
41
 
37
42
  describe Android::Manifest::Meta do
38
43
  let(:elem) do
@@ -168,13 +173,21 @@ describe Android::Manifest do
168
173
  subject { manifest.min_sdk_ver}
169
174
  it { should == 10 }
170
175
  end
176
+ describe "#label" do
177
+ subject { manifest.label }
178
+ it { should == "@0x7f040001" }
179
+ end
180
+ describe "#doc" do
181
+ subject { manifest.doc }
182
+ it { should be_instance_of REXML::Document }
183
+ end
171
184
  describe "#to_xml" do
172
185
  let(:raw_xml){ str = <<EOS
173
186
  <manifest xmlns:android='http://schemas.android.com/apk/res/android' android:versionCode='101' android:versionName='1.0.1-malware2' package='example.app.sample'>
174
187
  <uses-sdk android:minSdkVersion='10'/>
175
188
  <uses-permission android:name='android.permission.INTERNET'/>
176
189
  <uses-permission android:name='android.permission.WRITE_EXTERNAL_STORAGE'/>
177
- <application android:label='@0x7f040001' android:icon='@0x7f020000' android:debuggable='true'>
190
+ <application android:label='@0x7f040001' android:icon='@0x7f020000' android:debuggable='false'>
178
191
  <activity android:label='@0x7f040001' android:name='example.app.sample.SampleActivity'>
179
192
  <intent-filter>
180
193
  <action android:name='android.intent.action.MAIN'/>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_apk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-04 00:00:00.000000000 Z
12
+ date: 2013-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubyzip
@@ -184,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  segments:
186
186
  - 0
187
- hash: 671022741244016522
187
+ hash: 1470903068031812848
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  none: false
190
190
  requirements:
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project:
196
- rubygems_version: 1.8.23
196
+ rubygems_version: 1.8.25
197
197
  signing_key:
198
198
  specification_version: 3
199
199
  summary: static analysis tool for android apk