SurfaceFlinger: fix dispatching DISPLAY_EVENT_CONFIG_CHANGED
When setting a new desired config, we might be in the middle of a
previous config changed. We need to maintain the information about
whether we need to generate a config changed event and dispatch it when
we are done with the config switch.
Test: manual test to change config from SF
Bug: 122905403
Change-Id: I7efad63b666e83f6459a65a40e6cc880119ca7f6
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index df2bbc3..8ac7917 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -968,9 +968,11 @@
}
// Don't check against the current mode yet. Worst case we set the desired
- // config twice.
+ // config twice. However event generation config might have changed so we need to update it
+ // accordingly
std::lock_guard<std::mutex> lock(mActiveConfigLock);
- mDesiredActiveConfig = ActiveConfigInfo{mode, displayToken, event};
+ const ConfigEvent desiredConfig = mDesiredActiveConfig.event | event;
+ mDesiredActiveConfig = ActiveConfigInfo{mode, displayToken, desiredConfig};
if (!mDesiredActiveConfigChanged) {
// This is the first time we set the desired
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index abc03ec..4dfc29f 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -527,6 +527,13 @@
enum class ConfigEvent { None, Changed };
+ // logical or operator with the semantics of at least one of the events is Changed
+ friend ConfigEvent operator|(const ConfigEvent& first, const ConfigEvent& second) {
+ if (first == ConfigEvent::Changed) return ConfigEvent::Changed;
+ if (second == ConfigEvent::Changed) return ConfigEvent::Changed;
+ return ConfigEvent::None;
+ }
+
// called on the main thread in response to initializeDisplays()
void onInitializeDisplays() REQUIRES(mStateLock);
// Sets the desired active config bit. It obtains the lock, and sets mDesiredActiveConfig.