Skip to content
Permalink
Browse files

sdat2img.py: added marshmallow 6.0 support

  • Loading branch information...
xpirt committed Oct 11, 2015
1 parent a760bc3 commit d7211b1a35564ce612be8fa8699a2be701cde218
Showing with 14 additions and 8 deletions.
  1. +14 −8 sdat2img.py
@@ -3,7 +3,7 @@
#====================================================
# FILE: sdat2img.py
# AUTHORS: xpirt - luxi78 - howellzhu
# DATE: 2015-07-08 17:54:09 CST
# DATE: 2015-10-11 14:25:44 CST
#====================================================

import sys, os
@@ -18,7 +18,7 @@
try:
input = raw_input
except NameError: pass
input ("Press any key to exit...\n")
input ("Press ENTER to exit...\n")
sys.exit()

BLOCK_SIZE = 4096
@@ -37,7 +37,11 @@ def parse_transfer_list_file(path):
version = int(trans_list.readline()) # 1st line = transfer list version
new_blocks = int(trans_list.readline()) # 2nd line = total number of blocks

# version 2 introduced with android-5.1.0_r1
# system.transfer.list:
# - version 1: android-5.0.0_r1
# - version 2: android-5.1.0_r1
# - version 3: android-6.0.0_r1

# skip next 2 lines. we don't need this stuff now
if version >= 2:
trans_list.readline() # 3rd line = stash entries needed simultaneously
@@ -46,10 +50,12 @@ def parse_transfer_list_file(path):
for line in trans_list:
line = line.split(' ') # 5th & next lines should be only commands
cmd = line[0]
if 'erase' == cmd:
erase_block_set = rangeset(line[1])
elif 'new' == cmd:
if 'new' == cmd:
new_block_set = rangeset(line[1])
elif 'zero' == cmd:
zero_block_set = rangeset(line[1])
elif 'erase' == cmd:
erase_block_set = rangeset(line[1])
else:
# skip lines starting with numbers, they're not commands anyway.
if not cmd[0].isdigit():
@@ -58,7 +64,7 @@ def parse_transfer_list_file(path):
sys.exit(1)

trans_list.close()
return version, new_blocks, erase_block_set, new_block_set
return version, new_blocks, new_block_set, zero_block_set, erase_block_set

def init_output_file_size(output_file_obj, erase_block_set):
max_block_num = max(pair[1] for pair in erase_block_set)
@@ -67,7 +73,7 @@ def init_output_file_size(output_file_obj, erase_block_set):
output_file_obj.flush()

def main(argv):
version, new_blocks, erase_block_set, new_block_set = parse_transfer_list_file(TRANSFER_LIST_FILE)
version, new_blocks, new_block_set, zero_block_set, erase_block_set = parse_transfer_list_file(TRANSFER_LIST_FILE)
output_img = open(OUTPUT_IMAGE_FILE, 'wb')
init_output_file_size(output_img, erase_block_set)
new_data_file = open(NEW_DATA_FILE, 'rb')

2 comments on commit d7211b1

@mfonville

This comment has been minimized.

Copy link

replied Oct 11, 2015

I get on an old (5.1) image:

Traceback (most recent call last):
File "sdat2img.py", line 95, in
main(sys.argv)
File "sdat2img.py", line 76, in main
version, new_blocks, new_block_set, zero_block_set, erase_block_set = parse_transfer_list_file(TRANSFER_LIST_FILE)
File "sdat2img.py", line 67, in parse_transfer_list_file
return version, new_blocks, new_block_set, zero_block_set, erase_block_set
UnboundLocalError: local variable 'zero_block_set' referenced before assignment

@xpirt

This comment has been minimized.

Copy link
Owner Author

replied Oct 11, 2015

Sorry, my mistake. Fixed.

sdat2img.py: fixed UnboundLocalError on android 5.x - 50eb51e

Please sign in to comment.
You can’t perform that action at this time.