Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACCESS_NETWORK_STATE crash 2.13.3 #9002

Closed
yoobi opened this issue Jun 1, 2021 · 4 comments
Closed

ACCESS_NETWORK_STATE crash 2.13.3 #9002

yoobi opened this issue Jun 1, 2021 · 4 comments

Comments

@yoobi
Copy link
Contributor

yoobi commented Jun 1, 2021

I'm getting report from Crashlytics that some user are having crashes the stacktrace is as shown below:

Fatal Exception: java.lang.RuntimeException
Unable to create application com.my.application.PocApplication: java.lang.SecurityException: Package android does not belong to 10609
android.app.ActivityThread.handleMakeApplication (ActivityThread.java:7512)
android.app.ActivityThread.handleBindApplication (ActivityThread.java:7446)
android.app.ActivityThread.access$1500 (ActivityThread.java:301)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:2148)
android.os.Handler.dispatchMessage (Handler.java:106)
android.os.Looper.loop (Looper.java:246)
android.app.ActivityThread.main (ActivityThread.java:8512)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
android.os.Parcel.createExceptionOrNull (Parcel.java:2385)
android.os.Parcel.createException (Parcel.java:2369)
android.os.Parcel.readException (Parcel.java:2352)
android.os.Parcel.readException (Parcel.java:2294)
android.net.IConnectivityManager$Stub$Proxy.requestNetwork (IConnectivityManager.java:4597)
android.net.ConnectivityManager.sendRequestForNetwork (ConnectivityManager.java:4194)
android.net.ConnectivityManager.registerDefaultNetworkCallback (ConnectivityManager.java:4706)
android.net.ConnectivityManager.registerDefaultNetworkCallback (ConnectivityManager.java:4673)
com.google.android.exoplayer2.scheduler.RequirementsWatcher.registerNetworkCallbackV24 (RequirementsWatcher.java:136)
com.google.android.exoplayer2.scheduler.RequirementsWatcher.start (RequirementsWatcher.java:91)
com.google.android.exoplayer2.offline.DownloadManager.<init> (DownloadManager.java:278)
com.google.android.exoplayer2.offline.DownloadManager.<init> (DownloadManager.java:230)
Remote stack trace: at android.app.AppOpsManager.checkPackage(AppOpsManager.java:7783) at 
com.android.server.ConnectivityService.ensureSufficientPermissionsForRequest(ConnectivityService.java:8546) at
com.android.server.ConnectivityService.requestNetwork(ConnectivityService.java:8648) at 
android.net.IConnectivityManager$Stub.onTransact(IConnectivityManager.java:2051) at 
android.os.Binder.execTransactInternal(Binder.java:1190)

My manifest permission::

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />

The crash happened on

  • ExoPlayer: 2.13.3
  • Android version: 11
  • Android device: Samsung Galaxy S20 FE 5G
  • Rooted: no
@andrewlewis
Copy link
Collaborator

andrewlewis commented Jun 1, 2021

Do you have any other parts of the stack trace message apart from what's included above? In particular I was wondering if there is a line starting like AndroidRuntime: Caused by: java.lang.SecurityException:. [Internal: b/155549446] looks similar.

@yoobi
Copy link
Contributor Author

yoobi commented Jun 1, 2021

Yes Indeed, i thought it was irrelevant as it wasn't on exoplayer library, I'll update my post. The order I display in my post is the same order I get from Crashlytics

@pavelperc
Copy link

pavelperc commented Aug 16, 2021

We also got this crash. It is an android 11 bug, look here: https://stackoverflow.com/questions/66652819/getting-security-exception-while-trying-to-fetch-networkcapabilities-on-android

Here is stack trace:

Caused by java.lang.SecurityException: Package android does not belong to 10186
       at android.os.Parcel.createExceptionOrNull(Parcel.java:2373)
       at android.os.Parcel.createException(Parcel.java:2357)
       at android.os.Parcel.readException(Parcel.java:2340)
       at android.os.Parcel.readException(Parcel.java:2282)
       at android.net.IConnectivityManager$Stub$Proxy.getNetworkCapabilities(IConnectivityManager.java:2456)
       at android.net.ConnectivityManager.getNetworkCapabilities(ConnectivityManager.java:1385)
       at com.google.android.exoplayer2.scheduler.Requirements.isInternetConnectivityValidated(Requirements.java:215)
       at com.google.android.exoplayer2.scheduler.Requirements.getNotMetNetworkRequirements(Requirements.java:162)
       at com.google.android.exoplayer2.scheduler.Requirements.getNotMetRequirements(Requirements.java:137)
       at com.google.android.exoplayer2.scheduler.RequirementsWatcher.start(RequirementsWatcher.java:86)
       at com.google.android.exoplayer2.offline.DownloadManager.<init>(DownloadManager.java:278)
       at com.google.android.exoplayer2.offline.DownloadManager.<init>(DownloadManager.java:230)

ExoPlayer version: 2.12.2

Seems like you need to wrap this line into try catch:
https://github.com/google/ExoPlayer/blob/r2.15.0/library/core/src/main/java/com/google/android/exoplayer2/scheduler/Requirements.java#L215

@ojw28
Copy link
Contributor

ojw28 commented Sep 6, 2021

This issue was fixed in Android 12, by https://android-review.googlesource.com/c/platform/frameworks/base/+/1758029/. We'll add a try/catch for Android 11 devices that don't get patched. We'll return true from the catch block (i.e., assume network capability is validated), which is what we return from the method on API levels below 24 anyway.

@ojw28 ojw28 added the bug label Sep 6, 2021
@ojw28 ojw28 assigned ojw28 and unassigned andrewlewis Sep 6, 2021
icbaker pushed a commit that referenced this issue Sep 7, 2021
#exofixit
#minor-release
Issue: #9002
PiperOrigin-RevId: 395221648
@ojw28 ojw28 closed this as completed Sep 7, 2021
christosts pushed a commit that referenced this issue Sep 21, 2021
@google google locked and limited conversation to collaborators Nov 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants