PATTERN "*_doc.h" EXCLUDE
PATTERN "*.h")
-INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/core/ DESTINATION include/${PROJECT_NAME}/core
- FILES_MATCHING
- PATTERN "*.h")
-
-INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ DESTINATION include/${PROJECT_NAME}/shared
- FILES_MATCHING
- PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/core/ DESTINATION include/${PROJECT_NAME}/core FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/shared/ DESTINATION include/${PROJECT_NAME}/shared FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/extcon/ DESTINATION include/${PROJECT_NAME}/extcon FILES_MATCHING PATTERN "*.h")
IF(BATTERY_MODULE STREQUAL on)
INSTALL_CONF(conf battery)
%{_includedir}/deviced/*.h
%{_includedir}/deviced/core/*.h
%{_includedir}/deviced/shared/*.h
+%{_includedir}/deviced/extcon/*.h
%{_libdir}/libdeviced.so
%{_libdir}/pkgconfig/deviced.pc
#include "apps/apps.h"
#include "power-supply.h"
#include "battery.h"
+#include "extcon/extcon.h"
#ifndef VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL
#define VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL "db/setting/blockmode_wearable"
if (battery.online > POWER_SUPPLY_TYPE_BATTERY &&
online_status == VCONFKEY_SYSMAN_CHARGER_DISCONNECTED) {
online_status = VCONFKEY_SYSMAN_CHARGER_CONNECTED;
+ extcon_update_count(EXTCON_TA, 1);
check_power_supply(online_status);
charger_state_send_system_event(CHARGE_STATUS_CONNECTED);
if (old_battery.charge_status != battery.charge_status)
battery.capacity = atoi(env_value);
}
+static void update_capacity_full(void)
+{
+ static int old;
+ int delta;
+
+ if (battery.online <= POWER_SUPPLY_TYPE_BATTERY ||
+ old == 0 ||
+ old >= battery.capacity) {
+ old = battery.capacity;
+ return;
+ }
+ delta = battery.capacity - old;
+ old = battery.capacity;
+ extcon_update_count(EXTCON_BATTERY_FULL, delta);
+}
+
+static void update_battery_cycle(void)
+{
+ static int first = 1;
+ static int old;
+ int delta;
+
+ if (first) {
+ first = 0;
+ extcon_update_count(EXTCON_BATTERY_CYCLE, 0);
+ return;
+ }
+
+ if (battery.online > POWER_SUPPLY_TYPE_BATTERY ||
+ old == 0 ||
+ old <= battery.capacity) {
+ old = battery.capacity;
+ return;
+ }
+ delta = old - battery.capacity;
+ old = battery.capacity;
+ extcon_update_count(EXTCON_BATTERY_CYCLE, delta);
+}
+
static void process_power_supply(void *data)
{
bool broadcasted = true;
device_notify(DEVICE_NOTIFIER_POWER_SUPPLY, NULL);
if (old_battery.charge_now != battery.charge_now) {
- device_notify(DEVICE_NOTIFIER_BATTERY_CHARGING, &battery.charge_now);
+ device_notify(DEVICE_NOTIFIER_BATTERY_CHARGING, &battery.charge_now);
old_battery.charge_now = battery.charge_now;
}
+ update_capacity_full();
+ update_battery_cycle();
if (lock == 0) {
if (disp_plgn.pm_unlock_internal)
disp_plgn.pm_unlock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN);
DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS,
DEVICE_NOTIFIER_ULTRAPOWERSAVING,
DEVICE_NOTIFIER_CRITICAL_LOG,
+ DEVICE_NOTIFIER_EXTCON_COUNT,
DEVICE_NOTIFIER_MAX,
};
if (status != EARJACK_DICONNECTED) {
if (disp_plgn.pm_change_internal)
disp_plgn.pm_change_internal(INTERNAL_LOCK_EARJACK, LCD_NORMAL);
+
+ extcon_update_count(EXTCON_EARJACK, 1);
}
return 0;
--- /dev/null
+/*
+ * deviced
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __EXTCON_COUNT_H__
+#define __EXTCON_COUNT_H__
+
+#include "core/common.h"
+
+typedef enum {
+ EXTCON_TA = 0,
+ EXTCON_EARJACK,
+ EXTCON_BATTERY_FULL,
+ EXTCON_BATTERY_CYCLE,
+} extcon_index_type_e;
+
+struct extcon_notifier {
+ extcon_index_type_e index;
+ int count;
+};
+
+#endif /* __EXTCON_COUNT_H__ */
#define BUF_MAX 256
static dd_list *extcon_list;
-
static struct external_connection_device *extcon_dev;
void add_extcon(struct extcon_ops *dev)
return dev->status;
}
+void extcon_update_count(extcon_index_type_e index, unsigned long count)
+{
+ struct extcon_notifier extcon;
+ extcon.index = index;
+ extcon.count = count;
+
+ device_notify(DEVICE_NOTIFIER_EXTCON_COUNT, (void *)&extcon);
+}
+
static int extcon_update(const char *name, const char *value)
{
struct extcon_ops *dev;
#include "core/common.h"
#include <hw/external_connection.h>
+#include "extcon-count.h"
/**
* Extcon cable name is shared with kernel extcon class.
int extcon_get_status(const char *name);
int extcon_enable_device(const char *name);
int extcon_disable_device(const char *name);
+void extcon_update_count(extcon_index_type_e index, unsigned long count);
#endif /* __EXTCON_H__ */