How can I setup a custom WiFi AP or Hotspot with WEP security on Android?

933 Views Asked by At

I need to setup a WiFi AP with WEP security on an Android Phone or Tablet and I set out to build an App for this purpose.

Disclaimer: I am well aware of WEP shortcomings but I still need this. My app is only intended for a handful of people and clearly not meant to be published on Google Play or any other store.

Before I can set it, I tried reading the current configuration using the following piece of code but it fails with the exception:

java.lang.SecurityException: App not allowed to read or update stored WiFi Ap config

private fun getCurrentConfig(conf: WifiConfiguration) {
    val mGetWifiConfig = wifiManager.javaClass.getDeclaredMethod("getWifiApConfiguration")
    return mGetWifiConfig.invoke(wifiManager)
}

I have tried adding <uses-permission android:name="android.permission.OVERRIDE_WIFI_CONFIG" tools:ignore="ProtectedPermissions"/> to AndroidManifest.xml to no avail.
My current understanding is that the App needs to be either system or privileged to be eligible to the relevant permission but I have no clue how to achieve either.

I am using Android Studio Dolphin (2021.3.1) an currently targeting Api 28, although this it not a requirement and I am flexible here. I'd like my App to be easily installed on reasonably current devices but I'm willing to compromise here as well but I don't want to rely on finding specific vintage devices either.

1

There are 1 best solutions below

4
user496854 On

android.permission.OVERRIDE_WIFI_CONFIG is a system-level permission, meaning that your app has to be signed by a platform key (you would have to create a custom ROM, and sign your app with the same key). Alternatively, you would need to have a rooted phone, and move your app to the system partition.