Thanks to jwei (http://goo.gl/MbkS4) for the instructions on how to handle the screen on / off events.
Tags: sample code to lock the autorotation lock in, how to tackle auto rotation issue in jelly bean, auto rotate lock code, lock auto rotation 4 code, skin with auto rotation, horizontal autolock in code, note 2 auto rotate off, 42 autorotation screen, note 2 autorotation, app for auto rotation 42.
* Enabled checkbox in settings that disables the "lock mode preservation": Previous implementation suffered from the bug that sometimes the lock state could not be read successfully before the screen turned off. This caused the rotation to be disabled even after the screen was back on. If the checkbox is not checked (which is default), the rotation will ALWAYS be re-enabled when phone is turned back on.