| Summary: | PULL REQUEST: Android APK expansion files support | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Alexey <alexey.petruchik> |
| Component: | *don't know* | Assignee: | Gabriel Jacobo <gabomdq> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | enhancement | ||
| Priority: | P2 | CC: | philipp.wiesemann |
| Version: | 2.0.3 | ||
| Hardware: | All | ||
| OS: | Android (All) | ||
|
Description
Alexey
2014-04-14 15:15:50 UTC
In SDLActivity.java openAPKExtensionInputStream() calls getHint() 2x with the same argument. According to convention documented at the top of SDL_hints.h the string for SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION should be "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION". Maybe getHint() could be renamed to nativeGetHint() to match the other native methods. Thanks, Philipp for going through the code. I've fixed issues you discovered. I've also updated branch https://bitbucket.org/stopiccot/sdl/branch/apk. But the main question is still the same: How to deal with dependency on Google library? (In reply to Alexey from comment #2) > still the same: How to deal with dependency on Google library? I have not tried this but maybe reflection could be used. This way the two classes would not need to be imported and it would still compile if the library is not installed. On the other hand this would make the implementation more complicated. What about copying google files to SDL? Is Apache License compatible with license used by SDL? I tried implement the library access using reflection. Here is a patch for SDLActivity.java from the original patch. I have not tested this implementation. 4a5 > import java.lang.reflect.Method; 25,27d25 < import com.android.vending.expansion.zipfile.APKExpansionSupport; < import com.android.vending.expansion.zipfile.ZipResourceFile; < 505c503,506 < private ZipResourceFile expansionFile = null; --- > /** com.android.vending.expansion.zipfile.ZipResourceFile object or null. */ > private Object expansionFile; > /** com.android.vending.expansion.zipfile.ZipResourceFile's getInputStream() or null. */ > private Method expansionFileMethod; 513c514,526 < expansionFile = APKExpansionSupport.getAPKExpansionZipFile(this, mainVersion, patchVersion); --- > try { > expansionFile = Class > .forName("com.android.vending.expansion.zipfile.APKExpansionSupport") > .getMethod("getAPKExpansionZipFile", int.class, int.class) > .invoke(null, mainVersion, patchVersion); > expansionFileMethod = expansionFile > .getClass() > .getMethod("getInputStream", String.class); > } catch (Exception ex) { > ex.printStackTrace(); > expansionFile = null; > expansionFileMethod = null; > } 517c530,536 < InputStream fileStream = expansionFile.getInputStream(fileName); --- > InputStream fileStream; > try { > fileStream = (InputStream) expansionFileMethod.invoke(expansionFile, fileName); > } catch (Exception ex) { > ex.printStackTrace(); > fileStream = null; > } Patch worked almost without modifications. Seems that everything is ready to get merged into mainline. As always all changes can be pulled from https://bitbucket.org/stopiccot/sdl/branch/apk How should I test this? Sorry for such horrible late response. I've missed last e-mail. To test this patch just move some files from APK assets folder to OBB and try to read them. You can read detailed explanation here: http://developer.android.com/google/play/expansion-files.html Please note, that this patch does not implement downloading missing obb's. But it's really a weird case when user downloads app and then removes obb without removing app itself. Merged, thanks! |