Coder Social home page Coder Social logo

mnalis / android-wifi-upgrade Goto Github PK

View Code? Open in Web Editor NEW
17.0 17.0 8.0 60 KB

convert WiFi passwords from old Android wpa_supplicant.conf to newer (post-Oreo) WifiConfigStore.xml

License: Apache License 2.0

Perl 83.52% Makefile 16.48%
android wifi

android-wifi-upgrade's People

Contributors

jimklimov avatar juanro49 avatar mnalis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

android-wifi-upgrade's Issues

reverse engineering

Is it possible to "reconvert" the WifiConfigStore.xml back to wpa_supplicant.conf?

reverse engineering

Is it possible to "reconvert" the WifiConfigStore.xml back to wpa_supplicant.conf?

Needs changes for Android 10 (Lineage 17)

I tried your script today to import a wpa_supplicant.conf from Android 7 (Fairphone Open OS) into Android 10 (Lineage 17.1), but it needed some changes to work. In the hope that this might benefit others, I'm documenting what I did here.

Without changes, the produced file produces the following logcat warning:

05-17 19:59:18.227   749  2676 E WifiConfigManager: XML deserialization of store failed. All saved networks are lost!
05-17 19:59:18.227   749  2676 E WifiConfigManager: org.xmlpull.v1.XmlPullParserException: Configuration key does not match. Retrieved: "Jodocus"-WPA_PSK, Calculated: "Jodocus"WPA_PSK

Comparing the system-generated file with the script-generated file confirms that there should not be a dash between the SSID and the keymgmt. Other changes are the file version number (1 vs 3), but that does not seem to matter, Android autobumps it. And some of the Allowed fields have a few more bits in the script-generated version (probably because the script allows everything by default). However, the AllowedProtocols field does seem to cause a problem:

05-17 20:04:17.656   741  2710 E SupplicantStaIfaceHal: java.lang.IllegalArgumentException: Invalid protoMask bit in wificonfig: 3

Bit 3 is WAPI, I suspect Android 10 does not support it anymore (here is also some docs with the WAPI value grayed out). Unsetting that bit, fixes the error.

With the changes below, I managed to import 63 of my networks (one failed, but that one is a bit weird in wpa_supplication.conf).

--- a/convert_wifi.pl
+++ b/convert_wifi.pl
@@ -77,8 +77,8 @@ ()
        #   9 OWE - Opportunististic Wireless Encryption
        #   10 SUITE_B_192
 
-       #my $AllowedProtocols = '03'; # WPA1+WPA2
-       my $AllowedProtocols = '0b'; # WPA1+WPA2+WAPI
+       my $AllowedProtocols = '03'; # WPA1+WPA2
+       #my $AllowedProtocols = '0b'; # WPA1+WPA2+WAPI
        # https://developer.android.com/reference/android/net/wifi/WifiConfiguration.Protocol
        #   0 WPA1 (deprecated)
        #   1 RSN WPA2/WPA3/IEEE 802.11i
@@ -147,7 +147,7 @@ ()
        }
 
        $SSID = quote_xml $SSID;
-       my $ConfigKey = "${SSID}-$key_mgmt";
+       my $ConfigKey = "${SSID}$key_mgmt";
        my $priority = $CUR{priority} || 0;
        
        # output main config block with all variables filled-in

Permission denied when pushing

I get an error when pushing the generated file.

(I've enabled root access on ADB with no luck.)

adb push WifiConfigStore.xml /data/misc/wifi/WifiConfigStore.xml
adb: error: stat failed when trying to push to /data/misc/wifi/WifiConfigStore.xml: Permission denied

Updated WiFiConfigStore.xml is applied only after reboot

Hello,

First of all, thank you for providing this tool. I am having a slight issue with the change applied only after the Android device is rebooted, not right after the WiFi is enabled again.

Steps to reproduce (tested on a box with Android 9):

  1. Prepare WiFiConfigStore.xml with new WiFi networks on a computer
  2. Disable WiFi on Android device
  3. Push WiFiConfigStore.xml
  4. Enable WiFi on Android device
  5. Check Saved WiFi networks - Android doesn't display any
  6. Reboot the Android device
  7. Check Saved WiFi networks - Android shows the networks from uploaded WiFiConfigStore.xml

Is there a way to apply the changes without rebooting the entire device?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.