Clean up method 15/239815/14
authorJeon Sang-Heon <sh95.jeon@samsung.com>
Wed, 29 Jul 2020 12:12:56 +0000 (12:12 +0000)
committerJeon Sang-Heon <sh95.jeon@samsung.com>
Fri, 7 Aug 2020 17:25:16 +0000 (17:25 +0000)
- Change common client status -> boot status
- Change comment and log message

Change-Id: Ife35a8716c72697579020c1f5ad2ae4a9838ddae
Signed-off-by: Jeon Sang-Heon <sh95.jeon@samsung.com>
update-manager/common/common-boot-status-checker.c [new file with mode: 0644]
update-manager/common/common-client-info-checker.c
update-manager/common/common-client-status-checker.c [deleted file]
update-manager/fota/fota-client-controller.c
update-manager/fota/fota-client-info-checker.c
update-manager/main.c
update-manager/recovery/recovery-client-controller.c
update-manager/recovery/recovery-client-info-checker.c
update-manager/recovery/recovery-storage-checker.c
update-manager/update-manager.h

diff --git a/update-manager/common/common-boot-status-checker.c b/update-manager/common/common-boot-status-checker.c
new file mode 100644 (file)
index 0000000..716f191
--- /dev/null
@@ -0,0 +1,76 @@
+#include "../recovery/recovery-manager.h"
+#include "../update-manager.h"
+
+static int boot_status = -1;
+
+bool common_boot_status_checker_is_success()
+{
+       return (boot_status == VCONFKEY_SYSMAN_BOOTING_SUCCESS);
+}
+
+void common_boot_status_checker_callback(keynode_t *node, void *user_data)
+{
+       int ret = 0;
+
+       ret = vconf_keynode_get_type(node);
+       if (ret == VCONF_TYPE_INT) {
+               boot_status = vconf_keynode_get_int(node);
+               if (common_boot_status_checker_is_success()) {
+                       _I("Success to get bootstatus : success");
+
+                       ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_BOOTINGSTATUS, common_boot_status_checker_callback);
+                       if (ret == VCONF_OK)
+                               _I("Success to remove bootstatus callback");
+                       else
+                               _W("vconf_ignore_key_changed for %s failed : %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
+
+                       ret = fota_client_controller_process_launch_request();
+                       if (ret < 0)
+                               _E("Failed to process fota client : %d", ret);
+
+                       ret = recovery_client_controller_process_launch_request();
+                       if (ret < 0)
+                               _E("Failed to process recovery client : %d", ret);
+               }
+       } else {
+               _E("Invalid vconf key type : %d", ret);
+       }
+}
+
+int common_boot_status_checker_init()
+{
+       int ret = 0;
+
+       _I("Start process to get boot status");
+       ret = vconf_get_int(VCONFKEY_SYSMAN_BOOTINGSTATUS, &boot_status);
+       if (ret != VCONF_OK) {
+               _E("vconf_get_int for %s failed: %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
+               return -1;
+       }
+
+       if (common_boot_status_checker_is_success()) {
+               _I("Success to get boot status : success");
+       } else {
+               ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_BOOTINGSTATUS, common_boot_status_checker_callback, NULL);
+               if (ret != VCONF_OK) {
+                       _E("vconf_notify_key_changed for %s failed : %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
+                       return -1;
+               }
+               _I("Success to register boot status callback");
+       }
+
+       return 0;
+}
+
+int common_boot_status_checker_fini()
+{
+       int ret = 0;
+
+       if (!common_boot_status_checker_is_success()) {
+               ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_BOOTINGSTATUS, common_boot_status_checker_callback);
+               if (ret != VCONF_OK)
+                       _W("vconf_ignore_key_changed for %s failed : %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
+       }
+
+       return 0;
+}
index 0c04fb38d8752e36b44ef5570e403e7bb92055b1..ebcf452b8a3050c4262beabe6eb1266f8fcdd61e 100644 (file)
@@ -1,6 +1,6 @@
 #include "../update-manager.h"
 
-int common_client_info_checker_callback(pkgmgrinfo_appinfo_h handle, char **app_id)
+int common_client_info_checker_get_appid(pkgmgrinfo_appinfo_h handle, char **app_id)
 {
        int ret = 0, status = 0;
        pkgmgrinfo_appinfo_h appinfo_h = NULL;
@@ -48,7 +48,7 @@ callback_destroy:
        return status;
 }
 
-int common_client_info_checker_init(const char* key, const char* value, pkgmgrinfo_app_list_cb cb)
+int common_client_info_checker_filter(const char* key, const char* value, pkgmgrinfo_app_list_cb cb)
 {
        int ret = 0, status = 0;
        pkgmgrinfo_appinfo_metadata_filter_h filter_h = NULL;
diff --git a/update-manager/common/common-client-status-checker.c b/update-manager/common/common-client-status-checker.c
deleted file mode 100644 (file)
index dc5d1ea..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#include "../recovery/recovery-manager.h"
-#include "../update-manager.h"
-
-static int boot_status = -1;
-
-bool common_client_status_checker_is_success()
-{
-       return (boot_status == VCONFKEY_SYSMAN_BOOTING_SUCCESS);
-}
-
-void common_client_status_checker_callback(keynode_t *node, void *user_data)
-{
-       int ret = 0;
-
-       ret = vconf_keynode_get_type(node);
-       if (ret == VCONF_TYPE_INT) {
-               boot_status = vconf_keynode_get_int(node);
-               if (common_client_status_checker_is_success()) {
-                       _I("Success to get bootstatus : success");
-
-                       ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_BOOTINGSTATUS, common_client_status_checker_callback);
-                       if (ret == VCONF_OK)
-                               _I("Success to remove bootstatus callback");
-                       else
-                               _W("vconf_ignore_key_changed for %s failed : %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
-
-                       ret = fota_client_controller_process_launch_request();
-                       if (ret < 0)
-                               _E("Failed to process fota client : %d", ret);
-
-                       ret = recovery_client_controller_process_launch_request();
-                       if (ret < 0)
-                               _E("Failed to process recovery client : %d", ret);
-               }
-       } else {
-               _E("Invalid vconf key type : %d", ret);
-       }
-}
-
-int common_client_status_checker_init()
-{
-       int ret = 0;
-
-       _I("Start process to get boot status");
-       ret = vconf_get_int(VCONFKEY_SYSMAN_BOOTINGSTATUS, &boot_status);
-       if (ret != VCONF_OK) {
-               _E("vconf_get_int for %s failed: %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
-               return -1;
-       }
-
-       if (common_client_status_checker_is_success()) {
-               _I("Success to get boot status : success");
-       } else {
-               ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_BOOTINGSTATUS, common_client_status_checker_callback, NULL);
-               if (ret != VCONF_OK) {
-                       _E("vconf_notify_key_changed for %s failed : %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
-                       return -1;
-               }
-               _I("Success to register boot status callback");
-       }
-
-       return 0;
-}
-
-int common_client_status_checker_fini()
-{
-       int ret = 0;
-
-       if (!common_client_status_checker_is_success()) {
-               ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_BOOTINGSTATUS, common_client_status_checker_callback);
-               if (ret != VCONF_OK)
-                       _W("vconf_ignore_key_changed for %s failed : %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
-       }
-
-       return 0;
-}
index 2f9b745b1e1c0768e20504a7998b40d2cd381464..78f186fdfccde00ecd51be8dbe5e060f84456a87 100644 (file)
@@ -14,7 +14,7 @@ int fota_client_controller_process_launch_request()
                return -1;
        }
 
-       if (!common_client_status_checker_is_success()) {
+       if (!common_boot_status_checker_is_success()) {
                _I("Failed to launch client, user session is unset, current top : %d", fota_req_top);
                return -1;
        }
index 443781f81e2a6b218426136ec3139623f4b64a85..d2373c9b3f0f76276f6aa09f1e6a7241eb76dec9 100644 (file)
@@ -11,9 +11,9 @@ int fota_client_info_checker_callback(pkgmgrinfo_appinfo_h handle, void *user_da
 {
        int ret = 0;
 
-       ret = common_client_info_checker_callback(handle, &fota_client_app_id);
+       ret = common_client_info_checker_get_appid(handle, &fota_client_app_id);
        if (ret < 0) {
-               _E("Common client info checker callback failed at fota");
+               _E("Failed to get fota app id from handle : %d", ret);
                return -1;
        }
 
@@ -29,9 +29,10 @@ int fota_client_info_checker_init()
 {
        int ret = 0;
 
-       ret = common_client_info_checker_init(FOTA_CLIENT_METADATA_KEY, FOTA_CLIENT_METADATA_VALUE, fota_client_info_checker_callback);
+       ret = common_client_info_checker_filter(FOTA_CLIENT_METADATA_KEY, FOTA_CLIENT_METADATA_VALUE, fota_client_info_checker_callback);
        if (ret < 0) {
-               _E("Common client info checker failed, key : %s, value : %s", FOTA_CLIENT_METADATA_KEY, FOTA_CLIENT_METADATA_VALUE);
+               _E("Failed to set fota client app filter : %d, key : %s, value : %s",
+                       ret, FOTA_CLIENT_METADATA_KEY, FOTA_CLIENT_METADATA_VALUE);
                return -1;
        }
 
index 51008f1b5413b5106583af4d6318e328d3ad4c89..368a3b4efb3b43d431b9f17eddfdb1c1ec5d4bb0 100644 (file)
@@ -12,27 +12,33 @@ int main(int argc, char *argv[])
                return -ENOMEM;
        }
 
-       /* Client */
-       ret = fota_client_info_checker_init();
+       /* Common */
+       ret = common_storage_checker_init();
        if (ret < 0) {
-               _E("Failed to initialize fota client info checker : %d", ret);
+               _E("Failed to initialize common storage checker : %d", ret);
                goto main_destroy;
        }
 
-       ret = common_client_status_checker_init();
+       ret = common_boot_status_checker_init();
        if (ret < 0) {
-               _E("Failed to initialize client status checker : %d", ret);
+               _E("Failed to initialize common boot status checker : %d", ret);
                goto main_destroy;
        }
 
-       /* Common */
-       ret = common_storage_checker_init();
+       /* Recovery */
+       ret = recovery_client_info_checker_init();
        if (ret < 0) {
-               _E("Failed to initialize common storage checker : %d", ret);
+               _E("Failed to initialize recovery client info checker : %d", ret);
                goto main_destroy;
        }
 
        /* Fota */
+       ret = fota_client_info_checker_init();
+       if (ret < 0) {
+               _E("Failed to initialize fota client info checker : %d", ret);
+               goto main_destroy;
+       }
+
        ret = fota_info_checker_init();
        if (ret < 0) {
                _E("Failed to initialize fota info checker : %d", ret);
@@ -55,21 +61,25 @@ int main(int argc, char *argv[])
        g_main_loop_run(mainloop);
 
 main_destroy:
-       /* Client */
-       ret = fota_client_info_checker_fini();
+       /* Common */
+       ret = common_storage_checker_fini();
        if (ret < 0)
-               _W("Failed to finalize fota client info checker : %d", ret);
+               _W("Failed to finalize common storage checker : %d", ret);
 
-       ret = common_client_status_checker_fini();
+       ret = common_boot_status_checker_fini();
        if (ret < 0)
-               _W("Failed to finalize client status checker : %d", ret);
+               _W("Failed to finalize common boot status checker : %d", ret);
 
-       /* Common */
-       ret = common_storage_checker_fini();
+       /* Recovery */
+       ret = recovery_client_info_checker_fini();
        if (ret < 0)
-               _W("Failed to finalize common storage checker : %d", ret);
+               _W("Failed to finalize recovery client info checker : %d", ret);
 
        /* Fota */
+       ret = fota_client_info_checker_fini();
+       if (ret < 0)
+               _W("Failed to finalize fota client info checker : %d", ret);
+
        ret = fota_info_checker_fini();
        if (ret < 0)
                _W("Failed to finalize fota info checker : %d", ret);
index 6121e6d2a2c57f5377ad082d0b6778cfcc34d51c..7dd9d017f5e3c52844bb090593eff9dafabd3269 100644 (file)
@@ -15,7 +15,7 @@ int recovery_client_controller_process_launch_request()
                return -1;
        }
 
-       if (!common_client_status_checker_is_success()) {
+       if (!common_boot_status_checker_is_success()) {
                _RLOGI("Failed to launch client, user session is unset, current top : %d", recovery_req_top);
                return -1;
        }
index e8868043f989e8176801e66bed4b87793541aafc..1b99e60ab9d0f54bef932278e9761b15db0ab5d3 100644 (file)
@@ -12,16 +12,16 @@ int recovery_client_info_checker_callback(pkgmgrinfo_appinfo_h handle, void *use
 {
        int ret = 0;
 
-       ret = common_client_info_checker_callback(handle, &recovery_client_app_id);
+       ret = common_client_info_checker_get_appid(handle, &recovery_client_app_id);
        if (ret < 0) {
-               _E("Common client info checker callback failed at recovery");
+               _RLOGE("Failed to get recovery app id from handle : %d", ret);
                return -1;
        }
 
-       _I("Success to find recovery client id : %s", recovery_client_app_id);
+       _RLOGI("Success to find recovery client id : %s", recovery_client_app_id);
        ret = recovery_client_controller_process_launch_request();
        if (ret < 0)
-               _E("Failed to process launch recovery client : %d", ret);
+               _RLOGE("Failed to process launch recovery client : %d", ret);
 
        return 0;
 }
@@ -30,9 +30,10 @@ int recovery_client_info_checker_init()
 {
        int ret = 0;
 
-       ret = common_client_info_checker_init(RECOVERY_CLIENT_METADATA_KEY, RECOVERY_CLIENT_METADATA_VALUE, recovery_client_info_checker_callback);
+       ret = common_client_info_checker_filter(RECOVERY_CLIENT_METADATA_KEY, RECOVERY_CLIENT_METADATA_VALUE, recovery_client_info_checker_callback);
        if (ret < 0) {
-               _E("Common client info checker failed, key : %s, value : %s", RECOVERY_CLIENT_METADATA_KEY, RECOVERY_CLIENT_METADATA_KEY);
+               _RLOGE("Failed to set recovery client app filter : %d, key : %s, value : %s",
+                       ret, RECOVERY_CLIENT_METADATA_KEY, RECOVERY_CLIENT_METADATA_KEY);
                return -1;
        }
 
index 868726470e0f1974a9d8f37ea88708afa301673e..6b8f81072794d19f8160d8d42c6cef9480714c75 100644 (file)
@@ -28,6 +28,8 @@ void recovery_storage_checker_plug(int storage_id, const char *mount_path)
                goto plug_destroy;
        }
 
+       _RLOGD("Ready to trigger plug event, try to add launch request key : %s, value : %s",
+                       RECOVERY_CLIENT_APP_CTRL_PLUG_KEY, image_path);
        ret = recovery_client_controller_add_launch_request_with_data(RECOVERY_CLIENT_APP_CTRL_PLUG_KEY, image_path);
        if (ret < 0) {
                _RLOGE("Failed to add launch request : %d, key : %s, value : %s",
@@ -44,6 +46,8 @@ void recovery_storage_checker_unplug(int storage_id, const char *mount_path)
        int ret = 0;
 
        if (storage_id == recovery_storage_id) {
+               _RLOGD("Ready to trigger unplug event, try to add launch request key : %s, value : %s",
+                               RECOVERY_CLIENT_APP_CTRL_UNPLUG_KEY, mount_path);
                ret = recovery_client_controller_add_launch_request_with_data(RECOVERY_CLIENT_APP_CTRL_UNPLUG_KEY, mount_path);
                if (ret < 0) {
                        _RLOGE("Failed to add recovery launch request : %d, key : %s, value : %s",
index 5fb8d1f6c03148915ef40412da821581c0fc95e1..f5973da54ca7c47b06b51ff7925c070bdcec61cf 100644 (file)
@@ -90,15 +90,16 @@ int fota_client_controller_add_launch_request_with_data(const char *, const char
 int common_storage_checker_init(void);
 int common_storage_checker_fini(void);
 
+int common_boot_status_checker_init(void);
+int common_boot_status_checker_fini(void);
+bool common_boot_status_checker_is_success(void);
+
 int common_client_controller_launch_req_data(const char*, req_data);
 int common_client_controller_generate_req_data(const char *, const char *, req_data *);
 
-int common_client_info_checker_callback(pkgmgrinfo_appinfo_h, char **);
-int common_client_info_checker_init(const char*, const char*, pkgmgrinfo_app_list_cb);
+int common_client_info_checker_get_appid(pkgmgrinfo_appinfo_h, char **);
+int common_client_info_checker_filter(const char*, const char*, pkgmgrinfo_app_list_cb);
 
-int common_client_status_checker_init(void);
-int common_client_status_checker_fini(void);
-bool common_client_status_checker_is_success(void);
 
 int dbus_manager_init(void);
 int dbus_manager_fini(void);