Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileDataInteractorTest.kt 0 → 100644 +94 −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.qs.tiles.impl.modes.domain.interactor import android.app.Flags import android.os.UserHandle import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.annotations.EnabledOnRavenwood import android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS import android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS import android.provider.Settings.Global.ZEN_MODE_OFF import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.settingslib.notification.data.repository.FakeZenModeRepository import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectValues import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger import com.android.systemui.qs.tiles.impl.modes.domain.model.ModesTileModel import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.toCollection import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @EnabledOnRavenwood @RunWith(AndroidJUnit4::class) class ModesTileDataInteractorTest : SysuiTestCase() { private val zenModeRepository = FakeZenModeRepository() private val underTest = ModesTileDataInteractor(zenModeRepository) @EnableFlags(Flags.FLAG_MODES_UI) @Test fun availableWhenFlagIsOn() = runTest { val availability = underTest.availability(TEST_USER).toCollection(mutableListOf()) assertThat(availability).containsExactly(true) } @DisableFlags(Flags.FLAG_MODES_UI) @Test fun unavailableWhenFlagIsOff() = runTest { val availability = underTest.availability(TEST_USER).toCollection(mutableListOf()) assertThat(availability).containsExactly(false) } @EnableFlags(Flags.FLAG_MODES_UI) @Test fun dataMatchesTheRepository() = runTest { val dataList: List<ModesTileModel> by collectValues(underTest.tileData(TEST_USER, flowOf(DataUpdateTrigger.InitialRequest))) runCurrent() // Enable zen mode zenModeRepository.updateZenMode(ZEN_MODE_IMPORTANT_INTERRUPTIONS) runCurrent() // Change zen mode: it's still enabled, so this shouldn't cause another emission zenModeRepository.updateZenMode(ZEN_MODE_NO_INTERRUPTIONS) runCurrent() // Disable zen mode zenModeRepository.updateZenMode(ZEN_MODE_OFF) runCurrent() assertThat(dataList.map { it.isActivated }).containsExactly(false, true, false) } private companion object { val TEST_USER = UserHandle.of(1)!! } } packages/SystemUI/res/values/config.xml +1 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,7 @@ <!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" --> <string name="quick_settings_tiles_stock" translatable="false"> internet,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,font_scaling,record_issue,hearing_devices internet,bt,flashlight,dnd,modes,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,font_scaling,record_issue,hearing_devices </string> <!-- The tiles to display in QuickSettings --> Loading packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -716,6 +716,8 @@ <!-- QuickSettings: Do not disturb - Priority only [CHAR LIMIT=NONE] --> <!-- QuickSettings: Do not disturb - Alarms only [CHAR LIMIT=NONE] --> <!-- QuickSettings: Do not disturb - Total silence [CHAR LIMIT=NONE] --> <!-- QuickSettings: Priority modes [CHAR LIMIT=NONE] --> <string name="quick_settings_modes_label">Priority modes</string> <!-- QuickSettings: Bluetooth [CHAR LIMIT=NONE] --> <string name="quick_settings_bluetooth_label">Bluetooth</string> <!-- QuickSettings: Bluetooth (Multiple) [CHAR LIMIT=NONE] --> Loading packages/SystemUI/res/values/tiles_states_strings.xml +10 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,16 @@ <item>On</item> </string-array> <!-- State names for modes (Priority modes) tile: unavailable, off, on. This subtitle is shown when the tile is in that particular state but does not set its own subtitle, so some of these may never appear on screen. They should still be translated as if they could appear. [CHAR LIMIT=32] --> <string-array name="tile_states_modes"> <item>Unavailable</item> <item>Off</item> <item>On</item> </string-array> <!-- State names for flashlight tile: unavailable, off, on. This subtitle is shown when the tile is in that particular state but does not set its own subtitle, so some of these may never appear on screen. They should still be translated as Loading packages/SystemUI/src/com/android/systemui/qs/tileimpl/SubtitleArrayMapping.kt +2 −0 Original line number Diff line number Diff line Loading @@ -20,12 +20,14 @@ import com.android.systemui.res.R /** Return the subtitle resource Id of the given tile. */ object SubtitleArrayMapping { private val subtitleIdsMap: HashMap<String, Int> = HashMap() init { subtitleIdsMap["internet"] = R.array.tile_states_internet subtitleIdsMap["wifi"] = R.array.tile_states_wifi subtitleIdsMap["cell"] = R.array.tile_states_cell subtitleIdsMap["battery"] = R.array.tile_states_battery subtitleIdsMap["dnd"] = R.array.tile_states_dnd subtitleIdsMap["modes"] = R.array.tile_states_modes subtitleIdsMap["flashlight"] = R.array.tile_states_flashlight subtitleIdsMap["rotation"] = R.array.tile_states_rotation subtitleIdsMap["bt"] = R.array.tile_states_bt Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/modes/domain/interactor/ModesTileDataInteractorTest.kt 0 → 100644 +94 −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.qs.tiles.impl.modes.domain.interactor import android.app.Flags import android.os.UserHandle import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.annotations.EnabledOnRavenwood import android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS import android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS import android.provider.Settings.Global.ZEN_MODE_OFF import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.settingslib.notification.data.repository.FakeZenModeRepository import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectValues import com.android.systemui.qs.tiles.base.interactor.DataUpdateTrigger import com.android.systemui.qs.tiles.impl.modes.domain.model.ModesTileModel import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.toCollection import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @EnabledOnRavenwood @RunWith(AndroidJUnit4::class) class ModesTileDataInteractorTest : SysuiTestCase() { private val zenModeRepository = FakeZenModeRepository() private val underTest = ModesTileDataInteractor(zenModeRepository) @EnableFlags(Flags.FLAG_MODES_UI) @Test fun availableWhenFlagIsOn() = runTest { val availability = underTest.availability(TEST_USER).toCollection(mutableListOf()) assertThat(availability).containsExactly(true) } @DisableFlags(Flags.FLAG_MODES_UI) @Test fun unavailableWhenFlagIsOff() = runTest { val availability = underTest.availability(TEST_USER).toCollection(mutableListOf()) assertThat(availability).containsExactly(false) } @EnableFlags(Flags.FLAG_MODES_UI) @Test fun dataMatchesTheRepository() = runTest { val dataList: List<ModesTileModel> by collectValues(underTest.tileData(TEST_USER, flowOf(DataUpdateTrigger.InitialRequest))) runCurrent() // Enable zen mode zenModeRepository.updateZenMode(ZEN_MODE_IMPORTANT_INTERRUPTIONS) runCurrent() // Change zen mode: it's still enabled, so this shouldn't cause another emission zenModeRepository.updateZenMode(ZEN_MODE_NO_INTERRUPTIONS) runCurrent() // Disable zen mode zenModeRepository.updateZenMode(ZEN_MODE_OFF) runCurrent() assertThat(dataList.map { it.isActivated }).containsExactly(false, true, false) } private companion object { val TEST_USER = UserHandle.of(1)!! } }
packages/SystemUI/res/values/config.xml +1 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,7 @@ <!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" --> <string name="quick_settings_tiles_stock" translatable="false"> internet,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,font_scaling,record_issue,hearing_devices internet,bt,flashlight,dnd,modes,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,font_scaling,record_issue,hearing_devices </string> <!-- The tiles to display in QuickSettings --> Loading
packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -716,6 +716,8 @@ <!-- QuickSettings: Do not disturb - Priority only [CHAR LIMIT=NONE] --> <!-- QuickSettings: Do not disturb - Alarms only [CHAR LIMIT=NONE] --> <!-- QuickSettings: Do not disturb - Total silence [CHAR LIMIT=NONE] --> <!-- QuickSettings: Priority modes [CHAR LIMIT=NONE] --> <string name="quick_settings_modes_label">Priority modes</string> <!-- QuickSettings: Bluetooth [CHAR LIMIT=NONE] --> <string name="quick_settings_bluetooth_label">Bluetooth</string> <!-- QuickSettings: Bluetooth (Multiple) [CHAR LIMIT=NONE] --> Loading
packages/SystemUI/res/values/tiles_states_strings.xml +10 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,16 @@ <item>On</item> </string-array> <!-- State names for modes (Priority modes) tile: unavailable, off, on. This subtitle is shown when the tile is in that particular state but does not set its own subtitle, so some of these may never appear on screen. They should still be translated as if they could appear. [CHAR LIMIT=32] --> <string-array name="tile_states_modes"> <item>Unavailable</item> <item>Off</item> <item>On</item> </string-array> <!-- State names for flashlight tile: unavailable, off, on. This subtitle is shown when the tile is in that particular state but does not set its own subtitle, so some of these may never appear on screen. They should still be translated as Loading
packages/SystemUI/src/com/android/systemui/qs/tileimpl/SubtitleArrayMapping.kt +2 −0 Original line number Diff line number Diff line Loading @@ -20,12 +20,14 @@ import com.android.systemui.res.R /** Return the subtitle resource Id of the given tile. */ object SubtitleArrayMapping { private val subtitleIdsMap: HashMap<String, Int> = HashMap() init { subtitleIdsMap["internet"] = R.array.tile_states_internet subtitleIdsMap["wifi"] = R.array.tile_states_wifi subtitleIdsMap["cell"] = R.array.tile_states_cell subtitleIdsMap["battery"] = R.array.tile_states_battery subtitleIdsMap["dnd"] = R.array.tile_states_dnd subtitleIdsMap["modes"] = R.array.tile_states_modes subtitleIdsMap["flashlight"] = R.array.tile_states_flashlight subtitleIdsMap["rotation"] = R.array.tile_states_rotation subtitleIdsMap["bt"] = R.array.tile_states_bt Loading