I think I found a solution to this. In my case, the SIM stops working every time I place the SIM into another device and back into my Oneplus One (Lineage OS). It works perfectly until I remove the SIM card, put it into another device, and then back.
I have tried factory data reset, different custom OS, stock OS, Ubuntu Touch, nothing worked. After having tried hundreds of different variations, here's the recipe:
- Flash Lineage OS recovery
- Install Lineage OS (all with SIM inserted)
- After install, boot into the system. SIM won't be detected at this point
- Go back to the recovery mode (Vol. Down + Power for several minutes)
- Format cache data ONLY
- Boot back into the OS. Sometimes the SIM will start working even at this point but if not, just do a factory data reset now (initiated from the OS settings) and the SIM will be working perfectly
I don't know if anyone else will find this useful or maybe it's just pure luck and it is indeed totally random whether it works or not, but I have done this a few times after having succeeded to test stability, and so far this method works every time.