-
- 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.
-
-
Field Summary
Fields Modifier and Type Field Description public final static int
MAIN_FILE_URL_INDEX
public final static int
PATCH_FILE_URL_INDEX
-
Constructor Summary
Constructors Constructor Description APKExpansionPolicy(Context context, Obfuscator obfuscator)
-
Method Summary
Modifier and Type Method Description 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. void
processServerResponse(int response, ResponseData rawData)
Process a new response from the license server. long
getRetryCount()
long
getValidityTimestamp()
long
getRetryUntil()
long
getMaxRetries()
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). int
getExpansionURLCount()
Gets the count of expansion URLs. String
getExpansionURL(int index)
Gets the expansion URL. void
setExpansionURL(int index, String URL)
Sets the expansion URL. String
getExpansionFileName(int index)
void
setExpansionFileName(int index, String name)
long
getExpansionFileSize(int index)
void
setExpansionFileSize(int index, long size)
boolean
allowAccess()
Check if the user should be allowed access to the application. -
-
Constructor Detail
-
APKExpansionPolicy
APKExpansionPolicy(Context context, Obfuscator obfuscator)
- Parameters:
context
- The context for the current applicationobfuscator
- 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 responserawData
- the raw server response data
-
getRetryCount
long getRetryCount()
-
getValidityTimestamp
long getValidityTimestamp()
-
getRetryUntil
long getRetryUntil()
-
getMaxRetries
long getMaxRetries()
-
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
-
getExpansionFileName
String getExpansionFileName(int index)
-
setExpansionFileName
void setExpansionFileName(int index, String name)
-
getExpansionFileSize
long getExpansionFileSize(int index)
-
setExpansionFileSize
void setExpansionFileSize(int index, long size)
-
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.
-
-
-
-