Loading core/java/android/app/Notification.java +6 −1 Original line number Diff line number Diff line Loading @@ -6595,6 +6595,11 @@ public class Notification implements Parcelable * @hide */ public RemoteViews createCompactHeadsUpContentView() { // Don't show compact heads up for FSI notifications. if (mN.fullScreenIntent != null) { return createHeadsUpContentView(/* increasedHeight= */ false); } if (mStyle != null) { final RemoteViews styleView = mStyle.makeCompactHeadsUpContentView(); if (styleView != null) { Loading Loading @@ -10352,7 +10357,7 @@ public class Notification implements Parcelable @Nullable @Override public RemoteViews makeCompactHeadsUpContentView() { // TODO(b/336228700): Apply minimal HUN treatment for Call Style. // Use existing heads up for call style. return makeHeadsUpContentView(false); } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/row/HeadsUpStyleProvider.kt +10 −6 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.notification.row import android.app.Flags import com.android.systemui.statusbar.data.repository.StatusBarModeRepositoryStore import javax.inject.Inject /** Loading @@ -27,11 +28,14 @@ interface HeadsUpStyleProvider { fun shouldApplyCompactStyle(): Boolean } class HeadsUpStyleProviderImpl @Inject constructor() : HeadsUpStyleProvider { class HeadsUpStyleProviderImpl @Inject constructor(private val statusBarModeRepositoryStore: StatusBarModeRepositoryStore) : HeadsUpStyleProvider { /** * TODO(b/270709257) This feature is under development. This method returns Compact when the * flag is enabled for fish fooding purpose. */ override fun shouldApplyCompactStyle(): Boolean = Flags.compactHeadsUpNotification() override fun shouldApplyCompactStyle(): Boolean { // Use compact HUN for immersive mode. return Flags.compactHeadsUpNotification() && statusBarModeRepositoryStore.defaultDisplay.isInFullscreenMode.value } } packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/HeadsUpStyleProviderImplTest.kt 0 → 100644 +75 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.notification.row import android.app.Flags.FLAG_COMPACT_HEADS_UP_NOTIFICATION import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.SetFlagsRule import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.statusbar.data.repository.FakeStatusBarModeRepository import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidTestingRunner::class) class HeadsUpStyleProviderImplTest : SysuiTestCase() { @Rule @JvmField val setFlagsRule = SetFlagsRule() private lateinit var statusBarModeRepositoryStore: FakeStatusBarModeRepository private lateinit var headsUpStyleProvider: HeadsUpStyleProviderImpl @Before fun setUp() { statusBarModeRepositoryStore = FakeStatusBarModeRepository() statusBarModeRepositoryStore.defaultDisplay.isInFullscreenMode.value = true headsUpStyleProvider = HeadsUpStyleProviderImpl(statusBarModeRepositoryStore) } @Test @DisableFlags(FLAG_COMPACT_HEADS_UP_NOTIFICATION) fun shouldApplyCompactStyle_returnsFalse_whenCompactFlagDisabled() { assertThat(headsUpStyleProvider.shouldApplyCompactStyle()).isFalse() } @Test @EnableFlags(FLAG_COMPACT_HEADS_UP_NOTIFICATION) fun shouldApplyCompactStyle_returnsTrue_whenImmersiveModeEnabled() { // GIVEN statusBarModeRepositoryStore.defaultDisplay.isInFullscreenMode.value = true // THEN assertThat(headsUpStyleProvider.shouldApplyCompactStyle()).isTrue() } @Test @EnableFlags(FLAG_COMPACT_HEADS_UP_NOTIFICATION) fun shouldApplyCompactStyle_returnsFalse_whenImmersiveModeDisabled() { // GIVEN statusBarModeRepositoryStore.defaultDisplay.isInFullscreenMode.value = false // THEN assertThat(headsUpStyleProvider.shouldApplyCompactStyle()).isFalse() } } Loading
core/java/android/app/Notification.java +6 −1 Original line number Diff line number Diff line Loading @@ -6595,6 +6595,11 @@ public class Notification implements Parcelable * @hide */ public RemoteViews createCompactHeadsUpContentView() { // Don't show compact heads up for FSI notifications. if (mN.fullScreenIntent != null) { return createHeadsUpContentView(/* increasedHeight= */ false); } if (mStyle != null) { final RemoteViews styleView = mStyle.makeCompactHeadsUpContentView(); if (styleView != null) { Loading Loading @@ -10352,7 +10357,7 @@ public class Notification implements Parcelable @Nullable @Override public RemoteViews makeCompactHeadsUpContentView() { // TODO(b/336228700): Apply minimal HUN treatment for Call Style. // Use existing heads up for call style. return makeHeadsUpContentView(false); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/HeadsUpStyleProvider.kt +10 −6 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.notification.row import android.app.Flags import com.android.systemui.statusbar.data.repository.StatusBarModeRepositoryStore import javax.inject.Inject /** Loading @@ -27,11 +28,14 @@ interface HeadsUpStyleProvider { fun shouldApplyCompactStyle(): Boolean } class HeadsUpStyleProviderImpl @Inject constructor() : HeadsUpStyleProvider { class HeadsUpStyleProviderImpl @Inject constructor(private val statusBarModeRepositoryStore: StatusBarModeRepositoryStore) : HeadsUpStyleProvider { /** * TODO(b/270709257) This feature is under development. This method returns Compact when the * flag is enabled for fish fooding purpose. */ override fun shouldApplyCompactStyle(): Boolean = Flags.compactHeadsUpNotification() override fun shouldApplyCompactStyle(): Boolean { // Use compact HUN for immersive mode. return Flags.compactHeadsUpNotification() && statusBarModeRepositoryStore.defaultDisplay.isInFullscreenMode.value } }
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/HeadsUpStyleProviderImplTest.kt 0 → 100644 +75 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.notification.row import android.app.Flags.FLAG_COMPACT_HEADS_UP_NOTIFICATION import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.SetFlagsRule import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.statusbar.data.repository.FakeStatusBarModeRepository import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidTestingRunner::class) class HeadsUpStyleProviderImplTest : SysuiTestCase() { @Rule @JvmField val setFlagsRule = SetFlagsRule() private lateinit var statusBarModeRepositoryStore: FakeStatusBarModeRepository private lateinit var headsUpStyleProvider: HeadsUpStyleProviderImpl @Before fun setUp() { statusBarModeRepositoryStore = FakeStatusBarModeRepository() statusBarModeRepositoryStore.defaultDisplay.isInFullscreenMode.value = true headsUpStyleProvider = HeadsUpStyleProviderImpl(statusBarModeRepositoryStore) } @Test @DisableFlags(FLAG_COMPACT_HEADS_UP_NOTIFICATION) fun shouldApplyCompactStyle_returnsFalse_whenCompactFlagDisabled() { assertThat(headsUpStyleProvider.shouldApplyCompactStyle()).isFalse() } @Test @EnableFlags(FLAG_COMPACT_HEADS_UP_NOTIFICATION) fun shouldApplyCompactStyle_returnsTrue_whenImmersiveModeEnabled() { // GIVEN statusBarModeRepositoryStore.defaultDisplay.isInFullscreenMode.value = true // THEN assertThat(headsUpStyleProvider.shouldApplyCompactStyle()).isTrue() } @Test @EnableFlags(FLAG_COMPACT_HEADS_UP_NOTIFICATION) fun shouldApplyCompactStyle_returnsFalse_whenImmersiveModeDisabled() { // GIVEN statusBarModeRepositoryStore.defaultDisplay.isInFullscreenMode.value = false // THEN assertThat(headsUpStyleProvider.shouldApplyCompactStyle()).isFalse() } }