Akheon23 / marketlicensing

Automatically exported from code.google.com/p/marketlicensing
Apache License 2.0
0 stars 0 forks source link

ValidityTimeStamp is always null #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Download licensed application.
2. Start the application verify license is good.
3. Force quit on the application.
4. Disconnect from the web - wait for a minute (used in the ServerManagedPolicy)
5. Activate the application again - response is from the policy is dontAllow.

Expected a longer validity timestamp - at least few days,got NULL instead.

Using Android 2.2 Emulated...
Can it be because of the emulated ?

Original issue reported on code.google.com by yair.oha...@gmail.com on 30 Oct 2010 at 11:29

GoogleCodeExporter commented 9 years ago
Hi,

I have the same problem, but on an actual device. 

VT, GT, GR are always null so I'm not licensed when I shutdown the network 
("grace period disabled"). The primary Google account of my phone is a test 
account. The secondary is the publisher's account but it seems it is ignored.

I'm not that comfortable with this as I wouldn't like this to happen to one of 
my customer.

Original comment by shlu...@gmail.com on 18 Jan 2011 at 2:42

GoogleCodeExporter commented 9 years ago
I actually think it's because the test accounts.
Since none of my customers complained about bad licensing and sadly we cannot 
test it for real...
maybe if you have a customer which you know and can ask for some log output...

Original comment by yair.oha...@gmail.com on 18 Jan 2011 at 8:10

GoogleCodeExporter commented 9 years ago
You must be right. I've seen later on that Trevor posted very interesting 
information about that: 
http://groups.google.com/group/android-developers/browse_thread/thread/a7861900d
99de4f8

That's not a bad idea to prevent test accounts to use cached information, but 
it should be documented.

Thanks for having replied!

Original comment by shlu...@gmail.com on 18 Jan 2011 at 9:23

GoogleCodeExporter commented 9 years ago
Yep.I reviewed my code and i handled it by having set Caching of one week in 
case of successful licensing.
This enables me to perform 1 week tests while being offline(after single online 
license check - ofcourse)- i think its reasonable.

Original comment by yair.oha...@gmail.com on 19 Jan 2011 at 4:41

GoogleCodeExporter commented 9 years ago
I have one customer complaining that it doesn't cache on his Samsung Galaxy 
Tablet, but I have no debugging until I can make another release to the market 
to see what the values are, has anyone else ran into that with these?  I've 
tested on some regular phones and they seem to cache correctly, just by trying 
it not checking values.  Where did you set the 1 week extension or caching did 
you just increment the VT property?

Original comment by gcst...@gmail.com on 19 Jan 2011 at 12:48

GoogleCodeExporter commented 9 years ago
I did it ONLY if i got NULL value - since i didn't want to override Market 
logic.
In the Server managed policy - before returning the result .

I'll attach the code in a few hours if you need it (i am at my day job...)

Original comment by yair.oha...@gmail.com on 19 Jan 2011 at 12:52

GoogleCodeExporter commented 9 years ago
Appreciate it, thank you.

Original comment by gcst...@gmail.com on 19 Jan 2011 at 12:54

GoogleCodeExporter commented 9 years ago
Here you go:

   public void processServerResponse(LicenseResponse response, ResponseData rawData) {

        // Update retry counter
        if (response != LicenseResponse.RETRY) {
            setRetryCount(0);
        } else {
            setRetryCount(mRetryCount + 1);
        }

        if (response == LicenseResponse.LICENSED) {
            // Update server policy data
            Map<String, String> extras = decodeExtras(rawData.extra);
            mLastResponse = response;
            //setValidityTimestamp(extras.get("VT"));
            setValidityTimestamp( String.valueOf(System.currentTimeMillis() + (MILLIS_PER_MINUTE * 60 *24*7)));
            setRetryUntil(extras.get("GT"));
            setMaxRetries(extras.get("GR"));
        } else if (response == LicenseResponse.NOT_LICENSED) {
            // Clear out stale policy data
            setValidityTimestamp(DEFAULT_VALIDITY_TIMESTAMP);
            setRetryUntil(DEFAULT_RETRY_UNTIL);
            setMaxRetries(DEFAULT_MAX_RETRIES);
        }

        setLastResponse(response);
        mPreferences.commit();
    }

Original comment by yair.oha...@gmail.com on 19 Jan 2011 at 7:05

GoogleCodeExporter commented 9 years ago
Great, thanks a lot! setValidityTimestamp, that's one of the most significant 
line of code i've ever seen :)

Original comment by shlu...@gmail.com on 19 Jan 2011 at 10:21

GoogleCodeExporter commented 9 years ago
Thank you for the code but, I don't see where you check for null in there.  
Looks like  your setting every valid response to 1 week?

Original comment by gcst...@gmail.com on 21 Jan 2011 at 2:03

GoogleCodeExporter commented 9 years ago
Yes, on my side I changed

//setValidityTimestamp(extras.get("VT"));
setValidityTimestamp( String.valueOf(System.currentTimeMillis() + 
(MILLIS_PER_MINUTE * 60 *24*7)));

to 

final String vt = extras.get("VT");
setValidityTimestamp(vt == null ? theTimeIWant : vt);

Original comment by shlu...@gmail.com on 21 Jan 2011 at 2:32

GoogleCodeExporter commented 9 years ago
I use test account and real account, but validityTimeStamp(VT) is always null. 
I want to know the value of the VT normally, Thanks

Original comment by kaili.zh...@gmail.com on 23 Nov 2011 at 5:31

GoogleCodeExporter commented 9 years ago
I want to know the value of the VT normally too...

and when i upgraded, verify failed, why?

Original comment by ucam...@gmail.com on 10 May 2012 at 7:49