Android11中,systemUI中,被合并的Notification,是如何展开的,麻烦提供一下源码
时间: 2023-12-01 21:02:58 浏览: 151
在Android 11中,合并的通知在StatusBarNotification中的`isGroup()`方法中被判断。如果返回true,则表示该通知属于一组合并的通知。在展开通知栏时,系统会调用`NotificationGroupManager`类中的`onGroupExpand`方法,该方法中会将该组中的所有通知都展开。
以下是部分源码:
StatusBarNotification.java:
```java
public boolean isGroup() {
return getNotification().isGroupSummary();
}
```
NotificationGroupManager.java:
```java
public void onGroupExpand(NotificationEntry entry, boolean animateChildren) {
...
if (entry.row.isSummaryWithChildren()) {
boolean wasExpanded = entry.row.isGroupExpanded();
entry.row.setExpandAnimationRunning(animateChildren);
entry.row.setChildrenExpanded(true, animateChildren);
entry.row.setExpandAnimationRunning(false);
// Notify that we've expanded a group
mHeadsUpManager.onGroupExpanded(entry.row.getStatusBarNotification());
if (wasExpanded && !animateChildren) {
// No need to update the children if they are already visible and
// we aren't animating the expand gesture
return;
}
NotificationChildrenContainer childrenContainer = entry.row.getChildrenContainer();
ArrayList<ExpandableNotificationRow> notificationChildren =
childrenContainer.getNotificationChildren();
for (int i = 0; i < notificationChildren.size(); i++) {
ExpandableNotificationRow child = notificationChildren.get(i);
child.inflateViews();
mGroupExpansionManager.updateNotificationViews(child.getRow());
}
}
...
}
```
你可以在Android源码中的`frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/`中找到相关的源码。
阅读全文