zamojski / TowerCollector

The OpenCellID and MLS contributor's app.
Mozilla Public License 2.0
226 stars 27 forks source link

compatibility issue when calling method #158

Closed PSDroid2022 closed 2 years ago

PSDroid2022 commented 2 years ago

Hi, nice day! This time we confirm a callback compatibility issue which might threaten the robustness of your app and give a detailed suggestion for you.

In ''CsvExportFormatter.java", you call the framework API "<android.telephony.CellSignalStrengthNr: int getCsiRsrp()>" in "formatEntry" method as shown in following. But actually, this API is added in API level 29 (https://developer.android.google.cn/reference/kotlin/android/telephony/CellSignalStrengthNr?hl=en#getCsiRsrp()).

@Override
    public String formatEntry(Measurement m) {
        StringBuilder sb = new StringBuilder(150);

        for (Cell c : m.getCells()) {
             ...
             int csiRsrp = c.getCsiRsrp();
            if (csiRsrp != Cell.UNKNOWN_SIGNAL)
                sb.append(formatInt(csiRsrp));
            }
        }

So when the app try to call this API on devices level 21~28, your app will run with an unpredictable results. So we suggest you add an "if(SDK_INT>=29)", " @TargetApi(Build.VERSION_CODES.Q)" or change your app miniSDK from 21 to 29 to fix this potential issue.

By the way, "@TargetApi(Build.VERSION_CODES.Q)" will be deleted by Android compiler when extracting APKs, so it seems like a not good way to solve those issues.

zamojski commented 2 years ago

In ''CsvExportFormatter.java", you call the framework API "<android.telephony.CellSignalStrengthNr: int getCsiRsrp()>"

Not really, it uses my own Cell model there. The value from Android is read inside CellSignalConverter class.

zamojski commented 2 years ago

@PSDroid2022 Do you have any comments? If not then I'm closing the issue.