Jak programowo tworzyć i odczytywać konfiguracje WEP / EAP WiFi w systemie Android?


111

Jak programowo tworzyć i czytać WEP/EAP WiFi configurationsw systemie Android?

Widziałem wiele osób zmagających się z tym pytaniem na różnych forach i w całej społeczności. Wiem, że nie jest to takie proste (zwłaszcza EAP), aby się zorientować, ponieważ kiedy chciałem osiągnąć to samo, też miałem sporo problemów. Cóż, cała ciężka praca analizy kodu i wyszukiwania różnych implementacji w internecie wreszcie w stanie osiągnąć cel. Wszystko to zasługa wielu projektów open source i ich twórców.

Chciałbym podzielić się tą wiedzą ze wszystkimi, ponieważ SO zachęca do tego: „Dobrze jest też zadawać własne pytanie i odpowiadać na nie, o ile udajesz, że jesteś na Jeopardy: sformułuj je w formie pytania”.

Część 1: Programowe tworzenie konfiguracji WEP WiFi.

Część 2: Odczytaj programowo konfigurację WEP WiFi.

Część 3: Odczytaj programowo konfigurację EAP WiFi.

Część 4: programowe zapisywanie konfiguracji EAP WiFi.


Proponuję sformatować to jako pytanie, a następnie odpowiedzieć samodzielnie. Sformatuj go ładnie, a będziemy mieć dobre pytanie i odpowiedź.
Octavian A. Damiean

@Octavian Damiean: Dzięki za ostrzeżenie. Starałem się zapewnić dobre formatowanie. Wszelkie komentarze są mile widziane!
Alok Zapisz

Wygląda świetnie! Dzięki za udostępnienie! Odwiedź nas w pokoju rozmów SO Android .
Octavian A. Damiean

Android dodaje WifiEnterpriseConfig do obsługi EAP WiFi w API 18
ospider

To jest bardzo przydatne. Naprawdę chcesz wiedzieć, gdzie jest dokument na ten temat?
Dokumentacja

Odpowiedzi:


107

Część 1: Programowe tworzenie konfiguracji WEP WiFi

Jest to dość proste, WifiConfiguration ujawnia interfejs, aby stworzyć to samo. Oto przykładowy kod:

void saveWepConfig()
{
    WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    WifiConfiguration wc = new WifiConfiguration(); 
    wc.SSID = "\"SSID_NAME\""; //IMP! This should be in Quotes!!
    wc.hiddenSSID = true;
    wc.status = WifiConfiguration.Status.DISABLED;     
    wc.priority = 40;
    wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
    wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN); 
    wc.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
    wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
    wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
    wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
    wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
    wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
    wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);

    wc.wepKeys[0] = "\"aaabbb1234\""; //This is the WEP Password
    wc.wepTxKeyIndex = 0;

    WifiManager  wifiManag = (WifiManager) this.getSystemService(WIFI_SERVICE);
    boolean res1 = wifiManag.setWifiEnabled(true);
    int res = wifi.addNetwork(wc);
    Log.d("WifiPreference", "add Network returned " + res );
    boolean es = wifi.saveConfiguration();
    Log.d("WifiPreference", "saveConfiguration returned " + es );
    boolean b = wifi.enableNetwork(res, true);   
    Log.d("WifiPreference", "enableNetwork returned " + b );  

}

Zgodnie z uprawnieniami wymaganymi w AndroidManifest.xml

    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE">
    </uses-permission>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">
    </uses-permission>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE">
    </uses-permission>

Część 2:
Ponownie przeczytaj programowo konfigurację WEP WiFi Straighforward. Oto przykładowy kod:

    void readWepConfig()
    { 
        WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); 
        List<WifiConfiguration> item = wifi.getConfiguredNetworks();
        int i = item.size();
        Log.d("WifiPreference", "NO OF CONFIG " + i );
        Iterator<WifiConfiguration> iter =  item.iterator();
        WifiConfiguration config = item.get(0);
        Log.d("WifiPreference", "SSID" + config.SSID);
        Log.d("WifiPreference", "PASSWORD" + config.preSharedKey);
        Log.d("WifiPreference", "ALLOWED ALGORITHMS");
        Log.d("WifiPreference", "LEAP" + config.allowedAuthAlgorithms.get(AuthAlgorithm.LEAP));
        Log.d("WifiPreference", "OPEN" + config.allowedAuthAlgorithms.get(AuthAlgorithm.OPEN));
        Log.d("WifiPreference", "SHARED" + config.allowedAuthAlgorithms.get(AuthAlgorithm.SHARED));
        Log.d("WifiPreference", "GROUP CIPHERS");
        Log.d("WifiPreference", "CCMP" + config.allowedGroupCiphers.get(GroupCipher.CCMP));
        Log.d("WifiPreference", "TKIP" + config.allowedGroupCiphers.get(GroupCipher.TKIP));
        Log.d("WifiPreference", "WEP104" + config.allowedGroupCiphers.get(GroupCipher.WEP104));
        Log.d("WifiPreference", "WEP40" + config.allowedGroupCiphers.get(GroupCipher.WEP40));
        Log.d("WifiPreference", "KEYMGMT");
        Log.d("WifiPreference", "IEEE8021X" + config.allowedKeyManagement.get(KeyMgmt.IEEE8021X));
        Log.d("WifiPreference", "NONE" + config.allowedKeyManagement.get(KeyMgmt.NONE));
        Log.d("WifiPreference", "WPA_EAP" + config.allowedKeyManagement.get(KeyMgmt.WPA_EAP));
        Log.d("WifiPreference", "WPA_PSK" + config.allowedKeyManagement.get(KeyMgmt.WPA_PSK));
        Log.d("WifiPreference", "PairWiseCipher");
        Log.d("WifiPreference", "CCMP" + config.allowedPairwiseCiphers.get(PairwiseCipher.CCMP));
        Log.d("WifiPreference", "NONE" + config.allowedPairwiseCiphers.get(PairwiseCipher.NONE));
        Log.d("WifiPreference", "TKIP" + config.allowedPairwiseCiphers.get(PairwiseCipher.TKIP));
        Log.d("WifiPreference", "Protocols");
        Log.d("WifiPreference", "RSN" + config.allowedProtocols.get(Protocol.RSN));
        Log.d("WifiPreference", "WPA" + config.allowedProtocols.get(Protocol.WPA));
        Log.d("WifiPreference", "WEP Key Strings");
        String[] wepKeys = config.wepKeys;
        Log.d("WifiPreference", "WEP KEY 0" + wepKeys[0]);
        Log.d("WifiPreference", "WEP KEY 1" + wepKeys[1]);
        Log.d("WifiPreference", "WEP KEY 2" + wepKeys[2]);
        Log.d("WifiPreference", "WEP KEY 3" + wepKeys[3]);
    }

