I had the same issue with my Samsung S8+Tablet.
I tracked the problem down to a magnet issue with the 3rd party folding case.
A very simple fix was to tape in position a small piece of flat roofing iron cut off.
Magnet and sensor are about 2cm down from top of screen (portrai) and 5cm in from...