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

Commit e9f4fdcc authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB] Remove launched status_bar_signal_policy_refactor_ethernet.

Bug: 291321279
Flag: EXEMPT cleanup
Test: SysUI status bar icons still work
Test: atest StatusBarSignalPolicyTest
Change-Id: I3f98d0dc836537de1947becd7afc048eafa07ded
parent 542a3368
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -398,13 +398,6 @@ flag {
   bug: "264539100"
}

flag {
   name: "status_bar_signal_policy_refactor_ethernet"
   namespace: "systemui"
   description: "Use recommended architecture for ethernet icon in status bar"
   bug: "291321279"
}

flag {
  name: "status_bar_system_status_icons_in_compose"
  namespace: "systemui"
+1 −71
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import com.android.systemui.statusbar.phone.StatusBarSignalPolicy
import com.android.systemui.statusbar.phone.ui.StatusBarIconController
import com.android.systemui.statusbar.pipeline.airplane.domain.interactor.airplaneModeInteractor
import com.android.systemui.statusbar.pipeline.ethernet.domain.ethernetInteractor
import com.android.systemui.statusbar.pipeline.ethernet.shared.StatusBarSignalPolicyRefactorEthernet
import com.android.systemui.statusbar.pipeline.shared.data.repository.connectivityRepository
import com.android.systemui.statusbar.pipeline.shared.data.repository.fake
import com.android.systemui.statusbar.policy.SecurityController
@@ -164,76 +163,7 @@ class StatusBarSignalPolicyTest : SysuiTestCase() {

    @Test
    @EnableFlags(FLAG_STATUS_BAR_SIGNAL_POLICY_REFACTOR)
    @DisableFlags(StatusBarSignalPolicyRefactorEthernet.FLAG_NAME)
    fun ethernetIconViaSignalCallback_refactorFlagDisabled_iconUpdated() =
        kosmos.runTest {
            underTest.start()
            clearInvocations(statusBarIconController)

            underTest.setEthernetIndicators(
                IconState(/* visible= */ true, /* icon= */ 1, /* contentDescription= */ "Ethernet")
            )
            verify(statusBarIconController).setIconVisibility(slotEthernet, true)

            underTest.setEthernetIndicators(
                IconState(
                    /* visible= */ false,
                    /* icon= */ 0,
                    /* contentDescription= */ "No ethernet",
                )
            )
            verify(statusBarIconController).setIconVisibility(slotEthernet, false)
        }

    @Test
    @EnableFlags(
        FLAG_STATUS_BAR_SIGNAL_POLICY_REFACTOR,
        StatusBarSignalPolicyRefactorEthernet.FLAG_NAME,
    )
    fun ethernetIconViaSignalCallback_refactorFlagEnabled_iconNotUpdated() =
        kosmos.runTest {
            underTest.start()
            clearInvocations(statusBarIconController)

            underTest.setEthernetIndicators(
                IconState(/* visible= */ true, /* icon= */ 1, /* contentDescription= */ "Ethernet")
            )
            verify(statusBarIconController, never()).setIconVisibility(eq(slotEthernet), any())

            underTest.setEthernetIndicators(
                IconState(
                    /* visible= */ false,
                    /* icon= */ 0,
                    /* contentDescription= */ "No ethernet",
                )
            )
            verify(statusBarIconController, never()).setIconVisibility(eq(slotEthernet), any())
        }

    @Test
    @EnableFlags(FLAG_STATUS_BAR_SIGNAL_POLICY_REFACTOR)
    @DisableFlags(StatusBarSignalPolicyRefactorEthernet.FLAG_NAME)
    fun ethernetIconViaInteractor_refactorFlagDisabled_iconNotUpdated() =
        kosmos.runTest {
            underTest.start()
            clearInvocations(statusBarIconController)

            connectivityRepository.fake.setEthernetConnected(default = true, validated = true)
            verify(statusBarIconController, never()).setIconVisibility(eq(slotEthernet), any())

            connectivityRepository.fake.setEthernetConnected(default = false, validated = false)
            verify(statusBarIconController, never()).setIconVisibility(eq(slotEthernet), any())

            connectivityRepository.fake.setEthernetConnected(default = true, validated = false)
            verify(statusBarIconController, never()).setIconVisibility(eq(slotEthernet), any())
        }

    @Test
    @EnableFlags(
        FLAG_STATUS_BAR_SIGNAL_POLICY_REFACTOR,
        StatusBarSignalPolicyRefactorEthernet.FLAG_NAME,
    )
    fun ethernetIconViaInteractor_refactorFlagEnabled_iconUpdated() =
    fun ethernetIconViaInteractor_iconUpdated() =
        kosmos.runTest {
            underTest.start()
            clearInvocations(statusBarIconController)
+2 −28
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import com.android.systemui.statusbar.connectivity.SignalCallback;
import com.android.systemui.statusbar.phone.ui.StatusBarIconController;
import com.android.systemui.statusbar.pipeline.airplane.domain.interactor.AirplaneModeInteractor;
import com.android.systemui.statusbar.pipeline.ethernet.domain.EthernetInteractor;
import com.android.systemui.statusbar.pipeline.ethernet.shared.StatusBarSignalPolicyRefactorEthernet;
import com.android.systemui.statusbar.policy.SecurityController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
@@ -113,10 +112,8 @@ public class StatusBarSignalPolicy

        mJavaAdapter.alwaysCollectFlow(
                mAirplaneModeInteractor.isAirplaneMode(), this::updateAirplaneModeIcon);
        if (StatusBarSignalPolicyRefactorEthernet.isEnabled()) {
        mJavaAdapter.alwaysCollectFlow(mEthernetInteractor.getIcon(), this::updateEthernetIcon);
    }
    }

    /** Call to initialize and register this class with the system. */
    public void init() {
@@ -133,10 +130,8 @@ public class StatusBarSignalPolicy
                    mAirplaneModeInteractor.isAirplaneMode(),
                    this::updateAirplaneModeIcon);
        }
        if (StatusBarSignalPolicyRefactorEthernet.isEnabled()) {
        mJavaAdapter.alwaysCollectFlow(mEthernetInteractor.getIcon(), this::updateEthernetIcon);
    }
    }

    public void destroy() {
        mTunerService.removeTunable(this);
@@ -196,28 +191,7 @@ public class StatusBarSignalPolicy
        }
    }

    @Override
    public void setEthernetIndicators(IconState state) {
        if (StatusBarSignalPolicyRefactorEthernet.isEnabled()) {
            return;
        }

        int resId = state.icon;
        String description = state.contentDescription;

        if (resId > 0) {
            mIconController.setIcon(mSlotEthernet, resId, description);
            mIconController.setIconVisibility(mSlotEthernet, true);
        } else {
            mIconController.setIconVisibility(mSlotEthernet, false);
        }
    }

    private void updateEthernetIcon(@Nullable Icon.Resource ethernetIcon) {
        if (StatusBarSignalPolicyRefactorEthernet.isUnexpectedlyInLegacyMode()) {
            return;
        }

        if (ethernetIcon != null) {
            mIconController.setIcon(
                    mSlotEthernet,
+0 −63
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.statusbar.pipeline.ethernet.shared

import com.android.systemui.Flags
import com.android.systemui.flags.FlagToken
import com.android.systemui.flags.RefactorFlagUtils

/** Helper for reading or using the status bar signal policy refactor ethernet flag state. */
@Suppress("NOTHING_TO_INLINE")
object StatusBarSignalPolicyRefactorEthernet {
    /** The aconfig flag name */
    const val FLAG_NAME = Flags.FLAG_STATUS_BAR_SIGNAL_POLICY_REFACTOR_ETHERNET

    /** A token used for dependency declaration */
    val token: FlagToken
        get() = FlagToken(FLAG_NAME, isEnabled)

    /** Is the refactor enabled */
    @JvmStatic
    inline val isEnabled
        get() = Flags.statusBarSignalPolicyRefactorEthernet()

    /**
     * Called to ensure code is only run when the flag is enabled. This protects users from the
     * unintended behaviors caused by accidentally running new logic, while also crashing on an eng
     * build to ensure that the refactor author catches issues in testing.
     */
    @JvmStatic
    inline fun isUnexpectedlyInLegacyMode() =
        RefactorFlagUtils.isUnexpectedlyInLegacyMode(isEnabled, FLAG_NAME)

    /**
     * Called to ensure code is only run when the flag is enabled. This will throw an exception if
     * the flag is not enabled to ensure that the refactor author catches issues in testing.
     * Caution!! Using this check incorrectly will cause crashes in nextfood builds!
     */
    @JvmStatic
    @Deprecated("Avoid crashing.", ReplaceWith("if (this.isUnexpectedlyInLegacyMode()) return"))
    inline fun unsafeAssertInNewMode() =
        RefactorFlagUtils.unsafeAssertInNewMode(isEnabled, FLAG_NAME)

    /**
     * Called to ensure code is only run when the flag is disabled. This will throw an exception if
     * the flag is enabled to ensure that the refactor author catches issues in testing.
     */
    @JvmStatic
    inline fun assertInLegacyMode() = RefactorFlagUtils.assertInLegacyMode(isEnabled, FLAG_NAME)
}