modules/information: vconf removed from earphone. 75/58975/8
authorRadoslaw Czerski <r.czerski@samsung.com>
Tue, 9 Feb 2016 10:09:30 +0000 (11:09 +0100)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Tue, 9 Feb 2016 12:45:28 +0000 (04:45 -0800)
Vconf removed from earphone.c. Runtime-info used instead.

Change-Id: Iadbd51c0c21cfd507e7567739ba7ac4556f82358
Signed-off-by: Radoslaw Czerski <r.czerski@samsung.com>
src/modules/information/earphone.c

index 240cf8c..7f8058f 100644 (file)
  *
  */
 
-
-
 #include <stdio.h>
 #include <stdlib.h>
-#include <vconf.h>
-#include <notification.h>
+#include <runtime_info.h>
 #include "common.h"
 #include "indicator.h"
 #include "main.h"
 #include "modules.h"
 #include "icon.h"
+#include "log.h"
 
 #define ICON_PRIORITY  INDICATOR_PRIORITY_NOTI_2
 #define MODULE_NAME            "earphone"
@@ -66,15 +64,10 @@ static void set_app_state(void* data)
        earphone.ad = data;
 }
 
-
-
 static void show_image_icon(void)
 {
-
        if(bShown == 1)
-       {
                return;
-       }
 
        earphone.img_obj.data = icon_path[0];
        icon_show(&earphone);
@@ -82,8 +75,6 @@ static void show_image_icon(void)
        bShown = 1;
 }
 
-
-
 static void hide_image_icon(void)
 {
        icon_hide(&earphone);
@@ -91,56 +82,47 @@ static void hide_image_icon(void)
        bShown = 0;
 }
 
-
-
-static void indicator_earphone_change_cb(keynode_t *node, void *data)
+void check_jack_port(void *data)
 {
-       int status = 0;
+       bool is_jack_connected;
+       bool is_tv_out_connected;
        int ret;
 
        retif(data == NULL, , "Invalid parameter!");
 
-       if(icon_get_update_flag()==0)
-       {
+       if(icon_get_update_flag()==0) {
                updated_while_lcd_off = 1;
                return;
        }
        updated_while_lcd_off = 0;
+       ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_AUDIO_JACK_CONNECTED, &is_jack_connected);
+       retm_if(ret != RUNTIME_INFO_ERROR_NONE, "runtime_info_get_value_bool failed[%s]", get_error_message(ret));
 
-       ret = vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &status);
-       if (ret == FAIL) {
-               return;
-       }
+       ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, &is_tv_out_connected);
+       retm_if(ret != RUNTIME_INFO_ERROR_NONE, "runtime_info_get_value_bool failed[%s]", get_error_message(ret));
 
-       switch (status) {
-       case VCONFKEY_SYSMAN_EARJACK_3WIRE:
-       case VCONFKEY_SYSMAN_EARJACK_4WIRE:
-       case VCONFKEY_SYSMAN_EARJACK_TVOUT:
+       if (is_jack_connected || is_tv_out_connected) {
                DBG("Earphone connected");
                show_image_icon();
-               break;
-
-       default:
-               hide_image_icon();
-               break;
        }
+       else
+               hide_image_icon();
 }
 
-
+void indicator_earphone_change_cb(runtime_info_key_e key, void *data)
+{
+       check_jack_port(data);
+}
 
 static int wake_up_cb(void *data)
 {
-       if(updated_while_lcd_off==0)
-       {
+       if(updated_while_lcd_off == 0)
                return OK;
-       }
 
-       indicator_earphone_change_cb(NULL, data);
+       check_jack_port(data);
        return OK;
 }
 
-
-
 static int register_earphone_module(void *data)
 {
        int ret;
@@ -149,22 +131,26 @@ static int register_earphone_module(void *data)
 
        set_app_state(data);
 
-       ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_EARJACK,
-                                      indicator_earphone_change_cb, data);
+       ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_AUDIO_JACK_CONNECTED, indicator_earphone_change_cb, data);
+       retvm_if(ret != RUNTIME_INFO_ERROR_NONE, FAIL, "runtime_info_set_changed_cb failed[%s]", get_error_message(ret));
+
+       ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, indicator_earphone_change_cb, data);
+       retvm_if(ret != RUNTIME_INFO_ERROR_NONE, FAIL, "runtime_info_set_changed_cb failed[%s]", get_error_message(ret));
 
-       indicator_earphone_change_cb(NULL, data);
+       check_jack_port(data);
 
        return ret;
 }
 
-
-
 static int unregister_earphone_module(void)
 {
        int ret;
 
-       ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_EARJACK,
-                                      indicator_earphone_change_cb);
+       ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_AUDIO_JACK_CONNECTED);
+       retvm_if(ret != RUNTIME_INFO_ERROR_NONE, FAIL, "runtime_info_unset_changed_cb failed[%s]", get_error_message(ret));
+
+       ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_TV_OUT_CONNECTED);
+       retvm_if(ret != RUNTIME_INFO_ERROR_NONE, FAIL, "runtime_info_unset_changed_cb failed[%s]", get_error_message(ret));
 
        return ret;
 }