Recent Samsung vendor firmware, like in G781BXXSAHXC6 from April 2024, breaks SMS reception with recent GSI firmware, for example Andy Yan's LineageOS 20 GSI from https://sourceforge.net/projects/andyyan-gsi/files/lineage-20-light/

Based on the same fix for a different device (https://github.com/IverCoder/a03nnxx-ril-rollback), the 2 files libsec-ril.so and libsecril-client.so have to be extracted from an older Samsung firmware before June 2023, e.g. G781BXXS5HWD4

Here are the steps it took me to fix SMS reception:

  $ unzip AP_G781BXXS5HWD4_G781BXXS5HWD4_MQB64445591_REV00_user_low_ship_MULTI_CERT_meta_OS13.tar.md5.zip
  • Install android-sdk-libsparse-utils and lz4
  $ sudo apt install android-sdk-libsparse-utils lz4
  • Extract sparse image of super partition
  $ mkdir AP_G781BXXS5HWD4
  $ cd AP_G781BXXS5HWD4
  $ tar -xvf ../AP_G781BXXS5HWD4_G781BXXS5HWD4_MQB64445591_REV00_user_low_ship_MULTI_CERT_meta_OS13.tar.md5 super.img.lz4
  $ unlz4 super.img.lz4
  • Convert sparse super image to raw super image
  $ simg2img super.img super.img_raw
  • Build lpunpack from source
  $ cd ..
  $ git clone https://github.com/LonelyFool/lpunpack_and_lpmake.git 
  $ cd lpunpack_and_lpmake
  $ ./make.sh
  • Extract vendor image from raw super image
  $ cd AP_G781BXXS5HWD4
  $ mkdir super.img_raw_extracted
  $ ../lpunpack_and_lpmake/bin/lpunpack -p vendor super.img_raw super.img_raw_extracted/
  • Now we have an Ext4 image
  $ file super.img_raw_extracted/vendor.img 
  super.img_raw_extracted/vendor.img: Linux rev 1.0 ext2 filesystem data, UUID=70b6de35-be95-5001-bd80-c63c433cd480, volume name "vendor" (extents) (large files) (huge files)
  • Mount vendor image to access files
  $ mkdir vendor_mounted
  $ sudo mount -o loop super.img_raw_extracted/vendor.img vendor_mounted
  $ mkdir ril_patch
  $ cp vendor_mounted/lib64/libsec-ril.so ril_patch/
  $ cp vendor_mounted/lib64/libsecril-client.so ril_patch/
  • Make sure you have MTP, USB debugging and ADB root enabled

  • Connect device via USB and copy ril_patch directory to common storage (mounted as /sdcard)

  • Open ADB shell, become root, make /vendor writeable, replace existing files and reboot

  $ adb shell
  tdgsi_arm64_ab:/ $ su
  :/data/data # mount -o remount,rw /vendor
  :/data/data # cp /sdcard/ril_patch/libsec* /vendor/lib64/
  :/data/data # mount -o remount,ro /vendor
  :/data/data # reboot
  • After reboot, enter simcard PIN, unlock screen and send SMS from another phone. You should be able to receive SMS now.