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/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index bac9430..2dbe2e5 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -1377,7 +1377,12 @@
             Mutex::Autolock l(mLogLock);
             mEventLog.add(msg);
 
-            return -EBUSY;
+            auto current = mActiveClientManager.get(cameraId);
+            if (current != nullptr) {
+                return -EBUSY; // CAMERA_IN_USE
+            } else {
+                return -EUSERS; // MAX_CAMERAS_IN_USE
+            }
         }
 
         for (auto& i : evicted) {
@@ -1669,6 +1674,10 @@
                     return STATUS_ERROR_FMT(ERROR_CAMERA_IN_USE,
                             "Higher-priority client using camera, ID \"%s\" currently unavailable",
                             cameraId.string());
+                case -EUSERS:
+                    return STATUS_ERROR_FMT(ERROR_MAX_CAMERAS_IN_USE,
+                            "Too many cameras already open, cannot open camera \"%s\"",
+                            cameraId.string());
                 default:
                     return STATUS_ERROR_FMT(ERROR_INVALID_OPERATION,
                             "Unexpected error %s (%d) opening camera \"%s\"",