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