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

Commit a206f653 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Early return when state has not changed

Test: manual
Fixes: 145463139
Change-Id: I9a9116165f9d50215ae8882275d715e7ad9a19b2
parent c5f436ec
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import com.android.settingslib.graph.SignalDrawable;
import com.android.systemui.DualToneHandler;
import com.android.systemui.R;

import java.util.Objects;

public class QSCarrier extends LinearLayout {

    private View mMobileGroup;
@@ -39,6 +41,7 @@ public class QSCarrier extends LinearLayout {
    private DualToneHandler mDualToneHandler;
    private ColorStateList mColorForegroundStateList;
    private float mColorForegroundIntensity;
    private QSCarrierGroupController.CellSignalState mLastSignalState;

    public QSCarrier(Context context) {
        super(context);
@@ -74,6 +77,8 @@ public class QSCarrier extends LinearLayout {
    }

    public void updateState(QSCarrierGroupController.CellSignalState state) {
        if (Objects.equals(state, mLastSignalState)) return;
        mLastSignalState = state;
        mMobileGroup.setVisibility(state.visible ? View.VISIBLE : View.GONE);
        if (state.visible) {
            mMobileRoaming.setVisibility(state.roaming ? View.VISIBLE : View.GONE);
+23 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import com.android.keyguard.CarrierTextController;
@@ -37,6 +38,7 @@ import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.statusbar.policy.NetworkController;

import java.util.Objects;
import java.util.function.Consumer;

import javax.inject.Inject;
@@ -297,6 +299,27 @@ public class QSCarrierGroupController {
        String contentDescription;
        String typeContentDescription;
        boolean roaming;

        @Override
        public boolean equals(@Nullable Object obj) {
            if (this == obj) return true;
            if (!(obj instanceof CellSignalState)) return false;
            CellSignalState other = (CellSignalState) obj;
            return this.visible == other.visible
                    && this.mobileSignalIconId == other.mobileSignalIconId
                    && Objects.equals(this.contentDescription, other.contentDescription)
                    && Objects.equals(this.typeContentDescription, other.typeContentDescription)
                    && this.roaming == other.roaming;
        }

        @Override
        public int hashCode() {
            return Objects.hash(visible,
                    mobileSignalIconId,
                    contentDescription,
                    typeContentDescription,
                    roaming);
        }
    }

    public static class Builder {