Część 3: Odczytaj programowo konfigurację EAP WiFi
Teraz jest to trudne. Kod, który zapisuje konfigurację EAP WiFi, można znaleźć za pośrednictwem podstawowego interfejsu użytkownika systemu Android w WifiDialog.java . Dość łatwo Możemy użyć tego samego kodu w naszej aplikacji, no cóż, NIE! Jeśli zdarzy się, spróbuj to dostaniesz błędy mówiąc nie można znaleźć symboleeap,phase,client_certi tak dalej. Trochę szczegółowych badań mówi nam, że EnterpriseField jestis private wewnątrzWiFiConfigurationklasy i że wszystkie symbole, których nie możemy znaleźć, są tego typuEnterpriseField. Cóż, natrafiliśmy na przeszkodę. Potrzebujemy tych pól do odczytu / zapisania konfiguracji EAP, ale nie mamy do nich programistycznego dostępu!

Java Reflection APIna ratunek Cóż, nie jestem ekspertem od Javy, więc nie będę zagłębiać się w szczegóły dotyczące Reflection API jako takiego. Możesz znaleźć w Google samouczki lub uzyskać więcej informacji tutaj . Aby było krótkie i przyjemne, interfejs API Reflection pozwala na inspekcję klas, interfejsów, pól i metod w czasie wykonywania, bez znajomości nazw klas, metod itp. W czasie kompilacji. Możliwe jest również tworzenie instancji nowych obiektów, wywoływanie metod i pobieranie / ustawianie wartości pól za pomocą refleksji. Co ważniejsze, refleksja może pomóc w uzyskaniu dostępu do prywatnych elementów danych wewnątrz klasy. Cóż, tego potrzebujemy, prawda? :)

Sprawdźmy teraz przykładowy kod, który pokazuje, jak odczytać konfigurację EAP WiFi za pomocą Reflection Api. Jako bonus, snippet zarejestruje konfigurację do pliku i zapisze go na karcie SD .... całkiem sprytnie .. eh;) Trochę przeglądu Reflection Api i jestem pewien, że zrozumienie poniższego kodu jest łatwe.

    private static final String INT_PRIVATE_KEY = "private_key";
    private static final String INT_PHASE2 = "phase2";
    private static final String INT_PASSWORD = "password";
    private static final String INT_IDENTITY = "identity";
    private static final String INT_EAP = "eap";
    private static final String INT_CLIENT_CERT = "client_cert";
    private static final String INT_CA_CERT = "ca_cert";
    private static final String INT_ANONYMOUS_IDENTITY = "anonymous_identity";
    final String INT_ENTERPRISEFIELD_NAME = "android.net.wifi.WifiConfiguration$EnterpriseField";

