Add support for 2.2

copied copyOfRange from aosp.
fix for #265