Pebble: fix resource leak on app installation

here
cpfeiffer 2016-12-29 01:29:28 +01:00
parent 0646eda646
commit a96a747119
1 changed files with 11 additions and 3 deletions

View File

@ -60,6 +60,10 @@ public class PBWInstallHandler implements InstallHandler {
installActivity.setInfoText("file not found");
installActivity.setInstallEnabled(false);
return;
} catch (IOException e) {
installActivity.setInfoText("error reading file");
installActivity.setInstallEnabled(false);
return;
}
if (!mPBWReader.isValid()) {
@ -168,18 +172,22 @@ public class PBWInstallHandler implements InstallHandler {
}
InputStream jsConfigFile = mPBWReader.getInputStreamFile("pebble-js-app.js");
if (jsConfigFile != null) {
outputFile = new File(destDir, app.getUUID().toString() + "_config.js");
try {
outputFile = new File(destDir, app.getUUID().toString() + "_config.js");
FileUtils.copyStreamToFile(jsConfigFile, outputFile);
} catch (IOException e) {
LOG.error("Failed to open output file: " + e.getMessage(), e);
} finally {
try {
jsConfigFile.close();
} catch (IOException e) {
}
}
}
}
@Override
public boolean isValid() {
// always pretend it is valid, as we can't know yet about hw/fw version
return true;