static String get(Context context, String ssid, DetailedState state) {
    String[] formats =
        context
            .getResources()
            .getStringArray((ssid == null) ? R.array.wifi_status : R.array.wifi_status_with_ssid);
    int index = state.ordinal();

    if (index >= formats.length || formats[index].length() == 0) {
      return null;
    }
    return String.format(formats[index], ssid);
  }
  public static String getSummary(
      Context context,
      String ssid,
      DetailedState state,
      boolean isEphemeral,
      String passpointProvider) {
    if (state == DetailedState.CONNECTED && ssid == null) {
      if (TextUtils.isEmpty(passpointProvider) == false) {
        // Special case for connected + passpoint networks.
        String format = context.getString(R.string.connected_via_passpoint);
        return String.format(format, passpointProvider);
      } else if (isEphemeral) {
        // Special case for connected + ephemeral networks.
        return context.getString(R.string.connected_via_wfa);
      }
    }

    // Case when there is wifi connected without internet connectivity.
    final ConnectivityManager cm =
        (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (state == DetailedState.CONNECTED) {
      IWifiManager wifiManager =
          IWifiManager.Stub.asInterface(ServiceManager.getService(Context.WIFI_SERVICE));
      Network nw;

      try {
        nw = wifiManager.getCurrentNetwork();
      } catch (RemoteException e) {
        nw = null;
      }
      NetworkCapabilities nc = cm.getNetworkCapabilities(nw);
      if (nc != null && !nc.hasCapability(nc.NET_CAPABILITY_VALIDATED)) {
        return context.getString(R.string.wifi_connected_no_internet);
      }
    }

    String[] formats =
        context
            .getResources()
            .getStringArray((ssid == null) ? R.array.wifi_status : R.array.wifi_status_with_ssid);
    int index = state.ordinal();

    if (index >= formats.length || formats[index].length() == 0) {
      return "";
    }
    return String.format(formats[index], ssid);
  }