25

I am getting SecurityException followed by RemoteException while trying to access below code. API

val networkCapabilities = connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)

Exception getting

Fatal Exception: java.lang.SecurityException: Package android does not belong to 10319
           at android.os.Parcel.createExceptionOrNull(Parcel.java:2385)
           at android.os.Parcel.createException(Parcel.java:2369)
           at android.os.Parcel.readException(Parcel.java:2352)
           at android.os.Parcel.readException(Parcel.java:2294)
           at android.net.IConnectivityManager$Stub$Proxy.getNetworkCapabilities(IConnectivityManager.java:3347)
           at android.net.ConnectivityManager.getNetworkCapabilities(ConnectivityManager.java:1549)

Caused by android.os.RemoteException: Remote stack trace:
        at android.app.AppOpsManager.checkPackage(AppOpsManager.java:7783)
        at com.android.server.ConnectivityService.getNetworkCapabilities(ConnectivityService.java:2297)
        at android.net.IConnectivityManager$Stub.onTransact(IConnectivityManager.java:1357)
        at android.os.Binder.execTransactInternal(Binder.java:1195)
        at android.os.Binder.execTransact(Binder.java:1159)

I have analyzed it and when I dig into the aosp code, I got the flow is going to checkPackage method of from AppOpsManager class shown in attached screenshot and from the code we know whenever check package condition is not equal to MODE_ALLOWED then only we will get Security Excception. But I don't have any. Idea when that condition will fail.

Please help me if anyone has any idea on this , thanks

enter image description here

enter image description here

Sudhansu
  • 780
  • 1
  • 9
  • 28

1 Answers1

19

Looks like it is a known issue https://issuetracker.google.com/issues/175055271

Dec 10, 2020 11:43AM
We have passed this to the development team and will update this issue with more information as it becomes available.
Sep 14, 2021 12:04AM
Marked as fixed.
The issue has been fixed in Android S and above.

But no fixes for Android below S.

Andrew Tomash
  • 345
  • 3
  • 7