Release the content views when we mark a notification UNINFLATED.

Fixes: 215700025
Test: manual
Change-Id: Ibd5530ca1085dfa459d1b7c919d41156a16db452
This commit is contained in:
Jeff DeCew
2022-01-21 15:59:18 +00:00
parent f5c4898494
commit aecbbd4f2c
6 changed files with 37 additions and 0 deletions

View File

@@ -79,6 +79,11 @@ public class NotifInflaterImpl implements NotifInflater {
entry.abortTask();
}
@Override
public void releaseViews(@NonNull NotificationEntry entry) {
requireBinder().releaseViews(entry);
}
private NotificationContentInflater.InflationCallback wrapInflationCallback(
InflationCallback callback) {
return new NotificationContentInflater.InflationCallback() {

View File

@@ -375,6 +375,7 @@ public class PreparationCoordinator implements Coordinator {
private void freeNotifViews(NotificationEntry entry) {
mViewBarn.removeViewForEntry(entry);
mNotifInflater.releaseViews(entry);
// TODO: clear the entry's row here, or even better, stop setting the row on the entry!
mInflationStates.put(entry, STATE_UNINFLATED);
}

View File

@@ -46,6 +46,11 @@ interface NotifInflater {
*/
fun abortInflation(entry: NotificationEntry)
/**
* Called to let the system remove the content views from the notification row.
*/
fun releaseViews(entry: NotificationEntry)
/**
* Callback once all the views are inflated and bound for a given NotificationEntry.
*/

View File

@@ -50,4 +50,9 @@ public interface NotificationRowBinder {
NotificationUiAdjustment oldAdjustment,
NotificationUiAdjustment newAdjustment,
NotificationRowContentBinder.InflationCallback callback);
/**
* Called when a notification is no longer likely to be displayed and can have its views freed.
*/
void releaseViews(NotificationEntry entry);
}

View File

@@ -16,6 +16,8 @@
package com.android.systemui.statusbar.notification.collection.inflation;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_CONTRACTED;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_EXPANDED;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_PUBLIC;
import static java.util.Objects.requireNonNull;
@@ -161,6 +163,18 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
}
}
@Override
public void releaseViews(NotificationEntry entry) {
if (!entry.rowExists()) {
return;
}
final RowContentBindParams params = mRowContentBindStage.getStageParams(entry);
params.markContentViewsFreeable(FLAG_CONTENT_VIEW_CONTRACTED);
params.markContentViewsFreeable(FLAG_CONTENT_VIEW_EXPANDED);
params.markContentViewsFreeable(FLAG_CONTENT_VIEW_PUBLIC);
mRowContentBindStage.requestRebind(entry, null);
}
/**
* Bind row to various controllers and managers. This is only called when the row is first
* created.
@@ -249,6 +263,8 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
}
RowContentBindParams params = mRowContentBindStage.getStageParams(entry);
params.requireContentViews(FLAG_CONTENT_VIEW_CONTRACTED);
params.requireContentViews(FLAG_CONTENT_VIEW_EXPANDED);
params.setUseIncreasedCollapsedHeight(useIncreasedCollapsedHeight);
params.setUseLowPriority(isLowPriority);
boolean needsRedaction =

View File

@@ -446,6 +446,7 @@ public class PreparationCoordinatorTest extends SysuiTestCase {
mInflateCallbacks.put(entry, callback);
}
@Override
public void rebindViews(@NonNull NotificationEntry entry, @NonNull Params params,
@NonNull InflationCallback callback) {
@@ -462,6 +463,10 @@ public class PreparationCoordinatorTest extends SysuiTestCase {
public void invokeInflateCallbackForEntry(NotificationEntry entry) {
getInflateCallback(entry).onInflationFinished(entry, entry.getRowController());
}
@Override
public void releaseViews(@NonNull NotificationEntry entry) {
}
}
private void fireAddEvents(List<? extends ListEntry> entries) {