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

Commit 4dd590c6 authored by Nathan Harold's avatar Nathan Harold
Browse files

Update Conditions for SignalStrength Unsols

Update and Simplify the signal strength unsol criteria to
better align with other indications. There are two material
changes that result from this:
1) When the device is in Automotive Projection mode or tethering
   is on, signal strength indications will be sent. In both cases
   there is value.
2) Signal Strength indication requests won't fluctuate with the
   device power state when the radio is off.

Bug: 215750179
Test: atest DeviceStateMonitorTest#testAlwaysOnSignalStrengthwithRadioToggle
Change-Id: I8ba4ea97c8847c4060d650cbaf0cd20b28e4ab3d
parent 41fbcd74
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -355,10 +355,13 @@ public class DeviceStateMonitor extends Handler {
     */
    private boolean shouldEnableSignalStrengthReports() {
        // We should enable signal strength update if one of the following condition is true.
        // 1. The device is charging.
        // 2. When the screen is on.
        // 3. Any of system services is registrating to always listen to signal strength changes
        return mIsAlwaysSignalStrengthReportingEnabled || mIsCharging || mIsScreenOn;
        // 1. Whenever the conditions for high power usage are met.
        // 2. Any of system services is registrating to always listen to signal strength changes
        //    and the radio is on (if radio is off no indications should be sent regardless, but
        //    in the rare case that something registers/unregisters for always-on indications
        //    and the radio is off, we might as well ignore it).
        return shouldEnableHighPowerConsumptionIndications()
                || (mIsAlwaysSignalStrengthReportingEnabled && mIsRadioOn);
    }

    /**
+29 −3
Original line number Diff line number Diff line
@@ -73,9 +73,7 @@ public class DeviceStateMonitorTest extends TelephonyTest {
            | IndicationFilter.REGISTRATION_FAILURE
            | IndicationFilter.BARRING_INFO;

    // INDICATION_FILTERS_ALL but excludes Indication.SIGNAL_STRENGTH
    private static final int INDICATION_FILTERS_WHEN_TETHERING_ON =
            INDICATION_FILTERS_ALL & ~IndicationFilter.SIGNAL_STRENGTH;
    private static final int INDICATION_FILTERS_WHEN_TETHERING_ON = INDICATION_FILTERS_ALL;
    private static final int INDICATION_FILTERS_WHEN_CHARGING = INDICATION_FILTERS_ALL;
    private static final int INDICATION_FILTERS_WHEN_SCREEN_ON = INDICATION_FILTERS_ALL;

@@ -425,4 +423,32 @@ public class DeviceStateMonitorTest extends TelephonyTest {

        verify(mSimulatedCommandsVerifier).getBarringInfo(nullable(Message.class));
    }

    @Test
    public void testAlwaysOnSignalStrengthwithRadioToggle() {
        // Start with the radio off
        updateState(STATE_TYPE_RADIO_OFF_OR_NOT_AVAILABLE, /* stateValue is not used */ 0);
        reset(mSimulatedCommandsVerifier);
        // Toggle always-reported signal strength while the radio is OFF. This should do nothing.
        // This should have no effect while the radio is off.
        updateState(STATE_TYPE_ALWAYS_SIGNAL_STRENGTH_REPORTED, STATE_ON);
        updateState(STATE_TYPE_ALWAYS_SIGNAL_STRENGTH_REPORTED, STATE_OFF);
        verify(mSimulatedCommandsVerifier, never())
                .sendDeviceState(anyInt(), anyBoolean(), nullable(Message.class));

        // Turn on the always reported signal strength and then the radio, which should just turn
        // on this one little thing more than the absolute minimum.
        updateState(STATE_TYPE_ALWAYS_SIGNAL_STRENGTH_REPORTED, STATE_ON);
        updateState(STATE_TYPE_RADIO_ON, /* stateValue is not used */ 0);
        verify(mSimulatedCommandsVerifier).setUnsolResponseFilter(
                eq(IndicationFilter.SIGNAL_STRENGTH | INDICATION_FILTERS_MINIMUM),
                        nullable(Message.class));

        // Turn off radio and see that SignalStrength goes off again. Technically, in this
        // direction, the value becomes a "don't-care", but it's not worth the complexity of having
        // the value only sync on the rising edge of radio power.
        updateState(STATE_TYPE_RADIO_OFF_OR_NOT_AVAILABLE, /* stateValue is not used */ 0);
        verify(mSimulatedCommandsVerifier).setUnsolResponseFilter(
                eq(INDICATION_FILTERS_MINIMUM), nullable(Message.class));
    }
}