Fix compile on android build, which uses strongly typed enums.

With strongly typed enums that are of different size, neither
static_cast nor reinterpret_cast by themselves are enough, so
static_cast to an int and then to the desired type.