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

Commit 2ff81f1e authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB] Finish cleaning up icon callbacks in SBIconController.

1) Deleted `removeAllIconsForSlot` which is actually unused.
2) I decided to not rename `setIcon` to `setInternalIcon` because it's
   used in so many places, so I just removed the TODO.

Fixes: 265307726
Test: atest StatusBarIconControllerImplTest
Change-Id: I88c8225e7bde05f1946ba9e7e819e2b76114204b
parent ecfd3ee5
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -81,11 +81,7 @@ public interface StatusBarIconController {
    /** Removes an icon that had come from an active tile service. */
    void removeIconForTile(String slot);

    /**
     * Adds or updates an icon for the given slot for **internal system icons**.
     *
     * TODO(b/265307726): Re-name this to `setInternalIcon`.
     */
    /** Adds or updates an icon for the given slot for **internal system icons**. */
    void setIcon(String slot, int resourceId, CharSequence contentDescription);

    /**
@@ -127,11 +123,6 @@ public interface StatusBarIconController {
     */
    void removeIcon(String slot, int tag);

    /**
     * TODO(b/265307726): Re-name this to `removeAllIconsForInternalSlot`.
     */
    void removeAllIconsForSlot(String slot);

    // TODO: See if we can rename this tunable name.
    String ICON_HIDE_LIST = "icon_blacklist";

+1 −7
Original line number Diff line number Diff line
@@ -385,13 +385,7 @@ public class StatusBarIconControllerImpl implements Tunable,
    }

    private void removeAllIconsForExternalSlot(String slotName) {
        removeAllIconsForSlot(createExternalSlotName(slotName));
    }

    /** */
    @Override
    public void removeAllIconsForSlot(String slotName) {
        removeAllIconsForSlot(slotName, /* fromNewPipeline */ false);
        removeAllIconsForSlot(createExternalSlotName(slotName), /* fromNewPipeline= */ false);
    }

    private void removeAllIconsForSlot(String slotName, boolean fromNewPipeline) {
+0 −24
Original line number Diff line number Diff line
@@ -218,30 +218,6 @@ class StatusBarIconControllerImplTest : SysuiTestCase() {
        verify(iconGroup).onRemoveIcon(1)
    }

    /** Regression test for b/255428281. */
    @Test
    fun internalAndExternalIconWithSameName_internalRemoved_viaRemoveAll_externalStays() {
        val slotName = "mute"

        // Internal
        underTest.setIcon(slotName, /* resourceId= */ 10, "contentDescription")

        // External
        underTest.setIconFromTile(slotName, createExternalIcon())

        // WHEN the internal icon is removed via #removeAllIconsForSlot
        underTest.removeAllIconsForSlot(slotName)

        // THEN the internal icon is removed but the external icon remains
        assertThat(iconList.slots).hasSize(2)
        assertThat(iconList.slots[0].name).isEqualTo(slotName + EXTERNAL_SLOT_SUFFIX)
        assertThat(iconList.slots[1].name).isEqualTo(slotName)
        assertThat(iconList.slots[0].hasIconsInSlot()).isTrue()
        assertThat(iconList.slots[1].hasIconsInSlot()).isFalse() // Indicates removal

        verify(iconGroup).onRemoveIcon(1)
    }

    /** Regression test for b/255428281. */
    @Test
    fun internalAndExternalIconWithSameName_internalUpdatedIndependently() {
+0 −28
Original line number Diff line number Diff line
@@ -120,34 +120,6 @@ public class StatusBarIconControllerTest extends LeakCheckedTest {
        verify(manager, never()).onRemoveIcon(anyInt());
    }

    @Test
    public void testRemoveAllIconsForSlot_ignoredForNewPipeline() {
        IconManager manager = mock(IconManager.class);

        // GIVEN the new pipeline is on
        StatusBarPipelineFlags flags = mock(StatusBarPipelineFlags.class);
        when(flags.isIconControlledByFlags("test_icon")).thenReturn(true);

        StatusBarIconController iconController = new StatusBarIconControllerImpl(
                mContext,
                mock(CommandQueue.class),
                mock(DemoModeController.class),
                mock(ConfigurationController.class),
                mock(TunerService.class),
                mock(DumpManager.class),
                mock(StatusBarIconList.class),
                flags
        );

        iconController.addIconGroup(manager);

        // WHEN a request to remove a new icon is sent
        iconController.removeAllIconsForSlot("test_icon");

        // THEN it is not removed for those icons
        verify(manager, never()).onRemoveIcon(anyInt());
    }

    private <T extends IconManager & TestableIconManager> void testCallOnAdd_forManager(T manager) {
        StatusBarIconHolder holder = holderForType(TYPE_ICON);
        manager.onIconAdded(0, "test_slot", false, holder);
+0 −4
Original line number Diff line number Diff line
@@ -83,10 +83,6 @@ public class FakeStatusBarIconController extends BaseLeakChecker<IconManager>
    public void removeIcon(String slot, int tag) {
    }

    @Override
    public void removeAllIconsForSlot(String slot) {
    }

    @Override
    public void setIconAccessibilityLiveRegion(String slot, int mode) {
    }