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 9871381981a8adb6
parent 9870 6dd5ab47534b
child 9872 1052f7697d6f
Android: Added additional error messages for APK expansion file use.
android-project/src/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Thu Sep 17 22:30:24 2015 +0200
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Thu Sep 17 22:36:11 2015 +0200
     1.3 @@ -703,8 +703,15 @@
     1.4                  return null; // no expansion use if no patch version was set
     1.5              }
     1.6  
     1.7 -            Integer mainVersion = Integer.valueOf(mainHint);
     1.8 -            Integer patchVersion = Integer.valueOf(patchHint);
     1.9 +            Integer mainVersion;
    1.10 +            Integer patchVersion;
    1.11 +            try {
    1.12 +                mainVersion = Integer.valueOf(mainHint);
    1.13 +                patchVersion = Integer.valueOf(patchHint);
    1.14 +            } catch (NumberFormatException ex) {
    1.15 +                ex.printStackTrace();
    1.16 +                throw new IOException("No valid file versions set for APK expansion files", ex);
    1.17 +            }
    1.18  
    1.19              try {
    1.20                  // To avoid direct dependency on Google APK expansion library that is
    1.21 @@ -719,6 +726,7 @@
    1.22                  ex.printStackTrace();
    1.23                  expansionFile = null;
    1.24                  expansionFileMethod = null;
    1.25 +                throw new IOException("Could not access APK expansion support library", ex);
    1.26              }
    1.27          }
    1.28  
    1.29 @@ -727,12 +735,14 @@
    1.30          try {
    1.31              fileStream = (InputStream)expansionFileMethod.invoke(expansionFile, fileName);
    1.32          } catch (Exception ex) {
    1.33 +            // calling "getInputStream" failed
    1.34              ex.printStackTrace();
    1.35 -            fileStream = null;
    1.36 +            throw new IOException("Could not open stream from APK expansion file", ex);
    1.37          }
    1.38  
    1.39          if (fileStream == null) {
    1.40 -            throw new IOException();
    1.41 +            // calling "getInputStream" was successful but null was returned
    1.42 +            throw new IOException("Could not open stream from APK expansion file");
    1.43          }
    1.44  
    1.45          return fileStream;