Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc7687a2 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk
Browse files

Fix AM band range.

Test: open radio app, it doesn't throw any errors anymore
Bug: 75970985
Change-Id: I1d35fe02abf3c8de20c4426867f855feab3277d5
parent 0e675bd9
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -411,7 +411,8 @@ public final class ProgramSelector implements Parcelable {
    /**
     * Checks, if a given AM/FM frequency is roughly valid and in correct unit.
     *
     * It does not check the range precisely. In particular, it may be way off for certain regions.
     * It does not check the range precisely: it may provide false positives, but not false
     * negatives. In particular, it may be way off for certain regions.
     * The main purpose is to avoid passing inproper units, ie. MHz instead of kHz.
     *
     * @param isAm true, if AM, false if FM.
@@ -420,7 +421,7 @@ public final class ProgramSelector implements Parcelable {
     */
    private static boolean isValidAmFmFrequency(boolean isAm, int frequencyKhz) {
        if (isAm) {
            return frequencyKhz > 150 && frequencyKhz < 30000;
            return frequencyKhz > 150 && frequencyKhz <= 30000;
        } else {
            return frequencyKhz > 60000 && frequencyKhz < 110000;
        }
@@ -462,7 +463,8 @@ public final class ProgramSelector implements Parcelable {
            throw new IllegalArgumentException("Subchannels are not supported for non-HD radio");
        }
        if (!isValidAmFmFrequency(isAm, frequencyKhz)) {
            throw new IllegalArgumentException("Provided value is not a valid AM/FM frequency");
            throw new IllegalArgumentException("Provided value is not a valid AM/FM frequency: "
                    + frequencyKhz);
        }

        // We can't use AM_HD or FM_HD, because we don't know HD station ID.