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

Commit cf52591e authored by Eino-Ville Talvala's avatar Eino-Ville Talvala Committed by Android (Google) Code Review
Browse files

Merge "CameraService: Remove device HALv2 support, other cleanup"

parents fd51bde2 d309fb9c
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ public:

    virtual void onDeviceError(CameraErrorCode errorCode,
            const CaptureResultExtras& resultExtras) {
        (void) resultExtras;
        ALOGE("%s: onDeviceError occurred with: %d", __FUNCTION__, static_cast<int>(errorCode));
        Mutex::Autolock l(mLock);
        mError = true;
@@ -177,6 +178,8 @@ public:

    virtual void onCaptureStarted(const CaptureResultExtras& resultExtras,
            int64_t timestamp) {
        (void) resultExtras;
        (void) timestamp;
        Mutex::Autolock l(mLock);
        mLastStatus = RUNNING;
        mStatusesHit.push_back(mLastStatus);
@@ -186,6 +189,8 @@ public:

    virtual void onResultReceived(const CameraMetadata& metadata,
            const CaptureResultExtras& resultExtras) {
        (void) metadata;
        (void) resultExtras;
        Mutex::Autolock l(mLock);
        mLastStatus = SENT_RESULT;
        mStatusesHit.push_back(mLastStatus);
@@ -193,6 +198,7 @@ public:
    }

    virtual void onPrepared(int streamId) {
        (void) streamId;
        Mutex::Autolock l(mLock);
        mLastStatus = PREPARED;
        mStatusesHit.push_back(mLastStatus);
@@ -465,6 +471,7 @@ TEST_F(CameraClientBinderTest, CheckBinderCameraDeviceUser) {
        callbacks->clearStatus();
        int requestId3 = device->submitRequestList(requestList, /*streaming*/false,
                /*out*/&lastFrameNumber);
        EXPECT_LE(0, requestId3);
        EXPECT_TRUE(callbacks->waitForStatus(TestCameraDeviceCallbacks::SENT_RESULT));
        EXPECT_TRUE(callbacks->waitForIdle());
        EXPECT_LE(lastFrameNumberPrev, lastFrameNumber);
+1 −6
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ include $(CLEAR_VARS)

LOCAL_SRC_FILES:=               \
    CameraService.cpp \
    CameraDeviceFactory.cpp \
    CameraFlashlight.cpp \
    common/Camera2ClientBase.cpp \
    common/CameraDeviceBase.cpp \
@@ -35,14 +34,10 @@ LOCAL_SRC_FILES:= \
    api1/client2/StreamingProcessor.cpp \
    api1/client2/JpegProcessor.cpp \
    api1/client2/CallbackProcessor.cpp \
    api1/client2/ZslProcessor.cpp \
    api1/client2/ZslProcessorInterface.cpp \
    api1/client2/BurstCapture.cpp \
    api1/client2/JpegCompressor.cpp \
    api1/client2/CaptureSequencer.cpp \
    api1/client2/ZslProcessor3.cpp \
    api1/client2/ZslProcessor.cpp \
    api2/CameraDeviceClient.cpp \
    device2/Camera2Device.cpp \
    device3/Camera3Device.cpp \
    device3/Camera3Stream.cpp \
    device3/Camera3IOStreamBase.cpp \
+0 −74
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// #define LOG_NDEBUG 0
#define LOG_TAG "CameraDeviceFactory"
#include <utils/Log.h>

#include "CameraService.h"
#include "CameraDeviceFactory.h"
#include "common/CameraDeviceBase.h"
#include "device2/Camera2Device.h"
#include "device3/Camera3Device.h"

namespace android {

wp<CameraService> CameraDeviceFactory::sService;

sp<CameraDeviceBase> CameraDeviceFactory::createDevice(int cameraId) {

    sp<CameraService> svc = sService.promote();
    if (svc == 0) {
        ALOGE("%s: No service registered", __FUNCTION__);
        return NULL;
    }

    int deviceVersion = svc->getDeviceVersion(cameraId, /*facing*/NULL);

    sp<CameraDeviceBase> device;

    switch (deviceVersion) {
        case CAMERA_DEVICE_API_VERSION_2_0:
        case CAMERA_DEVICE_API_VERSION_2_1:
            device = new Camera2Device(cameraId);
            break;
        case CAMERA_DEVICE_API_VERSION_3_0:
        case CAMERA_DEVICE_API_VERSION_3_1:
        case CAMERA_DEVICE_API_VERSION_3_2:
        case CAMERA_DEVICE_API_VERSION_3_3:
            device = new Camera3Device(cameraId);
            break;
        default:
            ALOGE("%s: Camera %d: Unknown HAL device version %d",
                  __FUNCTION__, cameraId, deviceVersion);
            device = NULL;
            break;
    }

    ALOGV_IF(device != 0, "Created a new camera device for version %d",
                          deviceVersion);

    return device;
}

void CameraDeviceFactory::registerService(wp<CameraService> service) {
    ALOGV("%s: Registered service %p", __FUNCTION__,
          service.promote().get());

    sService = service;
}

}; // namespace android
+0 −45
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_SERVERS_CAMERA_CAMERADEVICEFACTORY_H
#define ANDROID_SERVERS_CAMERA_CAMERADEVICEFACTORY_H

#include <utils/RefBase.h>

namespace android {

class CameraDeviceBase;
class CameraService;

/**
 * Create the right instance of Camera2Device or Camera3Device
 * automatically based on the device version.
 */
class CameraDeviceFactory : public virtual RefBase {
  public:
    static void registerService(wp<CameraService> service);

    // Prerequisite: Call registerService.
    static sp<CameraDeviceBase> createDevice(int cameraId);
  private:
    CameraDeviceFactory(wp<CameraService> service);

    static wp<CameraService> sService;
};

}; // namespace android

#endif
+5 −6
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
#include "gui/IGraphicBufferConsumer.h"
#include "gui/BufferQueue.h"
#include "camera/camera2/CaptureRequest.h"
#include "CameraDeviceFactory.h"
#include "device3/Camera3Device.h"


namespace android {
@@ -78,7 +78,7 @@ status_t CameraFlashlight::createFlashlightControl(const String8& cameraId) {
            deviceVersion = info.device_version;
        }

        if (deviceVersion >= CAMERA_DEVICE_API_VERSION_2_0) {
        if (deviceVersion >= CAMERA_DEVICE_API_VERSION_3_0) {
            CameraDeviceClientFlashControl *flashControl =
                    new CameraDeviceClientFlashControl(*mCameraModule,
                                                       *mCallbacks);
@@ -193,8 +193,6 @@ status_t CameraFlashlight::findFlashUnits() {
}

bool CameraFlashlight::hasFlashUnit(const String8& cameraId) {
    status_t res;

    Mutex::Autolock l(mLock);
    return hasFlashUnitLocked(cameraId);
}
@@ -303,6 +301,7 @@ FlashControlBase::~FlashControlBase() {
ModuleFlashControl::ModuleFlashControl(CameraModule& cameraModule,
        const camera_module_callbacks_t& callbacks) :
        mCameraModule(&cameraModule) {
    (void) callbacks;
}

ModuleFlashControl::~ModuleFlashControl() {
@@ -478,7 +477,7 @@ status_t CameraDeviceClientFlashControl::connectCameraDevice(
    }

    sp<CameraDeviceBase> device =
            CameraDeviceFactory::createDevice(atoi(cameraId.string()));
            new Camera3Device(atoi(cameraId.string()));
    if (device == NULL) {
        return NO_MEMORY;
    }
Loading