I've been playing around with the new LVL announced yesterday and
wanted to write a policy which only stops the user when it is certain
that he does not have a license.
In other words, the policy will only "dontAllow" the user if the last
meaningful response from the licensing service was NOT_LICENSED.
Therefore, if the user is offline when they first use the app, then
they will be allowed in.
The idea behind this is that I don't want genuine paying users to ever
(within reason) be inconvenienced by this licensing system.
The downside is that all the user needs to do is clear the app data
and go offline before restarting the app. The app will continue
working until they go online (and restart the app).
My thoughts are:
1. Most users won't know about that workaround
2. Those users that are happy to use that workaround, probably
wouldn't pay for the app anyway
Any other thoughts?
===
Here is the code:
public void processServerResponse(LicenseResponse response,
ResponseData rawData) {
mLastResponse = response;
if (response == LicenseResponse.LICENSED || response ==
LicenseResponse.NOT_LICENSED) {
// note - we don't want to say "IS_LICENSED" because that can be
hacked
SharedPreferences prefs =
PreferenceManager.getDefaultSharedPreferences(this.mContext);
Editor edit = prefs.edit();
if (response == LicenseResponse.LICENSED) {
edit.remove(NOT_LICENSED_PREF);
} else if (response == LicenseResponse.NOT_LICENSED) {
edit.putBoolean(NOT_LICENSED_PREF, true);
}
edit.commit();
}
}
public boolean allowAccess() {
if (mLastResponse == null) {
// this is the first call
return false;
}
switch (mLastResponse) {
case LICENSED:
return true;
case NOT_LICENSED:
return false;
default:
return !isDefinitelyNotLicensed();
}
}
public boolean isDefinitelyNotLicensed() {
// if we don't know, then its NOT definitely not licensed.
SharedPreferences prefs =
PreferenceManager.getDefaultSharedPreferences(mContext);
return prefs.getBoolean(NOT_LICENSED_PREF, false);
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en