当没有数据连接处于活动状态时,Android 许可 ServerManagedPolicy 返回 dontAllow

发布于 2024-09-17 07:23:20 字数 245 浏览 1 评论 0原文

我已经在我的应用程序中按照示例代码实现了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

‖放下 2024-09-24 07:23:20

这是使用测试帐户的问题,它们将在 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.

叹沉浮 2024-09-24 07:23:20
  1. 将示例应用程序上传到 Market。在配置文件中进行更改。
  2. 等待几个小时,在此之前您永远不会从市场获得“许可”测试结果
  3. 在手机上进行测试时,请确保使用与上传相同的 APK:使用“latform-tools/adb install” ;.apk”命令
  1. Upload the example app to Market. Make the changes in the profile.
  2. Wait a few hours, before that you never get the "LICENSED" test result from market
  3. When testing on the phone, make sure to use the same APK as you uploaded: Use the "latform-tools/adb install <file>.apk" command
老子叫无熙 2024-09-24 07:23:20

我可以确认,对于 Play 商店中内部测试轨道上的版本,validityTimestamp 确实在服务器成功“允许”响应后设置为一分钟。经过进一步研究,我知道一分钟的缓存时间从何而来。它不是由服务器明确设置的。它实际上位于 lvl-library 代码中,如上所述,该代码是可编辑的。通常(对于生产版本)服务器将 validTimestamp 返回到“extras”中的 ServerManagedPolicy 类,如下所示:

setValidityTimestamp(extras.get("VT"));

以下是该方法中发生的相关部分:

 private void setValidityTimestamp(String validityTimestamp) {
    Long lValidityTimestamp;
    try {
        lValidityTimestamp = Long.parseLong(validityTimestamp);
    } catch (NumberFormatException e) {
        // No response or not parsable, expire in one minute.
        lValidityTimestamp = System.currentTimeMillis() + MILLIS_PER_MINUTE;
    }

我添加了一些调试代码来查看该函数的 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:

 private void setValidityTimestamp(String validityTimestamp) {
    Long lValidityTimestamp;
    try {
        lValidityTimestamp = Long.parseLong(validityTimestamp);
    } catch (NumberFormatException e) {
        // No response or not parsable, expire in one minute.
        lValidityTimestamp = System.currentTimeMillis() + MILLIS_PER_MINUTE;
    }

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文