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

Telemetry entry reporting Java NullPointerException error in `deviceInfo` section

Open dianabarsan opened this issue 2 years ago • 1 comments

Describe the bug I came across a telemetry entry that had this message in the device section:

"userAgent": "Mozilla/5.0 (Linux; Android 7.0; TECNO WX3P Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Crosswalk/23.53.589.4 Mobile Safari/537.36 org.livinggoods.smarthealth.region1.ug/v0.4.33",
    "deviceInfo": {
      "error": true,
      "message": "Problem fetching device info: class java.lang.NullPointerException: Attempt to invoke virtual method 'int android.net.NetworkCapabilities.getLinkDownstreamBandwidthKbps()' on a null object reference"
    },

Link to forum post sharing the full telemetry entry: https://forum.communityhealthtoolkit.org/t/error-loading-tasks/2471/9

To Reproduce Steps to reproduce the behavior: I'm assuming this is linked to the Android version this device runs, which is Android 7.0.

Expected behavior Get device info, not an error.

Environment

  • Instance: live instance
  • Android Version: 7.0
  • App Version: ??

dianabarsan avatar Feb 23 '23 13:02 dianabarsan

Looks like null is a valid return value: https://developer.android.com/reference/android/net/ConnectivityManager#getNetworkCapabilities(android.net.Network)

Need to add null check here: https://github.com/medic/cht-android/blob/8ab2db67d156eb288365d3fed36861966c9ff478/src/main/java/org/medicmobile/webapp/mobile/MedicAndroidJavascript.java#L284

garethbowen avatar Feb 23 '23 23:02 garethbowen