Getting Security exception while trying to fetch networkcapabilities on android 11 - android

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 😊

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.

Related

Can't solve error regarding 'org.codeaurora.qcamera3.exposure_metering.exposure_metering_mode'

I am working on an android application with AR elements. When it is redirecting me from the onboarding screen to the AR screen it crashes with the following error.
java.lang.IllegalArgumentException: Could not find tag for key 'org.codeaurora.qcamera3.exposure_metering.exposure_metering_mode')
at android.hardware.camera2.impl.CameraMetadataNative.nativeGetTagFromKeyLocal(Native Method)
at android.hardware.camera2.impl.CameraMetadataNative.setBase(CameraMetadataNative.java:1389)
at android.hardware.camera2.impl.CameraMetadataNative.set(CameraMetadataNative.java:459)
at android.hardware.camera2.impl.CameraMetadataNative.set(CameraMetadataNative.java:463)
at android.hardware.camera2.CaptureRequest$Builder.set(CaptureRequest.java:848)
at dez.a(PG:49)
at gtf.g(PG:104)
at det.a(Unknown Source:12)
at gjw.e(PG:5)
at gnx.run(PG:12)
at gsa.run(PG:2)
at gtc.run(PG:1)
at gsw.f(PG:2)
at gsv.run(PG:6)
Suppressed: gnv: [gpc{Cancelling}#66fb9dc, Dispatchers.IO]
It works fine on android API level 31 and the crash only happens on level 29. Does anybody have any idea what is causing this error?
Apparently it is a device dependent problem and the issue is reported on ARCore github.
https://github.com/google-ar/arcore-android-sdk/issues/1261

React-native-ble-plx unable to read with Android version less than 9

I am using React native version "0.63.3" and "react-native-ble-plx" version "2.0.2".
I am unable to read the characteristics in Android version less than 9.
It throws an error "Disconnected from {deviceId} with status 22 (UNKNOWN)"
If I debug, I could find this in BleError.js is thrown
"Error: Unknown error occurred. This is probably a bug! Check reason property"
Any help is appreciated!
I was recently working on an app requiring bluetooth functionality, I found this library to be much better than react-native-ble-plx, make sure to also check out their example to get a better understanding of how it works.

E/com.facebook.appevents.RestrictiveDataManager: updateRulesFromSetting failed

When I launch my app from Android Studio, with Facebook SDK installed on my device, Xiaomi Mi A2, it triggers the same error trhee times. It does not stop the app, but I don't know if I am missing something or simply, it is not important, but in the end, it is an error and I want to clarify it.
I am using Android Studio 3.4.1, Android 9 on the Xiaomi A2 and the new clause in build.gradle file is implementation 'com.facebook.android:facebook-android-sdk:5.1.0'. Error has not appeared before upgrading Facebook SDK.
This is what appears in Logcat:
2019-06-24 18:24:31.202 25105-25136/com.myapp
E/com.facebook.appevents.RestrictiveDataManager:
updateRulesFromSetting failed
org.json.JSONException: End of input at character 0 of
at org.json.JSONTokener.syntaxError(JSONTokener.java:449)
at org.json.JSONTokener.nextValue(JSONTokener.java:97)
at org.json.JSONArray.(JSONArray.java:92)
at org.json.JSONArray.(JSONArray.java:108)
at com.facebook.appevents.RestrictiveDataManager.updateFromSetting(RestrictiveDataManager.java:32)
at com.facebook.internal.FetchedAppSettingsManager.parseAppSettingsFromJSON(FetchedAppSettingsManager.java:323)
at com.facebook.internal.FetchedAppSettingsManager.access$000(FetchedAppSettingsManager.java:63)
at com.facebook.internal.FetchedAppSettingsManager$1.run(FetchedAppSettingsManager.java:181)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
EDIT
The issue has been fixed in version 5.1.1.
Revert to 5.0.3 to get rid of this.
5.1.0 is actually crashing in production at this method (there's a bug report here). GitHub commits of this file show its rather flawed, the method is called from multiple threads concluding to a concurrency crash because it's using a static ArrayList.
Lately the core FB SDK is kinda bloated with useless stuff and low-quality code. The codeless stuff "feature" that simply can't even be turned off is especially a horror to look at. If you don't strictly need the FB SDK in your app, I'd avoid it until they get their shit figured out.

App crash when connecting to google play games - A fatal developer error has occurred

My game stops when I try to connect it with the google play games. It was working. But suddenly this is happening. It's showing development error occurred. Here's the logcat.
07:34.150 2144-2144/com.sennovations.countermaster E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sennovations.countermaster, PID: 2144
java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
at com.google.android.gms.common.internal.zze.zzs(Unknown Source)
at com.google.android.gms.common.internal.zzi.zzrk(Unknown Source)
at com.google.android.gms.common.internal.zzh.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
I have added the meta tags in the manifest.
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="#string/app_id" />
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
Any help would be appreciated. Thanks
Based on your comments I infer that this wasn't your issue, but as I encountered a similar error that I resolved as follows, I'll add this answer:
Google's documentation (here, for instance) currently instructs us to add
compile 'com.google.android.gms:play-services:11.0.4'
to build.gradle. Notice that it currently advises version 11.0.4. Google adds:
Be sure you update this version number each time Google Play services is updated.
This one line appears to be quite possibly some of the worst advice ever given.
Why? Two reasons.
Suppose you use their free BaseGameUtils, which Google itself encourages. Its build.gradle is set up to use version 8.4.0:
ext.gms_library_version = '8.4.0'
I did this, and used the webpage's advice to use version 11.0.4. The disagreement in library numbers caused the app to crash on both Android Studio emulator and a test device with a stack trace similar to the one above.
To be fair, Android Studio will warn you that things can go wrong with the different version numbers: if you open the Manifest file, it will underline the version numbers and whine that it finds two different version numbers, and it will even tell you which version numbers disagree, but -- this is key -- it won't tell you where to find the other file(s) with different version numbers. If you are importing several libraries, and/or compiling dependencies on GitHub or elsewhere, it can be a bit of a challenge to find the cause.
If your app requests Play Games services 11.0.4, but your emulator and/or phone have a lower version number (e.g., 11.0.2 as on my emulator), then the Games API's connect() will give status RESULT_CANCEL to onActivityResult(). The documentation on these result codes leaves something to be desired, so this can take a while to debug -- in fact, I think I think the crashes above were my only clue that the problem might be with the API version number.
There is a way to check that the device supports the requested API, but most of Google's documentation doesn't tell you to do it, and even BaseGameUtils doesn't seem to check for it. (You want to look at GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE.)
In my particular case, the problem was solved by changing my app's play-services version to 8.4.0. Works beautifully now.

NPE on Facebook SDK 4.10 : Attempt to invoke interface method 'java.lang.Object com.facebook.inject.Lazy.get()' on a null object reference

Background
Recently we've updated the Facebook SDK library to 4.10 (from here).
Before, we had the same bug now and then, but now it seems it occurs a lot more often.
The problem
There is no way for us to understand where and why it occurs.
Here's the crash log:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke
interface method 'java.lang.Object com.facebook.inject.Lazy.get()' on
a null object reference
at android.os.Parcel.readException(Parcel.java:1552)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
at android.content.ContentResolver.query(ContentResolver.java:494)
at android.content.ContentResolver.query(ContentResolver.java:429)
at com.facebook.internal.NativeProtocol.fetchAllAvailableProtocolVersionsForAppInfo(NativeProtocol.java:790)
at com.facebook.internal.NativeProtocol.access$000(NativeProtocol.java:49)
at com.facebook.internal.NativeProtocol$NativeAppInfo.fetchAvailableVersions(NativeProtocol.java:281)
at com.facebook.internal.NativeProtocol$NativeAppInfo.access$600(NativeProtocol.java:226)
at com.facebook.internal.NativeProtocol$1.run(NativeProtocol.java:763)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
And, since it's a report from Crashlytics, I also have some statistics:
usually (90%) occurs on Meizu devices, and the rest on LG, Samsung and others.
usually (72%) occurs on Android 5.1 versions, and the rest on all of the other versions we support (4.x and above).
What I've tried
I tried searching for the exception, but I can't find anything even similar to it.
I tried to find the "com.facebook.inject.Lazy" class, but this is nowhere to be found. I can't even find injection related classes and repos that the sdk uses for normal use. Only for unit testings.
I also tried to go to the Github website of Facebook (here), but there is nowhere to write there.
Later I've found that this was reported on Facebook's developers website , but it doesn't seem that it's going to be fixed, and nobody knows how to handle it.
EDIT: now I've found this Facebook post, which says it might be because of using an old version of Facebook app, but it seem that it's incorrect.
The question
Why does it occur? Is there any workaround for this? Does Facebook work on a fix for this?
Is there any version of the Facebook SDK that this issue doesn't occur?
And, most importantly, How can it be handled and fixed?
Please use updated facebook sdk to overcome this error. old sdk has some problems.
you can download latest sdk from
https://developers.facebook.com/docs/android

Categories

Resources