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

Commit 49979214 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Dual Shade] Disable Split Shade in Flexiglass using a config." into main

parents 4f325aa3 f2c89e58
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -56,11 +56,12 @@ class CommunalUserActionsViewModelTest : SysuiTestCase() {

    private val kosmos = testKosmos().useUnconfinedTestDispatcher()

    private lateinit var underTest: CommunalUserActionsViewModel
    private val underTest: CommunalUserActionsViewModel by lazy {
        kosmos.communalUserActionsViewModel
    }

    @Before
    fun setUp() {
        underTest = kosmos.communalUserActionsViewModel
        underTest.activateIn(kosmos.testScope)
    }

+33 −0
Original line number Diff line number Diff line
@@ -16,13 +16,16 @@

package com.android.systemui.shade.domain.interactor

import android.content.testableContext
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.runTest
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.res.R
import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
@@ -57,6 +60,36 @@ class ShadeModeInteractorImplTest : SysuiTestCase() {
            assertThat(shadeMode).isEqualTo(ShadeMode.Split)
        }

    @Test
    fun legacyShadeMode_disableSplitShade_wideScreen_dualShade() =
        kosmos.runTest {
            enableSplitShade()
            testableContext.orCreateTestableResources.addOverride(
                R.bool.config_disableSplitShade,
                true,
            )
            fakeConfigurationRepository.onAnyConfigurationChange()

            val shadeMode by collectLastValue(underTest.shadeMode)

            assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
        }

    @Test
    fun legacyShadeMode_disableSplitShade_narrowScreen_singleShade() =
        kosmos.runTest {
            val shadeMode by collectLastValue(underTest.shadeMode)
            enableSingleShade()

            testableContext.orCreateTestableResources.addOverride(
                R.bool.config_disableSplitShade,
                true,
            )
            fakeConfigurationRepository.onAnyConfigurationChange()

            assertThat(shadeMode).isEqualTo(ShadeMode.Single)
        }

    @Test
    fun shadeMode_wideScreen_isDual() =
        kosmos.runTest {
+5 −2
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.os.Looper;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.testing.TestableLooper.RunWithLooper;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
@@ -341,10 +342,11 @@ public class NotificationContentInflaterTest extends SysuiTestCase {
    @Test
    @Ignore
    public void testNotificationViewHeightTooSmallFailsValidation() {
        DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
        View view = mock(View.class);
        when(view.getHeight())
                .thenReturn((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 10,
                        mContext.getResources().getDisplayMetrics()));
                        displayMetrics));
        String result = NotificationContentInflater.isValidView(view, mEntry,
                mContext.getResources());
        assertNotNull(result);
@@ -352,10 +354,11 @@ public class NotificationContentInflaterTest extends SysuiTestCase {

    @Test
    public void testNotificationViewPassesValidation() {
        DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
        View view = mock(View.class);
        when(view.getHeight())
                .thenReturn((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 17,
                        mContext.getResources().getDisplayMetrics()));
                        displayMetrics));
        String result = NotificationContentInflater.isValidView(view, mEntry,
                mContext.getResources());
        assertNull(result);
+4 −0
Original line number Diff line number Diff line
@@ -689,6 +689,10 @@
    <!-- TODO(b/411449027): This config is deprecated. Remove with the launch of SceneContainer. -->
    <bool name="force_config_use_split_notification_shade">false</bool>

    <!-- Whether to disable split shade on this configuration, and use dual shade instead. -->
    <!-- TODO(b/411449027): Remove this config once it is true on all configurations. -->
    <bool name="config_disableSplitShade">false</bool>

    <!-- Whether we use large screen shade header which takes only one row compared to QS header -->
    <bool name="config_use_large_screen_shade_header">false</bool>

+11 −5
Original line number Diff line number Diff line
@@ -16,13 +16,15 @@

package com.android.systemui.shade.domain.interactor

import android.content.Context
import android.provider.Settings
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.log.table.logDiffsForTable
import com.android.systemui.res.R
import com.android.systemui.scene.domain.SceneFrameworkTableLog
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.shade.data.repository.ShadeRepository
import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.shared.settings.data.repository.SecureSettingsRepository
@@ -73,8 +75,9 @@ interface ShadeModeInteractor {
class ShadeModeInteractorImpl
@Inject
constructor(
    @Application applicationScope: CoroutineScope,
    @Background applicationScope: CoroutineScope,
    @Background backgroundDispatcher: CoroutineDispatcher,
    @ShadeDisplayAware private val context: Context,
    private val repository: ShadeRepository,
    secureSettingsRepository: SecureSettingsRepository,
    @SceneFrameworkTableLog private val tableLogBuffer: TableLogBuffer,
@@ -109,9 +112,12 @@ constructor(
    ): ShadeMode {
        return when {
            isDualShadeEnabled -> ShadeMode.Dual
            // TODO(b/376411622): Once Dual Shade is enabled by default in SceneContainer, replace
            //  Split below with Dual. This will effectively remove Split mode from SceneContainer.
            isShadeLayoutWide -> ShadeMode.Split
            isShadeLayoutWide ->
                if (context.resources.getBoolean(R.bool.config_disableSplitShade)) {
                    ShadeMode.Dual
                } else {
                    ShadeMode.Split
                }
            else -> ShadeMode.Single
        }
    }
Loading