fix: 引入Settings的Module
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.settings.overlay;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||
import com.android.settings.connecteddevice.dock.DockUpdater;
|
||||
|
||||
/** Feature provider for the dock updater. */
|
||||
public interface DockUpdaterFeatureProvider {
|
||||
|
||||
/** Returns the DockUpdater of the connected dock device */
|
||||
DockUpdater getConnectedDockUpdater(Context context,
|
||||
DevicePreferenceCallback devicePreferenceCallback);
|
||||
|
||||
/** Returns the DockUpdater of the saved dock devices */
|
||||
DockUpdater getSavedDockUpdater(Context context,
|
||||
DevicePreferenceCallback devicePreferenceCallback);
|
||||
|
||||
}
|
||||
213
Settings/src/com/android/settings/overlay/FeatureFactory.kt
Normal file
213
Settings/src/com/android/settings/overlay/FeatureFactory.kt
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.settings.overlay
|
||||
|
||||
import android.content.Context
|
||||
import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider
|
||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider
|
||||
import com.android.settings.accounts.AccountFeatureProvider
|
||||
import com.android.settings.applications.ApplicationFeatureProvider
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider
|
||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider
|
||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingFeatureProvider
|
||||
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider
|
||||
import com.android.settings.connecteddevice.stylus.StylusFeatureProvider
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider
|
||||
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProvider
|
||||
import com.android.settings.display.DisplayFeatureProvider
|
||||
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider
|
||||
import com.android.settings.fuelgauge.BatterySettingsFeatureProvider
|
||||
import com.android.settings.fuelgauge.BatteryStatusFeatureProvider
|
||||
import com.android.settings.fuelgauge.PowerUsageFeatureProvider
|
||||
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider
|
||||
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider
|
||||
import com.android.settings.localepicker.LocaleFeatureProvider
|
||||
import com.android.settings.onboarding.OnboardingFeatureProvider
|
||||
import com.android.settings.overlay.FeatureFactory.Companion.setFactory
|
||||
import com.android.settings.panel.PanelFeatureProvider
|
||||
import com.android.settings.privatespace.PrivateSpaceLoginFeatureProvider
|
||||
import com.android.settings.search.SearchFeatureProvider
|
||||
import com.android.settings.security.SecurityFeatureProvider
|
||||
import com.android.settings.security.SecuritySettingsFeatureProvider
|
||||
import com.android.settings.slices.SlicesFeatureProvider
|
||||
import com.android.settings.users.UserFeatureProvider
|
||||
import com.android.settings.vpn2.AdvancedVpnFeatureProvider
|
||||
import com.android.settings.wifi.WifiTrackerLibProvider
|
||||
import com.android.settings.wifi.factory.WifiFeatureProvider
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider
|
||||
|
||||
/**
|
||||
* Abstract class for creating feature controllers.
|
||||
*
|
||||
* Allows OEM implementations to define their own factories with their own controllers containing
|
||||
* whatever code is needed to implement the features.
|
||||
* To provide a factory implementation, implementors should call [setFactory] in their Application.
|
||||
*/
|
||||
abstract class FeatureFactory {
|
||||
/**
|
||||
* Gets implementation for the Suggestion Feature provider.
|
||||
*/
|
||||
abstract val suggestionFeatureProvider: SuggestionFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for Hardware Info feature.
|
||||
*/
|
||||
abstract val hardwareInfoFeatureProvider: HardwareInfoFeatureProvider
|
||||
|
||||
/** Implementation for [SupportFeatureProvider]. */
|
||||
open val supportFeatureProvider: SupportFeatureProvider? = null
|
||||
|
||||
abstract val metricsFeatureProvider: MetricsFeatureProvider
|
||||
|
||||
abstract val powerUsageFeatureProvider: PowerUsageFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for Battery Status feature.
|
||||
*/
|
||||
abstract val batteryStatusFeatureProvider: BatteryStatusFeatureProvider
|
||||
|
||||
/**
|
||||
* Gets implementation for Battery Settings provider.
|
||||
*/
|
||||
abstract val batterySettingsFeatureProvider: BatterySettingsFeatureProvider
|
||||
|
||||
abstract val dashboardFeatureProvider: DashboardFeatureProvider
|
||||
abstract val dockUpdaterFeatureProvider: DockUpdaterFeatureProvider
|
||||
abstract val applicationFeatureProvider: ApplicationFeatureProvider
|
||||
abstract val localeFeatureProvider: LocaleFeatureProvider
|
||||
|
||||
abstract val enterprisePrivacyFeatureProvider: EnterprisePrivacyFeatureProvider
|
||||
|
||||
abstract val searchFeatureProvider: SearchFeatureProvider
|
||||
abstract fun getSurveyFeatureProvider(context: Context): SurveyFeatureProvider?
|
||||
abstract val securityFeatureProvider: SecurityFeatureProvider
|
||||
abstract val userFeatureProvider: UserFeatureProvider
|
||||
abstract val slicesFeatureProvider: SlicesFeatureProvider
|
||||
abstract val accountFeatureProvider: AccountFeatureProvider
|
||||
abstract val panelFeatureProvider: PanelFeatureProvider
|
||||
abstract fun getContextualCardFeatureProvider(context: Context): ContextualCardFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for Bluetooth feature.
|
||||
*/
|
||||
abstract val bluetoothFeatureProvider: BluetoothFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for Face feature.
|
||||
*/
|
||||
abstract val faceFeatureProvider: FaceFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for Fingerprint feature.
|
||||
*/
|
||||
abstract val fingerprintFeatureProvider: FingerprintFeatureProvider
|
||||
|
||||
/**
|
||||
* Gets implementation for Biometrics repository provider.
|
||||
*/
|
||||
abstract val biometricsRepositoryProvider: BiometricsRepositoryProvider
|
||||
|
||||
/**
|
||||
* Gets implementation for the WifiTrackerLib.
|
||||
*/
|
||||
abstract val wifiTrackerLibProvider: WifiTrackerLibProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for SecuritySettings feature.
|
||||
*/
|
||||
abstract val securitySettingsFeatureProvider: SecuritySettingsFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for Accessibility search index feature.
|
||||
*/
|
||||
abstract val accessibilitySearchFeatureProvider: AccessibilitySearchFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for Accessibility metrics category feature.
|
||||
*/
|
||||
abstract val accessibilityMetricsFeatureProvider: AccessibilityMetricsFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for advanced vpn feature.
|
||||
*/
|
||||
abstract val advancedVpnFeatureProvider: AdvancedVpnFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for Wi-Fi feature.
|
||||
*/
|
||||
abstract val wifiFeatureProvider: WifiFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for keyboard settings feature.
|
||||
*/
|
||||
abstract val keyboardSettingsFeatureProvider: KeyboardSettingsFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for stylus feature.
|
||||
*/
|
||||
abstract val stylusFeatureProvider: StylusFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for Onboarding related feature.
|
||||
*/
|
||||
open val onboardingFeatureProvider: OnboardingFeatureProvider? = null
|
||||
|
||||
/**
|
||||
* Gets implementation for Fast Pair device updater provider.
|
||||
*/
|
||||
abstract val fastPairFeatureProvider: FastPairFeatureProvider
|
||||
|
||||
/**
|
||||
* Gets implementation for Private Space account login feature.
|
||||
*/
|
||||
abstract val privateSpaceLoginFeatureProvider: PrivateSpaceLoginFeatureProvider
|
||||
|
||||
/**
|
||||
* Gets implementation for Display feature.
|
||||
*/
|
||||
abstract val displayFeatureProvider: DisplayFeatureProvider
|
||||
|
||||
/**
|
||||
* Gets implementation for audio sharing related feature.
|
||||
*/
|
||||
abstract val audioSharingFeatureProvider: AudioSharingFeatureProvider
|
||||
|
||||
companion object {
|
||||
private var _factory: FeatureFactory? = null
|
||||
|
||||
/** Returns a factory for creating feature controllers. */
|
||||
@JvmStatic
|
||||
val featureFactory: FeatureFactory
|
||||
get() = _factory ?: throw UnsupportedOperationException("No feature factory configured")
|
||||
|
||||
private var _appContext: Context? = null
|
||||
|
||||
/** Returns an application [Context] used to create this [FeatureFactory]. */
|
||||
@JvmStatic
|
||||
val appContext: Context
|
||||
get() = _appContext
|
||||
?: throw UnsupportedOperationException("No feature factory configured")
|
||||
|
||||
@JvmStatic
|
||||
fun setFactory(appContext: Context, factory: FeatureFactory) {
|
||||
_appContext = appContext
|
||||
_factory = factory
|
||||
}
|
||||
}
|
||||
}
|
||||
205
Settings/src/com/android/settings/overlay/FeatureFactoryImpl.kt
Normal file
205
Settings/src/com/android/settings/overlay/FeatureFactoryImpl.kt
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.settings.overlay
|
||||
|
||||
import android.app.AppGlobals
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.VpnManager
|
||||
import android.os.UserManager
|
||||
import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider
|
||||
import com.android.settings.accessibility.AccessibilityMetricsFeatureProviderImpl
|
||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider
|
||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProviderImpl
|
||||
import com.android.settings.accounts.AccountFeatureProvider
|
||||
import com.android.settings.accounts.AccountFeatureProviderImpl
|
||||
import com.android.settings.applications.ApplicationFeatureProviderImpl
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider
|
||||
import com.android.settings.biometrics.face.FaceFeatureProviderImpl
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProviderImpl
|
||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProviderImpl
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProviderImpl
|
||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingFeatureProvider
|
||||
import com.android.settings.connecteddevice.audiosharing.AudioSharingFeatureProviderImpl
|
||||
import com.android.settings.connecteddevice.dock.DockUpdaterFeatureProviderImpl
|
||||
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider
|
||||
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProviderImpl
|
||||
import com.android.settings.connecteddevice.stylus.StylusFeatureProvider
|
||||
import com.android.settings.connecteddevice.stylus.StylusFeatureProviderImpl
|
||||
import com.android.settings.core.instrumentation.SettingsMetricsFeatureProvider
|
||||
import com.android.settings.dashboard.DashboardFeatureProviderImpl
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl
|
||||
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProvider
|
||||
import com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFeatureProviderImpl
|
||||
import com.android.settings.display.DisplayFeatureProvider
|
||||
import com.android.settings.display.DisplayFeatureProviderImpl
|
||||
import com.android.settings.enterprise.EnterprisePrivacyFeatureProviderImpl
|
||||
import com.android.settings.fuelgauge.BatterySettingsFeatureProviderImpl
|
||||
import com.android.settings.fuelgauge.BatteryStatusFeatureProviderImpl
|
||||
import com.android.settings.fuelgauge.PowerUsageFeatureProviderImpl
|
||||
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProviderImpl
|
||||
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider
|
||||
import com.android.settings.inputmethod.KeyboardSettingsFeatureProviderImpl
|
||||
import com.android.settings.localepicker.LocaleFeatureProviderImpl
|
||||
import com.android.settings.panel.PanelFeatureProviderImpl
|
||||
import com.android.settings.search.SearchFeatureProvider
|
||||
import com.android.settings.search.SearchFeatureProviderImpl
|
||||
import com.android.settings.security.SecurityFeatureProviderImpl
|
||||
import com.android.settings.security.SecuritySettingsFeatureProvider
|
||||
import com.android.settings.security.SecuritySettingsFeatureProviderImpl
|
||||
import com.android.settings.privatespace.PrivateSpaceLoginFeatureProvider
|
||||
import com.android.settings.privatespace.PrivateSpaceLoginFeatureProviderImpl
|
||||
import com.android.settings.slices.SlicesFeatureProviderImpl
|
||||
import com.android.settings.users.UserFeatureProviderImpl
|
||||
import com.android.settings.vpn2.AdvancedVpnFeatureProviderImpl
|
||||
import com.android.settings.wifi.WifiTrackerLibProvider
|
||||
import com.android.settings.wifi.WifiTrackerLibProviderImpl
|
||||
import com.android.settings.wifi.factory.WifiFeatureProvider
|
||||
import com.android.settingslib.spaprivileged.framework.common.devicePolicyManager
|
||||
|
||||
/**
|
||||
* [FeatureFactory] implementation for AOSP Settings.
|
||||
*/
|
||||
open class FeatureFactoryImpl : FeatureFactory() {
|
||||
private val contextualCardFeatureProvider by lazy {
|
||||
ContextualCardFeatureProviderImpl(appContext)
|
||||
}
|
||||
|
||||
override val hardwareInfoFeatureProvider: HardwareInfoFeatureProvider =
|
||||
HardwareInfoFeatureProviderImpl
|
||||
|
||||
override val metricsFeatureProvider by lazy { SettingsMetricsFeatureProvider() }
|
||||
|
||||
override val powerUsageFeatureProvider by lazy { PowerUsageFeatureProviderImpl(appContext) }
|
||||
|
||||
override val batteryStatusFeatureProvider by lazy {
|
||||
BatteryStatusFeatureProviderImpl(appContext)
|
||||
}
|
||||
|
||||
override val batterySettingsFeatureProvider by lazy { BatterySettingsFeatureProviderImpl() }
|
||||
|
||||
override val dashboardFeatureProvider by lazy { DashboardFeatureProviderImpl(appContext) }
|
||||
|
||||
override val dockUpdaterFeatureProvider: DockUpdaterFeatureProvider by lazy {
|
||||
DockUpdaterFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val applicationFeatureProvider by lazy {
|
||||
ApplicationFeatureProviderImpl(
|
||||
appContext,
|
||||
appContext.packageManager,
|
||||
AppGlobals.getPackageManager(),
|
||||
appContext.devicePolicyManager,
|
||||
)
|
||||
}
|
||||
|
||||
override val localeFeatureProvider by lazy { LocaleFeatureProviderImpl() }
|
||||
|
||||
override val enterprisePrivacyFeatureProvider by lazy {
|
||||
EnterprisePrivacyFeatureProviderImpl(
|
||||
appContext,
|
||||
appContext.devicePolicyManager,
|
||||
appContext.packageManager,
|
||||
UserManager.get(appContext),
|
||||
appContext.getSystemService(ConnectivityManager::class.java),
|
||||
appContext.getSystemService(VpnManager::class.java),
|
||||
appContext.resources,
|
||||
)
|
||||
}
|
||||
|
||||
override val searchFeatureProvider: SearchFeatureProvider by lazy {
|
||||
SearchFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override fun getSurveyFeatureProvider(context: Context): SurveyFeatureProvider? = null
|
||||
|
||||
override val securityFeatureProvider by lazy { SecurityFeatureProviderImpl() }
|
||||
|
||||
override val suggestionFeatureProvider: SuggestionFeatureProvider by lazy {
|
||||
SuggestionFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val userFeatureProvider by lazy { UserFeatureProviderImpl(appContext) }
|
||||
|
||||
override val slicesFeatureProvider by lazy { SlicesFeatureProviderImpl() }
|
||||
|
||||
override val accountFeatureProvider: AccountFeatureProvider by lazy {
|
||||
AccountFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val panelFeatureProvider by lazy { PanelFeatureProviderImpl() }
|
||||
|
||||
override fun getContextualCardFeatureProvider(context: Context) = contextualCardFeatureProvider
|
||||
|
||||
override val bluetoothFeatureProvider: BluetoothFeatureProvider by lazy {
|
||||
BluetoothFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val faceFeatureProvider: FaceFeatureProvider by lazy { FaceFeatureProviderImpl() }
|
||||
|
||||
override val fingerprintFeatureProvider: FingerprintFeatureProvider by lazy {
|
||||
FingerprintFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val biometricsRepositoryProvider by lazy { BiometricsRepositoryProviderImpl() }
|
||||
|
||||
override val wifiTrackerLibProvider: WifiTrackerLibProvider by lazy {
|
||||
WifiTrackerLibProviderImpl()
|
||||
}
|
||||
|
||||
override val securitySettingsFeatureProvider: SecuritySettingsFeatureProvider by lazy {
|
||||
SecuritySettingsFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val accessibilitySearchFeatureProvider: AccessibilitySearchFeatureProvider by lazy {
|
||||
AccessibilitySearchFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val accessibilityMetricsFeatureProvider: AccessibilityMetricsFeatureProvider by lazy {
|
||||
AccessibilityMetricsFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val advancedVpnFeatureProvider by lazy { AdvancedVpnFeatureProviderImpl() }
|
||||
|
||||
override val wifiFeatureProvider by lazy { WifiFeatureProvider(appContext) }
|
||||
|
||||
override val keyboardSettingsFeatureProvider: KeyboardSettingsFeatureProvider by lazy {
|
||||
KeyboardSettingsFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val stylusFeatureProvider: StylusFeatureProvider by lazy {
|
||||
StylusFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val fastPairFeatureProvider: FastPairFeatureProvider by lazy {
|
||||
FastPairFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val privateSpaceLoginFeatureProvider: PrivateSpaceLoginFeatureProvider by lazy {
|
||||
PrivateSpaceLoginFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val displayFeatureProvider: DisplayFeatureProvider by lazy {
|
||||
DisplayFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val audioSharingFeatureProvider: AudioSharingFeatureProvider by lazy {
|
||||
AudioSharingFeatureProviderImpl()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.settings.overlay;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
/**
|
||||
* Feature provider for support tab.
|
||||
*/
|
||||
public interface SupportFeatureProvider {
|
||||
|
||||
/**
|
||||
* Starts support, invokes the support home page.
|
||||
*
|
||||
* @param activity Calling activity.
|
||||
*/
|
||||
void startSupport(Activity activity);
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.settings.overlay;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
/**
|
||||
* An interface for classes wishing to provide the ability to serve surveys to implement.
|
||||
*/
|
||||
public interface SurveyFeatureProvider {
|
||||
/**
|
||||
* Downloads a survey asynchronously to shared preferences to be served at a later date.
|
||||
*
|
||||
* @param activity A valid context.
|
||||
* @param surveyId A unique Id representing a survey to download.
|
||||
* @param data a text blob to be attached to the survey results.
|
||||
* @deprecated This is not used after T.
|
||||
*/
|
||||
@Deprecated
|
||||
void downloadSurvey(Activity activity, String surveyId, @Nullable String data);
|
||||
|
||||
/**
|
||||
* Shows a previously downloaded survey/prompt if possible in the activity provided.
|
||||
*
|
||||
* @param activity The host activity to show the survey in.
|
||||
* @param surveyId A unique Id representing a survey to download.
|
||||
* @return A boolean indicating if a survey was shown or not.
|
||||
* @deprecated This is not used after T.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean showSurveyIfAvailable(Activity activity, String surveyId);
|
||||
|
||||
/**
|
||||
* A helper method to get the surveyId. Implementers should create a mapping of
|
||||
* keys to surveyIds and provide them via this function.
|
||||
*
|
||||
* @param context A valid context.
|
||||
* @param simpleKey The simple name of the key to get the surveyId for.
|
||||
* @return The unique Id as a string or null on error.
|
||||
* @deprecated This is not used after T.
|
||||
*/
|
||||
@Deprecated
|
||||
String getSurveyId(Context context, String simpleKey);
|
||||
|
||||
/**
|
||||
* Removes the survey for {@code siteId} if it expired, then returns the expiration date (as a
|
||||
* unix timestamp) for the remaining survey should it exist and be ready to show. Returns -1 if
|
||||
* no valid survey exists after removing the potentially expired one.
|
||||
*
|
||||
* @param context the calling context.
|
||||
* @param surveyId the site ID.
|
||||
* @return the unix timestamp for the available survey for the given {@coe siteId} or -1 if
|
||||
* there is none available.
|
||||
* @deprecated This is not used after T.
|
||||
*/
|
||||
@Deprecated
|
||||
long getSurveyExpirationDate(Context context, String surveyId);
|
||||
|
||||
/**
|
||||
* Registers an activity to show surveys/prompts as soon as they are downloaded. The receiver
|
||||
* should be unregistered prior to destroying the activity to avoid undefined behavior by
|
||||
* calling {@link #unregisterReceiver(Activity, BroadcastReceiver)}.
|
||||
*
|
||||
* @param activity The activity that should show surveys once they are downloaded.
|
||||
* @return the broadcast receiver listening for survey downloads. Must be unregistered before
|
||||
* leaving the activity.
|
||||
* @deprecated This is not used after T.
|
||||
*/
|
||||
@Deprecated
|
||||
BroadcastReceiver createAndRegisterReceiver(Activity activity);
|
||||
|
||||
/**
|
||||
* Unregisters the broadcast receiver for this activity. Should only be called once per activity
|
||||
* after a call to {@link #createAndRegisterReceiver(Activity)}.
|
||||
*
|
||||
* @param activity The activity that was used to register the BroadcastReceiver.
|
||||
* @deprecated This is not used after T.
|
||||
*/
|
||||
@Deprecated
|
||||
static void unregisterReceiver(Activity activity, BroadcastReceiver receiver) {
|
||||
if (activity == null) {
|
||||
throw new IllegalStateException("Cannot unregister receiver if activity is null");
|
||||
}
|
||||
|
||||
LocalBroadcastManager.getInstance(activity).unregisterReceiver(receiver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the visited activity to the place where it will trigger a survey if possible.
|
||||
*
|
||||
* @param simpleKey The simple name of the key to get the surveyId for.
|
||||
*/
|
||||
void sendActivityIfAvailable(String simpleKey);
|
||||
}
|
||||
Reference in New Issue
Block a user