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

Commit 87a22b0f authored by Mikhail Naganov's avatar Mikhail Naganov Committed by Gerrit Code Review
Browse files

Merge "Retain ID mapping for product strategy to be optional" into main

parents aacec3eb 4a2c5fe8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ PolicySubsystem::PolicySubsystem(const std::string &name, core::log::Logger &log
        );
    addSubsystemObjectFactory(
        new TSubsystemObjectFactory<ProductStrategy>(
            mProductStrategyComponentName, (1 << MappingKeyName) | (1 << MappingKeyIdentifier))
            mProductStrategyComponentName, (1 << MappingKeyName))
        );
}

+13 −8
Original line number Diff line number Diff line
@@ -29,9 +29,6 @@ ProductStrategy::ProductStrategy(const std::string &mappingValue,
                                (MappingKeyAmendEnd - MappingKeyAmend1 + 1),
                                context) {

    size_t id = context.getItemAsInteger(MappingKeyIdentifier);
    std::string nameFromStructure(context.getItem(MappingKeyName));

    ALOG_ASSERT(instanceConfigurableElement != nullptr, "Invalid Configurable Element");
    mPolicySubsystem = static_cast<const PolicySubsystem *>(
            instanceConfigurableElement->getBelongingSubsystem());
@@ -40,14 +37,22 @@ ProductStrategy::ProductStrategy(const std::string &mappingValue,
    mPolicyPluginInterface = mPolicySubsystem->getPolicyPluginInterface();
    ALOG_ASSERT(mPolicyPluginInterface != nullptr, "Invalid Policy Plugin Interface");

    const std::string nameFromStructure(context.getItem(MappingKeyName));
    std::string name;
    if (context.iSet(MappingKeyIdentifier)) {
        size_t id = context.getItemAsInteger(MappingKeyIdentifier);
        mId = static_cast<android::product_strategy_t>(id);
    std::string name = mPolicyPluginInterface->getProductStrategyName(mId);
        name = mPolicyPluginInterface->getProductStrategyName(mId);
        if (name.empty()) {
            name = nameFromStructure;
            mId = mPolicyPluginInterface->getProductStrategyByName(name);
        }
    } else {
        name = nameFromStructure;
        mId = mPolicyPluginInterface->getProductStrategyByName(nameFromStructure);
    }

    ALOG_ASSERT(mId != PRODUCT_STRATEGY_INVALID, "Product Strategy %s not found", name.c_str());
    ALOG_ASSERT(mId != PRODUCT_STRATEGY_NONE, "Product Strategy %s not found", name.c_str());

    ALOGE("Product Strategy %s added", name.c_str());
}