lloydtorres / stately

A NationStates app for Android.
https://play.google.com/store/apps/details?id=com.lloydtorres.stately
Apache License 2.0
32 stars 8 forks source link

Network connection may not be being verified in project #28

Open caev03 opened 3 years ago

caev03 commented 3 years ago

Dear Developer!

My name is Camilo Escobar, I am a PhD Student at Universidad de los Andes, Colombia. I am part of a research on the usage of network libraries within android apps. As a result of this we identified that there is a missing validation of network connection within the project since some network operations are being performed in the application.

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: public NetworkInfo getActiveNetworkInfo () returns details about the currently active default data network. When connected, this network is the default route for outgoing connections. You should always check NetworkInfo#isConnected() before initiating network traffic, it requires Manifest.permission.ACCESS_NETWORK_STATE. However, isConnected() was 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.