Add NotificationListener to launcher.

- NotificationListener extends NotificationListenerService, and is
  added to the manifest.
- Added PopupDataProvider, which contains logic for storing and
  interacting with data that goes into the long-press popup menu
  (shortcuts and notifications). A follow-up CL will rename
  DeepShortcutsContainer to a generic PopupContainerWithArrow.
- If Launcher has notification access, NotificationListener will
  get callbacks when notifications are posted and removed; upon
  receiving these callbacks, NotificationListener passes them to
  PopupDataProvider via a NotificationsChangedListener interface.
- Upon receiving the changed notifications, PopupDataProvider maps
  them to the corresponding package/user and tells launcher to
  update relevant icons on the workspace and all apps.

This is guarded by FeatureFlags.BADGE_ICONS.

Bug: 32410600
Change-Id: I59aeb31a7f92399c9c4b831ab551e51e13f44f5c
This commit is contained in:
Tony Wickham
2017-01-20 08:15:28 -08:00
parent c711e6006f
commit 010d255018
14 changed files with 655 additions and 35 deletions

View File

@@ -0,0 +1,51 @@
package com.android.launcher3.util;
import android.os.UserHandle;
import android.service.notification.StatusBarNotification;
import com.android.launcher3.ItemInfo;
import java.util.Arrays;
/** Creates a hash key based on package name and user. */
public class PackageUserKey {
private String mPackageName;
private UserHandle mUser;
private int mHashCode;
public static PackageUserKey fromItemInfo(ItemInfo info) {
return new PackageUserKey(info.getTargetComponent().getPackageName(), info.user);
}
public static PackageUserKey fromNotification(StatusBarNotification notification) {
return new PackageUserKey(notification.getPackageName(), notification.getUser());
}
public PackageUserKey(String packageName, UserHandle user) {
update(packageName, user);
}
private void update(String packageName, UserHandle user) {
mPackageName = packageName;
mUser = user;
mHashCode = Arrays.hashCode(new Object[] {packageName, user});
}
/** This should only be called to avoid new object creations in a loop. */
public void updateFromItemInfo(ItemInfo info) {
update(info.getTargetComponent().getPackageName(), info.user);
}
@Override
public int hashCode() {
return mHashCode;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof PackageUserKey)) return false;
PackageUserKey otherKey = (PackageUserKey) obj;
return mPackageName.equals(otherKey.mPackageName) && mUser.equals(otherKey.mUser);
}
}