Skip to content
Permalink
Browse files

img2sdat.py: add ability to choose system version

- default version set to 4 (google's one)
- fixes #4
  • Loading branch information...
xpirt committed Dec 23, 2016
1 parent 8cdd746 commit eb9b693c2556944a7fd41dc232a5ac0b89fe203e
Showing with 29 additions and 5 deletions.
  1. +1 −1 blockimgdiff.py
  2. +28 −4 img2sdat.py
@@ -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
@@ -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
@@ -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__))

0 comments on commit eb9b693

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