To jest kod do utworzenia pliku logowania na karcie SD przed wywołaniem readEapConfig()funkcji.

        BufferedWriter out = null;
        try 
        {
            File root = Environment.getExternalStorageDirectory();
            Toast toast = Toast.makeText(this, "SD CARD mounted and writable? " + root.canWrite(), 5000);
            toast.show();
            if (root.canWrite())
            {
                File gpxfile = new File(root, "ReadConfigLog.txt");
                FileWriter gpxwriter = new FileWriter(gpxfile);
                out = new BufferedWriter(gpxwriter);
                out.write("Hello world");
                //out.close();
            }
        } catch (IOException e) 
        {
            Toast toast = Toast.makeText(this, "Problem reading SD CARD", 3000);
            Toast toast2 = Toast.makeText(this, "Please take logs using Logcat", 5000);
            Log.e("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "Could not write file " + e.getMessage());
        }

Teraz readEapConfig()sama funkcja:

    void readEapConfig(BufferedWriter out)
    {
        /*Get the WifiService */        
        WifiManager wifi = (WifiManager)getSystemService(WIFI_SERVICE);
        /*Get All WIfi configurations*/
        List<WifiConfiguration> configList = wifi.getConfiguredNetworks();
        /*Now we need to search appropriate configuration i.e. with name SSID_Name*/
        for(int i = 0;i<configList.size();i++)
        {
            if(configList.get(i).SSID.contentEquals("\"SSID_NAME\""))
            {
                /*We found the appropriate config now read all config details*/
                Iterator<WifiConfiguration> iter =  configList.iterator();
                WifiConfiguration config = configList.get(i);

                /*I dont think these fields have anything to do with EAP config but still will
                 * print these to be on safe side*/
                try {
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[SSID]" + config.SSID);
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[SSID]" + config.SSID);
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[BSSID]" + config.BSSID);
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" +"[BSSID]" + config.BSSID);
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[HIDDEN SSID]" + config.hiddenSSID);
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[HIDDEN SSID]" + config.hiddenSSID);
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[PASSWORD]" + config.preSharedKey);
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>"+ "[PASSWORD]" + config.preSharedKey);
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[ALLOWED ALGORITHMS]");
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>"+ "[ALLOWED ALGORITHMS]");
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[LEAP]" + config.allowedAuthAlgorithms.get(AuthAlgorithm.LEAP));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[LEAP]" + config.allowedAuthAlgorithms.get(AuthAlgorithm.LEAP));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[OPEN]" + config.allowedAuthAlgorithms.get(AuthAlgorithm.OPEN));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[OPEN]" + config.allowedAuthAlgorithms.get(AuthAlgorithm.OPEN));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[SHARED]" + config.allowedAuthAlgorithms.get(AuthAlgorithm.SHARED));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[SHARED]" + config.allowedAuthAlgorithms.get(AuthAlgorithm.SHARED));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[GROUP CIPHERS]");
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[GROUP CIPHERS]");
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[CCMP]" + config.allowedGroupCiphers.get(GroupCipher.CCMP));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[CCMP]" + config.allowedGroupCiphers.get(GroupCipher.CCMP));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" , "[TKIP]" + config.allowedGroupCiphers.get(GroupCipher.TKIP));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>"+ "[TKIP]" + config.allowedGroupCiphers.get(GroupCipher.TKIP));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[WEP104]" + config.allowedGroupCiphers.get(GroupCipher.WEP104));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[WEP104]" + config.allowedGroupCiphers.get(GroupCipher.WEP104));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[WEP40]" + config.allowedGroupCiphers.get(GroupCipher.WEP40));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[WEP40]" + config.allowedGroupCiphers.get(GroupCipher.WEP40));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[KEYMGMT]");
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[KEYMGMT]");
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[IEEE8021X]" + config.allowedKeyManagement.get(KeyMgmt.IEEE8021X));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>"+ "[IEEE8021X]" + config.allowedKeyManagement.get(KeyMgmt.IEEE8021X));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[NONE]" + config.allowedKeyManagement.get(KeyMgmt.NONE));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[NONE]" + config.allowedKeyManagement.get(KeyMgmt.NONE));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[WPA_EAP]" + config.allowedKeyManagement.get(KeyMgmt.WPA_EAP));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[WPA_EAP]" + config.allowedKeyManagement.get(KeyMgmt.WPA_EAP));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[WPA_PSK]" + config.allowedKeyManagement.get(KeyMgmt.WPA_PSK));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[WPA_PSK]" + config.allowedKeyManagement.get(KeyMgmt.WPA_PSK));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[PairWiseCipher]");
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[PairWiseCipher]");
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[CCMP]" + config.allowedPairwiseCiphers.get(PairwiseCipher.CCMP));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[CCMP]" + config.allowedPairwiseCiphers.get(PairwiseCipher.CCMP));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[NONE]" + config.allowedPairwiseCiphers.get(PairwiseCipher.NONE));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[NONE]" + config.allowedPairwiseCiphers.get(PairwiseCipher.NONE));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[TKIP]" + config.allowedPairwiseCiphers.get(PairwiseCipher.TKIP));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[TKIP]" + config.allowedPairwiseCiphers.get(PairwiseCipher.TKIP));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[Protocols]");
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[Protocols]");
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[RSN]" + config.allowedProtocols.get(Protocol.RSN));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[RSN]" + config.allowedProtocols.get(Protocol.RSN));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[WPA]" + config.allowedProtocols.get(Protocol.WPA));
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[WPA]" + config.allowedProtocols.get(Protocol.WPA));
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[PRE_SHARED_KEY]" + config.preSharedKey);
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[PRE_SHARED_KEY]" + config.preSharedKey);
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[WEP Key Strings]");
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[WEP Key Strings]");
                String[] wepKeys = config.wepKeys;
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[WEP KEY 0]" + wepKeys[0]);
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[WEP KEY 0]" + wepKeys[0]);
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[WEP KEY 1]" + wepKeys[1]);
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[WEP KEY 1]" + wepKeys[1]);
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[WEP KEY 2]" + wepKeys[2]);
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[WEP KEY 2]" + wepKeys[2]);
                Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[WEP KEY 3]" + wepKeys[3]);
                out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[WEP KEY 3]" + wepKeys[3]);

                }
                catch(IOException e) 
                {
                    Toast toast1 = Toast.makeText(this, "Failed to write Logs to ReadConfigLog.txt", 3000);
                    Toast toast2 = Toast.makeText(this, "Please take logs using Logcat", 5000);
                    Log.e("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "Could not write to ReadConfigLog.txt" + e.getMessage());
                }
                /*reflection magic*/
                /*These are the fields we are really interested in*/
                try 
                {
                    // Let the magic start
                    Class[] wcClasses = WifiConfiguration.class.getClasses();
                    // null for overzealous java compiler
                    Class wcEnterpriseField = null;

                    for (Class wcClass : wcClasses)
                        if (wcClass.getName().equals(INT_ENTERPRISEFIELD_NAME)) 
                        {
                            wcEnterpriseField = wcClass;
                            break;
                        }
                    boolean noEnterpriseFieldType = false; 
                    if(wcEnterpriseField == null)
                        noEnterpriseFieldType = true; // Cupcake/Donut access enterprise settings directly

                    Field wcefAnonymousId = null, wcefCaCert = null, wcefClientCert = null, wcefEap = null, wcefIdentity = null, wcefPassword = null, wcefPhase2 = null, wcefPrivateKey = null;
                    Field[] wcefFields = WifiConfiguration.class.getFields();
                    // Dispatching Field vars
                    for (Field wcefField : wcefFields) 
                    {
                        if (wcefField.getName().trim().equals(INT_ANONYMOUS_IDENTITY))
                            wcefAnonymousId = wcefField;
                        else if (wcefField.getName().trim().equals(INT_CA_CERT))
                            wcefCaCert = wcefField;
                        else if (wcefField.getName().trim().equals(INT_CLIENT_CERT))
                            wcefClientCert = wcefField;
                        else if (wcefField.getName().trim().equals(INT_EAP))
                            wcefEap = wcefField;
                        else if (wcefField.getName().trim().equals(INT_IDENTITY))
                            wcefIdentity = wcefField;
                        else if (wcefField.getName().trim().equals(INT_PASSWORD))
                            wcefPassword = wcefField;
                        else if (wcefField.getName().trim().equals(INT_PHASE2))
                            wcefPhase2 = wcefField;
                        else if (wcefField.getName().trim().equals(INT_PRIVATE_KEY))
                            wcefPrivateKey = wcefField;
                    }
                Method wcefValue = null;
                if(!noEnterpriseFieldType)
                {
                for(Method m: wcEnterpriseField.getMethods())
                //System.out.println(m.getName());
                if(m.getName().trim().equals("value")){
                    wcefValue = m;
                    break;
                }
                }

                /*EAP Method*/
                String result = null;
                Object obj = null;
                if(!noEnterpriseFieldType)
                {
                    obj = wcefValue.invoke(wcefEap.get(config), null);
                    String retval = (String)obj;
                    Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[EAP METHOD]" + retval);
                    out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[EAP METHOD]" + retval);
                }
                else
                {
                    obj = wcefEap.get(config);
                    String retval = (String)obj;                        
                }

                /*phase 2*/
                if(!noEnterpriseFieldType)
                {
                    result = (String) wcefValue.invoke(wcefPhase2.get(config), null);
                    Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[EAP PHASE 2 AUTHENTICATION]" + result);
                    out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[EAP PHASE 2 AUTHENTICATION]" + result);
                }
                else
                {
                    result = (String) wcefPhase2.get(config);
                }

                /*Anonymous Identity*/
                if(!noEnterpriseFieldType)
                {
                    result = (String) wcefValue.invoke(wcefAnonymousId.get(config),null);
                    Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[EAP ANONYMOUS IDENTITY]" + result);
                    out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[EAP ANONYMOUS IDENTITY]" + result);
                }
                else
                {
                    result = (String) wcefAnonymousId.get(config);
                }

                /*CA certificate*/
                if(!noEnterpriseFieldType)
                {
                    result = (String) wcefValue.invoke(wcefCaCert.get(config), null);
                    Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[EAP CA CERTIFICATE]" + result);
                    out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[EAP CA CERTIFICATE]" + result);
                }
                else
                {
                    result = (String)wcefCaCert.get(config);

                }

                /*private key*/
                if(!noEnterpriseFieldType)
                {
                    result = (String) wcefValue.invoke(wcefPrivateKey.get(config),null);
                    Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[EAP PRIVATE KEY]" + result);
                    out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[EAP PRIVATE KEY]" + result);
                }
                else
                {
                    result = (String)wcefPrivateKey.get(config);
                }

                /*Identity*/
                if(!noEnterpriseFieldType)
                {
                    result = (String) wcefValue.invoke(wcefIdentity.get(config), null);
                    Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[EAP IDENTITY]" + result);
                    out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[EAP IDENTITY]" + result);
                }
                else
                {
                    result = (String)wcefIdentity.get(config);
                }

                /*Password*/
                if(!noEnterpriseFieldType)
                {
                    result = (String) wcefValue.invoke(wcefPassword.get(config), null);
                    Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[EAP PASSWORD]" + result);
                    out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[EAP PASSWORD]" + result);
                }
                else
                {
                    result = (String)wcefPassword.get(config);
                }

                /*client certificate*/
                if(!noEnterpriseFieldType)
                {
                    result = (String) wcefValue.invoke(wcefClientCert.get(config), null);
                    Log.d("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "[EAP CLIENT CERT]" + result);
                    out.write("<<<<<<<<<<WifiPreference>>>>>>>>>>>>" + "[EAP CLIENT CERT]" + result);
                    Toast toast1 = Toast.makeText(this, "All config data logged to ReadConfigLog.txt", 3000);
                    Toast toast2 = Toast.makeText(this, "Extract ReadConfigLog.txt from SD CARD", 5000);
                }
                else
                {
                    result = (String)wcefClientCert.get(config);
                }

                out.close();

                }
                catch(IOException e) 
                {
                    Toast toast1 = Toast.makeText(this, "Failed to write Logs to ReadConfigLog.txt", 3000);
                    Toast toast2 = Toast.makeText(this, "Please take logs using Logcat", 5000);
                    Log.e("<<<<<<<<<<WifiPreference>>>>>>>>>>>>", "Could not write to ReadConfigLog.txt" + e.getMessage());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }

            }
        }
    }

