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

Commit ec9486b0 authored by Rambo Wang's avatar Rambo Wang Committed by Automerger Merge Worker
Browse files

Merge "DeviceStateMonitor: Rename indication filter "turn on" into "enable""...

Merge "DeviceStateMonitor: Rename indication filter "turn on" into "enable"" into rvc-dev am: 9eda55f0

Change-Id: Ifd72036f7fd911b22974bfb55947a506955c7d37
parents c3df6f1b 9eda55f0
Loading
Loading
Loading
Loading
+38 −32
Original line number Diff line number Diff line
@@ -308,10 +308,11 @@ public class DeviceStateMonitor extends Handler {
    }

    /**
     * @return True if signal strength update should be turned on.
     * @return True if signal strength update should be enabled. See details in
     *         android.hardware.radio@1.2::IndicationFilter::SIGNAL_STRENGTH.
     */
    private boolean shouldTurnOnSignalStrength() {
        // We should turn on signal strength update if one of the following condition is true.
    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
@@ -319,49 +320,54 @@ public class DeviceStateMonitor extends Handler {
    }

    /**
     * @return True if full network update should be turned on. When off, only significant changes
     * will trigger the network update unsolicited response.
     * @return True if full network state update should be enabled. When off, only significant
     *         changes will trigger the network update unsolicited response. See details in
     *         android.hardware.radio@1.2::IndicationFilter::FULL_NETWORK_STATE.
     */
    private boolean shouldTurnOnFullNetworkUpdate() {
        return shouldTurnOnHighPowerConsumptionIndications();
    private boolean shouldEnableFullNetworkStateReports() {
        return shouldEnableHighPowerConsumptionIndications();
    }

    /**
     * @return True if data dormancy status update should be turned on.
     * @return True if data call dormancy changed update should be enabled. See details in
     *         android.hardware.radio@1.2::IndicationFilter::DATA_CALL_DORMANCY_CHANGED.
     */
    private boolean shouldTurnOnDormancyUpdate() {
        return shouldTurnOnHighPowerConsumptionIndications();
    private boolean shouldEnableDataCallDormancyChangedReports() {
        return shouldEnableHighPowerConsumptionIndications();
    }

    /**
     * @return True if link capacity estimate update should be turned on.
     * @return True if link capacity estimate update should be enabled. See details in
     *         android.hardware.radio@1.2::IndicationFilter::LINK_CAPACITY_ESTIMATE.
     */
    private boolean shouldTurnOnLinkCapacityEstimate() {
        return shouldTurnOnHighPowerConsumptionIndications();
    private boolean shouldEnableLinkCapacityEstimateReports() {
        return shouldEnableHighPowerConsumptionIndications();
    }

    /**
     * @return True if physical channel config update should be turned on.
     * @return True if physical channel config update should be enabled. See details in
     *         android.hardware.radio@1.2::IndicationFilter::PHYSICAL_CHANNEL_CONFIG.
     */
    private boolean shouldTurnOnPhysicalChannelConfig() {
        return shouldTurnOnHighPowerConsumptionIndications();
    private boolean shouldEnablePhysicalChannelConfigReports() {
        return shouldEnableHighPowerConsumptionIndications();
    }

    /**
     * @return True if BarryingInfo update should be turned on.
     * @return True if barring info update should be enabled. See details in
     *         android.hardware.radio@1.5::IndicationFilter::BARRING_INFO.
     */
    private boolean shouldTurnOnBarringInfo() {
        return shouldTurnOnHighPowerConsumptionIndications();
    private boolean shouldEnableBarringInfoReports() {
        return shouldEnableHighPowerConsumptionIndications();
    }

    /**
     * A common policy to determine if we should turn on necessary indications,
     * A common policy to determine if we should enable the necessary indications update,
     * for power consumption's sake.
     *
     * @return True if the response filter update should be turned on.
     * @return True if the response update should be enabled.
     */
    private boolean shouldTurnOnHighPowerConsumptionIndications() {
        // We should turn on update if one of the following condition is true.
    private boolean shouldEnableHighPowerConsumptionIndications() {
        // We should enable indications reports 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.
@@ -414,7 +420,7 @@ public class DeviceStateMonitor extends Handler {
     * @param state True if enabled/on, otherwise disabled/off.
     */
    private void onUpdateDeviceState(int eventType, boolean state) {
        final boolean shouldTurnOnBarringInfoOld = shouldTurnOnBarringInfo();
        final boolean shouldEnableBarringInfoReportsOld = shouldEnableBarringInfoReports();
        switch (eventType) {
            case EVENT_SCREEN_STATE_CHANGED:
                if (mIsScreenOn == state) return;
@@ -459,35 +465,35 @@ public class DeviceStateMonitor extends Handler {
        }

        int newFilter = 0;
        if (shouldTurnOnSignalStrength()) {
        if (shouldEnableSignalStrengthReports()) {
            newFilter |= IndicationFilter.SIGNAL_STRENGTH;
        }

        if (shouldTurnOnFullNetworkUpdate()) {
        if (shouldEnableFullNetworkStateReports()) {
            newFilter |= IndicationFilter.FULL_NETWORK_STATE;
        }

        if (shouldTurnOnDormancyUpdate()) {
        if (shouldEnableDataCallDormancyChangedReports()) {
            newFilter |= IndicationFilter.DATA_CALL_DORMANCY_CHANGED;
        }

        if (shouldTurnOnLinkCapacityEstimate()) {
        if (shouldEnableLinkCapacityEstimateReports()) {
            newFilter |= IndicationFilter.LINK_CAPACITY_ESTIMATE;
        }

        if (shouldTurnOnPhysicalChannelConfig()) {
        if (shouldEnablePhysicalChannelConfigReports()) {
            newFilter |= IndicationFilter.PHYSICAL_CHANNEL_CONFIG;
        }

        final boolean shouldTurnOnBarringInfo = shouldTurnOnBarringInfo();
        if (shouldTurnOnBarringInfo) {
        final boolean shouldEnableBarringInfoReports = shouldEnableBarringInfoReports();
        if (shouldEnableBarringInfoReports) {
            newFilter |= IndicationFilter.BARRING_INFO;
        }

        setUnsolResponseFilter(newFilter, false);

        // Pull barring info AFTER setting filter, the order matters
        if (shouldTurnOnBarringInfo && !shouldTurnOnBarringInfoOld) {
        if (shouldEnableBarringInfoReports && !shouldEnableBarringInfoReportsOld) {
            if (DBG) log("Manually pull barring info...", true);
            // use a null message since we don't care of receiving response
            mPhone.mCi.getBarringInfo(null);