Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My expansion APK reader plugin. #14

Open
agamemnus opened this issue Oct 9, 2014 · 2 comments
Open

My expansion APK reader plugin. #14

agamemnus opened this issue Oct 9, 2014 · 2 comments

Comments

@agamemnus
Copy link

Hi moust, psyon. I took some of your base code concepts and made a new plugin.

https://github.com/agamemnus/cordova-plugin-xapkreader

It's almost entirely automated. You just need to modify the XML data and the provider's android:authorities string (in android.json, if rebuilding), and that's it. There's no need to modify any of the java files.

It just uses the content provider URI, no functions.

One big technical problem I had to overcome is getting the version (and other) data into the file reader before it was read. As you probably know, the file reader is run by the content provider before the XAPKReader has a chance to do anything. To solve that, I overrode openAssetFile in XAPKProvider to throw a FileNotFoundException if the version data wasn't sent over the XAPKProvider yet. When the XAPKReader runs, it populates that data and then runs openAssetFile via the webView's openForRead.

You'll find a number of other improvements:

  • It should accept separate main and patch file versions now. (not tested)
  • It should allow you to ignore the file size checks with some boolean switches.
  • The public key data and the text data are all loaded in programmatically from the xml file. No need for .R file linkage.
  • I included the needed Android SDK libraries, already compiled.
@moust
Copy link
Owner

moust commented Oct 13, 2014

It sounds interesting. I will take a look on your fork when I would have the time. It will probably inspire me to improve my own plugin. :)

@agamemnus
Copy link
Author

Well, it's not a fork... I forgot to add the link. Adding it to the first post now.

I made some more changes. All you have to do now is to add the public key and change the content provider in the AndroidManifest.xml file and in the xapkreader.xml file. (or in plugins/android.json)

  • Since there are ever only two possible files, it will just get a directory listing and do some simple pattern matching -- no version specification needed.
  • The patch file now properly works -- it will have precedence any file in the main file. You do have to recompile/update the apk in order for changes to take effect, since the plugin only runs at that point. I had to modify a number of Android SDK library files for this to the point of where adding modified versions to the library made more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants