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

Commit 738b3438 authored by Coco Duan's avatar Coco Duan Committed by Android (Google) Code Review
Browse files

Merge "Back up glanceable hub enabled setting" into main

parents b8f7f8d3 53184d9a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -10224,6 +10224,13 @@ public final class Settings {
        public static final String SCREENSAVER_COMPLICATIONS_ENABLED =
                "screensaver_complications_enabled";
        /**
         * Defines the enabled state for the glanceable hub.
         *
         * @hide
         */
        public static final String GLANCEABLE_HUB_ENABLED = "glanceable_hub_enabled";
        /**
         * Whether home controls are enabled to be shown over the screensaver by the user.
         *
+1 −0
Original line number Diff line number Diff line
@@ -258,6 +258,7 @@ public class SecureSettings {
        Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED,
        Settings.Secure.SEARCH_ALL_ENTRYPOINTS_ENABLED,
        Settings.Secure.HUB_MODE_TUTORIAL_STATE,
        Settings.Secure.GLANCEABLE_HUB_ENABLED,
        Settings.Secure.STYLUS_BUTTONS_ENABLED,
        Settings.Secure.STYLUS_HANDWRITING_ENABLED,
        Settings.Secure.DEFAULT_NOTE_TASK_PROFILE,
+1 −0
Original line number Diff line number Diff line
@@ -416,6 +416,7 @@ public class SecureSettingsValidators {
                BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.DND_CONFIGS_MIGRATED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.HUB_MODE_TUTORIAL_STATE, NON_NEGATIVE_INTEGER_VALIDATOR);
        VALIDATORS.put(Secure.GLANCEABLE_HUB_ENABLED, new InclusiveIntegerRangeValidator(0, 1));
        VALIDATORS.put(Secure.STYLUS_BUTTONS_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.STYLUS_HANDWRITING_ENABLED,
                new DiscreteValueValidator(new String[] {"-1", "0", "1"}));
+21 −5
Original line number Diff line number Diff line
@@ -25,13 +25,13 @@ import android.content.Intent
import android.content.pm.UserInfo
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.provider.Settings
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_COMMUNAL_HUB
import com.android.systemui.SysuiTestCase
import com.android.systemui.broadcast.broadcastDispatcher
import com.android.systemui.communal.data.model.DisabledReason
import com.android.systemui.communal.data.repository.CommunalSettingsRepositoryImpl.Companion.GLANCEABLE_HUB_ENABLED
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED
import com.android.systemui.flags.fakeFeatureFlagsClassic
@@ -95,15 +95,27 @@ class CommunalSettingsRepositoryImplTest : SysuiTestCase() {
    @Test
    fun hubIsDisabledByUser() =
        testScope.runTest {
            kosmos.fakeSettings.putIntForUser(GLANCEABLE_HUB_ENABLED, 0, PRIMARY_USER.id)
            kosmos.fakeSettings.putIntForUser(
                Settings.Secure.GLANCEABLE_HUB_ENABLED,
                0,
                PRIMARY_USER.id
            )
            val enabledState by collectLastValue(underTest.getEnabledState(PRIMARY_USER))
            assertThat(enabledState?.enabled).isFalse()
            assertThat(enabledState).containsExactly(DisabledReason.DISABLED_REASON_USER_SETTING)

            kosmos.fakeSettings.putIntForUser(GLANCEABLE_HUB_ENABLED, 1, SECONDARY_USER.id)
            kosmos.fakeSettings.putIntForUser(
                Settings.Secure.GLANCEABLE_HUB_ENABLED,
                1,
                SECONDARY_USER.id
            )
            assertThat(enabledState?.enabled).isFalse()

            kosmos.fakeSettings.putIntForUser(GLANCEABLE_HUB_ENABLED, 1, PRIMARY_USER.id)
            kosmos.fakeSettings.putIntForUser(
                Settings.Secure.GLANCEABLE_HUB_ENABLED,
                1,
                PRIMARY_USER.id
            )
            assertThat(enabledState?.enabled).isTrue()
        }

@@ -126,7 +138,11 @@ class CommunalSettingsRepositoryImplTest : SysuiTestCase() {
            val enabledState by collectLastValue(underTest.getEnabledState(PRIMARY_USER))
            assertThat(enabledState?.enabled).isTrue()

            kosmos.fakeSettings.putIntForUser(GLANCEABLE_HUB_ENABLED, 0, PRIMARY_USER.id)
            kosmos.fakeSettings.putIntForUser(
                Settings.Secure.GLANCEABLE_HUB_ENABLED,
                0,
                PRIMARY_USER.id
            )
            setKeyguardFeaturesDisabled(PRIMARY_USER, KEYGUARD_DISABLE_WIDGETS_ALL)

            assertThat(enabledState?.enabled).isFalse()
+6 −2
Original line number Diff line number Diff line
@@ -19,11 +19,11 @@ package com.android.systemui.communal.widgets
import android.appwidget.AppWidgetProviderInfo
import android.content.pm.UserInfo
import android.os.UserHandle
import android.provider.Settings
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_COMMUNAL_HUB
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.repository.CommunalSettingsRepositoryImpl.Companion.GLANCEABLE_HUB_ENABLED
import com.android.systemui.communal.data.repository.fakeCommunalWidgetRepository
import com.android.systemui.communal.domain.interactor.communalInteractor
import com.android.systemui.communal.shared.model.CommunalWidgetContentModel
@@ -220,7 +220,11 @@ class CommunalAppWidgetHostStartableTest : SysuiTestCase() {
            fakeUserRepository.setSelectedUserInfo(MAIN_USER_INFO)
            fakeKeyguardRepository.setKeyguardShowing(true)
            val settingsValue = if (available) 1 else 0
            fakeSettings.putIntForUser(GLANCEABLE_HUB_ENABLED, settingsValue, MAIN_USER_INFO.id)
            fakeSettings.putIntForUser(
                Settings.Secure.GLANCEABLE_HUB_ENABLED,
                settingsValue,
                MAIN_USER_INFO.id
            )
        }

    private fun createWidgetForUser(appWidgetId: Int, userId: Int): CommunalWidgetContentModel =
Loading