From 71b0c9553cad939b4bf36c1e80425de055d10825 Mon Sep 17 00:00:00 2001 From: "David G. Young" Date: Thu, 21 Sep 2017 18:46:41 +0700 Subject: [PATCH 1/2] Protect against NPE on process util process check --- .../java/org/altbeacon/beacon/utils/ProcessUtils.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/altbeacon/beacon/utils/ProcessUtils.java b/src/main/java/org/altbeacon/beacon/utils/ProcessUtils.java index f0ffb0d70..7cf0959c5 100644 --- a/src/main/java/org/altbeacon/beacon/utils/ProcessUtils.java +++ b/src/main/java/org/altbeacon/beacon/utils/ProcessUtils.java @@ -4,6 +4,8 @@ import android.content.Context; import android.support.annotation.NonNull; +import java.util.List; + /** * Created by dyoung on 3/10/17. * @@ -20,9 +22,12 @@ public ProcessUtils(@NonNull Context context) { public String getProcessName() { ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); - for (ActivityManager.RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) { - if (processInfo.pid == getPid()) { - return processInfo.processName; + List processes = manager.getRunningAppProcesses(); + if (processes != null) { + for (ActivityManager.RunningAppProcessInfo processInfo : processes) { + if (processInfo.pid == getPid()) { + return processInfo.processName; + } } } return null; From a41da6d266976b388e07e60291569407ae42ee89 Mon Sep 17 00:00:00 2001 From: "David G. Young" Date: Thu, 21 Sep 2017 18:52:02 +0700 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f213c0c30..c4c46ce21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### Development Bug Fixes: + - Fix NullPointerException in ProcessUtils. (#598, David G. Young) - Fix ConcurrentModificationException crashing app on Android 8 when monitored regions are changed at the same time the app shifts from active scanning to passive scanning. (#578, David G. Young)