char* alarm_data = NULL;
int res;
+ int battery_percentage = 0;
+ bool battery_charging = false;
// operation
int ret = app_control_get_operation(app_control, &operation);
LOGD("alarm data : %s", alarm_data);
- int battery_percentage = 0;
- int ret = device_battery_get_percent(&battery_percentage);
- if (ret == DEVICE_ERROR_NONE) {
- LOGD("battery percent : %d", battery_percentage);
- if (battery_percentage >= MINIMUM_BATTERY) {
- request_sticker_data("auto", "arsticker", "input");
- request_sticker_data("auto", "bitmoji", "input");
- }
- else {
- LOGD("No sync request due to insufficient battery");
- }
+ int ret = device_battery_is_charging(&battery_charging);
+ if (ret != DEVICE_ERROR_NONE) {
+ LOGW("No sync. Can't get battery charging status");
+ goto cleanup;
+ }
+
+ if (!battery_charging) {
+ LOGI("No sync due to no battery charging status");
+ goto cleanup;
+ }
+
+ ret = device_battery_get_percent(&battery_percentage);
+ if (ret != DEVICE_ERROR_NONE) {
+ LOGW("No sync. Failed to get battery percent. error : %d", ret);
+ goto cleanup;
+ }
+
+ LOGI("battery percent : %d", battery_percentage);
+ if (battery_percentage >= MINIMUM_BATTERY) {
+ request_sticker_data("auto", "arsticker", "input");
+ request_sticker_data("auto", "bitmoji", "input");
}
else {
- LOGW("Failed to get battery percent. error : %d", ret);
+ LOGI("No sync due to insufficient battery");
}
goto cleanup;