Tor Browser for Android needs a more dynamic Build ID
Currently, the build id only changes when the Firefox version changes and when the copyright year changes. Unfortunately, when building the APK, Mozilla expect the build id changes between every build. They use the build id and derive the Android version code (version number) from this. Unfortunately, they only use part of the buildid and they discard lower bits. This doesn't fit well with the current get-moz-build-date
script because:
- if the firefox build date and copyright year remain the same, then the build id remains the same
- if the patch version increases (such as 60.3.0 to 60.3.1), then the Android version code doesn't change (due to discarded lower bits)
I think we can solve 1. by incorporating the tor browser version number into the calculation. Solving 2. may require multiplying by at least 3600 (therefore offsets the division by 60*60), i think. https://gitweb.torproject.org/tor-browser.git/tree/python/mozbuild/mozbuild/android_version_code.py?h=tor-browser-60.3.0esr-8.5-1#n33
$ perl get-moz-build-date 2018 60.3.0
export MOZ_BUILD_DATE=20180204040101
$ python python/mozbuild/mozbuild/android_version_code.py --verbose --with-android-cpu-arch armeabi-v7a --with-android-min-sdk-version 16 --with-android-max-sdk-version 26 20180204040101
2015539361
$ perl get-moz-build-date 2018 60.3.1
export MOZ_BUILD_DATE=20180204040201
$ python python/mozbuild/mozbuild/android_version_code.py --verbose --with-android-cpu-arch armeabi-v7a --with-android-min-sdk-version 16 --with-android-max-sdk-version 26 20180204040201
2015539361
$ perl get-moz-build-date 2018 60.4.0
export MOZ_BUILD_DATE=20180204050101
$ python python/mozbuild/mozbuild/android_version_code.py --verbose --with-android-cpu-arch armeabi-v7a --with-android-min-sdk-version 16 --with-android-max-sdk-version 26 20180204050101
2015539369
Notice the android version code is the same for 60.3.0
and 60.3.1
.
Currently, the script with the current Tor Browser Build ID is:
import math
import time
fmt = '%Y%m%d%H%M%S'
buildid = "20180204040101"
V1_CUTOFF = 20150801000000
build = time.strptime(str(buildid), fmt)
cutoff = time.strptime(str(V1_CUTOFF), fmt)
base = int(math.floor((time.mktime(build) - time.mktime(cutoff)) / (60.0 * 60.0)))
version = 0b1111000001000000000000000000000
version |= base << 3
version |= 1 << 0
print(version)
Something else I noticed is this current scheme only provides 8 android version codes between 60.3.0 (2015539361) and 60.4.0 (2015539369). We probably want more than that - but this may be accomplished when adjusting the other bits.