Skip to content

Commit

Permalink
Android: Renamed SDLActivity's Java method used for APK expansion files.
Browse files Browse the repository at this point in the history
The name was not correct.
  • Loading branch information
philippwiesemann committed Sep 17, 2015
1 parent 5e59368 commit 92ca42d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions android-project/src/org/libsdl/app/SDLActivity.java
Expand Up @@ -669,7 +669,7 @@ public static void pollInputDevices() {
}
}

// APK extension files support
// APK expansion files support

/** com.android.vending.expansion.zipfile.ZipResourceFile object or null. */
private Object expansionFile;
Expand All @@ -678,16 +678,25 @@ public static void pollInputDevices() {
private Method expansionFileMethod;

/**
* This method is called by SDL using JNI.
* This method was called by SDL using JNI.
* @deprecated because of an incorrect name
*/
@Deprecated
public InputStream openAPKExtensionInputStream(String fileName) throws IOException {
return openAPKExpansionInputStream(fileName);
}

/**
* This method is called by SDL using JNI.
*/
public InputStream openAPKExpansionInputStream(String fileName) throws IOException {
// Get a ZipResourceFile representing a merger of both the main and patch files
if (expansionFile == null) {
Integer mainVersion = Integer.valueOf(nativeGetHint("SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"));
Integer patchVersion = Integer.valueOf(nativeGetHint("SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"));

try {
// To avoid direct dependency on Google APK extension library that is
// To avoid direct dependency on Google APK expansion library that is
// not a part of Android SDK we access it using reflection
expansionFile = Class.forName("com.android.vending.expansion.zipfile.APKExpansionSupport")
.getMethod("getAPKExpansionZipFile", Context.class, int.class, int.class)
Expand Down
4 changes: 2 additions & 2 deletions src/core/android/SDL_android.c
Expand Up @@ -785,9 +785,9 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx)
"open", "(Ljava/lang/String;I)Ljava/io/InputStream;");
inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */);
if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
// Try fallback to APK Extension files
/* Try fallback to APK expansion files */
mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context),
"openAPKExtensionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;");
"openAPKExpansionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;");
inputStream = (*mEnv)->CallObjectMethod(mEnv, context, mid, fileNameJString);

if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
Expand Down

0 comments on commit 92ca42d

Please sign in to comment.