android-app icon indicating copy to clipboard operation
android-app copied to clipboard

Network connection may not be being verified in project

Open amazuerar opened this issue 3 years ago • 0 comments

Issue details

Dear Developer!

My name is Alejandro Mazuera-Rozo, I am a PhD Student at Universidad de los Andes, and at Università della Svizzera italiana. I am part of a research on the usage of network libraries within android apps.

Duplicate?

Have you searched the issues of this repository if your issue is already known? yes

Actual behaviour

As a result of our research we identified that there is a missing validation of network connection within the project since some network operations are being performed in the application.

Expected behaviour

As you might know, a device may not be connected to a network. In order to get such information see https://developer.android.com/reference/android/net/ConnectivityManager. Therefore it is recommended for the app to identify whether the device has a network connection available before performing a network operation.

In order to address this issue we recommend you to visit:

  1. https://developer.android.com/training/basics/network-ops/managing
  2. https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback

Note: Despite the fact isConnectedOrConnecting() is being called within isNetworkAvailable(). isConnectedOrConnecting() indicates whether network connectivity exists or is in the process of being established. This is good for applications that need to do anything related to the network other than read or write data. However, for the latter, call isConnected() instead, which guarantees that the network is fully usable.

https://github.com/wallabag/android-app/blob/c4de8bdecfaf03623f0eff65040bcf77f85807c1/app/src/main/java/fr/gaulupeau/apps/Poche/network/WallabagConnection.java#L131-L139

Note: isConnected() and isConnectedOrConnecting() were deprecated in API level 29, one should instead use the ConnectivityManager.NetworkCallback API to learn about connectivity changes, to be more specific the onAvailable() method.

Steps to reproduce the issue

N/A

Environment details

N/A

Logs

N/A

Web server

N/A

amazuerar avatar Aug 14 '21 15:08 amazuerar