fork from https://github.com/BoD/android-switch-backport