repeatWhenAttached
This new View extension function replaces WindowAddedViewLifecycleOwner and is
intended for use with views that are not part of an activity.
It is more correct because it properly disposes itself and stops
all previously launched coroutines/jobs when the view is detached from
its view hierarchy.
Test: Extensive unit tests included. Also tested manually making sure that there are no
crashes and that jobs scheduled by a view-binder are properly cleaned up
when the view is detached and replaced by a different view when changing
device configuration using:
$ adb shell wm density 1000
Bug: 235403546
Change-Id: Ied36c9e1735333c482fc82cfbe28e665083795ae
diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp
index ffd6b52..1344144 100644
--- a/packages/SystemUI/Android.bp
+++ b/packages/SystemUI/Android.bp
@@ -225,6 +225,7 @@
"androidx.exifinterface_exifinterface",
"kotlinx-coroutines-android",
"kotlinx-coroutines-core",
+ "kotlinx_coroutines_test",
"iconloader_base",
"SystemUI-tags",
"SystemUI-proto",