1 package com.android.managedprovisioning.common
2 
3 import com.android.managedprovisioning.annotations.LegacyApi
4 import com.android.onboarding.flags.DefaultOnboardingFlagsProvider
5 import com.android.onboarding.flags.OnboardingFlagsProvider
6 import javax.inject.Inject
7 import com.android.managedprovisioning.flags.FeatureFlags as AconfigFlags
8 import com.android.managedprovisioning.flags.FeatureFlagsImpl as DefaultAconfigFlags
9 
10 
11 interface Flags : AconfigFlags {
12     @Deprecated(
13         "Static version is reserved for edge-cases where DI could not be " +
14                 "easily achieved and as such should be avoided. " +
15                 "Consider using injected version whenever possible."
16     )
17     @LegacyApi
18     companion object : Flags by DefaultFlags(DefaultOnboardingFlagsProvider())
19 }
20 
21 class DefaultFlags(
22     private val onboardingFlags: OnboardingFlagsProvider,
23     private val aconfigFlags: AconfigFlags,
24 ) : Flags, AconfigFlags by aconfigFlags {
25     @Inject
26     constructor(
27         onboardingFlags: OnboardingFlagsProvider,
28     ) : this(onboardingFlags, DefaultAconfigFlags())
29 
isCosmicRayEnablednull30     override fun isCosmicRayEnabled(): Boolean =
31         onboardingFlags.isDebug ||
32                 (onboardingFlags.isContractEnabled && aconfigFlags.isCosmicRayEnabled)
33 }
34