Próbowałem to zrobić, ale z jakiegoś powodu tworzy nowy interfejs w sieciach bezprzewodowych (z komentarzem Nieosiągalny), ale identyfikator SSID jest dokładnie taki sam jak w oryginalnej sieci. Jakaś pomoc w tym zakresie?
nithinreddy

@nithinreddy: Obawiam się, że nie bawię się już Androidem (nie robiłem tego od dłuższego czasu), więc wątpię, czy mogę pomóc.AFAIR, nie powinieneś mieć dwóch konfiguracji o tej samej nazwie SSID. nieosiągalny problem, sprawdź parametry konfiguracyjne. Domyślam się, że gdzieś tam może być niezgodność .. Wykonaj konfigurację ręcznie, sprawdź, czy się łączy, a następnie przeczytaj programowo parametry konfiguracji (zobacz szczegóły w poradnikach w odpowiedziach powyżej), a następnie użyj tych parametrów, aby utworzyć konfigurację programowo. Prawdopodobnie konfiguracja, która connects nie jest tym, który dodałeś programowo
Alok Save

1
@AlokSave Byłoby świetnie, gdybyś podał kroki dotyczące certyfikatów. (dla EAP WIFI). Mam kilka pytań, jak mogę utworzyć te certyfikaty i zainstalować je programowo. Właściwie googluję przez ostatnie dwa dni, ale nie znalazłem sposobu na programową instalację certyfikatu. Więc proszę, podziel się swoją wiedzą.
Android Learner

