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

Crash when app widget loading images #2121

Closed
dxinl opened this issue Jul 10, 2017 · 2 comments
Closed

Crash when app widget loading images #2121

dxinl opened this issue Jul 10, 2017 · 2 comments
Labels
Milestone

Comments

@dxinl
Copy link

dxinl commented Jul 10, 2017

Glide Version:
glide-full-4.0.0-RC1

Integration libraries:

Device/Android Version:
Nexus 6/Android 7.1.1

Issue details / Repro steps / Use case background:

Glide load line / GlideModule (if any) / list Adapter code (if any):

RequestOptions options = new RequestOptions()
                .centerCrop()
                .override(thumbnailWidth, thumbnailHeight);
return Glide.with(context).asBitmap().load(realUri).apply(options).submit().get();

/** then in RemoteViewsFactory */
views.setImageViewBitmap(R.id.iv_item_widget_image, bitmap);

Stack trace / LogCat:

java.lang.SecurityException: ConnectivityService: Neither user 10126 nor current process has android.permission.ACCESS_NETWORK_STATE.
                                                                        at android.os.Parcel.readException(Parcel.java:1684)
                                                                        at android.os.Parcel.readException(Parcel.java:1637)
                                                                        at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:1170)
                                                                        at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:745)
                                                                        at com.bumptech.glide.manager.DefaultConnectivityMonitor.isConnected(DefaultConnectivityMonitor.java:61)
                                                                        at com.bumptech.glide.manager.DefaultConnectivityMonitor.register(DefaultConnectivityMonitor.java:42)
                                                                        at com.bumptech.glide.manager.DefaultConnectivityMonitor.onStart(DefaultConnectivityMonitor.java:67)
                                                                        at com.bumptech.glide.manager.ApplicationLifecycle.addListener(ApplicationLifecycle.java:13)
                                                                        at com.bumptech.glide.RequestManager.<init>(RequestManager.java:101)
                                                                        at com.bumptech.glide.RequestManager.<init>(RequestManager.java:71)
                                                                        at com.bumptech.glide.manager.RequestManagerRetriever$1.build(RequestManagerRetriever.java:402)
                                                                        at com.bumptech.glide.manager.RequestManagerRetriever.getApplicationManager(RequestManagerRetriever.java:96)
                                                                        at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:117)
                                                                        at com.bumptech.glide.Glide.with(Glide.java:540)
                                                                        at com.dxinl.utils.BitmapUtils.loadThumbnailForWidget(BitmapUtils.java:55)
                                                                        at com.dxinl.widget.NoteViewsFactory.getImageViews(NoteViewsFactory.java:127)
                                                                        at com.dxinl.widget.NoteViewsFactory.getViewAt(NoteViewsFactory.java:68)
                                                                        at android.widget.RemoteViewsService$RemoteViewsFactoryAdapter.getViewAt(RemoteViewsService.java:164)
                                                                        at com.android.internal.widget.IRemoteViewsFactory$Stub.onTransact(IRemoteViewsFactory.java:85)
                                                                        at android.os.Binder.execTransact(Binder.java:565)

By the way, I do not request ACCESS_NETWORK_STATE permission in my Manifest. If I request that permission, the crashing will not happen. But I use Glide to load just local images, so I don't want to request that permission.

@sjudd
Copy link
Collaborator

sjudd commented Jul 10, 2017

If you don't want to monitor connectivity status (totally fine), you can use setConnectivityMonitorFactory() in a GlideModule and set a factory that just returns an empty listener.

For more information on configuring Glide, see Glide's docs.

@sjudd sjudd added this to the 4.0 milestone Jul 10, 2017
@dxinl
Copy link
Author

dxinl commented Jul 11, 2017

@sjudd Thanks very much for your reply.

But I am still confused. There is code which call Context#checkCallingOrSelfPermission(String) to check permission ACCESS_NETWORK_STATE in DefaultConnectivityMonitorFactory#build(Context, ConnectivityListener).

The method Context#checkCallingOrSelfPermission(String)

Determine whether the calling process of an IPC or you have been granted a particular permission.

In my case, calling process of an IPC has ACCESS_NETWORK_STATE permission but not my app. So, DefaultConnectivityMonitorFactory#build(Context, ConnectivityListener) returns an object of class DefaultConnectivityMonitor, and crash happen when that object try to get network state later.

I guess calling Context#context.checkCallingOrSelfPermission(String) is incorrect. Is it?

@sjudd sjudd closed this as completed in 86e472d Aug 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants