1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java Wed Apr 23 03:42:32 2014 +0300
1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java Wed Apr 30 22:51:29 2014 +0300
1.3 @@ -7,6 +7,7 @@
1.4 import java.util.Collections;
1.5 import java.util.Comparator;
1.6 import java.util.List;
1.7 +import java.lang.reflect.Method;
1.8
1.9 import android.app.*;
1.10 import android.content.*;
1.11 @@ -22,9 +23,6 @@
1.12 import android.media.*;
1.13 import android.hardware.*;
1.14
1.15 -import com.android.vending.expansion.zipfile.APKExpansionSupport;
1.16 -import com.android.vending.expansion.zipfile.ZipResourceFile;
1.17 -
1.18 /**
1.19 SDL Activity
1.20 */
1.21 @@ -502,7 +500,12 @@
1.22 }
1.23
1.24 // APK extension files support
1.25 - private ZipResourceFile expansionFile = null;
1.26 +
1.27 + /** com.android.vending.expansion.zipfile.ZipResourceFile object or null. */
1.28 + private Object expansionFile;
1.29 +
1.30 + /** com.android.vending.expansion.zipfile.ZipResourceFile's getInputStream() or null. */
1.31 + private Method expansionFileMethod;
1.32
1.33 public InputStream openAPKExtensionInputStream(String fileName) throws IOException {
1.34 // Get a ZipResourceFile representing a merger of both the main and patch files
1.35 @@ -510,11 +513,28 @@
1.36 Integer mainVersion = Integer.parseInt(nativeGetHint("SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"));
1.37 Integer patchVersion = Integer.parseInt(nativeGetHint("SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"));
1.38
1.39 - expansionFile = APKExpansionSupport.getAPKExpansionZipFile(this, mainVersion, patchVersion);
1.40 + try {
1.41 + expansionFile = Class.forName("com.android.vending.expansion.zipfile.APKExpansionSupport")
1.42 + .getMethod("getAPKExpansionZipFile", Context.class, int.class, int.class)
1.43 + .invoke(null, this, mainVersion, patchVersion);
1.44 +
1.45 + expansionFileMethod = expansionFile.getClass()
1.46 + .getMethod("getInputStream", String.class);
1.47 + } catch (Exception ex) {
1.48 + ex.printStackTrace();
1.49 + expansionFile = null;
1.50 + expansionFileMethod = null;
1.51 + }
1.52 }
1.53
1.54 // Get an input stream for a known file inside the expansion file ZIPs
1.55 - InputStream fileStream = expansionFile.getInputStream(fileName);
1.56 + InputStream fileStream;
1.57 + try {
1.58 + fileStream = (InputStream)expansionFileMethod.invoke(expansionFile, fileName);
1.59 + } catch (Exception ex) {
1.60 + ex.printStackTrace();
1.61 + fileStream = null;
1.62 + }
1.63
1.64 if (fileStream == null) {
1.65 throw new IOException();