Fix returning an occluded activity below boundary
WindowContainer#getActivity() was returning null if there was no
matching activity or hit the boundary. Since we were unable to
tell the difference between the two cases, we would continue looking
for a matching activity from higher level window containers.
Take below hierarchy for example, #getActivity() returns null if
the boundary was TopActivity. So, we were kept looking for the matching
activity from Task#2 and returns BottomActivity.
RootTask
- Task#1
- TopActivity
- Task#2
- BottomActivity
Bug: 156014697
Test: start activity from recents in split-secondary
Change-Id: Ic344e8c1c47e9fa05c4de60be8c6b30f75cdb0bc
This commit is contained in:
@@ -3589,7 +3589,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
|
||||
@Override
|
||||
ActivityRecord getActivity(Predicate<ActivityRecord> callback, boolean traverseTopToBottom,
|
||||
WindowContainer boundary) {
|
||||
ActivityRecord boundary) {
|
||||
return callback.test(this) ? this : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2689,7 +2689,9 @@ class ActivityStack extends Task {
|
||||
*/
|
||||
@Nullable
|
||||
private ActivityRecord getOccludingActivityAbove(ActivityRecord activity) {
|
||||
return getActivity((ar) -> ar.occludesParent(), true /* traverseTopToBottom */, activity);
|
||||
ActivityRecord top = getActivity((ar) -> ar.occludesParent(),
|
||||
true /* traverseTopToBottom */, activity);
|
||||
return top != activity ? top : null;
|
||||
}
|
||||
|
||||
boolean willActivityBeVisible(IBinder token) {
|
||||
|
||||
@@ -1415,11 +1415,12 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
|
||||
}
|
||||
|
||||
ActivityRecord getActivity(Predicate<ActivityRecord> callback, boolean traverseTopToBottom,
|
||||
WindowContainer boundary) {
|
||||
ActivityRecord boundary) {
|
||||
if (traverseTopToBottom) {
|
||||
for (int i = mChildren.size() - 1; i >= 0; --i) {
|
||||
final WindowContainer wc = mChildren.get(i);
|
||||
if (wc == boundary) return null;
|
||||
// TODO(b/156986561): Improve the correctness of the boundary check.
|
||||
if (wc == boundary) return boundary;
|
||||
|
||||
final ActivityRecord r = wc.getActivity(callback, traverseTopToBottom, boundary);
|
||||
if (r != null) {
|
||||
@@ -1430,7 +1431,8 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
|
||||
final int count = mChildren.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final WindowContainer wc = mChildren.get(i);
|
||||
if (wc == boundary) return null;
|
||||
// TODO(b/156986561): Improve the correctness of the boundary check.
|
||||
if (wc == boundary) return boundary;
|
||||
|
||||
final ActivityRecord r = wc.getActivity(callback, traverseTopToBottom, boundary);
|
||||
if (r != null) {
|
||||
|
||||
Reference in New Issue
Block a user