Skip to content

Commit

Permalink
RDK-55945: Sync code with stable2
Browse files Browse the repository at this point in the history
Reason for change: bring stable2 code changes to develop
Test Procedure: No Regressions
Risks: Low
Signed-off-by: c.shivabhaskar97@gmail.com
  • Loading branch information
shivabhaskar committed Feb 24, 2025
1 parent 3ae1f2c commit 5cc82ef
Show file tree
Hide file tree
Showing 20 changed files with 600 additions and 136 deletions.
6 changes: 3 additions & 3 deletions include/telemetry_busmessage_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void t2_init(char *component);
* value in string
* RETURN : 0 on successful sending of the message
*/
T2ERROR t2_event_s(char* marker, char* value);
T2ERROR t2_event_s(const char* marker, const char* value);

/*
* NAME : t2_event_f
Expand All @@ -57,7 +57,7 @@ T2ERROR t2_event_s(char* marker, char* value);
* value - floating point value
* RETURN : 0 on successful sending of the message
*/
T2ERROR t2_event_f(char* marker, double value);
T2ERROR t2_event_f(const char* marker, double value);


/*
Expand All @@ -67,7 +67,7 @@ T2ERROR t2_event_f(char* marker, double value);
* value - integer value
* RETURN : 0 on successful sending of the message
*/
T2ERROR t2_event_d(char* marker, int value);
T2ERROR t2_event_d(const char* marker, int value);

