private static void getTetherStatus(Context context, InterfaceDetails d) {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    Method[] wmMethods = wifi.getClass().getDeclaredMethods();

    d.isTethered = false;
    d.tetherStatusKnown = false;

    for (Method method : wmMethods) {
      if (method.getName().equals("isWifiApEnabled")) {
        try {
          d.isTethered = ((Boolean) method.invoke(wifi)).booleanValue();
          d.tetherStatusKnown = true;
          Log.d(TAG, "isWifiApEnabled is " + d.isTethered);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }