diff options
author | Hyunyoung Song <hyunyoungs@google.com> | 2019-08-21 02:25:20 -0700 |
---|---|---|
committer | Hyunyoung Song <hyunyoungs@google.com> | 2019-08-21 22:20:03 +0000 |
commit | 227daf0108bc5769d9bb8bec88b0c2bb8ada96b2 (patch) | |
tree | baee44af7cf46e3d6af195d1038a748eea6149ff /src/com/android/launcher3/popup/PopupDataProvider.java | |
parent | 63b2cbc0c7515ca3d34fd8503e6c3f87e5f34162 (diff) | |
parent | d88f63bbed4c4c1e7eace9ab8c25e89ad6c662c9 (diff) | |
download | android_packages_apps_Trebuchet-227daf0108bc5769d9bb8bec88b0c2bb8ada96b2.tar.gz android_packages_apps_Trebuchet-227daf0108bc5769d9bb8bec88b0c2bb8ada96b2.tar.bz2 android_packages_apps_Trebuchet-227daf0108bc5769d9bb8bec88b0c2bb8ada96b2.zip |
ub-launcher3-qt-qpr1-dev @ build 5818303
Test: presubmit setup on source branch
Bug: 112282235 Starting an app from Launcher sometimes takes > 10 sec
Bug: 125027540 Apps to be searchable in different languages
Bug: 132336512 Notification dots on pinned shortcuts
Bug: 135218095 Disable unnecessary services
Bug: 136277517 Widgets often don’t support scroll direction up/down, left/right and use forward/backward instead
Bug: 137777105 Make clearcut launcher logging feature parity with westworld logging
Bug: 137952354 OnResume() and onStop logging doesn't reflect the real source id for -1 screen
Bug: 137953006 Swiping/fling up from workspace logged as hotseat
Bug: 138273985 The pause app message takes more than 30 seconds to display after restarting the device.
Bug: 138683199 Pass the captured snapshot data to Launcher when recents animation is cancelled
Bug: 138729456 [Flaky test] java.lang.AssertionError: http://go/tapl : Can't find an object with selector: BySelector [CLASS='\Qandroid.widget.TextView\E', PKG='\Qcom.google.android.apps.nexuslauncher\E', TEXT='\QShortcut 3\E'] (visible state: Workspace)
Bug: 138743758 [Flaky test] java.lang.AssertionError: App still doesn't have Pause action: com.google.android.calculator
Bug: 138743792 [Flaky test] java.lang.AssertionError: ensureScrollable didn't add Chrome app
Bug: 138964490 Investigate if ToggleableFlags can be connected with DeviceConfig
Bug: 139416391 CTS tests crash when app_prediction service is disabled
Bug: 139498375 Flake: java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
Bug: 139540363 Launcher goes in crash loop
Change-Id: Iaba4ed67e9fe4f8f5858324201e4c4e8711f59fa
Diffstat (limited to 'src/com/android/launcher3/popup/PopupDataProvider.java')
-rw-r--r-- | src/com/android/launcher3/popup/PopupDataProvider.java | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/src/com/android/launcher3/popup/PopupDataProvider.java b/src/com/android/launcher3/popup/PopupDataProvider.java index 2d301ac00..4612b2a47 100644 --- a/src/com/android/launcher3/popup/PopupDataProvider.java +++ b/src/com/android/launcher3/popup/PopupDataProvider.java @@ -29,17 +29,22 @@ import com.android.launcher3.notification.NotificationListener; import com.android.launcher3.shortcuts.DeepShortcutManager; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.PackageUserKey; +import com.android.launcher3.util.ShortcutUtil; import com.android.launcher3.widget.WidgetListRowEntry; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.Predicate; +import java.util.stream.Collectors; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; /** * Provides data for the popup menu that appears after long-clicking on apps. @@ -129,7 +134,8 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan for (PackageUserKey packageUserKey : mPackageUserToDotInfos.keySet()) { DotInfo prevDot = updatedDots.get(packageUserKey); DotInfo newDot = mPackageUserToDotInfos.get(packageUserKey); - if (prevDot == null) { + if (prevDot == null + || prevDot.getNotificationCount() != newDot.getNotificationCount()) { updatedDots.put(packageUserKey, newDot); } else { // No need to update the dot if it already existed (no visual change). @@ -155,7 +161,7 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan } public int getShortcutCountForItem(ItemInfo info) { - if (!DeepShortcutManager.supportsShortcuts(info)) { + if (!ShortcutUtil.supportsDeepShortcuts(info)) { return 0; } ComponentName component = info.getTargetComponent(); @@ -167,17 +173,26 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan return count == null ? 0 : count; } - public DotInfo getDotInfoForItem(ItemInfo info) { - if (!DeepShortcutManager.supportsShortcuts(info)) { + public @Nullable DotInfo getDotInfoForItem(@NonNull ItemInfo info) { + if (!ShortcutUtil.supportsShortcuts(info)) { return null; } - - return mPackageUserToDotInfos.get(PackageUserKey.fromItemInfo(info)); + DotInfo dotInfo = mPackageUserToDotInfos.get(PackageUserKey.fromItemInfo(info)); + if (dotInfo == null) { + return null; + } + List<NotificationKeyData> notifications = getNotificationsForItem( + info, dotInfo.getNotificationKeys()); + if (notifications.isEmpty()) { + return null; + } + return dotInfo; } public @NonNull List<NotificationKeyData> getNotificationKeysForItem(ItemInfo info) { DotInfo dotInfo = getDotInfoForItem(info); - return dotInfo == null ? Collections.EMPTY_LIST : dotInfo.getNotificationKeys(); + return dotInfo == null ? Collections.EMPTY_LIST + : getNotificationsForItem(info, dotInfo.getNotificationKeys()); } /** This makes a potentially expensive binder call and should be run on a background thread. */ @@ -226,6 +241,27 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan return null; } + /** + * Returns a list of notifications that are relevant to given ItemInfo. + */ + public static @NonNull List<NotificationKeyData> getNotificationsForItem( + @NonNull ItemInfo info, @NonNull List<NotificationKeyData> notifications) { + String shortcutId = ShortcutUtil.getShortcutIdIfPinnedShortcut(info); + if (shortcutId == null) { + return notifications; + } + String[] personKeys = ShortcutUtil.getPersonKeysIfPinnedShortcut(info); + return notifications.stream().filter((NotificationKeyData notification) -> { + if (notification.shortcutId != null) { + return notification.shortcutId.equals(shortcutId); + } + if (notification.personKeysFromNotification.length != 0) { + return Arrays.equals(notification.personKeysFromNotification, personKeys); + } + return false; + }).collect(Collectors.toList()); + } + public interface PopupDataChangeListener { PopupDataChangeListener INSTANCE = new PopupDataChangeListener() { }; |