aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-11-23 14:58:54 +0100
committerChristian Schneppe <christian@pix-art.de>2018-11-23 14:58:54 +0100
commite5f2c9d1e918be11ac91c055ecc07dad9233c6d3 (patch)
tree191295dfeccb4e25f203f8062e93b0f716cc9db5 /src/main
parent437d88331d49d628b64909c74febceb3d2c0c372 (diff)
catch a few run time exceptions related to androids life cycle mgmt
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java19
-rw-r--r--src/main/java/de/pixart/messenger/utils/Compatibility.java2
2 files changed, 13 insertions, 8 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 9fcb83aa5..7c5d2b64d 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -957,15 +957,18 @@ public class XmppConnectionService extends Service {
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public boolean isInteractive() {
- final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
-
- final boolean isScreenOn;
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
- isScreenOn = pm.isScreenOn();
- } else {
- isScreenOn = pm.isInteractive();
+ try {
+ final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ final boolean isScreenOn;
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
+ isScreenOn = pm.isScreenOn();
+ } else {
+ isScreenOn = pm.isInteractive();
+ }
+ return isScreenOn;
+ } catch (RuntimeException e) {
+ return false;
}
- return isScreenOn;
}
private boolean isPhoneSilenced() {
diff --git a/src/main/java/de/pixart/messenger/utils/Compatibility.java b/src/main/java/de/pixart/messenger/utils/Compatibility.java
index f178f17c7..38f9db378 100644
--- a/src/main/java/de/pixart/messenger/utils/Compatibility.java
+++ b/src/main/java/de/pixart/messenger/utils/Compatibility.java
@@ -56,6 +56,8 @@ public class Compatibility {
return applicationInfo == null || applicationInfo.targetSdkVersion >= 26;
} catch (PackageManager.NameNotFoundException e) {
return true; //when in doubt…
+ } catch (RuntimeException e) {
+ return true; //when in doubt…
}
}