Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6ca5295 authored by Vadim Caen's avatar Vadim Caen
Browse files

Return error code on failed camera creation command

We were not returning the error code in case the test camera could not
be created.

Flag: EXEMPT Bug fix
Bug: 372971702
Test: CtsVirtualDevicesCameraCtsTestCases
Change-Id: I4cf7e98bdea14562fca4b5798a5505787bd4eba1
parent c4a2fe51
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -395,7 +395,7 @@ binder_status_t VirtualCameraService::handleShellCommand(int, int out, int err,
      status = enableTestCameraCmd(out, err, cmd.optionToValueMap);
      break;
    case Command::DISABLE_TEST_CAMERA:
      disableTestCameraCmd(out);
      status = disableTestCameraCmd(out);
      break;
  }

@@ -490,21 +490,23 @@ binder_status_t VirtualCameraService::enableTestCameraCmd(
      mTestCameraToken, configuration,
      cameraId.value_or(std::to_string(sNextIdNumericalPortion++)),
      kDefaultDeviceId, &ret);
  if (ret) {
  if (!ret) {
    dprintf(err, "Failed to create test camera (error %d)\n", ret);
    return ret;
  }

  dprintf(out, "Successfully registered test camera %s\n",
          getCamera(mTestCameraToken)->getCameraName().c_str());
  } else {
    dprintf(err, "Failed to create test camera\n");
  }
  return STATUS_OK;
}

void VirtualCameraService::disableTestCameraCmd(const int out) {
binder_status_t VirtualCameraService::disableTestCameraCmd(const int out) {
  if (mTestCameraToken == nullptr) {
    dprintf(out, "Test camera is not registered.");
  }
  unregisterCamera(mTestCameraToken);
  binder_status_t ret = unregisterCamera(mTestCameraToken).getStatus();
  mTestCameraToken.set(nullptr);
  return ret;
}

}  // namespace virtualcamera
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ class VirtualCameraService
  binder_status_t enableTestCameraCmd(
      int out, int err, const std::map<std::string, std::string>& options);
  // Disable and destroy test camera instance if there's one.
  void disableTestCameraCmd(int out);
  binder_status_t disableTestCameraCmd(int out);

  // Register camera corresponding to the binder token without checking for
  // caller permission.