src/agent/adu_core_interface/src/agent_workflow.c
void ADUC_Workflow_HandlePropertyUpdate(ADUC_WorkflowData* workflowData, const unsigned char* propertyUpdateValue)
{
    // char cast because incoming response might be binary data in the future?
    workflowData->UpdateActionJson = ADUC_Json_GetRoot((const char*)propertyUpdateValue);

    //
    // TODO(NIC): 29565671: Cancel messages don't send a signature. Need to add unit tests.
    //
    unsigned int desiredAction;
    if (!ADUC_Json_GetUpdateAction(workflowData->UpdateActionJson, &desiredAction))
    {
        Log_Error("Cannot determine the desired update action. Update data: (%s)", propertyUpdateValue);

        //
        // TODO(NIC): 31481186 Refactor reporting so failures are reported in line instead of waiting for the state change to happen
        //
        ADUC_Result result = { .ResultCode = ADUC_LowerLayerResult_Failure,
                               .ExtendedResultCode = ADUC_ERC_LOWERLEVEL_UPDATE_MANIFEST_VALIDATION_INVALID_HASH };
        ADUC_SetUpdateStateWithResult(workflowData, ADUCITF_State_Failed, result);
        return;
    }

    if (desiredAction != ADUCITF_UpdateAction_Cancel)
    {
        if (!ADUC_Json_ValidateManifest(workflowData->UpdateActionJson))
        {
            Log_Error("Invalid Manifest received, manifest str: %s", propertyUpdateValue);

            //
            // TODO(NIC): 31481186 Refactor reporting so failures are reported in line instead of waiting for the state change to happen
            //
            ADUC_Result result = { .ResultCode = ADUC_LowerLayerResult_Failure,
                                   .ExtendedResultCode = ADUC_ERC_LOWERLEVEL_INVALID_UPDATE_ACTION };
            ADUC_SetUpdateStateWithResult(workflowData, ADUCITF_State_Failed, result);
            return;
        }
    }

    ADUC_WorkflowData_UpdateContentData(workflowData);

    // If the agent has just started up but we have yet to report the installedUpdateId along with a state of 'Idle'
    // we want to ignore any further action received so we don't confuse the workflow which would interpret a state of 'Idle'
    // not accompanied with an installedUpdateId as a failed end state in some cases.
    // In this case we will go through our startup logic which would report the installedUpdateId with a state of 'Idle',
    // if we can determine that the update has been installed successfully (by calling IsInstalled()).
    // Otherwise we will honor and process the action requested.
    if (!workflowData->StartupIdleCallSent)
    {
        ADUC_Workflow_HandleStartupWorkflowData(workflowData);
    }
    else
    {
        ADUC_Workflow_HandleUpdateAction(workflowData);
    }
}
/**
 * @brief Handles updates to a 1 or more PnP Properties in the ADU Core interface.
 *
 * @param[in,out] workflowData The current ADUC_WorkflowData object.
 * @param[in] propertyUpdateValue The updated property value.
 */
