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

Commit 2d463300 authored by Rambo Wang's avatar Rambo Wang
Browse files

Remove duplication to determine when should turn off response filters

Introduce a private method to keep the common policy to determine if
we should turn off one of the response filters, while all
metheds sharing the same common policy will call the new method.

Bug: 150965768
Test: atest DeviceStateMonitorTest
Change-Id: Ib9c9b1bd64cda404692b02290ee12f39789f9749
parent 546555c8
Loading
Loading
Loading
Loading
+14 −41
Original line number Diff line number Diff line
@@ -328,71 +328,44 @@ public class DeviceStateMonitor extends Handler {
     * trigger the network update unsolicited response.
     */
    private boolean shouldTurnOffFullNetworkUpdate() {
        // We should not turn off full network update if one of the following condition is true.
        // 1. The device is charging.
        // 2. When the screen is on.
        // 3. When data tethering is on.
        if (mIsCharging || mIsScreenOn || mIsTetheringOn) {
            return false;
        }

        // In all other cases, we turn off full network state update.
        return true;
        return shouldTurnOffHighPowerConsumptionIndications();
    }

    /**
     * @return True if data dormancy status update should be turned off.
     */
    private boolean shouldTurnOffDormancyUpdate() {
        // We should not turn off data dormancy update if one of the following condition is true.
        // 1. The device is charging.
        // 2. When the screen is on.
        // 3. When data tethering is on.
        if (mIsCharging || mIsScreenOn || mIsTetheringOn) {
            return false;
        }

        // In all other cases, we turn off data dormancy update.
        return true;
        return shouldTurnOffHighPowerConsumptionIndications();
    }

    /**
     * @return True if link capacity estimate update should be turned off.
     */
    private boolean shouldTurnOffLinkCapacityEstimate() {
        // We should not turn off link capacity update if one of the following condition is true.
        // 1. The device is charging.
        // 2. When the screen is on.
        // 3. When data tethering is on.
        if (mIsCharging || mIsScreenOn || mIsTetheringOn) {
            return false;
        }

        // In all other cases, we turn off link capacity update.
        return true;
        return shouldTurnOffHighPowerConsumptionIndications();
    }

    /**
     * @return True if physical channel config update should be turned off.
     */
    private boolean shouldTurnOffPhysicalChannelConfig() {
        // We should not turn off physical channel update if one of the following condition is true.
        // 1. The device is charging.
        // 2. When the screen is on.
        // 3. When data tethering is on.
        if (mIsCharging || mIsScreenOn || mIsTetheringOn) {
            return false;
        }

        // In all other cases, we turn off physical channel config update.
        return true;
        return shouldTurnOffHighPowerConsumptionIndications();
    }

    /**
     * @return True if BarryingInfo update should be turned off.
     */
    private boolean shouldTurnOffBarringInfo() {
        // We should not turn off BarringInfo update if one of the following condition is true.
        return shouldTurnOffHighPowerConsumptionIndications();
    }

    /**
     * A common policy to determine if we should turn off unnecessary indications for power saving.
     *
     * @return True if the response filter update should be turned off.
     */
    private boolean shouldTurnOffHighPowerConsumptionIndications() {
        // We should not turn off update if one of the following condition is true.
        // 1. The device is charging.
        // 2. When the screen is on.
        // 3. When the tethering is on.