/xosp_delta

Primary LanguageCGNU General Public License v3.0GPL-3.0

XOSPDelta is a delta update method for XOSP. Instead of downloading full ROM zips, it uses deltas to reduce the download size.
XOSPDelta uses xdelta3 (http://xdelta.org) between the previous and current release. Quote from github.com/omnirom/android_packages_apps_OpenDelta/blob/android-6.0/README.md :
"Usually, OTA ZIP files created by Android builds are compressed.Diffs between compressed OTA ZIPs are not ideal - they are significantly larger than the diff between two uncompressed OTA ZIPs would be. So before we create the diff we decompress the contents of the OTA ZIPs." XOSPDelta uses Chainfire's and OmniROM's zipadjust to decompress the zips.

Delta specifications

The delta is generated by running xdelta3 on the decompressed zip of the newest, but as yet unreleased ROM, using the decompressed zip of the newest released ROM. The resultant delta is named "diff". All decompressions are done using Chainfire's zipadjust.
After that, certain information about the base ROM, the target ROM, and the generated delta is written as JSON in a file called "deltaconfig". A sample deltaconfig is below.
The diff and deltaconfig files are then put into a zip archive without compression, and uploaded to a server. The user downloads it, gives the base ROM and the delta zip to XOSPDelta, and gets the updated ROM.
TO-DO : Automatically fetch the delta and apply it to the correct ROM.

Server script

There is a script to generate the deltas on the build machine. Get server/xospdelta.sh, and set the variables to reflect your build environment. Run it with the name of the device as a parameter and upload the zip in publish/DEVICE_NAME The zip will have the same name as the second newest (the base ROM) build, to make it easier for the client to find it.

Server side

To create the delta files on the server, you need several things, some of which can be found in the server directory.
The main thing is the xospdelta.sh script. It contains a configuration section which you can edit with the correct file locations on your own system. Quite likely you will need to create a wrapper script that pulls in your previous release and your current release, and pushes out the created delta files.The script depends on xdelta3, zip,and zipadjust. To build the binaries for use on your server, make a copy of the jni directory - do not compile inside jni because you may mess up the build of libopendelta.
xdelta3 can be built in (the copy of)jni/xdelta3-3.0.7 by calling:
./configure
make
zipadjust can be built in (the copy of)jni by calling:
gcc -o zipadjust zipadjust.c zipadjust_run.c -lz
dedelta (not used by the script, but maybe helpful when debugging) can be built in (the copy of)jni by calling:
gcc -o dedelta xdelta3-3.0.7/xdelta3.c delta.c delta_run.c
You should be able to install zip from your distro's repositories.

Sample deltaconfig

{
"version":2.1,
"source":"(base_rom_name).zip",
"target":"(target_rom_nam).zip",
"targetMd5":"(target_rom_md5)",
"sourceMd5":"(base_rom_md5)",
"sourceDecMd5":"(base_rom_decompressed_md5)",
"deltaMd5":"(md5_of_the_diff_file)",
"targetSize":(target_rom_size)
}

Used libraries and assets

(1) Android Cardview - Google
(2) Apache Commons IO - Apache
(3) Android-Iconics - mikepenz
(4) Android-MaterialRefreshLayout - android-cjj
(5) Android Support - Google
(6) Android Support AppCompat - Google
(7) Android Support Design - Google
(8) AppIntro - PaoloRotolo
(9) AVLoadingIndicatorView - Jack Wang
(10) libopendelta - Chainfire (https://github.com/omnirom/android_packages_apps_OpenDelta/blob/android-6.0/jni/delta_run.c)
(11) libsuperuser - Chainfire
(12) Moshi - Square, Inc.
(13) Nineoldandroids - Jake Wharton
(14) NoNonsense-FilePicker - spacecowboy
(15) NumberProgressbar - daimajia
(16) SlideExpandableListView - tjerkw
(17) xdelta3