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

Commit e7a23599 authored by sqian's avatar sqian Committed by Shuo Qian
Browse files

Integrate 5G Signal Strength Threshold Reporting Framework Support

Test: CellSignalStrengthNrTest; ServiceStateTrackerTest; SignalThresholdInfoTest
Bug: 135717625
Change-Id: I316840372b7d31ecbd6ab2ca593ef0d99a0323c8
Merged-In: I316840372b7d31ecbd6ab2ca593ef0d99a0323c8
(cherry picked from commit bf837583)
parent 81e14337
Loading
Loading
Loading
Loading
+22 −8
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.telephony.CarrierRestrictionRules;
import android.telephony.ClientRequestStats;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.NetworkScanRequest;
import android.telephony.SignalThresholdInfo;
import android.telephony.data.DataProfile;
import android.telephony.emergency.EmergencyNumber;

@@ -2230,17 +2231,30 @@ public interface CommandsInterface {
    void setUnsolResponseFilter(int filter, Message result);

    /**
     * Send the signal strength reporting criteria to the modem.
     * Sets the signal strength reporting criteria.
     *
     * @param hysteresisMs A hysteresis time in milliseconds. A value of 0 disables hysteresis.
     * @param hysteresisDb An interval in dB defining the required magnitude change between reports.
     *     A value of 0 disables hysteresis.
     * @param thresholdsDbm An array of trigger thresholds in dBm. A size of 0 disables thresholds.
     * @param ran RadioAccessNetwork for which to apply criteria.
     * The resulting reporting rules are the AND of all the supplied criteria. For each RAN
     * The hysteresisDb and thresholds apply to only the following measured quantities:
     * -GERAN    - RSSI
     * -CDMA2000 - RSSI
     * -UTRAN    - RSCP
     * -EUTRAN   - RSRP/RSRQ/RSSNR
     * -NGRAN    - SSRSRP/SSRSRQ/SSSINR
     *
     * Note: Reporting criteria must be individually set for each RAN. For any unset reporting
     * criteria, the value is implementation-defined.
     *
     * Response callback is
     * IRadioResponse.setSignalStrengthReportingCriteriaResponse_1_5()
     *
     * @param signalThresholdInfo Signal threshold info including the threshold values,
     *                            hysteresisDb, and hysteresisMs. See @1.5::SignalThresholdInfo
     *                            for details.
     * @param ran The type of network for which to apply these thresholds.
     * @param result callback message contains the information of SUCCESS/FAILURE
     */
    void setSignalStrengthReportingCriteria(int hysteresisMs, int hysteresisDb, int[] thresholdsDbm,
            int ran, Message result);
    void setSignalStrengthReportingCriteria(SignalThresholdInfo signalThresholdInfo, int ran,
            Message result);

    /**
     * Send the link capacity reporting criteria to the modem
+52 −10
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.os.PowerManager;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.CarrierConfigManager;
import android.telephony.Rlog;
import android.telephony.SignalThresholdInfo;
import android.telephony.TelephonyManager;
import android.util.LocalLog;
import android.util.SparseIntArray;
@@ -587,14 +588,23 @@ public class DeviceStateMonitor extends Handler {
    }

    private void setSignalStrengthReportingCriteria() {
        mPhone.setSignalStrengthReportingCriteria(
                AccessNetworkThresholds.GERAN, AccessNetworkType.GERAN);
        mPhone.setSignalStrengthReportingCriteria(
                AccessNetworkThresholds.UTRAN, AccessNetworkType.UTRAN);
        mPhone.setSignalStrengthReportingCriteria(
                AccessNetworkThresholds.EUTRAN, AccessNetworkType.EUTRAN);
        mPhone.setSignalStrengthReportingCriteria(
                AccessNetworkThresholds.CDMA2000, AccessNetworkType.CDMA2000);
        mPhone.setSignalStrengthReportingCriteria(SignalThresholdInfo.SIGNAL_RSSI,
                AccessNetworkThresholds.GERAN, AccessNetworkType.GERAN, true);
        mPhone.setSignalStrengthReportingCriteria(SignalThresholdInfo.SIGNAL_RSCP,
                AccessNetworkThresholds.UTRAN, AccessNetworkType.UTRAN, true);
        mPhone.setSignalStrengthReportingCriteria(SignalThresholdInfo.SIGNAL_RSRP,
                AccessNetworkThresholds.EUTRAN_RSRP, AccessNetworkType.EUTRAN, true);
        mPhone.setSignalStrengthReportingCriteria(SignalThresholdInfo.SIGNAL_RSSI,
                AccessNetworkThresholds.CDMA2000, AccessNetworkType.CDMA2000, true);
        if (mPhone.getHalVersion().greaterOrEqual(RIL.RADIO_HAL_VERSION_1_5)) {
            // Defaultly we only need SSRSRP for NGRAN signal criterial reporting
            mPhone.setSignalStrengthReportingCriteria(SignalThresholdInfo.SIGNAL_SSRSRP,
                    AccessNetworkThresholds.NGRAN_RSRSRP, AccessNetworkType.NGRAN, true);
            mPhone.setSignalStrengthReportingCriteria(SignalThresholdInfo.SIGNAL_SSRSRQ,
                    AccessNetworkThresholds.NGRAN_RSRSRQ, AccessNetworkType.NGRAN, false);
            mPhone.setSignalStrengthReportingCriteria(SignalThresholdInfo.SIGNAL_SSSINR,
                    AccessNetworkThresholds.NGRAN_SSSINR, AccessNetworkType.NGRAN, false);
        }
    }

    private void setLinkCapacityReportingCriteria() {
@@ -730,17 +740,19 @@ public class DeviceStateMonitor extends Handler {
        };

        /**
         * List of default dBm thresholds for EUTRAN {@link AccessNetworkType}.
         * List of default dBm RSRP thresholds for EUTRAN {@link AccessNetworkType}.
         *
         * These thresholds are taken from the LTE RSRP defaults in {@link CarrierConfigManager}.
         */
        public static final int[] EUTRAN = new int[] {
        public static final int[] EUTRAN_RSRP = new int[] {
            -128, /* SIGNAL_STRENGTH_POOR */
            -118, /* SIGNAL_STRENGTH_MODERATE */
            -108, /* SIGNAL_STRENGTH_GOOD */
            -98,  /* SIGNAL_STRENGTH_GREAT */
        };

        // TODO Add EUTRAN_RSRQ and EUTRAN_RSSNI

        /**
         * List of dBm thresholds for CDMA2000 {@link AccessNetworkType}.
         *
@@ -752,6 +764,36 @@ public class DeviceStateMonitor extends Handler {
            -75,
            -65
        };

        /**
         * List of dB thresholds for NGRAN {@link AccessNetworkType} RSRSRP
         */
        public static final int[] NGRAN_RSRSRP = new int[] {
            -125, /* SIGNAL_STRENGTH_POOR */
            -115, /* SIGNAL_STRENGTH_MODERATE */
            -105, /* SIGNAL_STRENGTH_GOOD */
            -95,  /* SIGNAL_STRENGTH_GREAT */
        };

        /**
         * List of dB thresholds for NGRAN {@link AccessNetworkType} RSRSRP
         */
        public static final int[] NGRAN_RSRSRQ = new int[] {
            -14, /* SIGNAL_STRENGTH_POOR */
            -12, /* SIGNAL_STRENGTH_MODERATE */
            -10, /* SIGNAL_STRENGTH_GOOD */
            -8  /* SIGNAL_STRENGTH_GREAT */
        };

        /**
         * List of dB thresholds for NGRAN {@link AccessNetworkType} SSSINR
         */
        public static final int[] NGRAN_SSSINR = new int[] {
            -8, /* SIGNAL_STRENGTH_POOR */
            0, /* SIGNAL_STRENGTH_MODERATE */
            8, /* SIGNAL_STRENGTH_GOOD */
            16  /* SIGNAL_STRENGTH_GREAT */
        };
    }

    /**
+6 −3
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import android.telephony.NetworkScanRequest;
import android.telephony.PhoneNumberUtils;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SignalThresholdInfo;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -3658,9 +3659,11 @@ public class GsmCdmaPhone extends Phone {
    }

    @Override
    public void setSignalStrengthReportingCriteria(int[] thresholds, int ran) {
        mCi.setSignalStrengthReportingCriteria(REPORTING_HYSTERESIS_MILLIS, REPORTING_HYSTERESIS_DB,
                thresholds, ran, null);
    public void setSignalStrengthReportingCriteria(
            int signalStrengthMeasure, int[] thresholds, int ran, boolean isEnabled) {
        mCi.setSignalStrengthReportingCriteria(new SignalThresholdInfo(signalStrengthMeasure,
                REPORTING_HYSTERESIS_MILLIS, REPORTING_HYSTERESIS_DB, thresholds, isEnabled),
                ran, null);
    }

    @Override
+2 −1
Original line number Diff line number Diff line
@@ -3847,7 +3847,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    }

    /** Sets the SignalStrength reporting criteria. */
    public void setSignalStrengthReportingCriteria(int[] thresholds, int ran) {
    public void setSignalStrengthReportingCriteria(
            int signalStrengthMeasure, int[] thresholds, int ran, boolean isEnabled) {
        // no-op default implementation
    }

+52 −18
Original line number Diff line number Diff line
@@ -48,9 +48,9 @@ import android.hardware.radio.V1_0.SelectUiccSub;
import android.hardware.radio.V1_0.SimApdu;
import android.hardware.radio.V1_0.SmsWriteArgs;
import android.hardware.radio.V1_0.UusInfo;
import android.hardware.radio.V1_2.AccessNetwork;
import android.hardware.radio.V1_4.CarrierRestrictionsWithPriority;
import android.hardware.radio.V1_4.SimLockMultiSimPolicy;
import android.hardware.radio.V1_5.AccessNetwork;
import android.hardware.radio.deprecated.V1_0.IOemHook;
import android.net.ConnectivityManager;
import android.net.KeepalivePacketData;
@@ -90,6 +90,7 @@ import android.telephony.RadioAccessSpecifier;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SignalThresholdInfo;
import android.telephony.SmsManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyHistogram;
@@ -4441,8 +4442,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
    }

    @Override
    public void setSignalStrengthReportingCriteria(int hysteresisMs, int hysteresisDb,
            int[] thresholdsDbm, int ran, Message result) {
    public void setSignalStrengthReportingCriteria(SignalThresholdInfo signalThresholdInfo,
            int ran, Message result) {
        IRadio radioProxy = getRadioProxy(result);
        if (radioProxy != null) {
            if (mRadioVersion.less(RADIO_HAL_VERSION_1_2)) {
@@ -4450,24 +4451,55 @@ public class RIL extends BaseCommands implements CommandsInterface {
                        + "than 1.2");
                return;
            }

            if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_2)
                    && mRadioVersion.less(RADIO_HAL_VERSION_1_5)) {
                RILRequest rr = obtainRequest(RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA,
                        result, mRILDefaultWorkSource);

                if (RILJ_LOGD) {
                    riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
                }

                try {
                    android.hardware.radio.V1_2.IRadio radioProxy12 =
                        (android.hardware.radio.V1_2.IRadio) radioProxy;
                radioProxy12.setSignalStrengthReportingCriteria(rr.mSerial, hysteresisMs,
                        hysteresisDb, primitiveArrayToArrayList(thresholdsDbm),
                    radioProxy12.setSignalStrengthReportingCriteria(rr.mSerial,
                            signalThresholdInfo.getHysteresisMs(),
                            signalThresholdInfo.getHysteresisDb(),
                            primitiveArrayToArrayList(signalThresholdInfo.getThresholds()),
                            convertRanToHalRan(ran));
                } catch (RemoteException | RuntimeException e) {
                    handleRadioProxyExceptionForRR(rr, "setSignalStrengthReportingCriteria", e);
                }
            }
            if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_5)) {
                RILRequest rr = obtainRequest(RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA,
                        result, mRILDefaultWorkSource);
                if (RILJ_LOGD) {
                    riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
                }
                try {
                    android.hardware.radio.V1_5.IRadio radioProxy15 =
                            (android.hardware.radio.V1_5.IRadio) radioProxy;
                    radioProxy15.setSignalStrengthReportingCriteria_1_5(rr.mSerial,
                            convertToHalSignalThresholdInfo(signalThresholdInfo),
                            convertRanToHalRan(ran));
                } catch (RemoteException | RuntimeException e) {
                    handleRadioProxyExceptionForRR(
                            rr, "setSignalStrengthReportingCriteria_1_5", e);
                }
            }
        }
    }

    private static android.hardware.radio.V1_5.SignalThresholdInfo convertToHalSignalThresholdInfo(
            SignalThresholdInfo signalThresholdInfo) {
        android.hardware.radio.V1_5.SignalThresholdInfo signalThresholdInfoHal =
                new android.hardware.radio.V1_5.SignalThresholdInfo();
        signalThresholdInfoHal.signalMeasurement = signalThresholdInfo.getSignalMeasurement();
        signalThresholdInfoHal.hysteresisMs = signalThresholdInfo.getHysteresisMs();
        signalThresholdInfoHal.hysteresisDb = signalThresholdInfo.getHysteresisDb();
        signalThresholdInfoHal.thresholds = primitiveArrayToArrayList(
                signalThresholdInfo.getThresholds());
        return signalThresholdInfoHal;
    }

    @Override
@@ -4514,6 +4546,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
                return AccessNetwork.CDMA2000;
            case AccessNetworkType.IWLAN:
                return AccessNetwork.IWLAN;
            case AccessNetworkType.NGRAN:
                return AccessNetwork.NGRAN;
            case AccessNetworkType.UNKNOWN:
            default:
                return 0;
Loading