Camera: update eviction logic for same owner case

Update the eviction logic when the same owner is trying
to open a new camera. The new expected behavior:
   1. If the same camera is opened twice, the second
      open will succeed and the first one would be
      evicted.
   2. If the owner is trying to open a camera that is
      conflicting with any camera that's opened by
      the same owner, the open call will fail.

Before this change, the behavior of #2 above
could vary (either old or new camera being evicted) on
different devices depending on how conflicting device
is listed by camera HAL, which is not exposed to
application developers.

Also added new unit test to verify the eviction logic.

Bug: 153699385
Test: B1 camera CTS test
Change-Id: Id935e30f441d172ba774fc99a2714ade974668a8
diff --git a/services/camera/libcameraservice/utils/ClientManager.h b/services/camera/libcameraservice/utils/ClientManager.h
index 35d25bf..64be6c5 100644
--- a/services/camera/libcameraservice/utils/ClientManager.h
+++ b/services/camera/libcameraservice/utils/ClientManager.h
@@ -496,6 +496,20 @@
                 evictList.clear();
                 evictList.push_back(client);
                 return evictList;
+            } else if (conflicting && owner == curOwner) {
+                // Pre-existing conflicting client with the same client owner exists
+                // Open the same device twice -> most recent open wins
+                // Otherwise let the existing client wins to avoid behaviors difference
+                // due to how HAL advertising conflicting devices (which is hidden from
+                // application)
+                if (curKey == key) {
+                    evictList.push_back(i);
+                    totalCost -= curCost;
+                } else {
+                    evictList.clear();
+                    evictList.push_back(client);
+                    return evictList;
+                }
             } else if (conflicting || ((totalCost > mMaxCost && curCost > 0) &&
                     (curPriority >= priority) &&
                     !(highestPriorityOwner == owner && owner == curOwner))) {