kazuto's changes pulled in from https://github.com/rosjava/android_core/pull/154/commits