Optimize DisplayRepository to reduce lock contention

Despite all the calls to getDisplays() were going on in the background, they were often taking a lot of time, and ending up keeping a lock that was blocking other threads and processes.

This change reduces the binder calls to get displays to only one per addition.

Bug: 345472038
Bug: 344362341
Test: DisplayRepositoryTest
Flag: com.android.systemui.enable_efficient_display_repository
Change-Id: I77a463db42c5ae2c06d59f6bcef2f3f89fa05bef
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 85aa33a..c61f996 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -1076,6 +1076,16 @@
 }
 
 flag {
+   name: "enable_efficient_display_repository"
+   namespace: "systemui"
+   description: "Decide whether to use the new implementation of DisplayRepository that minimizes binder calls and background lock contention."
+   bug: "345472038"
+   metadata {
+     purpose: PURPOSE_BUGFIX
+   }
+}
+
+flag {
   name: "notification_media_manager_background_execution"
   namespace: "systemui"
   description: "Decide whether to execute binder calls in background thread"