1
Chcę potwierdzić, że coś jest nie tak z WEP w systemie Android (tutaj 4.1), gdy robię to programowo. Jeśli jednak zrobię to ręcznie w ustawieniach systemu, to działa. Próbowałem wszystkiego przez kilka dni, potem zmieniłem na WPA i zadziałało w obu przypadkach (ręcznie i programowo). Tak więc w przypadku WEP: przeczytałem strukturę WEP, gdy została utworzona ręcznie (co działa), aby odtworzyć ją dokładnie programowo, ale nie ma mowy, po prostu pozostanie na zawsze w stanie „OBTAINING_IPADDR”. Znalazłem inną osobę z tym samym problemem, więc ostrzegam. Informacje są tutaj świetne, ale czegoś brakuje (przynajmniej w niektórych przypadkach).
Alex

1
Dlaczego używasz AuthAlgorithm.OPEN dla WEP ?, w dokumentacji systemu Android jest napisane „Uwierzytelnianie systemu otwartego (wymagane w przypadku WPA / WPA2)”
David

36

Ahh Skończyło mi się miejsce na edycję, dodając pozostałą część tutaj.

Część 4: programowe zapisywanie konfiguracji EAP WiFi

Jeśli przeczytałeś już część 3, rozumiesz już magię Refleksji, która działa tutaj.Jeśli przechodzisz bezpośrednio do tej sekcji, przeczytaj wprowadzenie przed fragmentem kodu w części 3, a będziesz mógł szybko przejrzeć kod tutaj !

