private static long fromLibcore()

in metrics/src/main/java/com/facebook/battery/metrics/cpu/Sysconf.java [56:77]


  private static long fromLibcore(String field, long fallback) {
    try {
      Class osConstantsClass = Class.forName("libcore.io.OsConstants");
      int scClkTck = osConstantsClass.getField(field).getInt(null);
      Class libcoreClass = Class.forName("libcore.io.Libcore");
      Class osClass = Class.forName("libcore.io.Os");
      Object osInstance = libcoreClass.getField("os").get(null);
      return (long) osClass.getMethod("sysconf", int.class).invoke(osInstance, scClkTck);
    } catch (NoSuchMethodException ex) {
      logReflectionException(ex);
    } catch (NoSuchFieldException ex) {
      logReflectionException(ex);
    } catch (IllegalAccessException ex) {
      logReflectionException(ex);
    } catch (InvocationTargetException ex) {
      logReflectionException(ex);
    } catch (ClassNotFoundException ex) {
      logReflectionException(ex);
    }

    return fallback;
  }