Introduction
You probably know already that starting from Android 5.0 (Lollipop) compiled roms (aosp,cm,stock) are not compressed anymore the way they used to be on previous android versions. On previous versions all content inside /system folder that has to be extracted within our device was either uncompressed (simple /system folder inside our flashable zip) or compressed in a system.img file, which it is a ext4 compressed file; both of these, anyway, were readable and we could see all system files (app,framework, etc).
The problem comes in 5.0+ versions, this method is not used anymore. Why? Because roms started to be always larger, so it is necessary to compress them even more.
What does Android 5.0 zips (full roms, but also otas) contain?
Android 5.0 flashable zips are made this way:
What does updater-script contains then?
The updater-script uses a brand new function: block_image_update(), this method basically decompresses necessary files inside the device. Let's study it.
From google git source code, if we go inside the new file /bootable/recovery/updater/blockimg.c, we find at the end of it the registration of the function block_image_update() as the method BlockImageUpdateFn() which starts at line 254. Here finally we find all information we need to know about the decompression of the .dat file(s). First file we analyze is system.transfer.list which Google tells us:
But what each line means? Here again Google explains us :):
Ok, but how to decompress the system.new.dat file?
howellzhu, a guy from chinese development forums managed to compile a binary that does exactly what we want.
This binary file is called sdat2img, below you find information about that file and how to use it.
What is the sdat2img binary?
The sdat2img binary file is a simple 64-bit linux binary(warning! you already know that this needs a 64-bit kernel too, therefore you must have installed a 64-bit linux distro) that converts system.new.dat to a standard ext4 image.
How to use the sdat2img binary?
Assuming you have already installed Linux 64-bit, to use it is very simple, here is the way:
Where can I download the sdat2img binary?
The download can be found uploaded in my Dev-Host account, specifically click here to download it directly.
If you have more information about the new method on Android 5.0, feel free to reply here or Pm me, I'll be happy to include it in the OP.
If you have questions or problems write here too ;)
Credits
howellzhu - big thanks go to him for the sdat2img binary
me - for how-to guide and information
You probably know already that starting from Android 5.0 (Lollipop) compiled roms (aosp,cm,stock) are not compressed anymore the way they used to be on previous android versions. On previous versions all content inside /system folder that has to be extracted within our device was either uncompressed (simple /system folder inside our flashable zip) or compressed in a system.img file, which it is a ext4 compressed file; both of these, anyway, were readable and we could see all system files (app,framework, etc).
The problem comes in 5.0+ versions, this method is not used anymore. Why? Because roms started to be always larger, so it is necessary to compress them even more.
What does Android 5.0 zips (full roms, but also otas) contain?
Android 5.0 flashable zips are made this way:
boot.img (we all know what it is)
file_contexts
META-INF (folder containing scripts)
system.new.dat (compressed /system partition)
system.patch.dat
system.transfer.list (see explanation below)
What does updater-script contains then?
The updater-script uses a brand new function: block_image_update(), this method basically decompresses necessary files inside the device. Let's study it.
From google git source code, if we go inside the new file /bootable/recovery/updater/blockimg.c, we find at the end of it the registration of the function block_image_update() as the method BlockImageUpdateFn() which starts at line 254. Here finally we find all information we need to know about the decompression of the .dat file(s). First file we analyze is system.transfer.list which Google tells us:
Quote:
The transfer list is a text file containing commands to transfer data from one place to another on the target partition. |
But what each line means? Here again Google explains us :):
Quote:
First line is the version number of the transfer list; currently there's only version 1. Second line is the total number of blocks being written. Third line and subsequent lines are all individual transfer commands. |
Ok, but how to decompress the system.new.dat file?
howellzhu, a guy from chinese development forums managed to compile a binary that does exactly what we want.
This binary file is called sdat2img, below you find information about that file and how to use it.
What is the sdat2img binary?
The sdat2img binary file is a simple 64-bit linux binary(warning! you already know that this needs a 64-bit kernel too, therefore you must have installed a 64-bit linux distro) that converts system.new.dat to a standard ext4 image.
How to use the sdat2img binary?
Assuming you have already installed Linux 64-bit, to use it is very simple, here is the way:
sdat2img <trans_list> <system_new_file> <system_img>and a quick example:
sdat2img system.transfer.list system.new.dat my_new_system.imgby running this command you will get as output the file my_new_system.img which is the ext4 image. It can be decompressed as this:
sudo mount -t ext4 -o loop,ro,noexec,noload my_new_system.img my_output_folderfinally inside the folder my_output_folder you find /app, /framework, /lib, /priv-app, etc folders together with the build.prop.
Where can I download the sdat2img binary?
The download can be found uploaded in my Dev-Host account, specifically click here to download it directly.
If you have more information about the new method on Android 5.0, feel free to reply here or Pm me, I'll be happy to include it in the OP.
If you have questions or problems write here too ;)
Credits
howellzhu - big thanks go to him for the sdat2img binary
me - for how-to guide and information