Maybe can be considered sloppy, using androidx.core:core-ktx
's getSystemService extension,
isHighTextContrastEnabled = try {
context.getSystemService()?.run {
(javaClass.getMethod("isHighTextContrastEnabled").invoke(this) as? Boolean)
} ?: false
} catch (e: Exception) {
e.printStackTrace()
false
}