[Android] Prevent potential NPE at app initialization
Geoffrey Métais
git at videolan.org
Wed Nov 15 15:48:48 CET 2017
vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 15 15:43:20 2017 +0100| [f3f316702d555674315d6bd7f205c2cfd0010b80] | committer: Geoffrey Métais
Prevent potential NPE at app initialization
(cherry picked from commit 2f602fbfeea14c36959f77543cb36322d6db7ae5)
> https://code.videolan.org/videolan/vlc-android/commit/f3f316702d555674315d6bd7f205c2cfd0010b80
---
vlc-android/src/org/videolan/vlc/util/AndroidDevices.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
index 9670fc479..fccba6785 100644
--- a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
+++ b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
@@ -103,8 +103,8 @@ public class AndroidDevices {
isChromeBook = pm != null && pm.hasSystemFeature("org.chromium.arc.device_management");
hasPlayServices = pm == null || hasPlayServices(pm);
hasPiP = AndroidUtil.isOOrLater || AndroidUtil.isNougatOrLater && isAndroidTv;
- isPhone = ctx == null || ((TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE))
- .getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
+ final TelephonyManager tm = ctx != null ? ((TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE)) : null;
+ isPhone = tm == null || tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
// hasCombBar test if device has Combined Bar : only for tablet with Honeycomb or ICS
hasCombBar = !AndroidDevices.isPhone && AndroidUtil.isHoneycombOrLater
&& !AndroidUtil.isJellyBeanMR1OrLater;
More information about the Android
mailing list