Resolving Patch Conflicts
First off, we include two redundant methods for applying patches beyond the base patches script.
Apply Base Patches with Resolutions:
This will search through each set in vendor/ag/utils/android_r/google_diff/x86-resolutions/set# and attempt to apply any resolutions found after one of the base patches has a conflict.
Apply Base Patches Verbose:
This will run through the base set of patches, and offer a more verbose patching method. This script will leave a lot to manual work.
Manual Patch Resolution:
You will want to then make a copy of all the results of the patch scripts (Copy and paste the contents of the terminal output into a Notepad or text document). Each of the patches applied either resulted in "Applying", "Already applied", or "Conflicts". The only ones we want to pay attention to here are the "Conflicts", but only half of them. Some of the patches have duplicates for different vendor setups. So you will sometimes get results that look like this:
Conflicts system/core/0015-Bliss-init-don-t-bail-out-even-no-SELinux-domain-defined.patch
Applying system/core/0015-Tesla-init-don-t-bail-out-even-no-SELinux-domain-defined.patch 0
Notice how the one starting with "0015-Bliss-" failed, but the patch starting with "0015-Tesla-" applied correctly? If that happend on your vendor setup, you can ignore that patch. But if you only see one patch that had a "Conflicts", that will need to be applied and fixed.
First, you apply the patch manually:
git am "__patchLocationHere__"
You can expect that to fail, but it's crutial to the next step. Next you patch the file again, but using the "patch" command
patch -p1 < "__patchLocationHere__"
This will generate the .orig & .rej files to help narrow down what you need to fix. Once the conflicting parts (what's in the .rej files) are resolved, delete the .rej & .orig files, then stage the files:
Then we can continue the staged git am commit from the first step:
After applying the patch(s) to your local project folder, remember to generate the patch needed to resolve that conflict:
Then copy the patch to the appropriate vendor folder for the conflict. Any patches that are needed to be done to the ROM before applying the generic set of patches will go to the prepatch folder (pc_vendor_prepatches/treble_vendor_prepatches), while any conflicts that happened from the generic patches themselves should go to the vendor_patches folder (pv_vendor_patches/treble_vendor_patches) Example:
cp system/core/0001-init-don-t-bail-out-even-no-SELinux-domain-defined.patch vendor/android-generic/patches/google_diff/x86/pc_vendor_patches/__YourVendorName__/patches/system/core/0015-init-don-t-bail-out-even-no-SELinux-domain-defined.patch