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

Commit 567b0f61 authored by Matt Pietal's avatar Matt Pietal
Browse files

Controls UI - Do not save empty structures

We currently save state for all structures. If no controls are
contained, there is no need to store the structure in the favorites
file.

Bug: 151137318
Test: atest ControlsControllerImplTest
Change-Id: I8b604c9321118e3f349d779bbdfaf6138b3557fb
parent 4a4e1e45
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -489,10 +489,12 @@ private object Favorites {
                updatedStructure
            } else { s }

            if (!newStructure.controls.isEmpty()) {
                structures.add(newStructure)
            }
        }

        if (!replaced) {
        if (!replaced && !updatedStructure.controls.isEmpty()) {
            structures.add(updatedStructure)
        }

+11 −1
Original line number Diff line number Diff line
@@ -521,7 +521,7 @@ class ControlsControllerImplTest : SysuiTestCase() {
    }

    @Test
    fun testReplaceFavoritesForStructure_noFavorites() {
    fun testReplaceFavoritesForStructure_noExistingFavorites() {
        controller.replaceFavoritesForStructure(TEST_STRUCTURE_INFO)
        delayableExecutor.runAllReady()

@@ -530,6 +530,16 @@ class ControlsControllerImplTest : SysuiTestCase() {
            controller.getFavoritesForComponent(TEST_COMPONENT))
    }

    @Test
    fun testReplaceFavoritesForStructure_doNotStoreEmptyStructure() {
        controller.replaceFavoritesForStructure(
            StructureInfo(TEST_COMPONENT, "Home", emptyList<ControlInfo>()))
        delayableExecutor.runAllReady()

        assertEquals(0, controller.countFavoritesForComponent(TEST_COMPONENT))
        assertEquals(emptyList<ControlInfo>(), controller.getFavoritesForComponent(TEST_COMPONENT))
    }

    @Test
    fun testReplaceFavoritesForStructure_differentComponentsAreFilteredOut() {
        controller.replaceFavoritesForStructure(TEST_STRUCTURE_INFO)