Long story short, looking for a way to either disable the behaviour of screen turning on/off in reaction to magnets, or disable the Hall sensor (the sensor responsible for the reaction) altogether. The flip cover I have in hand has a weak magnet and thus doesn't turn on/off the screen reliably, hence I want to simply disable the feature and take things into my own hands.
There are a bunch of Xposed modules that do just the job (example), but Android 7+ probably never will get Xposed from what it looks like right now, so a solution without using Xposed is required.
The device in question is a Samsung Galaxy Tab S2 (Qualcomm, Wi-Fi) with root access.
EDIT 1: after some poking around, it seems that
/dev/input/event6 corresponds to the Hall sensor on this device - every time I open/close the magnetic lid, it shows an event there. Unfortunately, I still haven't found a way to disable a particular input device.
EDIT 2: I have tried a way to prevent the Hall sensor from reporting back its status, thus effectively disabling the sensor, and it works well. The problem is it requires me to modify the ROM's source code, and although I can handle that as a ROM compiler, I'm sure there are much more people who can't. So still, waiting for a more feasible solution.