Skip to content

Feature Flags (Feature Restriction Policy)

SAP Mobile Services allows you to configure feature flags using the SAP mobile service cockpit, as described in Feature Restrictions Overview. SAP Mobile Services maintains the list of allowed and restricted features and the Android SDK reads these configurations from the application. Note that in the SAP mobile service cockpit this feature is called “feature vector policy”, while for the SDK it is called “feature restriction policy.” You can manage the feature restriction policy using the Get Feature Restriction Policy Request API. See Managing Feature Restrictions for detailed information.

Managing Feature Flags in the SDK

The SDK stores the value of feature vector policies during an onboarding or restoring flow. The SDK deserializes the incoming JSON as a ClientPolicies object and reads the policy as a FeatureRestrictionPolicy.

You can retrieve the value of the feature vector policy from the onClientPolicyRetrieved in WizardFlowStateListener.

To retrieve these policies on a client application, you can use something similar to the following code:

when (val result = ClientPolicyService().retrieveClientPolicies(SettingsTarget.DEVICE)) {
        is ServiceResult.SUCCESS -> {
            result.data?.also { clientPolicies ->
                clientPolicies.featureRestrictionPolices?.let { featureRestrictionPolices ->
                    val enabledAllFeatureVectorPolicy = featureRestrictionPolices.featureVectorPolicyAllEnabled
                    val allowedPolicies = featureRestrictionPolices.allowedPolicies
                    val restrictedFeatures = featureRestrictionPolices.restrictedFeatures
                }
            }
        }
        is ServiceResult.FAILURE -> {
            ......
        }
    }

Last update: February 20, 2023