From 45e104700083d1a1a12e750798ad52846a70704f Mon Sep 17 00:00:00 2001 From: taeyoung Date: Fri, 5 Aug 2016 09:42:26 +0900 Subject: [PATCH] common: remove unused battery codes - Old battery apis are not used any more. For the battery information, battery.h needs to be used. Change-Id: Id6f23122824c0d327580c4e0f507d629c3afc9c8 Signed-off-by: taeyoung --- include/device.h | 296 ------------------------------------------------------- src/device.c | 159 ------------------------------ 2 files changed, 455 deletions(-) diff --git a/include/device.h b/include/device.h index 59805a7..d2e31da 100755 --- a/include/device.h +++ b/include/device.h @@ -34,302 +34,6 @@ extern "C" { */ /** - * @brief Enumerations of the battery warning status - */ -typedef enum { - DEVICE_BATTERY_WARN_EMPTY, /**< The battery goes empty. Prepare for the safe termination of the application, because the device starts a shutdown process soon after entering this level. */ - DEVICE_BATTERY_WARN_CRITICAL, /**< The battery charge is at a critical state. You may have to stop using multimedia features, because they are not guaranteed to work correctly at this battery status. */ - DEVICE_BATTERY_WARN_LOW, /**< The battery has little charge left. */ - DEVICE_BATTERY_WARN_NORMAL, /**< The battery status is not to be careful. */ - DEVICE_BATTERY_WARN_FULL, /**< The battery status is full. */ -} device_battery_warn_e; - -/** - * @brief Enumerations of the battery remaining time type - */ -typedef enum { - DEVICE_BATTERY_REMAINING_TIME_TO_FULLY_CHARGED, - DEVICE_BATTERY_REMAINING_TIME_TO_DISCHARGED -} device_battery_remaining_time_type_e; - -/** - * @brief Enumerations of the battery level status - */ -typedef enum { - DEVICE_BATTERY_LEVEL_EMPTY = 0, /**< The battery goes empty. Prepare for the safe termination of the application, because the device starts a shutdown process soon after entering this level. */ - DEVICE_BATTERY_LEVEL_CRITICAL, /**< The battery charge is at a critical state. You may have to stop using multimedia features, because they are not guaranteed to work correctly at this battery status. */ - DEVICE_BATTERY_LEVEL_LOW, /**< The battery has little charge left. */ - DEVICE_BATTERY_LEVEL_HIGH, /**< The battery status is not to be careful. */ - DEVICE_BATTERY_LEVEL_FULL, /**< The battery status is full. */ -} device_battery_level_e; - - -/** - * @brief Structure of the time information system spent, measured in units of USER_HZ - */ -typedef struct { - unsigned long long total; - unsigned long long user; - unsigned long long nice; - unsigned long long system; - unsigned long long idle; - unsigned long long iowait; - unsigned long long irq; - unsigned long long softirq; -} device_system_time_s; - -/** - * @} -*/ - - /** - * @addtogroup CAPI_SYSTEM_DEVICE_MODULE - * @{ - */ - -/** - * @brief Called when an battery charge percentage changed - * - * @param[in] percent The remaining battery charge percentage (0 ~ 100) - * @param[in] user_data The user data passed from the callback registration function - * - */ -typedef void (*device_battery_cb)(int percent, void *user_data); - -/** - * @brief Called when the device warn about the battery status. - * - * @param[in] status The battery warning status - * @param[in] user_data The user data passed from the callback registration function - * - */ -typedef void (*device_battery_warn_cb)(device_battery_warn_e status, void *user_data); - -/** - * @brief This callback take remained time for fully charged or discharged. - * - * @param[in] time The battery remaining seconds to fully charged or discharged - * @param[in] user_data The user data passed from the callback registration function - * - */ -typedef void (*device_battery_remaining_time_changed_cb)(int time, void* user_data); - -/** - * @brief Called when an battery level changed - * - * @param[in] status The remaining battery level (empty[0~1] critical[2~5] low[6~15] high[16~94] full[95~100]) - * @param[in] user_data The user data passed from the callback registration function - * - */ -typedef void (*device_battery_level_cb)(device_battery_level_e status, void *user_data); - -/** - * @brief Gets the battery warning status. - * - * @param[out] status The battery warning status. - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - * - * @see device_battery_status_e - * @see device_battery_status_set_cb() - */ -int device_battery_get_warning_status(device_battery_warn_e *status); - -/** - * @brief Set callback to be observing battery warning. - * - * @param[in] callback The callback function to set - * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - * - * @see device_battery_status_e - * @see device_battery_get_status() - */ -int device_battery_warning_set_cb(device_battery_warn_cb callback, void* user_data); - -/** - * @brief Unset battery warning callback function. - * - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - */ -int device_battery_warning_unset_cb(void); - -/** - * @brief Gets the battery charge percentage. - * @details It returns integer value from 0 to 100 that indicates remaining battery charge - * as a percentage of the maximum level. - * @remarks In order to be notified when the battery state changes, use system_info_set_changed_cb(). - * - * @param[out] percent The remaining battery charge percentage (0 ~ 100) - * - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - * - * @see device_battery_is_full() - * @see device_battery_get_detail() - * @see device_battery_set_cb() - */ -int device_battery_get_percent(int *percent); - -/** - * @brief Gets the battery detail charge as a per ten thousand. - * @details It return integer value from 0 to 10000 that indicates remaining battery charge as a per ten thousand of the maximum level. - * @remarks this function return #DEVICE_ERROR_NOT_SUPPORTED when device can not be supported detail battery information. - * - * @param[out] detail The remaining battery charge as a per ten thousand. (0 ~ 10000) - * - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device - * - * @see device_battery_is_full() - * @see device_battery_get_percent() - * @see device_battery_set_cb() - */ -int device_battery_get_detail(int *detail); - -/** - * @brief Get charging state - * - * @param[out] charging The battery charging state. - * - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - * - */ -int device_battery_is_charging(bool *charging); - -/** - * @brief Set callback to be observing battery charge percentage. - * - * @param[in] callback The callback function to set - * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - */ -int device_battery_set_cb(device_battery_cb callback, void* user_data); - -/** - * @brief Unset battery charge percentage callback function. - * - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - */ -int device_battery_unset_cb(void); - -/** - * @brief Checks whether the battery is fully charged. - * @remarks In order to be notified when the battery state changes, use system_info_set_changed_cb(). - * - * @param[out] full @c true when the battery is fully charged, otherwise @c false. - * - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - * - * @see device_battery_get_percent() - * @see system_info_set_changed_cb() - * @see system_info_get_value_int(SYSTEM_INFO_KEY_BATTERY_PERCENTAGE, ...) - * @see system_info_get_value_int(SYSTEM_INFO_KEY_BATTERY_CHARGE, ...) - */ -int device_battery_is_full(bool *full); - -/** - * @brief Retrive the remaining time for fully charged or discharged. - * - * @remarks @a time will be retrieved the time to fully charged or discharged depending on @a type - * - * @param[in] type The type of battery remaining time - * @param[out] time battery remaining seconds to fully charged or discharged - - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - * - * @see device_battery_set_remaining_time_changed_cb() - * @see device_battery_unset_remaining_time_changed_cb() - */ -int device_battery_get_remaining_time(device_battery_remaining_time_type_e type, int* time); - -/** - * @brief Set callback to be return battery remaining time to fully charged or discharged. - * - * @remarks @a callback will be retrieved the time to fully charged or discharged depending on @a type - * - * @param[in] callback The callback function to set - * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - * - */ -int device_battery_set_remaining_time_changed_cb( - device_battery_remaining_time_type_e type, - device_battery_remaining_time_changed_cb callback, void* user_data); - -/** - * @brief Unset battery remaining time callback function. - * - * @param[in] type The type of battery remaining time - * - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - */ -int device_battery_unset_remaining_time_changed_cb(device_battery_remaining_time_type_e type); - -/** - * @brief Gets the battery level status. - * - * @param[out] status The battery level status. - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - * - * @see device_battery_level_e - * @see device_battery_level_set_cb() - */ -int device_battery_get_level_status(device_battery_level_e *status); - -/** - * @brief Set/Unset callback to be observing battery level. - * - * @param[in] callback The callback function to set, if you input NULL, observing is disabled - * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value. - * @retval #DEVICE_ERROR_NONE Successful - * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed - * - * @see device_battery_level_e - * @see device_battery_get_level_status() - */ -int device_battery_level_set_cb(device_battery_level_cb callback, void* user_data); - -/** * @brief Gets the number of display devices. * * @return The number of display devices that the device provides. diff --git a/src/device.c b/src/device.c index e9abdd9..2b97d6b 100644 --- a/src/device.c +++ b/src/device.c @@ -65,163 +65,4 @@ int device_set_brightness_to_settings(int disp_idx, int new_value) { return device_display_set_brightness(disp_idx, new_value); } - -int device_battery_get_detail(int *percent) -{ - _E("Deprecated api. Use device_battery_get_percent()"); - return DEVICE_ERROR_NOT_SUPPORTED; -} - -int device_battery_is_full(bool* full) -{ - device_battery_level_e status; - int ret; - - if (full == NULL) - return DEVICE_ERROR_INVALID_PARAMETER; - - ret = device_battery_get_level_status(&status); - CHECK_ERR(ret); - - if (status == DEVICE_BATTERY_LEVEL_FULL) - *full = true; - else - *full = false; - - return DEVICE_ERROR_NONE; -} - -int device_battery_get_remaining_time(device_battery_remaining_time_type_e type, int *time) -{ - _E("Deprecated api."); - return DEVICE_ERROR_NOT_SUPPORTED; -} - -int device_battery_set_remaining_time_changed_cb(device_battery_remaining_time_type_e type, - device_battery_remaining_time_changed_cb callback, void* user_data) -{ - _E("Deprecated api."); - return DEVICE_ERROR_NOT_SUPPORTED; -} - -int device_battery_unset_remaining_time_changed_cb(device_battery_remaining_time_type_e type) -{ - _E("Deprecated api."); - return DEVICE_ERROR_NOT_SUPPORTED; -} - -static device_battery_cb changed_callback = NULL; -static void* changed_callback_user_data = NULL; - -static void battery_changed_inside_cb(keynode_t* key, void* user_data) -{ - const char* keyname = vconf_keynode_get_name(key); - - if (keyname != NULL && changed_callback != NULL && strcmp(keyname, VCONFKEY_SYSMAN_BATTERY_CAPACITY) == 0) { - int percent = 0; - if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &percent) == 0) - changed_callback(percent, changed_callback_user_data); - } -} - -int device_battery_set_cb(device_battery_cb callback, void* user_data) -{ - /* VCONFKEY_SYSMAN_BATTERY_CAPACITY */ - int err; - if (callback == NULL) - return DEVICE_ERROR_INVALID_PARAMETER; - - changed_callback = callback; - changed_callback_user_data = user_data; - - err = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, battery_changed_inside_cb, NULL); - if (err < 0) - return DEVICE_ERROR_INVALID_PARAMETER; - - return DEVICE_ERROR_NONE; -} - -int device_battery_unset_cb(void) -{ - int err = vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, battery_changed_inside_cb); - if (err < 0) - return DEVICE_ERROR_OPERATION_FAILED; - - changed_callback = NULL; - changed_callback_user_data = NULL; - - return DEVICE_ERROR_NONE; -} - -int device_battery_get_warning_status(device_battery_warn_e *status) -{ - if (status == NULL) - return DEVICE_ERROR_INVALID_PARAMETER; - - int value, err; - - err = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &value); - if (err < 0) - return DEVICE_ERROR_OPERATION_FAILED; - - if (value == VCONFKEY_SYSMAN_BAT_POWER_OFF) - *status = DEVICE_BATTERY_WARN_EMPTY; - else if (value == VCONFKEY_SYSMAN_BAT_CRITICAL_LOW) - *status = DEVICE_BATTERY_WARN_CRITICAL; - else if (value == VCONFKEY_SYSMAN_BAT_WARNING_LOW) - *status = DEVICE_BATTERY_WARN_LOW; - else if (value == VCONFKEY_SYSMAN_BAT_NORMAL) - *status = DEVICE_BATTERY_WARN_NORMAL; - else if (value == VCONFKEY_SYSMAN_BAT_FULL) - *status = DEVICE_BATTERY_WARN_FULL; - else - return DEVICE_ERROR_OPERATION_FAILED; - - - return DEVICE_ERROR_NONE; -} - -static device_battery_warn_cb warn_changed_callback = NULL; -static void* warn_changed_callback_user_data = NULL; - -static void battery_warn_changed_inside_cb(keynode_t* key, void* user_data) -{ - const char* keyname = vconf_keynode_get_name(key); - - if (keyname != NULL && warn_changed_callback != NULL && strcmp(keyname, VCONFKEY_SYSMAN_BATTERY_STATUS_LOW) == 0) { - int bat_state = 0; - if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state) == 0) - warn_changed_callback(bat_state-1, warn_changed_callback_user_data); - } -} - -int device_battery_warning_set_cb(device_battery_warn_cb callback, void* user_data) -{ - /* VCONFKEY_SYSMAN_BATTERY_STATUS_LOW */ - int err; - - if (callback == NULL) - return DEVICE_ERROR_INVALID_PARAMETER; - - warn_changed_callback = callback; - warn_changed_callback_user_data = user_data; - - err = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, battery_warn_changed_inside_cb, NULL); - if (err < 0) - return DEVICE_ERROR_INVALID_PARAMETER; - - return DEVICE_ERROR_NONE; -} - -int device_battery_warning_unset_cb(void) -{ - int err = vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, battery_warn_changed_inside_cb); - if (err < 0) - return DEVICE_ERROR_OPERATION_FAILED; - - warn_changed_callback = NULL; - warn_changed_callback_user_data = NULL; - - return DEVICE_ERROR_NONE; -} //LCOV_EXCL_STOP -- 2.7.4