@WorkerThread
    public static synchronized boolean isSELinuxEnforcing() {
      if (isSELinuxEnforcing == null) {
        Boolean enforcing = null;

        // First known firmware with SELinux built-in was a 4.2 (17) leak
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
          // Detect enforcing through sysfs, not always present
          File f = new File("/sys/fs/selinux/enforce");
          if (f.exists()) {
            InputStream is = null;
            try {
              is = new FileInputStream("/sys/fs/selinux/enforce");
              enforcing = (is.read() == '1');
            } catch (Exception e) {
              // we might not be allowed to read, thanks SELinux
            } finally {
              if (is != null) {
                try {
                  is.close();
                } catch (IOException ignored) {
                }
              }
            }
          }

          // 4.4+ builds are enforcing by default, take the gamble
          if (enforcing == null) {
            try {
              Class<?> SELinux = Class.forName("android.os.SELinux");
              Method isSELinuxEnforced = SELinux.getMethod("isSELinuxEnforced");
              if (!isSELinuxEnforced.isAccessible()) isSELinuxEnforced.setAccessible(true);
              enforcing = (Boolean) isSELinuxEnforced.invoke(SELinux.newInstance());
            } catch (Exception e) {
              // 4.4+ release builds are enforcing by default, take the gamble
              enforcing = Build.VERSION.SDK_INT >= 19;
            }
          }
        }

        if (enforcing == null) {
          enforcing = false;
        }

        isSELinuxEnforcing = enforcing;
      }
      return isSELinuxEnforcing;
    }
Detect if SELinux is set to enforcing, caches result

@return true if SELinux set to enforcing, or false in the case of permissive or not present
imitate/src/main/java/com/engineer/imitate/shell/Shell.java