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

Commit 1f55b131 authored by Biswarup Pal's avatar Biswarup Pal Committed by Android (Google) Code Review
Browse files

Merge "Add method to get id of virtual camera" into main

parents 5caea02d 68137fc4
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2,6 +2,14 @@
  "postsubmit": [
    {
      "name": "virtual_camera_tests"
    },
    {
      "name": "CtsVirtualDevicesCameraTestCases",
      "options": [
        {
          "exclude-annotation": "androidx.test.filters.FlakyTest"
        }
      ]
    }
  ]
}
+2 −0
Original line number Diff line number Diff line
@@ -95,6 +95,8 @@ class VirtualCameraDevice
  // "device@{major}.{minor}/virtual/{numerical_id}"
  std::string getCameraName() const;

  uint32_t getCameraId() const { return mCameraId; }

 private:
  const uint32_t mCameraId;
  const std::shared_ptr<
+21 −0
Original line number Diff line number Diff line
@@ -143,6 +143,27 @@ ndk::ScopedAStatus VirtualCameraService::unregisterCamera(
  return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus VirtualCameraService::getCameraId(
        const ::ndk::SpAIBinder& token, int32_t* _aidl_return) {
  if (_aidl_return == nullptr) {
    return ndk::ScopedAStatus::fromServiceSpecificError(
            Status::EX_ILLEGAL_ARGUMENT);
  }

  auto camera = getCamera(token);
  if (camera == nullptr) {
    ALOGE(
        "Attempt to get camera id corresponding to unknown binder token: "
        "0x%" PRIxPTR,
        reinterpret_cast<uintptr_t>(token.get()));
    return ndk::ScopedAStatus::ok();
  }

  *_aidl_return = camera->getCameraId();

  return ndk::ScopedAStatus::ok();
}

std::shared_ptr<VirtualCameraDevice> VirtualCameraService::getCamera(
    const ::ndk::SpAIBinder& token) {
  if (token == nullptr) {
+4 −0
Original line number Diff line number Diff line
@@ -47,6 +47,10 @@ class VirtualCameraService
  ndk::ScopedAStatus unregisterCamera(const ::ndk::SpAIBinder& token) override
      EXCLUDES(mLock);

  // Returns the camera id corresponding to the binder token.
  ndk::ScopedAStatus getCameraId(
      const ::ndk::SpAIBinder& token, int32_t* _aidl_return) override EXCLUDES(mLock);

  // Returns VirtualCameraDevice corresponding to binder token or nullptr if
  // there's no camera asociated with the token.
  std::shared_ptr<VirtualCameraDevice> getCamera(const ::ndk::SpAIBinder& token)
+6 −0
Original line number Diff line number Diff line
@@ -35,4 +35,10 @@ interface IVirtualCameraService {
     * be visible to the camera framework anymore.
     */
    void unregisterCamera(in IBinder token);

    /**
     * Returns the camera id for a given binder token. Note that this id corresponds to the id of
     * the camera device in the camera framework.
     */
    int getCameraId(in IBinder token);
}