Enable/Disable process launch by loc_launcher based on SOC-Id
Add a parameter SOC_IDS for process configuration in izat.conf to include/exclude the process based on SOC-Id. Read the value of this parameter to enable or disable the process launch by loc_launcher. Fixed an issue in read_a_line function to handle newline at the end of line in the file to be read. Change-Id: I66777856ebbb928ce4f49a44dfd9d2f1fbca69b5 CRs-Fixed: 2540349
This commit is contained in:
parent
b9e824b01e
commit
201f612040
3 changed files with 75 additions and 11 deletions
|
@ -460,6 +460,9 @@ void loc_read_conf(const char* conf_file_name, const loc_param_s_type* config_ta
|
|||
#define CONFIG_MASK_AUTOPLATFORM_ALL 0x10
|
||||
#define CONFIG_MASK_AUTOPLATFORM_FOUND 0x20
|
||||
#define CONFIG_MASK_AUTOPLATFORM_CHECK 0x30
|
||||
#define CONFIG_MASK_SOCID_ALL 0x40
|
||||
#define CONFIG_MASK_SOCID_FOUND 0x80
|
||||
#define CONFIG_MASK_SOCID_CHECK 0xc0
|
||||
|
||||
#define LOC_FEATURE_MASK_GTP_WIFI_BASIC 0x01
|
||||
#define LOC_FEATURE_MASK_GTP_WIFI_PREMIUM 0X02
|
||||
|
@ -484,6 +487,7 @@ typedef struct {
|
|||
char platform_list[LOC_MAX_PARAM_STRING];
|
||||
char baseband[LOC_MAX_PARAM_STRING];
|
||||
char low_ram_targets[LOC_MAX_PARAM_STRING];
|
||||
char soc_id_list[LOC_MAX_PARAM_STRING];
|
||||
unsigned int sglte_target;
|
||||
char feature_gtp_mode[LOC_MAX_PARAM_STRING];
|
||||
char feature_gtp_waa[LOC_MAX_PARAM_STRING];
|
||||
|
@ -524,6 +528,7 @@ static const loc_param_s_type loc_process_conf_parameter_table[] = {
|
|||
{"PREMIUM_FEATURE", &conf.premium_feature, NULL, 'n'},
|
||||
{"IZAT_FEATURE_MASK", &conf.loc_feature_mask, NULL, 'n'},
|
||||
{"PLATFORMS", &conf.platform_list, NULL, 's'},
|
||||
{"SOC_IDS", &conf.soc_id_list, NULL, 's'},
|
||||
{"BASEBAND", &conf.baseband, NULL, 's'},
|
||||
{"LOW_RAM_TARGETS", &conf.low_ram_targets, NULL, 's'},
|
||||
{"HARDWARE_TYPE", &conf.auto_platform, NULL, 's'},
|
||||
|
@ -563,14 +568,14 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p
|
|||
gid_t gid_list[LOC_PROCESS_MAX_NUM_GROUPS];
|
||||
char *split_strings[MAX_NUM_STRINGS];
|
||||
int name_length=0, group_list_length=0, platform_length=0, baseband_length=0, ngroups=0, ret=0;
|
||||
int auto_platform_length = 0;
|
||||
int auto_platform_length = 0, soc_id_list_length=0;
|
||||
int group_index=0, nstrings=0, status_length=0;
|
||||
FILE* conf_fp = nullptr;
|
||||
char platform_name[PROPERTY_VALUE_MAX], baseband_name[PROPERTY_VALUE_MAX];
|
||||
int low_ram_target=0;
|
||||
char autoplatform_name[PROPERTY_VALUE_MAX];
|
||||
char autoplatform_name[PROPERTY_VALUE_MAX], socid_value[PROPERTY_VALUE_MAX];
|
||||
unsigned int loc_service_mask=0;
|
||||
char config_mask = 0;
|
||||
unsigned char config_mask = 0;
|
||||
unsigned char proc_list_length=0;
|
||||
int gtp_cell_ap_enabled = 0;
|
||||
char arg_gtp_waa[LOC_PROCESS_MAX_ARG_STR_LENGTH] = "--";
|
||||
|
@ -602,6 +607,8 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p
|
|||
loc_get_auto_platform_name(autoplatform_name,sizeof(autoplatform_name));
|
||||
//Identify if this is a low ram target from ro.config.low_ram property
|
||||
low_ram_target = loc_identify_low_ram_target();
|
||||
// Get the soc-id for this device.
|
||||
loc_get_device_soc_id(socid_value, sizeof(socid_value));
|
||||
|
||||
UTIL_READ_CONF(conf_file_name, loc_feature_conf_table);
|
||||
|
||||
|
@ -774,9 +781,10 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p
|
|||
baseband_length = (int)strlen(conf.baseband);
|
||||
status_length = (int)strlen(conf.proc_status);
|
||||
auto_platform_length = (int)strlen(conf.auto_platform);
|
||||
soc_id_list_length = (int)strlen(conf.soc_id_list);
|
||||
|
||||
if(!name_length || !group_list_length || !platform_length ||
|
||||
!baseband_length || !status_length || !auto_platform_length) {
|
||||
!baseband_length || !status_length || !auto_platform_length || !soc_id_list_length) {
|
||||
LOC_LOGE("%s:%d]: Error: i: %d; One of the parameters not specified in conf file",
|
||||
__func__, __LINE__, i);
|
||||
continue;
|
||||
|
@ -847,6 +855,34 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p
|
|||
}
|
||||
}
|
||||
|
||||
// SOC Id's check
|
||||
nstrings = loc_util_split_string(conf.soc_id_list, split_strings, MAX_NUM_STRINGS, ' ');
|
||||
if (strcmp("all", split_strings[0]) == 0) {
|
||||
if (nstrings == 1 || (nstrings == 2 && (strcmp("exclude", split_strings[1]) == 0))) {
|
||||
LOC_LOGd("Enabled for all SOC ids\n");
|
||||
config_mask |= CONFIG_MASK_SOCID_ALL;
|
||||
}
|
||||
else if (nstrings > 2 && (strcmp("exclude", split_strings[1]) == 0)) {
|
||||
config_mask |= CONFIG_MASK_SOCID_FOUND;
|
||||
for (i = 2; i < nstrings; i++) {
|
||||
if (strcmp(socid_value, split_strings[i]) == 0) {
|
||||
LOC_LOGd("Disabled for SOC id %s\n", socid_value);
|
||||
config_mask &= ~CONFIG_MASK_SOCID_FOUND;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < nstrings; i++) {
|
||||
if (strcmp(socid_value, split_strings[i]) == 0) {
|
||||
LOC_LOGd("Matched SOC id : %s\n", split_strings[i]);
|
||||
config_mask |= CONFIG_MASK_SOCID_FOUND;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nstrings = loc_util_split_string(conf.baseband, split_strings, MAX_NUM_STRINGS, ' ');
|
||||
if(strcmp("all", split_strings[0]) == 0) {
|
||||
if (nstrings == 1 || (nstrings == 2 && (strcmp("exclude", split_strings[1]) == 0))) {
|
||||
|
@ -909,6 +945,7 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p
|
|||
if((config_mask & CONFIG_MASK_TARGET_CHECK) &&
|
||||
(config_mask & CONFIG_MASK_BASEBAND_CHECK) &&
|
||||
(config_mask & CONFIG_MASK_AUTOPLATFORM_CHECK) &&
|
||||
(config_mask & CONFIG_MASK_SOCID_CHECK) &&
|
||||
(child_proc[j].proc_status != DISABLED_FROM_CONF) &&
|
||||
(child_proc[j].proc_status != DISABLED_VIA_VENDOR_ENHANCED_CHECK)) {
|
||||
|
||||
|
|
|
@ -80,6 +80,11 @@ static int read_a_line(const char * file_path, char * line, int line_size)
|
|||
int len;
|
||||
fgets(line, line_size, fp);
|
||||
len = strlen(line);
|
||||
while ('\n' == line[len-1]) {
|
||||
// If there is a new line at end of string, replace it with NULL
|
||||
line[len-1] = '\0';
|
||||
len--;
|
||||
}
|
||||
len = len < line_size - 1? len : line_size - 1;
|
||||
line[len] = '\0';
|
||||
LOC_LOGD("cat %s: %s", file_path, line);
|
||||
|
@ -144,6 +149,30 @@ int loc_identify_low_ram_target()
|
|||
return !(strncmp(low_ram_target, "true", PROPERTY_VALUE_MAX));
|
||||
}
|
||||
|
||||
/*The character array passed to this function should have length
|
||||
of atleast PROPERTY_VALUE_MAX*/
|
||||
/* Reads the soc_id node and return the soc_id value */
|
||||
void loc_get_device_soc_id(char *soc_id_value, int array_length)
|
||||
{
|
||||
static const char soc_id[] = "/sys/devices/soc0/soc_id";
|
||||
static const char soc_id_dep[] = "/sys/devices/system/soc/soc0/id";
|
||||
int return_val = 0;
|
||||
|
||||
if (soc_id_value && (array_length >= PROPERTY_VALUE_MAX)) {
|
||||
if (!access(soc_id, F_OK)) {
|
||||
return_val = read_a_line(soc_id, soc_id_value, array_length);
|
||||
} else {
|
||||
return_val = read_a_line(soc_id_dep, soc_id_value, array_length);
|
||||
}
|
||||
if (0 == return_val) {
|
||||
LOC_LOGd("SOC Id value: %s\n", soc_id_value);
|
||||
} else {
|
||||
LOC_LOGe("Unable to read the soc_id value\n");
|
||||
}
|
||||
} else {
|
||||
LOC_LOGe("Null parameter or array length less than PROPERTY_VALUE_MAX\n");
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int loc_get_target(void)
|
||||
{
|
||||
|
@ -151,10 +180,8 @@ unsigned int loc_get_target(void)
|
|||
return gTarget;
|
||||
|
||||
static const char hw_platform[] = "/sys/devices/soc0/hw_platform";
|
||||
static const char id[] = "/sys/devices/soc0/soc_id";
|
||||
static const char hw_platform_dep[] =
|
||||
"/sys/devices/system/soc/soc0/hw_platform";
|
||||
static const char id_dep[] = "/sys/devices/system/soc/soc0/id";
|
||||
static const char mdm[] = "/target"; // mdm target we are using
|
||||
|
||||
char rd_hw_platform[LINE_LEN];
|
||||
|
@ -170,11 +197,8 @@ unsigned int loc_get_target(void)
|
|||
} else {
|
||||
read_a_line(hw_platform_dep, rd_hw_platform, LINE_LEN);
|
||||
}
|
||||
if (!access(id, F_OK)) {
|
||||
read_a_line(id, rd_id, LINE_LEN);
|
||||
} else {
|
||||
read_a_line(id_dep, rd_id, LINE_LEN);
|
||||
}
|
||||
// Get the soc-id for this device.
|
||||
loc_get_device_soc_id(rd_id, sizeof(rd_id));
|
||||
|
||||
/*check automotive platform*/
|
||||
loc_get_auto_platform_name(rd_auto_platform, sizeof(rd_auto_platform));
|
||||
|
|
|
@ -55,6 +55,9 @@ void loc_get_platform_name(char *platform_name, int array_length);
|
|||
of atleast PROPERTY_VALUE_MAX*/
|
||||
void loc_get_auto_platform_name(char *platform_name, int array_length);
|
||||
int loc_identify_low_ram_target();
|
||||
/*The character array passed to this function should have length
|
||||
of atleast PROPERTY_VALUE_MAX*/
|
||||
void loc_get_device_soc_id(char *soc_id_value, int array_length);
|
||||
|
||||
/* Please remember to update 'target_name' in loc_log.cpp,
|
||||
if do any changes to this enum. */
|
||||
|
|
Loading…
Reference in a new issue