void saveEapConfig(String passString, String userName)
    {
    /********************************Configuration Strings****************************************************/
    final String ENTERPRISE_EAP = "TLS";
    final String ENTERPRISE_CLIENT_CERT = "keystore://USRCERT_CertificateName";
    final String ENTERPRISE_PRIV_KEY = "USRPKEY_CertificateName";
    //CertificateName = Name given to the certificate while installing it

    /*Optional Params- My wireless Doesn't use these*/
    final String ENTERPRISE_PHASE2 = "";
    final String ENTERPRISE_ANON_IDENT = "ABC";
    final String ENTERPRISE_CA_CERT = ""; // If required: "keystore://CACERT_CaCertificateName"
    /********************************Configuration Strings****************************************************/

    /*Create a WifiConfig*/
    WifiConfiguration selectedConfig = new WifiConfiguration();

    /*AP Name*/
    selectedConfig.SSID = "\"SSID_Name\"";

    /*Priority*/
    selectedConfig.priority = 40;

    /*Enable Hidden SSID*/
    selectedConfig.hiddenSSID = true;

    /*Key Mgmnt*/
    selectedConfig.allowedKeyManagement.clear();
    selectedConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
    selectedConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);

    /*Group Ciphers*/
    selectedConfig.allowedGroupCiphers.clear();
    selectedConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
    selectedConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
    selectedConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
    selectedConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);

    /*Pairwise ciphers*/
    selectedConfig.allowedPairwiseCiphers.clear();
    selectedConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
    selectedConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);

    /*Protocols*/
    selectedConfig.allowedProtocols.clear();
    selectedConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
    selectedConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA);

    // Enterprise Settings
    // Reflection magic here too, need access to non-public APIs
    try {
        // Let the magic start
        Class[] wcClasses = WifiConfiguration.class.getClasses();
        // null for overzealous java compiler
        Class wcEnterpriseField = null;

        for (Class wcClass : wcClasses)
            if (wcClass.getName().equals(INT_ENTERPRISEFIELD_NAME)) 
            {
                wcEnterpriseField = wcClass;
                break;
            }
        boolean noEnterpriseFieldType = false; 
        if(wcEnterpriseField == null)
            noEnterpriseFieldType = true; // Cupcake/Donut access enterprise settings directly

        Field wcefAnonymousId = null, wcefCaCert = null, wcefClientCert = null, wcefEap = null, wcefIdentity = null, wcefPassword = null, wcefPhase2 = null, wcefPrivateKey = null, wcefEngine = null, wcefEngineId = null;
        Field[] wcefFields = WifiConfiguration.class.getFields();
        // Dispatching Field vars
        for (Field wcefField : wcefFields) 
        {
            if (wcefField.getName().equals(INT_ANONYMOUS_IDENTITY))
                wcefAnonymousId = wcefField;
            else if (wcefField.getName().equals(INT_CA_CERT))
                wcefCaCert = wcefField;
            else if (wcefField.getName().equals(INT_CLIENT_CERT))
                wcefClientCert = wcefField;
            else if (wcefField.getName().equals(INT_EAP))
                wcefEap = wcefField;
            else if (wcefField.getName().equals(INT_IDENTITY))
                wcefIdentity = wcefField;
            else if (wcefField.getName().equals(INT_PASSWORD))
                wcefPassword = wcefField;
            else if (wcefField.getName().equals(INT_PHASE2))
                wcefPhase2 = wcefField;
            else if (wcefField.getName().equals(INT_PRIVATE_KEY))
                wcefPrivateKey = wcefField;
            else if (wcefField.getName().equals("engine"))
                wcefEngine = wcefField;
            else if (wcefField.getName().equals("engine_id"))
                wcefEngineId = wcefField;
        }


        Method wcefSetValue = null;
        if(!noEnterpriseFieldType){
        for(Method m: wcEnterpriseField.getMethods())
            //System.out.println(m.getName());
            if(m.getName().trim().equals("setValue"))
                wcefSetValue = m;
        }


        /*EAP Method*/
        if(!noEnterpriseFieldType)
        {
                wcefSetValue.invoke(wcefEap.get(selectedConfig), ENTERPRISE_EAP);
        }
        else
        {
                wcefEap.set(selectedConfig, ENTERPRISE_EAP);
        }
        /*EAP Phase 2 Authentication*/
        if(!noEnterpriseFieldType)
        {
                wcefSetValue.invoke(wcefPhase2.get(selectedConfig), ENTERPRISE_PHASE2);
        }
        else
        {
              wcefPhase2.set(selectedConfig, ENTERPRISE_PHASE2);
        }
        /*EAP Anonymous Identity*/
        if(!noEnterpriseFieldType)
        {
                wcefSetValue.invoke(wcefAnonymousId.get(selectedConfig), ENTERPRISE_ANON_IDENT);
        }
        else
        {
              wcefAnonymousId.set(selectedConfig, ENTERPRISE_ANON_IDENT);
        }
        /*EAP CA Certificate*/
        if(!noEnterpriseFieldType)
        {
                wcefSetValue.invoke(wcefCaCert.get(selectedConfig), ENTERPRISE_CA_CERT);
        }
        else
        {
              wcefCaCert.set(selectedConfig, ENTERPRISE_CA_CERT);
        }               
        /*EAP Private key*/
        if(!noEnterpriseFieldType)
        {
                wcefSetValue.invoke(wcefPrivateKey.get(selectedConfig), ENTERPRISE_PRIV_KEY);
        }
        else
        {
              wcefPrivateKey.set(selectedConfig, ENTERPRISE_PRIV_KEY);
        }               
        /*EAP Identity*/
        if(!noEnterpriseFieldType)
        {
                wcefSetValue.invoke(wcefIdentity.get(selectedConfig), userName);
        }
        else
        {
              wcefIdentity.set(selectedConfig, userName);
        }               
        /*EAP Password*/
        if(!noEnterpriseFieldType)
        {
                wcefSetValue.invoke(wcefPassword.get(selectedConfig), passString);
        }
        else
        {
              wcefPassword.set(selectedConfig, passString);
        }               
        /*EAp Client certificate*/
        if(!noEnterpriseFieldType)
        {
            wcefSetValue.invoke(wcefClientCert.get(selectedConfig), ENTERPRISE_CLIENT_CERT);
        }
        else
        {
              wcefClientCert.set(selectedConfig, ENTERPRISE_CLIENT_CERT);
        }
        /*Engine fields*/
        if(!noEnterpriseFieldType)
        {
           wcefSetValue.invoke(wcefEngine.get(wifiConf), "1");
           wcefSetValue.invoke(wcefEngineId.get(wifiConf), "keystore");
        }

        // Adhoc for CM6
        // if non-CM6 fails gracefully thanks to nested try-catch

        try{
        Field wcAdhoc = WifiConfiguration.class.getField("adhocSSID");
        Field wcAdhocFreq = WifiConfiguration.class.getField("frequency");
        //wcAdhoc.setBoolean(selectedConfig, prefs.getBoolean(PREF_ADHOC,
        //      false));
        wcAdhoc.setBoolean(selectedConfig, false);
        int freq = 2462;    // default to channel 11
        //int freq = Integer.parseInt(prefs.getString(PREF_ADHOC_FREQUENCY,
        //"2462"));     // default to channel 11
        //System.err.println(freq);
        wcAdhocFreq.setInt(selectedConfig, freq); 
        } catch (Exception e)
        {
            e.printStackTrace();
        }

    } catch (Exception e)
    {
        // TODO Auto-generated catch block
        // FIXME As above, what should I do here?
        e.printStackTrace();
    }

    WifiManager wifiManag = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    boolean res1 = wifiManag.setWifiEnabled(true);
    int res = wifiManag.addNetwork(selectedConfig);
    Log.d("WifiPreference", "add Network returned " + res );
    boolean b = wifiManag.enableNetwork(selectedConfig.networkId, false);
    Log.d("WifiPreference", "enableNetwork returned " + b );
    boolean c = wifiManag.saveConfiguration();
    Log.d("WifiPreference", "Save configuration returned " + c );
    boolean d = wifiManag.enableNetwork(res, true);   
    Log.d("WifiPreference", "enableNetwork returned " + d );  
}

