Remove layer from previous relative list.

If a layer is getting a new zOrderRelative, it needs to remove itself
from its previous zOrderRelative's list, if it had one.

Test: Open app that opens the ime. Switch to another app that opens the
ime. Relative layers are updated properly.

Change-Id: I54fbfc0f926d39a1630f3b2faed04fbf428b4fe3
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 5405971..0525607 100755
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1868,6 +1868,10 @@
     mCurrentState.modified = true;
     mCurrentState.z = z;
 
+    auto oldZOrderRelativeOf = mCurrentState.zOrderRelativeOf.promote();
+    if (oldZOrderRelativeOf != nullptr) {
+        oldZOrderRelativeOf->removeZOrderRelative(this);
+    }
     mCurrentState.zOrderRelativeOf = relative;
     relative->addZOrderRelative(this);