/*
* NAME : t2_uninit
Expand Down
4 changes: 1 addition & 3 deletions source/bulkdata/datamodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ void datamodel_getSavedJsonProfilesasString(char** SavedProfiles)
cJSON_AddItemToObject(temparrayItem, "value",tempObject);
cJSON_AddItemToArray(valArray, temparrayItem);
}
char* temp = cJSON_PrintUnformatted(jsonObj);
*SavedProfiles = strdup(temp);
free(temp);
*SavedProfiles = cJSON_PrintUnformatted(jsonObj);
cJSON_Delete(jsonObj);
}
Vector_Destroy(configList,free);
Expand Down
9 changes: 5 additions & 4 deletions source/bulkdata/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ static pthread_mutex_t reportLock;

static pthread_mutex_t triggerConditionQueMutex = PTHREAD_MUTEX_INITIALIZER;
static queue_t *triggerConditionQueue = NULL;
#if defined(PRIVACYMODES_CONTROL)
static char* paramValue = NULL;
#endif

typedef struct __triggerConditionObj__ {
char referenceName[MAX_LEN];
Expand Down Expand Up @@ -158,6 +155,7 @@ static void freeProfile(void *data)

if(profile->cachedReportList){
Vector_Destroy(profile->cachedReportList, free);
profile->cachedReportList = NULL;
}
if(profile->jsonReportObj){
cJSON_Delete(profile->jsonReportObj);
Expand Down Expand Up @@ -1131,13 +1129,16 @@ static void loadReportProfilesFromDisk()
T2Info("JSON: loadReportProfilesFromDisk \n");
#endif
#if defined(PRIVACYMODES_CONTROL)
getParameterValue(PRIVACYMODES_RFC, &paramValue);
char* paramValue = NULL;
getPrivacyMode(&paramValue);
if(strcmp(paramValue, "DO_NOT_SHARE") == 0){
T2Warning("PrivacyModes is DO_NOT_SHARE. Reportprofiles is not supported\n");
free(paramValue);
paramValue = NULL;
return;
}
free(paramValue);
paramValue = NULL;
#endif

size_t configIndex = 0;
Expand Down
28 changes: 15 additions & 13 deletions source/bulkdata/profilexconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ static void freeProfileXConf()
}

// Data elements from this list is copied in new profile. So do not destroy the vector
free(singleProfile->cachedReportList);
if(singleProfile->cachedReportList) {
free(singleProfile->cachedReportList);
singleProfile->cachedReportList = NULL;
}
free(singleProfile);
singleProfile = NULL;
}
Expand Down Expand Up @@ -213,9 +216,7 @@ static void* CollectAndReportXconf(void* data)
}
if(profile->paramList != NULL && Vector_Size(profile->paramList) > 0)
{
pthread_mutex_unlock(&plMutex);
profileParamVals = getProfileParameterValues(profile->paramList);
pthread_mutex_lock(&plMutex);
T2Info("Fetch complete for TR-181 Object/Parameter Values for parameters \n");
if(profileParamVals != NULL)
{
Expand Down Expand Up @@ -288,9 +289,7 @@ static void* CollectAndReportXconf(void* data)
ret = T2ERROR_FAILURE ;
} else {
T2Debug("Abort upload is not yet set.\n");
pthread_mutex_unlock(&plMutex);
ret = sendReportOverHTTP(profile->t2HTTPDest->URL, jsonReport, &xconfReportPid);
pthread_mutex_lock(&plMutex);
}

xconfReportPid = -1 ;
Expand Down Expand Up @@ -498,18 +497,18 @@ void ProfileXConf_updateMarkerComponentMap()
T2Error("profile list is not initialized yet, ignoring\n");
return ;
}
if(!singleProfile)
{
T2Error("Profile not found in %s\n", __FUNCTION__);
return ;
}
size_t emIndex = 0;
EventMarker *eMarker = NULL;
pthread_mutex_lock(&plMutex);
for(;emIndex < Vector_Size(singleProfile->eMarkerList); emIndex++)
if(singleProfile)
{
eMarker = (EventMarker *)Vector_At(singleProfile->eMarkerList, emIndex);
addT2EventMarker(eMarker->markerName, eMarker->compName, singleProfile->name, eMarker->skipFreq);
for(;emIndex < Vector_Size(singleProfile->eMarkerList); emIndex++)
{
eMarker = (EventMarker *)Vector_At(singleProfile->eMarkerList, emIndex);
addT2EventMarker(eMarker->markerName, eMarker->compName, singleProfile->name, eMarker->skipFreq);
}
}else{
T2Error("Profile not found in %s\n", __FUNCTION__);
}
pthread_mutex_unlock(&plMutex);
T2Debug("%s --out\n", __FUNCTION__);
Expand Down Expand Up @@ -565,9 +564,11 @@ T2ERROR ProfileXConf_delete(ProfileXConf *profile)
T2Info("Waiting for CollectAndReport to be complete : %s\n", singleProfile->name);
pthread_mutex_lock(&plMutex);
initialized=false;
T2Info("Sending signal to reuse Thread in CollectAndReportXconf\n");
pthread_cond_signal(&reuseThread);
pthread_mutex_unlock(&plMutex);
pthread_join(singleProfile->reportThread, NULL);
T2Info("reportThread exits and initialising the profile list\n");
reportThreadExits = false;
initialized=true;
singleProfile->reportInProgress = false ;
Expand All @@ -593,6 +594,7 @@ T2ERROR ProfileXConf_delete(ProfileXConf *profile)
else{
if(count > 0){ //Destroy the cachedReportList vector when the profile name is not equal
Vector_Destroy(singleProfile->cachedReportList, free);
singleProfile->cachedReportList = NULL;
}
}
// copy max events irrespective of the profile name
Expand Down
59 changes: 25 additions & 34 deletions source/bulkdata/reportprofiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ pthread_mutex_t rpMutex = PTHREAD_MUTEX_INITIALIZER;
T2ERROR RemovePreRPfromDisk(const char* path , hash_map_t *map);
static bool isT2MtlsEnable = false;
static bool initT2MtlsEnable = false;
#if defined(PRIVACYMODES_CONTROL)
static char* paramValue = NULL;
#endif
struct rusage pusage;
unsigned int profilemem=0;

Expand Down Expand Up @@ -283,6 +280,13 @@ T2ERROR ReportProfiles_setProfileXConf(ProfileXConf *profile) {
}

T2ER_StopDispatchThread();
// un-register and re-register Component Event List
// This is done to support any new components added for events
if(isRbusEnabled()){
unregisterDEforCompEventList();
createComponentDataElements();
publishEventsProfileUpdates();
}
T2ER_StartDispatchThread();

T2Debug("%s --out\n", __FUNCTION__);
Expand Down Expand Up @@ -352,29 +356,6 @@ T2ERROR ReportProfiles_deleteProfile(const char* profileName) {
return T2ERROR_SUCCESS;
}

static void createComponentDataElements() {
T2Debug("%s ++in\n", __FUNCTION__);
Vector* componentList = NULL ;
FILE* cfgReadyFlag = NULL ;
int i = 0;
int length = 0 ;
getComponentsWithEventMarkers(&componentList);
length = Vector_Size(componentList);
for (i = 0; i < length; ++i) {
char *compName = (char*) Vector_At(componentList,i);
if(compName)
regDEforCompEventList(compName, getComponentMarkerList);
}
cfgReadyFlag = fopen(T2_CONFIG_READY, "w+");
if(cfgReadyFlag){
fclose(cfgReadyFlag);
}
setT2EventReceiveState(T2_STATE_CONFIG_READY);
T2Info("T2 is now Ready to be configured for report profiles\n");

T2Debug("%s --out\n", __FUNCTION__);
}

void profilemem_usage(unsigned int *value) {
T2Debug("%s ++in\n", __FUNCTION__);
*value = profilemem;
Expand Down Expand Up @@ -474,11 +455,13 @@ T2ERROR initReportProfiles()
// Drop root privileges for Telemetry 2.0, If NonRootSupport RFC is true
drop_root();
#endif

#ifndef DEVICE_EXTENDER
ProfileXConf_init();
#endif
t2Version = strdup("2.0.1"); // Setting the version to 2.0.1
{
T2Debug("T2 Version = %s\n", t2Version);
//initProfileList();
initProfileList();
free(t2Version);
// Init datamodel processing thread
if (T2ERROR_SUCCESS == datamodel_init())
Expand Down Expand Up @@ -542,15 +525,17 @@ T2ERROR initReportProfiles()
{
T2Error("Unable to start message processing thread!!! \n");
}
initProfileList();
}
#ifndef DEVICE_EXTENDER
ProfileXConf_init();
#endif

if(ProfileXConf_isSet() || getProfileCount() > 0) {

if(isRbusEnabled()){
unregisterDEforCompEventList();
createComponentDataElements();
FILE* cfgReadyFlag = NULL ;
cfgReadyFlag = fopen(T2_CONFIG_READY, "w+");
if(cfgReadyFlag)
fclose(cfgReadyFlag);
getMarkerCompRbusSub(true);
}
T2ER_StartDispatchThread();
Expand Down Expand Up @@ -731,13 +716,16 @@ void ReportProfiles_ProcessReportProfilesBlob(cJSON *profiles_root , bool rprofi
return;
}
#if defined(PRIVACYMODES_CONTROL)
getParameterValue(PRIVACYMODES_RFC, &paramValue);
char* paramValue = NULL;
getPrivacyMode(&paramValue);
if(strcmp(paramValue, "DO_NOT_SHARE") == 0){
T2Warning("Privacy Mode is DO_NOT_SHARE. Reportprofiles is not supported\n");
free(paramValue);
paramValue = NULL;
return;
}
free(paramValue);
paramValue = NULL;
#endif
cJSON *profilesArray = cJSON_GetObjectItem(profiles_root, "profiles");
uint32_t profiles_count = cJSON_GetArraySize(profilesArray);
Expand Down Expand Up @@ -1044,13 +1032,16 @@ void ReportProfiles_ProcessReportProfilesMsgPackBlob(char *msgpack_blob , int ms
int __ReportProfiles_ProcessReportProfilesMsgPackBlob(void *msgpack)
{
#if defined(PRIVACYMODES_CONTROL)
getParameterValue(PRIVACYMODES_RFC, &paramValue);
char* paramValue = NULL;
getPrivacyMode(&paramValue);
if(strcmp(paramValue, "DO_NOT_SHARE") == 0){
T2Warning("Privacy Mode is DO_NOT_SHARE. Reportprofiles is not supported\n");
free(paramValue);
paramValue = NULL;
return T2ERROR_SUCCESS;
}
free(paramValue);
paramValue = NULL;
#endif
char *msgpack_blob = ((struct __msgpack__ *)msgpack)->msgpack_blob;
int msgpack_blob_size = ((struct __msgpack__ *)msgpack)->msgpack_blob_size;
Expand Down
16 changes: 16 additions & 0 deletions source/bulkdata/t2markers.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "t2collection.h"
#include "t2eventreceiver.h"
#include "t2log_wrapper.h"
#include "rbusInterface.h"

/**
* Store event markers associated with a component
Expand Down Expand Up @@ -284,3 +285,18 @@ T2ERROR getMarkerProfileList(const char* markerName, Vector **profileList)
pthread_mutex_unlock(&t2MarkersMutex);
return T2ERROR_SUCCESS;
}

void createComponentDataElements() {
T2Debug("%s ++in\n", __FUNCTION__);
int i = 0;
int length = 0 ;
pthread_mutex_lock(&t2CompListMutex);
length = Vector_Size(componentList);
for (i = 0; i < length; ++i) {
char *compName = (char*) Vector_At(componentList,i);
if(compName)
regDEforCompEventList(compName, getComponentMarkerList);
}
pthread_mutex_unlock(&t2CompListMutex);
T2Debug("%s --out\n", __FUNCTION__);
}
2 changes: 2 additions & 0 deletions source/bulkdata/t2markers.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ void getComponentsWithEventMarkers(Vector **eventComponentList);

T2ERROR getMarkerProfileList(const char* markerName, Vector **profileList);

void createComponentDataElements();

#endif /* _T2MARKERS_H_ */
Loading

0 comments on commit 5cc82ef

Please sign in to comment.