Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Licensing checker longevity of the "activated" status. How frequent is too much for the user?

My app is a kind of a pocket guide with some data for the whole year. I'm assuming users will use the program at least once with Internet access to activate the license. Or at least that's my understanding of how the Android licensing system works. I'm using ServerManagedPolicy.

Does it check periodically for the license? Is there any way that I can control this? I don't want my users to be in the middle of nowhere, with an app already and previously activated and suddenly after 1 week, 1 month, 1 year etc. the app starts limiting the usability of the app itself because the license couldn't be verified again. My app is going to be used in remote places with erratic net access (can't be taken for granted all the time) by people who will live there for weeks, maybe months.

I feel I should at least warn them that they will be asked every X weeks to do that. Is the license system even that draconian?

I know I can handle the errors with the ERROR_CONTACTING_SERVER flag, on the applicationError void of LicenseCheckerCallback. Is the "VT" response always the same (can't test this on a test account/my account)? I was just curious about how you guys treat this situation on your own real life apps. Am I missing something here? For some reason I'm feeling I am. Is there any "catch"?

// EDITED:

Here is the code I'm trying right now:

// ServerManagedPolicy.java
private void setValidityTimestamp(String validityTimestamp) {
    Long lValidityTimestamp;
    try {
        lValidityTimestamp = Long.parseLong(validityTimestamp);
    } catch (NumberFormatException e) {
        // No response or not parsable, expire in one minute.
        Log.w(TAG, "License validity timestamp (VT) missing, caching for a minute");
        lValidityTimestamp = System.currentTimeMillis() + MILLIS_PER_MINUTE;
        validityTimestamp = Long.toString(lValidityTimestamp);
    }
    // added by me--->

    private static long maxLicense = 1000 * 3600 * 24 * 30; // ~ roughly 30 days
    private static long minLicense = 1000 * 3600 * 24 * 3;  // ~ roughly 3 days

    long lMax = System.currentTimeMillis() + maxLicense;
    long lMin = System.currentTimeMillis() + minLicense;
    if ((lValidityTimestamp > lMin) && (lValidityTimestamp < lMax)) {
        validityTimestamp = Long.toString(lMax);
    }

    // <--- added by me

    mValidityTimestamp = lValidityTimestamp;
    mPreferences.putString(PREF_VALIDITY_TIMESTAMP, validityTimestamp);
}
like image 899
davidcesarino Avatar asked Nov 22 '10 06:11

davidcesarino


4 Answers

Just my two cents, you can define a period of time you would like to check (lets say 3 days). Check for the license after 3 days, if there is no internet, continue letting the user use it for lets say another week max or else the app will not be full functioned. Or just keep it full functioned until there is a connection again, then you can check and reset your time stamp. The license checker will only check when you tell it to.

I can clarify if need be!

Good luck

like image 113
zsniperx Avatar answered Oct 20 '22 00:10

zsniperx


David, the short answer is it is up to you.

Taken directly from the developer document. "For example, the server provides recommended values for the application's license validity period, retry grace period, and maximum allowable retry count, among others."

Depending how you choose to implement the policy, your choosing the answer to your own question.

like image 40
user432209 Avatar answered Oct 20 '22 00:10

user432209


Even with the ServerManagedPolicy, your app will only check for a license when you call "checkAccess()" as described in the checking access section of the licensing doc. If that call is never made, your app will continue to work indefinitely - As such, if you can detect that your users are in a situation where they legitimately cannot ping the server for license information, you can wrap the "checkAccess" call in a condition for that.

Further down the page there's information on setting up test accounts to verify LVL functionality. I highly recommend making good use of that testing functionality.

like image 45
Alexander Lucas Avatar answered Oct 20 '22 00:10

Alexander Lucas


I got the answer to this very simply. Connect a real device via USB to your computer. Edit your LVL library source code in ServerManagedPolicy.java and add in a log statement for the lValidityTimestamp variable using DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM). Then uninstall your application to clear out any previous license cache timestamp, reinstall, and run your app. This contacts the server and then your logging statement reveals the answer. In my testing, the VT comes back to be exactly 1 day from now (when the license is checkes).

like image 39
Shawn Castrianni Avatar answered Oct 19 '22 22:10

Shawn Castrianni