Use correct StateSet for LayerVector compare.

Currently LayerVector compare function was using the current StateSet.
This is incorect since the LayerVector may be created with the intention
of sorting the layers by drawing state. Instead, create the LayerVector
with a specified StateSet so the compare function always uses the
correct state.

This fixes an issue where the layers were getting added and sorted by
current state z order but the caller expected the order to be by drawing
state z order.

Change-Id: I7afef556fa72f687bcfeb0a642465488cc72f40b
Fixes: 80516823
Test: No longer flicker when IME closes. Logs show correct z order.
diff --git a/services/surfaceflinger/LayerVector.h b/services/surfaceflinger/LayerVector.h
index a9adb41..88d7711 100644
--- a/services/surfaceflinger/LayerVector.h
+++ b/services/surfaceflinger/LayerVector.h
@@ -32,22 +32,27 @@
  */
 class LayerVector : public SortedVector<sp<Layer>> {
 public:
-    LayerVector();
-    LayerVector(const LayerVector& rhs);
-    ~LayerVector() override;
-
     enum class StateSet {
         Invalid,
         Current,
         Drawing,
     };
 
+    explicit LayerVector(const StateSet stateSet);
+    LayerVector(const LayerVector& rhs, const StateSet stateSet);
+    ~LayerVector() override;
+
+    LayerVector& operator=(const LayerVector& rhs);
+
     // Sorts layer by layer-stack, Z order, and finally creation order (sequence).
     int do_compare(const void* lhs, const void* rhs) const override;
 
     using Visitor = std::function<void(Layer*)>;
     void traverseInReverseZOrder(StateSet stateSet, const Visitor& visitor) const;
     void traverseInZOrder(StateSet stateSet, const Visitor& visitor) const;
+
+private:
+    const StateSet mStateSet;
 };
 }