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

Commit 0bd3852f authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

Make CameraProviderManager inner classes binder transport agnostic.



In preparation for supporting both aidl and hidl hals.

Bug: 196432585

Test: Camera CTS

Change-Id: Iabddc0cfdaaa95bd4b38125c276cd9c874b500ec
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent 14929832
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ cc_library_shared {
        "common/CameraOfflineSessionBase.cpp",
        "common/CameraProviderManager.cpp",
        "common/FrameProcessorBase.cpp",
        "common/hidl/HidlProviderInfo.cpp",
        "api1/Camera2Client.cpp",
        "api1/client2/Parameters.cpp",
        "api1/client2/FrameProcessor.cpp",
+0 −2
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@

namespace android {

using hardware::camera::common::V1_0::TorchModeStatus;

/////////////////////////////////////////////////////////////////////
// CameraFlashlight implementation begins
// used by camera service to control flashflight.
+2 −20
Original line number Diff line number Diff line
@@ -91,8 +91,6 @@ using frameworks::cameraservice::service::V2_0::implementation::HidlCameraServic
using hardware::ICamera;
using hardware::ICameraClient;
using hardware::ICameraServiceListener;
using hardware::camera::common::V1_0::CameraDeviceStatus;
using hardware::camera::common::V1_0::TorchModeStatus;
using hardware::camera2::ICameraInjectionCallback;
using hardware::camera2::ICameraInjectionSession;
using hardware::camera2::utils::CameraIdAndSessionConfiguration;
@@ -363,7 +361,7 @@ void CameraService::filterSPerfClassCharacteristicsLocked() {

void CameraService::addStates(const String8 id) {
    std::string cameraId(id.c_str());
    hardware::camera::common::V1_0::CameraResourceCost cost;
    CameraResourceCost cost;
    status_t res = mCameraProviderManager->getResourceCost(cameraId, &cost);
    if (res != OK) {
        ALOGE("Failed to query device resource cost: %s (%d)", strerror(-res), res);
@@ -2384,23 +2382,7 @@ Status CameraService::notifyDeviceStateChange(int64_t newState) {

    ATRACE_CALL();

    using hardware::camera::provider::V2_5::DeviceState;
    hardware::hidl_bitfield<DeviceState> newDeviceState{};
    if (newState & ICameraService::DEVICE_STATE_BACK_COVERED) {
        newDeviceState |= DeviceState::BACK_COVERED;
    }
    if (newState & ICameraService::DEVICE_STATE_FRONT_COVERED) {
        newDeviceState |= DeviceState::FRONT_COVERED;
    }
    if (newState & ICameraService::DEVICE_STATE_FOLDED) {
        newDeviceState |= DeviceState::FOLDED;
    }
    // Only map vendor bits directly
    uint64_t vendorBits = static_cast<uint64_t>(newState) & 0xFFFFFFFF00000000l;
    newDeviceState |= vendorBits;

    ALOGV("%s: New device state 0x%" PRIx64, __FUNCTION__, newDeviceState);
    mCameraProviderManager->notifyDeviceStateChange(newDeviceState);
    mCameraProviderManager->notifyDeviceStateChange(newState);

    return Status::ok();
}
+11 −14
Original line number Diff line number Diff line
@@ -106,19 +106,19 @@ public:
    // HAL Callbacks - implements CameraProviderManager::StatusListener

    virtual void        onDeviceStatusChanged(const String8 &cameraId,
            hardware::camera::common::V1_0::CameraDeviceStatus newHalStatus) override;
            CameraDeviceStatus newHalStatus) override;
    virtual void        onDeviceStatusChanged(const String8 &cameraId,
            const String8 &physicalCameraId,
            hardware::camera::common::V1_0::CameraDeviceStatus newHalStatus) override;
            CameraDeviceStatus newHalStatus) override;
    // This method may hold CameraProviderManager::mInterfaceMutex as a part
    // of calling getSystemCameraKind() internally. Care should be taken not to
    // directly / indirectly call this from callers who also hold
    // mInterfaceMutex.
    virtual void        onTorchStatusChanged(const String8& cameraId,
            hardware::camera::common::V1_0::TorchModeStatus newStatus) override;
            TorchModeStatus newStatus) override;
    // Does not hold CameraProviderManager::mInterfaceMutex.
    virtual void        onTorchStatusChanged(const String8& cameraId,
            hardware::camera::common::V1_0::TorchModeStatus newStatus,
            TorchModeStatus newStatus,
            SystemCameraKind kind) override;
    virtual void        onNewProviderRegistered() override;

@@ -558,8 +558,6 @@ public:

private:

    typedef hardware::camera::common::V1_0::CameraDeviceStatus CameraDeviceStatus;

    /**
     * Typesafe version of device status, containing both the HAL-layer and the service interface-
     * layer values.
@@ -1102,7 +1100,7 @@ private:
    // guard mTorchUidMap
    Mutex                mTorchUidMapMutex;
    // camera id -> torch status
    KeyedVector<String8, hardware::camera::common::V1_0::TorchModeStatus>
    KeyedVector<String8, TorchModeStatus>
            mTorchStatusMap;
    // camera id -> torch client binder
    // only store the last client that turns on each camera's torch mode
@@ -1116,16 +1114,16 @@ private:
    // handle torch mode status change and invoke callbacks. mTorchStatusMutex
    // should be locked.
    void onTorchStatusChangedLocked(const String8& cameraId,
            hardware::camera::common::V1_0::TorchModeStatus newStatus,
            TorchModeStatus newStatus,
            SystemCameraKind systemCameraKind);

    // get a camera's torch status. mTorchStatusMutex should be locked.
    status_t getTorchStatusLocked(const String8 &cameraId,
             hardware::camera::common::V1_0::TorchModeStatus *status) const;
             TorchModeStatus *status) const;

    // set a camera's torch status. mTorchStatusMutex should be locked.
    status_t setTorchStatusLocked(const String8 &cameraId,
            hardware::camera::common::V1_0::TorchModeStatus status);
            TorchModeStatus status);

    // notify physical camera status when the physical camera is public.
    // Expects mStatusListenerLock to be locked.
@@ -1236,14 +1234,13 @@ private:
    status_t checkCameraAccess(const String16& opPackageName);

    static String8 toString(std::set<userid_t> intSet);
    static int32_t mapToInterface(hardware::camera::common::V1_0::TorchModeStatus status);
    static StatusInternal mapToInternal(hardware::camera::common::V1_0::CameraDeviceStatus status);
    static int32_t mapToInterface(TorchModeStatus status);
    static StatusInternal mapToInternal(CameraDeviceStatus status);
    static int32_t mapToInterface(StatusInternal status);


    void broadcastTorchModeStatus(const String8& cameraId,
            hardware::camera::common::V1_0::TorchModeStatus status,
            SystemCameraKind systemCameraKind);
            TorchModeStatus status, SystemCameraKind systemCameraKind);

    void broadcastTorchStrengthLevel(const String8& cameraId, int32_t newTorchStrengthLevel);

+1 −19
Original line number Diff line number Diff line
@@ -710,27 +710,9 @@ binder::Status CameraDeviceClient::isSessionConfigurationSupported(
        return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
    }

    hardware::camera::device::V3_8::StreamConfiguration streamConfiguration;
    bool earlyExit = false;
    camera3::metadataGetter getMetadata = [this](const String8 &id, bool /*overrideForPerfClass*/) {
          return mDevice->infoPhysical(id);};
    std::vector<std::string> physicalCameraIds;
    mProviderManager->isLogicalCamera(mCameraIdStr.string(), &physicalCameraIds);
    res = SessionConfigurationUtils::convertToHALStreamCombination(sessionConfiguration,
            mCameraIdStr, mDevice->info(), getMetadata, physicalCameraIds, streamConfiguration,
            mOverrideForPerfClass, &earlyExit);
    if (!res.isOk()) {
        return res;
    }

    if (earlyExit) {
        *status = false;
        return binder::Status::ok();
    }

    *status = false;
    ret = mProviderManager->isSessionConfigurationSupported(mCameraIdStr.string(),
            streamConfiguration, status);
            sessionConfiguration, mOverrideForPerfClass, status);
    switch (ret) {
        case OK:
            // Expected, do nothing.
Loading