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 18 19 import android.content.Context 20 import android.util.FeatureFlagUtils 21 import com.android.settings.network.apn.ApnEditPageProvider 22 import com.android.settings.print.PrintSettingsPageProvider 23 import com.android.settings.spa.about.AboutPhonePageProvider 24 import com.android.settings.spa.app.AllAppListPageProvider 25 import com.android.settings.spa.app.AppsMainPageProvider 26 import com.android.settings.spa.app.appcompat.UserAspectRatioAppsPageProvider 27 import com.android.settings.spa.app.appinfo.AppInfoSettingsProvider 28 import com.android.settings.spa.app.appinfo.CloneAppInfoSettingsProvider 29 import com.android.settings.spa.app.backgroundinstall.BackgroundInstalledAppsPageProvider 30 import com.android.settings.spa.app.battery.BatteryOptimizationModeAppListPageProvider 31 import com.android.settings.spa.app.specialaccess.AlarmsAndRemindersAppListProvider 32 import com.android.settings.spa.app.specialaccess.AllFilesAccessAppListProvider 33 import com.android.settings.spa.app.specialaccess.DisplayOverOtherAppsAppListProvider 34 import com.android.settings.spa.app.specialaccess.InstallUnknownAppsListProvider 35 import com.android.settings.spa.app.specialaccess.LongBackgroundTasksAppListProvider 36 import com.android.settings.spa.app.specialaccess.MediaManagementAppsAppListProvider 37 import com.android.settings.spa.app.specialaccess.MediaRoutingControlAppListProvider 38 import com.android.settings.spa.app.specialaccess.ModifySystemSettingsAppListProvider 39 import com.android.settings.spa.app.specialaccess.NfcTagAppsSettingsProvider 40 import com.android.settings.spa.app.specialaccess.PictureInPictureListProvider 41 import com.android.settings.spa.app.specialaccess.SpecialAppAccessPageProvider 42 import com.android.settings.spa.app.specialaccess.TurnScreenOnAppsAppListProvider 43 import com.android.settings.spa.app.specialaccess.UseFullScreenIntentAppListProvider 44 import com.android.settings.spa.app.specialaccess.WifiControlAppListProvider 45 import com.android.settings.spa.app.storage.StorageAppListPageProvider 46 import com.android.settings.spa.core.instrumentation.SpaLogMetricsProvider 47 import com.android.settings.spa.core.instrumentation.SpaLogProvider 48 import com.android.settings.spa.development.UsageStatsPageProvider 49 import com.android.settings.spa.development.compat.PlatformCompatAppListPageProvider 50 import com.android.settings.spa.home.HomePageProvider 51 import com.android.settings.spa.network.NetworkAndInternetPageProvider 52 import com.android.settings.spa.network.NetworkCellularGroupProvider 53 import com.android.settings.spa.network.SimOnboardingPageProvider 54 import com.android.settings.spa.notification.AppListNotificationsPageProvider 55 import com.android.settings.spa.notification.NotificationMainPageProvider 56 import com.android.settings.spa.system.AppLanguagesPageProvider 57 import com.android.settings.spa.system.LanguageAndInputPageProvider 58 import com.android.settings.spa.system.SystemMainPageProvider 59 import com.android.settings.wifi.details2.WifiPrivacyPageProvider 60 import com.android.settingslib.spa.framework.common.SettingsPageProviderRepository 61 import com.android.settingslib.spa.framework.common.SpaEnvironment 62 import com.android.settingslib.spa.framework.common.SpaLogger 63 import com.android.settingslib.spa.framework.common.createSettingsPage 64 import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider 65 import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListTemplate 66 67 open class SettingsSpaEnvironment(context: Context) : SpaEnvironment(context) { getTogglePermissionAppListProvidersnull68 open fun getTogglePermissionAppListProviders(): List<TogglePermissionAppListProvider> { 69 return listOf( 70 AllFilesAccessAppListProvider, 71 DisplayOverOtherAppsAppListProvider, 72 MediaManagementAppsAppListProvider, 73 MediaRoutingControlAppListProvider, 74 ModifySystemSettingsAppListProvider, 75 UseFullScreenIntentAppListProvider, 76 PictureInPictureListProvider, 77 InstallUnknownAppsListProvider, 78 AlarmsAndRemindersAppListProvider, 79 WifiControlAppListProvider, 80 NfcTagAppsSettingsProvider, 81 LongBackgroundTasksAppListProvider, 82 TurnScreenOnAppsAppListProvider, 83 ) 84 } 85 <lambda>null86 override val pageProviderRepository = lazy { 87 val togglePermissionAppListTemplate = TogglePermissionAppListTemplate( 88 allProviders = getTogglePermissionAppListProviders() 89 ) 90 SettingsPageProviderRepository( 91 allPageProviders = settingsPageProviders() 92 + togglePermissionAppListTemplate.createPageProviders(), 93 rootPages = listOf( 94 HomePageProvider.createSettingsPage() 95 ), 96 ) 97 } 98 99 settingsPageProvidersnull100 open fun settingsPageProviders() = listOf( 101 HomePageProvider, 102 AppsMainPageProvider, 103 AllAppListPageProvider, 104 AppInfoSettingsProvider, 105 SpecialAppAccessPageProvider, 106 NotificationMainPageProvider, 107 AppListNotificationsPageProvider, 108 SystemMainPageProvider, 109 LanguageAndInputPageProvider, 110 AppLanguagesPageProvider, 111 UsageStatsPageProvider, 112 PlatformCompatAppListPageProvider, 113 BackgroundInstalledAppsPageProvider, 114 UserAspectRatioAppsPageProvider, 115 CloneAppInfoSettingsProvider, 116 NetworkAndInternetPageProvider, 117 AboutPhonePageProvider, 118 StorageAppListPageProvider.Apps, 119 StorageAppListPageProvider.Games, 120 ApnEditPageProvider, 121 SimOnboardingPageProvider, 122 BatteryOptimizationModeAppListPageProvider, 123 NetworkCellularGroupProvider(), 124 WifiPrivacyPageProvider, 125 PrintSettingsPageProvider, 126 ) 127 128 override val logger = if (FeatureFlagUtils.isEnabled( 129 context, FeatureFlagUtils.SETTINGS_ENABLE_SPA_METRICS 130 ) 131 ) SpaLogMetricsProvider // ToDo: Implement 'SpaLogProvider' for SPA settings. 132 else object : SpaLogger {} 133 } 134