Skip to content

Commit

Permalink
img2sdat.py: add ability to choose system version
Browse files Browse the repository at this point in the history
- default version set to 4 (google's one)
- fixes #4
  • Loading branch information
xpirt committed Dec 23, 2016
1 parent 8cdd746 commit eb9b693
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion blockimgdiff.py
Expand Up @@ -261,7 +261,7 @@ def __le__(self, other):
# original image.

class BlockImageDiff(object):
def __init__(self, tgt, src=None, threads=None, version=4,
def __init__(self, tgt, src=None, version=4, threads=None,
disable_imgdiff=False):
if threads is None:
threads = multiprocessing.cpu_count() // 2
Expand Down
32 changes: 28 additions & 4 deletions img2sdat.py
Expand Up @@ -3,7 +3,7 @@
#====================================================
# FILE: img2sdat.py
# AUTHORS: xpirt - luxi78 - howellzhu
# DATE: 2016-11-23 16:20:11 CST
# DATE: 2016-12-23 17:46:55 CST
#====================================================

import sys, os, errno, tempfile
Expand All @@ -26,19 +26,43 @@
except IndexError:
print('Usage: img2sdat.py <system_img>\n')
print(' <system_img>: input system image\n')
print("Visit xda thread for more information.\n")
print('Visit xda thread for more information.\n')
try:
input = raw_input
except NameError: pass
input('Press ENTER to exit...')
sys.exit()

def main(argv):
version = 4
item = True
while item:
print(''' 1. Android Lollipop 5.0
2. Android Lollipop 5.1
3. Android Marshmallow 6.0
4. Android Nougat 7.0
''')
item = raw_input('Choose system version: ')
if item == '1':
version = 1
break
elif item == '2':
version = 2
break
elif item == '3':
version = 3
break
elif item == '4':
version = 4
break
else:
return

# Get sparse image
input_image = sparse_img.SparseImage(INPUT_IMAGE, tempfile.mkstemp()[1], '0')
image = sparse_img.SparseImage(INPUT_IMAGE, tempfile.mkstemp()[1], '0')

# Generate output files
b = blockimgdiff.BlockImageDiff(input_image, None)
b = blockimgdiff.BlockImageDiff(image, None, version)
b.Compute('system')

print('Done! Output files: %s' % os.path.dirname(__file__))
Expand Down

0 comments on commit eb9b693

Please sign in to comment.