系统获取大于等于9.0才有
decorView.rootWindowInsets?.displayCutout.safeInsetTop (kotlin)
华为
判断
val cl: ClassLoader = context!!.classLoader
val HwNotchSizeUtil: Class = cl.loadClass("com.huawei.android.util.HwNotchSizeUtil")
val get = HwNotchSizeUtil.getMethod("hasNotchInScreen")
ret = get.invoke(HwNotchSizeUtil) as Boolean
获取
val cl = context!!.classLoader
val HwNotchSizeUtil = cl.loadClass("com.huawei.android.util.HwNotchSizeUtil")
val get: Method = HwNotchSizeUtil.getMethod("getNotchSize")
ret = get.invoke(HwNotchSizeUtil) as IntArray
小米
判断
com.bilibili.droid.SystemProperties.get("ro.miui.notch", "0") == "1"
获取
val res = context!!.resources
var resourceId = res.getIdentifier("notch_height",