diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-06-17 21:21:18 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-06-17 21:21:18 +0200 |
commit | 35a37b737084bf91be07d006a6d545b4b0fb659d (patch) | |
tree | 0035a68f596d48331640ed07b24b5ec1d1c01b29 /src/main/java/de/pixart/messenger | |
parent | abee212bc6c133f46cbff50ac1647a91c28cff47 (diff) |
fix some NPE
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/FileBackend.java | 7 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ActionBarActivity.java | 12 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index 8fb5aa406..39c743185 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -433,11 +433,13 @@ public class FileBackend { is = mXmppConnectionService.getContentResolver().openInputStream(uri); byte[] buffer = new byte[1024]; int length; - while ((length = is.read(buffer)) > 0) { + while ((length = is != null ? is.read(buffer) : 0) > 0) { try { os.write(buffer, 0, length); } catch (IOException e) { throw new FileWriterException(); + } catch (Exception e) { + throw new FileWriterException(); } } try { @@ -452,6 +454,9 @@ public class FileBackend { } catch (IOException e) { e.printStackTrace(); throw new FileCopyException(R.string.error_io_exception); + } catch (Exception e) { + e.printStackTrace(); + throw new FileCopyException(R.string.error_unable_to_create_temporary_file); } finally { close(os); close(is); diff --git a/src/main/java/de/pixart/messenger/ui/ActionBarActivity.java b/src/main/java/de/pixart/messenger/ui/ActionBarActivity.java index cab311d58..0bd0c78c7 100644 --- a/src/main/java/de/pixart/messenger/ui/ActionBarActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ActionBarActivity.java @@ -33,10 +33,14 @@ public abstract class ActionBarActivity extends AppCompatActivity { } void initializeScreenshotSecurity() { - if (isScreenSecurityEnabled()) { - getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); - } else { - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE); + try { + if (isScreenSecurityEnabled()) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); + } else { + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE); + } + } catch (Exception e) { + e.printStackTrace(); } } |