Merge "Release the content views when we mark a notification UNINFLATED." into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2022-06-08 20:10:55 +00:00
committed by Android (Google) Code Review
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

@@ -376,6 +376,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);

View File

@@ -449,6 +449,7 @@ public class PreparationCoordinatorTest extends SysuiTestCase {
mInflateCallbacks.put(entry, callback);
}
@Override
public void rebindViews(@NonNull NotificationEntry entry, @NonNull Params params,
@NonNull InflationCallback callback) {
@@ -465,6 +466,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) {