Loading packages/SystemUI/src/com/android/systemui/dagger/DefaultActivityBinder.java +7 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.app.Activity; import com.android.systemui.ForegroundServicesDialog; import com.android.systemui.keyguard.WorkLockActivity; import com.android.systemui.people.PeopleSpaceActivity; import com.android.systemui.screenrecord.ScreenRecordDialog; import com.android.systemui.settings.brightness.BrightnessDialog; import com.android.systemui.statusbar.tv.notifications.TvNotificationPanelActivity; Loading Loading @@ -92,4 +93,10 @@ public abstract class DefaultActivityBinder { @IntoMap @ClassKey(TvNotificationPanelActivity.class) public abstract Activity bindTvNotificationPanelActivity(TvNotificationPanelActivity activity); /** Inject into PeopleSpaceActivity. */ @Binds @IntoMap @ClassKey(PeopleSpaceActivity.class) public abstract Activity bindPeopleSpaceActivity(PeopleSpaceActivity activity); } packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.java +12 −2 Original line number Diff line number Diff line Loading @@ -37,9 +37,12 @@ import android.view.ViewGroup; import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.UiEventLoggerImpl; import com.android.systemui.R; import com.android.systemui.statusbar.notification.NotificationEntryManager; import java.util.List; import javax.inject.Inject; /** * Shows the user their tiles for their priority People (go/live-status). */ Loading @@ -54,10 +57,17 @@ public class PeopleSpaceActivity extends Activity { private LauncherApps mLauncherApps; private Context mContext; private AppWidgetManager mAppWidgetManager; private NotificationEntryManager mNotificationEntryManager; private int mAppWidgetId; private boolean mShowSingleConversation; private UiEventLogger mUiEventLogger = new UiEventLoggerImpl(); @Inject public PeopleSpaceActivity(NotificationEntryManager notificationEntryManager) { super(); mNotificationEntryManager = notificationEntryManager; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loading Loading @@ -91,8 +101,8 @@ public class PeopleSpaceActivity extends Activity { */ private void setTileViewsWithPriorityConversations() { try { List<PeopleSpaceTile> tiles = PeopleSpaceUtils.getTiles( mContext, mNotificationManager, mPeopleManager, mLauncherApps); List<PeopleSpaceTile> tiles = PeopleSpaceUtils.getTiles(mContext, mNotificationManager, mPeopleManager, mLauncherApps, mNotificationEntryManager); for (PeopleSpaceTile tile : tiles) { PeopleSpaceTileView tileView = new PeopleSpaceTileView(mContext, mPeopleSpaceLayout, tile.getId()); Loading packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java +69 −13 Original line number Diff line number Diff line Loading @@ -60,9 +60,12 @@ import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import com.android.internal.util.ArrayUtils; import com.android.settingslib.utils.ThreadUtils; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.people.widget.LaunchConversationActivity; import com.android.systemui.people.widget.PeopleSpaceWidgetProvider; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import java.text.SimpleDateFormat; import java.time.Duration; Loading Loading @@ -137,7 +140,7 @@ public class PeopleSpaceUtils { /** Returns a list of map entries corresponding to user's conversations. */ public static List<PeopleSpaceTile> getTiles( Context context, INotificationManager notificationManager, IPeopleManager peopleManager, LauncherApps launcherApps) LauncherApps launcherApps, NotificationEntryManager notificationEntryManager) throws Exception { boolean showOnlyPriority = Settings.Global.getInt(context.getContentResolver(), Settings.Global.PEOPLE_SPACE_CONVERSATION_TYPE, 0) == 1; Loading Loading @@ -173,6 +176,8 @@ public class PeopleSpaceUtils { getSortedTiles(peopleManager, launcherApps, mergedStream); tiles.addAll(recentTiles); } tiles = augmentTilesFromVisibleNotifications(tiles, notificationEntryManager); return tiles; } Loading Loading @@ -258,7 +263,8 @@ public class PeopleSpaceUtils { ServiceManager.getService(Context.NOTIFICATION_SERVICE)), IPeopleManager.Stub.asInterface( ServiceManager.getService(Context.PEOPLE_SERVICE)), context.getSystemService(LauncherApps.class)); context.getSystemService(LauncherApps.class), Dependency.get(NotificationEntryManager.class)); Optional<PeopleSpaceTile> entry = tiles.stream().filter( e -> e.getId().equals(shortcutId)).findFirst(); if (entry.isPresent()) { Loading Loading @@ -339,6 +345,41 @@ public class PeopleSpaceUtils { && storedUserId == userId; } static List<PeopleSpaceTile> augmentTilesFromVisibleNotifications(List<PeopleSpaceTile> tiles, NotificationEntryManager notificationEntryManager) { if (notificationEntryManager == null) { Log.w(TAG, "NotificationEntryManager is null"); return tiles; } Map<String, NotificationEntry> visibleNotifications = notificationEntryManager .getVisibleNotifications() .stream() .filter(entry -> entry.getRanking() != null && entry.getRanking().getConversationShortcutInfo() != null) .collect(Collectors.toMap(PeopleSpaceUtils::getKey, e -> e)); if (DEBUG) { Log.d(TAG, "Number of visible notifications:" + visibleNotifications.size()); } return tiles .stream() .map(entry -> augmentTileFromVisibleNotifications(entry, visibleNotifications)) .collect(Collectors.toList()); } static PeopleSpaceTile augmentTileFromVisibleNotifications(PeopleSpaceTile tile, Map<String, NotificationEntry> visibleNotifications) { String shortcutId = tile.getId(); String packageName = tile.getPackageName(); int userId = UserHandle.getUserHandleForUid(tile.getUid()).getIdentifier(); String key = getKey(shortcutId, packageName, userId); if (!visibleNotifications.containsKey(key)) { if (DEBUG) Log.d(TAG, "No existing notifications for key:" + key); return tile; } if (DEBUG) Log.d(TAG, "Augmenting tile from visible notifications, key:" + key); return augmentTileFromNotification(tile, visibleNotifications.get(key).getSbn()); } /** * If incoming notification changed tile, store the changes in the tile options. */ Loading @@ -355,17 +396,7 @@ public class PeopleSpaceUtils { } if (notificationAction == PeopleSpaceUtils.NotificationAction.POSTED) { if (DEBUG) Log.i(TAG, "Adding notification to storage, appWidgetId: " + appWidgetId); Notification.MessagingStyle.Message message = getLastMessagingStyleMessage(sbn); if (message == null) { if (DEBUG) Log.i(TAG, "Notification doesn't have content, skipping."); return; } storedTile = storedTile .toBuilder() .setNotificationKey(sbn.getKey()) .setNotificationContent(message.getText()) .setNotificationDataUri(message.getDataUri()) .build(); storedTile = augmentTileFromNotification(storedTile, sbn); } else { if (DEBUG) { Log.i(TAG, "Removing notification from storage, appWidgetId: " + appWidgetId); Loading @@ -380,6 +411,21 @@ public class PeopleSpaceUtils { updateAppWidgetOptionsAndView(appWidgetManager, context, appWidgetId, storedTile); } static PeopleSpaceTile augmentTileFromNotification(PeopleSpaceTile tile, StatusBarNotification sbn) { Notification.MessagingStyle.Message message = getLastMessagingStyleMessage(sbn); if (message == null) { if (DEBUG) Log.i(TAG, "Notification doesn't have content, skipping."); return tile; } return tile .toBuilder() .setNotificationKey(sbn.getKey()) .setNotificationContent(message.getText()) .setNotificationDataUri(message.getDataUri()) .build(); } private static void updateAppWidgetOptions(AppWidgetManager appWidgetManager, int appWidgetId, PeopleSpaceTile tile) { if (tile == null) { Loading Loading @@ -792,6 +838,16 @@ public class PeopleSpaceUtils { return lookupKeysWithBirthdaysToday; } static String getKey(NotificationEntry entry) { if (entry.getRanking() == null || entry.getRanking().getConversationShortcutInfo() == null || entry.getSbn() == null || entry.getSbn().getUser() == null) { return null; } return getKey(entry.getRanking().getConversationShortcutInfo().getId(), entry.getSbn().getPackageName(), entry.getSbn().getUser().getIdentifier()); } /** * Returns the uniquely identifying key for the conversation. * Loading packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -135,12 +135,14 @@ public class PeopleSpaceWidgetManager { try { String sbnShortcutId = sbn.getShortcutId(); if (sbnShortcutId == null) { if (DEBUG) Log.d(TAG, "Sbn shortcut id is null"); return; } int[] widgetIds = mAppWidgetService.getAppWidgetIds( new ComponentName(mContext, PeopleSpaceWidgetProvider.class) ); if (widgetIds.length == 0) { Log.d(TAG, "No app widget ids returned"); return; } SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); Loading @@ -148,6 +150,7 @@ public class PeopleSpaceWidgetManager { String key = PeopleSpaceUtils.getKey(sbnShortcutId, sbn.getPackageName(), userId); Set<String> storedWidgetIds = new HashSet<>(sp.getStringSet(key, new HashSet<>())); if (storedWidgetIds.isEmpty()) { Log.d(TAG, "No stored widget ids"); return; } for (String widgetIdString : storedWidgetIds) { Loading packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetRemoteViewsFactory.java +5 −1 Original line number Diff line number Diff line Loading @@ -28,9 +28,11 @@ import android.util.Log; import android.widget.RemoteViews; import android.widget.RemoteViewsService; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.people.PeopleSpaceTileView; import com.android.systemui.people.PeopleSpaceUtils; import com.android.systemui.statusbar.notification.NotificationEntryManager; import java.util.ArrayList; import java.util.List; Loading @@ -42,6 +44,7 @@ public class PeopleSpaceWidgetRemoteViewsFactory implements RemoteViewsService.R private IPeopleManager mPeopleManager; private INotificationManager mNotificationManager; private NotificationEntryManager mNotificationEntryManager; private PackageManager mPackageManager; private LauncherApps mLauncherApps; private List<PeopleSpaceTile> mTiles = new ArrayList<>(); Loading @@ -56,6 +59,7 @@ public class PeopleSpaceWidgetRemoteViewsFactory implements RemoteViewsService.R if (DEBUG) Log.d(TAG, "onCreate called"); mNotificationManager = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); mNotificationEntryManager = Dependency.get(NotificationEntryManager.class); mPackageManager = mContext.getPackageManager(); mPeopleManager = IPeopleManager.Stub.asInterface( ServiceManager.getService(Context.PEOPLE_SERVICE)); Loading @@ -70,7 +74,7 @@ public class PeopleSpaceWidgetRemoteViewsFactory implements RemoteViewsService.R private void setTileViewsWithPriorityConversations() { try { mTiles = PeopleSpaceUtils.getTiles(mContext, mNotificationManager, mPeopleManager, mLauncherApps); mPeopleManager, mLauncherApps, mNotificationEntryManager); } catch (Exception e) { Log.e(TAG, "Couldn't retrieve conversations", e); } Loading Loading
packages/SystemUI/src/com/android/systemui/dagger/DefaultActivityBinder.java +7 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.app.Activity; import com.android.systemui.ForegroundServicesDialog; import com.android.systemui.keyguard.WorkLockActivity; import com.android.systemui.people.PeopleSpaceActivity; import com.android.systemui.screenrecord.ScreenRecordDialog; import com.android.systemui.settings.brightness.BrightnessDialog; import com.android.systemui.statusbar.tv.notifications.TvNotificationPanelActivity; Loading Loading @@ -92,4 +93,10 @@ public abstract class DefaultActivityBinder { @IntoMap @ClassKey(TvNotificationPanelActivity.class) public abstract Activity bindTvNotificationPanelActivity(TvNotificationPanelActivity activity); /** Inject into PeopleSpaceActivity. */ @Binds @IntoMap @ClassKey(PeopleSpaceActivity.class) public abstract Activity bindPeopleSpaceActivity(PeopleSpaceActivity activity); }
packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.java +12 −2 Original line number Diff line number Diff line Loading @@ -37,9 +37,12 @@ import android.view.ViewGroup; import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.UiEventLoggerImpl; import com.android.systemui.R; import com.android.systemui.statusbar.notification.NotificationEntryManager; import java.util.List; import javax.inject.Inject; /** * Shows the user their tiles for their priority People (go/live-status). */ Loading @@ -54,10 +57,17 @@ public class PeopleSpaceActivity extends Activity { private LauncherApps mLauncherApps; private Context mContext; private AppWidgetManager mAppWidgetManager; private NotificationEntryManager mNotificationEntryManager; private int mAppWidgetId; private boolean mShowSingleConversation; private UiEventLogger mUiEventLogger = new UiEventLoggerImpl(); @Inject public PeopleSpaceActivity(NotificationEntryManager notificationEntryManager) { super(); mNotificationEntryManager = notificationEntryManager; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loading Loading @@ -91,8 +101,8 @@ public class PeopleSpaceActivity extends Activity { */ private void setTileViewsWithPriorityConversations() { try { List<PeopleSpaceTile> tiles = PeopleSpaceUtils.getTiles( mContext, mNotificationManager, mPeopleManager, mLauncherApps); List<PeopleSpaceTile> tiles = PeopleSpaceUtils.getTiles(mContext, mNotificationManager, mPeopleManager, mLauncherApps, mNotificationEntryManager); for (PeopleSpaceTile tile : tiles) { PeopleSpaceTileView tileView = new PeopleSpaceTileView(mContext, mPeopleSpaceLayout, tile.getId()); Loading
packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java +69 −13 Original line number Diff line number Diff line Loading @@ -60,9 +60,12 @@ import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import com.android.internal.util.ArrayUtils; import com.android.settingslib.utils.ThreadUtils; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.people.widget.LaunchConversationActivity; import com.android.systemui.people.widget.PeopleSpaceWidgetProvider; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import java.text.SimpleDateFormat; import java.time.Duration; Loading Loading @@ -137,7 +140,7 @@ public class PeopleSpaceUtils { /** Returns a list of map entries corresponding to user's conversations. */ public static List<PeopleSpaceTile> getTiles( Context context, INotificationManager notificationManager, IPeopleManager peopleManager, LauncherApps launcherApps) LauncherApps launcherApps, NotificationEntryManager notificationEntryManager) throws Exception { boolean showOnlyPriority = Settings.Global.getInt(context.getContentResolver(), Settings.Global.PEOPLE_SPACE_CONVERSATION_TYPE, 0) == 1; Loading Loading @@ -173,6 +176,8 @@ public class PeopleSpaceUtils { getSortedTiles(peopleManager, launcherApps, mergedStream); tiles.addAll(recentTiles); } tiles = augmentTilesFromVisibleNotifications(tiles, notificationEntryManager); return tiles; } Loading Loading @@ -258,7 +263,8 @@ public class PeopleSpaceUtils { ServiceManager.getService(Context.NOTIFICATION_SERVICE)), IPeopleManager.Stub.asInterface( ServiceManager.getService(Context.PEOPLE_SERVICE)), context.getSystemService(LauncherApps.class)); context.getSystemService(LauncherApps.class), Dependency.get(NotificationEntryManager.class)); Optional<PeopleSpaceTile> entry = tiles.stream().filter( e -> e.getId().equals(shortcutId)).findFirst(); if (entry.isPresent()) { Loading Loading @@ -339,6 +345,41 @@ public class PeopleSpaceUtils { && storedUserId == userId; } static List<PeopleSpaceTile> augmentTilesFromVisibleNotifications(List<PeopleSpaceTile> tiles, NotificationEntryManager notificationEntryManager) { if (notificationEntryManager == null) { Log.w(TAG, "NotificationEntryManager is null"); return tiles; } Map<String, NotificationEntry> visibleNotifications = notificationEntryManager .getVisibleNotifications() .stream() .filter(entry -> entry.getRanking() != null && entry.getRanking().getConversationShortcutInfo() != null) .collect(Collectors.toMap(PeopleSpaceUtils::getKey, e -> e)); if (DEBUG) { Log.d(TAG, "Number of visible notifications:" + visibleNotifications.size()); } return tiles .stream() .map(entry -> augmentTileFromVisibleNotifications(entry, visibleNotifications)) .collect(Collectors.toList()); } static PeopleSpaceTile augmentTileFromVisibleNotifications(PeopleSpaceTile tile, Map<String, NotificationEntry> visibleNotifications) { String shortcutId = tile.getId(); String packageName = tile.getPackageName(); int userId = UserHandle.getUserHandleForUid(tile.getUid()).getIdentifier(); String key = getKey(shortcutId, packageName, userId); if (!visibleNotifications.containsKey(key)) { if (DEBUG) Log.d(TAG, "No existing notifications for key:" + key); return tile; } if (DEBUG) Log.d(TAG, "Augmenting tile from visible notifications, key:" + key); return augmentTileFromNotification(tile, visibleNotifications.get(key).getSbn()); } /** * If incoming notification changed tile, store the changes in the tile options. */ Loading @@ -355,17 +396,7 @@ public class PeopleSpaceUtils { } if (notificationAction == PeopleSpaceUtils.NotificationAction.POSTED) { if (DEBUG) Log.i(TAG, "Adding notification to storage, appWidgetId: " + appWidgetId); Notification.MessagingStyle.Message message = getLastMessagingStyleMessage(sbn); if (message == null) { if (DEBUG) Log.i(TAG, "Notification doesn't have content, skipping."); return; } storedTile = storedTile .toBuilder() .setNotificationKey(sbn.getKey()) .setNotificationContent(message.getText()) .setNotificationDataUri(message.getDataUri()) .build(); storedTile = augmentTileFromNotification(storedTile, sbn); } else { if (DEBUG) { Log.i(TAG, "Removing notification from storage, appWidgetId: " + appWidgetId); Loading @@ -380,6 +411,21 @@ public class PeopleSpaceUtils { updateAppWidgetOptionsAndView(appWidgetManager, context, appWidgetId, storedTile); } static PeopleSpaceTile augmentTileFromNotification(PeopleSpaceTile tile, StatusBarNotification sbn) { Notification.MessagingStyle.Message message = getLastMessagingStyleMessage(sbn); if (message == null) { if (DEBUG) Log.i(TAG, "Notification doesn't have content, skipping."); return tile; } return tile .toBuilder() .setNotificationKey(sbn.getKey()) .setNotificationContent(message.getText()) .setNotificationDataUri(message.getDataUri()) .build(); } private static void updateAppWidgetOptions(AppWidgetManager appWidgetManager, int appWidgetId, PeopleSpaceTile tile) { if (tile == null) { Loading Loading @@ -792,6 +838,16 @@ public class PeopleSpaceUtils { return lookupKeysWithBirthdaysToday; } static String getKey(NotificationEntry entry) { if (entry.getRanking() == null || entry.getRanking().getConversationShortcutInfo() == null || entry.getSbn() == null || entry.getSbn().getUser() == null) { return null; } return getKey(entry.getRanking().getConversationShortcutInfo().getId(), entry.getSbn().getPackageName(), entry.getSbn().getUser().getIdentifier()); } /** * Returns the uniquely identifying key for the conversation. * Loading
packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -135,12 +135,14 @@ public class PeopleSpaceWidgetManager { try { String sbnShortcutId = sbn.getShortcutId(); if (sbnShortcutId == null) { if (DEBUG) Log.d(TAG, "Sbn shortcut id is null"); return; } int[] widgetIds = mAppWidgetService.getAppWidgetIds( new ComponentName(mContext, PeopleSpaceWidgetProvider.class) ); if (widgetIds.length == 0) { Log.d(TAG, "No app widget ids returned"); return; } SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); Loading @@ -148,6 +150,7 @@ public class PeopleSpaceWidgetManager { String key = PeopleSpaceUtils.getKey(sbnShortcutId, sbn.getPackageName(), userId); Set<String> storedWidgetIds = new HashSet<>(sp.getStringSet(key, new HashSet<>())); if (storedWidgetIds.isEmpty()) { Log.d(TAG, "No stored widget ids"); return; } for (String widgetIdString : storedWidgetIds) { Loading
packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetRemoteViewsFactory.java +5 −1 Original line number Diff line number Diff line Loading @@ -28,9 +28,11 @@ import android.util.Log; import android.widget.RemoteViews; import android.widget.RemoteViewsService; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.people.PeopleSpaceTileView; import com.android.systemui.people.PeopleSpaceUtils; import com.android.systemui.statusbar.notification.NotificationEntryManager; import java.util.ArrayList; import java.util.List; Loading @@ -42,6 +44,7 @@ public class PeopleSpaceWidgetRemoteViewsFactory implements RemoteViewsService.R private IPeopleManager mPeopleManager; private INotificationManager mNotificationManager; private NotificationEntryManager mNotificationEntryManager; private PackageManager mPackageManager; private LauncherApps mLauncherApps; private List<PeopleSpaceTile> mTiles = new ArrayList<>(); Loading @@ -56,6 +59,7 @@ public class PeopleSpaceWidgetRemoteViewsFactory implements RemoteViewsService.R if (DEBUG) Log.d(TAG, "onCreate called"); mNotificationManager = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); mNotificationEntryManager = Dependency.get(NotificationEntryManager.class); mPackageManager = mContext.getPackageManager(); mPeopleManager = IPeopleManager.Stub.asInterface( ServiceManager.getService(Context.PEOPLE_SERVICE)); Loading @@ -70,7 +74,7 @@ public class PeopleSpaceWidgetRemoteViewsFactory implements RemoteViewsService.R private void setTileViewsWithPriorityConversations() { try { mTiles = PeopleSpaceUtils.getTiles(mContext, mNotificationManager, mPeopleManager, mLauncherApps); mPeopleManager, mLauncherApps, mNotificationEntryManager); } catch (Exception e) { Log.e(TAG, "Couldn't retrieve conversations", e); } Loading