SurfaceFlinger: only focused layers can use appRequestRange
When DisplayManager sets the DisplayConfigsSpecs with a policy
that the appRequestRange is broader than the primaryRange,
it means that an app can choose a refresh rate from the
appRequestRange and not from the primaryRange only if that app
explicitly specified a frame rate using setFrameRate API. However,
to avoid cases where we switch the refresh rate back and forth from
the two ranges, we are allowing only applications that their window
is focused from WindowManager's perspective to select refresh rate out
the primaryRange. This matches the behavior of an application that sets
the preferredDisplayModeId.
Bug: 144307188
Bug: 159940172
Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest
Test: YouTube in PIP mode while device is restricted by primaryRange
Change-Id: I26a9690210bb5771bd8aae2bff301031617f7c8f
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 13049ed..03903f6 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1325,6 +1325,10 @@
return Layer::PRIORITY_UNSET;
}
+bool Layer::isLayerFocusedBasedOnPriority(int32_t priority) {
+ return priority == PRIORITY_FOCUSED_WITH_MODE || priority == PRIORITY_FOCUSED_WITHOUT_MODE;
+};
+
uint32_t Layer::getLayerStack() const {
auto p = mDrawingParent.promote();
if (p == nullptr) {
@@ -1558,7 +1562,7 @@
result.append("-------------------------------");
result.append("-------------------------------");
result.append("-------------------------------");
- result.append("---------\n");
+ result.append("-------------------\n");
result.append(" Layer name\n");
result.append(" Z | ");
result.append(" Window Type | ");
@@ -1566,12 +1570,12 @@
result.append(" Transform | ");
result.append(" Disp Frame (LTRB) | ");
result.append(" Source Crop (LTRB) | ");
- result.append(" Frame Rate (Explicit)\n");
+ result.append(" Frame Rate (Explicit) [Focused]\n");
result.append("-------------------------------");
result.append("-------------------------------");
result.append("-------------------------------");
result.append("-------------------------------");
- result.append("---------\n");
+ result.append("-------------------\n");
}
std::string Layer::frameRateCompatibilityString(Layer::FrameRateCompatibility compatibility) {
@@ -1622,17 +1626,20 @@
crop.bottom);
if (layerState.frameRate.rate != 0 ||
layerState.frameRate.type != FrameRateCompatibility::Default) {
- StringAppendF(&result, "% 6.2ffps %15s\n", layerState.frameRate.rate,
+ StringAppendF(&result, "% 6.2ffps %15s", layerState.frameRate.rate,
frameRateCompatibilityString(layerState.frameRate.type).c_str());
} else {
- StringAppendF(&result, "\n");
+ StringAppendF(&result, " ");
}
+ const auto focused = isLayerFocusedBasedOnPriority(getFrameRateSelectionPriority());
+ StringAppendF(&result, " [%s]\n", focused ? "*" : " ");
+
result.append("- - - - - - - - - - - - - - - - ");
result.append("- - - - - - - - - - - - - - - - ");
result.append("- - - - - - - - - - - - - - - - ");
result.append("- - - - - - - - - - - - - - - - ");
- result.append("- - -\n");
+ result.append("- - - - - - - -\n");
}
void Layer::dumpFrameStats(std::string& result) const {