Skip to content

Instantly share code, notes, and snippets.

@rugk
Created December 21, 2017 11:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rugk/a4c9fa11c5c031faf45602d6bf922a1c to your computer and use it in GitHub Desktop.
Save rugk/a4c9fa11c5c031faf45602d6bf922a1c to your computer and use it in GitHub Desktop.
OTA survival script for AOSP keyboard swipe (LatinME)
#!/sbin/sh
#
# /system/addon.d/95-latinimegoogle.sh
# During an OS upgrade, this script backs up /system/lib/libjni_latinimegoogle.so,
# /system is formatted and reinstalled, then the file is restored.
#
. /tmp/backuptool.functions
list_files() {
cat <<EOF
lib/libjni_latinimegoogle.so
EOF
}
case "$1" in
backup)
list_files | while read FILE DUMMY; do
backup_file $S/"$FILE"
done
;;
restore)
list_files | while read FILE REPLACEMENT; do
R=""
[ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
[ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
done
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# Stub
;;
esac
@rugk
Copy link
Author

rugk commented Dec 21, 2017

Installation instructions/more details: https://android.stackexchange.com/a/187686/158241

@taivlam
Copy link

taivlam commented May 18, 2021

Some things have changed since December 2017 and I would like to document those changes:

  1. The OTA survival script/configuration fragment hack stopped working on the OnePlus 3T after the last OEM firmware update from OnePlus. I think this is because the LineageOS maintainers of oneplus3 started using digest files and this verifies system components against some set of signing keys, which will always cause the phone to vanish the custom OTA survival script. Due to this, the OTA solution only works on either: older 32-bit Android devices (such as the OnePlus One/bacon) or any 64-bit Android devices with LOS builds that do not use digest file checking. (I do not know how to check for this on arbitrary LOS-available devices.) (Even though the final OEM firmware update for the OnePlus 3T was relased by OnePlus in July 2019, I feel compelled to still write this because I have not seen anyone mention this so far.) If anything can be done to circumvent the digest file check, then that would be wonderful - however, I am not going to expect this to be very likely.

  2. As a note, the libjni_latinimegoogle.so hack requires TWRP as the device's custom recovery to work. Since LOS 17.1-18.1, Lineage Recovery has been offered for any device with LOS builds. However, do not use Lineage Recovery if you use this libjni_latinimegoogle.so hack. For some reason, if you have Lineage Recovery, the /system/lib64 directory simply does not exist, even when you mount the device storage via Lineage Recovery. This was observed on a OnePlus 3T/oneplus3.

  3. Based on what I have read, I infer that this libjni_latinimegoogle.so hack will simply not work on any custom ROM that properly implements verified boot via relocking the bootloader. As of May 2021, CalyxOS and GrapheneOS are 2 custom Android ROMs which use verified boot. So, dropping libjni_latinimegoogle.so among system files will probably be prohibited. Even if this gesture typing library hack was hypothetically possible, I feel like that would be an extremely bad security practice/move. Instead, if your use case/threat model allows for open source third-party keyboards, I would recommend FlorisBoard, which has recently implemented what it calls "glide" typing and is available on F-Droid. (Just to be clear, I am not affiliated with CalyxOS, GrapheneOS, or FlorisBoard.) AnySoftKeyboard promised some sort of glide/gesture typing, but that was back in 2018 and ASK never fully implemented this feature when I tired ASK once in 2020.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment