本文整理汇总了Java中com.google.android.vending.licensing.Policy.RETRY属性的典型用法代码示例。如果您正苦于以下问题:Java Policy.RETRY属性的具体用法?Java Policy.RETRY怎么用?Java Policy.RETRY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.android.vending.licensing.Policy
的用法示例。
在下文中一共展示了Policy.RETRY属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dontAllow
public void dontAllow(int reason) {
if (((Activity) delegate).isFinishing()) { return; }
if (reason == Policy.RETRY) {
delegate.onLicenceRetry(reason);
} else {
delegate.onLicenceInvalid(reason);
}
}
示例2: processServerResponse
/**
* Process a new response from the license server.
* <p>
* This data will be used for computing future policy decisions. The
* following parameters are processed:
* <ul>
* <li>VT: the timestamp that the client should consider the response
* valid until
* <li>GT: the timestamp that the client should ignore retry errors until
* <li>GR: the number of retry errors that the client should ignore
* </ul>
*
* @param response the result from validating the server response
* @param rawData the raw server response data
*/
public void processServerResponse(int response, ResponseData rawData) {
// Update lastCheckTime. This timestamp is using server clock
if(rawData != null){
setLastCheckTime(rawData.timestamp);
}
Log.d(TAG, "Retry Count: " + mRetryCount);
// Update retry counter
if (response != Policy.RETRY) {
setRetryCount(0);
} else {
setRetryCount(mRetryCount + 1);
}
if (response == Policy.LICENSED) {
// Update server policy data
Map<String, String> extras = decodeExtras(rawData.extra);
mLastResponse = response;
setValidityTimestamp(extras.get("VT"));
setRetryUntil(extras.get("GT"));
setMaxRetries(extras.get("GR"));
} else if (response == Policy.NOT_LICENSED) {
// Clear out stale policy data
setValidityTimestamp(DEFAULT_VALIDITY_TIMESTAMP);
setRetryUntil(DEFAULT_RETRY_UNTIL);
setMaxRetries(DEFAULT_MAX_RETRIES);
}
setLastResponse(response);
mPreferences.commit();
}
示例3: allowAccess
/**
* {@inheritDoc}
*
* This implementation allows access if either:<br>
* <ol>
* <li>a LICENSED response was received within the validity period
* <li>a RETRY response was received in the last minute, and we are under
* the RETRY count or in the RETRY period.
* </ol>
*/
public boolean allowAccess() {
long ts = System.currentTimeMillis();
// Detect clock abuse.
// Current timestamp should never be smaller than the timestamp of last check
if(ts + 1000 < mLastCheckTime){
// Clear cache and force server side check
clear();
return false;
}
// Update check time
setLastCheckTime(ts);
mPreferences.commit();
if (mLastResponse == Policy.LICENSED) {
// Check if the LICENSED response occurred within the validity timeout.
if (ts <= mValidityTimestamp) {
// Cached LICENSED response is still valid.
return true;
}
} else if (mLastResponse == Policy.RETRY &&
ts < mLastResponseTime + MILLIS_PER_MINUTE) {
// Only allow access if we are within the retry period or we haven't used up our
// max retries.
return (ts <= mRetryUntil || mRetryCount <= mMaxRetries);
}
return false;
}
示例4: clear
private void clear(){
mPreferences.clear();
mLastResponse = Policy.RETRY;
mValidityTimestamp = Long.parseLong(DEFAULT_VALIDITY_TIMESTAMP);
mRetryUntil = Long.parseLong(DEFAULT_RETRY_UNTIL);
mMaxRetries = Long.parseLong(DEFAULT_MAX_RETRIES);
mRetryCount = Long.parseLong(DEFAULT_RETRY_COUNT);
mLastCheckTime = System.currentTimeMillis();
}