Only log NOTIF INFLATION ABORTED if we may have actually aborted something.

Bug: 236140753
Test: atest PreparationCoodinatorTest
Change-Id: I60fb07e47da7bcb5e81c7a97c9fa7b73310a0335
This commit is contained in:
Jeff DeCew
2022-07-01 17:24:16 +00:00
parent 4a823189a9
commit 3caf79a3ea
5 changed files with 15 additions and 10 deletions

View File

@@ -75,8 +75,8 @@ public class NotifInflaterImpl implements NotifInflater {
}
@Override
public void abortInflation(NotificationEntry entry) {
entry.abortTask();
public boolean abortInflation(NotificationEntry entry) {
return entry.abortTask();
}
@Override

View File

@@ -476,11 +476,13 @@ public final class NotificationEntry extends ListEntry {
/**
* Abort all existing inflation tasks
*/
public void abortTask() {
public boolean abortTask() {
if (mRunningTask != null) {
mRunningTask.abort();
mRunningTask = null;
return true;
}
return false;
}
public void setInflationTask(InflationTask abortableTask) {

View File

@@ -363,9 +363,11 @@ public class PreparationCoordinator implements Coordinator {
}
private void abortInflation(NotificationEntry entry, String reason) {
mLogger.logInflationAborted(entry, reason);
mNotifInflater.abortInflation(entry);
mInflatingNotifs.remove(entry);
final boolean taskAborted = mNotifInflater.abortInflation(entry);
final boolean wasInflating = mInflatingNotifs.remove(entry);
if (taskAborted || wasInflating) {
mLogger.logInflationAborted(entry, reason);
}
}
private void onInflationFinished(NotificationEntry entry, NotifViewController controller) {

View File

@@ -42,9 +42,9 @@ interface NotifInflater {
/**
* Request to stop the inflation of an entry. For example, called when a notification is
* removed and no longer needs to be inflated.
* removed and no longer needs to be inflated. Returns whether anything may have been aborted.
*/
fun abortInflation(entry: NotificationEntry)
fun abortInflation(entry: NotificationEntry): Boolean
/**
* Called to let the system remove the content views from the notification row.
@@ -62,4 +62,4 @@ interface NotifInflater {
* A class holding parameters used when inflating the notification row
*/
class Params(val isLowPriority: Boolean, val reason: String)
}
}

View File

@@ -463,7 +463,8 @@ public class PreparationCoordinatorTest extends SysuiTestCase {
}
@Override
public void abortInflation(@NonNull NotificationEntry entry) {
public boolean abortInflation(@NonNull NotificationEntry entry) {
return false;
}
public InflationCallback getInflateCallback(NotificationEntry entry) {