Skip to content

Commit

Permalink
Clean up reporting of unknown res specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
devunwired committed Dec 18, 2013
1 parent a0c6ff1 commit b187c60
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/read_manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@

# You can also optionally enable indented (pretty) output,
# and resolving of resource values
manifest_xml = xml.parse_xml("AndroidManifest.xml", true, true)
manifest_xml = xml.parse_xml("AndroidManifest.xml", true, false)

File.open(outfile, 'w') { |file| file.write(manifest_xml) }
19 changes: 16 additions & 3 deletions lib/apktools/apkresources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,12 @@ def get_resource_key(res_id, xml_format=false)
end

res_spec = package_element.type_data[res_type-1]
entry = res_spec.types.entries[res_index]

if res_spec == nil
puts "Could not find ResTypeSpec for #{res_package} #{res_type}" if DEBUG
return nil
end

entry = res_spec.types.entries[res_index]
if entry == nil
# There is no entry in our table for this resource
return nil
Expand Down Expand Up @@ -294,7 +298,11 @@ def get_resource_value(res_id)
end

res_spec = package_element.type_data[res_type-1]

if res_spec == nil
puts "Could not find ResTypeSpec for #{res_package} #{res_type}" if DEBUG
return nil
end

entries = res_spec.types.entries[res_index]
if entries == nil
puts "Could not find #{res_spec.types.id} ResType chunk" if DEBUG
Expand Down Expand Up @@ -342,6 +350,7 @@ def get_resource_value(res_id)
# Header Constants
CHUNKTYPE_TYPESPEC = 0x202 # :nodoc:
CHUNKTYPE_TYPE = 0x201 # :nodoc:
CHUNKTYPE_PACKAGE = 0x200 # :nodoc:

#Flag Constants
FLAG_UTF8 = 0x100 # :nodoc:
Expand Down Expand Up @@ -554,6 +563,10 @@ def parse_package(data, offset)
end

current += header.chunk_size
elsif header.type == CHUNKTYPE_PACKAGE
## This is the next package chunk, move along
puts "Next Package Chunk Found...Ending" if DEBUG
current = data.length
else
puts "Unknown Chunk Found: #{header.type} #{header.size}" if DEBUG
## End Immediately
Expand Down

0 comments on commit b187c60

Please sign in to comment.