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

Commit c4be9794 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6549967 from 67f2ae33 to mainline-release

Change-Id: Ib4e07a058ff8bce1c06722d596eabc8e4ac474cb
parents 36fc70ae 67f2ae33
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -1036,6 +1036,22 @@ const ConfigDeclaration kVehicleProperties[]{
                                .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
                        },
        },
        {
                .config =
                        {
                                .prop = toInt(VehicleProperty::CREATE_USER),
                                .access = VehiclePropertyAccess::READ_WRITE,
                                .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
                        },
        },
        {
                .config =
                        {
                                .prop = toInt(VehicleProperty::REMOVE_USER),
                                .access = VehiclePropertyAccess::READ_WRITE,
                                .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
                        },
        },
        {
                .config =
                        {
+52 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ namespace impl {

constexpr int INITIAL_USER_INFO = static_cast<int>(VehicleProperty::INITIAL_USER_INFO);
constexpr int SWITCH_USER = static_cast<int>(VehicleProperty::SWITCH_USER);
constexpr int CREATE_USER = static_cast<int>(VehicleProperty::CREATE_USER);
constexpr int REMOVE_USER = static_cast<int>(VehicleProperty::REMOVE_USER);
constexpr int USER_IDENTIFICATION_ASSOCIATION =
        static_cast<int>(VehicleProperty::USER_IDENTIFICATION_ASSOCIATION);

@@ -37,6 +39,8 @@ bool EmulatedUserHal::isSupported(int32_t prop) {
    switch (prop) {
        case INITIAL_USER_INFO:
        case SWITCH_USER:
        case CREATE_USER:
        case REMOVE_USER:
        case USER_IDENTIFICATION_ASSOCIATION:
            return true;
        default:
@@ -53,6 +57,11 @@ android::base::Result<std::unique_ptr<VehiclePropValue>> EmulatedUserHal::onSetP
            return onSetInitialUserInfoResponse(value);
        case SWITCH_USER:
            return onSetSwitchUserResponse(value);
        case CREATE_USER:
            return onSetCreateUserResponse(value);
        case REMOVE_USER:
            ALOGI("REMOVE_USER is FYI only, nothing to do...");
            return {};
        case USER_IDENTIFICATION_ASSOCIATION:
            return onSetUserIdentificationAssociation(value);
        default:
@@ -67,6 +76,8 @@ android::base::Result<std::unique_ptr<VehiclePropValue>> EmulatedUserHal::onGetP
    switch (prop) {
        case INITIAL_USER_INFO:
        case SWITCH_USER:
        case CREATE_USER:
        case REMOVE_USER:
            ALOGE("onGetProperty(): %d is only supported on SET", prop);
            return android::base::Error(static_cast<int>(StatusCode::INVALID_ARG))
                   << "only supported on SET";
@@ -162,6 +173,41 @@ android::base::Result<std::unique_ptr<VehiclePropValue>> EmulatedUserHal::onSetS
    return updatedValue;
}

android::base::Result<std::unique_ptr<VehiclePropValue>> EmulatedUserHal::onSetCreateUserResponse(
        const VehiclePropValue& value) {
    if (value.value.int32Values.size() == 0) {
        ALOGE("set(CREATE_USER): no int32values, ignoring it: %s", toString(value).c_str());
        return android::base::Error(static_cast<int>(StatusCode::INVALID_ARG))
               << "no int32values on " << toString(value);
    }

    if (value.areaId != 0) {
        ALOGD("set(CREATE_USER) called from lshal; storing it: %s", toString(value).c_str());
        mCreateUserResponseFromCmd.reset(new VehiclePropValue(value));
        return {};
    }
    ALOGD("set(CREATE_USER) called from Android: %s", toString(value).c_str());

    int32_t requestId = value.value.int32Values[0];
    if (mCreateUserResponseFromCmd != nullptr) {
        ALOGI("replying CREATE_USER with lshal value:  %s",
              toString(*mCreateUserResponseFromCmd).c_str());
        return sendUserHalResponse(std::move(mCreateUserResponseFromCmd), requestId);
    }

    // Returns default response
    auto updatedValue = std::unique_ptr<VehiclePropValue>(new VehiclePropValue);
    updatedValue->prop = CREATE_USER;
    updatedValue->timestamp = elapsedRealtimeNano();
    updatedValue->value.int32Values.resize(2);
    updatedValue->value.int32Values[0] = requestId;
    updatedValue->value.int32Values[1] = (int32_t)CreateUserStatus::SUCCESS;

    ALOGI("no lshal response; replying with SUCCESS: %s", toString(*updatedValue).c_str());

    return updatedValue;
}

android::base::Result<std::unique_ptr<VehiclePropValue>>
EmulatedUserHal::onSetUserIdentificationAssociation(const VehiclePropValue& value) {
    if (value.value.int32Values.size() == 0) {
@@ -247,6 +293,12 @@ void EmulatedUserHal::dump(int fd, std::string indent) {
    } else {
        dprintf(fd, "%sNo SwitchUser response\n", indent.c_str());
    }
    if (mCreateUserResponseFromCmd != nullptr) {
        dprintf(fd, "%sCreateUser response: %s\n", indent.c_str(),
                toString(*mCreateUserResponseFromCmd).c_str());
    } else {
        dprintf(fd, "%sNo CreateUser response\n", indent.c_str());
    }
    if (mSetUserIdentificationAssociationResponseFromCmd != nullptr) {
        dprintf(fd, "%sSetUserIdentificationAssociation response: %s\n", indent.c_str(),
                toString(*mSetUserIdentificationAssociationResponseFromCmd).c_str());
+7 −0
Original line number Diff line number Diff line
@@ -104,6 +104,12 @@ class EmulatedUserHal {
    android::base::Result<std::unique_ptr<VehiclePropValue>> onSetSwitchUserResponse(
            const VehiclePropValue& value);

    /**
     * Used to emulate CREATE_USER - see onSetInitialUserInfoResponse() for usage.
     */
    android::base::Result<std::unique_ptr<VehiclePropValue>> onSetCreateUserResponse(
            const VehiclePropValue& value);

    /**
     * Used to emulate USER_IDENTIFICATION_ASSOCIATION - see onSetInitialUserInfoResponse() for
     * usage.
@@ -116,6 +122,7 @@ class EmulatedUserHal {

    std::unique_ptr<VehiclePropValue> mInitialUserResponseFromCmd;
    std::unique_ptr<VehiclePropValue> mSwitchUserResponseFromCmd;
    std::unique_ptr<VehiclePropValue> mCreateUserResponseFromCmd;
    std::unique_ptr<VehiclePropValue> mSetUserIdentificationAssociationResponseFromCmd;
};

+107 −24
Original line number Diff line number Diff line
@@ -575,7 +575,10 @@ public:
 }
 virtual void TearDown() override {}

 hidl_vec<hidl_string> getCameraDeviceNames(sp<ICameraProvider> provider);
 hidl_vec<hidl_string> getCameraDeviceNames(sp<ICameraProvider> provider,
                                            bool addSecureOnly = false);

 bool isSecureOnly(sp<ICameraProvider> provider, const hidl_string& name);

 std::map<hidl_string, hidl_string> getCameraDeviceIdToNameMap(sp<ICameraProvider> provider);

@@ -799,6 +802,16 @@ public:
            bool *useHalBufManager /*out*/,
            sp<DeviceCb> *cb /*out*/,
            uint32_t streamConfigCounter = 0);
    void configureSingleStream(const std::string& name, int32_t deviceVersion,
            sp<ICameraProvider> provider,
            const AvailableStream* previewThreshold, uint64_t bufferUsage,
            RequestTemplate reqTemplate,
            sp<ICameraDeviceSession>* session /*out*/,
            V3_2::Stream* previewStream /*out*/,
            HalStreamConfiguration* halStreamConfig /*out*/,
            bool* supportsPartialResults /*out*/,
            uint32_t* partialResultCount /*out*/, bool* useHalBufManager /*out*/,
            sp<DeviceCb>* cb /*out*/, uint32_t streamConfigCounter = 0);

    void verifyLogicalCameraMetadata(const std::string& cameraName,
            const ::android::sp<::android::hardware::camera::device::V3_2::ICameraDevice>& device,
@@ -875,6 +888,9 @@ public:
    static Status getSystemCameraKind(const camera_metadata_t* staticMeta,
                                      SystemCameraKind* systemCameraKind);

    void processCaptureRequestInternal(uint64_t bufferusage, RequestTemplate reqTemplate,
                                       bool useSecureOnlyCameras);

    // Used by switchToOffline where a new result queue is created for offline reqs
    void updateInflightResultQueue(std::shared_ptr<ResultMetadataQueue> resultQueue);

@@ -1585,7 +1601,8 @@ std::map<hidl_string, hidl_string> CameraHidlTest::getCameraDeviceIdToNameMap(
    return idToNameMap;
}

hidl_vec<hidl_string> CameraHidlTest::getCameraDeviceNames(sp<ICameraProvider> provider) {
hidl_vec<hidl_string> CameraHidlTest::getCameraDeviceNames(sp<ICameraProvider> provider,
                                                           bool addSecureOnly) {
    std::vector<std::string> cameraDeviceNames;
    Return<void> ret;
    ret = provider->getCameraIdList(
@@ -1634,11 +1651,51 @@ hidl_vec<hidl_string> CameraHidlTest::getCameraDeviceNames(sp<ICameraProvider> p
        }
    }

    hidl_vec<hidl_string> retList(cameraDeviceNames.size());
    std::vector<hidl_string> retList;
    for (size_t i = 0; i < cameraDeviceNames.size(); i++) {
        retList[i] = cameraDeviceNames[i];
        bool isSecureOnlyCamera = isSecureOnly(mProvider, cameraDeviceNames[i]);
        if (addSecureOnly) {
            if (isSecureOnlyCamera) {
                retList.emplace_back(cameraDeviceNames[i]);
            }
    return retList;
        } else if (!isSecureOnlyCamera) {
            retList.emplace_back(cameraDeviceNames[i]);
        }
    }
    hidl_vec<hidl_string> finalRetList = std::move(retList);
    return finalRetList;
}

bool CameraHidlTest::isSecureOnly(sp<ICameraProvider> provider, const hidl_string& name) {
    Return<void> ret;
    ::android::sp<ICameraDevice> device3_x;
    bool retVal = false;
    if (getCameraDeviceVersion(mProviderType, name) == CAMERA_DEVICE_API_VERSION_1_0) {
        return false;
    }
    ret = provider->getCameraDeviceInterface_V3_x(name, [&](auto status, const auto& device) {
        ALOGI("getCameraDeviceInterface_V3_x returns status:%d", (int)status);
        ASSERT_EQ(Status::OK, status);
        ASSERT_NE(device, nullptr);
        device3_x = device;
    });
    if (!ret.isOk()) {
        ADD_FAILURE() << "Failed to get camera device interface for " << name;
    }
    ret = device3_x->getCameraCharacteristics([&](Status s, CameraMetadata metadata) {
        ASSERT_EQ(Status::OK, s);
        camera_metadata_t* chars = (camera_metadata_t*)metadata.data();
        SystemCameraKind systemCameraKind = SystemCameraKind::PUBLIC;
        Status status = getSystemCameraKind(chars, &systemCameraKind);
        ASSERT_EQ(status, Status::OK);
        if (systemCameraKind == SystemCameraKind::HIDDEN_SECURE_CAMERA) {
            retVal = true;
        }
    });
    if (!ret.isOk()) {
        ADD_FAILURE() << "Failed to get camera characteristics for device " << name;
    }
    return retVal;
}

hidl_vec<hidl_vec<hidl_string>> CameraHidlTest::getConcurrentDeviceCombinations(
@@ -4316,8 +4373,21 @@ TEST_P(CameraHidlTest, configureStreamsVideoStillOutputs) {

// Generate and verify a camera capture request
TEST_P(CameraHidlTest, processCaptureRequestPreview) {
    hidl_vec<hidl_string> cameraDeviceNames = getCameraDeviceNames(mProvider);
    AvailableStream previewThreshold = {kMaxPreviewWidth, kMaxPreviewHeight,
    processCaptureRequestInternal(GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, RequestTemplate::PREVIEW,
                                  false /*secureOnlyCameras*/);
}

// Generate and verify a secure camera capture request
TEST_P(CameraHidlTest, processSecureCaptureRequest) {
    processCaptureRequestInternal(GRALLOC1_PRODUCER_USAGE_PROTECTED, RequestTemplate::STILL_CAPTURE,
                                  true /*secureOnlyCameras*/);
}

void CameraHidlTest::processCaptureRequestInternal(uint64_t bufferUsage,
                                                   RequestTemplate reqTemplate,
                                                   bool useSecureOnlyCameras) {
    hidl_vec<hidl_string> cameraDeviceNames = getCameraDeviceNames(mProvider, useSecureOnlyCameras);
    AvailableStream streamThreshold = {kMaxPreviewWidth, kMaxPreviewHeight,
                                        static_cast<int32_t>(PixelFormat::IMPLEMENTATION_DEFINED)};
    uint64_t bufferId = 1;
    uint32_t frameNumber = 1;
@@ -4333,16 +4403,16 @@ TEST_P(CameraHidlTest, processCaptureRequestPreview) {
            return;
        }

        V3_2::Stream previewStream;
        V3_2::Stream testStream;
        HalStreamConfiguration halStreamConfig;
        sp<ICameraDeviceSession> session;
        sp<DeviceCb> cb;
        bool supportsPartialResults = false;
        bool useHalBufManager = false;
        uint32_t partialResultCount = 0;
        configurePreviewStream(name, deviceVersion, mProvider, &previewThreshold, &session /*out*/,
                &previewStream /*out*/, &halStreamConfig /*out*/,
                &supportsPartialResults /*out*/,
        configureSingleStream(name, deviceVersion, mProvider, &streamThreshold, bufferUsage,
                              reqTemplate, &session /*out*/, &testStream /*out*/,
                              &halStreamConfig /*out*/, &supportsPartialResults /*out*/,
                              &partialResultCount /*out*/, &useHalBufManager /*out*/, &cb /*out*/);

        std::shared_ptr<ResultMetadataQueue> resultQueue;
@@ -4364,7 +4434,6 @@ TEST_P(CameraHidlTest, processCaptureRequestPreview) {
        InFlightRequest inflightReq = {1, false, supportsPartialResults,
                                       partialResultCount, resultQueue};

        RequestTemplate reqTemplate = RequestTemplate::PREVIEW;
        Return<void> ret;
        ret = session->constructDefaultRequestSettings(reqTemplate,
                                                       [&](auto status, const auto& req) {
@@ -4383,7 +4452,7 @@ TEST_P(CameraHidlTest, processCaptureRequestPreview) {
                            nullptr,
                            nullptr};
        } else {
            allocateGraphicBuffer(previewStream.width, previewStream.height,
            allocateGraphicBuffer(testStream.width, testStream.height,
                    android_convertGralloc1To0Usage(halStreamConfig.streams[0].producerUsage,
                        halStreamConfig.streams[0].consumerUsage),
                    halStreamConfig.streams[0].overrideFormat, &buffer_handle);
@@ -4432,7 +4501,7 @@ TEST_P(CameraHidlTest, processCaptureRequestPreview) {

            ASSERT_FALSE(inflightReq.errorCodeValid);
            ASSERT_NE(inflightReq.resultOutputBuffers.size(), 0u);
            ASSERT_EQ(previewStream.id, inflightReq.resultOutputBuffers[0].streamId);
            ASSERT_EQ(testStream.id, inflightReq.resultOutputBuffers[0].streamId);

            request.frameNumber++;
            // Empty settings should be supported after the first call
@@ -4470,11 +4539,11 @@ TEST_P(CameraHidlTest, processCaptureRequestPreview) {

            ASSERT_FALSE(inflightReq.errorCodeValid);
            ASSERT_NE(inflightReq.resultOutputBuffers.size(), 0u);
            ASSERT_EQ(previewStream.id, inflightReq.resultOutputBuffers[0].streamId);
            ASSERT_EQ(testStream.id, inflightReq.resultOutputBuffers[0].streamId);
        }

        if (useHalBufManager) {
            verifyBuffersReturned(session, deviceVersion, previewStream.id, cb);
            verifyBuffersReturned(session, deviceVersion, testStream.id, cb);
        }

        ret = session->close();
@@ -6278,6 +6347,19 @@ void CameraHidlTest::configurePreviewStream(const std::string &name, int32_t dev
        bool *useHalBufManager /*out*/,
        sp<DeviceCb> *outCb /*out*/,
        uint32_t streamConfigCounter) {
    configureSingleStream(name, deviceVersion, provider, previewThreshold,
                          GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, RequestTemplate::PREVIEW, session,
                          previewStream, halStreamConfig, supportsPartialResults,
                          partialResultCount, useHalBufManager, outCb, streamConfigCounter);
}
// Open a device session and configure a preview stream.
void CameraHidlTest::configureSingleStream(
        const std::string& name, int32_t deviceVersion, sp<ICameraProvider> provider,
        const AvailableStream* previewThreshold, uint64_t bufferUsage, RequestTemplate reqTemplate,
        sp<ICameraDeviceSession>* session /*out*/, V3_2::Stream* previewStream /*out*/,
        HalStreamConfiguration* halStreamConfig /*out*/, bool* supportsPartialResults /*out*/,
        uint32_t* partialResultCount /*out*/, bool* useHalBufManager /*out*/,
        sp<DeviceCb>* outCb /*out*/, uint32_t streamConfigCounter) {
    ASSERT_NE(nullptr, session);
    ASSERT_NE(nullptr, previewStream);
    ASSERT_NE(nullptr, halStreamConfig);
@@ -6366,11 +6448,14 @@ void CameraHidlTest::configurePreviewStream(const std::string &name, int32_t dev
            dataspaceFlag = static_cast<V3_2::DataspaceFlags>(Dataspace::UNKNOWN);
    }

    V3_2::Stream stream3_2 = {0, StreamType::OUTPUT,
    V3_2::Stream stream3_2 = {0,
                              StreamType::OUTPUT,
                              static_cast<uint32_t>(outputPreviewStreams[0].width),
                              static_cast<uint32_t>(outputPreviewStreams[0].height),
                              static_cast<PixelFormat>(outputPreviewStreams[0].format),
            GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, dataspaceFlag, StreamRotation::ROTATION_0};
                              bufferUsage,
                              dataspaceFlag,
                              StreamRotation::ROTATION_0};
    ::android::hardware::hidl_vec<V3_2::Stream> streams3_2 = {stream3_2};
    ::android::hardware::camera::device::V3_2::StreamConfiguration config3_2;
    ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4;
@@ -6378,7 +6463,6 @@ void CameraHidlTest::configurePreviewStream(const std::string &name, int32_t dev
    createStreamConfiguration(streams3_2, StreamConfigurationMode::NORMAL_MODE,
                              &config3_2, &config3_4, &config3_5, jpegBufferSize);
    if (session3_5 != nullptr) {
        RequestTemplate reqTemplate = RequestTemplate::PREVIEW;
        ret = session3_5->constructDefaultRequestSettings(reqTemplate,
                                                       [&config3_5](auto status, const auto& req) {
                                                           ASSERT_EQ(Status::OK, status);
@@ -6401,7 +6485,6 @@ void CameraHidlTest::configurePreviewStream(const std::string &name, int32_t dev
                    }
                });
    } else if (session3_4 != nullptr) {
        RequestTemplate reqTemplate = RequestTemplate::PREVIEW;
        ret = session3_4->constructDefaultRequestSettings(reqTemplate,
                                                       [&config3_4](auto status, const auto& req) {
                                                           ASSERT_EQ(Status::OK, status);