Add support for 2.2

copied copyOfRange from aosp