[Indicator] Fix for "Value of ringtone display wrong" 77/108777/1 accepted/tizen/3.0/wearable/20170105.232611 submit/tizen_3.0/20170105.140103
authoranirudha_r.c <anirudha_r.c@samsung.com>
Thu, 5 Jan 2017 13:44:14 +0000 (19:14 +0530)
committeranirudha_r.c <anirudha_r.c@samsung.com>
Thu, 5 Jan 2017 13:44:14 +0000 (19:14 +0530)
Change-Id: Iae18ef0f0a4758d9ed5ce1cbb0403eafe6dc1293

src/windicator_volume.c

index 19167d65dc0333fd9058acb9c00857993d5e12a1..4c9345ef07157fcf8c9ea399ab762dfd0a82f674 100755 (executable)
  * limitations under the License.
  */
 
+#define SETTING_TELEPHONY_PATH "tizen.org/feature/network.telephony"
+
 #include <efl_extension.h>
 #include <vconf.h>
 #include <vconf-keys.h>
 #include <sound_manager.h>
+#include <system_info.h>
 
 #include "windicator.h"
 #include "log.h"
@@ -122,19 +125,47 @@ void windicator_volume_icon_set_by_level(void *data)
                elm_object_signal_emit(ad->volume_small_icon, "volume.icon.mute", "img.volume.icon");
 }
 
+
+static int is_supported(const char *path)
+{
+       bool res;
+
+       if (system_info_get_platform_bool(path, &res) != SYSTEM_INFO_ERROR_NONE) {
+               _D("Fail to get TELEPHONY INFO");
+               return -1;
+       }
+
+       return res;
+}
+
+int is_telephony_enable(void)
+{
+       int ret = is_supported(SETTING_TELEPHONY_PATH);
+       _D("TELEPHONY = %d", ret);
+
+       if (ret > 1 || ret < 0) {
+       _D("Cannot decide telephony type!");
+       ret = 0;
+       }
+
+       return ret;
+}
+
+
 static int _current_device_volume_level_get(void* data)
 {
        int level = 1;
 
        int real_volume_index = 0;
-
-       //sound_manager_get_volume(SOUND_TYPE_MEDIA, &real_volume_index);
-       sound_manager_get_volume(SOUND_TYPE_RINGTONE, &real_volume_index);
-
-       _D("Setting - real vol: %d", real_volume_index);
+       if(is_telephony_enable()) {
+               sound_manager_get_volume(SOUND_TYPE_RINGTONE, &real_volume_index);
+               _D("ringtone volume value: %d", real_volume_index);
+       } else {
+               sound_manager_get_volume(SOUND_TYPE_MEDIA, &real_volume_index);
+               _D("media volume value: %d", real_volume_index);
+       }
 
        level = real_volume_index;
-
        _D("volume level : %d", level);
 
        return level;
@@ -156,7 +187,6 @@ windicator_error_e windicator_volume_update(void *data)
        return WINDICATOR_ERROR_OK;
 }
 
-
 static void _volume_status_changed_cb(sound_type_e type, unsigned int volume, void *data)
 {
        _D("");