code: protected int loadLibraryFrom(
        String soName, int loadFlags, File libDir, StrictMode.ThreadPolicy threadPolicy)
        throws IOException {
      File soFile = new File(libDir, soName);
      if (!soFile.exists()) {
        Log.d(SoLoader.TAG, soName + " not found on " + libDir.getCanonicalPath());
        return LOAD_RESULT_NOT_FOUND;
      } else {
        Log.d(SoLoader.TAG, soName + " found on " + libDir.getCanonicalPath());
      }
      if ((loadFlags & LOAD_FLAG_ALLOW_IMPLICIT_PROVISION) != 0 &&
          (flags & ON_LD_LIBRARY_PATH) != 0) {
        Log.d(SoLoader.TAG, soName + " loaded implicitly");
        return LOAD_RESULT_IMPLICITLY_PROVIDED;
      }
  
      if ((flags & RESOLVE_DEPENDENCIES) != 0) {
        loadDependencies(soFile, loadFlags, threadPolicy);
      } else {
        Log.d(SoLoader.TAG, "Not resolving dependencies for " + soName);
      }
  
      try {
        SoLoader.sSoFileLoader.load(soFile.getAbsolutePath(), loadFlags);
      } catch (UnsatisfiedLinkError e) {
        if (e.getMessage().contains("bad ELF magic")) {
          Log.d(SoLoader.TAG, "Corrupted lib file detected");
          // Swallow exception. Higher layers will try again from a backup source
          return LOAD_RESULT_CORRUPTED_LIB_FILE;
        } else {
          throw e;
        }
      }
  
      return LOAD_RESULT_LOADED;
    }
docs: Abstracted this logic in another method so subclasses can take advantage of it.