return cgroup_write_node_uint32(buf, CLASSID_FILE_NAME, result_classid);
}
-static uint32_t __get_classid_from_cgroup(const char *cgroup,
- const char *subdir)
+static stc_error_e __get_classid_from_cgroup(const char *cgroup,
+ const char *subdir, uint32_t *classid)
{
char buf[MAX_PATH_LENGTH];
- uint32_t classid = STC_UNKNOWN_CLASSID;
snprintf(buf, sizeof(buf), "%s/%s", cgroup, subdir);
- int ret = cgroup_read_node_uint32(buf, CLASSID_FILE_NAME, &classid);
- if (ret < 0)
- STC_LOGE("Can't read classid from cgroup %s", buf); //LCOV_EXCL_LINE
- return classid;
+ int ret = cgroup_read_node_uint32(buf, CLASSID_FILE_NAME, classid);
+ if (ret < 0) {
+ *classid = STC_UNKNOWN_CLASSID;
+ return STC_ERROR_NO_DATA;
+ }
+
+ return STC_ERROR_NONE;
}
stc_error_e init_current_classid(void)
return STC_ERROR_NONE;
}
-uint32_t get_classid_by_app_id(const char *app_id, int create)
+API uint32_t get_classid_by_app_id(const char *app_id, int create)
{
- int ret = 0;
bool exists;
+ int ret = STC_ERROR_NONE;
uint32_t classid = STC_UNKNOWN_CLASSID;
const char *path_to_net_cgroup_dir = NULL;
return STC_UNKNOWN_CLASSID; //LCOV_EXCL_LINE
}
- if (!strcmp(app_id, STC_BACKGROUND_APP_ID))
+ if (!strcmp(app_id, STC_TOTAL_BACKGROUND))
return STC_BACKGROUND_APP_CLASSID;
if (!strcmp(app_id, STC_TOTAL_DATACALL))
/* just read */
if (!create)
- classid = __get_classid_from_cgroup(path_to_net_cgroup_dir, //LCOV_EXCL_LINE
- app_id);
+ ret = __get_classid_from_cgroup(path_to_net_cgroup_dir, //LCOV_EXCL_LINE
+ app_id, &classid);
+
+ if (ret != STC_ERROR_NONE)
+ return STC_UNKNOWN_CLASSID;
if (classid != STC_UNKNOWN_CLASSID)
return classid;
goto handle_error;
if (exists)
- classid = __get_classid_from_cgroup(path_to_net_cgroup_dir,
- app_id);
+ ret = __get_classid_from_cgroup(path_to_net_cgroup_dir,
+ app_id, &classid);
else
ret = __place_classid_to_cgroup(path_to_net_cgroup_dir,
(char *)app_id, &classid, NULL);
return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- if (!strcmp(app_id, STC_BACKGROUND_APP_ID))
- path_to_net_cgroup_dir = STC_CGROUP_NETWORK;
- else if (strstr(app_id, STC_BACKGROUND_APP_SUFFIX))
+ if (strstr(app_id, STC_BACKGROUND_APP_SUFFIX))
path_to_net_cgroup_dir = BACKGROUND_CGROUP_NETWORK;
else if (strstr(app_id, STC_TETHERING_APP_SUFFIX))
path_to_net_cgroup_dir = TETHERING_CGROUP_NETWORK;