Cóż, to wszystko! I mam nadzieję, że to kiedyś pomoże zagubionemu programiście :)


7
@abresas: Jak wspomniałem w odpowiedzi, to źródło zostało opracowane przeze mnie, pobierając informacje z różnych źródeł w Internecie i dawno temu, w tym czasie wydano nowe SDK i nie było o nich zbyt wiele informacji. obecna sytuacja z Androidem, ponieważ obecnie nie pracuję z Androidem, również nie mam praw autorskich do tego kodu i nie mam żadnych problemów, aby ktokolwiek z niego korzystał, co jest powodem umieszczenia go tutaj w pierwszej kolejności, ale nie wiem o przemyśleniach / perspektywach źródeł, które pomogły mi w napisaniu tego źródła.
Alok Zapisz

1
Field wcAdhoc = WifiConfiguration.class.getField("adhocSSID"); Field wcAdhocFreq = WifiConfiguration.class.getField("frequency");. Tych członków nie ma w WifiConfiguration.java. Kod daje mi wyjątek java.lang.NoSuchFieldException: adhocSSID . Proszę pomóż.
Android Learner

1
Używam Androida 4.1.2, więc może ten kod nie działa już z ostatnimi wersjami.
Tiago Babo

1
Zauważyłem, że nie działa dla 4.1 lub 4.2. Linia wcefPrivateKey.get(selectedConfig)rzuca NullPointerException. Jakieś szczęście od kogoś innego?
Dulax,

1
Masz rację @PrashanthDebbadwar, to już nie działa dla API 18+. Ten kod działa tylko we wcześniejszych wersjach.
BurninatorDor

5

Android dodał API do JellyBean 4.3. Musisz użyć tej opcji, jeśli chcesz skonfigurować WIFI na API 18:

http://developer.android.com/reference/android/net/wifi/WifiEnterpriseConfig.html


2
to coś więcej niż „inna opcja”. android.net.wifi.WifiConfiguration $ EnterpriseField już nie istnieje (prawdopodobnie od API 18, gdzie dodali WifiEnterpriseConfig), więc rozwiązanie Alok nie działa. oba rozwiązania są teraz wymagane dla aplikacji, które chcą działać w API 18+ i API 17-.
rmanna

1

