Skip to content

Commit

Permalink
fix showing notification counters on Honor devices
Browse files Browse the repository at this point in the history
taken from leolin310148#361 , not
tested
  • Loading branch information
tibbi committed Aug 25, 2021
1 parent 01e8e62 commit 8009423
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResolveInfo> 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;
Expand All @@ -273,6 +283,13 @@ private static void validateInfoList(ResolveInfo defaultActivity, List<ResolveIn
Collections.swap(resolveInfos, 0, indexToSwapWith);
}

private static boolean hasPackageName(ResolveInfo resolveInfo) {
if (resolveInfo == null || resolveInfo.activityInfo == null) {
return false;
}
return resolveInfo.activityInfo.packageName != null;
}

// Avoid anybody to instantiate this class
private ShortcutBadger() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public void executeBadge(Context context, ComponentName componentName, int badge
@Override
public List<String> getSupportLaunchers() {
return Arrays.asList(
"com.huawei.android.launcher"
"com.huawei.android.launcher",
"com.hihonor.android.launcher"
);
}
}

0 comments on commit 8009423

Please sign in to comment.