frameworks/base: Fix race conditions on resume/suspend using power key

Credits to codeaurora