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

Commit 5b76bfc0 authored by sqian's avatar sqian
Browse files

Introduce getRssi() in CellSignalStrengthLte

Previous people designed that the lte signal strength from HAL is rssi
in ASU, but the new need of getRssi() API requires dBm unit.

Bug: 113074174
Test: Treehugger
Change-Id: I2982365a2e7fe1a56a393d123b9b0a30807d4d15
parent fbc4e555
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -42281,6 +42281,7 @@ package android.telephony {
    method public int getLevel();
    method public int getRsrp();
    method public int getRsrq();
    method public int getRssi();
    method public int getRssnr();
    method public int getTimingAdvance();
    method public void writeToParcel(android.os.Parcel, int);
+45 −0
Original line number Diff line number Diff line
@@ -31,6 +31,25 @@ public final class CellSignalStrengthLte extends CellSignalStrength implements P
    private static final String LOG_TAG = "CellSignalStrengthLte";
    private static final boolean DBG = false;

    /**
     * Indicates the unknown or undetectable RSSI value in ASU.
     *
     * Reference: TS 27.007 8.5 - Signal quality +CSQ
     */
    private static final int SIGNAL_STRENGTH_LTE_RSSI_ASU_UNKNOWN = 99;
    /**
     * Indicates the maximum valid RSSI value in ASU.
     *
     * Reference: TS 27.007 8.5 - Signal quality +CSQ
     */
    private static final int SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MAX_VALUE = 31;
    /**
     * Indicates the minimum valid RSSI value in ASU.
     *
     * Reference: TS 27.007 8.5 - Signal quality +CSQ
     */
    private static final int SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MIN_VALUE = 0;

    @UnsupportedAppUsage
    private int mSignalStrength;
    @UnsupportedAppUsage
@@ -141,6 +160,19 @@ public final class CellSignalStrengthLte extends CellSignalStrength implements P
        return mRsrq;
    }

    /**
     * Get Received Signal Strength Indication (RSSI) in dBm
     *
     * The value range is [-113, -51] inclusively or {@link CellInfo#UNAVAILABLE} if unavailable.
     *
     * Reference: TS 27.007 8.5 Signal quality +CSQ
     *
     * @return the RSSI if available or {@link CellInfo#UNAVAILABLE} if unavailable.
     */
    public int getRssi() {
        return convertRssiAsuToDBm(mSignalStrength);
    }

    /**
     * Get reference signal signal-to-noise ratio
     *
@@ -309,4 +341,17 @@ public final class CellSignalStrengthLte extends CellSignalStrength implements P
    private static void log(String s) {
        Rlog.w(LOG_TAG, s);
    }

    private static int convertRssiAsuToDBm(int rssiAsu) {
        if (rssiAsu != SIGNAL_STRENGTH_LTE_RSSI_ASU_UNKNOWN
                && (rssiAsu < SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MIN_VALUE
                || rssiAsu > SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MAX_VALUE)) {
            Rlog.e(LOG_TAG, "convertRssiAsuToDBm: invalid RSSI in ASU=" + rssiAsu);
            return CellInfo.UNAVAILABLE;
        }
        if (rssiAsu == SIGNAL_STRENGTH_LTE_RSSI_ASU_UNKNOWN) {
            return CellInfo.UNAVAILABLE;
        }
        return -113 + (2 * rssiAsu);
    }
}