GPS won't fix on cancro (Xiaomi mi4)

Fresh install of /e/ on my old Xiaomi MI4(cancro) from e-0.13-n-2020120989402-dev-cancro.zip

First installed F-Droid and OpenTracks and went for a walk - noticed that it doesn’t record the distance.

Back home I installed GPSTest and found out that it won’t get a fix - not even after 10-15 minutes.

The following errors are repeatedly displayed in adb logcat while GPSTest is running:

01-04 17:38:53.878 831 1334 E LocSvc_utils_q: D/msg_q_snd: Sending message with handle = 0x8FC9E900
01-04 17:38:53.878 831 1334 E LocSvc_utils_ll: D/linked_list_add: Adding to list data_obj = 0x8FC9E900
01-04 17:38:53.878 831 1334 E LocSvc_utils_q: D/msg_q_snd: Finished Sending message with handle = 0x8FC9E900
01-04 17:38:53.878 831 1320 E LocSvc_utils_ll: D/linked_list_remove: Removing from list
01-04 17:38:53.878 831 1320 E LocSvc_utils_q: D/msg_q_rcv: Received message 0x8FC9E900 rv = 0
01-04 17:38:53.879 831 1320 E LocSvc_eng: V/flags: 35
01-04 17:38:53.879 831 1320 E LocSvc_eng: source: 2
01-04 17:38:53.879 831 1320 E LocSvc_eng: latitude: 31.409998
01-04 17:38:53.879 831 1320 E LocSvc_eng: longitude: 35.070001
01-04 17:38:53.879 831 1320 E LocSvc_eng: altitude: 0.000000
01-04 17:38:53.879 831 1320 E LocSvc_eng: speed: 0.000000
01-04 17:38:53.879 831 1320 E LocSvc_eng: bearing: 0.000000
01-04 17:38:53.879 831 1320 E LocSvc_eng: accuracy: 0.000000
01-04 17:38:53.879 831 1320 E LocSvc_eng: timestamp: 1609774733847
01-04 17:38:53.879 831 1320 E LocSvc_eng: rawDataSize: 0
01-04 17:38:53.879 831 1320 E LocSvc_eng: rawData: 0x0
01-04 17:38:53.879 831 1320 E LocSvc_eng: Session status: 1
01-04 17:38:53.879 831 1320 E LocSvc_eng: Technology mask: 2
01-04 17:38:53.879 831 1320 E LocSvc_afw: V/Entering void local_loc_cb(UlpLocation*, void*) line 1089
01-04 17:38:53.879 831 1320 E LocSvc_afw: I/<=== location_cb - from line 1091 2
01-04 17:38:53.880 831 1320 W LocationManagerService: Dropping incomplete location: Location[gps 31.409998,35.070001 acc=??? et=+26m47s972ms alt=0.0 {Bundle[{satellites=0}]}]
01-04 17:38:53.880 831 1320 E LocSvc_afw: V/Exiting void local_loc_cb(UlpLocation*, void*) line 1097 None
01-04 17:38:53.881 831 1320 E LocSvc_MsgTask: D/MsgTask::loop() 1453 listening …
01-04 17:38:53.881 831 1320 E LocSvc_utils_q: D/msg_q_rcv: Waiting on message
01-04 17:38:54.275 2785 2785 D GpsOutputNmea: 1609774733867,$GPGSV,4,1,15,02,00,000,09,32,319,11,32,063,14,34,296,*72
01-04 17:38:54.275 2785 2785 D GpsOutputNmea: 1609774733868,$GPGSV,4,2,15,16,05,067,17,70,202,20,00,000,21,00,000,*78
01-04 17:38:54.276 2785 2785 D GpsOutputNmea: 1609774733868,$GPGSV,4,3,15,23,10,317,24,23,081,26,00,000,27,00,000,*70
01-04 17:38:54.276 2785 2785 D GpsOutputNmea: 1609774733869,$GPGSV,4,4,15,28,35,049,29,00,000,31,40,322,*42
01-04 17:38:54.284 2785 2785 D GpsOutputNmea: 1609774733869,$GLGSV,3,1,10,78,37,074,70,09,310,82,29,180,77,00,000,*6A
01-04 17:38:54.286 2785 2785 D GpsOutputNmea: 1609774733869,$GLGSV,3,2,10,80,09,307,69,16,254,88,31,036,87,00,000,*63
01-04 17:38:54.287 2785 2785 D GpsOutputNmea: 1609774733870,$GLGSV,3,3,10,81,66,113,68,01,208,*6B
01-04 17:38:54.289 2785 2785 W NmeaUtils: Empty DOP values in NMEA: $GPGSA,A,1,1E
01-04 17:38:54.289 2785 2785 D GpsOutputNmea: 1609774733870,$GPGSA,A,1,1E
01-04 17:38:54.290 2785 2785 D GpsOutputNmea: 1609774733870,$GPVTG,T,M,N,K,N
2C
01-04 17:38:54.291 2785 2785 D GpsOutputNmea: 1609774733871,$GPRMC,V,N
53
01-04 17:38:54.291 2785 2785 W NmeaUtils: Couldn’t parse geoid altitude from NMEA: $GPGGA,0,*66
01-04 17:38:54.291 2785 2785 D GpsOutputNmea: 1609774733871,$GPGGA,0,*66

Here’s a screenshot showing lots of satellites visible, but not getting location fix.
Screenshot_20210104-115605

How can I make GPS work reliably? Main reason for using this device is to record hikes and runs (the Xiaomi ROMs usually disables the location service to save power, unless you turn on the screen every couple of minutes - and I was hoping to avoid that).

After (lots) of fiddling and trial and error, which included referencing my Note 5 gps.conf and flashing xiaomi.eu and mokee ROM on this poor Mi4, I’ve got something that works, eventually (first time the fix took 510 seconds, now even more).
Screenshot_20210113-120828

Of course, now time to test how it behaves with Battery Optimization turned off for OruxMaps and runner apps.

In hopes it helps someone in the future, here’s the gist file