0

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.

YeO
  • 938
  • 1
  • 9
  • 17

1 Answers1

0

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.

user496854
  • 6,461
  • 10
  • 47
  • 84
  • is there a way to test this in Android Studio ? – YeO Oct 09 '22 at 09:44
  • You can try rooting your emulator, but I have no idea if you'd e able to actually modify any hotspot settings outside of a physical device: https://forum.xda-developers.com/t/script-rootavd-root-your-android-studio-virtual-device-emulator-with-magisk-android-12-linux-darwin-macos-win-google-play-store-apis.4218123/ – user496854 Oct 09 '22 at 12:39
  • I'm fine using a physical device, but I have no idea how to "move my app to the system partition", I have currently no way to test my app if I cannot get past the point where the permission is required – YeO Oct 09 '22 at 14:25
  • You have to root your phone, then: https://stackoverflow.com/questions/2007024/push-my-apk-to-system-app – user496854 Oct 09 '22 at 21:03