Skip to content

Commit

Permalink
Refresh cached licenses preemptively.
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Nov 28, 2012
1 parent f3d14fa commit 9cbda17
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/com/clockworkmod/billing/ClockworkModBillingClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 845,16 @@ public void run() {
}
});
Log.i(LOGTAG, "CheckPurchase result: " syncResult.toString());
return syncResult;
state.reportedPurchase = true;
long til = System.currentTimeMillis() - syncResult.getOrder().getPurchaseTime();
if (syncResult.getOrder() instanceof ClockworkOrder) {
if (billingCacheDuration / 3 < til || billingCacheDuration == CACHE_DURATION_FOREVER)
return syncResult;
}
else {
if (marketCacheDuration / 3 < til || marketCacheDuration == CACHE_DURATION_FOREVER)
return syncResult;
}
}

// don't do a market payment refresh for the sandbox, as that only returns production data.
Expand Down Expand Up @@ -874,7 883,7 @@ else if (BillingReceiver.SUCCEEDED.equals(intent.getAction())) {
else {
state.marketResult = CheckPurchaseResult.notPurchased();
}
Log.i(LOGTAG, "In app billing result: " state.marketResult);
Log.i(LOGTAG, "In app billing result: " state.marketResult.mState);
reportPurchase.run();
}
};
Expand Down Expand Up @@ -944,6 953,9 @@ public void run() {
state.serverResult = CheckPurchaseResult.notPurchased();
}

if (syncResult != null)
return syncResult;

if (state.refreshedServer && state.restoredMarket) {
handler.post(new Runnable() {
@Override
Expand Down

0 comments on commit 9cbda17

Please sign in to comment.