Package 

Class APKExpansionPolicy

  • All Implemented Interfaces:
    com.google.android.vending.licensing.Policy

    
    public class APKExpansionPolicy
     implements Policy
                        

    Default policy. All policy decisions are based off of response data received from the licensing service. Specifically, the licensing server sends the following information: response validity period, error retry period, error retry count and a URL for restoring app access in unlicensed cases.

    These values will vary based on the the way the application is configured in the Google Play publishing console, such as whether the application is marked as free or is within its refund period, as well as how often an application is checking with the licensing service.

    Developers who need more fine grained control over their application's licensing policy should implement a custom Policy.

    • Constructor Detail

      • APKExpansionPolicy

        APKExpansionPolicy(Context context, Obfuscator obfuscator)
        Parameters:
        context - The context for the current application
        obfuscator - An obfuscator to be used with preferences.
    • Method Detail

      • resetPolicy

         void resetPolicy()

        We call this to guarantee that we fetch a fresh policy from the server.This is to be used if the URL is invalid.

      • processServerResponse

         void processServerResponse(int response, ResponseData rawData)

        Process a new response from the license server.

        This data will be used for computing future policy decisions. Thefollowing parameters are processed:

        • VT: the timestamp that the client should consider the response validuntil
        • GT: the timestamp that the client should ignore retry errors until
        • GR: the number of retry errors that the client should ignore
        • LU: a deep link URL that can enable access for unlicensed apps (e.g.buy app on the Play Store)
        Parameters:
        response - the result from validating the server response
        rawData - the raw server response data
      • getLicensingUrl

         String getLicensingUrl()

        Gets the licensing URL returned by the server that can enable access for unlicensed apps (e.g.buy app on the Play Store).

      • getExpansionURLCount

         int getExpansionURLCount()

        Gets the count of expansion URLs. Since expansionURLs are not committedto preferences, this will return zero if there has been no LVL fetchin the current session.

      • getExpansionURL

         String getExpansionURL(int index)

        Gets the expansion URL. Since these URLs are not committed topreferences, this will always return null if there has not been an LVLfetch in the current session.

        Parameters:
        index - the index of the URL to fetch.
      • setExpansionURL

         void setExpansionURL(int index, String URL)

        Sets the expansion URL. Expansion URL's are not committed to preferences,but are instead intended to be stored when the license response isprocessed by the front-end.

        Parameters:
        index - the index of the expansion URL.
        URL - the URL to set
      • allowAccess

         boolean allowAccess()

        Check if the user should be allowed access to the application. This implementation allows access if either:

        • a LICENSED response was received within the validity period
        • a RETRY response was received in the last minute, and we are underthe RETRY count or in the RETRY period.