How to reinstall critical system files after an accidental OS wipe?

Anyone who reads this is going to bash their head against a wall. Anyways, I have a OnePlus 5. It was running LineageOS 15.1. However, there were various problems with the operating system that resulted in many apps crashing on my phone. I wanted to go back to Oxygen OS. Before flashing Lineage, I created a TWRP backup of Oxygen OS. I tried to restore it by booting into TWRP, wiping the usual systems before a flash (Dalvik/ART cache, cache, system, and data), then I used the restore feature to restore the Oxygen OS backup. When the OS started up, the lockscreen would not let me in, even though I made sure I had the correct PIN. I tried factory resetting the phone through TWRP, no dice. I looked up a guide to fixing this for this specific issue and it said to, in TWRP, load the root explorer and delete "gatekeeper.password.key", "gatekeeper.pattern.key", and "locksettings.db" from /data/system. I did that and sucessfully bypassed the lockscreen, but the phone (being factory reset) tried to set itself up. I pressed the "Start" button (like you would on any new phone), but it got stuck on the next screen which was "just a sec" or something like that. I then tried to get around this by restoring the backup again, without factory resetting it. I was able to get into the phone but the homescreen showed ONLY the backround image (no dock, icons, nothing). I was able to access settings through the notifications and found that only the Phone app was installed (according to the default apps menu). I then went back into TWRP and tried to flash Open Gapps, but that didn't work (the script was aborted because of an error). Then I though reflashing LineageOS would at least make my phone usable. So I flashed LineageOS (wiping the Dalvik/ART cache, cache, system, and data via "advanced wipe") and added Open Gapps and Magisk to the zip quene. Lineage flashed, Gapps had an error, and Magisk did as well. When I tried to boot, it when right back into recovery. I figured it was because I tried to root the phone right off the bat, so I repeated the same thing without Magisk. the phone booted into the OS but got stuck at the same screen as Oxygen OS did when it was trying to set up a new phone. I then read a guide that said to format the system and reflash the ROM. I misunderstood and wiped the OS off the phone. When using TWRP to browse the phone files, I have the following folders:

acct, boot, cache, config, data, dev, etc, firmware, license, mnt, oem, proc, recovery, res, root, sbin, sdcard, sideload, storage, sys, system, tmp, twres, usbstorage, and vendor

There are also various files (tell me if that information is important). I then, like the guide said, tried to flash Lineage OS with Open Gapps. However, I had to copy the files back over from my computer, which didn't work. I tried to install the OnePlus drivers (even though these were already installed), but the zip still wouldn't copy over to the phone. I finally used "adb sideload" to flash LineageOS and Open Gapps and this is where the phone told me, when I was about to reboot, that there was no operating system. After reading that, I have left the phone alone and resorted to asking for help, like this.

Show Accepted Answer

Guest Quick Reply (No URL, BBcode or HTML)

Last post by rrau
2 hours ago
Last post by keeley11
2 hours ago
Last post by hane.monserrat
4 hours ago
Last post by koch.nelda
1 hour ago
Last post by loyal.steuber
3 hours ago
Last post by oceane13
4 hours ago
Last post by lmetz
47 minutes ago
Last post by trantow.caesar
1 hour ago
Last post by mueller.javonte
1 hour ago
Last post by mittie96
4 hours ago
Last post by isabella78
3 hours ago
[Q] Xperia NEo
Started by fthiel
Last post by sfarrell
12 minutes ago
Last post by hudson.fritsch
3 hours ago