Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Security exception while trying to fetch networkcapabilities on android 11

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

like image 610
Sudhansu Avatar asked Mar 16 '21 09:03

Sudhansu


1 Answers

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.

like image 161
Andrew Tomash Avatar answered Oct 24 '22 04:10

Andrew Tomash