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

Commit a26df246 authored by Nathan Harold's avatar Nathan Harold
Browse files

[conflict] Merge changes I8ba4ea97,I444a27c4 am: 631bddd4 am: b88c9d5e am: 20f0a62b

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1998152

Change-Id: Ic324bc31552134f424ecf99a3bfbbf7006584baf
parents eed03c14 20f0a62b
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;

@@ -427,4 +425,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));
    }
}