DEVICE_BATTERY_PROPERTY_CAPACITY, /**< The battery capacity (0 ~ 100 %) */
DEVICE_BATTERY_PROPERTY_CURRENT_NOW, /**< The battery current (uA) */
DEVICE_BATTERY_PROPERTY_CURRENT_AVERAGE, /**< The average battery current (uA) */
+ DEVICE_BATTERY_PROPERTY_VOLTAGE_NOW, /**< The battery voltage (uV) (Since 5.0) */
+ DEVICE_BATTERY_PROPERTY_VOLTAGE_AVERAGE, /**< The average battery voltage (uV) (Since 5.0) */
+ DEVICE_BATTERY_PROPERTY_TEMPERATURE, /**< The battery temperature (`C) (Since 5.0) */
} device_battery_property_e;
* @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
* @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
*/
int device_battery_get_percent(int *percent);
* @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_add_callback
* @see device_remove_callback
* @see #DEVICE_CALLBACK_BATTERY_CHARGING
* @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_level_e
* @see device_add_callback
* @see device_remove_callback
* @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
*/
int device_battery_get_health(device_battery_health_e *health);
* @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
*/
int device_battery_get_power_source(device_battery_power_source_e *source);
* @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
*/
int device_battery_get_property(device_battery_property_e property, int *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
*/
int device_battery_get_status(device_battery_status_e *status);
#define METHOD_GET_INFO "GetBatteryInfo"
#define INFO_MAX 32
+#define BATTERY_FEATURE "http://tizen.org/feature/battery"
struct battery_info {
char status[INFO_MAX];
int capacity;
int current_now;
int current_average;
+ int voltage_now;
+ int voltage_average;
+ int temperature;
};
+static int is_battery_supported(void)
+{
+ int ret;
+ bool battery_avail;
+
+ ret = system_info_get_platform_bool(BATTERY_FEATURE, &battery_avail);
+ if (ret < 0) {
+ _E("Failed to get value of battery feature");
+ return false;
+ } else if (ret == 0 && !battery_avail) {
+ _D("Battery is not supported");
+ return false;
+ } else
+ return true;
+}
+
+
int device_battery_get_percent(int *percent)
{
int ret;
if (!percent)
return DEVICE_ERROR_INVALID_PARAMETER;
+ ret = is_battery_supported();
+ if (!ret)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
ret = dbus_method_sync(DEVICED_BUS_NAME,
DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY,
METHOD_GET_PERCENT, NULL, NULL);
if (!charging)
return DEVICE_ERROR_INVALID_PARAMETER;
+ ret = is_battery_supported();
+ if (!ret)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &val);
/* regard not supported as disconnected */
if (val == -ENOTSUP)
if (!status)
return DEVICE_ERROR_INVALID_PARAMETER;
+ ret = is_battery_supported();
+ if (!ret)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_LEVEL_STATUS, &val);
if (ret < 0)
return DEVICE_ERROR_OPERATION_FAILED;
int capacity;
int current_now;
int current_average;
+ int voltage_now;
+ int voltage_average;
+ int temperature;
if (!info)
return DEVICE_ERROR_INVALID_PARAMETER;
else if (ret < 0)
return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
- g_variant_get(output, "(isssiiiii)", &ret,
+ g_variant_get(output, "(isssiiiiiiii)", &ret,
&status, &health, &power_source,
&online, &present, &capacity,
- ¤t_now, ¤t_average);
+ ¤t_now, ¤t_average, &voltage_now,
+ &voltage_average, &temperature);
if (ret < 0) {
//LCOV_EXCL_START System Error
info->capacity = capacity;
info->current_now = current_now;
info->current_average = current_average;
+ info->voltage_now = voltage_now;
+ info->voltage_average = voltage_average;
+ info->temperature = temperature;
ret = DEVICE_ERROR_NONE;
if (!health)
return DEVICE_ERROR_INVALID_PARAMETER;
+ ret = is_battery_supported();
+ if (!ret)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
ret = device_battery_get_info(&info);
if (ret != DEVICE_ERROR_NONE) {
_E("Failed to get battery info (%d)", ret); //LCOV_EXCL_LINE Logs
if (!source)
return DEVICE_ERROR_INVALID_PARAMETER;
+ ret = is_battery_supported();
+ if (!ret)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
ret = device_battery_get_info(&info);
if (ret != DEVICE_ERROR_NONE) {
_E("Failed to get battery info (%d)", ret); //LCOV_EXCL_LINE Logs
if (!val)
return DEVICE_ERROR_INVALID_PARAMETER;
+ ret = is_battery_supported();
+ if (!ret)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
ret = device_battery_get_info(&info);
if (ret != DEVICE_ERROR_NONE) {
_E("Failed to get battery info (%d)", ret); //LCOV_EXCL_LINE Logs
case DEVICE_BATTERY_PROPERTY_CURRENT_AVERAGE:
*val = info.current_average;
break;
+ case DEVICE_BATTERY_PROPERTY_VOLTAGE_NOW:
+ *val = info.voltage_now;
+ break;
+ case DEVICE_BATTERY_PROPERTY_VOLTAGE_AVERAGE:
+ *val = info.voltage_average;
+ break;
+ case DEVICE_BATTERY_PROPERTY_TEMPERATURE:
+ *val = info.temperature;
+ break;
+
default:
return DEVICE_ERROR_INVALID_PARAMETER;
}
if (!status)
return DEVICE_ERROR_INVALID_PARAMETER;
+ ret = is_battery_supported();
+ if (!ret)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
ret = device_battery_get_info(&info);
if (ret != DEVICE_ERROR_NONE) {
_E("Failed to get battery info (%d)", ret); //LCOV_EXCL_LINE Logs