1

im writing a simple app that want to connect to a specific WiFi Network on Android 10. I gave all permissions that I thought I might need in the manifest.xml.

<uses-permission-sdk-23 android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission-sdk-23 android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission-sdk-23 android:name="android.permission.INTERNET"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission-sdk-23 android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission-sdk-23 android:name="android.permission.CONNECTIVITY_INTERNAL" />
<uses-permission-sdk-23 android:name="android.permission.MAINLINE_NETWORK_STACK" />

But when I use the fuction "connectivitymanager.requestNetwork" I get the Error:

java.lang.SecurityException: Requires one of the following permissions: android.permission.CONNECTIVITY_INTERNAL, android.permission.MAINLINE_NETWORK_STACK.

In the code where I want to request permissions this two permissions are not defined and not available for a request.

Anyone knows about this Permissions or the cause of the error?

Jürgen

Hacki
  • 41
  • 2
  • 5

2 Answers2

0

I had this issue when I was calling NetworkRequest.Builder#addCapability() and passing in a NetworkCapabilities.TRANSPORT_X value. I needed to call addTransportType() instead.

Noah Andrews
  • 353
  • 2
  • 14
0

As per the android docs:
"android.permission.CONNECTIVITY_INTERNAL" : deprecated This permission used to allow too broad access to sensitive methods and all its uses have been replaced by a more appropriate permission. Most uses have been replaced with a NETWORK_STACK or NETWORK_SETTINGS check. Please look up the documentation of the individual functions to figure out what permission now protects the individual function. @SystemApi Allows an internal user to use privileged ConnectivityManager APIs.

sameer pradhan
  • 324
  • 1
  • 4
  • 14