1 /* 2 * Copyright (C) 2016 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 package com.android.settings.overlay 17 18 import android.content.Context 19 import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider 20 import com.android.settings.accessibility.AccessibilitySearchFeatureProvider 21 import com.android.settings.accounts.AccountFeatureProvider 22 import com.android.settings.applications.ApplicationFeatureProvider 23 import com.android.settings.biometrics.face.FaceFeatureProvider 24 import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider 25 import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider 26 import com.android.settings.bluetooth.BluetoothFeatureProvider 27 import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider 28 import com.android.settings.connecteddevice.stylus.StylusFeatureProvider 29 import com.android.settings.dashboard.DashboardFeatureProvider 30 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider 31 import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProvider 32 import com.android.settings.display.DisplayFeatureProvider 33 import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider 34 import com.android.settings.fuelgauge.BatterySettingsFeatureProvider 35 import com.android.settings.fuelgauge.BatteryStatusFeatureProvider 36 import com.android.settings.fuelgauge.PowerUsageFeatureProvider 37 import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider 38 import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider 39 import com.android.settings.localepicker.LocaleFeatureProvider 40 import com.android.settings.notification.syncacrossdevices.SyncAcrossDevicesFeatureProvider 41 import com.android.settings.onboarding.OnboardingFeatureProvider 42 import com.android.settings.overlay.FeatureFactory.Companion.setFactory 43 import com.android.settings.panel.PanelFeatureProvider 44 import com.android.settings.privatespace.PrivateSpaceLoginFeatureProvider 45 import com.android.settings.search.SearchFeatureProvider 46 import com.android.settings.security.SecurityFeatureProvider 47 import com.android.settings.security.SecuritySettingsFeatureProvider 48 import com.android.settings.slices.SlicesFeatureProvider 49 import com.android.settings.users.UserFeatureProvider 50 import com.android.settings.vpn2.AdvancedVpnFeatureProvider 51 import com.android.settings.wifi.WifiTrackerLibProvider 52 import com.android.settings.wifi.factory.WifiFeatureProvider 53 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider 54 55 /** 56 * Abstract class for creating feature controllers. 57 * 58 * Allows OEM implementations to define their own factories with their own controllers containing 59 * whatever code is needed to implement the features. 60 * To provide a factory implementation, implementors should call [setFactory] in their Application. 61 */ 62 abstract class FeatureFactory { 63 /** 64 * Gets implementation for the Suggestion Feature provider. 65 */ 66 abstract val suggestionFeatureProvider: SuggestionFeatureProvider 67 68 /** 69 * Retrieves implementation for Hardware Info feature. 70 */ 71 open val hardwareInfoFeatureProvider: HardwareInfoFeatureProvider? = null 72 73 /** Implementation for [SupportFeatureProvider]. */ 74 open val supportFeatureProvider: SupportFeatureProvider? = null 75 76 abstract val metricsFeatureProvider: MetricsFeatureProvider 77 78 abstract val powerUsageFeatureProvider: PowerUsageFeatureProvider 79 80 /** 81 * Retrieves implementation for Battery Status feature. 82 */ 83 abstract val batteryStatusFeatureProvider: BatteryStatusFeatureProvider 84 85 /** 86 * Gets implementation for Battery Settings provider. 87 */ 88 abstract val batterySettingsFeatureProvider: BatterySettingsFeatureProvider 89 90 abstract val dashboardFeatureProvider: DashboardFeatureProvider 91 abstract val dockUpdaterFeatureProvider: DockUpdaterFeatureProvider 92 abstract val applicationFeatureProvider: ApplicationFeatureProvider 93 abstract val localeFeatureProvider: LocaleFeatureProvider 94 95 abstract val enterprisePrivacyFeatureProvider: EnterprisePrivacyFeatureProvider 96 97 abstract val searchFeatureProvider: SearchFeatureProvider getSurveyFeatureProvidernull98 abstract fun getSurveyFeatureProvider(context: Context): SurveyFeatureProvider? 99 abstract val securityFeatureProvider: SecurityFeatureProvider 100 abstract val userFeatureProvider: UserFeatureProvider 101 abstract val slicesFeatureProvider: SlicesFeatureProvider 102 abstract val accountFeatureProvider: AccountFeatureProvider 103 abstract val panelFeatureProvider: PanelFeatureProvider 104 abstract fun getContextualCardFeatureProvider(context: Context): ContextualCardFeatureProvider 105 106 /** 107 * Retrieves implementation for Bluetooth feature. 108 */ 109 abstract val bluetoothFeatureProvider: BluetoothFeatureProvider 110 111 /** 112 * Retrieves implementation for Face feature. 113 */ 114 abstract val faceFeatureProvider: FaceFeatureProvider 115 116 /** 117 * Retrieves implementation for Fingerprint feature. 118 */ 119 abstract val fingerprintFeatureProvider: FingerprintFeatureProvider 120 121 /** 122 * Gets implementation for Biometrics repository provider. 123 */ 124 abstract val biometricsRepositoryProvider: BiometricsRepositoryProvider 125 126 /** 127 * Gets implementation for the WifiTrackerLib. 128 */ 129 abstract val wifiTrackerLibProvider: WifiTrackerLibProvider 130 131 /** 132 * Retrieves implementation for SecuritySettings feature. 133 */ 134 abstract val securitySettingsFeatureProvider: SecuritySettingsFeatureProvider 135 136 /** 137 * Retrieves implementation for Accessibility search index feature. 138 */ 139 abstract val accessibilitySearchFeatureProvider: AccessibilitySearchFeatureProvider 140 141 /** 142 * Retrieves implementation for Accessibility metrics category feature. 143 */ 144 abstract val accessibilityMetricsFeatureProvider: AccessibilityMetricsFeatureProvider 145 146 /** 147 * Retrieves implementation for advanced vpn feature. 148 */ 149 abstract val advancedVpnFeatureProvider: AdvancedVpnFeatureProvider 150 151 /** 152 * Retrieves implementation for Wi-Fi feature. 153 */ 154 abstract val wifiFeatureProvider: WifiFeatureProvider 155 156 /** 157 * Retrieves implementation for keyboard settings feature. 158 */ 159 abstract val keyboardSettingsFeatureProvider: KeyboardSettingsFeatureProvider 160 161 /** 162 * Retrieves implementation for stylus feature. 163 */ 164 abstract val stylusFeatureProvider: StylusFeatureProvider 165 166 /** 167 * Retrieves implementation for Onboarding related feature. 168 */ 169 open val onboardingFeatureProvider: OnboardingFeatureProvider? = null 170 171 /** 172 * Gets implementation for Fast Pair device updater provider. 173 */ 174 abstract val fastPairFeatureProvider: FastPairFeatureProvider 175 176 /** 177 * Gets implementation for Private Space account login feature. 178 */ 179 abstract val privateSpaceLoginFeatureProvider: PrivateSpaceLoginFeatureProvider 180 181 /** 182 * Gets implementation for Display feature. 183 */ 184 abstract val displayFeatureProvider: DisplayFeatureProvider 185 186 /** 187 * Gets implementation for sync across devices related feature. 188 */ 189 abstract val syncAcrossDevicesFeatureProvider: SyncAcrossDevicesFeatureProvider 190 191 companion object { 192 private var _factory: FeatureFactory? = null 193 194 /** Returns a factory for creating feature controllers. */ 195 @JvmStatic 196 val featureFactory: FeatureFactory 197 get() = _factory ?: throw UnsupportedOperationException("No feature factory configured") 198 199 private var _appContext: Context? = null 200 201 /** Returns an application [Context] used to create this [FeatureFactory]. */ 202 @JvmStatic 203 val appContext: Context 204 get() = _appContext 205 ?: throw UnsupportedOperationException("No feature factory configured") 206 207 @JvmStatic 208 fun setFactory(appContext: Context, factory: FeatureFactory) { 209 _appContext = appContext 210 _factory = factory 211 } 212 } 213 } 214