[Android] Prevent potential NPE at app initialization
Geoffrey Métais
git at videolan.org
Wed Nov 15 15:47:38 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 15 15:43:20 2017 +0100| [2f602fbfeea14c36959f77543cb36322d6db7ae5] | committer: Geoffrey Métais
Prevent potential NPE at app initialization
> https://code.videolan.org/videolan/vlc-android/commit/2f602fbfeea14c36959f77543cb36322d6db7ae5
---
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