fix some NPE

This commit is contained in:
Christian Schneppe 2019-06-17 21:21:18 +02:00
parent abee212bc6
commit 35a37b7370
2 changed files with 14 additions and 5 deletions

View file

@ -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);

View file

@ -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();
}
}