summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewRootImpl.java
diff options
context:
space:
mode:
authorTiger Huang <tigerhuang@google.com>2021-06-24 15:11:04 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-06-24 15:11:04 +0000
commitef1bb2c9fab128b2a9ee869f295b41954629b98f (patch)
treed8afef2db73fc4a818bddeaffaad304912e343eb /core/java/android/view/ViewRootImpl.java
parent0acf11a23d1e5907cf6e6190dec6b9e421b84c5c (diff)
parentc7746aa3deb9deffcab5a50b80ffec4a08740982 (diff)
Merge "Release leashes of insets controls if they are not needed" into sc-dev
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
-rw-r--r--core/java/android/view/ViewRootImpl.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 573ae998305e..210f10c10ad1 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -5290,7 +5290,16 @@ public final class ViewRootImpl implements ViewParent,
// b) When loosing control, controller can restore server state by taking last
// dispatched state as truth.
mInsetsController.onStateChanged((InsetsState) args.arg1);
- mInsetsController.onControlsChanged((InsetsSourceControl[]) args.arg2);
+ InsetsSourceControl[] controls = (InsetsSourceControl[]) args.arg2;
+ if (mAdded) {
+ mInsetsController.onControlsChanged(controls);
+ } else if (controls != null) {
+ for (InsetsSourceControl control : controls) {
+ if (control != null) {
+ control.release(SurfaceControl::release);
+ }
+ }
+ }
args.recycle();
break;
}
@@ -8136,6 +8145,10 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ // If our window is removed, we might not get notified about losing control.
+ // Invoking this can release the leashes as soon as possible instead of relying on GC.
+ mInsetsController.onControlsChanged(null);
+
mAdded = false;
}
WindowManagerGlobal.getInstance().doRemoveView(this);