Make shouldBeSeamless an enum

We change theboolean shouldBeSemaless to an enum with
three values. This introduces a third value "Default" which
indicates that the layer doesn't have a preference for
seamlessness. This is the default value for Surfaces which
haven't called setFrameRate, or have called setFrameRate(0).

Bug: 161776961
Test: presubmit
Change-Id: I157e332e82e95badc928d6a8135e657cd6984db4
diff --git a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp
index df76110..5a92d0a 100644
--- a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp
+++ b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp
@@ -310,7 +310,7 @@
                                                  /*currentConfigId=*/HWC_CONFIG_ID_60);
 
     const auto makeLayerRequirements = [](float refreshRate) -> std::vector<LayerRequirement> {
-        return {{"testLayer", LayerVoteType::Heuristic, refreshRate, /*shouldBeSeamless*/ true,
+        return {{"testLayer", LayerVoteType::Heuristic, refreshRate, Seamlessness::OnlySeamless,
                  /*weight*/ 1.0f, /*focused*/ false}};
     };
 
@@ -1263,7 +1263,7 @@
     auto& layer = layers[0];
     layer.vote = LayerVoteType::ExplicitDefault;
     layer.desiredRefreshRate = 90.0f;
-    layer.shouldBeSeamless = false;
+    layer.seamlessness = Seamlessness::SeamedAndSeamless;
     layer.name = "90Hz ExplicitDefault";
     layer.focused = true;
 
@@ -1280,32 +1280,49 @@
                       .getConfigId());
 
     // Verify that we won't change the group if seamless switch is required.
-    layer.shouldBeSeamless = true;
+    layer.seamlessness = Seamlessness::OnlySeamless;
     ASSERT_EQ(HWC_CONFIG_ID_60,
               refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false})
                       .getConfigId());
 
-    // At this point the default config in the DisplayManager policy with be 60Hz.
-    // Verify that if the current config is in another group and there are no layers with
-    // shouldBeSeamless=false we'll go back to the default group.
+    // Verify that we won't do a seamless switch if we request the same mode as the default
     refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90);
     layer.desiredRefreshRate = 60.0f;
     layer.name = "60Hz ExplicitDefault";
-    layer.shouldBeSeamless = true;
+    layer.seamlessness = Seamlessness::OnlySeamless;
+    ASSERT_EQ(HWC_CONFIG_ID_90,
+              refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false})
+                      .getConfigId());
+
+    // Verify that if the current config is in another group and there are no layers with
+    // seamlessness=SeamedAndSeamless we'll go back to the default group.
+    layer.desiredRefreshRate = 60.0f;
+    layer.name = "60Hz ExplicitDefault";
+    layer.seamlessness = Seamlessness::Default;
     ASSERT_EQ(HWC_CONFIG_ID_60,
               refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false})
                       .getConfigId());
 
-    // If there's a layer with shouldBeSeamless=false, another layer with shouldBeSeamless=true
-    // can't change the config group.
+    // If there's a layer with seamlessness=SeamedAndSeamless, another layer with
+    // seamlessness=OnlySeamless can't change the config group.
     refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90);
-    auto layer2 = LayerRequirement{.weight = 0.5f};
+    layer.seamlessness = Seamlessness::OnlySeamless;
+
+    layers.push_back(LayerRequirement{.weight = 0.5f});
+    auto& layer2 = layers[layers.size() - 1];
     layer2.vote = LayerVoteType::ExplicitDefault;
     layer2.desiredRefreshRate = 90.0f;
     layer2.name = "90Hz ExplicitDefault";
-    layer2.shouldBeSeamless = false;
+    layer2.seamlessness = Seamlessness::SeamedAndSeamless;
     layer2.focused = false;
-    layers.push_back(layer2);
+
+    ASSERT_EQ(HWC_CONFIG_ID_90,
+              refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false})
+                      .getConfigId());
+
+    // If there's a layer with seamlessness=SeamedAndSeamless, another layer with
+    // seamlessness=Default can't change the config group.
+    layers[0].seamlessness = Seamlessness::Default;
     ASSERT_EQ(HWC_CONFIG_ID_90,
               refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false})
                       .getConfigId());
@@ -1326,7 +1343,7 @@
     auto& layer = layers[0];
     layer.vote = LayerVoteType::ExplicitExactOrMultiple;
     layer.desiredRefreshRate = 60.0f;
-    layer.shouldBeSeamless = false;
+    layer.seamlessness = Seamlessness::SeamedAndSeamless;
     layer.name = "60Hz ExplicitExactOrMultiple";
     layer.focused = true;
 
@@ -1355,13 +1372,13 @@
             LayerRequirement>{LayerRequirement{.name = "60Hz ExplicitDefault",
                                                .vote = LayerVoteType::ExplicitDefault,
                                                .desiredRefreshRate = 60.0f,
-                                               .shouldBeSeamless = false,
+                                               .seamlessness = Seamlessness::SeamedAndSeamless,
                                                .weight = 0.5f,
                                                .focused = false},
                               LayerRequirement{.name = "25Hz ExplicitExactOrMultiple",
                                                .vote = LayerVoteType::ExplicitExactOrMultiple,
                                                .desiredRefreshRate = 25.0f,
-                                               .shouldBeSeamless = true,
+                                               .seamlessness = Seamlessness::OnlySeamless,
                                                .weight = 1.0f,
                                                .focused = true}};
     auto& seamedLayer = layers[0];