summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/compose/facade/disabled/src/com/android/systemui/volume/panel/component/anc/AncModule21
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/statusbar/phone/SystemUIDialogFactoryExt.kt6
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/anc/AncModule.kt53
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/anc/ui/composable/AncPopup.kt109
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ButtonComponent.kt80
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ToggleButtonComponent.kt2
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/popup/ui/composable/VolumePanelPopup.kt110
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/anc/data/repository/AncSliceRepositoryTest.kt114
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/anc/domain/AncAvailabilityCriteriaTest.kt89
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/anc/domain/interactor/AncSliceInteractorTest.kt101
-rw-r--r--packages/SystemUI/res/drawable/ic_noise_aware.xml26
-rw-r--r--packages/SystemUI/res/layout/anc_slice.xml20
-rw-r--r--packages/SystemUI/res/values/strings.xml3
-rw-r--r--packages/SystemUI/res/values/styles.xml6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ComponentSystemUIDialog.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialogFactory.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/dagger/AncModule.kt40
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/dagger/VolumeModule.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/data/repository/AncSliceRepository.kt118
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/domain/AncAvailabilityCriteria.kt35
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/domain/interactor/AncSliceInteractor.kt75
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/ui/viewmodel/AncViewModel.kt61
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/panel/component/button/ui/viewmodel/ButtonViewModel.kt25
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/panel/component/shared/model/VolumePanelComponents.kt1
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/panel/dagger/VolumePanelComponent.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/panel/domain/DomainModule.kt1
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/panel/ui/UiModule.kt3
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/anc/FakeSliceFactory.kt51
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/anc/VolumePanelAncKosmos.kt29
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/anc/data/repository/FakeAncSliceRepository.kt33
30 files changed, 2 insertions, 1221 deletions
diff --git a/packages/SystemUI/compose/facade/disabled/src/com/android/systemui/volume/panel/component/anc/AncModule b/packages/SystemUI/compose/facade/disabled/src/com/android/systemui/volume/panel/component/anc/AncModule
deleted file mode 100644
index a4fb05d3b5b9..000000000000
--- a/packages/SystemUI/compose/facade/disabled/src/com/android/systemui/volume/panel/component/anc/AncModule
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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.volume.panel.component.anc
-
-import dagger.Module
-
-@Module interface AncModule
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/statusbar/phone/SystemUIDialogFactoryExt.kt b/packages/SystemUI/compose/features/src/com/android/systemui/statusbar/phone/SystemUIDialogFactoryExt.kt
index d66bada04297..7d692cc17015 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/statusbar/phone/SystemUIDialogFactoryExt.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/statusbar/phone/SystemUIDialogFactoryExt.kt
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.phone
import android.content.Context
-import androidx.annotation.GravityInt
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
@@ -46,17 +45,14 @@ import com.android.compose.theme.PlatformTheme
* @param context the [Context] in which the dialog will be constructed.
* @param dismissOnDeviceLock whether the dialog should be automatically dismissed when the device
* is locked (true by default).
- * @param dialogGravity is one of the [android.view.Gravity] and determines dialog position on the
- * screen.
*/
fun SystemUIDialogFactory.create(
context: Context = this.applicationContext,
theme: Int = SystemUIDialog.DEFAULT_THEME,
dismissOnDeviceLock: Boolean = SystemUIDialog.DEFAULT_DISMISS_ON_DEVICE_LOCK,
- @GravityInt dialogGravity: Int? = null,
content: @Composable (SystemUIDialog) -> Unit,
): ComponentSystemUIDialog {
- val dialog = create(context, theme, dismissOnDeviceLock, dialogGravity)
+ val dialog = create(context, theme, dismissOnDeviceLock)
// Create the dialog so that it is properly constructed before we set the Compose content.
// Otherwise, the ComposeView won't render properly.
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/anc/AncModule.kt b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/anc/AncModule.kt
deleted file mode 100644
index ccb5d367c357..000000000000
--- a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/anc/AncModule.kt
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.volume.panel.component.anc
-
-import com.android.systemui.volume.panel.component.anc.domain.AncAvailabilityCriteria
-import com.android.systemui.volume.panel.component.anc.ui.composable.AncPopup
-import com.android.systemui.volume.panel.component.anc.ui.viewmodel.AncViewModel
-import com.android.systemui.volume.panel.component.button.ui.composable.ButtonComponent
-import com.android.systemui.volume.panel.component.shared.model.VolumePanelComponents
-import com.android.systemui.volume.panel.domain.ComponentAvailabilityCriteria
-import com.android.systemui.volume.panel.shared.model.VolumePanelUiComponent
-import dagger.Binds
-import dagger.Module
-import dagger.Provides
-import dagger.multibindings.IntoMap
-import dagger.multibindings.StringKey
-
-/** Dagger module, that provides Active Noise Cancellation Volume Panel UI functionality. */
-@Module
-interface AncModule {
-
- @Binds
- @IntoMap
- @StringKey(VolumePanelComponents.ANC)
- fun bindComponentAvailabilityCriteria(
- criteria: AncAvailabilityCriteria
- ): ComponentAvailabilityCriteria
-
- companion object {
-
- @Provides
- @IntoMap
- @StringKey(VolumePanelComponents.ANC)
- fun provideVolumePanelUiComponent(
- viewModel: AncViewModel,
- popup: AncPopup,
- ): VolumePanelUiComponent = ButtonComponent(viewModel.button, popup::show)
- }
-}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/anc/ui/composable/AncPopup.kt b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/anc/ui/composable/AncPopup.kt
deleted file mode 100644
index a5bbd7ff311b..000000000000
--- a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/anc/ui/composable/AncPopup.kt
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.volume.panel.component.anc.ui.composable
-
-import android.content.Context
-import android.view.View
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.material3.MaterialTheme
-import androidx.compose.material3.Text
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.SideEffect
-import androidx.compose.runtime.collectAsState
-import androidx.compose.runtime.getValue
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.res.stringResource
-import androidx.compose.ui.text.style.TextAlign
-import androidx.compose.ui.viewinterop.AndroidView
-import androidx.slice.Slice
-import androidx.slice.widget.SliceView
-import com.android.systemui.animation.Expandable
-import com.android.systemui.res.R
-import com.android.systemui.statusbar.phone.SystemUIDialog
-import com.android.systemui.volume.panel.component.anc.ui.viewmodel.AncViewModel
-import com.android.systemui.volume.panel.component.popup.ui.composable.VolumePanelPopup
-import javax.inject.Inject
-
-/** ANC popup up displaying ANC control [Slice]. */
-class AncPopup
-@Inject
-constructor(
- private val volumePanelPopup: VolumePanelPopup,
- private val viewModel: AncViewModel,
-) {
-
- fun show(expandable: Expandable) {
- volumePanelPopup.show(expandable, { Title() }, { Content(it) })
- }
-
- @Composable
- private fun Title() {
- Text(
- text = stringResource(R.string.volume_panel_noise_control_title),
- style = MaterialTheme.typography.titleMedium,
- textAlign = TextAlign.Center,
- maxLines = 1,
- )
- }
-
- @Composable
- private fun Content(dialog: SystemUIDialog) {
- val slice: Slice? by viewModel.slice.collectAsState()
-
- if (slice == null) {
- SideEffect { dialog.dismiss() }
- return
- }
-
- AndroidView<SliceView>(
- modifier = Modifier.fillMaxWidth(),
- factory = { context: Context ->
- SliceView(context).apply {
- mode = SliceView.MODE_LARGE
- isScrollable = false
- importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
- setShowTitleItems(true)
- addOnLayoutChangeListener(
- OnWidthChangedLayoutListener(viewModel::changeSliceWidth)
- )
- }
- },
- update = { sliceView: SliceView -> sliceView.slice = slice }
- )
- }
-
- private class OnWidthChangedLayoutListener(private val widthChanged: (Int) -> Unit) :
- View.OnLayoutChangeListener {
- override fun onLayoutChange(
- v: View?,
- left: Int,
- top: Int,
- right: Int,
- bottom: Int,
- oldLeft: Int,
- oldTop: Int,
- oldRight: Int,
- oldBottom: Int
- ) {
- val newWidth = right - left
- val oldWidth = oldRight - oldLeft
- if (oldWidth != newWidth) {
- widthChanged(newWidth)
- }
- }
- }
-}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ButtonComponent.kt b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ButtonComponent.kt
deleted file mode 100644
index 8c9f26a707ea..000000000000
--- a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ButtonComponent.kt
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.volume.panel.component.button.ui.composable
-
-import androidx.compose.foundation.BorderStroke
-import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material3.MaterialTheme
-import androidx.compose.material3.Text
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.collectAsState
-import androidx.compose.runtime.getValue
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.text.style.TextOverflow
-import androidx.compose.ui.unit.dp
-import com.android.compose.animation.Expandable
-import com.android.systemui.animation.Expandable
-import com.android.systemui.common.ui.compose.Icon
-import com.android.systemui.volume.panel.component.button.ui.viewmodel.ButtonViewModel
-import com.android.systemui.volume.panel.ui.composable.ComposeVolumePanelUiComponent
-import com.android.systemui.volume.panel.ui.composable.VolumePanelComposeScope
-import kotlinx.coroutines.flow.StateFlow
-
-class ButtonComponent(
- private val viewModelFlow: StateFlow<ButtonViewModel?>,
- private val onClick: (Expandable) -> Unit
-) : ComposeVolumePanelUiComponent {
-
- @Composable
- override fun VolumePanelComposeScope.Content(modifier: Modifier) {
- val viewModelByState by viewModelFlow.collectAsState()
- val viewModel = viewModelByState ?: return
-
- Column(
- modifier = modifier,
- verticalArrangement = Arrangement.spacedBy(12.dp),
- horizontalAlignment = Alignment.CenterHorizontally,
- ) {
- Expandable(
- modifier = Modifier.height(64.dp).fillMaxWidth(),
- color = MaterialTheme.colorScheme.primaryContainer,
- shape = RoundedCornerShape(28.dp),
- contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
- borderStroke = BorderStroke(8.dp, MaterialTheme.colorScheme.surface),
- onClick = onClick,
- ) {
- Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
- Icon(modifier = Modifier.size(24.dp), icon = viewModel.icon)
- }
- }
- Text(
- text = viewModel.label.toString(),
- style = MaterialTheme.typography.labelMedium,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis,
- )
- }
- }
-}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ToggleButtonComponent.kt b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ToggleButtonComponent.kt
index 57f1c4b1de88..228111dae8d9 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ToggleButtonComponent.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/button/ui/composable/ToggleButtonComponent.kt
@@ -22,7 +22,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedIconToggleButton
@@ -58,7 +57,6 @@ class ToggleButtonComponent(
modifier = Modifier.height(64.dp).fillMaxWidth(),
checked = viewModel.isChecked,
onCheckedChange = onCheckedChange,
- shape = RoundedCornerShape(28.dp),
colors =
IconButtonDefaults.outlinedIconToggleButtonColors(
containerColor = MaterialTheme.colorScheme.surface,
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/popup/ui/composable/VolumePanelPopup.kt b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/popup/ui/composable/VolumePanelPopup.kt
deleted file mode 100644
index 1be087c1bbb0..000000000000
--- a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/popup/ui/composable/VolumePanelPopup.kt
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.volume.panel.component.popup.ui.composable
-
-import android.view.Gravity
-import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.wrapContentHeight
-import androidx.compose.material3.IconButtonDefaults
-import androidx.compose.material3.MaterialTheme
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.unit.dp
-import com.android.compose.PlatformIconButton
-import com.android.systemui.animation.DialogTransitionAnimator
-import com.android.systemui.animation.Expandable
-import com.android.systemui.res.R
-import com.android.systemui.statusbar.phone.SystemUIDialog
-import com.android.systemui.statusbar.phone.SystemUIDialogFactory
-import com.android.systemui.statusbar.phone.create
-import javax.inject.Inject
-
-/** Volume panel bottom popup menu. */
-class VolumePanelPopup
-@Inject
-constructor(
- private val dialogFactory: SystemUIDialogFactory,
- private val dialogTransitionAnimator: DialogTransitionAnimator,
-) {
-
- fun show(
- expandable: Expandable,
- title: @Composable (SystemUIDialog) -> Unit,
- content: @Composable (SystemUIDialog) -> Unit,
- ) {
- val dialog =
- dialogFactory.create(
- theme = R.style.Theme_VolumePanelActivity_Popup,
- dialogGravity = Gravity.BOTTOM,
- ) {
- PopupComposable(it, title, content)
- }
- val controller = expandable.dialogTransitionController()
- if (controller == null) {
- dialog.show()
- } else {
- dialogTransitionAnimator.show(dialog, controller)
- }
- }
-
- @Composable
- private fun PopupComposable(
- dialog: SystemUIDialog,
- title: @Composable (SystemUIDialog) -> Unit,
- content: @Composable (SystemUIDialog) -> Unit,
- ) {
- Box(Modifier.fillMaxWidth()) {
- Column(
- modifier = Modifier.fillMaxWidth().padding(vertical = 20.dp),
- verticalArrangement = Arrangement.spacedBy(20.dp),
- ) {
- Box(
- modifier =
- Modifier.padding(horizontal = 80.dp).fillMaxWidth().wrapContentHeight(),
- contentAlignment = Alignment.Center
- ) {
- title(dialog)
- }
-
- Box(
- modifier =
- Modifier.padding(horizontal = 16.dp).fillMaxWidth().wrapContentHeight(),
- contentAlignment = Alignment.Center
- ) {
- content(dialog)
- }
- }
-
- PlatformIconButton(
- modifier = Modifier.align(Alignment.TopEnd).size(64.dp).padding(20.dp),
- iconResource = R.drawable.ic_close,
- contentDescription = null,
- onClick = { dialog.dismiss() },
- colors =
- IconButtonDefaults.iconButtonColors(
- contentColor = MaterialTheme.colorScheme.outline
- )
- )
- }
- }
-}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/anc/data/repository/AncSliceRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/anc/data/repository/AncSliceRepositoryTest.kt
deleted file mode 100644
index e31cdcd82e7e..000000000000
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/anc/data/repository/AncSliceRepositoryTest.kt
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.volume.panel.component.anc.data.repository
-
-import android.bluetooth.BluetoothDevice
-import android.net.Uri
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.filters.SmallTest
-import com.android.settingslib.bluetooth.CachedBluetoothDevice
-import com.android.settingslib.media.BluetoothMediaDevice
-import com.android.settingslib.media.MediaDevice
-import com.android.systemui.SysuiTestCase
-import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.kosmos.testScope
-import com.android.systemui.testKosmos
-import com.android.systemui.util.mockito.any
-import com.android.systemui.util.mockito.mock
-import com.android.systemui.util.mockito.whenever
-import com.android.systemui.volume.localMediaRepository
-import com.android.systemui.volume.localMediaRepositoryFactory
-import com.android.systemui.volume.panel.component.anc.FakeSliceFactory
-import com.android.systemui.volume.panel.component.anc.sliceViewManager
-import com.google.common.truth.Truth.assertThat
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.test.runCurrent
-import kotlinx.coroutines.test.runTest
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@OptIn(ExperimentalCoroutinesApi::class)
-@SmallTest
-@RunWith(AndroidJUnit4::class)
-class AncSliceRepositoryTest : SysuiTestCase() {
-
- private val kosmos = testKosmos()
-
- private lateinit var underTest: AncSliceRepository
-
- @Before
- fun setup() {
- with(kosmos) {
- val slice = FakeSliceFactory.createSlice(hasError = false, hasSliceItem = true)
- whenever(sliceViewManager.bindSlice(any<Uri>())).thenReturn(slice)
-
- underTest =
- AncSliceRepositoryImpl(
- localMediaRepositoryFactory,
- testScope.testScheduler,
- sliceViewManager,
- )
- }
- }
-
- @Test
- fun noConnectedDevice_noSlice() {
- with(kosmos) {
- testScope.runTest {
- localMediaRepository.updateCurrentConnectedDevice(null)
-
- val slice by collectLastValue(underTest.ancSlice(1))
- runCurrent()
-
- assertThat(slice).isNull()
- }
- }
- }
-
- @Test
- fun connectedDevice_sliceReturned() {
- with(kosmos) {
- testScope.runTest {
- localMediaRepository.updateCurrentConnectedDevice(createMediaDevice())
-
- val slice by collectLastValue(underTest.ancSlice(1))
- runCurrent()
-
- assertThat(slice).isNotNull()
- }
- }
- }
-
- private fun createMediaDevice(sliceUri: String = "content://test.slice"): MediaDevice {
- val bluetoothDevice: BluetoothDevice = mock {
- whenever(getMetadata(any()))
- .thenReturn(
- ("<HEARABLE_CONTROL_SLICE_WITH_WIDTH>" +
- sliceUri +
- "</HEARABLE_CONTROL_SLICE_WITH_WIDTH>")
- .toByteArray()
- )
- }
- val cachedBluetoothDevice: CachedBluetoothDevice = mock {
- whenever(device).thenReturn(bluetoothDevice)
- }
- return mock<BluetoothMediaDevice> {
- whenever(cachedDevice).thenReturn(cachedBluetoothDevice)
- }
- }
-}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/anc/domain/AncAvailabilityCriteriaTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/anc/domain/AncAvailabilityCriteriaTest.kt
deleted file mode 100644
index 553aed8cfb05..000000000000
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/anc/domain/AncAvailabilityCriteriaTest.kt
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.volume.panel.component.anc.domain
-
-import android.net.Uri
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.filters.SmallTest
-import com.android.systemui.SysuiTestCase
-import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.kosmos.testScope
-import com.android.systemui.testKosmos
-import com.android.systemui.util.mockito.any
-import com.android.systemui.util.mockito.mock
-import com.android.systemui.util.mockito.whenever
-import com.android.systemui.volume.panel.component.anc.FakeSliceFactory
-import com.android.systemui.volume.panel.component.anc.ancSliceInteractor
-import com.android.systemui.volume.panel.component.anc.ancSliceRepository
-import com.android.systemui.volume.panel.component.anc.sliceViewManager
-import com.google.common.truth.Truth.assertThat
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.test.runCurrent
-import kotlinx.coroutines.test.runTest
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@OptIn(ExperimentalCoroutinesApi::class)
-@SmallTest
-@RunWith(AndroidJUnit4::class)
-class AncAvailabilityCriteriaTest : SysuiTestCase() {
-
- private val kosmos = testKosmos()
-
- private lateinit var underTest: AncAvailabilityCriteria
-
- @Before
- fun setup() {
- with(kosmos) {
- whenever(sliceViewManager.bindSlice(any<Uri>())).thenReturn(mock {})
-
- underTest = AncAvailabilityCriteria(ancSliceInteractor)
- }
- }
-
- @Test
- fun noSlice_unavailable() {
- with(kosmos) {
- testScope.runTest {
- ancSliceRepository.putSlice(1, null)
-
- val isAvailable by collectLastValue(underTest.isAvailable())
- runCurrent()
-
- assertThat(isAvailable).isFalse()
- }
- }
- }
-
- @Test
- fun hasSlice_available() {
- with(kosmos) {
- testScope.runTest {
- ancSliceRepository.putSlice(
- 1,
- FakeSliceFactory.createSlice(hasError = false, hasSliceItem = true)
- )
-
- val isAvailable by collectLastValue(underTest.isAvailable())
- runCurrent()
-
- assertThat(isAvailable).isTrue()
- }
- }
- }
-}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/anc/domain/interactor/AncSliceInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/anc/domain/interactor/AncSliceInteractorTest.kt
deleted file mode 100644
index 53f0bc9ddb51..000000000000
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/component/anc/domain/interactor/AncSliceInteractorTest.kt
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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.volume.panel.component.anc.domain.interactor
-
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.filters.SmallTest
-import com.android.systemui.SysuiTestCase
-import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.kosmos.testScope
-import com.android.systemui.testKosmos
-import com.android.systemui.volume.panel.component.anc.FakeSliceFactory
-import com.android.systemui.volume.panel.component.anc.ancSliceRepository
-import com.google.common.truth.Truth.assertThat
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.test.runCurrent
-import kotlinx.coroutines.test.runTest
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@OptIn(ExperimentalCoroutinesApi::class)
-@SmallTest
-@RunWith(AndroidJUnit4::class)
-class AncSliceInteractorTest : SysuiTestCase() {
-
- private val kosmos = testKosmos()
-
- private lateinit var underTest: AncSliceInteractor
-
- @Before
- fun setup() {
- with(kosmos) {
- underTest = AncSliceInteractor(ancSliceRepository, testScope.backgroundScope)
- }
- }
-
- @Test
- fun errorSlice_returnsNull() {
- with(kosmos) {
- testScope.runTest {
- ancSliceRepository.putSlice(
- 1,
- FakeSliceFactory.createSlice(hasError = true, hasSliceItem = true)
- )
-
- val slice by collectLastValue(underTest.ancSlice)
- runCurrent()
-
- assertThat(slice).isNull()
- }
- }
- }
-
- @Test
- fun noSliceItem_returnsNull() {
- with(kosmos) {
- testScope.runTest {
- ancSliceRepository.putSlice(
- 1,
- FakeSliceFactory.createSlice(hasError = false, hasSliceItem = false)
- )
-
- val slice by collectLastValue(underTest.ancSlice)
- runCurrent()
-
- assertThat(slice).isNull()
- }
- }
- }
-
- @Test
- fun sliceItem_noError_returnsSlice() {
- with(kosmos) {
- testScope.runTest {
- ancSliceRepository.putSlice(
- 1,
- FakeSliceFactory.createSlice(hasError = false, hasSliceItem = true)
- )
-
- val slice by collectLastValue(underTest.ancSlice)
- runCurrent()
-
- assertThat(slice).isNotNull()
- }
- }
- }
-}
diff --git a/packages/SystemUI/res/drawable/ic_noise_aware.xml b/packages/SystemUI/res/drawable/ic_noise_aware.xml
deleted file mode 100644
index 54826414f3f7..000000000000
--- a/packages/SystemUI/res/drawable/ic_noise_aware.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<!--
- ~ 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.
- -->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="960"
- android:viewportHeight="960"
- android:tint="?attr/colorControlNormal">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M440,82Q450,81 460,80.5Q470,80 480,80Q491,80 500.5,80.5Q510,81 520,82L520,162Q510,160 500.5,160Q491,160 480,160Q469,160 459.5,160Q450,160 440,162L440,82ZM272,138Q289,127 306.5,119Q324,111 343,104L378,176Q358,182 340.5,190.5Q323,199 306,210L272,138ZM654,210Q637,199 619.5,190.5Q602,182 582,176L617,104Q636,111 653.5,119Q671,127 688,138L654,210ZM753,311Q742,294 729,278.5Q716,263 702,249L765,199Q779,213 792,228.5Q805,244 816,261L753,311ZM143,263Q154,246 166.5,230.5Q179,215 193,201L256,251Q242,265 229.5,280.5Q217,296 206,313L143,263ZM83,428Q85,408 90,388.5Q95,369 101,350L180,368Q173,387 168.5,406.5Q164,426 162,446L83,428ZM799,449Q797,429 792.5,409Q788,389 781,370L859,352Q865,371 870,390.5Q875,410 877,430L799,449ZM781,590Q788,571 792,552Q796,533 798,513L877,531Q875,551 870,570.5Q865,590 859,609L781,590ZM162,514Q164,534 168.5,553.5Q173,573 180,592L101,610Q95,591 90,571.5Q85,552 83,532L162,514ZM705,708Q719,694 731,678.5Q743,663 754,646L818,696Q807,713 794.5,728.5Q782,744 768,758L705,708ZM194,760Q180,746 167.5,730Q155,714 144,697L206,647Q217,664 229.5,680Q242,696 256,710L194,760ZM583,783Q603,776 620,768Q637,760 654,749L689,821Q672,832 654.5,840.5Q637,849 618,856L583,783ZM344,857Q325,850 307,841.5Q289,833 272,822L307,750Q324,761 341.5,769.5Q359,778 379,784L344,857ZM480,880Q470,880 460,879.5Q450,879 440,878L440,798Q453,800 480,800Q491,800 500.5,800Q510,800 520,798L520,878Q510,879 500.5,879.5Q491,880 480,880ZM520,720Q482,720 450.5,697Q419,674 406,638Q403,629 399.5,620.5Q396,612 389,605L334,550Q308,524 294,490.5Q280,457 280,420Q280,345 332.5,292.5Q385,240 460,240Q529,240 580,285.5Q631,331 639,400L558,400Q551,365 523.5,342.5Q496,320 460,320Q418,320 389,349Q360,378 360,420Q360,440 368,459.5Q376,479 391,494L445,548Q459,562 467.5,578.5Q476,595 482,612Q487,625 497,632.5Q507,640 520,640Q537,640 548.5,628.5Q560,617 560,600L640,600Q640,650 605.5,685Q571,720 520,720ZM540,560Q515,560 497.5,542.5Q480,525 480,500Q480,474 497.5,457Q515,440 540,440Q566,440 583,457Q600,474 600,500Q600,525 583,542.5Q566,560 540,560Z"/>
-</vector>
diff --git a/packages/SystemUI/res/layout/anc_slice.xml b/packages/SystemUI/res/layout/anc_slice.xml
deleted file mode 100644
index 71752f217a4f..000000000000
--- a/packages/SystemUI/res/layout/anc_slice.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!--
- ~ 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.
- -->
-<androidx.slice.widget.SliceView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/slice_view"
- style="@style/Widget.SliceView.Panel.Slider"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" /> \ No newline at end of file
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 495f20f27996..a7d93e70fda3 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1522,9 +1522,6 @@
<string name="volume_stream_content_description_vibrate_a11y">%1$s. Tap to set to vibrate.</string>
<string name="volume_stream_content_description_mute_a11y">%1$s. Tap to mute.</string>
- <!-- Label for button to enabled/disable live caption [CHAR_LIMIT=30] -->
- <string name="volume_panel_noise_control_title">Noise Control</string>
-
<string name="volume_ringer_change">Tap to change ringer mode</string>
<!-- Hint for accessibility. For example: double tap to mute [CHAR_LIMIT=NONE] -->
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index d0dec63b5b8c..f1d4d71d1cc4 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -962,12 +962,6 @@
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
</style>
- <style name="Theme.VolumePanelActivity.Popup" parent="@style/Theme.SystemUI.Dialog">
- <item name="android:dialogCornerRadius">44dp</item>
- <item name="android:colorBackground">?androidprv:attr/materialColorSurfaceContainerHigh
- </item>
- </style>
-
<style name="Theme.UserSwitcherFullscreenDialog" parent="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen">
<item name="android:statusBarColor">@color/user_switcher_fullscreen_bg</item>
<item name="android:windowBackground">@color/user_switcher_fullscreen_bg</item>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ComponentSystemUIDialog.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ComponentSystemUIDialog.kt
index f3a4f0e64924..4fe9c8ccca0b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ComponentSystemUIDialog.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ComponentSystemUIDialog.kt
@@ -24,7 +24,6 @@ import android.view.ViewGroup
import androidx.activity.OnBackPressedDispatcher
import androidx.activity.OnBackPressedDispatcherOwner
import androidx.activity.setViewTreeOnBackPressedDispatcherOwner
-import androidx.annotation.GravityInt
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
@@ -57,7 +56,6 @@ class ComponentSystemUIDialog(
sysUiState: SysUiState,
broadcastDispatcher: BroadcastDispatcher,
dialogTransitionAnimator: DialogTransitionAnimator,
- @GravityInt private val dialogGravity: Int?,
) :
SystemUIDialog(
context,
@@ -92,7 +90,6 @@ class ComponentSystemUIDialog(
@CallSuper
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- dialogGravity?.let { window?.setGravity(it) }
onBackPressedDispatcher.setOnBackInvokedDispatcher(onBackInvokedDispatcher)
savedStateRegistryController.performRestore(savedInstanceState)
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialogFactory.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialogFactory.kt
index 1edd4d11351c..553edf9b5d13 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialogFactory.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialogFactory.kt
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.phone
import android.content.Context
-import androidx.annotation.GravityInt
import com.android.systemui.animation.DialogTransitionAnimator
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.dagger.qualifiers.Application
@@ -44,14 +43,11 @@ constructor(
* @param context the [Context] in which the dialog will be constructed.
* @param dismissOnDeviceLock whether the dialog should be automatically dismissed when the
* device is locked (true by default).
- * @param dialogGravity is one of the [android.view.Gravity] and determines dialog position on
- * the screen.
*/
fun create(
context: Context = this.applicationContext,
theme: Int = SystemUIDialog.DEFAULT_THEME,
dismissOnDeviceLock: Boolean = SystemUIDialog.DEFAULT_DISMISS_ON_DEVICE_LOCK,
- @GravityInt dialogGravity: Int? = null,
): ComponentSystemUIDialog {
Assert.isMainThread()
@@ -63,7 +59,6 @@ constructor(
sysUiState,
broadcastDispatcher,
dialogTransitionAnimator,
- dialogGravity,
)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/dagger/AncModule.kt b/packages/SystemUI/src/com/android/systemui/volume/dagger/AncModule.kt
deleted file mode 100644
index 66df45ca4cfa..000000000000
--- a/packages/SystemUI/src/com/android/systemui/volume/dagger/AncModule.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.volume.dagger
-
-import android.content.Context
-import androidx.slice.SliceViewManager
-import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.dagger.qualifiers.Application
-import com.android.systemui.volume.panel.component.anc.data.repository.AncSliceRepository
-import com.android.systemui.volume.panel.component.anc.data.repository.AncSliceRepositoryImpl
-import dagger.Module
-import dagger.Provides
-
-/** Dagger module that provides ANC controlling backend. */
-@Module
-interface AncModule {
-
- companion object {
- @Provides
- @SysUISingleton
- fun provideAncSliceRepository(
- @Application context: Context,
- implFactory: AncSliceRepositoryImpl.Factory
- ): AncSliceRepository = implFactory.create(SliceViewManager.getInstance(context))
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/dagger/VolumeModule.java b/packages/SystemUI/src/com/android/systemui/volume/dagger/VolumeModule.java
index c6aee428ce6a..32856373dbe9 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/dagger/VolumeModule.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/dagger/VolumeModule.java
@@ -57,7 +57,6 @@ import dagger.multibindings.IntoSet;
@Module(
includes = {
AudioModule.class,
- AncModule.class,
CaptioningModule.class,
MediaDevicesModule.class
},
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/data/repository/AncSliceRepository.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/data/repository/AncSliceRepository.kt
deleted file mode 100644
index 971ef465fc31..000000000000
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/data/repository/AncSliceRepository.kt
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.volume.panel.component.anc.data.repository
-
-import android.bluetooth.BluetoothDevice
-import android.net.Uri
-import androidx.slice.Slice
-import androidx.slice.SliceViewManager
-import com.android.settingslib.bluetooth.BluetoothUtils
-import com.android.settingslib.media.BluetoothMediaDevice
-import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
-import com.android.systemui.dagger.qualifiers.Background
-import com.android.systemui.volume.panel.component.mediaoutput.data.repository.LocalMediaRepositoryFactory
-import dagger.assisted.Assisted
-import dagger.assisted.AssistedFactory
-import dagger.assisted.AssistedInject
-import kotlin.coroutines.CoroutineContext
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.channels.awaitClose
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.distinctUntilChanged
-import kotlinx.coroutines.flow.flatMapLatest
-import kotlinx.coroutines.flow.flowOf
-import kotlinx.coroutines.flow.flowOn
-import kotlinx.coroutines.flow.map
-import kotlinx.coroutines.launch
-
-/** Provides ANC slice data */
-interface AncSliceRepository {
-
- /**
- * ANC slice with a given width. Emits null when there is no ANC slice available. This can mean
- * that:
- * - there is no supported device connected;
- * - there is no slice provider for the uri;
- */
- fun ancSlice(width: Int): Flow<Slice?>
-}
-
-@OptIn(ExperimentalCoroutinesApi::class)
-class AncSliceRepositoryImpl
-@AssistedInject
-constructor(
- mediaRepositoryFactory: LocalMediaRepositoryFactory,
- @Background private val backgroundCoroutineContext: CoroutineContext,
- @Assisted private val sliceViewManager: SliceViewManager,
-) : AncSliceRepository {
-
- private val localMediaRepository = mediaRepositoryFactory.create(null)
-
- override fun ancSlice(width: Int): Flow<Slice?> {
- return localMediaRepository.currentConnectedDevice
- .map { (it as? BluetoothMediaDevice)?.cachedDevice?.device?.getExtraControlUri(width) }
- .distinctUntilChanged()
- .flatMapLatest { sliceUri ->
- sliceUri ?: return@flatMapLatest flowOf(null)
-
- conflatedCallbackFlow<Slice?> {
- val callback = SliceViewManager.SliceCallback { launch { send(it) } }
-
- val slice = sliceViewManager.bindSlice(sliceUri)
- send(slice)
- sliceViewManager.registerSliceCallback(sliceUri, callback)
- awaitClose { sliceViewManager.unregisterSliceCallback(sliceUri, callback) }
- }
- }
- .flowOn(backgroundCoroutineContext)
- }
-
- private fun BluetoothDevice.getExtraControlUri(width: Int): Uri? {
- val uri: String? = BluetoothUtils.getControlUriMetaData(this)
- uri ?: return null
-
- return if (uri.isEmpty()) {
- null
- } else {
- Uri.parse(
- "$uri$width" +
- "&version=${SliceParameters.VERSION}" +
- "&is_collapsed=${SliceParameters.IS_COLLAPSED}"
- )
- }
- }
-
- @AssistedFactory
- interface Factory {
- fun create(sliceViewManager: SliceViewManager): AncSliceRepositoryImpl
- }
-
- private object SliceParameters {
- /**
- * Slice version
- * 1) legacy slice
- * 2) new slice
- */
- const val VERSION = 2
-
- /**
- * Collapsed slice shows a single button, and expanded shows a row buttons. Supported since
- * [VERSION]==2.
- */
- const val IS_COLLAPSED = false
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/domain/AncAvailabilityCriteria.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/domain/AncAvailabilityCriteria.kt
deleted file mode 100644
index 89b927480783..000000000000
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/domain/AncAvailabilityCriteria.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.volume.panel.component.anc.domain
-
-import com.android.systemui.volume.panel.component.anc.domain.interactor.AncSliceInteractor
-import com.android.systemui.volume.panel.dagger.scope.VolumePanelScope
-import com.android.systemui.volume.panel.domain.ComponentAvailabilityCriteria
-import javax.inject.Inject
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.map
-
-/** Determines if ANC component is available for the Volume Panel. */
-@VolumePanelScope
-class AncAvailabilityCriteria
-@Inject
-constructor(
- private val ancSliceInteractor: AncSliceInteractor,
-) : ComponentAvailabilityCriteria {
-
- override fun isAvailable(): Flow<Boolean> = ancSliceInteractor.ancSlice.map { it != null }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/domain/interactor/AncSliceInteractor.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/domain/interactor/AncSliceInteractor.kt
deleted file mode 100644
index 053fd072b15c..000000000000
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/domain/interactor/AncSliceInteractor.kt
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.volume.panel.component.anc.domain.interactor
-
-import android.app.slice.Slice.HINT_ERROR
-import android.app.slice.SliceItem.FORMAT_SLICE
-import androidx.slice.Slice
-import com.android.systemui.volume.panel.component.anc.data.repository.AncSliceRepository
-import com.android.systemui.volume.panel.dagger.scope.VolumePanelScope
-import javax.inject.Inject
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.flow.SharedFlow
-import kotlinx.coroutines.flow.SharingStarted
-import kotlinx.coroutines.flow.flatMapLatest
-import kotlinx.coroutines.flow.map
-import kotlinx.coroutines.flow.shareIn
-
-@OptIn(ExperimentalCoroutinesApi::class)
-@VolumePanelScope
-class AncSliceInteractor
-@Inject
-constructor(
- private val ancSliceRepository: AncSliceRepository,
- scope: CoroutineScope,
-) {
-
- // Start with a positive width to check is the Slice is available.
- private val width = MutableStateFlow(1)
-
- /** Provides a valid ANC slice. */
- val ancSlice: SharedFlow<Slice?> =
- width
- .flatMapLatest { width -> ancSliceRepository.ancSlice(width) }
- .map { slice ->
- if (slice?.isValidSlice() == true) {
- slice
- } else {
- null
- }
- }
- .shareIn(scope, SharingStarted.Eagerly, replay = 1)
-
- /** Updates the width of the [ancSlice] */
- fun changeWidth(newWidth: Int) {
- width.value = newWidth
- }
-
- private fun Slice.isValidSlice(): Boolean {
- if (hints.contains(HINT_ERROR)) {
- return false
- }
- for (item in items) {
- if (item.format == FORMAT_SLICE) {
- return true
- }
- }
- return false
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/ui/viewmodel/AncViewModel.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/ui/viewmodel/AncViewModel.kt
deleted file mode 100644
index 41903dec7a2d..000000000000
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/component/anc/ui/viewmodel/AncViewModel.kt
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.volume.panel.component.anc.ui.viewmodel
-
-import android.content.Context
-import androidx.slice.Slice
-import com.android.systemui.common.shared.model.Icon
-import com.android.systemui.dagger.qualifiers.Application
-import com.android.systemui.res.R
-import com.android.systemui.volume.panel.component.anc.domain.interactor.AncSliceInteractor
-import com.android.systemui.volume.panel.component.button.ui.viewmodel.ButtonViewModel
-import com.android.systemui.volume.panel.dagger.scope.VolumePanelScope
-import javax.inject.Inject
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.flow.SharingStarted
-import kotlinx.coroutines.flow.StateFlow
-import kotlinx.coroutines.flow.map
-import kotlinx.coroutines.flow.stateIn
-
-/** Volume Panel ANC component view model. */
-@VolumePanelScope
-class AncViewModel
-@Inject
-constructor(
- @Application private val context: Context,
- @VolumePanelScope private val coroutineScope: CoroutineScope,
- private val interactor: AncSliceInteractor,
-) {
-
- val slice: StateFlow<Slice?> =
- interactor.ancSlice.stateIn(coroutineScope, SharingStarted.Eagerly, null)
- val button: StateFlow<ButtonViewModel?> =
- interactor.ancSlice
- .map { slice ->
- slice?.let {
- ButtonViewModel(
- Icon.Resource(R.drawable.ic_noise_aware, null),
- context.getString(R.string.volume_panel_noise_control_title)
- )
- }
- }
- .stateIn(coroutineScope, SharingStarted.Eagerly, null)
-
- fun changeSliceWidth(width: Int) {
- interactor.changeWidth(width)
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/button/ui/viewmodel/ButtonViewModel.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/button/ui/viewmodel/ButtonViewModel.kt
deleted file mode 100644
index 754d258b2b86..000000000000
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/component/button/ui/viewmodel/ButtonViewModel.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.volume.panel.component.button.ui.viewmodel
-
-import com.android.systemui.common.shared.model.Icon
-
-/** Models base buttons appearance. */
-data class ButtonViewModel(
- val icon: Icon,
- val label: CharSequence,
-)
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/component/shared/model/VolumePanelComponents.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/component/shared/model/VolumePanelComponents.kt
index f11ac5e1a8e4..6c742ba7e5f9 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/component/shared/model/VolumePanelComponents.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/panel/component/shared/model/VolumePanelComponents.kt
@@ -23,5 +23,4 @@ object VolumePanelComponents {
const val MEDIA_OUTPUT: VolumePanelComponentKey = "media_output"
const val BOTTOM_BAR: VolumePanelComponentKey = "bottom_bar"
const val CAPTIONING: VolumePanelComponentKey = "captioning"
- const val ANC: VolumePanelComponentKey = "anc"
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/dagger/VolumePanelComponent.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/dagger/VolumePanelComponent.kt
index df4972aeafea..afd3f6170d3d 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/dagger/VolumePanelComponent.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/panel/dagger/VolumePanelComponent.kt
@@ -16,7 +16,6 @@
package com.android.systemui.volume.panel.dagger
-import com.android.systemui.volume.panel.component.anc.AncModule
import com.android.systemui.volume.panel.component.bottombar.BottomBarModule
import com.android.systemui.volume.panel.component.captioning.CaptioningModule
import com.android.systemui.volume.panel.component.mediaoutput.MediaOutputModule
@@ -47,7 +46,6 @@ import kotlinx.coroutines.CoroutineScope
UiModule::class,
// Components modules
BottomBarModule::class,
- AncModule::class,
CaptioningModule::class,
MediaOutputModule::class,
]
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/domain/DomainModule.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/domain/DomainModule.kt
index 0d65c429eac6..55d8de5aeb95 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/domain/DomainModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/panel/domain/DomainModule.kt
@@ -50,7 +50,6 @@ interface DomainModule {
@VolumePanelScope
fun provideEnabledComponents(): Collection<VolumePanelComponentKey> {
return setOf(
- VolumePanelComponents.ANC,
VolumePanelComponents.CAPTIONING,
VolumePanelComponents.MEDIA_OUTPUT,
VolumePanelComponents.BOTTOM_BAR,
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/ui/UiModule.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/ui/UiModule.kt
index ec4da0692841..867df4a87dd5 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/ui/UiModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/panel/ui/UiModule.kt
@@ -47,8 +47,7 @@ interface UiModule {
@VolumePanelScope
@FooterComponents
fun provideFooterComponents(): Collection<VolumePanelComponentKey> {
- return listOf(
- VolumePanelComponents.ANC,
+ return setOf(
VolumePanelComponents.CAPTIONING,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/anc/FakeSliceFactory.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/anc/FakeSliceFactory.kt
deleted file mode 100644
index fc406eaae0f1..000000000000
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/anc/FakeSliceFactory.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.volume.panel.component.anc
-
-import androidx.slice.Slice
-import androidx.slice.SliceItem
-import com.android.systemui.util.mockito.mock
-import com.android.systemui.util.mockito.whenever
-
-object FakeSliceFactory {
-
- fun createSlice(hasError: Boolean, hasSliceItem: Boolean): Slice {
- return mock {
- val sliceItem: SliceItem = mock {
- whenever(format).thenReturn(android.app.slice.SliceItem.FORMAT_SLICE)
- }
-
- whenever(items)
- .thenReturn(
- buildList {
- if (hasSliceItem) {
- add(sliceItem)
- }
- }
- )
-
- whenever(hints)
- .thenReturn(
- buildList {
- if (hasError) {
- add(android.app.slice.Slice.HINT_ERROR)
- }
- }
- )
- }
- }
-}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/anc/VolumePanelAncKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/anc/VolumePanelAncKosmos.kt
deleted file mode 100644
index f9b7e69eea7d..000000000000
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/anc/VolumePanelAncKosmos.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.volume.panel.component.anc
-
-import androidx.slice.SliceViewManager
-import com.android.systemui.kosmos.Kosmos
-import com.android.systemui.kosmos.testScope
-import com.android.systemui.util.mockito.mock
-import com.android.systemui.volume.panel.component.anc.data.repository.FakeAncSliceRepository
-import com.android.systemui.volume.panel.component.anc.domain.interactor.AncSliceInteractor
-
-var Kosmos.sliceViewManager: SliceViewManager by Kosmos.Fixture { mock {} }
-val Kosmos.ancSliceRepository by Kosmos.Fixture { FakeAncSliceRepository() }
-val Kosmos.ancSliceInteractor by
- Kosmos.Fixture { AncSliceInteractor(ancSliceRepository, testScope.backgroundScope) }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/anc/data/repository/FakeAncSliceRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/anc/data/repository/FakeAncSliceRepository.kt
deleted file mode 100644
index b66d7f974eca..000000000000
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/panel/component/anc/data/repository/FakeAncSliceRepository.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.volume.panel.component.anc.data.repository
-
-import androidx.slice.Slice
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.MutableStateFlow
-
-class FakeAncSliceRepository : AncSliceRepository {
-
- private val sliceByWidth = mutableMapOf<Int, MutableStateFlow<Slice?>>()
-
- override fun ancSlice(width: Int): Flow<Slice?> =
- sliceByWidth.getOrPut(width) { MutableStateFlow(null) }
-
- fun putSlice(width: Int, slice: Slice?) {
- sliceByWidth.getOrPut(width) { MutableStateFlow(null) }.value = slice
- }
-}