AconfigPackage


open class AconfigPackage
kotlin.Any
   ↳ android.os.flagging.AconfigPackage

An aconfig package containing the enabled state of its flags.

Note: this is intended only to be used by generated code. To determine if a given flag is enabled in app code, the generated android flags should be used.

This class is used to read the flag from Aconfig Package.Each instance of this class will cache information related to one package. To read flags from a different package, a new instance of this class should be loaded.

Summary

Public methods
open Boolean
getBooleanFlagValue(flagName: String, defaultValue: Boolean)

Retrieves the value of a boolean flag.

open static AconfigPackage
load(packageName: String)

Loads an Aconfig Package from Aconfig Storage.

Public methods

getBooleanFlagValue

open fun getBooleanFlagValue(
    flagName: String,
    defaultValue: Boolean
): Boolean

Retrieves the value of a boolean flag.

This method retrieves the value of the specified flag. If the flag exists within the loaded Aconfig Package, its value is returned. Otherwise, the provided `defaultValue` is returned.

Parameters
flagName String: The name of the flag (excluding any package name prefix). This value cannot be null.
defaultValue Boolean: The value to return if the flag is not found.
Return
Boolean The boolean value of the flag, or `defaultValue` if the flag is not found.

load

open static fun load(packageName: String): AconfigPackage

Loads an Aconfig Package from Aconfig Storage.

This method attempts to load the specified Aconfig package.

Parameters
packageName String: The name of the Aconfig package to load. This value cannot be null.
Return
AconfigPackage An instance of AconfigPackage, which may be empty if the package is not found in the container. This value cannot be null.
Exceptions
android.os.flagging.AconfigStorageReadException if there is an error reading from Aconfig Storage, such as if the storage system is not found, the package is not found, or there is an error reading the storage file. The specific error code can be obtained using android.os.flagging.AconfigStorageReadException#getErrorCode().