Port https://github.com/CyanogenMod/android_frameworks_base/commit/44f2f8d10e87fd315abeb267a3159f2e00ce8e73#