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

Commit 89bc7353 authored by Peiyong Lin's avatar Peiyong Lin
Browse files

Show the footer when global switch is off.

In the original implementation we showed a footer when global switch is off,
however, this was broken due to some refactor. This patch fixes the issue where
we don't set the visibility of the footer when global switch is on/off.

Bug: b/148626177
Test: make RunSettingsRoboTests ROBOTEST_FILTER=GraphicsDriver
Change-Id: I0f0763ee1551199cc8611c650350a2adbdf402ed
parent 54114d78
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.Looper;
import android.provider.Settings;

import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;

import com.android.settings.core.BasePreferenceController;
@@ -79,6 +80,12 @@ public class GraphicsDriverFooterPreferenceController extends BasePreferenceCont
        mGraphicsDriverContentObserver.unregister(mContentResolver);
    }

    @Override
    public void updateState(Preference preference) {
        final FooterPreference footerPref = (FooterPreference) preference;
        footerPref.setVisible(isAvailable());
    }

    @Override
    public void onGraphicsDriverContentChanged() {
        updateState(mPreference);
+16 −0
Original line number Diff line number Diff line
@@ -105,4 +105,20 @@ public class GraphicsDriverFooterPreferenceControllerTest {

        verify(mGraphicsDriverContentObserver).unregister(mResolver);
    }

    @Test
    public void updateState_available_visible() {
        when(mController.getAvailabilityStatus()).thenReturn(AVAILABLE_UNSEARCHABLE);
        mController.updateState(mPreference);

        verify(mPreference).setVisible(true);
    }

    @Test
    public void updateState_unavailable_invisible() {
        when(mController.getAvailabilityStatus()).thenReturn(CONDITIONALLY_UNAVAILABLE);
        mController.updateState(mPreference);

        verify(mPreference).setVisible(false);
    }
}