halapi: Fix directory where halcc searches for manifest.xml 62/310162/2
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 23 Apr 2024 08:22:22 +0000 (17:22 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 23 Apr 2024 09:28:05 +0000 (18:28 +0900)
The hal manifest install path has changed to a directory, /etc/hal-manifest,
regardless of tizen version specified at /hal/etc/hal-info.ini.

Change-Id: Ib6941b89ed4688e43f954cf278add0dc8008a92b
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/hal-api-compatibility-checker.c

index 9423093eeffefab0bcad7ee4bcf89bc30bbc4d37..ac154d3154c9cb681f47d248f1ae17640f2542f5 100644 (file)
@@ -37,6 +37,7 @@
 #include "hal-api-compatibility-checker-util.h"
 
 #define HAL_CC_DEFAULT_HAL_INFO_INI_PATH               "/hal/etc/hal-info.ini"
+#define HAL_CC_DEFAULT_HAL_MANIFEST_DIR                        "/etc/hal-manifest"
 #define HAL_CC_DEFAULT_COMPATIBILITY_RESULT_PATH       "/opt/etc/hal/.hal-backend-compatibility"
 
 #define COMPAT_INFO_MODULE_NAME_MAX                    64
@@ -212,61 +213,6 @@ out:
        manifest_info[module].error_desc = error_desc;
 }
 
-static int get_tizen_hal_version(int *major, int *minor)
-{
-       FILE *fp = NULL;
-       char *line = NULL;
-       size_t len = 0;
-       int found = 0;
-
-       assert(major);
-       assert(minor);
-
-       fp = fopen(HAL_CC_DEFAULT_HAL_INFO_INI_PATH, "r");
-       if (!fp) {
-               _E("Failed to open %s, %m\n", HAL_CC_DEFAULT_HAL_INFO_INI_PATH);
-               return -errno;
-       }
-
-       while (getline(&line, &len, fp) != EOF) {
-               if (fscanf(fp, "Model=Tizen%d.%d", major, minor) == 2) {
-                       found = 1;
-                       break;
-               }
-       }
-
-       fclose(fp);
-       fp = NULL;
-       free(line);
-       line = NULL;
-
-       return found ? 0 : -EINVAL;
-}
-
-static int build_compatibility_manifest_dir(char *manifest_dir, int len)
-{
-       int manifest_major = 0;
-       int manifest_minor = 0;
-       int ret;
-
-       if (!manifest_dir || len <= 0)
-               return -EINVAL;
-
-       ret = get_tizen_hal_version(&manifest_major, &manifest_minor);
-       if (ret < 0) {
-               _E("Failed to get hal version, ret=%d\n", ret);
-               return ret;
-       }
-
-       ret = snprintf(manifest_dir, len, "/etc/hal/%d.%d", manifest_major, manifest_minor);
-       if (ret >= len) {
-               _E("Buffer is too small for manifest directory\n");
-               return -EOVERFLOW;
-       }
-
-       return 0;
-}
-
 static int set_owner(int fd)
 {
        static uid_t uid_system_fw = -1;
@@ -351,7 +297,6 @@ static int store_hal_backend_compatibility(struct compatibility_info *manifest_i
 
 static int load_hal_manifest(struct compatibility_info *manifest_info, int load_flag)
 {
-       char manifest_dir[64] = { 0, };
        halcc_manifest *manifest = NULL;
        int ret = 0;
 
@@ -366,15 +311,11 @@ static int load_hal_manifest(struct compatibility_info *manifest_info, int load_
 
        g_compatibility_result_synced = false;
 
-       ret = build_compatibility_manifest_dir(manifest_dir, sizeof(manifest_dir));
-       if (ret < 0)
-               return ret;
-
        ret = halcc_manifest_new(&manifest);
        if (ret < 0)
                return ret;
 
-       ret = parse_manifest_directory(manifest_dir, manifest);
+       ret = parse_manifest_directory(HAL_CC_DEFAULT_HAL_MANIFEST_DIR, manifest);
        if (ret < 0)
                goto out;