From 80094235929a2e4bbd42943be7c0d6ec10afb6dd Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 25 Aug 2021 19:26:59 +0200 Subject: [PATCH] fix showing notification counters on Honor devices taken from https://github.com/leolin310148/ShortcutBadger/pull/361 , not tested --- .../leolin/shortcutbadger/ShortcutBadger.java | 21 +++++++++++++++++-- .../shortcutbadger/impl/HuaweiHomeBadger.java | 3 ++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ShortcutBadger/src/main/java/me/leolin/shortcutbadger/ShortcutBadger.java b/ShortcutBadger/src/main/java/me/leolin/shortcutbadger/ShortcutBadger.java index fa0ffa1..5bc3b0a 100644 --- a/ShortcutBadger/src/main/java/me/leolin/shortcutbadger/ShortcutBadger.java +++ b/ShortcutBadger/src/main/java/me/leolin/shortcutbadger/ShortcutBadger.java @@ -258,13 +258,23 @@ private static boolean isLauncherVersionSupported(Context context, String curren /** * Making sure the default Home activity is on top of the returned list - * @param defaultActivity default Home activity - * @param resolveInfos list of all Home activities in the system + * + * @param defaultActivity default Home activity + * @param resolveInfos list of all Home activities in the system */ private static void validateInfoList(ResolveInfo defaultActivity, List resolveInfos) { + if (resolveInfos == null || resolveInfos.isEmpty()) { + return; + } + if (!hasPackageName(defaultActivity)) { + return; + } int indexToSwapWith = 0; for (int i = 0, resolveInfosSize = resolveInfos.size(); i < resolveInfosSize; i++) { ResolveInfo resolveInfo = resolveInfos.get(i); + if (!hasPackageName(resolveInfo)) { + continue; + } String currentActivityName = resolveInfo.activityInfo.packageName; if (currentActivityName.equals(defaultActivity.activityInfo.packageName)) { indexToSwapWith = i; @@ -273,6 +283,13 @@ private static void validateInfoList(ResolveInfo defaultActivity, List getSupportLaunchers() { return Arrays.asList( - "com.huawei.android.launcher" + "com.huawei.android.launcher", + "com.hihonor.android.launcher" ); } }