I had the exact same problem the screen would always go back to landscape after sleep. One day while searching for solutions i came across nuelight. This is the line in the description that made me think it would do the trick. "Now checks if keyboard is open, overrides keyboard driver IST". And yes i fixed the problem like a charm even when i boot android.
http://www.nuerom.com/BlogEngine/page/nueKBLight.aspx