Skip to content

Commit

Permalink
Android: Added additional error messages for APK expansion file use.
Browse files Browse the repository at this point in the history
  • Loading branch information
philippwiesemann committed Sep 17, 2015
1 parent 6e7c479 commit 625d39b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions android-project/src/org/libsdl/app/SDLActivity.java
Expand Up @@ -703,8 +703,15 @@ public InputStream openAPKExpansionInputStream(String fileName) throws IOExcepti
return null; // no expansion use if no patch version was set
}

Integer mainVersion = Integer.valueOf(mainHint);
Integer patchVersion = Integer.valueOf(patchHint);
Integer mainVersion;
Integer patchVersion;
try {
mainVersion = Integer.valueOf(mainHint);
patchVersion = Integer.valueOf(patchHint);
} catch (NumberFormatException ex) {
ex.printStackTrace();
throw new IOException("No valid file versions set for APK expansion files", ex);
}

try {
// To avoid direct dependency on Google APK expansion library that is
Expand All @@ -719,6 +726,7 @@ public InputStream openAPKExpansionInputStream(String fileName) throws IOExcepti
ex.printStackTrace();
expansionFile = null;
expansionFileMethod = null;
throw new IOException("Could not access APK expansion support library", ex);
}
}

Expand All @@ -727,12 +735,14 @@ public InputStream openAPKExpansionInputStream(String fileName) throws IOExcepti
try {
fileStream = (InputStream)expansionFileMethod.invoke(expansionFile, fileName);
} catch (Exception ex) {
// calling "getInputStream" failed
ex.printStackTrace();
fileStream = null;
throw new IOException("Could not open stream from APK expansion file", ex);
}

if (fileStream == null) {
throw new IOException();
// calling "getInputStream" was successful but null was returned
throw new IOException("Could not open stream from APK expansion file");
}

return fileStream;
Expand Down

0 comments on commit 625d39b

Please sign in to comment.