@brief Handles updates to a 1 or more PnP Properties in the ADU Core interface.
@param[in,out] workflowData The current ADUC_WorkflowData object.
@param[in] propertyUpdateValue The updated property value.
@brief Handles updates to a 1 or more PnP Properties in the ADU Core interface . @param [ in out ] workflowData The current ADUC_WorkflowData object . @param [ in ] propertyUpdateValue The updated property value .
void ADUC_Workflow_HandlePropertyUpdate(ADUC_WorkflowData* workflowData, const unsigned char* propertyUpdateValue)
{
    workflowData->UpdateActionJson = ADUC_Json_GetRoot((const char*)propertyUpdateValue);
     TODO(NIC): 29565671: Cancel messages don't send a signature. Need to add unit tests.
    unsigned int desiredAction;
    if (!ADUC_Json_GetUpdateAction(workflowData->UpdateActionJson, &desiredAction))
    {
        Log_Error("Cannot determine the desired update action. Update data: (%s)", propertyUpdateValue);
         TODO(NIC): 31481186 Refactor reporting so failures are reported in line instead of waiting for the state change to happen
        ADUC_Result result = { .ResultCode = ADUC_LowerLayerResult_Failure,
                               .ExtendedResultCode = ADUC_ERC_LOWERLEVEL_UPDATE_MANIFEST_VALIDATION_INVALID_HASH };
        ADUC_SetUpdateStateWithResult(workflowData, ADUCITF_State_Failed, result);
        return;
    }
    if (desiredAction != ADUCITF_UpdateAction_Cancel)
    {
        if (!ADUC_Json_ValidateManifest(workflowData->UpdateActionJson))
        {
            Log_Error("Invalid Manifest received, manifest str: %s", propertyUpdateValue);
             TODO(NIC): 31481186 Refactor reporting so failures are reported in line instead of waiting for the state change to happen
            ADUC_Result result = { .ResultCode = ADUC_LowerLayerResult_Failure,
                                   .ExtendedResultCode = ADUC_ERC_LOWERLEVEL_INVALID_UPDATE_ACTION };
            ADUC_SetUpdateStateWithResult(workflowData, ADUCITF_State_Failed, result);
            return;
        }
    }
    ADUC_WorkflowData_UpdateContentData(workflowData);
     If the agent has just started up but we have yet to report the installedUpdateId along with a state of 'Idle'
     we want to ignore any further action received so we don't confuse the workflow which would interpret a state of 'Idle'
     not accompanied with an installedUpdateId as a failed end state in some cases.
     In this case we will go through our startup logic which would report the installedUpdateId with a state of 'Idle',
     if we can determine that the update has been installed successfully (by calling IsInstalled()).
     Otherwise we will honor and process the action requested.
    if (!workflowData->StartupIdleCallSent)
    {
        ADUC_Workflow_HandleStartupWorkflowData(workflowData);
    }
    else
    {
        ADUC_Workflow_HandleUpdateAction(workflowData);
    }
}
void ADUC_Workflow_HandlePropertyUpdate ( ADUC_WorkflowData * workflowData , const unsigned char * propertyUpdateValue ) { workflowData -> UpdateActionJson = ADUC_Json_GetRoot ( ( const char * ) propertyUpdateValue ) ; unsigned int desiredAction ; if ( ! ADUC_Json_GetUpdateAction ( workflowData -> UpdateActionJson , & desiredAction ) ) { Log_Error ( " " , propertyUpdateValue ) ; ADUC_Result result = { . ResultCode = ADUC_LowerLayerResult_Failure , . ExtendedResultCode = ADUC_ERC_LOWERLEVEL_UPDATE_MANIFEST_VALIDATION_INVALID_HASH } ; ADUC_SetUpdateStateWithResult ( workflowData , ADUCITF_State_Failed , result ) ; return ; } if ( desiredAction != ADUCITF_UpdateAction_Cancel ) { if ( ! ADUC_Json_ValidateManifest ( workflowData -> UpdateActionJson ) ) { Log_Error ( " " , propertyUpdateValue ) ; ADUC_Result result = { . ResultCode = ADUC_LowerLayerResult_Failure , . ExtendedResultCode = ADUC_ERC_LOWERLEVEL_INVALID_UPDATE_ACTION } ; ADUC_SetUpdateStateWithResult ( workflowData , ADUCITF_State_Failed , result ) ; return ; } } ADUC_WorkflowData_UpdateContentData ( workflowData ) ; if ( ! workflowData -> StartupIdleCallSent ) { ADUC_Workflow_HandleStartupWorkflowData ( workflowData ) ; } else { ADUC_Workflow_HandleUpdateAction ( workflowData ) ; } }
@brief Handles updates to a 1 or more PnP Properties in the ADU Core interface.
@brief Handles updates to a 1 or more PnP Properties in the ADU Core interface .
// char cast because incoming response might be binary data in the future? // // TODO(NIC): 29565671: Cancel messages don't send a signature. Need to add unit tests. // // // TODO(NIC): 31481186 Refactor reporting so failures are reported in line instead of waiting for the state change to happen // // // TODO(NIC): 31481186 Refactor reporting so failures are reported in line instead of waiting for the state change to happen // // If the agent has just started up but we have yet to report the installedUpdateId along with a state of 'Idle' // we want to ignore any further action received so we don't confuse the workflow which would interpret a state of 'Idle' // not accompanied with an installedUpdateId as a failed end state in some cases. // In this case we will go through our startup logic which would report the installedUpdateId with a state of 'Idle', // if we can determine that the update has been installed successfully (by calling IsInstalled()). // Otherwise we will honor and process the action requested.