code: private static void changeNetworkWPA2EAP(WifiManager wifiManager, WifiParsedResult wifiResult) {
      WifiConfiguration config = changeNetworkCommon(wifiResult);
      // Hex passwords that are 64 bits long are not to be quoted.
      config.preSharedKey = quoteNonHex(wifiResult.getPassword(), 64);
      config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
      config.allowedProtocols.set(WifiConfiguration.Protocol.RSN); // For WPA2
      config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
      config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
      config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
      config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
      config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
      config.enterpriseConfig.setIdentity(wifiResult.getIdentity());
      config.enterpriseConfig.setAnonymousIdentity(wifiResult.getAnonymousIdentity());
      config.enterpriseConfig.setPassword(wifiResult.getPassword());
      config.enterpriseConfig.setEapMethod(parseEap(wifiResult.getEapMethod()));
      config.enterpriseConfig.setPhase2Method(parsePhase2(wifiResult.getPhase2Method()));
      updateNetwork(wifiManager, config);
    }
docs: Adding a WPA2 enterprise (EAP) network