Essentially, I want to find the value that would be returned by Display#getRotation()
if the device were oriented in straight up in portrait mode, but without assuming that the user is holding their device this way. The reason I want to do this is that I have a camera activity which should always run in portrait mode, and I need to set the orientation of the camera appropriately so that the image appears in the same orientation as reality, but I can't guarantee that the device is in any particular orientation when this activity starts and the camera is initialized, not only because users are unpredictable, but also because they may be entering the camera from a landscape-mode activity, if they are using a tablet.
I saw https://stackoverflow.com/a/9888357/3634598, but I was unsatisfied with this solution because it makes the assumption that the user is holding the device in the same orientation as the window, which is faulty in my case since I am locking the orientation to portrait.
It's frustrating to me that Android would have this concept of a natural orientation for which developers are supposed to compensate, with no context-free way to get at it.