1 /*
2  * Copyright (C) 2022 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.settings.spa.app.specialaccess
18 
19 import android.os.Bundle
20 import androidx.compose.runtime.Composable
21 import androidx.compose.ui.res.stringResource
22 import com.android.settings.R
23 import com.android.settingslib.spa.framework.common.SettingsEntry
24 import com.android.settingslib.spa.framework.common.SettingsEntryBuilder
25 import com.android.settingslib.spa.framework.common.SettingsPageProvider
26 import com.android.settingslib.spa.framework.common.createSettingsPage
27 import com.android.settingslib.spa.framework.compose.navigator
28 import com.android.settingslib.spa.widget.preference.Preference
29 import com.android.settingslib.spa.widget.preference.PreferenceModel
30 import com.android.settingslib.spa.widget.scaffold.RegularScaffold
31 
32 object SpecialAppAccessPageProvider : SettingsPageProvider {
33     override val name = "SpecialAppAccess"
34     private val owner = createSettingsPage()
35 
isEnablednull36     override fun isEnabled(arguments: Bundle?) = false
37 
38     @Composable
39     override fun Page(arguments: Bundle?) {
40         RegularScaffold(title = stringResource(R.string.special_access)) {
41             for (entry in buildEntry(arguments)) {
42                 entry.UiLayout()
43             }
44         }
45     }
46 
47     @Composable
EntryItemnull48     fun EntryItem() {
49         Preference(
50             object : PreferenceModel {
51                 override val title = stringResource(R.string.special_access)
52                 override val onClick = navigator(name)
53             }
54         )
55     }
56 
buildInjectEntrynull57     fun buildInjectEntry() = SettingsEntryBuilder.createInject(owner)
58 
59     override fun buildEntry(arguments: Bundle?): List<SettingsEntry> {
60         return listOf(
61                 AllFilesAccessAppListProvider,
62                 DisplayOverOtherAppsAppListProvider,
63                 MediaManagementAppsAppListProvider,
64                 MediaRoutingControlAppListProvider,
65                 ModifySystemSettingsAppListProvider,
66                 UseFullScreenIntentAppListProvider,
67                 PictureInPictureListProvider,
68                 InstallUnknownAppsListProvider,
69                 AlarmsAndRemindersAppListProvider,
70                 WifiControlAppListProvider,
71                 LongBackgroundTasksAppListProvider,
72                 TurnScreenOnAppsAppListProvider,
73             )
74             .map { it.buildAppListInjectEntry().setLink(fromPage = owner).build() }
75     }
76 }
77