Android: Added additional error messages for APK expansion file use.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Thu, 17 Sep 2015 22:36:11 +0200
changeset 9871 381981a8adb6
parent 9870 6dd5ab47534b
child 9872 1052f7697d6f
Android: Added additional error messages for APK expansion file use.
android-project/src/org/libsdl/app/SDLActivity.java
--- a/android-project/src/org/libsdl/app/SDLActivity.java	Thu Sep 17 22:30:24 2015 +0200
+++ b/android-project/src/org/libsdl/app/SDLActivity.java	Thu Sep 17 22:36:11 2015 +0200
@@ -703,8 +703,15 @@
                 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
@@ -719,6 +726,7 @@
                 ex.printStackTrace();
                 expansionFile = null;
                 expansionFileMethod = null;
+                throw new IOException("Could not access APK expansion support library", ex);
             }
         }
 
@@ -727,12 +735,14 @@
         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;