From 51df70e073adc09afee961713c5d20ea89cee033 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Ricau Date: Mon, 10 Dec 2018 13:09:44 -0800 Subject: [PATCH] Fix impossible null `memInfo` is created two lines above, the code should check for memInfo.totalMem (defaults to 0) --- .../src/main/java/com/facebook/device/yearclass/DeviceInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yearclass/src/main/java/com/facebook/device/yearclass/DeviceInfo.java b/yearclass/src/main/java/com/facebook/device/yearclass/DeviceInfo.java index 1c04c9c..20ef0d2 100644 --- a/yearclass/src/main/java/com/facebook/device/yearclass/DeviceInfo.java +++ b/yearclass/src/main/java/com/facebook/device/yearclass/DeviceInfo.java @@ -182,7 +182,7 @@ public static long getTotalMemory(Context c) { ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo(); ActivityManager am = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE); am.getMemoryInfo(memInfo); - if (memInfo != null) { + if (memInfo.totalMem != 0L) { return memInfo.totalMem; } else { return DEVICEINFO_UNKNOWN;