• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.shade.domain.interactor
18 
19 import android.content.testableContext
20 import android.provider.Settings
21 import com.android.systemui.kosmos.Kosmos
22 import com.android.systemui.kosmos.Kosmos.Fixture
23 import com.android.systemui.kosmos.applicationCoroutineScope
24 import com.android.systemui.log.table.logcatTableLogBuffer
25 import com.android.systemui.res.R
26 import com.android.systemui.shade.data.repository.fakeShadeRepository
27 import com.android.systemui.shade.data.repository.shadeRepository
28 import com.android.systemui.shared.settings.data.repository.fakeSecureSettingsRepository
29 
<lambda>null30 val Kosmos.shadeModeInteractor by Fixture {
31     ShadeModeInteractorImpl(
32         applicationScope = applicationCoroutineScope,
33         repository = shadeRepository,
34         secureSettingsRepository = fakeSecureSettingsRepository,
35         tableLogBuffer = logcatTableLogBuffer(this, "sceneFrameworkTableLogBuffer"),
36     )
37 }
38 
<lambda>null39 val Kosmos.shadeMode by Fixture { shadeModeInteractor.shadeMode }
40 
41 // TODO(b/391578667): Make this user-aware once supported by FakeSecureSettingsRepository.
42 /**
43  * Enables the Dual Shade setting, and (optionally) sets the shade layout to be wide (`true`) or
44  * narrow (`false`).
45  *
46  * In a wide layout, notifications and quick settings shades each take up only half the screen
47  * width. In a narrow layout, they each take up the entire screen width.
48  */
enableDualShadenull49 fun Kosmos.enableDualShade(wideLayout: Boolean? = null) {
50     fakeSecureSettingsRepository.setBool(Settings.Secure.DUAL_SHADE, true)
51 
52     if (wideLayout != null) {
53         overrideLargeScreenResources(isLargeScreen = wideLayout)
54         fakeShadeRepository.setShadeLayoutWide(wideLayout)
55     }
56 }
57 
58 // TODO(b/391578667): Make this user-aware once supported by FakeSecureSettingsRepository.
disableDualShadenull59 fun Kosmos.disableDualShade() {
60     fakeSecureSettingsRepository.setBool(Settings.Secure.DUAL_SHADE, false)
61 }
62 
enableSingleShadenull63 fun Kosmos.enableSingleShade() {
64     disableDualShade()
65     overrideLargeScreenResources(isLargeScreen = false)
66     fakeShadeRepository.setShadeLayoutWide(false)
67 }
68 
enableSplitShadenull69 fun Kosmos.enableSplitShade() {
70     disableDualShade()
71     overrideLargeScreenResources(isLargeScreen = true)
72     fakeShadeRepository.setShadeLayoutWide(true)
73 }
74 
Kosmosnull75 private fun Kosmos.overrideLargeScreenResources(isLargeScreen: Boolean) {
76     with(testableContext.orCreateTestableResources) {
77         addOverride(R.bool.config_use_split_notification_shade, isLargeScreen)
78         addOverride(R.bool.config_use_large_screen_shade_header, isLargeScreen)
79     }
80 }
81