openbmap / radiocells-nlp-android

radiocells.org Unified Network Location Provider
https://radiocells.org
Other
41 stars 13 forks source link

Missing version check for API getNeighboringCellInfo #55

Open DSOTM-pf opened 3 years ago

DSOTM-pf commented 3 years ago

Hi, there, I've found a version check is missing in version 0.2.9, the app is downloaded from F-Droid.

It is related to the following call chain:

org.openbmap.unifiedNlp.services.RadiocellsLocationService$2.run()void
 org.openbmap.unifiedNlp.services.RadiocellsLocationService.access$300(org.openbmap.unifiedNlp.services.RadiocellsLocationService,java.util.List)void
  org.openbmap.unifiedNlp.services.RadiocellsLocationService.getLocationFromWifisAndCells(java.util.List)void
   org.openbmap.unifiedNlp.services.RadiocellsLocationService.getCells()java.util.List
    android.telephony.TelephonyManager.getNeighboringCellInfo()java.util.List

The API getNeighboringCellInfo is added in Android API-level 25, if it is called in under 25 device, the app will crash. It may be better if we can check for the runtime version before calling it, such as:

if (Build.VERSION.SDK_INT >= 25)
    List list = getNeighboringCellInfo()
else
   // something else

@wish7code Can you help me review this? Very thanks!