Merge "[CD Cursor] Add DisplayTopologyValidator" into main
diff --git a/cmds/installd/TEST_MAPPING b/cmds/installd/TEST_MAPPING
index fc4cfc9..d53c94b 100644
--- a/cmds/installd/TEST_MAPPING
+++ b/cmds/installd/TEST_MAPPING
@@ -18,10 +18,6 @@
     {
       "name": "run_dex2oat_test"
     },
-    // AdoptableHostTest moves packages, part of which is handled by installd
-    {
-      "name": "AdoptableHostTest"
-    },
     {
       "name": "CtsUsesLibraryHostTestCases"
     },
diff --git a/include/input/InputFlags.h b/include/input/InputFlags.h
index 4b42f77..16e754e 100644
--- a/include/input/InputFlags.h
+++ b/include/input/InputFlags.h
@@ -22,7 +22,21 @@
 public:
     /**
      * Check if connected displays feature is enabled, either via the feature flag or settings
-     * override.
+     * override. Developer setting override allows enabling all the "desktop experiences" features
+     * including input related connected_displays_cursor flag.
+     *
+     * The developer settings override is prioritised over aconfig flags. Any tests that require
+     * applicable aconfig flags to be disabled with SCOPED_FLAG_OVERRIDE also need this developer
+     * option to be reset locally.
+     *
+     * Also note the developer setting override is only applicable to the desktop experiences
+     * related features.
+     *
+     * To enable only the input flag run:
+     *      adb shell aflags enable com.android.input.flags.connected_displays_cursor
+     * To override this flag and enable all "desktop experiences" features run:
+     *      adb shell aflags enable com.android.window.flags.enable_desktop_mode_through_dev_option
+     *      adb shell setprop persist.wm.debug.desktop_experience_devopts 1
      */
     static bool connectedDisplaysCursorEnabled();
 
diff --git a/libs/binder/BackendUnifiedServiceManager.cpp b/libs/binder/BackendUnifiedServiceManager.cpp
index 7c0319a..b1c8994 100644
--- a/libs/binder/BackendUnifiedServiceManager.cpp
+++ b/libs/binder/BackendUnifiedServiceManager.cpp
@@ -130,7 +130,13 @@
 
 bool BinderCacheWithInvalidation::isClientSideCachingEnabled(const std::string& serviceName) {
     sp<ProcessState> self = ProcessState::selfOrNull();
-    if (!self || self->getThreadPoolMaxTotalThreadCount() <= 0) {
+    // Should not cache if process state could not be found, or if thread pool
+    // max could is not greater than zero.
+    if (!self) {
+        ALOGW("Service retrieved before binder threads started. If they are to be started, "
+              "consider starting binder threads earlier.");
+        return false;
+    } else if (self->getThreadPoolMaxTotalThreadCount() <= 0) {
         ALOGW("Thread Pool max thread count is 0. Cannot cache binder as linkToDeath cannot be "
               "implemented. serviceName: %s",
               serviceName.c_str());
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp
index fa97142..1aae13c 100644
--- a/libs/gui/BLASTBufferQueue.cpp
+++ b/libs/gui/BLASTBufferQueue.cpp
@@ -937,15 +937,22 @@
           : Surface(igbp, controlledByApp, scHandle), mBbq(bbq) {}
 
     void allocateBuffers() override {
+        ATRACE_CALL();
         uint32_t reqWidth = mReqWidth ? mReqWidth : mUserWidth;
         uint32_t reqHeight = mReqHeight ? mReqHeight : mUserHeight;
         auto gbp = getIGraphicBufferProducer();
-        std::thread ([reqWidth, reqHeight, gbp=getIGraphicBufferProducer(),
-                      reqFormat=mReqFormat, reqUsage=mReqUsage] () {
+        std::thread allocateThread([reqWidth, reqHeight, gbp = getIGraphicBufferProducer(),
+                                    reqFormat = mReqFormat, reqUsage = mReqUsage]() {
+            if (com_android_graphics_libgui_flags_allocate_buffer_priority()) {
+                androidSetThreadName("allocateBuffers");
+                pid_t tid = gettid();
+                androidSetThreadPriority(tid, ANDROID_PRIORITY_DISPLAY);
+            }
+
             gbp->allocateBuffers(reqWidth, reqHeight,
                                  reqFormat, reqUsage);
-
-        }).detach();
+        });
+        allocateThread.detach();
     }
 
     status_t setFrameRate(float frameRate, int8_t compatibility,
diff --git a/libs/gui/libgui_flags.aconfig b/libs/gui/libgui_flags.aconfig
index 534f05e..2c3222d 100644
--- a/libs/gui/libgui_flags.aconfig
+++ b/libs/gui/libgui_flags.aconfig
@@ -142,3 +142,14 @@
   bug: "340934031"
   is_fixed_read_only: true
 } # wb_media_migration
+
+flag {
+  name: "allocate_buffer_priority"
+  namespace: "wear_system_health"
+  description: "Boost priority for buffer allocation"
+  bug: "399701430"
+  metadata {
+    purpose: PURPOSE_BUGFIX
+  }
+  is_fixed_read_only: true
+} # allocate_buffer_priority
diff --git a/libs/input/Android.bp b/libs/input/Android.bp
index 0a180a4..52e0276 100644
--- a/libs/input/Android.bp
+++ b/libs/input/Android.bp
@@ -271,6 +271,7 @@
 
     shared_libs: [
         "android.companion.virtualdevice.flags-aconfig-cc",
+        "com.android.window.flags.window-aconfig_flags_c_lib",
         "libPlatformProperties",
         "libaconfig_storage_read_api_cc",
         "libbase",
diff --git a/libs/input/InputFlags.cpp b/libs/input/InputFlags.cpp
index f866f9b..6aa9ae6 100644
--- a/libs/input/InputFlags.cpp
+++ b/libs/input/InputFlags.cpp
@@ -18,6 +18,7 @@
 
 #include <android-base/logging.h>
 #include <com_android_input_flags.h>
+#include <com_android_window_flags.h>
 #include <cutils/properties.h>
 
 #include <string>
@@ -25,6 +26,9 @@
 namespace android {
 
 bool InputFlags::connectedDisplaysCursorEnabled() {
+    if (!com::android::window::flags::enable_desktop_mode_through_dev_option()) {
+        return com::android::input::flags::connected_displays_cursor();
+    }
     static std::optional<bool> cachedDevOption;
     if (!cachedDevOption.has_value()) {
         char value[PROPERTY_VALUE_MAX];
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index de1d13a..b30cf20 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -1389,7 +1389,8 @@
     // or complex GPU shaders and it's expensive. We boost the GPU frequency so that
     // GPU composition can finish in time. We must reset GPU frequency afterwards,
     // because high frequency consumes extra battery.
-    const bool expensiveRenderingExpected =
+    const bool expensiveBlurs = mLayerRequestingBackgroundBlur != nullptr;
+    const bool expensiveRenderingExpected = expensiveBlurs ||
             std::any_of(clientCompositionLayers.begin(), clientCompositionLayers.end(),
                         [outputDataspace =
                                  clientCompositionDisplay.outputDataspace](const auto& layer) {