Your phone screen's autorotate function can be really helpful for letting you view photos and videos in landscape mode, but it's annoying when you're lying in bed and the screen flips around when you don't want it to. Thankfully, Android 12 has a neat new feature to help exactly this problem.
It uses face detection to see the position of your face relative to your phone and will keep the orientation locked to whatever angle your face is in even if the phone flips on its side. So if you're reading a web page or a book in bed and roll over, the phone should recognize that you're still looking at it vertically and won't flip the screen around. Here's how to turn it on.
First, head into your settings and scroll down to Display. In there, scroll down and tap on "Auto-rotate screen."
In this submenu you'll see the option to turn autorotate off completely, as well as a new toggle to enable face detection. Make sure both toggles are turned on.
Now your phone should still autorotate when you turn the phone on its side, but if the phone turns because you're lying down, it should recognize this and keep things the right way up for you.