当没有数据连接处于活动状态时,Android 许可 ServerManagedPolicy 返回 dontAllow
我已经在我的应用程序中按照示例代码实现了 android 许可服务器管理策略。
许可证检查器工作正常,但是当设备或模拟器没有数据连接时,许可代码将始终返回 dontAllow(),而我希望它允许。我似乎在上面的页面上找不到任何详细说明如何避免这种情况的内容。
I've implemented the android licensing in my application following the example code using the ServerManagedPolicy.
The licence checker works fine, however when a device or emulator has no data connection then the licensing code will always return dontAllow(), while I want it to allow. I cannot seem to find anything on the page above that details how to avoid this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是使用测试帐户的问题,它们将在 1 分钟(最小值)后使缓存结果过期,
这可能是因为您可以更改服务器为测试提供的所有可能性的响应,并且您不想等待缓存过期,或者强制它针对每种情况刷新。
This is an issue with using test accounts, they will expire the cached result after 1 minute (the minimum)
This is probably because you can change the response the server gives to the test all possibilities and you wouldn't want to wait for cache to expire, or force it to refresh for each case.
latform-tools/adb install” ;.apk
”命令latform-tools/adb install <file>.apk
" command我可以确认,对于 Play 商店中内部测试轨道上的版本,validityTimestamp 确实在服务器成功“允许”响应后设置为一分钟。经过进一步研究,我知道一分钟的缓存时间从何而来。它不是由服务器明确设置的。它实际上位于 lvl-library 代码中,如上所述,该代码是可编辑的。通常(对于生产版本)服务器将 validTimestamp 返回到“extras”中的 ServerManagedPolicy 类,如下所示:
setValidityTimestamp(extras.get("VT"));
以下是该方法中发生的相关部分:
我添加了一些调试代码来查看该函数的 String 参数是什么。结果发现是一个空字符串。因此,服务器在“VT”的额外映射中没有返回任何内容。 ServerManagedPolicy 中对此类不可解析字符串的响应是使有效性时间戳为当前时间加一分钟 (MILLS_PER_MINUTE)。
I can confirm that for releases on the Internal Test track in the Play Store the validityTimestamp does indeed get set to one minute after a successful "allow" response from the server. And on further research, I know where that one-minute caching period comes from. It is not explicitly set by the server. It is actually in the lvl-library code, which is editable as mentioned above. Normally (for production releases) the server returns the validityTimestamp to the ServerManagedPolicy class in the "extras" as follows:
setValidityTimestamp(extras.get("VT"));
and here is the relevant part of what happens in that method:
I added some debugging code to see what the String parameter to this function was. It turns out to be a null String. So the server is returning nothing in the extras map for "VT". The response in the ServerManagedPolicy to such a non-parsable String is to make the validityTimestamp the current time plus one minute (MILLS_PER_MINUTE).