0

I am trying to perform an APKExpansionPolicy check so I can get the URL of the file to download for a custom download. I put up my APK, left it in the unpublished state, uploaded an expansion file, and then test with the emulator to do the LVL call. It returns (no errors) and when i change the options in the google play testing section to always return valid, or false, i see those results as expected. But every time, no matter what I do, the extra strings (url, filename) are not filled in (null).

I'm wondering if I'm trying to do something in the emulator that it just doesn't do. I have also tried different versions of emulator 2.3.3, 4.0, with the same results.

private class MyLicenseCheckerCallback implements LicenseCheckerCallback {
    public void allow(int reason) {
        if (isFinishing()) {
           // Don't update UI if Activity is finishing.
           return;
        }
        // Should allow user access.
        String url = policy.getExpansionURL(APKExpansionPolicy.MAIN_FILE_URL_INDEX);
        String expansionFileName = policy.getExpansionFileName( APKExpansionPolicy.MAIN_FILE_URL_INDEX );
        long expansionFileSize = policy.getExpansionFileSize( APKExpansionPolicy.MAIN_FILE_URL_INDEX );
}
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
LordYabo
  • 41
  • 5

1 Answers1

0

At 2:30am i found the answer...

I'm basically following the Android tutorial on licensing, except i'm using the APKExpansionPolicy.
This didn't work:

policy = new APKExpansionPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId));

And this does:

policy = new APKExpansionPolicy(getApplicationContext(), new AESObfuscator(SALT, getPackageName(), deviceId));

Google Play now passes back the URL, size, and filename of my expansion. Here is the code in context:

String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);

// Library calls this when it's done.
mLicenseCheckerCallback = new MyLicenseCheckerCallback();

policy = new APKExpansionPolicy(getApplicationContext(), new AESObfuscator(SALT, getPackageName(), deviceId));

// Construct the LicenseChecker with a policy.
mChecker = new LicenseChecker(this, policy,base64key);

mChecker.checkAccess(mLicenseCheckerCallback);
LordYabo
  • 41
  • 5
  • Can you check if you changed anything else in that part of code? Doesn't work for me.. I am getting LICENSED response, but 'extras' are empty. – milosmns Jan 11 '15 at 01:17