content: package com.faceunity.fulivedemo.utils;
  
  import android.content.Context;
  import android.util.Log;
  
  import java.lang.reflect.Method;
  
  /**
   * Created by tujh on 2018/7/4.
   */
  public final class NotchInScreenUtil {
      private static final String TAG = NotchInScreenUtil.class.getSimpleName();
  
      public static boolean hasNotch(Context context) {
          return hasNotchInHW(context) || hasNotchInOppo(context) || hasNotchInVoio(context);
      }
  
      public static boolean hasNotchInHW(Context context) {
          boolean ret = false;
          try {
              ClassLoader cl = context.getClassLoader();
              Class HwNotchSizeUtil = cl.loadClass("com.huawei.android.util.HwNotchSizeUtil");
              Method get = HwNotchSizeUtil.getMethod("hasNotchInScreen");
              ret = (boolean) get.invoke(HwNotchSizeUtil);
          } catch (ClassNotFoundException e) {
              Log.e(TAG, "hasNotchInScreen ClassNotFoundException");
          } catch (NoSuchMethodException e) {
              Log.e(TAG, "hasNotchInScreen NoSuchMethodException");
          } catch (Exception e) {
              Log.e(TAG, "hasNotchInScreen Exception");
          } finally {
              return ret;
          }
      }
  
      public static boolean hasNotchInOppo(Context context) {
          return context.getPackageManager().hasSystemFeature("com.oppo.feature.screen.heteromorphism");
      }
  
      public static final int NOTCH_IN_SCREEN_VOIO = 0x00000020;//是否有凹槽
      public static final int ROUNDED_IN_SCREEN_VOIO = 0x00000008;//是否有圆角
  
      public static boolean hasNotchInVoio(Context context) {
          boolean ret = false;
          try {
              ClassLoader cl = context.getClassLoader();
              Class FtFeature = cl.loadClass("com.util.FtFeature");
              Method get = FtFeature.getMethod("isFeatureSupport", int.class);
              ret = (boolean) get.invoke(FtFeature, NOTCH_IN_SCREEN_VOIO);
          } catch (ClassNotFoundException e) {
              Log.e(TAG, "hasNotchInScreen ClassNotFoundException");
          } catch (NoSuchMethodException e) {
              Log.e(TAG, "hasNotchInScreen NoSuchMethodException");
          } catch (Exception e) {
              Log.e(TAG, "hasNotchInScreen Exception");
          } finally {
              return ret;
          }
      }
  }
  