Clone from https://android.googlesource.com/platform/frameworks/native