AFAIK secure flag has never been 100% working for all devices and builds and I have never encounter any error for this patch before as what you've mentioned. Unfortunately there's nothing I can do on this, maybe you can try raising this issue with fOmey?Valuable members, dear @A30NI_Y.
I created the module "SecureFlag" for my Samsung S8 (Pie) flawlessly.
But the APP supposed to allow screenshot (I mean ADB mirroring) is not working as expected. On other mobile of mine (S5 with LOS 7.1.2) same module works fine.
I had no compiling error, all was ok but module is not working.
Adb method works flawlessly on android 8.1 for Sony AOSP roms on X and XZ premium. The trick is to run the program in recovery (with system mounted obviously), to avoid permission issues.