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

Commit a0dd95d4 authored by Yin-Chia Yeh's avatar Yin-Chia Yeh
Browse files

Camera: fix various VTS issues

Also fix wrong return values for processCaptureRequest in default
wrapper.

Test: running camera VTS
Bug: 64041692
Change-Id: I397390af7c85a776713f6287bef1c4d11c721c9a
Merged-In: I397390af7c85a776713f6287bef1c4d11c721c9a
parent 1d1b503b
Loading
Loading
Loading
Loading
+28 −7
Original line number Original line Diff line number Diff line
@@ -131,22 +131,34 @@ namespace {
    const char *kHAL1_0 = "1.0";
    const char *kHAL1_0 = "1.0";


    bool matchDeviceName(const hidl_string& deviceName,
    bool matchDeviceName(const hidl_string& deviceName,
            const hidl_string &providerType, std::smatch& sm) {
            const hidl_string &providerType,
            std::string* deviceVersion,
            std::string* cameraId) {
        ::android::String8 pattern;
        ::android::String8 pattern;
        pattern.appendFormat(kDeviceNameRE, providerType.c_str());
        pattern.appendFormat(kDeviceNameRE, providerType.c_str());
        std::regex e(pattern.string());
        std::regex e(pattern.string());
        std::string deviceNameStd(deviceName.c_str());
        std::string deviceNameStd(deviceName.c_str());
        return std::regex_match(deviceNameStd, sm, e);
        std::smatch sm;
        if (std::regex_match(deviceNameStd, sm, e)) {
            if (deviceVersion != nullptr) {
                *deviceVersion = sm[1];
            }
            if (cameraId != nullptr) {
                *cameraId = sm[2];
            }
            return true;
        }
        return false;
    }
    }


    int getCameraDeviceVersion(const hidl_string& deviceName,
    int getCameraDeviceVersion(const hidl_string& deviceName,
            const hidl_string &providerType) {
            const hidl_string &providerType) {
        std::smatch sm;
        std::string version;
        bool match = matchDeviceName(deviceName, providerType, sm);
        bool match = matchDeviceName(deviceName, providerType, &version, nullptr);
        if (!match) {
        if (!match) {
            return -1;
            return -1;
        }
        }
        std::string version = sm[1].str();

        if (version.compare(kHAL3_2) == 0) {
        if (version.compare(kHAL3_2) == 0) {
            // maybe switched to 3.4 or define the hidl version enumlater
            // maybe switched to 3.4 or define the hidl version enumlater
            return CAMERA_DEVICE_API_VERSION_3_2;
            return CAMERA_DEVICE_API_VERSION_3_2;
@@ -2977,6 +2989,9 @@ TEST_F(CameraHidlTest, processCaptureRequestPreview) {
                    //Empty settings should be supported after the first call
                    //Empty settings should be supported after the first call
                    //for repeating requests.
                    //for repeating requests.
                    request.settings.setToExternal(nullptr, 0, true);
                    request.settings.setToExternal(nullptr, 0, true);
                    // The buffer has been registered to HAL by bufferId, so per
                    // API contract we should send a null handle for this buffer
                    request.outputBuffers[0].buffer = nullptr;
                    mInflightMap.clear();
                    mInflightMap.clear();
                    inflightReq = {1, false, supportsPartialResults,
                    inflightReq = {1, false, supportsPartialResults,
                                        partialResultCount, resultQueue};
                                        partialResultCount, resultQueue};
@@ -3073,7 +3088,10 @@ TEST_F(CameraHidlTest, processCaptureRequestInvalidSinglePreview) {
                            numRequestProcessed = n;
                            numRequestProcessed = n;
                        });
                        });
                ASSERT_TRUE(ret.isOk());
                ASSERT_TRUE(ret.isOk());
                ASSERT_EQ(Status::INTERNAL_ERROR, status);
                // b/64041692: Temporariy accept ILLEGAL_ARGUMENT or INTERNAL_ERROR
                // It will be changed to only accept ILLEGAL_ARGUMENT in next release
                ASSERT_TRUE(status == Status::ILLEGAL_ARGUMENT ||
                        status == Status::INTERNAL_ERROR);
                ASSERT_EQ(numRequestProcessed, 0u);
                ASSERT_EQ(numRequestProcessed, 0u);


                ret = session->close();
                ret = session->close();
@@ -3134,7 +3152,10 @@ TEST_F(CameraHidlTest, processCaptureRequestInvalidBuffer) {
                            numRequestProcessed = n;
                            numRequestProcessed = n;
                        });
                        });
                ASSERT_TRUE(ret.isOk());
                ASSERT_TRUE(ret.isOk());
                ASSERT_EQ(Status::INTERNAL_ERROR, status);
                // b/64041692: Temporariy accept ILLEGAL_ARGUMENT or INTERNAL_ERROR
                // It will be changed to only accept ILLEGAL_ARGUMENT in next release
                ASSERT_TRUE(status == Status::ILLEGAL_ARGUMENT ||
                        status == Status::INTERNAL_ERROR);
                ASSERT_EQ(numRequestProcessed, 0u);
                ASSERT_EQ(numRequestProcessed, 0u);


                ret = session->close();
                ret = session->close();