New Pipeline: Don't skip detaching children; it causes crashes if they are attached later to a different parent.

Fixes: 211574810
Test: I had a reliable repro when building http://ag/q/topic:b194287800_test_empty_shade, and this resolved it.
Change-Id: I7974b471630c767b8bbf6d44434dd68bd103cb01
This commit is contained in:
Jeff DeCew
2022-01-31 21:56:12 +00:00
parent a9f0101e33
commit a7d34d956f
3 changed files with 17 additions and 28 deletions

View File

@@ -104,19 +104,14 @@ class ShadeViewDiffer(
views.remove(childNode.controller.view)
}
if (childCompletelyRemoved && parentSpec == null) {
// If both the child and the parent are being removed at the same time, then
// keep the child attached to the parent for animation purposes
logger.logSkippingDetach(childNode.label, parentNode.label)
} else {
logger.logDetachingChild(
childNode.label,
!childCompletelyRemoved,
parentNode.label,
newParentNode?.label)
parentNode.removeChild(childNode, !childCompletelyRemoved)
childNode.parent = null
}
logger.logDetachingChild(
key = childNode.label,
isTransfer = !childCompletelyRemoved,
isParentRemoved = parentSpec == null,
oldParent = parentNode.label,
newParent = newParentNode?.label)
parentNode.removeChild(childNode, isTransfer = !childCompletelyRemoved)
childNode.parent = null
}
}

View File

@@ -28,25 +28,18 @@ class ShadeViewDifferLogger @Inject constructor(
fun logDetachingChild(
key: String,
isTransfer: Boolean,
isParentRemoved: Boolean,
oldParent: String?,
newParent: String?
) {
buffer.log(TAG, LogLevel.DEBUG, {
str1 = key
bool1 = isTransfer
bool2 = isParentRemoved
str2 = oldParent
str3 = newParent
}, {
"Detach $str1 isTransfer=$bool1 oldParent=$str2 newParent=$str3"
})
}
fun logSkippingDetach(key: String, parent: String?) {
buffer.log(TAG, LogLevel.DEBUG, {
str1 = key
str2 = parent
}, {
"Skipping detach of $str1 because its parent $str2 is also being detached"
"Detach $str1 isTransfer=$bool1 isParentRemoved=$bool2 oldParent=$str2 newParent=$str3"
})
}

View File

@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.collection.render;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import android.content.Context;
import android.testing.AndroidTestingRunner;
@@ -138,7 +139,7 @@ public class ShadeViewDifferTest extends SysuiTestCase {
}
@Test
public void testRemovedGroupsAreKeptTogether() {
public void testRemovedGroupsAreBrokenApart() {
// GIVEN a preexisting tree with a group
applySpecAndCheck(
node(mController1),
@@ -154,10 +155,10 @@ public class ShadeViewDifferTest extends SysuiTestCase {
node(mController1)
);
// THEN the group children are still attached to their parent
assertEquals(mController2.getView(), mController3.getView().getParent());
assertEquals(mController2.getView(), mController4.getView().getParent());
assertEquals(mController2.getView(), mController5.getView().getParent());
// THEN the group children are no longer attached to their parent
assertNull(mController3.getView().getParent());
assertNull(mController4.getView().getParent());
assertNull(mController5.getView().getParent());
}
@Test