adapted from new bionic from android-l