Część 4 wprowadziła mnie na właściwą ścieżkę! Jednak chciałem utworzyć konfigurację TTLS zamiast TLS, oto jak to zrobiłem!

    /********************************Configuration Strings****************************************************/
    final String ENTERPRISE_EAP = "TTLS";

    /*Optional Params- My wireless Doesn't use these*/
    final String ENTERPRISE_PHASE2 = "PAP";
    final String ENTERPRISE_ANON_IDENT = "ABC";
    final String ENTERPRISE_CA_CERT = "";
    /********************************Configuration Strings****************************************************/

    /*Create a WifiConfig*/
    WifiConfiguration selectedConfig = new WifiConfiguration();

    /*AP Name*/
    selectedConfig.SSID = "\"EAP_SSID_TEST_CONFIG\"";

    /*Priority*/
    selectedConfig.priority = 40;

    /*Enable Hidden SSID*/
    selectedConfig.hiddenSSID = false;

    /*Key Mgmnt*/
    selectedConfig.allowedKeyManagement.clear();
    selectedConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
    selectedConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);

    /*Group Ciphers*/
    selectedConfig.allowedGroupCiphers.clear();
    selectedConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
    selectedConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
    selectedConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
    selectedConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);

    /*Pairwise ciphers*/
    selectedConfig.allowedPairwiseCiphers.clear();
    selectedConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
    selectedConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);

    /*Protocols*/
    selectedConfig.allowedProtocols.clear();
    selectedConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
    selectedConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA);

    // Enterprise Settings
    // Reflection magic here too, need access to non-public APIs
    try {
        // Let the magic start
        Class[] wcClasses = WifiConfiguration.class.getClasses();
        // null for overzealous java compiler
        Class wcEnterpriseField = null;

        for (Class wcClass : wcClasses)
            if (wcClass.getName().equals(INT_ENTERPRISEFIELD_NAME)) 
            {
                wcEnterpriseField = wcClass;
                break;
            }
        boolean noEnterpriseFieldType = false; 
        if(wcEnterpriseField == null)
            noEnterpriseFieldType = true; // Cupcake/Donut access enterprise settings directly

        Field wcefAnonymousId = null, wcefCaCert = null, wcefClientCert = null, wcefEap = null, wcefIdentity = null, wcefPassword = null, wcefPhase2 = null, wcefPrivateKey = null;
        Field[] wcefFields = WifiConfiguration.class.getFields();
        // Dispatching Field vars
        for (Field wcefField : wcefFields) 
        {
            if (wcefField.getName().equals(INT_ANONYMOUS_IDENTITY))
                wcefAnonymousId = wcefField;
            else if (wcefField.getName().equals(INT_CA_CERT))
                wcefCaCert = wcefField;
            else if (wcefField.getName().equals(INT_CLIENT_CERT))
                wcefClientCert = wcefField;
            else if (wcefField.getName().equals(INT_EAP))
                wcefEap = wcefField;
            else if (wcefField.getName().equals(INT_IDENTITY))
                wcefIdentity = wcefField;
            else if (wcefField.getName().equals(INT_PASSWORD))
                wcefPassword = wcefField;
            else if (wcefField.getName().equals(INT_PHASE2))
                wcefPhase2 = wcefField;
            else if (wcefField.getName().equals(INT_PRIVATE_KEY))
                wcefPrivateKey = wcefField;
        }


        Method wcefSetValue = null;
        if(!noEnterpriseFieldType){
        for(Method m: wcEnterpriseField.getMethods())
            //System.out.println(m.getName());
            if(m.getName().trim().equals("setValue"))
                wcefSetValue = m;
        }


        /*EAP Method*/
        if(!noEnterpriseFieldType){
            wcefSetValue.invoke(wcefEap.get(selectedConfig), ENTERPRISE_EAP);
        }
        /*EAP Phase 2 Authentication*/
        if(!noEnterpriseFieldType){
            wcefSetValue.invoke(wcefPhase2.get(selectedConfig), ENTERPRISE_PHASE2);
        }
        /*EAP Anonymous Identity*/
        if(!noEnterpriseFieldType){
            wcefSetValue.invoke(wcefAnonymousId.get(selectedConfig), ENTERPRISE_ANON_IDENT);
        }
        /*EAP CA Certificate*/
        if(!noEnterpriseFieldType){
            wcefSetValue.invoke(wcefCaCert.get(selectedConfig), ENTERPRISE_CA_CERT);
        }


        /*EAP Identity*/
        if(!noEnterpriseFieldType){
            wcefSetValue.invoke(wcefIdentity.get(selectedConfig), "test user name");
        }
        /*EAP Password*/
        if(!noEnterpriseFieldType){
            wcefSetValue.invoke(wcefPassword.get(selectedConfig), "test password");
        }


        try{

        } catch (Exception e)
        {
            e.printStackTrace();
        }

    } catch (Exception e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    WifiManager wifiManag = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    boolean res1 = wifiManag.setWifiEnabled(true);
    int res = wifiManag.addNetwork(selectedConfig);
    Log.d("WifiPreference", "add Network returned " + res );
//        boolean b = wifiManag.enableNetwork(selectedConfig.networkId, false);
//        Log.d("WifiPreference", "enableNetwork returned " + b );
//        boolean c = wifiManag.saveConfiguration();
//        Log.d("WifiPreference", "Save configuration returned " + c );
//        boolean d = wifiManag.enableNetwork(res, true);   
//        Log.d("WifiPreference", "enableNetwork returned " + d ); 


}

Mam nadzieję, że to komuś pomoże. @Android uczący się Usunąłem trochę o adHocFrequency i SSID, ponieważ powodowały awarie, ale moje wyniki były nadal dobre bez nich.


0

Klucze WEP są maskowane, więc nie ma możliwości ich odczytania za pomocą wspomnianego kodu

    Log.d("WifiPreference", "WEP KEY 0" + wepKeys[0]);
    Log.d("WifiPreference", "WEP KEY 1" + wepKeys[1]);
    Log.d("WifiPreference", "WEP KEY 2" + wepKeys[2]);
    Log.d("WifiPreference", "WEP KEY 3" + wepKeys[3]);

Czy istnieje sposób rozwiązania tego problemu w taki sam sposób, jak rozwiązanie EAP? Z refleksją?


dla eap również refleksja nie działa dla określonych dziedzin, których potrzebujemy. rozwiązałeś swój problem?
Prashanth Debbadwar
Korzystając z naszej strony potwierdzasz, że przeczytałeś(-aś) i rozumiesz nasze zasady używania plików cookie i zasady ochrony prywatności.
Licensed under cc by-sa 3.0 with attribution required.